diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-09 22:23:40 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-09 22:23:40 +0000 |
commit | efb2a4e8a6d5c546cc38eaf907e24bd3cee54e82 (patch) | |
tree | fad994d6521deb407a9f145aaf83c0b25d70c247 /ui/views | |
parent | 2add5dd52cc070d26a1687bd5cd530ca44293be6 (diff) | |
download | chromium_src-efb2a4e8a6d5c546cc38eaf907e24bd3cee54e82.zip chromium_src-efb2a4e8a6d5c546cc38eaf907e24bd3cee54e82.tar.gz chromium_src-efb2a4e8a6d5c546cc38eaf907e24bd3cee54e82.tar.bz2 |
linux_aura: Use system configuration for middle clicking the titlebar.
The action that is taken when the user middle clicks on non client area
is configurable with gnome-tweak-tool. This allows users to disable any
action on middle click, lower windows, minimize windows, or toggle the
maximize state.
Also renames GConfTitlebarListener to GConfListener, since it's now
doing more than just checking maximize button order.
BUG=132061
Review URL: https://codereview.chromium.org/229783002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262839 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/linux_ui/linux_ui.h | 13 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/x11_window_event_filter.cc | 35 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/x11_window_event_filter.h | 2 |
3 files changed, 45 insertions, 5 deletions
diff --git a/ui/views/linux_ui/linux_ui.h b/ui/views/linux_ui/linux_ui.h index 563a518..cadc7b7 100644 --- a/ui/views/linux_ui/linux_ui.h +++ b/ui/views/linux_ui/linux_ui.h @@ -46,6 +46,15 @@ class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory, public ui::LinuxShellDialog, public ui::TextEditKeyBindingsDelegateAuraLinux { public: + // Describes the window management actions that could be taken in response to + // a middle click in the non client area. + enum NonClientMiddleClickAction { + MIDDLE_CLICK_ACTION_NONE, + MIDDLE_CLICK_ACTION_LOWER, + MIDDLE_CLICK_ACTION_MINIMIZE, + MIDDLE_CLICK_ACTION_TOGGLE_MAXIMIZE + }; + virtual ~LinuxUI() {} // Sets the dynamically loaded singleton that draws the desktop native UI. @@ -127,6 +136,10 @@ class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory, // Determines whether the user's window manager is Unity. virtual bool UnityIsRunning() = 0; + // What action we should take when the user middle clicks on non-client + // area. The default is lowering the window. + virtual NonClientMiddleClickAction GetNonClientMiddleClickAction() = 0; + // Notifies the window manager that start up has completed. // Normally Chromium opens a new window on startup and GTK does this // automatically. In case Chromium does not open a new window on startup, 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 9cb6834..d6fbfc0 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc @@ -17,6 +17,7 @@ #include "ui/events/event.h" #include "ui/events/event_utils.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" @@ -107,7 +108,27 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { return; if (event->IsMiddleMouseButton() && (component == HTCAPTION)) { - XLowerWindow(xdisplay_, xwindow_); + LinuxUI::NonClientMiddleClickAction action = + LinuxUI::MIDDLE_CLICK_ACTION_LOWER; + LinuxUI* linux_ui = LinuxUI::instance(); + if (linux_ui) + action = linux_ui->GetNonClientMiddleClickAction(); + + switch (action) { + case LinuxUI::MIDDLE_CLICK_ACTION_NONE: + break; + case LinuxUI::MIDDLE_CLICK_ACTION_LOWER: + XLowerWindow(xdisplay_, xwindow_); + break; + case LinuxUI::MIDDLE_CLICK_ACTION_MINIMIZE: + window_tree_host_->Minimize(); + break; + case LinuxUI::MIDDLE_CLICK_ACTION_TOGGLE_MAXIMIZE: + if (target->GetProperty(aura::client::kCanMaximizeKey)) + ToggleMaximizedState(); + break; + } + event->SetHandled(); return; } @@ -119,10 +140,7 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { // 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 - window_tree_host_->Maximize(); + ToggleMaximizedState(); event->SetHandled(); return; } @@ -139,6 +157,13 @@ void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { } } +void X11WindowEventFilter::ToggleMaximizedState() { + if (window_tree_host_->IsMaximized()) + window_tree_host_->Restore(); + else + window_tree_host_->Maximize(); +} + bool X11WindowEventFilter::DispatchHostWindowDragMovement( int hittest, const gfx::Point& screen_location) { diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.h b/ui/views/widget/desktop_aura/x11_window_event_filter.h index 7cc97a1..47bc69f 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.h +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.h @@ -39,6 +39,8 @@ class VIEWS_EXPORT X11WindowEventFilter : public ui::EventHandler { virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; private: + void ToggleMaximizedState(); + // Dispatches a _NET_WM_MOVERESIZE message to the window manager to tell it // to act as if a border or titlebar drag occurred. bool DispatchHostWindowDragMovement(int hittest, |