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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h"
6 6
7 #include <X11/extensions/Xrandr.h> 7 #include <X11/extensions/Xrandr.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // It clashes with out RootWindow. 10 // It clashes with out RootWindow.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (!gfx::Display::HasForceDeviceScaleFactor() && 56 if (!gfx::Display::HasForceDeviceScaleFactor() &&
57 !ui::IsXDisplaySizeBlackListed(mm_width, mm_height)) { 57 !ui::IsXDisplaySizeBlackListed(mm_width, mm_height)) {
58 float device_scale_factor = GetDeviceScaleFactor(width, mm_width); 58 float device_scale_factor = GetDeviceScaleFactor(width, mm_width);
59 DCHECK_LE(1.0f, device_scale_factor); 59 DCHECK_LE(1.0f, device_scale_factor);
60 gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels); 60 gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels);
61 } 61 }
62 62
63 return std::vector<gfx::Display>(1, gfx_display); 63 return std::vector<gfx::Display>(1, gfx_display);
64 } 64 }
65 65
66 // Helper class to GetWindowAtScreenPoint() which returns the topmost window at
67 // the location passed to FindAt(). NULL is returned if a window which does not
68 // belong to Chromium is topmost at the passed in location.
69 class ToplevelWindowFinder : public ui::EnumerateWindowsDelegate {
70 public:
71 ToplevelWindowFinder() : toplevel_(NULL) {
72 }
73
74 virtual ~ToplevelWindowFinder() {
75 }
76
77 aura::Window* FindAt(const gfx::Point& screen_loc) {
78 screen_loc_ = screen_loc;
79 ui::EnumerateTopLevelWindows(this);
80 return toplevel_;
81 }
82
83 protected:
84 virtual bool ShouldStopIterating(XID xid) OVERRIDE {
85 aura::Window* window =
86 views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid);
87 if (window &&
88 window->IsVisible() &&
89 window->GetBoundsInScreen().Contains(screen_loc_)) {
90 toplevel_ = window;
91 return true;
92 }
93
94 if (ui::IsWindowVisible(xid) &&
95 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
96 toplevel_ = window;
97 return true;
98 }
99 return false;
100 }
101
102 gfx::Point screen_loc_;
103 aura::Window* toplevel_;
104
105 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowFinder);
106 };
107
66 } // namespace 108 } // namespace
67 109
68 namespace views { 110 namespace views {
69 111
70 //////////////////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////////////////
71 // DesktopScreenX11, public: 113 // DesktopScreenX11, public:
72 114
73 DesktopScreenX11::DesktopScreenX11() 115 DesktopScreenX11::DesktopScreenX11()
74 : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()), 116 : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
75 x_root_window_(DefaultRootWindow(xdisplay_)), 117 x_root_window_(DefaultRootWindow(xdisplay_)),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 217
176 return gfx::Point(root_x, root_y); 218 return gfx::Point(root_x, root_y);
177 } 219 }
178 220
179 gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() { 221 gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() {
180 return GetWindowAtScreenPoint(GetCursorScreenPoint()); 222 return GetWindowAtScreenPoint(GetCursorScreenPoint());
181 } 223 }
182 224
183 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( 225 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint(
184 const gfx::Point& point) { 226 const gfx::Point& point) {
185 std::vector<aura::Window*> windows = 227 ToplevelWindowFinder finder;
186 DesktopWindowTreeHostX11::GetAllOpenWindows(); 228 return finder.FindAt(point);
187
188 for (std::vector<aura::Window*>::const_iterator it = windows.begin();
189 it != windows.end(); ++it) {
190 if ((*it)->GetBoundsInScreen().Contains(point))
191 return *it;
192 }
193
194 return NULL;
195 } 229 }
196 230
197 int DesktopScreenX11::GetNumDisplays() const { 231 int DesktopScreenX11::GetNumDisplays() const {
198 return displays_.size(); 232 return displays_.size();
199 } 233 }
200 234
201 std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const { 235 std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const {
202 return displays_; 236 return displays_;
203 } 237 }
204 238
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 ProcessDisplayChange(new_displays); 416 ProcessDisplayChange(new_displays);
383 } 417 }
384 418
385 //////////////////////////////////////////////////////////////////////////////// 419 ////////////////////////////////////////////////////////////////////////////////
386 420
387 gfx::Screen* CreateDesktopScreen() { 421 gfx::Screen* CreateDesktopScreen() {
388 return new DesktopScreenX11; 422 return new DesktopScreenX11;
389 } 423 }
390 424
391 } // namespace views 425 } // namespace views
OLDNEW
« 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