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

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

Issue 1003863005: Fix tab drag and drop with hi-dpi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tab drag and drop with hi-dpi. Created 5 years, 9 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
« no previous file with comments | « ui/views/widget/desktop_aura/x11_topmost_window_finder.h ('k') | 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 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> 7 #include <X11/Xutil.h>
8 8
9 #include "ui/aura/client/screen_position_client.h" 9 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #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"
12 12
13 namespace views { 13 namespace views {
14 14
15 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) { 15 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) {
16 } 16 }
17 17
18 X11TopmostWindowFinder::~X11TopmostWindowFinder() { 18 X11TopmostWindowFinder::~X11TopmostWindowFinder() {
19 } 19 }
20 20
21 aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt( 21 aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt(
22 const gfx::Point& screen_loc, 22 const gfx::Point& screen_loc_in_pixels,
23 const std::set<aura::Window*>& ignore) { 23 const std::set<aura::Window*>& ignore) {
24 screen_loc_ = screen_loc; 24 screen_loc_in_pixels_ = screen_loc_in_pixels;
25 ignore_ = ignore; 25 ignore_ = ignore;
26 26
27 std::vector<aura::Window*> local_process_windows = 27 std::vector<aura::Window*> local_process_windows =
28 DesktopWindowTreeHostX11::GetAllOpenWindows(); 28 DesktopWindowTreeHostX11::GetAllOpenWindows();
29 bool found_local_process_window = false; 29 bool found_local_process_window = false;
30 for (size_t i = 0; i < local_process_windows.size(); ++i) { 30 for (size_t i = 0; i < local_process_windows.size(); ++i) {
31 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) { 31 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) {
32 found_local_process_window = true; 32 found_local_process_window = true;
33 break; 33 break;
34 } 34 }
35 } 35 }
36 if (!found_local_process_window) 36 if (!found_local_process_window)
37 return NULL; 37 return NULL;
38 38
39 ui::EnumerateTopLevelWindows(this); 39 ui::EnumerateTopLevelWindows(this);
40 return DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_); 40 return DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_);
41 } 41 }
42 42
43 XID X11TopmostWindowFinder::FindWindowAt(const gfx::Point& screen_loc) { 43 XID X11TopmostWindowFinder::FindWindowAt(
44 screen_loc_ = screen_loc; 44 const gfx::Point& screen_loc_in_pixels) {
45 screen_loc_in_pixels_ = screen_loc_in_pixels;
45 ui::EnumerateTopLevelWindows(this); 46 ui::EnumerateTopLevelWindows(this);
46 return toplevel_; 47 return toplevel_;
47 } 48 }
48 49
49 bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) { 50 bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) {
50 if (!ui::IsWindowVisible(xid)) 51 if (!ui::IsWindowVisible(xid))
51 return false; 52 return false;
52 53
53 aura::Window* window = 54 aura::Window* window =
54 views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid); 55 views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid);
55 if (window) { 56 if (window) {
56 if (ShouldStopIteratingAtLocalProcessWindow(window)) { 57 if (ShouldStopIteratingAtLocalProcessWindow(window)) {
57 toplevel_ = xid; 58 toplevel_ = xid;
58 return true; 59 return true;
59 } 60 }
60 return false; 61 return false;
61 } 62 }
62 63
63 if (ui::WindowContainsPoint(xid, screen_loc_)) { 64 if (ui::WindowContainsPoint(xid, screen_loc_in_pixels_)) {
64 toplevel_ = xid; 65 toplevel_ = xid;
65 return true; 66 return true;
66 } 67 }
67 return false; 68 return false;
68 } 69 }
69 70
70 bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow( 71 bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow(
71 aura::Window* window) { 72 aura::Window* window) {
72 if (ignore_.find(window) != ignore_.end()) 73 if (ignore_.find(window) != ignore_.end())
73 return false; 74 return false;
74 75
75 // Currently |window|->IsVisible() always returns true. 76 // Currently |window|->IsVisible() always returns true.
76 // TODO(pkotwicz): Fix this. crbug.com/353038 77 // TODO(pkotwicz): Fix this. crbug.com/353038
77 if (!window->IsVisible()) 78 if (!window->IsVisible())
78 return false; 79 return false;
79 80
80 DesktopWindowTreeHostX11* host = 81 DesktopWindowTreeHostX11* host =
81 DesktopWindowTreeHostX11::GetHostForXID( 82 DesktopWindowTreeHostX11::GetHostForXID(
82 window->GetHost()->GetAcceleratedWidget()); 83 window->GetHost()->GetAcceleratedWidget());
83 if (!host->GetX11RootWindowOuterBounds().Contains(screen_loc_)) 84 if (!host->GetX11RootWindowOuterBounds().Contains(screen_loc_in_pixels_))
84 return false; 85 return false;
85 86
86 ::Region shape = host->GetWindowShape(); 87 ::Region shape = host->GetWindowShape();
87 if (!shape) 88 if (!shape)
88 return true; 89 return true;
89 90
90 aura::client::ScreenPositionClient* screen_position_client = 91 aura::client::ScreenPositionClient* screen_position_client =
91 aura::client::GetScreenPositionClient(window->GetRootWindow()); 92 aura::client::GetScreenPositionClient(window->GetRootWindow());
92 gfx::Point window_loc(screen_loc_); 93 gfx::Point window_loc(screen_loc_in_pixels_);
93 screen_position_client->ConvertPointFromScreen(window, &window_loc); 94 screen_position_client->ConvertPointFromScreen(window, &window_loc);
94 return XPointInRegion(shape, window_loc.x(), window_loc.y()) == True; 95 return XPointInRegion(shape, window_loc.x(), window_loc.y()) == True;
95 } 96 }
96 97
97 } // namespace views 98 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/x11_topmost_window_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698