| OLD | NEW |
| 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 Loading... |
| 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 |
| 99 int num_masks = -1; |
| 100 XIEventMask* current_mask = XIGetSelectedEvents(display, root_window, |
| 101 &num_masks); |
| 102 if (current_mask) { |
| 103 XFree(current_mask); |
| 104 return; |
| 105 } |
| 106 |
| 97 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; | 107 unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; |
| 98 memset(mask, 0, sizeof(mask)); | 108 memset(mask, 0, sizeof(mask)); |
| 99 | 109 |
| 100 XISetMask(mask, XI_HierarchyChanged); | 110 XISetMask(mask, XI_HierarchyChanged); |
| 101 | 111 |
| 102 XISetMask(mask, XI_KeyPress); | 112 XISetMask(mask, XI_KeyPress); |
| 103 XISetMask(mask, XI_KeyRelease); | 113 XISetMask(mask, XI_KeyRelease); |
| 104 | 114 |
| 105 #if defined(USE_XI2_MT) | 115 #if defined(USE_XI2_MT) |
| 106 XISetMask(mask, XI_TouchBegin); | 116 XISetMask(mask, XI_TouchBegin); |
| 107 XISetMask(mask, XI_TouchUpdate); | 117 XISetMask(mask, XI_TouchUpdate); |
| 108 XISetMask(mask, XI_TouchEnd); | 118 XISetMask(mask, XI_TouchEnd); |
| 109 #endif | 119 #endif |
| 120 |
| 121 XIEventMask evmask; |
| 110 evmask.deviceid = XIAllDevices; | 122 evmask.deviceid = XIAllDevices; |
| 111 evmask.mask_len = sizeof(mask); | 123 evmask.mask_len = sizeof(mask); |
| 112 evmask.mask = mask; | 124 evmask.mask = mask; |
| 113 | 125 |
| 114 XISelectEvents(display, root_window, &evmask, 1); | 126 XISelectEvents(display, root_window, &evmask, 1); |
| 115 } | 127 } |
| 116 | 128 |
| 117 // We emulate Windows' WM_KEYDOWN and WM_CHAR messages. WM_CHAR events are only | 129 // We emulate Windows' WM_KEYDOWN and WM_CHAR messages. WM_CHAR events are only |
| 118 // generated for certain keys; see | 130 // generated for certain keys; see |
| 119 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646268.aspx. Per | 131 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646268.aspx. Per |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 return new RootWindowHostLinux(bounds); | 916 return new RootWindowHostLinux(bounds); |
| 905 } | 917 } |
| 906 | 918 |
| 907 // static | 919 // static |
| 908 gfx::Size RootWindowHost::GetNativeScreenSize() { | 920 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 909 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 921 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| 910 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 922 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 911 } | 923 } |
| 912 | 924 |
| 913 } // namespace aura | 925 } // namespace aura |
| OLD | NEW |