Chromium Code Reviews| 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/XInput2.h> | |
| 7 #include <X11/extensions/Xrandr.h> | 8 #include <X11/extensions/Xrandr.h> |
| 8 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 9 | 10 |
| 10 // It clashes with out RootWindow. | 11 // It clashes with out RootWindow. |
| 11 #undef RootWindow | 12 #undef RootWindow |
| 12 | 13 |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
| 18 #include "ui/base/layout.h" | 19 #include "ui/base/layout.h" |
| 19 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
| 20 #include "ui/display/display_finder.h" | 21 #include "ui/display/display_finder.h" |
| 21 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 22 #include "ui/display/util/display_util.h" | 23 #include "ui/display/util/display_util.h" |
| 23 #include "ui/display/util/x11/edid_parser_x11.h" | 24 #include "ui/display/util/x11/edid_parser_x11.h" |
| 24 #include "ui/events/platform/platform_event_source.h" | 25 #include "ui/events/platform/platform_event_source.h" |
| 26 #include "ui/events/platform/x11/x11_event_source.h" | |
| 25 #include "ui/gfx/font_render_params.h" | 27 #include "ui/gfx/font_render_params.h" |
| 26 #include "ui/gfx/geometry/point_conversions.h" | 28 #include "ui/gfx/geometry/point_conversions.h" |
| 27 #include "ui/gfx/geometry/size_conversions.h" | 29 #include "ui/gfx/geometry/size_conversions.h" |
| 28 #include "ui/gfx/native_widget_types.h" | 30 #include "ui/gfx/native_widget_types.h" |
| 29 #include "ui/gfx/x/x11_types.h" | 31 #include "ui/gfx/x/x11_types.h" |
| 30 #include "ui/views/linux_ui/linux_ui.h" | 32 #include "ui/views/linux_ui/linux_ui.h" |
| 31 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 33 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 32 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 34 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| 33 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" | 35 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" |
| 34 | 36 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 if (has_xrandr_ && ui::PlatformEventSource::GetInstance()) | 128 if (has_xrandr_ && ui::PlatformEventSource::GetInstance()) |
| 127 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 129 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
| 128 } | 130 } |
| 129 | 131 |
| 130 //////////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////////// |
| 131 // DesktopScreenX11, display::Screen implementation: | 133 // DesktopScreenX11, display::Screen implementation: |
| 132 | 134 |
| 133 gfx::Point DesktopScreenX11::GetCursorScreenPoint() { | 135 gfx::Point DesktopScreenX11::GetCursorScreenPoint() { |
| 134 TRACE_EVENT0("views", "DesktopScreenX11::GetCursorScreenPoint()"); | 136 TRACE_EVENT0("views", "DesktopScreenX11::GetCursorScreenPoint()"); |
| 135 | 137 |
| 136 XDisplay* display = gfx::GetXDisplay(); | 138 const XEvent* event = |
| 139 ui::X11EventSource::HasInstance() | |
| 140 ? ui::X11EventSource::GetInstance()->get_dispatching_event() | |
| 141 : nullptr; | |
| 142 | |
| 143 if (event) { | |
| 144 switch (event->type) { | |
| 145 case ButtonPress: | |
| 146 case ButtonRelease: | |
| 147 return gfx::Point(event->xbutton.x_root, event->xbutton.y_root); | |
| 148 case MotionNotify: | |
| 149 return gfx::Point(event->xmotion.x_root, event->xmotion.y_root); | |
| 150 case EnterNotify: | |
| 151 case LeaveNotify: | |
| 152 return gfx::Point(event->xcrossing.x_root, event->xcrossing.y_root); | |
| 153 case GenericEvent: | |
| 154 const XIEvent* xi_event = | |
|
Tom (Use chromium acct)
2016/10/07 00:23:18
Do we need to check for deviceid or sourceid here?
sadrul
2016/10/07 02:12:51
Probably check with TouchFactory first (like in ht
Tom (Use chromium acct)
2016/10/07 21:13:18
Done.
| |
| 155 static_cast<const XIEvent*>(event->xcookie.data); | |
| 156 switch (xi_event->evtype) { | |
| 157 case XI_ButtonPress: | |
| 158 case XI_ButtonRelease: | |
| 159 case XI_Motion: { | |
| 160 const XIDeviceEvent* device_event = | |
| 161 static_cast<const XIDeviceEvent*>(event->xcookie.data); | |
| 162 return gfx::Point(device_event->root_x, device_event->root_y); | |
| 163 } | |
| 164 case XI_Enter: | |
| 165 case XI_Leave: { | |
| 166 const XIEnterEvent* enter_event = | |
| 167 static_cast<const XIEnterEvent*>(event->xcookie.data); | |
| 168 return gfx::Point(enter_event->root_x, enter_event->root_y); | |
| 169 } | |
|
Tom (Use chromium acct)
2016/10/07 00:23:18
Do we also need to handle XI_Touch{Begin,Update,En
sadrul
2016/10/07 02:12:51
Let's not. chrome generally expects that touch eve
Tom (Use chromium acct)
2016/10/07 21:13:18
Acknowledged.
| |
| 170 } | |
| 171 } | |
| 172 } | |
| 137 | 173 |
| 138 ::Window root, child; | 174 ::Window root, child; |
| 139 int root_x, root_y, win_x, win_y; | 175 int root_x, root_y, win_x, win_y; |
| 140 unsigned int mask; | 176 unsigned int mask; |
| 141 XQueryPointer(display, | 177 XQueryPointer(xdisplay_, x_root_window_, &root, &child, &root_x, &root_y, |
| 142 DefaultRootWindow(display), | 178 &win_x, &win_y, &mask); |
| 143 &root, | |
| 144 &child, | |
| 145 &root_x, | |
| 146 &root_y, | |
| 147 &win_x, | |
| 148 &win_y, | |
| 149 &mask); | |
| 150 | 179 |
| 151 return PixelToDIPPoint(gfx::Point(root_x, root_y)); | 180 return PixelToDIPPoint(gfx::Point(root_x, root_y)); |
| 152 } | 181 } |
| 153 | 182 |
| 154 bool DesktopScreenX11::IsWindowUnderCursor(gfx::NativeWindow window) { | 183 bool DesktopScreenX11::IsWindowUnderCursor(gfx::NativeWindow window) { |
| 155 return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window; | 184 return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window; |
| 156 } | 185 } |
| 157 | 186 |
| 158 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( | 187 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( |
| 159 const gfx::Point& point) { | 188 const gfx::Point& point) { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 GetPrimaryDisplay().device_scale_factor()); | 433 GetPrimaryDisplay().device_scale_factor()); |
| 405 } | 434 } |
| 406 | 435 |
| 407 //////////////////////////////////////////////////////////////////////////////// | 436 //////////////////////////////////////////////////////////////////////////////// |
| 408 | 437 |
| 409 display::Screen* CreateDesktopScreen() { | 438 display::Screen* CreateDesktopScreen() { |
| 410 return new DesktopScreenX11; | 439 return new DesktopScreenX11; |
| 411 } | 440 } |
| 412 | 441 |
| 413 } // namespace views | 442 } // namespace views |
| OLD | NEW |