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

Side by Side Diff: ui/base/touch/touch_factory.cc

Issue 7942004: Consolidate/cleanup event cracking code; single out GdkEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge removal of compact nav. Created 9 years, 2 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
« no previous file with comments | « ui/base/touch/touch_factory.h ('k') | ui/base/wayland/events_wayland.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/touchui/touch_factory.h" 5 #include "ui/base/touch/touch_factory.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 // TODO(sad) Remove all TOOLKIT_USES_GTK uses once we move to aura only. 8 // TODO(sad) Remove all TOOLKIT_USES_GTK uses once we move to aura only.
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 #include <gdk/gdkx.h> 10 #include <gdk/gdkx.h>
11 #endif 11 #endif
12 #include <X11/cursorfont.h> 12 #include <X11/cursorfont.h>
13 #include <X11/extensions/XInput.h> 13 #include <X11/extensions/XInput.h>
14 #include <X11/extensions/XInput2.h> 14 #include <X11/extensions/XInput2.h>
15 #include <X11/extensions/XIproto.h> 15 #include <X11/extensions/XIproto.h>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/message_loop.h" 20 #include "base/message_loop.h"
21 #include "ui/base/x/x11_util.h" 21 #include "ui/base/x/x11_util.h"
22 22
23 namespace { 23 namespace {
24 24
25 // The X cursor is hidden if it is idle for kCursorIdleSeconds seconds. 25 // The X cursor is hidden if it is idle for kCursorIdleSeconds seconds.
26 int kCursorIdleSeconds = 5; 26 int kCursorIdleSeconds = 5;
27 27
28 // Given the TouchParam, return the correspoding XIValuatorClassInfo using 28 // Given the TouchParam, return the correspoding XIValuatorClassInfo using
29 // the X device information through Atom name matching. 29 // the X device information through Atom name matching.
30 XIValuatorClassInfo* FindTPValuator(Display* display, 30 XIValuatorClassInfo* FindTPValuator(Display* display,
31 XIDeviceInfo* info, 31 XIDeviceInfo* info,
32 views::TouchFactory::TouchParam tp) { 32 ui::TouchFactory::TouchParam tp) {
33 // Lookup table for mapping TouchParam to Atom string used in X. 33 // Lookup table for mapping TouchParam to Atom string used in X.
34 // A full set of Atom strings can be found at xserver-properties.h. 34 // A full set of Atom strings can be found at xserver-properties.h.
35 static struct { 35 static struct {
36 views::TouchFactory::TouchParam tp; 36 ui::TouchFactory::TouchParam tp;
37 const char* atom; 37 const char* atom;
38 } kTouchParamAtom[] = { 38 } kTouchParamAtom[] = {
39 { views::TouchFactory::TP_TOUCH_MAJOR, "Abs MT Touch Major" }, 39 { ui::TouchFactory::TP_TOUCH_MAJOR, "Abs MT Touch Major" },
40 { views::TouchFactory::TP_TOUCH_MINOR, "Abs MT Touch Minor" }, 40 { ui::TouchFactory::TP_TOUCH_MINOR, "Abs MT Touch Minor" },
41 { views::TouchFactory::TP_ORIENTATION, "Abs MT Orientation" }, 41 { ui::TouchFactory::TP_ORIENTATION, "Abs MT Orientation" },
42 { views::TouchFactory::TP_PRESSURE, "Abs MT Pressure" }, 42 { ui::TouchFactory::TP_PRESSURE, "Abs MT Pressure" },
43 #if !defined(USE_XI2_MT) 43 #if !defined(USE_XI2_MT)
44 // For Slot ID, See this chromeos revision: http://git.chromium.org/gitweb/? 44 // For Slot ID, See this chromeos revision: http://git.chromium.org/gitweb/?
45 // p=chromiumos/overlays/chromiumos-overlay.git; 45 // p=chromiumos/overlays/chromiumos-overlay.git;
46 // a=commit;h=9164d0a75e48c4867e4ef4ab51f743ae231c059a 46 // a=commit;h=9164d0a75e48c4867e4ef4ab51f743ae231c059a
47 { views::TouchFactory::TP_SLOT_ID, "Abs MT Slot ID" }, 47 { ui::TouchFactory::TP_SLOT_ID, "Abs MT Slot ID" },
48 #endif 48 #endif
49 { views::TouchFactory::TP_TRACKING_ID, "Abs MT Tracking ID" }, 49 { ui::TouchFactory::TP_TRACKING_ID, "Abs MT Tracking ID" },
50 { views::TouchFactory::TP_LAST_ENTRY, NULL }, 50 { ui::TouchFactory::TP_LAST_ENTRY, NULL },
51 }; 51 };
52 52
53 const char* atom_tp = NULL; 53 const char* atom_tp = NULL;
54 54
55 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTouchParamAtom); i++) { 55 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTouchParamAtom); i++) {
56 if (tp == kTouchParamAtom[i].tp) { 56 if (tp == kTouchParamAtom[i].tp) {
57 atom_tp = kTouchParamAtom[i].atom; 57 atom_tp = kTouchParamAtom[i].atom;
58 break; 58 break;
59 } 59 }
60 } 60 }
(...skipping 14 matching lines...) Expand all
75 75
76 return NULL; 76 return NULL;
77 } 77 }
78 78
79 #if defined(TOOLKIT_USES_GTK) 79 #if defined(TOOLKIT_USES_GTK)
80 // Setup XInput2 select for the GtkWidget. 80 // Setup XInput2 select for the GtkWidget.
81 gboolean GtkWidgetRealizeCallback(GSignalInvocationHint* hint, guint nparams, 81 gboolean GtkWidgetRealizeCallback(GSignalInvocationHint* hint, guint nparams,
82 const GValue* pvalues, gpointer data) { 82 const GValue* pvalues, gpointer data) {
83 GtkWidget* widget = GTK_WIDGET(g_value_get_object(pvalues)); 83 GtkWidget* widget = GTK_WIDGET(g_value_get_object(pvalues));
84 GdkWindow* window = widget->window; 84 GdkWindow* window = widget->window;
85 views::TouchFactory* factory = static_cast<views::TouchFactory*>(data); 85 ui::TouchFactory* factory = static_cast<ui::TouchFactory*>(data);
86 86
87 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_TOPLEVEL && 87 if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_TOPLEVEL &&
88 GDK_WINDOW_TYPE(window) != GDK_WINDOW_CHILD && 88 GDK_WINDOW_TYPE(window) != GDK_WINDOW_CHILD &&
89 GDK_WINDOW_TYPE(window) != GDK_WINDOW_DIALOG) 89 GDK_WINDOW_TYPE(window) != GDK_WINDOW_DIALOG)
90 return true; 90 return true;
91 91
92 factory->SetupXI2ForXWindow(GDK_WINDOW_XID(window)); 92 factory->SetupXI2ForXWindow(GDK_WINDOW_XID(window));
93 return true; 93 return true;
94 } 94 }
95 95
96 // We need to capture all the GDK windows that get created, and start 96 // We need to capture all the GDK windows that get created, and start
97 // listening for XInput2 events. So we setup a callback to the 'realize' 97 // listening for XInput2 events. So we setup a callback to the 'realize'
98 // signal for GTK+ widgets, so that whenever the signal triggers for any 98 // signal for GTK+ widgets, so that whenever the signal triggers for any
99 // GtkWidget, which means the GtkWidget should now have a GdkWindow, we can 99 // GtkWidget, which means the GtkWidget should now have a GdkWindow, we can
100 // setup XInput2 events for the GdkWindow. 100 // setup XInput2 events for the GdkWindow.
101 guint realize_signal_id = 0; 101 guint realize_signal_id = 0;
102 guint realize_hook_id = 0; 102 guint realize_hook_id = 0;
103 103
104 void SetupGtkWidgetRealizeNotifier(views::TouchFactory* factory) { 104 void SetupGtkWidgetRealizeNotifier(ui::TouchFactory* factory) {
105 gpointer klass = g_type_class_ref(GTK_TYPE_WIDGET); 105 gpointer klass = g_type_class_ref(GTK_TYPE_WIDGET);
106 106
107 g_signal_parse_name("realize", GTK_TYPE_WIDGET, 107 g_signal_parse_name("realize", GTK_TYPE_WIDGET,
108 &realize_signal_id, NULL, FALSE); 108 &realize_signal_id, NULL, FALSE);
109 realize_hook_id = g_signal_add_emission_hook(realize_signal_id, 0, 109 realize_hook_id = g_signal_add_emission_hook(realize_signal_id, 0,
110 GtkWidgetRealizeCallback, static_cast<gpointer>(factory), NULL); 110 GtkWidgetRealizeCallback, static_cast<gpointer>(factory), NULL);
111 111
112 g_type_class_unref(klass); 112 g_type_class_unref(klass);
113 } 113 }
114 114
115 void RemoveGtkWidgetRealizeNotifier() { 115 void RemoveGtkWidgetRealizeNotifier() {
116 if (realize_signal_id != 0) 116 if (realize_signal_id != 0)
117 g_signal_remove_emission_hook(realize_signal_id, realize_hook_id); 117 g_signal_remove_emission_hook(realize_signal_id, realize_hook_id);
118 realize_signal_id = 0; 118 realize_signal_id = 0;
119 realize_hook_id = 0; 119 realize_hook_id = 0;
120 } 120 }
121 #endif 121 #endif
122 122
123 } // namespace 123 } // namespace
124 124
125 namespace views { 125 namespace ui {
126 126
127 // static 127 // static
128 TouchFactory* TouchFactory::GetInstance() { 128 TouchFactory* TouchFactory::GetInstance() {
129 return Singleton<TouchFactory>::get(); 129 return Singleton<TouchFactory>::get();
130 } 130 }
131 131
132 TouchFactory::TouchFactory() 132 TouchFactory::TouchFactory()
133 : is_cursor_visible_(true), 133 : is_cursor_visible_(true),
134 keep_mouse_cursor_(false), 134 keep_mouse_cursor_(false),
135 cursor_timer_(), 135 cursor_timer_(),
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 float* min, 492 float* min,
493 float* max) { 493 float* max) {
494 if (valuator_lookup_[deviceid][tp] >= 0) { 494 if (valuator_lookup_[deviceid][tp] >= 0) {
495 *min = touch_param_min_[deviceid][tp]; 495 *min = touch_param_min_[deviceid][tp];
496 *max = touch_param_max_[deviceid][tp]; 496 *max = touch_param_max_[deviceid][tp];
497 return true; 497 return true;
498 } 498 }
499 return false; 499 return false;
500 } 500 }
501 501
502 } // namespace views 502 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/touch/touch_factory.h ('k') | ui/base/wayland/events_wayland.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698