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

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

Issue 11437005: aura-x11: Select for non-touch events before selecting for touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | « no previous file | ui/base/touch/touch_factory.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/root_window_host_linux.h" 5 #include "ui/aura/root_window_host_linux.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // Receive resize events for the root-window so |x_root_bounds_| can be 87 // Receive resize events for the root-window so |x_root_bounds_| can be
88 // updated. 88 // updated.
89 XWindowAttributes attr; 89 XWindowAttributes attr;
90 XGetWindowAttributes(display, root_window, &attr); 90 XGetWindowAttributes(display, root_window, &attr);
91 if (!(attr.your_event_mask & StructureNotifyMask)) { 91 if (!(attr.your_event_mask & StructureNotifyMask)) {
92 XSelectInput(display, root_window, 92 XSelectInput(display, root_window,
93 StructureNotifyMask | attr.your_event_mask); 93 StructureNotifyMask | attr.your_event_mask);
94 } 94 }
95 95
96 XIEventMask evmask; 96 if (!base::MessagePumpForUI::HasXInput2())
97 return;
98
97 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; 99 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {};
98 memset(mask, 0, sizeof(mask)); 100 memset(mask, 0, sizeof(mask));
99 101
100 XISetMask(mask, XI_HierarchyChanged); 102 XISetMask(mask, XI_HierarchyChanged);
101
102 XISetMask(mask, XI_KeyPress); 103 XISetMask(mask, XI_KeyPress);
103 XISetMask(mask, XI_KeyRelease); 104 XISetMask(mask, XI_KeyRelease);
104 105
106 XIEventMask evmask;
107 evmask.deviceid = XIAllDevices;
108 evmask.mask_len = sizeof(mask);
109 evmask.mask = mask;
110 XISelectEvents(display, root_window, &evmask, 1);
111
112 // Selecting for touch events seems to fail on some cases (e.g. when logging
113 // in incognito). So select for non-touch events first, and then select for
114 // touch-events (but keep the other events in the mask, i.e. do not memset
115 // |mask| back to 0).
116 // TODO(sad): Figure out why this happens. http://crbug.com/153976
105 #if defined(USE_XI2_MT) 117 #if defined(USE_XI2_MT)
106 XISetMask(mask, XI_TouchBegin); 118 XISetMask(mask, XI_TouchBegin);
107 XISetMask(mask, XI_TouchUpdate); 119 XISetMask(mask, XI_TouchUpdate);
108 XISetMask(mask, XI_TouchEnd); 120 XISetMask(mask, XI_TouchEnd);
121 XISelectEvents(display, root_window, &evmask, 1);
109 #endif 122 #endif
110 evmask.deviceid = XIAllDevices;
111 evmask.mask_len = sizeof(mask);
112 evmask.mask = mask;
113
114 XISelectEvents(display, root_window, &evmask, 1);
115 } 123 }
116 124
117 // We emulate Windows' WM_KEYDOWN and WM_CHAR messages. WM_CHAR events are only 125 // We emulate Windows' WM_KEYDOWN and WM_CHAR messages. WM_CHAR events are only
118 // generated for certain keys; see 126 // generated for certain keys; see
119 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646268.aspx. Per 127 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646268.aspx. Per
120 // discussion on http://crbug.com/108480, char events should furthermore not be 128 // discussion on http://crbug.com/108480, char events should furthermore not be
121 // generated for Tab, Escape, and Backspace. 129 // generated for Tab, Escape, and Backspace.
122 bool ShouldSendCharEventForKeyboardCode(ui::KeyboardCode keycode) { 130 bool ShouldSendCharEventForKeyboardCode(ui::KeyboardCode keycode) {
123 if ((keycode >= ui::VKEY_0 && keycode <= ui::VKEY_9) || 131 if ((keycode >= ui::VKEY_0 && keycode <= ui::VKEY_9) ||
124 (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z) || 132 (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z) ||
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 return new RootWindowHostLinux(bounds); 912 return new RootWindowHostLinux(bounds);
905 } 913 }
906 914
907 // static 915 // static
908 gfx::Size RootWindowHost::GetNativeScreenSize() { 916 gfx::Size RootWindowHost::GetNativeScreenSize() {
909 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 917 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
910 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 918 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
911 } 919 }
912 920
913 } // namespace aura 921 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/base/touch/touch_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698