Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Unified Diff: ui/views/widget/desktop_aura/x11_window_event_filter.cc

Issue 288203005: Maximize window vertically/horizontally when the maximize button is middle/right clicked on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/x11_window_event_filter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
}
« no previous file with comments | « ui/views/widget/desktop_aura/x11_window_event_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698