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

Unified Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 1735743002: Use the MonitorFromPoint API for the cursor position to cover cases where the MonitorFromWindow API… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/chrome_views_delegate.cc
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 35b2fae5ef6e622e5ee72c9bf51a0daae2f77226..4a5c719d9724ad6f629cc86652155422e004831e 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -126,9 +126,21 @@ bool MonitorHasTopmostAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) {
if (taskbar_data.uEdge == edge)
taskbar = taskbar_data.hWnd;
}
- return ::IsWindow(taskbar) &&
- (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONULL) == monitor) &&
- (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST);
+
+ if (::IsWindow(taskbar) &&
+ (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST)) {
+ if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor)
+ return true;
+ // In some cases like when the autohide taskbar is on the left of the
+ // secondary monitor, the MonitorFromWindow call above fails to return the
+ // correct monitor the taskbar is on. We fallback to MonitorFromPoint for
+ // the cursor position in that case, which seems to work well.
+ POINT cursor_pos = {0};
+ GetCursorPos(&cursor_pos);
+ if (MonitorFromPoint(cursor_pos, MONITOR_DEFAULTTONEAREST) == monitor)
+ return true;
+ }
+ return false;
}
int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) {
« 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