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

Side by Side Diff: ui/aura/root_window_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/root_window_host.h" 5 #include "ui/aura/root_window_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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 466 }
465 case MapNotify: { 467 case MapNotify: {
466 // If there's no window manager running, we need to assign the X input 468 // If there's no window manager running, we need to assign the X input
467 // focus to our host window. 469 // focus to our host window.
468 if (!IsWindowManagerPresent()) 470 if (!IsWindowManagerPresent())
469 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); 471 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime);
470 handled = true; 472 handled = true;
471 break; 473 break;
472 } 474 }
473 case MappingNotify: { 475 case MappingNotify: {
474 if (xev->xmapping.request == MappingModifier || 476 switch (xev->xmapping.request) {
475 xev->xmapping.request == MappingKeyboard) 477 case MappingModifier:
476 XRefreshKeyboardMapping(&xev->xmapping); 478 case MappingKeyboard:
479 XRefreshKeyboardMapping(&xev->xmapping);
480 break;
481 case MappingPointer:
482 ui::UpdateButtonMap();
483 break;
484 default:
485 NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request;
486 break;
487 }
477 break; 488 break;
478 } 489 }
479 case MotionNotify: { 490 case MotionNotify: {
480 // Discard all but the most recent motion event that targets the same 491 // Discard all but the most recent motion event that targets the same
481 // window with unchanged state. 492 // window with unchanged state.
482 XEvent last_event; 493 XEvent last_event;
483 while (XPending(xev->xany.display)) { 494 while (XPending(xev->xany.display)) {
484 XEvent next_event; 495 XEvent next_event;
485 XPeekEvent(xev->xany.display, &next_event); 496 XPeekEvent(xev->xany.display, &next_event);
486 if (next_event.type == MotionNotify && 497 if (next_event.type == MotionNotify &&
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return new RootWindowHostLinux(bounds); 630 return new RootWindowHostLinux(bounds);
620 } 631 }
621 632
622 // static 633 // static
623 gfx::Size RootWindowHost::GetNativeScreenSize() { 634 gfx::Size RootWindowHost::GetNativeScreenSize() {
624 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); 635 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay();
625 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 636 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
626 } 637 }
627 638
628 } // namespace aura 639 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698