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

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: 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
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 943d3c2389b3871d1303b31bc06084fc2e022e07..dbf01b5e081ef1ab3165ceb388dff1d1568caa8d 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 when running
+ // with X11. These locations crop up when windows overlap or when dragging.
sky 2016/08/11 20:58:04 I believe this will also happen on some devices th
kylechar 2016/08/12 16:09:11 Yep, it definitely needs more work. This will avoi
+ if (!target_display) {
+ LOG(ERROR) << "Invalid event location " << location->ToString();
sky 2016/08/11 20:58:04 Make this a DVLOG(1) given it can happen in normal
kylechar 2016/08/12 16:09:11 Done.
+ 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->root_window()->bounds().origin();
sky 2016/08/11 20:58:04 The location of the root is always 0, 0. Don't you
kylechar 2016/08/12 16:09:11 I'll change it to use the PlatformDisplay bounds b
sky 2016/08/12 16:47:46 I think we need to put them at 0, 0, otherwise I w
+ location->Offset(-origin.x(), -origin.y());
+ return display_root->root();
}
void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) {
« services/ui/ws/event_dispatcher_delegate.h ('K') | « 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