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

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

Issue 8793002: aura-x11: Add support for xmodmap'ed pointer buttons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 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
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 "ui/aura/desktop_host.h" 5 #include "ui/aura/desktop_host.h"
6 6
7 #include <X11/cursorfont.h> 7 #include <X11/cursorfont.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
(...skipping 21 matching lines...) Expand all
32 namespace aura { 32 namespace aura {
33 33
34 namespace { 34 namespace {
35 35
36 // The events reported for slave devices can have incorrect information for some 36 // The events reported for slave devices can have incorrect information for some
37 // fields. This utility function is used to check for such inconsistencies. 37 // fields. This utility function is used to check for such inconsistencies.
38 void CheckXEventForConsistency(XEvent* xevent) { 38 void CheckXEventForConsistency(XEvent* xevent) {
39 static bool expect_master_event = false; 39 static bool expect_master_event = false;
40 static XIDeviceEvent slave_event; 40 static XIDeviceEvent slave_event;
41 static gfx::Point slave_location; 41 static gfx::Point slave_location;
42 static int slave_button;
42 43
43 // Note: If an event comes from a slave pointer device, then it will be 44 // Note: If an event comes from a slave pointer device, then it will be
44 // followed by the same event, but reported from its master pointer device. 45 // followed by the same event, but reported from its master pointer device.
45 // However, if the event comes from a floating slave device (e.g. a 46 // However, if the event comes from a floating slave device (e.g. a
46 // touchscreen), then it will not be followed by a duplicate event, since the 47 // touchscreen), then it will not be followed by a duplicate event, since the
47 // floating slave isn't attached to a master. 48 // floating slave isn't attached to a master.
48 49
49 bool was_expecting_master_event = expect_master_event; 50 bool was_expecting_master_event = expect_master_event;
50 expect_master_event = false; 51 expect_master_event = false;
51 52
52 if (!xevent || xevent->type != GenericEvent) 53 if (!xevent || xevent->type != GenericEvent)
53 return; 54 return;
54 55
55 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); 56 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data);
56 if (xievent->evtype != XI_Motion && 57 if (xievent->evtype != XI_Motion &&
57 xievent->evtype != XI_ButtonPress && 58 xievent->evtype != XI_ButtonPress &&
58 xievent->evtype != XI_ButtonRelease) { 59 xievent->evtype != XI_ButtonRelease) {
59 return; 60 return;
60 } 61 }
61 62
62 if (xievent->sourceid == xievent->deviceid) { 63 if (xievent->sourceid == xievent->deviceid) {
63 slave_event = *xievent; 64 slave_event = *xievent;
64 slave_location = ui::EventLocationFromNative(xevent); 65 slave_location = ui::EventLocationFromNative(xevent);
66 slave_button = ui::EventButtonFromNative(xevent);
65 expect_master_event = true; 67 expect_master_event = true;
66 } else if (was_expecting_master_event) { 68 } else if (was_expecting_master_event) {
67 CHECK_EQ(slave_location.x(), ui::EventLocationFromNative(xevent).x()); 69 CHECK_EQ(slave_location.x(), ui::EventLocationFromNative(xevent).x());
68 CHECK_EQ(slave_location.y(), ui::EventLocationFromNative(xevent).y()); 70 CHECK_EQ(slave_location.y(), ui::EventLocationFromNative(xevent).y());
69 71
70 CHECK_EQ(slave_event.type, xievent->type); 72 CHECK_EQ(slave_event.type, xievent->type);
71 CHECK_EQ(slave_event.evtype, xievent->evtype); 73 CHECK_EQ(slave_event.evtype, xievent->evtype);
72 CHECK_EQ(slave_event.detail, xievent->detail); 74 CHECK_EQ(slave_button, ui::EventButtonFromNative(xevent));
73 CHECK_EQ(slave_event.flags, xievent->flags); 75 CHECK_EQ(slave_event.flags, xievent->flags);
74 CHECK_EQ(slave_event.buttons.mask_len, xievent->buttons.mask_len); 76 CHECK_EQ(slave_event.buttons.mask_len, xievent->buttons.mask_len);
75 CHECK_EQ(slave_event.valuators.mask_len, xievent->valuators.mask_len); 77 CHECK_EQ(slave_event.valuators.mask_len, xievent->valuators.mask_len);
76 CHECK_EQ(slave_event.mods.base, xievent->mods.base); 78 CHECK_EQ(slave_event.mods.base, xievent->mods.base);
77 CHECK_EQ(slave_event.mods.latched, xievent->mods.latched); 79 CHECK_EQ(slave_event.mods.latched, xievent->mods.latched);
78 CHECK_EQ(slave_event.mods.locked, xievent->mods.locked); 80 CHECK_EQ(slave_event.mods.locked, xievent->mods.locked);
79 CHECK_EQ(slave_event.mods.effective, xievent->mods.effective); 81 CHECK_EQ(slave_event.mods.effective, xievent->mods.effective);
80 } 82 }
81 } 83 }
82 84
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 return new DesktopHostLinux(bounds); 611 return new DesktopHostLinux(bounds);
610 } 612 }
611 613
612 // static 614 // static
613 gfx::Size DesktopHost::GetNativeScreenSize() { 615 gfx::Size DesktopHost::GetNativeScreenSize() {
614 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); 616 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay();
615 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 617 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
616 } 618 }
617 619
618 } // namespace aura 620 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698