OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/panels/bottom_bar.h" |
| 6 |
| 7 #include <windows.h> |
| 8 #include <shellapi.h> |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/ui/window_sizer.h" |
| 13 #include "views/widget/monitor_win.h" |
| 14 |
| 15 namespace { |
| 16 |
| 17 // The thickness of an auto-hide taskbar in pixels. |
| 18 const int kAutoHideTaskbarThicknessPx = 2; |
| 19 |
| 20 gfx::Rect GetBottomBarBounds() { |
| 21 HWND taskbar = ::FindWindow(L"Shell_TrayWnd", NULL); |
| 22 if (!taskbar) |
| 23 return gfx::Rect(); |
| 24 RECT rect; |
| 25 if (!::GetWindowRect(taskbar, &rect)) |
| 26 return gfx::Rect(); |
| 27 return gfx::Rect(rect); |
| 28 } |
| 29 |
| 30 } |
| 31 |
| 32 bool IsBottomBarInAutoHideMode() { |
| 33 RECT rect; |
| 34 HMONITOR monitor = ::MonitorFromRect(&rect, MONITOR_DEFAULTTOPRIMARY); |
| 35 DCHECK(monitor); |
| 36 return views::EdgeHasTopmostAutoHideTaskbar(ABE_BOTTOM, monitor); |
| 37 } |
| 38 |
| 39 int GetBottomBarHeight() { |
| 40 gfx::Rect bounds = GetBottomBarBounds(); |
| 41 return bounds.height(); |
| 42 } |
| 43 |
| 44 bool IsBottomBarFullyVisible() { |
| 45 scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( |
| 46 WindowSizer::CreateDefaultMonitorInfoProvider()); |
| 47 gfx::Rect screen_bounds = info_provider->GetPrimaryMonitorBounds(); |
| 48 |
| 49 gfx::Rect bottom_bar_bounds = GetBottomBarBounds(); |
| 50 return bottom_bar_bounds.bottom() <= screen_bounds.bottom(); |
| 51 } |
| 52 |
| 53 bool IsBottomBarHidden() { |
| 54 scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( |
| 55 WindowSizer::CreateDefaultMonitorInfoProvider()); |
| 56 gfx::Rect screen_bounds = info_provider->GetPrimaryMonitorBounds(); |
| 57 |
| 58 gfx::Rect bottom_bar_bounds = GetBottomBarBounds(); |
| 59 return bottom_bar_bounds.y() >= |
| 60 screen_bounds.bottom() - kAutoHideTaskbarThicknessPx; |
| 61 } |
OLD | NEW |