OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/platform_window/x11/x11_window_base.h" | 5 #include "ui/platform_window/x11/x11_window_base.h" |
6 | 6 |
7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/Xutil.h> | 10 #include <X11/Xutil.h> |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "ui/base/platform_window_defaults.h" |
15 #include "ui/base/x/x11_window_event_manager.h" | 16 #include "ui/base/x/x11_window_event_manager.h" |
16 #include "ui/events/devices/x11/touch_factory_x11.h" | 17 #include "ui/events/devices/x11/touch_factory_x11.h" |
17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
18 #include "ui/events/event_utils.h" | 19 #include "ui/events/event_utils.h" |
19 #include "ui/events/platform/platform_event_dispatcher.h" | 20 #include "ui/events/platform/platform_event_dispatcher.h" |
20 #include "ui/events/platform/platform_event_source.h" | 21 #include "ui/events/platform/platform_event_source.h" |
21 #include "ui/events/platform/x11/x11_event_source.h" | 22 #include "ui/events/platform/x11/x11_event_source.h" |
22 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
23 #include "ui/platform_window/platform_window_delegate.h" | 24 #include "ui/platform_window/platform_window_delegate.h" |
24 | 25 |
25 namespace ui { | 26 namespace ui { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 const char* kAtomsToCache[] = {"UTF8_STRING", "WM_DELETE_WINDOW", | 30 const char* kAtomsToCache[] = {"UTF8_STRING", "WM_DELETE_WINDOW", |
30 "_NET_WM_NAME", "_NET_WM_PID", | 31 "_NET_WM_NAME", "_NET_WM_PID", |
31 "_NET_WM_PING", NULL}; | 32 "_NET_WM_PING", NULL}; |
32 | 33 |
33 bool g_override_redirect = false; | |
34 | |
35 XID FindXEventTarget(const XEvent& xev) { | 34 XID FindXEventTarget(const XEvent& xev) { |
36 XID target = xev.xany.window; | 35 XID target = xev.xany.window; |
37 if (xev.type == GenericEvent) | 36 if (xev.type == GenericEvent) |
38 target = static_cast<XIDeviceEvent*>(xev.xcookie.data)->event; | 37 target = static_cast<XIDeviceEvent*>(xev.xcookie.data)->event; |
39 return target; | 38 return target; |
40 } | 39 } |
41 | 40 |
42 } // namespace | 41 } // namespace |
43 | 42 |
44 X11WindowBase::X11WindowBase(PlatformWindowDelegate* delegate, | 43 X11WindowBase::X11WindowBase(PlatformWindowDelegate* delegate, |
(...skipping 26 matching lines...) Expand all Loading... |
71 XDestroyWindow(xdisplay, xwindow); | 70 XDestroyWindow(xdisplay, xwindow); |
72 } | 71 } |
73 | 72 |
74 void X11WindowBase::Create() { | 73 void X11WindowBase::Create() { |
75 DCHECK(!bounds_.size().IsEmpty()); | 74 DCHECK(!bounds_.size().IsEmpty()); |
76 | 75 |
77 XSetWindowAttributes swa; | 76 XSetWindowAttributes swa; |
78 memset(&swa, 0, sizeof(swa)); | 77 memset(&swa, 0, sizeof(swa)); |
79 swa.background_pixmap = None; | 78 swa.background_pixmap = None; |
80 swa.bit_gravity = NorthWestGravity; | 79 swa.bit_gravity = NorthWestGravity; |
81 swa.override_redirect = g_override_redirect; | 80 swa.override_redirect = UseTestConfigForPlatformWindows(); |
82 xwindow_ = | 81 xwindow_ = |
83 XCreateWindow(xdisplay_, xroot_window_, bounds_.x(), bounds_.y(), | 82 XCreateWindow(xdisplay_, xroot_window_, bounds_.x(), bounds_.y(), |
84 bounds_.width(), bounds_.height(), | 83 bounds_.width(), bounds_.height(), |
85 0, // border width | 84 0, // border width |
86 CopyFromParent, // depth | 85 CopyFromParent, // depth |
87 InputOutput, | 86 InputOutput, |
88 CopyFromParent, // visual | 87 CopyFromParent, // visual |
89 CWBackPixmap | CWBitGravity | CWOverrideRedirect, &swa); | 88 CWBackPixmap | CWBitGravity | CWOverrideRedirect, &swa); |
90 | 89 |
91 // Setup XInput event mask. | 90 // Setup XInput event mask. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 XSendEvent(xdisplay_, reply_event.xclient.window, False, | 296 XSendEvent(xdisplay_, reply_event.xclient.window, False, |
298 SubstructureRedirectMask | SubstructureNotifyMask, | 297 SubstructureRedirectMask | SubstructureNotifyMask, |
299 &reply_event); | 298 &reply_event); |
300 XFlush(xdisplay_); | 299 XFlush(xdisplay_); |
301 } | 300 } |
302 break; | 301 break; |
303 } | 302 } |
304 } | 303 } |
305 } | 304 } |
306 | 305 |
307 namespace test { | |
308 | |
309 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | |
310 g_override_redirect = override_redirect; | |
311 } | |
312 | |
313 } // namespace test | |
314 } // namespace ui | 306 } // namespace ui |
OLD | NEW |