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

Side by Side Diff: ui/views/widget/desktop_aura/x11_topmost_window_finder.cc

Issue 268673017: Fix X11TopmostWindowFinder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/x11_topmost_window_finder.h" 5 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
6 6
7 #include <X11/Xutil.h>
8
9 #include "ui/aura/client/screen_position_client.h"
7 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
8 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 11 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
9 12
10 namespace views { 13 namespace views {
11 14
12 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) { 15 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) {
13 } 16 }
14 17
15 X11TopmostWindowFinder::~X11TopmostWindowFinder() { 18 X11TopmostWindowFinder::~X11TopmostWindowFinder() {
16 } 19 }
(...skipping 10 matching lines...) Expand all
27 for (size_t i = 0; i < local_process_windows.size(); ++i) { 30 for (size_t i = 0; i < local_process_windows.size(); ++i) {
28 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) { 31 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) {
29 found_local_process_window = true; 32 found_local_process_window = true;
30 break; 33 break;
31 } 34 }
32 } 35 }
33 if (!found_local_process_window) 36 if (!found_local_process_window)
34 return NULL; 37 return NULL;
35 38
36 ui::EnumerateTopLevelWindows(this); 39 ui::EnumerateTopLevelWindows(this);
37 return views::DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_); 40 return DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_);
38 } 41 }
39 42
40 XID X11TopmostWindowFinder::FindWindowAt(const gfx::Point& screen_loc) { 43 XID X11TopmostWindowFinder::FindWindowAt(const gfx::Point& screen_loc) {
41 screen_loc_ = screen_loc; 44 screen_loc_ = screen_loc;
42 ui::EnumerateTopLevelWindows(this); 45 ui::EnumerateTopLevelWindows(this);
43 return toplevel_; 46 return toplevel_;
44 } 47 }
45 48
46 bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) { 49 bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) {
47 if (!ui::IsWindowVisible(xid)) 50 if (!ui::IsWindowVisible(xid))
(...skipping 16 matching lines...) Expand all
64 return false; 67 return false;
65 } 68 }
66 69
67 bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow( 70 bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow(
68 aura::Window* window) { 71 aura::Window* window) {
69 if (ignore_.find(window) != ignore_.end()) 72 if (ignore_.find(window) != ignore_.end())
70 return false; 73 return false;
71 74
72 // Currently |window|->IsVisible() always returns true. 75 // Currently |window|->IsVisible() always returns true.
73 // TODO(pkotwicz): Fix this. crbug.com/353038 76 // TODO(pkotwicz): Fix this. crbug.com/353038
74 return window->IsVisible() && 77 if (!window->IsVisible())
75 window->GetBoundsInScreen().Contains(screen_loc_); 78 return false;
79
80 DesktopWindowTreeHostX11* host =
81 DesktopWindowTreeHostX11::GetHostForXID(
82 window->GetHost()->GetAcceleratedWidget());
83 if (!host->GetX11RootWindowOuterBounds().Contains(screen_loc_))
84 return false;
85
86 ::Region shape = host->GetWindowShape();
87 if (!shape)
88 return true;
89
90 aura::client::ScreenPositionClient* screen_position_client =
91 aura::client::GetScreenPositionClient(window->GetRootWindow());
92 gfx::Point window_loc(screen_loc_);
93 screen_position_client->ConvertPointFromScreen(window, &window_loc);
94 return XPointInRegion(shape, window_loc.x(), window_loc.y()) == True;
76 } 95 }
77 96
78 } // namespace views 97 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698