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) { |