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

Side by Side Diff: trunk/src/ui/views/widget/desktop_aura/desktop_screen_x11.cc

Issue 174943003: Revert 252502 "Fixes DesktopScreenX11::GetWindowAtScreenPoint() ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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 if (window->IsVisible() &&
89 window->GetBoundsInScreen().Contains(screen_loc_)) {
90 toplevel_ = window;
91 return true;
92 }
93 return false;
94 }
95
96 if (ui::IsWindowVisible(xid) &&
97 ui::WindowContainsPoint(xid, screen_loc_)) {
98 // toplevel_ = NULL
99 return true;
100 }
101 return false;
102 }
103
104 gfx::Point screen_loc_;
105 aura::Window* toplevel_;
106
107 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowFinder);
108 };
109
110 } // namespace 66 } // namespace
111 67
112 namespace views { 68 namespace views {
113 69
114 //////////////////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////////////////
115 // DesktopScreenX11, public: 71 // DesktopScreenX11, public:
116 72
117 DesktopScreenX11::DesktopScreenX11() 73 DesktopScreenX11::DesktopScreenX11()
118 : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()), 74 : xdisplay_(base::MessagePumpX11::GetDefaultXDisplay()),
119 x_root_window_(DefaultRootWindow(xdisplay_)), 75 x_root_window_(DefaultRootWindow(xdisplay_)),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 175
220 return gfx::Point(root_x, root_y); 176 return gfx::Point(root_x, root_y);
221 } 177 }
222 178
223 gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() { 179 gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() {
224 return GetWindowAtScreenPoint(GetCursorScreenPoint()); 180 return GetWindowAtScreenPoint(GetCursorScreenPoint());
225 } 181 }
226 182
227 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( 183 gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint(
228 const gfx::Point& point) { 184 const gfx::Point& point) {
229 ToplevelWindowFinder finder; 185 std::vector<aura::Window*> windows =
230 return finder.FindAt(point); 186 DesktopWindowTreeHostX11::GetAllOpenWindows();
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;
231 } 195 }
232 196
233 int DesktopScreenX11::GetNumDisplays() const { 197 int DesktopScreenX11::GetNumDisplays() const {
234 return displays_.size(); 198 return displays_.size();
235 } 199 }
236 200
237 std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const { 201 std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const {
238 return displays_; 202 return displays_;
239 } 203 }
240 204
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 ProcessDisplayChange(new_displays); 382 ProcessDisplayChange(new_displays);
419 } 383 }
420 384
421 //////////////////////////////////////////////////////////////////////////////// 385 ////////////////////////////////////////////////////////////////////////////////
422 386
423 gfx::Screen* CreateDesktopScreen() { 387 gfx::Screen* CreateDesktopScreen() {
424 return new DesktopScreenX11; 388 return new DesktopScreenX11;
425 } 389 }
426 390
427 } // namespace views 391 } // 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