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

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

Issue 2319933002: X11: Remove calls to XSelectInput (Closed)
Patch Set: Change mask stuff in window_tree_host_x11, remove XSelectInput in ui/compositor, update dependent patch set Created 4 years, 3 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
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/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/extensions/Xrandr.h> 10 #include <X11/extensions/Xrandr.h>
(...skipping 16 matching lines...) Expand all
27 #include "base/trace_event/trace_event.h" 27 #include "base/trace_event/trace_event.h"
28 #include "build/build_config.h" 28 #include "build/build_config.h"
29 #include "ui/aura/client/cursor_client.h" 29 #include "ui/aura/client/cursor_client.h"
30 #include "ui/aura/env.h" 30 #include "ui/aura/env.h"
31 #include "ui/aura/window.h" 31 #include "ui/aura/window.h"
32 #include "ui/aura/window_event_dispatcher.h" 32 #include "ui/aura/window_event_dispatcher.h"
33 #include "ui/base/cursor/cursor.h" 33 #include "ui/base/cursor/cursor.h"
34 #include "ui/base/ui_base_switches.h" 34 #include "ui/base/ui_base_switches.h"
35 #include "ui/base/view_prop.h" 35 #include "ui/base/view_prop.h"
36 #include "ui/base/x/x11_util.h" 36 #include "ui/base/x/x11_util.h"
37 #include "ui/base/x/x11_window_event_manager.h"
37 #include "ui/compositor/compositor.h" 38 #include "ui/compositor/compositor.h"
38 #include "ui/compositor/dip_util.h" 39 #include "ui/compositor/dip_util.h"
39 #include "ui/compositor/layer.h" 40 #include "ui/compositor/layer.h"
40 #include "ui/display/screen.h" 41 #include "ui/display/screen.h"
41 #include "ui/events/devices/x11/device_data_manager_x11.h" 42 #include "ui/events/devices/x11/device_data_manager_x11.h"
42 #include "ui/events/devices/x11/device_list_cache_x11.h" 43 #include "ui/events/devices/x11/device_list_cache_x11.h"
43 #include "ui/events/devices/x11/touch_factory_x11.h" 44 #include "ui/events/devices/x11/touch_factory_x11.h"
44 #include "ui/events/event.h" 45 #include "ui/events/event.h"
45 #include "ui/events/event_switches.h" 46 #include "ui/events/event_switches.h"
46 #include "ui/events/event_utils.h" 47 #include "ui/events/event_utils.h"
47 #include "ui/events/keycodes/keyboard_codes.h" 48 #include "ui/events/keycodes/keyboard_codes.h"
48 #include "ui/events/platform/platform_event_observer.h" 49 #include "ui/events/platform/platform_event_observer.h"
49 #include "ui/events/platform/platform_event_source.h" 50 #include "ui/events/platform/platform_event_source.h"
50 #include "ui/events/platform/x11/x11_event_source.h" 51 #include "ui/events/platform/x11/x11_event_source.h"
51 52
52 using std::max; 53 using std::max;
53 using std::min; 54 using std::min;
54 55
55 namespace aura { 56 namespace aura {
56 57
57 namespace { 58 namespace {
58 59
59 const char* kAtomsToCache[] = { 60 const char* kAtomsToCache[] = {
60 "WM_DELETE_WINDOW", 61 "WM_DELETE_WINDOW",
61 "_NET_WM_PING", 62 "_NET_WM_PING",
62 "_NET_WM_PID", 63 "_NET_WM_PID",
63 NULL 64 NULL
64 }; 65 };
65 66
67 constexpr uint32_t kInputEventMask =
68 ButtonPressMask | ButtonReleaseMask | FocusChangeMask | KeyPressMask |
69 KeyReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask;
70
71 constexpr uint32_t kEventMask = kInputEventMask | ExposureMask |
72 VisibilityChangeMask | StructureNotifyMask |
73 PropertyChangeMask;
74
66 ::Window FindEventTarget(const base::NativeEvent& xev) { 75 ::Window FindEventTarget(const base::NativeEvent& xev) {
67 ::Window target = xev->xany.window; 76 ::Window target = xev->xany.window;
68 if (xev->type == GenericEvent) 77 if (xev->type == GenericEvent)
69 target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event; 78 target = static_cast<XIDeviceEvent*>(xev->xcookie.data)->event;
70 return target; 79 return target;
71 } 80 }
72 81
73 void SelectXInput2EventsForRootWindow(XDisplay* display, ::Window root_window) { 82 void SelectXInput2EventsForRootWindow(XDisplay* display, ::Window root_window) {
74 CHECK(ui::IsXInput2Available()); 83 CHECK(ui::IsXInput2Available());
75 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; 84 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {};
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bounds.x(), bounds.y(), bounds.width(), bounds.height(), 134 bounds.x(), bounds.y(), bounds.width(), bounds.height(),
126 0, // border width 135 0, // border width
127 CopyFromParent, // depth 136 CopyFromParent, // depth
128 InputOutput, 137 InputOutput,
129 CopyFromParent, // visual 138 CopyFromParent, // visual
130 CWBackPixmap | CWBitGravity | CWOverrideRedirect, 139 CWBackPixmap | CWBitGravity | CWOverrideRedirect,
131 &swa); 140 &swa);
132 if (ui::PlatformEventSource::GetInstance()) 141 if (ui::PlatformEventSource::GetInstance())
133 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 142 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
134 143
135 long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | 144 xwindow_events_.reset(new ui::XScopedEventSelector(xwindow_, kEventMask));
136 KeyPressMask | KeyReleaseMask |
137 EnterWindowMask | LeaveWindowMask |
138 ExposureMask | VisibilityChangeMask |
139 StructureNotifyMask | PropertyChangeMask |
140 PointerMotionMask;
141 XSelectInput(xdisplay_, xwindow_, event_mask);
142 XFlush(xdisplay_); 145 XFlush(xdisplay_);
143 146
144 if (ui::IsXInput2Available()) { 147 if (ui::IsXInput2Available()) {
145 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); 148 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_);
146 SelectXInput2EventsForRootWindow(xdisplay_, x_root_window_); 149 SelectXInput2EventsForRootWindow(xdisplay_, x_root_window_);
147 } 150 }
148 151
149 // TODO(erg): We currently only request window deletion events. We also 152 // TODO(erg): We currently only request window deletion events. We also
150 // should listen for activation events and anything else that GTK+ listens 153 // should listen for activation events and anything else that GTK+ listens
151 // for, and do something useful. 154 // for, and do something useful.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 466
464 void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) { 467 void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) {
465 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, 468 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0,
466 bounds_.x() + location.x(), 469 bounds_.x() + location.x(),
467 bounds_.y() + location.y()); 470 bounds_.y() + location.y());
468 } 471 }
469 472
470 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { 473 void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
471 } 474 }
472 475
476 void WindowTreeHostX11::DisableInput() {
477 xwindow_events_.reset(
Daniel Erat 2016/09/07 23:36:16 is there a risk that we can miss some events betwe
Tom (Use chromium acct) 2016/09/08 17:15:15 The new XScopedEventSelector gets created before t
Daniel Erat 2016/09/08 18:11:28 oh, duh. yes. :-)
478 new ui::XScopedEventSelector(xwindow_, kEventMask & ~kInputEventMask));
479 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {0};
480 XIEventMask evmask;
481 evmask.deviceid = XIAllDevices;
482 evmask.mask_len = sizeof(mask);
483 evmask.mask = mask;
484 XISelectEvents(gfx::GetXDisplay(), xwindow_, &evmask, 1);
485 }
486
473 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) { 487 void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
474 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); 488 ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
475 XEvent* xev = event; 489 XEvent* xev = event;
476 if (!factory->ShouldProcessXI2Event(xev)) 490 if (!factory->ShouldProcessXI2Event(xev))
477 return; 491 return;
478 492
479 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event", 493 TRACE_EVENT1("input", "WindowTreeHostX11::DispatchXI2Event",
480 "event_latency_us", 494 "event_latency_us",
481 (ui::EventTimeForNow() - ui::EventTimeFromNative(event)). 495 (ui::EventTimeForNow() - ui::EventTimeFromNative(event)).
482 InMicroseconds()); 496 InMicroseconds());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 574 }
561 575
562 namespace test { 576 namespace test {
563 577
564 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { 578 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) {
565 default_override_redirect = override_redirect; 579 default_override_redirect = override_redirect;
566 } 580 }
567 581
568 } // namespace test 582 } // namespace test
569 } // namespace aura 583 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698