Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / x11_window_event_filter.cc
index 45418fb..1336c46 100644 (file)
@@ -9,6 +9,7 @@
 #include <X11/Xatom.h>
 #include <X11/Xlib.h>
 
+#include "ui/aura/client/aura_constants.h"
 #include "ui/aura/root_window.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_delegate.h"
@@ -16,7 +17,7 @@
 #include "ui/events/event.h"
 #include "ui/events/event_utils.h"
 #include "ui/gfx/x/x11_types.h"
-#include "ui/views/widget/desktop_aura/desktop_root_window_host.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
 #include "ui/views/widget/native_widget_aura.h"
 
 namespace {
@@ -61,12 +62,12 @@ namespace views {
 
 X11WindowEventFilter::X11WindowEventFilter(
     aura::RootWindow* root_window,
-    DesktopWindowTreeHost* root_window_host)
+    DesktopWindowTreeHost* window_tree_host)
     : xdisplay_(gfx::GetXDisplay()),
       xwindow_(root_window->host()->GetAcceleratedWidget()),
       x_root_window_(DefaultRootWindow(xdisplay_)),
       atom_cache_(xdisplay_, kAtomsToCache),
-      root_window_host_(root_window_host),
+      window_tree_host_(window_tree_host),
       is_active_(false) {
 }
 
@@ -106,14 +107,16 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) {
   if (component == HTCLIENT)
     return;
 
-  if (event->flags() & ui::EF_IS_DOUBLE_CLICK && component == HTCAPTION) {
-    // Our event is a double click in the caption area. We are responsible for
-    // dispatching this as a minimize/maximize on X11 (Windows converts this to
-    // min/max events for us).
-    if (root_window_host_->IsMaximized())
-      root_window_host_->Restore();
+  if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
+      component == HTCAPTION &&
+      target->GetProperty(aura::client::kCanMaximizeKey)) {
+    // Our event is a double click in the caption area in a window that can be
+    // maximized. We are responsible for dispatching this as a minimize/
+    // maximize on X11 (Windows converts this to min/max events for us).
+    if (window_tree_host_->IsMaximized())
+      window_tree_host_->Restore();
     else
-      root_window_host_->Maximize();
+      window_tree_host_->Maximize();
     event->SetHandled();
     return;
   }
@@ -122,8 +125,11 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) {
   if (event->native_event()) {
     const gfx::Point x_root_location =
         ui::EventSystemLocationFromNative(event->native_event());
-    if (DispatchHostWindowDragMovement(component, x_root_location))
+    if ((component == HTCAPTION ||
+         target->GetProperty(aura::client::kCanResizeKey)) &&
+        DispatchHostWindowDragMovement(component, x_root_location)) {
       event->StopPropagation();
+    }
   }
 }