diff options
author | ananta <ananta@chromium.org> | 2016-02-25 12:38:13 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-25 20:39:47 +0000 |
commit | a25bf4f5f135fa548f7a2de0580059313c6730b9 (patch) | |
tree | 4de16e0ca6cb5c9b6b46df62e67544ec9771fe62 | |
parent | 22f66bb532f69f24d33e1800ba4b5be1b2ad45e4 (diff) | |
download | chromium_src-a25bf4f5f135fa548f7a2de0580059313c6730b9.zip chromium_src-a25bf4f5f135fa548f7a2de0580059313c6730b9.tar.gz chromium_src-a25bf4f5f135fa548f7a2de0580059313c6730b9.tar.bz2 |
Use the MonitorFromPoint API for the cursor position to cover cases where the MonitorFromWindow API fails.
In some cases the MonitorFromWindow API for the taskbar fails to return the correct monitor. Examples include the autohide
taskbar on the left of the secondary monitor or the right of the primary monitor. This causes maximized Chrome windows to
draw over these taskbars.
Fix is to use the MonitorFromPoint API for the cursor position which seems to work for these cases.
BUG=472139
Review URL: https://codereview.chromium.org/1735743002
Cr-Commit-Position: refs/heads/master@{#377661}
-rw-r--r-- | chrome/browser/ui/views/chrome_views_delegate.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index 35b2fae..4a5c719 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) { |