Index: ui/views/widget/desktop_aura/x11_window_event_filter.cc |
diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.cc b/ui/views/widget/desktop_aura/x11_window_event_filter.cc |
index 887bb979e0b16f3facdf5037d93f315cf05cf882..809aec8635d1d75203f5878ea259984f6aae1d54 100644 |
--- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc |
+++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc |
@@ -16,10 +16,13 @@ |
#include "ui/base/hit_test.h" |
#include "ui/events/event.h" |
#include "ui/events/event_utils.h" |
+#include "ui/gfx/display.h" |
+#include "ui/gfx/screen.h" |
#include "ui/gfx/x/x11_types.h" |
#include "ui/views/linux_ui/linux_ui.h" |
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
#include "ui/views/widget/native_widget_aura.h" |
+#include "ui/views/widget/widget.h" |
namespace { |
@@ -96,9 +99,6 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
if (event->type() != ui::ET_MOUSE_PRESSED) |
return; |
- if (!(event->IsLeftMouseButton() || event->IsMiddleMouseButton())) |
- return; |
- |
aura::Window* target = static_cast<aura::Window*>(event->target()); |
if (!target->delegate()) |
return; |
@@ -110,10 +110,29 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
previous_click_component = click_component_; |
click_component_ = component; |
} |
- if (component == HTCLIENT) |
- return; |
- if (event->IsMiddleMouseButton() && (component == HTCAPTION)) { |
+ if (component == HTCAPTION) { |
+ OnClickedCaption(event, previous_click_component); |
+ } else if (component == HTMAXBUTTON) { |
+ OnClickedMaximizeButton(event); |
+ } else { |
+ // Get the |x_root_window_| location out of the native event. |
+ if (event->IsLeftMouseButton() && event->native_event()) { |
+ const gfx::Point x_root_location = |
+ ui::EventSystemLocationFromNative(event->native_event()); |
+ if (target->GetProperty(aura::client::kCanResizeKey) && |
+ DispatchHostWindowDragMovement(component, x_root_location)) { |
+ event->StopPropagation(); |
+ } |
+ } |
+ } |
+} |
+ |
+void X11WindowEventFilter::OnClickedCaption(ui::MouseEvent* event, |
+ int previous_click_component) { |
+ aura::Window* target = static_cast<aura::Window*>(event->target()); |
+ |
+ if (event->IsMiddleMouseButton()) { |
LinuxUI::NonClientMiddleClickAction action = |
LinuxUI::MIDDLE_CLICK_ACTION_LOWER; |
LinuxUI* linux_ui = LinuxUI::instance(); |
@@ -139,12 +158,10 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
return; |
} |
- // Left button case. |
- if (event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
+ if (event->IsLeftMouseButton() && event->flags() & ui::EF_IS_DOUBLE_CLICK) { |
click_component_ = HTNOWHERE; |
- if (component == HTCAPTION && |
- target->GetProperty(aura::client::kCanMaximizeKey) && |
- previous_click_component == component) { |
+ if (target->GetProperty(aura::client::kCanMaximizeKey) && |
+ previous_click_component == HTCAPTION) { |
// 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). |
@@ -155,14 +172,34 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
} |
// Get the |x_root_window_| location out of the native event. |
- if (event->native_event()) { |
+ if (event->IsLeftMouseButton() && event->native_event()) { |
const gfx::Point x_root_location = |
ui::EventSystemLocationFromNative(event->native_event()); |
- if ((component == HTCAPTION || |
- target->GetProperty(aura::client::kCanResizeKey)) && |
- DispatchHostWindowDragMovement(component, x_root_location)) { |
+ if (DispatchHostWindowDragMovement(HTCAPTION, x_root_location)) |
event->StopPropagation(); |
- } |
+ } |
+} |
+ |
+void X11WindowEventFilter::OnClickedMaximizeButton(ui::MouseEvent* event) { |
+ aura::Window* target = static_cast<aura::Window*>(event->target()); |
+ views::Widget* widget = views::Widget::GetWidgetForNativeView(target); |
+ if (!widget) |
+ return; |
+ |
+ gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
+ gfx::Rect display_work_area = |
+ screen->GetDisplayNearestWindow(target).work_area(); |
+ gfx::Rect bounds = widget->GetWindowBoundsInScreen(); |
+ if (event->IsMiddleMouseButton()) { |
+ bounds.set_y(display_work_area.y()); |
+ bounds.set_height(display_work_area.height()); |
+ widget->SetBounds(bounds); |
+ event->StopPropagation(); |
+ } else if (event->IsRightMouseButton()) { |
+ bounds.set_x(display_work_area.x()); |
+ bounds.set_width(display_work_area.width()); |
+ widget->SetBounds(bounds); |
+ event->StopPropagation(); |
} |
} |