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

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

Issue 173193006: Make DesktopScreenX11::GetWindowAtScreenPoint() take non-Chrome windows into account (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « no previous file | 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/desktop_screen_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index 271e4ec558a10b10a81d0ad439906dfc37254100..f82f24e5a8f05f96b24d940f723d9d4010bbf5d1 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -63,6 +63,48 @@ std::vector<gfx::Display> GetFallbackDisplayList() {
return std::vector<gfx::Display>(1, gfx_display);
}
+// Helper class to GetWindowAtScreenPoint() which returns the topmost window at
+// the location passed to FindAt(). NULL is returned if a window which does not
+// belong to Chromium is topmost at the passed in location.
+class ToplevelWindowFinder : public ui::EnumerateWindowsDelegate {
+ public:
+ ToplevelWindowFinder() : toplevel_(NULL) {
+ }
+
+ virtual ~ToplevelWindowFinder() {
+ }
+
+ aura::Window* FindAt(const gfx::Point& screen_loc) {
+ screen_loc_ = screen_loc;
+ ui::EnumerateTopLevelWindows(this);
+ return toplevel_;
+ }
+
+ protected:
+ virtual bool ShouldStopIterating(XID xid) OVERRIDE {
+ aura::Window* window =
+ views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid);
+ if (window &&
+ window->IsVisible() &&
+ window->GetBoundsInScreen().Contains(screen_loc_)) {
+ toplevel_ = window;
+ return true;
+ }
+
+ if (ui::IsWindowVisible(xid) &&
+ ui::WindowContainsPoint(xid, screen_loc_)) {
pkotwicz 2014/02/20 03:01:55 Should I be checking for the WM_STATE property her
Elliot Glaysher 2014/02/20 18:30:09 I don't think so. You're already checking for visi
+ toplevel_ = window;
+ return true;
+ }
+ return false;
+ }
+
+ gfx::Point screen_loc_;
+ aura::Window* toplevel_;
+
+ DISALLOW_COPY_AND_ASSIGN(ToplevelWindowFinder);
+};
+
} // namespace
namespace views {
@@ -182,16 +224,8 @@ gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() {
gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint(
const gfx::Point& point) {
- std::vector<aura::Window*> windows =
- DesktopWindowTreeHostX11::GetAllOpenWindows();
-
- for (std::vector<aura::Window*>::const_iterator it = windows.begin();
- it != windows.end(); ++it) {
- if ((*it)->GetBoundsInScreen().Contains(point))
- return *it;
- }
-
- return NULL;
+ ToplevelWindowFinder finder;
+ return finder.FindAt(point);
}
int DesktopScreenX11::GetNumDisplays() const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698