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/views/widget/desktop_aura/desktop_screen_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" |
6 | 6 |
7 #include <X11/extensions/Xrandr.h> | 7 #include <X11/extensions/Xrandr.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // It clashes with out RootWindow. | 10 // It clashes with out RootWindow. |
11 #undef RootWindow | 11 #undef RootWindow |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
17 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
18 #include "ui/base/layout.h" | 18 #include "ui/base/layout.h" |
19 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
20 #include "ui/display/display_finder.h" | 20 #include "ui/display/display_finder.h" |
21 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
22 #include "ui/display/util/display_util.h" | 22 #include "ui/display/util/display_util.h" |
23 #include "ui/display/util/x11/edid_parser_x11.h" | 23 #include "ui/display/util/x11/edid_parser_x11.h" |
24 #include "ui/events/platform/platform_event_source.h" | 24 #include "ui/events/platform/platform_event_source.h" |
| 25 #include "ui/events/platform/x11/x11_event_source.h" |
25 #include "ui/gfx/font_render_params.h" | 26 #include "ui/gfx/font_render_params.h" |
26 #include "ui/gfx/geometry/point_conversions.h" | 27 #include "ui/gfx/geometry/point_conversions.h" |
27 #include "ui/gfx/geometry/size_conversions.h" | 28 #include "ui/gfx/geometry/size_conversions.h" |
28 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
29 #include "ui/gfx/x/x11_types.h" | 30 #include "ui/gfx/x/x11_types.h" |
30 #include "ui/views/linux_ui/linux_ui.h" | 31 #include "ui/views/linux_ui/linux_ui.h" |
31 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 32 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
32 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 33 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
33 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" | 34 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" |
34 | 35 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (has_xrandr_ && ui::PlatformEventSource::GetInstance()) | 127 if (has_xrandr_ && ui::PlatformEventSource::GetInstance()) |
127 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 128 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
128 } | 129 } |
129 | 130 |
130 //////////////////////////////////////////////////////////////////////////////// | 131 //////////////////////////////////////////////////////////////////////////////// |
131 // DesktopScreenX11, display::Screen implementation: | 132 // DesktopScreenX11, display::Screen implementation: |
132 | 133 |
133 gfx::Point DesktopScreenX11::GetCursorScreenPoint() { | 134 gfx::Point DesktopScreenX11::GetCursorScreenPoint() { |
134 TRACE_EVENT0("views", "DesktopScreenX11::GetCursorScreenPoint()"); | 135 TRACE_EVENT0("views", "DesktopScreenX11::GetCursorScreenPoint()"); |
135 | 136 |
136 XDisplay* display = gfx::GetXDisplay(); | 137 if (ui::X11EventSource::HasInstance()) { |
| 138 auto point = ui::X11EventSource::GetInstance() |
| 139 ->GetRootCursorLocationFromCurrentEvent(); |
| 140 if (point) |
| 141 return point.value(); |
| 142 } |
137 | 143 |
138 ::Window root, child; | 144 ::Window root, child; |
139 int root_x, root_y, win_x, win_y; | 145 int root_x, root_y, win_x, win_y; |
140 unsigned int mask; | 146 unsigned int mask; |
141 XQueryPointer(display, | 147 XQueryPointer(xdisplay_, x_root_window_, &root, &child, &root_x, &root_y, |
142 DefaultRootWindow(display), | 148 &win_x, &win_y, &mask); |
143 &root, | |
144 &child, | |
145 &root_x, | |
146 &root_y, | |
147 &win_x, | |
148 &win_y, | |
149 &mask); | |
150 | 149 |
151 return PixelToDIPPoint(gfx::Point(root_x, root_y)); | 150 return PixelToDIPPoint(gfx::Point(root_x, root_y)); |
152 } | 151 } |
153 | 152 |
154 bool DesktopScreenX11::IsWindowUnderCursor(gfx::NativeWindow window) { | 153 bool DesktopScreenX11::IsWindowUnderCursor(gfx::NativeWindow window) { |
155 return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window; | 154 return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window; |
156 } | 155 } |
157 | 156 |
158 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( | 157 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( |
159 const gfx::Point& point) { | 158 const gfx::Point& point) { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 GetPrimaryDisplay().device_scale_factor()); | 403 GetPrimaryDisplay().device_scale_factor()); |
405 } | 404 } |
406 | 405 |
407 //////////////////////////////////////////////////////////////////////////////// | 406 //////////////////////////////////////////////////////////////////////////////// |
408 | 407 |
409 display::Screen* CreateDesktopScreen() { | 408 display::Screen* CreateDesktopScreen() { |
410 return new DesktopScreenX11; | 409 return new DesktopScreenX11; |
411 } | 410 } |
412 | 411 |
413 } // namespace views | 412 } // namespace views |
OLD | NEW |