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

Unified Diff: services/ui/ws/window_manager_state.cc

Issue 2237003002: Find display root ServerWindow for located events in mus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_display
Patch Set: Fix tests. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f25453158095992d9763252c18c20381d3cbfad1 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,36 @@ ClientSpecificId WindowManagerState::GetEventTargetClientId(
}
ServerWindow* WindowManagerState::GetRootWindowContaining(
- const gfx::Point& location) {
+ gfx::Point* location) {
if (display_manager()->displays().empty())
- return nullptr;
+ return nullptr;
+
+ 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 -= origin.OffsetFromOrigin();
+ return display_root->root();
}
void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
« no previous file with comments | « services/ui/ws/window_manager_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698