| 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/panels/display_settings_provider.h" | 5 #include "chrome/browser/ui/panels/display_settings_provider.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/fullscreen.h" | 8 #include "chrome/browser/fullscreen.h" |
| 9 #include "ui/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 gfx::Rect DisplaySettingsProvider::GetDisplayArea() { | 63 gfx::Rect DisplaySettingsProvider::GetDisplayArea() { |
| 64 // Do the first-time initialization if not yet. | 64 // Do the first-time initialization if not yet. |
| 65 if (adjusted_work_area_.IsEmpty()) | 65 if (adjusted_work_area_.IsEmpty()) |
| 66 OnDisplaySettingsChanged(); | 66 OnDisplaySettingsChanged(); |
| 67 | 67 |
| 68 return adjusted_work_area_; | 68 return adjusted_work_area_; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // TODO(scottmg): This should be moved to ui/. |
| 71 gfx::Rect DisplaySettingsProvider::GetPrimaryScreenArea() const { | 72 gfx::Rect DisplaySettingsProvider::GetPrimaryScreenArea() const { |
| 72 return gfx::Screen::GetPrimaryDisplay().bounds(); | 73 // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 |
| 74 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 gfx::Rect DisplaySettingsProvider::GetWorkArea() const { | 77 gfx::Rect DisplaySettingsProvider::GetWorkArea() const { |
| 76 #if defined(OS_MACOSX) | 78 #if defined(OS_MACOSX) |
| 77 // On OSX, panels should be dropped all the way to the bottom edge of the | 79 // On OSX, panels should be dropped all the way to the bottom edge of the |
| 78 // screen (and overlap Dock). And we also want to exclude the system menu | 80 // screen (and overlap Dock). And we also want to exclude the system menu |
| 79 // area. Note that the rect returned from gfx::Screen util functions is in | 81 // area. Note that the rect returned from gfx::Screen util functions is in |
| 80 // platform-independent screen coordinates with (0, 0) as the top-left corner. | 82 // platform-independent screen coordinates with (0, 0) as the top-left corner. |
| 81 gfx::Display display = gfx::Screen::GetPrimaryDisplay(); | 83 // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 |
| 84 gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 82 gfx::Rect display_area = display.bounds(); | 85 gfx::Rect display_area = display.bounds(); |
| 83 gfx::Rect work_area = display.work_area(); | 86 gfx::Rect work_area = display.work_area(); |
| 84 int system_menu_height = work_area.y() - display_area.y(); | 87 int system_menu_height = work_area.y() - display_area.y(); |
| 85 if (system_menu_height > 0) { | 88 if (system_menu_height > 0) { |
| 86 display_area.set_y(display_area.y() + system_menu_height); | 89 display_area.set_y(display_area.y() + system_menu_height); |
| 87 display_area.set_height(display_area.height() - system_menu_height); | 90 display_area.set_height(display_area.height() - system_menu_height); |
| 88 } | 91 } |
| 89 return display_area; | 92 return display_area; |
| 90 #else | 93 #else |
| 91 gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); | 94 // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 |
| 95 gfx::Rect work_area = |
| 96 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); |
| 97 return work_area; |
| 92 #endif | 98 #endif |
| 93 return work_area; | |
| 94 } | 99 } |
| 95 | 100 |
| 96 void DisplaySettingsProvider::OnDisplaySettingsChanged() { | 101 void DisplaySettingsProvider::OnDisplaySettingsChanged() { |
| 97 gfx::Rect work_area = GetWorkArea(); | 102 gfx::Rect work_area = GetWorkArea(); |
| 98 if (work_area == work_area_) | 103 if (work_area == work_area_) |
| 99 return; | 104 return; |
| 100 work_area_ = work_area; | 105 work_area_ = work_area; |
| 101 | 106 |
| 102 OnAutoHidingDesktopBarChanged(); | 107 OnAutoHidingDesktopBarChanged(); |
| 103 } | 108 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 bool DisplaySettingsProvider::IsFullScreen() const { | 172 bool DisplaySettingsProvider::IsFullScreen() const { |
| 168 return IsFullScreenMode(); | 173 return IsFullScreenMode(); |
| 169 } | 174 } |
| 170 | 175 |
| 171 #if defined(USE_AURA) | 176 #if defined(USE_AURA) |
| 172 // static | 177 // static |
| 173 DisplaySettingsProvider* DisplaySettingsProvider::Create() { | 178 DisplaySettingsProvider* DisplaySettingsProvider::Create() { |
| 174 return new DisplaySettingsProvider(); | 179 return new DisplaySettingsProvider(); |
| 175 } | 180 } |
| 176 #endif | 181 #endif |
| OLD | NEW |