Upstream version 9.38.204.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / desktop_aura / desktop_window_tree_host_wayland.cc
index 7e7b580..117a872 100644 (file)
 #include "ui/events/event_utils.h"
 #include "ui/gfx/insets.h"
 #include "ui/native_theme/native_theme.h"
+#include "ui/ozone/public/ozone_platform.h"
 #include "ui/ozone/public/surface_factory_ozone.h"
+#include "ui/platform_window/platform_window.h"
+#include "ui/platform_window/platform_window_delegate.h"
 #include "ui/views/corewm/tooltip_aura.h"
 #include "ui/views/ime/input_method.h"
 #include "ui/views/linux_ui/linux_ui.h"
@@ -110,9 +113,10 @@ gfx::Rect DesktopWindowTreeHostWayland::GetBoundsInScreen() const {
 
 void DesktopWindowTreeHostWayland::InitWaylandWindow(
     const Widget::InitParams& params) {
-  ui::SurfaceFactoryOzone* surface_factory =
-          ui::SurfaceFactoryOzone::GetInstance();
-  window_ = surface_factory->GetAcceleratedWidget();
+  bounds_ = params.bounds;
+  platform_window_ =
+      ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds_);
+  DCHECK(window_);
   // Maintain parent child relation as done in X11 version.
   // If we have a parent, record the parent/child relationship. We use this
   // data during destruction to make sure that when we try to close a parent
@@ -125,7 +129,6 @@ void DesktopWindowTreeHostWayland::InitWaylandWindow(
     window_parent_->window_children_.insert(this);
   }
 
-  bounds_ = params.bounds;
   ui::WindowStateChangeHandler* state_handler =
       ui::WindowStateChangeHandler::GetInstance();
   switch (params.type) {
@@ -179,6 +182,11 @@ void DesktopWindowTreeHostWayland::InitWaylandWindow(
   CreateCompositor(GetAcceleratedWidget());
 }
 
+void DesktopWindowTreeHostWayland::OnAcceleratedWidgetAvailable(
+      gfx::AcceleratedWidget widget) {
+  window_ = widget;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // DesktopWindowTreeHostWayland, DesktopWindowTreeHost implementation:
 
@@ -355,10 +363,10 @@ void DesktopWindowTreeHostWayland::GetWindowPlacement(
     ui::WindowShowState* show_state) const {
   *bounds = GetRestoredBounds();
 
-  if (IsFullscreen()) {
-    *show_state = ui::SHOW_STATE_FULLSCREEN;
-  } else if (IsMinimized()) {
+  if (IsMinimized()) {
     *show_state = ui::SHOW_STATE_MINIMIZED;
+  } else if (IsFullscreen()) {
+    *show_state = ui::SHOW_STATE_FULLSCREEN;
   } else if (IsMaximized()) {
     *show_state = ui::SHOW_STATE_MAXIMIZED;
   } else if (!IsActive()) {
@@ -447,9 +455,7 @@ void DesktopWindowTreeHostWayland::Minimize() {
   if (state_ & Minimized)
     return;
 
-  state_ &= ~Maximized;
   state_ |= Minimized;
-  state_ &= ~Normal;
   previous_bounds_ = bounds_;
   ui::WindowStateChangeHandler::GetInstance()->SetWidgetState(window_,
                                                               ui::MINIMIZED);
@@ -640,7 +646,7 @@ void DesktopWindowTreeHostWayland::FlashFrame(bool flash_frame) {
   NOTIMPLEMENTED();
 }
 
-void DesktopWindowTreeHostWayland::OnRootViewLayout() const {
+void DesktopWindowTreeHostWayland::OnRootViewLayout() {
   NOTIMPLEMENTED();
 }
 
@@ -657,6 +663,10 @@ bool DesktopWindowTreeHostWayland::IsAnimatingClosed() const {
   return false;
 }
 
+bool DesktopWindowTreeHostWayland::IsTranslucentWindowOpacitySupported() const {
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // DesktopWindowTreeHostWayland, aura::WindowTreeHost implementation:
 
@@ -743,10 +753,6 @@ void DesktopWindowTreeHostWayland::PostNativeEvent(
   NOTIMPLEMENTED();
 }
 
-void DesktopWindowTreeHostWayland::OnDeviceScaleFactorChanged(
-    float device_scale_factor) {
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // DesktopWindowTreeHostWayland, Private implementation:
 
@@ -783,6 +789,10 @@ void DesktopWindowTreeHostWayland::HandleWindowResize(unsigned width,
   }
 }
 
+void DesktopWindowTreeHostWayland::HandleWindowUnminimized() {
+  state_ &= ~Minimized;
+}
+
 void DesktopWindowTreeHostWayland::HandleCommit(const std::string& text) {
   ui::InputMethodAuraLinux* inputMethod =
       static_cast<ui::InputMethodAuraLinux*>(desktop_native_widget_aura_->