| 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/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "ui/events/devices/x11/device_data_manager_x11.h" | 44 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 45 #include "ui/events/devices/x11/device_list_cache_x11.h" | 45 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 46 #include "ui/events/devices/x11/touch_factory_x11.h" | 46 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 47 #include "ui/events/event.h" | 47 #include "ui/events/event.h" |
| 48 #include "ui/events/event_switches.h" | 48 #include "ui/events/event_switches.h" |
| 49 #include "ui/events/event_utils.h" | 49 #include "ui/events/event_utils.h" |
| 50 #include "ui/events/keycodes/keyboard_codes.h" | 50 #include "ui/events/keycodes/keyboard_codes.h" |
| 51 #include "ui/events/platform/platform_event_observer.h" | 51 #include "ui/events/platform/platform_event_observer.h" |
| 52 #include "ui/events/platform/platform_event_source.h" | 52 #include "ui/events/platform/platform_event_source.h" |
| 53 #include "ui/events/platform/x11/x11_event_source.h" | 53 #include "ui/events/platform/x11/x11_event_source.h" |
| 54 #include "ui/gfx/x/x11_atom_cache.h" |
| 54 | 55 |
| 55 using std::max; | 56 using std::max; |
| 56 using std::min; | 57 using std::min; |
| 57 | 58 |
| 58 namespace aura { | 59 namespace aura { |
| 59 | 60 |
| 60 namespace { | 61 namespace { |
| 61 | 62 |
| 62 constexpr uint32_t kInputEventMask = | 63 constexpr uint32_t kInputEventMask = |
| 63 ButtonPressMask | ButtonReleaseMask | FocusChangeMask | KeyPressMask | | 64 ButtonPressMask | ButtonReleaseMask | FocusChangeMask | KeyPressMask | |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 139 |
| 139 if (ui::IsXInput2Available()) { | 140 if (ui::IsXInput2Available()) { |
| 140 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); | 141 ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); |
| 141 SelectXInput2EventsForRootWindow(xdisplay_, x_root_window_); | 142 SelectXInput2EventsForRootWindow(xdisplay_, x_root_window_); |
| 142 } | 143 } |
| 143 | 144 |
| 144 // TODO(erg): We currently only request window deletion events. We also | 145 // TODO(erg): We currently only request window deletion events. We also |
| 145 // should listen for activation events and anything else that GTK+ listens | 146 // should listen for activation events and anything else that GTK+ listens |
| 146 // for, and do something useful. | 147 // for, and do something useful. |
| 147 ::Atom protocols[2]; | 148 ::Atom protocols[2]; |
| 148 protocols[0] = ui::GetAtom("WM_DELETE_WINDOW"); | 149 protocols[0] = gfx::GetAtom("WM_DELETE_WINDOW"); |
| 149 protocols[1] = ui::GetAtom("_NET_WM_PING"); | 150 protocols[1] = gfx::GetAtom("_NET_WM_PING"); |
| 150 XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); | 151 XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); |
| 151 | 152 |
| 152 // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with | 153 // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with |
| 153 // the desktop environment. | 154 // the desktop environment. |
| 154 XSetWMProperties(xdisplay_, xwindow_, NULL, NULL, NULL, 0, NULL, NULL, NULL); | 155 XSetWMProperties(xdisplay_, xwindow_, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
| 155 ui::SetWindowClassHint(xdisplay_, xwindow_, "chromiumos", "ChromiumOS"); | 156 ui::SetWindowClassHint(xdisplay_, xwindow_, "chromiumos", "ChromiumOS"); |
| 156 | 157 |
| 157 // Likewise, the X server needs to know this window's pid so it knows which | 158 // Likewise, the X server needs to know this window's pid so it knows which |
| 158 // program to kill if the window hangs. | 159 // program to kill if the window hangs. |
| 159 // XChangeProperty() expects "pid" to be long. | 160 // XChangeProperty() expects "pid" to be long. |
| 160 static_assert(sizeof(long) >= sizeof(pid_t), | 161 static_assert(sizeof(long) >= sizeof(pid_t), |
| 161 "pid_t should not be larger than long"); | 162 "pid_t should not be larger than long"); |
| 162 long pid = getpid(); | 163 long pid = getpid(); |
| 163 XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_PID"), XA_CARDINAL, | 164 XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_PID"), XA_CARDINAL, |
| 164 32, PropModeReplace, reinterpret_cast<unsigned char*>(&pid), | 165 32, PropModeReplace, reinterpret_cast<unsigned char*>(&pid), |
| 165 1); | 166 1); |
| 166 | 167 |
| 167 XRRSelectInput(xdisplay_, x_root_window_, | 168 XRRSelectInput(xdisplay_, x_root_window_, |
| 168 RRScreenChangeNotifyMask | RROutputChangeNotifyMask); | 169 RRScreenChangeNotifyMask | RROutputChangeNotifyMask); |
| 169 CreateCompositor(); | 170 CreateCompositor(); |
| 170 OnAcceleratedWidgetAvailable(); | 171 OnAcceleratedWidgetAvailable(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 WindowTreeHostX11::~WindowTreeHostX11() { | 174 WindowTreeHostX11::~WindowTreeHostX11() { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 OnHostResizedInPixels(bounds.size()); | 301 OnHostResizedInPixels(bounds.size()); |
| 301 if (origin_changed) | 302 if (origin_changed) |
| 302 OnHostMovedInPixels(bounds_.origin()); | 303 OnHostMovedInPixels(bounds_.origin()); |
| 303 break; | 304 break; |
| 304 } | 305 } |
| 305 case GenericEvent: | 306 case GenericEvent: |
| 306 DispatchXI2Event(xev); | 307 DispatchXI2Event(xev); |
| 307 break; | 308 break; |
| 308 case ClientMessage: { | 309 case ClientMessage: { |
| 309 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); | 310 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); |
| 310 if (message_type == ui::GetAtom("WM_DELETE_WINDOW")) { | 311 if (message_type == gfx::GetAtom("WM_DELETE_WINDOW")) { |
| 311 // We have received a close message from the window manager. | 312 // We have received a close message from the window manager. |
| 312 OnHostCloseRequested(); | 313 OnHostCloseRequested(); |
| 313 } else if (message_type == ui::GetAtom("_NET_WM_PING")) { | 314 } else if (message_type == gfx::GetAtom("_NET_WM_PING")) { |
| 314 XEvent reply_event = *xev; | 315 XEvent reply_event = *xev; |
| 315 reply_event.xclient.window = x_root_window_; | 316 reply_event.xclient.window = x_root_window_; |
| 316 | 317 |
| 317 XSendEvent(xdisplay_, | 318 XSendEvent(xdisplay_, |
| 318 reply_event.xclient.window, | 319 reply_event.xclient.window, |
| 319 False, | 320 False, |
| 320 SubstructureRedirectMask | SubstructureNotifyMask, | 321 SubstructureRedirectMask | SubstructureNotifyMask, |
| 321 &reply_event); | 322 &reply_event); |
| 322 XFlush(xdisplay_); | 323 XFlush(xdisplay_); |
| 323 } | 324 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 ui::LocatedEvent* event) { | 553 ui::LocatedEvent* event) { |
| 553 SendEventToSink(event); | 554 SendEventToSink(event); |
| 554 } | 555 } |
| 555 | 556 |
| 556 // static | 557 // static |
| 557 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds_in_pixels) { | 558 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds_in_pixels) { |
| 558 return new WindowTreeHostX11(bounds_in_pixels); | 559 return new WindowTreeHostX11(bounds_in_pixels); |
| 559 } | 560 } |
| 560 | 561 |
| 561 } // namespace aura | 562 } // namespace aura |
| OLD | NEW |