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

Side by Side Diff: chrome/browser/ui/views/tabs/window_finder_win.cc

Issue 256923002: Fixed tab dragging which was broken on high DPI windows for scales other than 100%. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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
« no previous file with comments | « no previous file | ui/app_list/views/apps_grid_view.cc » ('j') | 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 "chrome/browser/ui/views/tabs/window_finder.h" 5 #include "chrome/browser/ui/views/tabs/window_finder.h"
6 6
7 #include "base/win/scoped_gdi_object.h" 7 #include "base/win/scoped_gdi_object.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/gfx/screen.h" 10 #include "ui/gfx/screen.h"
11 #include "ui/gfx/win/dpi.h"
11 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" 12 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
12 #include "ui/views/win/hwnd_util.h" 13 #include "ui/views/win/hwnd_util.h"
13 14
14 #if defined(USE_ASH) 15 #if defined(USE_ASH)
15 aura::Window* GetLocalProcessWindowAtPointAsh( 16 aura::Window* GetLocalProcessWindowAtPointAsh(
16 const gfx::Point& screen_point, 17 const gfx::Point& screen_point,
17 const std::set<aura::Window*>& ignore); 18 const std::set<aura::Window*>& ignore);
18 #endif 19 #endif
19 20
20 namespace { 21 namespace {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Stop iterating if the region contains the point. 120 // Stop iterating if the region contains the point.
120 return !!is_point_in_region; 121 return !!is_point_in_region;
121 } 122 }
122 123
123 private: 124 private:
124 TopMostFinder(HWND window, 125 TopMostFinder(HWND window,
125 const gfx::Point& screen_loc, 126 const gfx::Point& screen_loc,
126 const std::set<HWND>& ignore) 127 const std::set<HWND>& ignore)
127 : BaseWindowFinder(ignore), 128 : BaseWindowFinder(ignore),
128 target_(window), 129 target_(window),
129 screen_loc_(screen_loc),
130 is_top_most_(false), 130 is_top_most_(false),
131 tmp_region_(CreateRectRgn(0, 0, 0, 0)) { 131 tmp_region_(CreateRectRgn(0, 0, 0, 0)) {
132 screen_loc_ = gfx::win::DIPToScreenPoint(screen_loc);
132 EnumWindows(WindowCallbackProc, as_lparam()); 133 EnumWindows(WindowCallbackProc, as_lparam());
133 } 134 }
134 135
135 // The window we're looking for. 136 // The window we're looking for.
136 HWND target_; 137 HWND target_;
137 138
138 // Location of window to find. 139 // Location of window to find in pixel coordinates.
139 gfx::Point screen_loc_; 140 gfx::Point screen_loc_;
140 141
141 // Is target_ the top most window? This is initially false but set to true 142 // Is target_ the top most window? This is initially false but set to true
142 // in ShouldStopIterating if target_ is passed in. 143 // in ShouldStopIterating if target_ is passed in.
143 bool is_top_most_; 144 bool is_top_most_;
144 145
145 base::win::ScopedRegion tmp_region_; 146 base::win::ScopedRegion tmp_region_;
146 147
147 DISALLOW_COPY_AND_ASSIGN(TopMostFinder); 148 DISALLOW_COPY_AND_ASSIGN(TopMostFinder);
148 }; 149 };
149 150
150 // WindowFinder --------------------------------------------------------------- 151 // WindowFinder ---------------------------------------------------------------
151 152
152 // Helper class to determine if a particular point contains a window from our 153 // Helper class to determine if a particular point contains a window from our
153 // process. 154 // process.
154 class LocalProcessWindowFinder : public BaseWindowFinder { 155 class LocalProcessWindowFinder : public BaseWindowFinder {
155 public: 156 public:
156 // Returns the hwnd from our process at screen_loc that is not obscured by 157 // Returns the hwnd from our process at screen_loc that is not obscured by
157 // another window. Returns NULL otherwise. 158 // another window. Returns NULL otherwise.
158 static gfx::NativeWindow GetProcessWindowAtPoint( 159 static gfx::NativeWindow GetProcessWindowAtPoint(
159 const gfx::Point& screen_loc, 160 const gfx::Point& screen_loc,
160 const std::set<HWND>& ignore) { 161 const std::set<HWND>& ignore) {
161 LocalProcessWindowFinder finder(screen_loc, ignore); 162 LocalProcessWindowFinder finder(screen_loc, ignore);
162 // Windows 8 has a window that appears first in the list of iterated 163 // Windows 8 has a window that appears first in the list of iterated
163 // windows, yet is not visually on top of everything. 164 // windows, yet is not visually on top of everything.
164 // TODO(sky): figure out a better way to ignore this window. 165 // TODO(sky): figure out a better way to ignore this window.
165 if (finder.result_ && 166 if (finder.result_ &&
166 ((base::win::OSInfo::GetInstance()->version() >= 167 ((base::win::OSInfo::GetInstance()->version() >=
167 base::win::VERSION_WIN8) || 168 base::win::VERSION_WIN8) ||
168 TopMostFinder::IsTopMostWindowAtPoint(finder.result_, screen_loc, 169 TopMostFinder::IsTopMostWindowAtPoint(finder.result_,
170 screen_loc,
169 ignore))) { 171 ignore))) {
170 return views::DesktopWindowTreeHostWin::GetContentWindowForHWND( 172 return views::DesktopWindowTreeHostWin::GetContentWindowForHWND(
171 finder.result_); 173 finder.result_);
172 } 174 }
173 return NULL; 175 return NULL;
174 } 176 }
175 177
176 protected: 178 protected:
177 virtual bool ShouldStopIterating(HWND hwnd) { 179 virtual bool ShouldStopIterating(HWND hwnd) {
178 RECT r; 180 RECT r;
179 if (IsWindowVisible(hwnd) && GetWindowRect(hwnd, &r) && 181 if (IsWindowVisible(hwnd) && GetWindowRect(hwnd, &r) &&
180 PtInRect(&r, screen_loc_.ToPOINT())) { 182 PtInRect(&r, screen_loc_.ToPOINT())) {
181 result_ = hwnd; 183 result_ = hwnd;
182 return true; 184 return true;
183 } 185 }
184 return false; 186 return false;
185 } 187 }
186 188
187 private: 189 private:
188 LocalProcessWindowFinder(const gfx::Point& screen_loc, 190 LocalProcessWindowFinder(const gfx::Point& screen_loc,
189 const std::set<HWND>& ignore) 191 const std::set<HWND>& ignore)
190 : BaseWindowFinder(ignore), 192 : BaseWindowFinder(ignore),
191 screen_loc_(screen_loc),
192 result_(NULL) { 193 result_(NULL) {
194 screen_loc_ = gfx::win::DIPToScreenPoint(screen_loc);
193 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, as_lparam()); 195 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, as_lparam());
194 } 196 }
195 197
196 // Position of the mouse. 198 // Position of the mouse in pixel coordinates.
197 gfx::Point screen_loc_; 199 gfx::Point screen_loc_;
198 200
199 // The resulting window. This is initially null but set to true in 201 // The resulting window. This is initially null but set to true in
200 // ShouldStopIterating if an appropriate window is found. 202 // ShouldStopIterating if an appropriate window is found.
201 HWND result_; 203 HWND result_;
202 204
203 DISALLOW_COPY_AND_ASSIGN(LocalProcessWindowFinder); 205 DISALLOW_COPY_AND_ASSIGN(LocalProcessWindowFinder);
204 }; 206 };
205 207
206 std::set<HWND> RemapIgnoreSet(const std::set<gfx::NativeView>& ignore) { 208 std::set<HWND> RemapIgnoreSet(const std::set<gfx::NativeView>& ignore) {
(...skipping 13 matching lines...) Expand all
220 chrome::HostDesktopType host_desktop_type, 222 chrome::HostDesktopType host_desktop_type,
221 const gfx::Point& screen_point, 223 const gfx::Point& screen_point,
222 const std::set<aura::Window*>& ignore) { 224 const std::set<aura::Window*>& ignore) {
223 #if defined(USE_ASH) 225 #if defined(USE_ASH)
224 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) 226 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH)
225 return GetLocalProcessWindowAtPointAsh(screen_point, ignore); 227 return GetLocalProcessWindowAtPointAsh(screen_point, ignore);
226 #endif 228 #endif
227 return LocalProcessWindowFinder::GetProcessWindowAtPoint( 229 return LocalProcessWindowFinder::GetProcessWindowAtPoint(
228 screen_point, RemapIgnoreSet(ignore)); 230 screen_point, RemapIgnoreSet(ignore));
229 } 231 }
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698