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

Unified Diff: ui/views/widget/desktop_aura/x11_topmost_window_finder.cc

Issue 260263002: Merge three implementations for getting the topmost x11 window at a point (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « ui/views/widget/desktop_aura/x11_topmost_window_finder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/x11_topmost_window_finder.cc
diff --git a/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc b/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eb0d1bdcba917bb24b5067b87f1dcc5a9bd7de45
--- /dev/null
+++ b/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc
@@ -0,0 +1,78 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
+
+#include "ui/aura/window.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
+
+namespace views {
+
+X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) {
+}
+
+X11TopmostWindowFinder::~X11TopmostWindowFinder() {
+}
+
+aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt(
+ const gfx::Point& screen_loc,
+ const std::set<aura::Window*>& ignore) {
+ screen_loc_ = screen_loc;
+ ignore_ = ignore;
+
+ std::vector<aura::Window*> local_process_windows =
+ DesktopWindowTreeHostX11::GetAllOpenWindows();
+ bool found_local_process_window = false;
+ for (size_t i = 0; i < local_process_windows.size(); ++i) {
+ if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) {
+ found_local_process_window = true;
+ break;
+ }
+ }
+ if (!found_local_process_window)
+ return NULL;
+
+ ui::EnumerateTopLevelWindows(this);
+ return views::DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_);
+}
+
+XID X11TopmostWindowFinder::FindWindowAt(const gfx::Point& screen_loc) {
+ screen_loc_ = screen_loc;
+ ui::EnumerateTopLevelWindows(this);
+ return toplevel_;
+}
+
+bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) {
+ if (!ui::IsWindowVisible(xid))
+ return false;
+
+ aura::Window* window =
+ views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid);
+ if (window) {
+ if (ShouldStopIteratingAtLocalProcessWindow(window)) {
+ toplevel_ = xid;
+ return true;
+ }
+ return false;
+ }
+
+ if (ui::WindowContainsPoint(xid, screen_loc_)) {
+ toplevel_ = xid;
+ return true;
+ }
+ return false;
+}
+
+bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow(
+ aura::Window* window) {
+ if (ignore_.find(window) != ignore_.end())
+ return false;
+
+ // Currently |window|->IsVisible() always returns true.
+ // TODO(pkotwicz): Fix this. crbug.com/353038
+ return window->IsVisible() &&
+ window->GetBoundsInScreen().Contains(screen_loc_);
pkotwicz 2014/04/29 02:27:46 For an upcoming CL: Checking the bounds is wrong.
+}
+
+} // namespace views
« no previous file with comments | « ui/views/widget/desktop_aura/x11_topmost_window_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698