Skip to content

Commit

Permalink
Fixes DesktopScreenX11::GetWindowAtScreenPoint() so that NULL is retu…
Browse files Browse the repository at this point in the history
…rned if a chrome browser window is occluded by a non Chrome app at the passed in point

BUG=339587
TEST=Manual, see bug

Review URL: https://codereview.chromium.org/173193006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252502 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
pkotwicz@chromium.org committed Feb 21, 2014
1 parent 056ce05 commit 183de20
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions ui/views/widget/desktop_aura/desktop_screen_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,50 @@ 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) {
if (window->IsVisible() &&
window->GetBoundsInScreen().Contains(screen_loc_)) {
toplevel_ = window;
return true;
}
return false;
}

if (ui::IsWindowVisible(xid) &&
ui::WindowContainsPoint(xid, screen_loc_)) {
// toplevel_ = NULL
return true;
}
return false;
}

gfx::Point screen_loc_;
aura::Window* toplevel_;

DISALLOW_COPY_AND_ASSIGN(ToplevelWindowFinder);
};

} // namespace

namespace views {
Expand Down Expand Up @@ -182,16 +226,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 {
Expand Down

0 comments on commit 183de20

Please sign in to comment.