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

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

Issue 233653002: x11: Remove MessagePumpObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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 | « base/message_loop/message_pump_x11.cc ('k') | ui/base/clipboard/clipboard_aurax11.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) 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>
11 #include <X11/extensions/Xrandr.h> 11 #include <X11/extensions/Xrandr.h>
12 #include <X11/Xatom.h> 12 #include <X11/Xatom.h>
13 #include <X11/Xcursor/Xcursor.h> 13 #include <X11/Xcursor/Xcursor.h>
14 #include <X11/Xlib.h> 14 #include <X11/Xlib.h>
15 15
16 #include <algorithm> 16 #include <algorithm>
17 #include <limits> 17 #include <limits>
18 #include <string> 18 #include <string>
19 19
20 #include "base/basictypes.h" 20 #include "base/basictypes.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/debug/trace_event.h" 22 #include "base/debug/trace_event.h"
23 #include "base/message_loop/message_loop.h"
24 #include "base/stl_util.h" 23 #include "base/stl_util.h"
25 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
27 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
28 #include "base/sys_info.h" 27 #include "base/sys_info.h"
29 #include "ui/aura/client/cursor_client.h" 28 #include "ui/aura/client/cursor_client.h"
30 #include "ui/aura/client/screen_position_client.h" 29 #include "ui/aura/client/screen_position_client.h"
31 #include "ui/aura/env.h" 30 #include "ui/aura/env.h"
32 #include "ui/aura/window_event_dispatcher.h" 31 #include "ui/aura/window_event_dispatcher.h"
33 #include "ui/base/cursor/cursor.h" 32 #include "ui/base/cursor/cursor.h"
34 #include "ui/base/ui_base_switches.h" 33 #include "ui/base/ui_base_switches.h"
35 #include "ui/base/view_prop.h" 34 #include "ui/base/view_prop.h"
36 #include "ui/base/x/x11_util.h" 35 #include "ui/base/x/x11_util.h"
37 #include "ui/compositor/compositor.h" 36 #include "ui/compositor/compositor.h"
38 #include "ui/compositor/dip_util.h" 37 #include "ui/compositor/dip_util.h"
39 #include "ui/compositor/layer.h" 38 #include "ui/compositor/layer.h"
40 #include "ui/events/event.h" 39 #include "ui/events/event.h"
41 #include "ui/events/event_switches.h" 40 #include "ui/events/event_switches.h"
42 #include "ui/events/event_utils.h" 41 #include "ui/events/event_utils.h"
43 #include "ui/events/keycodes/keyboard_codes.h" 42 #include "ui/events/keycodes/keyboard_codes.h"
43 #include "ui/events/platform/platform_event_observer.h"
44 #include "ui/events/platform/x11/x11_event_source.h" 44 #include "ui/events/platform/x11/x11_event_source.h"
45 #include "ui/events/x/device_data_manager.h" 45 #include "ui/events/x/device_data_manager.h"
46 #include "ui/events/x/device_list_cache_x.h" 46 #include "ui/events/x/device_list_cache_x.h"
47 #include "ui/events/x/touch_factory_x11.h" 47 #include "ui/events/x/touch_factory_x11.h"
48 #include "ui/gfx/screen.h" 48 #include "ui/gfx/screen.h"
49 49
50 using std::max; 50 using std::max;
51 using std::min; 51 using std::min;
52 52
53 namespace aura { 53 namespace aura {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } // namespace 109 } // namespace
110 110
111 namespace internal { 111 namespace internal {
112 112
113 // Accomplishes 2 tasks concerning touch event calibration: 113 // Accomplishes 2 tasks concerning touch event calibration:
114 // 1. Being a message-pump observer, 114 // 1. Being a message-pump observer,
115 // routes all the touch events to the X root window, 115 // routes all the touch events to the X root window,
116 // where they can be calibrated later. 116 // where they can be calibrated later.
117 // 2. Has the Calibrate method that does the actual bezel calibration, 117 // 2. Has the Calibrate method that does the actual bezel calibration,
118 // when invoked from X root window's event dispatcher. 118 // when invoked from X root window's event dispatcher.
119 class TouchEventCalibrate : public base::MessagePumpObserver { 119 class TouchEventCalibrate : public ui::PlatformEventObserver {
120 public: 120 public:
121 TouchEventCalibrate() 121 TouchEventCalibrate()
122 : left_(0), 122 : left_(0),
123 right_(0), 123 right_(0),
124 top_(0), 124 top_(0),
125 bottom_(0) { 125 bottom_(0) {
126 base::MessageLoopForUI::current()->AddObserver(this); 126 if (ui::PlatformEventSource::GetInstance())
127 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
127 #if defined(USE_XI2_MT) 128 #if defined(USE_XI2_MT)
128 std::vector<std::string> parts; 129 std::vector<std::string> parts;
129 if (Tokenize(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 130 if (Tokenize(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
130 switches::kTouchCalibration), ",", &parts) >= 4) { 131 switches::kTouchCalibration), ",", &parts) >= 4) {
131 if (!base::StringToInt(parts[0], &left_)) 132 if (!base::StringToInt(parts[0], &left_))
132 DLOG(ERROR) << "Incorrect left border calibration value passed."; 133 DLOG(ERROR) << "Incorrect left border calibration value passed.";
133 if (!base::StringToInt(parts[1], &right_)) 134 if (!base::StringToInt(parts[1], &right_))
134 DLOG(ERROR) << "Incorrect right border calibration value passed."; 135 DLOG(ERROR) << "Incorrect right border calibration value passed.";
135 if (!base::StringToInt(parts[2], &top_)) 136 if (!base::StringToInt(parts[2], &top_))
136 DLOG(ERROR) << "Incorrect top border calibration value passed."; 137 DLOG(ERROR) << "Incorrect top border calibration value passed.";
137 if (!base::StringToInt(parts[3], &bottom_)) 138 if (!base::StringToInt(parts[3], &bottom_))
138 DLOG(ERROR) << "Incorrect bottom border calibration value passed."; 139 DLOG(ERROR) << "Incorrect bottom border calibration value passed.";
139 } 140 }
140 #endif // defined(USE_XI2_MT) 141 #endif // defined(USE_XI2_MT)
141 } 142 }
142 143
143 virtual ~TouchEventCalibrate() { 144 virtual ~TouchEventCalibrate() {
144 base::MessageLoopForUI::current()->RemoveObserver(this); 145 if (ui::PlatformEventSource::GetInstance())
146 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
145 } 147 }
146 148
147 // Modify the location of the |event|, 149 // Modify the location of the |event|,
148 // expanding it from |bounds| to (|bounds| + bezels). 150 // expanding it from |bounds| to (|bounds| + bezels).
149 // Required when touchscreen is bigger than screen (i.e. has bezels), 151 // Required when touchscreen is bigger than screen (i.e. has bezels),
150 // because we receive events in touchscreen coordinates, 152 // because we receive events in touchscreen coordinates,
151 // which need to be expanded when converting to screen coordinates, 153 // which need to be expanded when converting to screen coordinates,
152 // so that location on bezels will be outside of screen area. 154 // so that location on bezels will be outside of screen area.
153 void Calibrate(ui::TouchEvent* event, const gfx::Rect& bounds) { 155 void Calibrate(ui::TouchEvent* event, const gfx::Rect& bounds) {
154 #if defined(USE_XI2_MT) 156 #if defined(USE_XI2_MT)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if (event->root_location() == event->location()) { 202 if (event->root_location() == event->location()) {
201 // Usually those will be equal, 203 // Usually those will be equal,
202 // if not, I am not sure what the correct value should be. 204 // if not, I am not sure what the correct value should be.
203 event->set_root_location(gfx::Point(x, y)); 205 event->set_root_location(gfx::Point(x, y));
204 } 206 }
205 event->set_location(gfx::Point(x, y)); 207 event->set_location(gfx::Point(x, y));
206 #endif // defined(USE_XI2_MT) 208 #endif // defined(USE_XI2_MT)
207 } 209 }
208 210
209 private: 211 private:
210 // Overridden from base::MessagePumpObserver: 212 // ui::PlatformEventObserver:
211 virtual void WillProcessEvent(const base::NativeEvent& event) OVERRIDE { 213 virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE {
212 #if defined(USE_XI2_MT) 214 #if defined(USE_XI2_MT)
213 if (event->type == GenericEvent && 215 if (event->type == GenericEvent &&
214 (event->xgeneric.evtype == XI_TouchBegin || 216 (event->xgeneric.evtype == XI_TouchBegin ||
215 event->xgeneric.evtype == XI_TouchUpdate || 217 event->xgeneric.evtype == XI_TouchUpdate ||
216 event->xgeneric.evtype == XI_TouchEnd)) { 218 event->xgeneric.evtype == XI_TouchEnd)) {
217 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data); 219 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data);
218 xievent->event = xievent->root; 220 xievent->event = xievent->root;
219 xievent->event_x = xievent->root_x; 221 xievent->event_x = xievent->root_x;
220 xievent->event_y = xievent->root_y; 222 xievent->event_y = xievent->root_y;
221 } 223 }
222 #endif // defined(USE_XI2_MT) 224 #endif // defined(USE_XI2_MT)
223 } 225 }
224 226
225 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { 227 virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE {}
226 }
227 228
228 // The difference in screen's native resolution pixels between 229 // The difference in screen's native resolution pixels between
229 // the border of the touchscreen and the border of the screen, 230 // the border of the touchscreen and the border of the screen,
230 // aka bezel sizes. 231 // aka bezel sizes.
231 int left_; 232 int left_;
232 int right_; 233 int right_;
233 int top_; 234 int top_;
234 int bottom_; 235 int bottom_;
235 236
236 DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate); 237 DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate);
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 } 918 }
918 919
919 namespace test { 920 namespace test {
920 921
921 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { 922 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
922 default_override_redirect = override_redirect; 923 default_override_redirect = override_redirect;
923 } 924 }
924 925
925 } // namespace test 926 } // namespace test
926 } // namespace aura 927 } // namespace aura
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_x11.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698