summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-06 18:07:58 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-06 18:07:58 +0000
commit74684ce7d2c75ca285143884419362475f2bfa70 (patch)
tree4da678b2577074a5cbde1dab3ea6daeba6cfe7bf /ui/views
parent51cb94c68d8adbfa4736029ac2bcd70d924946e9 (diff)
downloadchromium_src-74684ce7d2c75ca285143884419362475f2bfa70.zip
chromium_src-74684ce7d2c75ca285143884419362475f2bfa70.tar.gz
chromium_src-74684ce7d2c75ca285143884419362475f2bfa70.tar.bz2
Revert 255385 "aura: Remove client::UserActionClient."
> aura: Remove client::UserActionClient. > > UserActionClient is used to navigate back/forward when the back/forward on a > supported mouse-device is clicked on X11. This can instead be achieved by > installing an event-handler on the browser window. > > This does change the behaviour a little on ChromeOS: clicking these navigation > buttons when the cursor is not on top of the browser window will not navigate > after this change. I have confirmed with UX that this is a desirable change. > > BUG=319636 > R=sky@chromium.org > > Review URL: https://codereview.chromium.org/183853037 TBR=sadrul@chromium.org Review URL: https://codereview.chromium.org/186123004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255398 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc47
1 files changed, 46 insertions, 1 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 8c7c3df..979cfe9 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -18,6 +18,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/focus_client.h"
+#include "ui/aura/client/user_action_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_property.h"
@@ -64,6 +65,10 @@ DEFINE_WINDOW_PROPERTY_KEY(
namespace {
+// Standard Linux mouse buttons for going back and forward.
+const int kBackMouseButton = 8;
+const int kForwardMouseButton = 9;
+
// Constants that are part of EWMH.
const int k_NET_WM_STATE_ADD = 1;
const int k_NET_WM_STATE_REMOVE = 0;
@@ -1296,7 +1301,20 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
SendEventToProcessor(&keyup_event);
break;
}
- case ButtonPress:
+ case ButtonPress: {
+ if (static_cast<int>(xev->xbutton.button) == kBackMouseButton ||
+ static_cast<int>(xev->xbutton.button) == kForwardMouseButton) {
+ aura::client::UserActionClient* gesture_client =
+ aura::client::GetUserActionClient(dispatcher_->window());
+ if (gesture_client) {
+ gesture_client->OnUserAction(
+ static_cast<int>(xev->xbutton.button) == kBackMouseButton ?
+ aura::client::UserActionClient::BACK :
+ aura::client::UserActionClient::FORWARD);
+ }
+ break;
+ }
+ } // fallthrough
case ButtonRelease: {
ui::EventType event_type = ui::EventTypeFromNative(xev);
switch (event_type) {
@@ -1389,6 +1407,33 @@ uint32_t DesktopWindowTreeHostX11::Dispatch(const base::NativeEvent& event) {
num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
if (num_coalesced > 0)
xev = &last_event;
+ } else if (type == ui::ET_MOUSE_PRESSED) {
+ XIDeviceEvent* xievent =
+ static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ int button = xievent->detail;
+ if (button == kBackMouseButton || button == kForwardMouseButton) {
+ aura::client::UserActionClient* gesture_client =
+ aura::client::GetUserActionClient(window());
+ if (gesture_client) {
+ bool reverse_direction =
+ ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled();
+ gesture_client->OnUserAction(
+ (button == kBackMouseButton && !reverse_direction) ||
+ (button == kForwardMouseButton && reverse_direction) ?
+ aura::client::UserActionClient::BACK :
+ aura::client::UserActionClient::FORWARD);
+ }
+ break;
+ }
+ } else if (type == ui::ET_MOUSE_RELEASED) {
+ XIDeviceEvent* xievent =
+ static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ int button = xievent->detail;
+ if (button == kBackMouseButton || button == kForwardMouseButton) {
+ // We've already passed the back/forward mouse down to the user
+ // action client; we want to swallow the corresponding release.
+ break;
+ }
}
ui::MouseEvent mouseev(xev);
DispatchMouseEvent(&mouseev);