Chromium Code Reviews| Index: services/ui/ws/window_manager_state.cc |
| diff --git a/services/ui/ws/window_manager_state.cc b/services/ui/ws/window_manager_state.cc |
| index d34fe4bfcfcf13850ef4a44c2592b5e6ee8cd04c..134864d4b1aff1dceae15b52dd52502707a6a94d 100644 |
| --- a/services/ui/ws/window_manager_state.cc |
| +++ b/services/ui/ws/window_manager_state.cc |
| @@ -4,6 +4,8 @@ |
| #include "services/ui/ws/window_manager_state.h" |
| +#include <utility> |
| + |
| #include "base/memory/weak_ptr.h" |
| #include "services/shell/public/interfaces/connector.mojom.h" |
| #include "services/ui/common/event_matcher_util.h" |
| @@ -522,16 +524,33 @@ ClientSpecificId WindowManagerState::GetEventTargetClientId( |
| } |
| ServerWindow* WindowManagerState::GetRootWindowContaining( |
| - const gfx::Point& location) { |
| - if (display_manager()->displays().empty()) |
| - return nullptr; |
| + gfx::Point* location) { |
| + Display* target_display = nullptr; |
| + for (Display* display : display_manager()->displays()) { |
| + if (display->platform_display()->GetBounds().Contains(*location)) { |
| + target_display = display; |
| + break; |
| + } |
| + } |
| + |
| + // TODO(kylechar): Better handle locations outside the window. Overlapping X11 |
| + // windows, dragging and touch sensors need to be handled properly. |
| + if (!target_display) { |
| + DVLOG(1) << "Invalid event location " << location->ToString(); |
| + target_display = *(display_manager()->displays().begin()); |
| + } |
| - // TODO(sky): this isn't right. To correctly implement need bounds of |
| - // Display, which we aren't tracking yet. For now, use the first display. |
| - Display* display = *(display_manager()->displays().begin()); |
| WindowManagerDisplayRoot* display_root = |
| - display->GetWindowManagerDisplayRootForUser(user_id()); |
| - return display_root ? display_root->root() : nullptr; |
| + target_display->GetWindowManagerDisplayRootForUser(user_id()); |
| + |
| + if (!display_root) |
| + return nullptr; |
| + |
| + // Translate the location to be relative to the display instead of relative |
| + // to the screen space. |
| + gfx::Point origin = target_display->platform_display()->GetBounds().origin(); |
| + location->Offset(-origin.x(), -origin.y()); |
|
sky
2016/08/12 16:47:46
Typically we do something like:
*location -= origi
kylechar
2016/08/12 17:25:12
Done.
|
| + return display_root->root(); |
| } |
| void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { |