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

Side by Side Diff: ui/views/widget/desktop_aura/x11_window_event_filter.cc

Issue 2914103002: Remove usages of XInternAtom (Closed)
Patch Set: Address sadrul and sergeyu comments Created 3 years, 6 months 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
« no previous file with comments | « ui/views/widget/desktop_aura/x11_window_event_filter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/widget/desktop_aura/x11_window_event_filter.h" 5 #include "ui/views/widget/desktop_aura/x11_window_event_filter.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
11 11
12 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" 12 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
13 #include "ui/aura/client/aura_constants.h" 13 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_delegate.h" 15 #include "ui/aura/window_delegate.h"
16 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
17 #include "ui/base/hit_test.h" 17 #include "ui/base/hit_test.h"
18 #include "ui/base/x/x11_util.h"
18 #include "ui/display/display.h" 19 #include "ui/display/display.h"
19 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
20 #include "ui/events/event.h" 21 #include "ui/events/event.h"
21 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
22 #include "ui/gfx/x/x11_types.h" 23 #include "ui/gfx/x/x11_types.h"
23 #include "ui/views/linux_ui/linux_ui.h" 24 #include "ui/views/linux_ui/linux_ui.h"
24 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" 25 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
25 #include "ui/views/widget/native_widget_aura.h" 26 #include "ui/views/widget/native_widget_aura.h"
26 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
27 28
28 namespace { 29 namespace {
29 30
30 // These constants are defined in the Extended Window Manager Hints 31 // These constants are defined in the Extended Window Manager Hints
31 // standard...and aren't in any header that I can find. 32 // standard...and aren't in any header that I can find.
32 const int k_NET_WM_MOVERESIZE_SIZE_TOPLEFT = 0; 33 const int k_NET_WM_MOVERESIZE_SIZE_TOPLEFT = 0;
33 const int k_NET_WM_MOVERESIZE_SIZE_TOP = 1; 34 const int k_NET_WM_MOVERESIZE_SIZE_TOP = 1;
34 const int k_NET_WM_MOVERESIZE_SIZE_TOPRIGHT = 2; 35 const int k_NET_WM_MOVERESIZE_SIZE_TOPRIGHT = 2;
35 const int k_NET_WM_MOVERESIZE_SIZE_RIGHT = 3; 36 const int k_NET_WM_MOVERESIZE_SIZE_RIGHT = 3;
36 const int k_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT = 4; 37 const int k_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT = 4;
37 const int k_NET_WM_MOVERESIZE_SIZE_BOTTOM = 5; 38 const int k_NET_WM_MOVERESIZE_SIZE_BOTTOM = 5;
38 const int k_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6; 39 const int k_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6;
39 const int k_NET_WM_MOVERESIZE_SIZE_LEFT = 7; 40 const int k_NET_WM_MOVERESIZE_SIZE_LEFT = 7;
40 const int k_NET_WM_MOVERESIZE_MOVE = 8; 41 const int k_NET_WM_MOVERESIZE_MOVE = 8;
41 42
42 const char* kAtomsToCache[] = {
43 "_NET_WM_MOVERESIZE",
44 NULL
45 };
46
47 } // namespace 43 } // namespace
48 44
49 namespace views { 45 namespace views {
50 46
51 X11WindowEventFilter::X11WindowEventFilter( 47 X11WindowEventFilter::X11WindowEventFilter(
52 DesktopWindowTreeHost* window_tree_host) 48 DesktopWindowTreeHost* window_tree_host)
53 : xdisplay_(gfx::GetXDisplay()), 49 : xdisplay_(gfx::GetXDisplay()),
54 xwindow_(window_tree_host->AsWindowTreeHost()->GetAcceleratedWidget()), 50 xwindow_(window_tree_host->AsWindowTreeHost()->GetAcceleratedWidget()),
55 x_root_window_(DefaultRootWindow(xdisplay_)), 51 x_root_window_(DefaultRootWindow(xdisplay_)),
56 atom_cache_(xdisplay_, kAtomsToCache),
57 window_tree_host_(window_tree_host), 52 window_tree_host_(window_tree_host),
58 click_component_(HTNOWHERE) { 53 click_component_(HTNOWHERE) {
59 } 54 }
60 55
61 X11WindowEventFilter::~X11WindowEventFilter() { 56 X11WindowEventFilter::~X11WindowEventFilter() {
62 } 57 }
63 58
64 void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) { 59 void X11WindowEventFilter::OnMouseEvent(ui::MouseEvent* event) {
65 if (event->type() != ui::ET_MOUSE_PRESSED) 60 if (event->type() != ui::ET_MOUSE_PRESSED)
66 return; 61 return;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // because what we're about to do is tell the window manager 213 // because what we're about to do is tell the window manager
219 // that it's now responsible for moving the window around; it immediately 214 // that it's now responsible for moving the window around; it immediately
220 // grabs when it receives the event below. 215 // grabs when it receives the event below.
221 XUngrabPointer(xdisplay_, CurrentTime); 216 XUngrabPointer(xdisplay_, CurrentTime);
222 217
223 XEvent event; 218 XEvent event;
224 memset(&event, 0, sizeof(event)); 219 memset(&event, 0, sizeof(event));
225 event.xclient.type = ClientMessage; 220 event.xclient.type = ClientMessage;
226 event.xclient.display = xdisplay_; 221 event.xclient.display = xdisplay_;
227 event.xclient.window = xwindow_; 222 event.xclient.window = xwindow_;
228 event.xclient.message_type = atom_cache_.GetAtom("_NET_WM_MOVERESIZE"); 223 event.xclient.message_type = ui::GetAtom("_NET_WM_MOVERESIZE");
229 event.xclient.format = 32; 224 event.xclient.format = 32;
230 event.xclient.data.l[0] = screen_location.x(); 225 event.xclient.data.l[0] = screen_location.x();
231 event.xclient.data.l[1] = screen_location.y(); 226 event.xclient.data.l[1] = screen_location.y();
232 event.xclient.data.l[2] = direction; 227 event.xclient.data.l[2] = direction;
233 event.xclient.data.l[3] = 0; 228 event.xclient.data.l[3] = 0;
234 event.xclient.data.l[4] = 0; 229 event.xclient.data.l[4] = 0;
235 230
236 XSendEvent(xdisplay_, x_root_window_, False, 231 XSendEvent(xdisplay_, x_root_window_, False,
237 SubstructureRedirectMask | SubstructureNotifyMask, 232 SubstructureRedirectMask | SubstructureNotifyMask,
238 &event); 233 &event);
239 234
240 return true; 235 return true;
241 } 236 }
242 237
243 } // namespace views 238 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_window_event_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698