Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / desktop_window_tree_host_win.cc
index 2fc499b..45f1a86 100644 (file)
@@ -35,7 +35,6 @@
 #include "ui/views/widget/widget_hwnd_utils.h"
 #include "ui/views/win/fullscreen_handler.h"
 #include "ui/views/win/hwnd_message_handler.h"
-#include "ui/views/window/native_frame_view.h"
 #include "ui/wm/core/compound_event_filter.h"
 #include "ui/wm/core/input_method_event_filter.h"
 #include "ui/wm/core/window_animations.h"
@@ -366,7 +365,7 @@ void DesktopWindowTreeHostWin::SetVisibilityChangedAnimationsEnabled(
 }
 
 bool DesktopWindowTreeHostWin::ShouldUseNativeFrame() const {
-  return ui::win::IsAeroGlassEnabled();
+  return IsTranslucentWindowOpacitySupported();
 }
 
 bool DesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const {
@@ -382,11 +381,6 @@ void DesktopWindowTreeHostWin::FrameTypeChanged() {
   SetWindowTransparency();
 }
 
-NonClientFrameView* DesktopWindowTreeHostWin::CreateNonClientFrameView() {
-  return GetWidget()->ShouldUseNativeFrame() ?
-      new NativeFrameView(GetWidget()) : NULL;
-}
-
 void DesktopWindowTreeHostWin::SetFullscreen(bool fullscreen) {
   message_handler_->fullscreen_handler()->SetFullscreen(fullscreen);
   // TODO(sky): workaround for ScopedFullscreenVisibility showing window
@@ -419,7 +413,7 @@ void DesktopWindowTreeHostWin::FlashFrame(bool flash_frame) {
   message_handler_->FlashFrame(flash_frame);
 }
 
-void DesktopWindowTreeHostWin::OnRootViewLayout() const {
+void DesktopWindowTreeHostWin::OnRootViewLayout() {
 }
 
 void DesktopWindowTreeHostWin::OnNativeWidgetFocus() {
@@ -433,9 +427,17 @@ bool DesktopWindowTreeHostWin::IsAnimatingClosed() const {
   return pending_close_;
 }
 
+bool DesktopWindowTreeHostWin::IsTranslucentWindowOpacitySupported() const {
+  return ui::win::IsAeroGlassEnabled();
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // DesktopWindowTreeHostWin, WindowTreeHost implementation:
 
+ui::EventSource* DesktopWindowTreeHostWin::GetEventSource() {
+  return this;
+}
+
 gfx::AcceleratedWidget DesktopWindowTreeHostWin::GetAcceleratedWidget() {
   return message_handler_->hwnd();
 }
@@ -449,10 +451,6 @@ void DesktopWindowTreeHostWin::Hide() {
     message_handler_->Hide();
 }
 
-void DesktopWindowTreeHostWin::ToggleFullScreen() {
-  SetWindowTransparency();
-}
-
 // GetBounds and SetBounds work in pixel coordinates, whereas other get/set
 // methods work in DIP.
 
@@ -492,19 +490,7 @@ void DesktopWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
   window_enlargement_ =
       gfx::Vector2d(new_expanded.width() - expanded.width(),
                     new_expanded.height() - expanded.height());
-  message_handler_->SetBounds(new_expanded);
-
-  // The client area size may have changed even though the window bounds have
-  // not, if the window bounds were expanded to 64 pixels both times.
-  if (old_hwnd_size == new_expanded.size() && old_content_size != bounds.size())
-    HandleClientSizeChanged(new_expanded.size());
-}
-
-gfx::Insets DesktopWindowTreeHostWin::GetInsets() const {
-  return gfx::Insets();
-}
-
-void DesktopWindowTreeHostWin::SetInsets(const gfx::Insets& insets) {
+  message_handler_->SetBounds(new_expanded, old_content_size != bounds.size());
 }
 
 gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const {
@@ -519,38 +505,10 @@ void DesktopWindowTreeHostWin::ReleaseCapture() {
   message_handler_->ReleaseCapture();
 }
 
-bool DesktopWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) {
-  aura::client::CursorClient* cursor_client =
-      aura::client::GetCursorClient(window());
-  if (cursor_client && !cursor_client->IsMouseEventsEnabled()) {
-    *location_return = gfx::Point(0, 0);
-    return false;
-  }
-  POINT pt = {0};
-  ::GetCursorPos(&pt);
-  *location_return =
-      gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y));
-  return true;
-}
-
-bool DesktopWindowTreeHostWin::ConfineCursorToRootWindow() {
-  RECT window_rect = window()->GetBoundsInScreen().ToRECT();
-  ::ClipCursor(&window_rect);
-  return true;
-}
-
-void DesktopWindowTreeHostWin::UnConfineCursor() {
-  ::ClipCursor(NULL);
-}
-
 void DesktopWindowTreeHostWin::PostNativeEvent(
     const base::NativeEvent& native_event) {
 }
 
-void DesktopWindowTreeHostWin::OnDeviceScaleFactorChanged(
-    float device_scale_factor) {
-}
-
 void DesktopWindowTreeHostWin::SetCursorNative(gfx::NativeCursor cursor) {
   ui::CursorLoaderWin cursor_loader;
   cursor_loader.SetPlatformCursor(&cursor);
@@ -637,28 +595,12 @@ bool DesktopWindowTreeHostWin::WidgetSizeIsClientSize() const {
   return IsMaximized() || (widget && widget->ShouldUseNativeFrame());
 }
 
-bool DesktopWindowTreeHostWin::CanSaveFocus() const {
-  return GetWidget()->is_top_level();
-}
-
-void DesktopWindowTreeHostWin::SaveFocusOnDeactivate() {
-  GetWidget()->GetFocusManager()->StoreFocusedView(true);
-}
-
-void DesktopWindowTreeHostWin::RestoreFocusOnActivate() {
-  RestoreFocusOnEnable();
-}
-
-void DesktopWindowTreeHostWin::RestoreFocusOnEnable() {
-  GetWidget()->GetFocusManager()->RestoreFocusedView();
-}
-
 bool DesktopWindowTreeHostWin::IsModal() const {
   return native_widget_delegate_->IsModal();
 }
 
 int DesktopWindowTreeHostWin::GetInitialShowState() const {
-  return SW_SHOWNORMAL;
+  return CanActivate() ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
 }
 
 bool DesktopWindowTreeHostWin::WillProcessWorkAreaChange() const {
@@ -703,7 +645,7 @@ void DesktopWindowTreeHostWin::ResetWindowControls() {
 }
 
 void DesktopWindowTreeHostWin::PaintLayeredWindow(gfx::Canvas* canvas) {
-  GetWidget()->GetRootView()->Paint(canvas);
+  GetWidget()->GetRootView()->Paint(canvas, views::CullSet());
 }
 
 gfx::NativeViewAccessible DesktopWindowTreeHostWin::GetNativeViewAccessible() {
@@ -747,7 +689,6 @@ void DesktopWindowTreeHostWin::HandleCancelMode() {
 
 void DesktopWindowTreeHostWin::HandleCaptureLost() {
   OnHostLostWindowCapture();
-  native_widget_delegate_->OnMouseCaptureLost();
 }
 
 void DesktopWindowTreeHostWin::HandleClose() {
@@ -911,7 +852,9 @@ bool DesktopWindowTreeHostWin::HandlePaintAccelerated(
 }
 
 void DesktopWindowTreeHostWin::HandlePaint(gfx::Canvas* canvas) {
-  compositor()->ScheduleRedrawRect(gfx::Rect());
+  // It appears possible to get WM_PAINT after WM_DESTROY.
+  if (compositor())
+    compositor()->ScheduleRedrawRect(gfx::Rect());
 }
 
 bool DesktopWindowTreeHostWin::HandleTooltipNotify(int w_param,
@@ -920,13 +863,6 @@ bool DesktopWindowTreeHostWin::HandleTooltipNotify(int w_param,
   return tooltip_ && tooltip_->HandleNotify(w_param, l_param, l_result);
 }
 
-void DesktopWindowTreeHostWin::HandleTooltipMouseMove(UINT message,
-                                                      WPARAM w_param,
-                                                      LPARAM l_param) {
-  // TooltipWin implementation doesn't need this.
-  // TODO(sky): remove from HWNDMessageHandler once non-aura path nuked.
-}
-
 void DesktopWindowTreeHostWin::HandleMenuLoop(bool in_menu_loop) {
   if (in_menu_loop) {
     tooltip_disabler_.reset(
@@ -954,6 +890,11 @@ bool DesktopWindowTreeHostWin::HandleScrollEvent(
   return event.handled();
 }
 
+void DesktopWindowTreeHostWin::HandleWindowSizeChanging() {
+  if (compositor())
+    compositor()->FinishAllRendering();
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // DesktopWindowTreeHostWin, private: