Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_views_delegate.h" | 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 PrefService* GetPrefsForWindow(const views::Widget* window) { | 92 PrefService* GetPrefsForWindow(const views::Widget* window) { |
| 93 Profile* profile = GetProfileForWindow(window); | 93 Profile* profile = GetProfileForWindow(window); |
| 94 if (!profile) { | 94 if (!profile) { |
| 95 // Use local state for windows that have no explicit profile. | 95 // Use local state for windows that have no explicit profile. |
| 96 return g_browser_process->local_state(); | 96 return g_browser_process->local_state(); |
| 97 } | 97 } |
| 98 return profile->GetPrefs(); | 98 return profile->GetPrefs(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 #if defined(OS_WIN) | 101 #if defined(OS_WIN) |
| 102 bool MonitorHasTopmostAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) { | 102 bool MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) { |
| 103 APPBARDATA taskbar_data = { sizeof(APPBARDATA), NULL, 0, edge }; | 103 APPBARDATA taskbar_data = { sizeof(APPBARDATA), NULL, 0, edge }; |
| 104 taskbar_data.hWnd = ::GetForegroundWindow(); | 104 taskbar_data.hWnd = ::GetForegroundWindow(); |
| 105 | 105 |
| 106 // TODO(robliao): Remove ScopedTracker below once crbug.com/462368 is fixed. | 106 // TODO(robliao): Remove ScopedTracker below once crbug.com/462368 is fixed. |
| 107 tracked_objects::ScopedTracker tracking_profile( | 107 tracked_objects::ScopedTracker tracking_profile( |
| 108 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 108 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 109 "462368 MonitorHasTopmostAutohideTaskbarForEdge")); | 109 "462368 MonitorHasAutohideTaskbarForEdge")); |
| 110 | 110 |
| 111 // MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor | 111 // MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor |
| 112 // rect and returns autohide bars on that monitor. This sounds like a good | 112 // rect and returns autohide bars on that monitor. This sounds like a good |
| 113 // idea for multi-monitor systems. Unfortunately, it appears to not work at | 113 // idea for multi-monitor systems. Unfortunately, it appears to not work at |
| 114 // least some of the time (erroneously returning NULL) and there's almost no | 114 // least some of the time (erroneously returning NULL) and there's almost no |
| 115 // online documentation or other sample code using it that suggests ways to | 115 // online documentation or other sample code using it that suggests ways to |
| 116 // address this problem. We do the following:- | 116 // address this problem. We do the following:- |
| 117 // 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid | 117 // 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid |
| 118 // window we are done. | 118 // window we are done. |
| 119 // 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide | 119 // 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 132 | 132 |
| 133 taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", NULL); | 133 taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", NULL); |
| 134 if (!::IsWindow(taskbar_data.hWnd)) | 134 if (!::IsWindow(taskbar_data.hWnd)) |
| 135 return false; | 135 return false; |
| 136 | 136 |
| 137 SHAppBarMessage(ABM_GETTASKBARPOS, &taskbar_data); | 137 SHAppBarMessage(ABM_GETTASKBARPOS, &taskbar_data); |
| 138 if (taskbar_data.uEdge == edge) | 138 if (taskbar_data.uEdge == edge) |
| 139 taskbar = taskbar_data.hWnd; | 139 taskbar = taskbar_data.hWnd; |
| 140 } | 140 } |
| 141 | 141 |
| 142 if (::IsWindow(taskbar) && | 142 if (::IsWindow(taskbar)) { |
| 143 (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST)) { | |
|
ananta
2016/11/30 02:16:18
Found this patch from 2+ years ago which had this
Peter Kasting
2016/11/30 07:30:30
You didn't link to the patch, but I tracked this d
ananta
2016/11/30 20:37:47
I found this link on msdn https://msdn.microsoft.c
| |
| 144 if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor) | 143 if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor) |
| 145 return true; | 144 return true; |
| 146 // In some cases like when the autohide taskbar is on the left of the | 145 // In some cases like when the autohide taskbar is on the left of the |
| 147 // secondary monitor, the MonitorFromWindow call above fails to return the | 146 // secondary monitor, the MonitorFromWindow call above fails to return the |
| 148 // correct monitor the taskbar is on. We fallback to MonitorFromPoint for | 147 // correct monitor the taskbar is on. We fallback to MonitorFromPoint for |
| 149 // the cursor position in that case, which seems to work well. | 148 // the cursor position in that case, which seems to work well. |
| 150 POINT cursor_pos = {0}; | 149 POINT cursor_pos = {0}; |
| 151 GetCursorPos(&cursor_pos); | 150 GetCursorPos(&cursor_pos); |
| 152 if (MonitorFromPoint(cursor_pos, MONITOR_DEFAULTTONEAREST) == monitor) | 151 if (MonitorFromPoint(cursor_pos, MONITOR_DEFAULTTONEAREST) == monitor) |
| 153 return true; | 152 return true; |
| 154 } | 153 } |
| 155 return false; | 154 return false; |
| 156 } | 155 } |
| 157 | 156 |
| 158 int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) { | 157 int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) { |
| 159 DCHECK(monitor); | 158 DCHECK(monitor); |
| 160 | 159 |
| 161 int edges = 0; | 160 int edges = 0; |
| 162 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_LEFT, monitor)) | 161 if (MonitorHasAutohideTaskbarForEdge(ABE_LEFT, monitor)) |
| 163 edges |= views::ViewsDelegate::EDGE_LEFT; | 162 edges |= views::ViewsDelegate::EDGE_LEFT; |
| 164 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_TOP, monitor)) | 163 if (MonitorHasAutohideTaskbarForEdge(ABE_TOP, monitor)) |
| 165 edges |= views::ViewsDelegate::EDGE_TOP; | 164 edges |= views::ViewsDelegate::EDGE_TOP; |
| 166 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_RIGHT, monitor)) | 165 if (MonitorHasAutohideTaskbarForEdge(ABE_RIGHT, monitor)) |
| 167 edges |= views::ViewsDelegate::EDGE_RIGHT; | 166 edges |= views::ViewsDelegate::EDGE_RIGHT; |
| 168 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) | 167 if (MonitorHasAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) |
| 169 edges |= views::ViewsDelegate::EDGE_BOTTOM; | 168 edges |= views::ViewsDelegate::EDGE_BOTTOM; |
| 170 return edges; | 169 return edges; |
| 171 } | 170 } |
| 172 #endif | 171 #endif |
| 173 | 172 |
| 174 #if defined(USE_ASH) | 173 #if defined(USE_ASH) |
| 175 void ProcessAcceleratorNow(const ui::Accelerator& accelerator) { | 174 void ProcessAcceleratorNow(const ui::Accelerator& accelerator) { |
| 176 // TODO(afakhry): See if we need here to send the accelerator to the | 175 // TODO(afakhry): See if we need here to send the accelerator to the |
| 177 // FocusManager of the active window in a follow-up CL. | 176 // FocusManager of the active window in a follow-up CL. |
| 178 ash::WmShell::Get()->accelerator_controller()->Process(accelerator); | 177 ash::WmShell::Get()->accelerator_controller()->Process(accelerator); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 return ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing(); | 522 return ViewsDelegate::GetDialogRelatedButtonHorizontalSpacing(); |
| 524 } | 523 } |
| 525 | 524 |
| 526 #if !defined(USE_ASH) | 525 #if !defined(USE_ASH) |
| 527 views::Widget::InitParams::WindowOpacity | 526 views::Widget::InitParams::WindowOpacity |
| 528 ChromeViewsDelegate::GetOpacityForInitParams( | 527 ChromeViewsDelegate::GetOpacityForInitParams( |
| 529 const views::Widget::InitParams& params) { | 528 const views::Widget::InitParams& params) { |
| 530 return views::Widget::InitParams::OPAQUE_WINDOW; | 529 return views::Widget::InitParams::OPAQUE_WINDOW; |
| 531 } | 530 } |
| 532 #endif | 531 #endif |
| OLD | NEW |