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

Side by Side Diff: trunk/src/ui/aura/window_tree_host_x11.cc

Issue 186123004: Revert 255385 "aura: Remove client::UserActionClient." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window_tree_host_x11.h" 5 #include "ui/aura/window_tree_host_x11.h"
6 6
7 #include <strings.h> 7 #include <strings.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/Xfixes.h> 9 #include <X11/extensions/Xfixes.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 11 matching lines...) Expand all
22 #include "base/debug/trace_event.h" 22 #include "base/debug/trace_event.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/message_loop/message_pump_x11.h" 24 #include "base/message_loop/message_pump_x11.h"
25 #include "base/stl_util.h" 25 #include "base/stl_util.h"
26 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
29 #include "base/sys_info.h" 29 #include "base/sys_info.h"
30 #include "ui/aura/client/cursor_client.h" 30 #include "ui/aura/client/cursor_client.h"
31 #include "ui/aura/client/screen_position_client.h" 31 #include "ui/aura/client/screen_position_client.h"
32 #include "ui/aura/client/user_action_client.h"
32 #include "ui/aura/env.h" 33 #include "ui/aura/env.h"
33 #include "ui/aura/window_event_dispatcher.h" 34 #include "ui/aura/window_event_dispatcher.h"
34 #include "ui/base/cursor/cursor.h" 35 #include "ui/base/cursor/cursor.h"
35 #include "ui/base/ui_base_switches.h" 36 #include "ui/base/ui_base_switches.h"
36 #include "ui/base/view_prop.h" 37 #include "ui/base/view_prop.h"
37 #include "ui/base/x/x11_util.h" 38 #include "ui/base/x/x11_util.h"
38 #include "ui/compositor/compositor.h" 39 #include "ui/compositor/compositor.h"
39 #include "ui/compositor/dip_util.h" 40 #include "ui/compositor/dip_util.h"
40 #include "ui/compositor/layer.h" 41 #include "ui/compositor/layer.h"
41 #include "ui/events/event.h" 42 #include "ui/events/event.h"
42 #include "ui/events/event_utils.h" 43 #include "ui/events/event_utils.h"
43 #include "ui/events/keycodes/keyboard_codes.h" 44 #include "ui/events/keycodes/keyboard_codes.h"
44 #include "ui/events/x/device_data_manager.h" 45 #include "ui/events/x/device_data_manager.h"
45 #include "ui/events/x/device_list_cache_x.h" 46 #include "ui/events/x/device_list_cache_x.h"
46 #include "ui/events/x/touch_factory_x11.h" 47 #include "ui/events/x/touch_factory_x11.h"
47 #include "ui/gfx/screen.h" 48 #include "ui/gfx/screen.h"
48 49
49 using std::max; 50 using std::max;
50 using std::min; 51 using std::min;
51 52
52 namespace aura { 53 namespace aura {
53 54
54 namespace { 55 namespace {
55 56
57 // Standard Linux mouse buttons for going back and forward.
58 const int kBackMouseButton = 8;
59 const int kForwardMouseButton = 9;
60
56 const char* kAtomsToCache[] = { 61 const char* kAtomsToCache[] = {
57 "WM_DELETE_WINDOW", 62 "WM_DELETE_WINDOW",
58 "_NET_WM_PING", 63 "_NET_WM_PING",
59 "_NET_WM_PID", 64 "_NET_WM_PID",
60 "WM_S0", 65 "WM_S0",
61 #if defined(OS_CHROMEOS) 66 #if defined(OS_CHROMEOS)
62 "Tap Paused", // Defined in the gestures library. 67 "Tap Paused", // Defined in the gestures library.
63 #endif 68 #endif
64 NULL 69 NULL
65 }; 70 };
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 case KeyPress: { 393 case KeyPress: {
389 ui::KeyEvent keydown_event(xev, false); 394 ui::KeyEvent keydown_event(xev, false);
390 SendEventToProcessor(&keydown_event); 395 SendEventToProcessor(&keydown_event);
391 break; 396 break;
392 } 397 }
393 case KeyRelease: { 398 case KeyRelease: {
394 ui::KeyEvent keyup_event(xev, false); 399 ui::KeyEvent keyup_event(xev, false);
395 SendEventToProcessor(&keyup_event); 400 SendEventToProcessor(&keyup_event);
396 break; 401 break;
397 } 402 }
398 case ButtonPress: 403 case ButtonPress: {
404 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton ||
405 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) {
406 client::UserActionClient* gesture_client =
407 client::GetUserActionClient(window());
408 if (gesture_client) {
409 gesture_client->OnUserAction(
410 static_cast<int>(xev->xbutton.button) == kBackMouseButton ?
411 client::UserActionClient::BACK :
412 client::UserActionClient::FORWARD);
413 }
414 break;
415 }
416 } // fallthrough
399 case ButtonRelease: { 417 case ButtonRelease: {
400 switch (ui::EventTypeFromNative(xev)) { 418 switch (ui::EventTypeFromNative(xev)) {
401 case ui::ET_MOUSEWHEEL: { 419 case ui::ET_MOUSEWHEEL: {
402 ui::MouseWheelEvent mouseev(xev); 420 ui::MouseWheelEvent mouseev(xev);
403 TranslateAndDispatchMouseEvent(&mouseev); 421 TranslateAndDispatchMouseEvent(&mouseev);
404 break; 422 break;
405 } 423 }
406 case ui::ET_MOUSE_PRESSED: 424 case ui::ET_MOUSE_PRESSED:
407 case ui::ET_MOUSE_RELEASED: { 425 case ui::ET_MOUSE_RELEASED: {
408 ui::MouseEvent mouseev(xev); 426 ui::MouseEvent mouseev(xev);
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 case ui::ET_MOUSE_PRESSED: 854 case ui::ET_MOUSE_PRESSED:
837 case ui::ET_MOUSE_RELEASED: 855 case ui::ET_MOUSE_RELEASED:
838 case ui::ET_MOUSE_ENTERED: 856 case ui::ET_MOUSE_ENTERED:
839 case ui::ET_MOUSE_EXITED: { 857 case ui::ET_MOUSE_EXITED: {
840 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { 858 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) {
841 // If this is a motion event, we want to coalesce all pending motion 859 // If this is a motion event, we want to coalesce all pending motion
842 // events that are at the top of the queue. 860 // events that are at the top of the queue.
843 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); 861 num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
844 if (num_coalesced > 0) 862 if (num_coalesced > 0)
845 xev = &last_event; 863 xev = &last_event;
864 } else if (type == ui::ET_MOUSE_PRESSED ||
865 type == ui::ET_MOUSE_RELEASED) {
866 XIDeviceEvent* xievent =
867 static_cast<XIDeviceEvent*>(xev->xcookie.data);
868 int button = xievent->detail;
869 if (button == kBackMouseButton || button == kForwardMouseButton) {
870 if (type == ui::ET_MOUSE_RELEASED)
871 break;
872 client::UserActionClient* gesture_client =
873 client::GetUserActionClient(window());
874 if (gesture_client) {
875 bool reverse_direction =
876 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled();
877 gesture_client->OnUserAction(
878 (button == kBackMouseButton && !reverse_direction) ||
879 (button == kForwardMouseButton && reverse_direction) ?
880 client::UserActionClient::BACK :
881 client::UserActionClient::FORWARD);
882 }
883 break;
884 }
846 } 885 }
847 ui::MouseEvent mouseev(xev); 886 ui::MouseEvent mouseev(xev);
848 TranslateAndDispatchMouseEvent(&mouseev); 887 TranslateAndDispatchMouseEvent(&mouseev);
849 break; 888 break;
850 } 889 }
851 case ui::ET_MOUSEWHEEL: { 890 case ui::ET_MOUSEWHEEL: {
852 ui::MouseWheelEvent mouseev(xev); 891 ui::MouseWheelEvent mouseev(xev);
853 TranslateAndDispatchMouseEvent(&mouseev); 892 TranslateAndDispatchMouseEvent(&mouseev);
854 break; 893 break;
855 } 894 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 994 }
956 995
957 namespace test { 996 namespace test {
958 997
959 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { 998 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
960 default_override_redirect = override_redirect; 999 default_override_redirect = override_redirect;
961 } 1000 }
962 1001
963 } // namespace test 1002 } // namespace test
964 } // namespace aura 1003 } // namespace aura
OLDNEW
« no previous file with comments | « trunk/src/ui/aura/client/user_action_client.cc ('k') | trunk/src/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698