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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 if (!profile) { | 83 if (!profile) { |
| 84 // Use local state for windows that have no explicit profile. | 84 // Use local state for windows that have no explicit profile. |
| 85 return g_browser_process->local_state(); | 85 return g_browser_process->local_state(); |
| 86 } | 86 } |
| 87 return profile->GetPrefs(); | 87 return profile->GetPrefs(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
| 91 bool MonitorHasTopmostAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) { | 91 bool MonitorHasTopmostAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) { |
| 92 APPBARDATA taskbar_data = { sizeof(APPBARDATA), NULL, 0, edge }; | 92 APPBARDATA taskbar_data = { sizeof(APPBARDATA), NULL, 0, edge }; |
| 93 taskbar_data.hWnd = ::GetForegroundWindow(); | |
| 93 | 94 |
| 94 // TODO(robliao): Remove ScopedTracker below once crbug.com/462368 is fixed. | 95 // TODO(robliao): Remove ScopedTracker below once crbug.com/462368 is fixed. |
| 95 tracked_objects::ScopedTracker tracking_profile( | 96 tracked_objects::ScopedTracker tracking_profile( |
| 96 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 97 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 97 "462368 MonitorHasTopmostAutohideTaskbarForEdge")); | 98 "462368 MonitorHasTopmostAutohideTaskbarForEdge")); |
| 98 | 99 |
| 99 // MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor | 100 // MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor |
| 100 // rect and returns autohide bars on that monitor. This sounds like a good | 101 // rect and returns autohide bars on that monitor. This sounds like a good |
| 101 // idea for multi-monitor systems. Unfortunately, it appears to not work at | 102 // idea for multi-monitor systems. Unfortunately, it appears to not work at |
| 102 // least some of the time (erroneously returning NULL) and there's almost no | 103 // least some of the time (erroneously returning NULL) and there's almost no |
| 103 // online documentation or other sample code using it that suggests ways to | 104 // online documentation or other sample code using it that suggests ways to |
| 104 // address this problem. So we just use ABM_GETAUTOHIDEBAR and hope the user | 105 // address this problem. We do the following:- |
| 105 // only cares about autohide bars on the monitor with the primary taskbar. | 106 // 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid |
| 106 // | 107 // window we are done. |
| 108 // 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide | |
| 109 // state of the taskbar and then retrieve its position. That call returns | |
| 110 // the edge on which the taskbar is present. If it matches the edge we | |
| 111 // are looking for, we are done. | |
| 107 // NOTE: This call spins a nested message loop. | 112 // NOTE: This call spins a nested message loop. |
| 108 HWND taskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAR, | 113 HWND taskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAR, |
| 109 &taskbar_data)); | 114 &taskbar_data)); |
| 115 if (!::IsWindow(taskbar)) { | |
| 116 APPBARDATA taskbar_data = { sizeof(APPBARDATA), 0, 0, 0}; | |
| 117 unsigned int taskbar_state = SHAppBarMessage(ABM_GETSTATE, | |
|
sky
2015/11/22 15:57:19
All these ole function calls make me nervous that
ananta
2015/11/23 19:10:44
Please see below. The function GetAppbarAutohideEd
| |
| 118 &taskbar_data); | |
| 119 if (!(taskbar_state & ABS_AUTOHIDE)) | |
| 120 return false; | |
| 121 | |
| 122 taskbar_data.hWnd = ::FindWindow(L"Shell_TrayWnd", NULL); | |
| 123 if (!::IsWindow(taskbar_data.hWnd)) | |
| 124 return false; | |
| 125 | |
| 126 SHAppBarMessage(ABM_GETTASKBARPOS, &taskbar_data); | |
| 127 if (taskbar_data.uEdge == edge) | |
| 128 taskbar = taskbar_data.hWnd; | |
| 129 } | |
| 110 return ::IsWindow(taskbar) && | 130 return ::IsWindow(taskbar) && |
| 111 (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONULL) == monitor) && | 131 (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONULL) == monitor) && |
| 112 (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST); | 132 (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST); |
| 113 } | 133 } |
| 114 | 134 |
| 115 int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) { | 135 int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) { |
| 116 DCHECK(monitor); | 136 DCHECK(monitor); |
| 117 | 137 |
| 118 int edges = 0; | 138 int edges = 0; |
| 119 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_LEFT, monitor)) | 139 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_LEFT, monitor)) |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 return content::BrowserThread::GetBlockingPool(); | 492 return content::BrowserThread::GetBlockingPool(); |
| 473 } | 493 } |
| 474 | 494 |
| 475 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) | 495 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) |
| 476 views::Widget::InitParams::WindowOpacity | 496 views::Widget::InitParams::WindowOpacity |
| 477 ChromeViewsDelegate::GetOpacityForInitParams( | 497 ChromeViewsDelegate::GetOpacityForInitParams( |
| 478 const views::Widget::InitParams& params) { | 498 const views::Widget::InitParams& params) { |
| 479 return views::Widget::InitParams::OPAQUE_WINDOW; | 499 return views::Widget::InitParams::OPAQUE_WINDOW; |
| 480 } | 500 } |
| 481 #endif | 501 #endif |
| OLD | NEW |