OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/panel_manager.h" | 5 #include "chrome/browser/ui/panels/panel_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const double kPanelMaxWidthFactor = 0.35; | 35 const double kPanelMaxWidthFactor = 0.35; |
36 const double kPanelMaxHeightFactor = 0.5; | 36 const double kPanelMaxHeightFactor = 0.5; |
37 | 37 |
38 // Occasionally some system, like Windows, might not bring up or down the bottom | 38 // Occasionally some system, like Windows, might not bring up or down the bottom |
39 // bar when the mouse enters or leaves the bottom screen area. This is the | 39 // bar when the mouse enters or leaves the bottom screen area. This is the |
40 // maximum time we will wait for the bottom bar visibility change notification. | 40 // maximum time we will wait for the bottom bar visibility change notification. |
41 // After the time expires, we bring up/down the titlebars as planned. | 41 // After the time expires, we bring up/down the titlebars as planned. |
42 const int kMaxMillisecondsWaitForBottomBarVisibilityChange = 1000; | 42 const int kMaxMillisecondsWaitForBottomBarVisibilityChange = 1000; |
43 | 43 |
44 // See usage below. | 44 // See usage below. |
45 #if defined(OS_MACOSX) | 45 #if defined(TOOLKIT_GTK) |
46 const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 3000; | |
47 #elif defined(TOOLKIT_GTK) | |
48 const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 2000; | 46 const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 2000; |
49 #else | 47 #else |
50 const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 0; | 48 const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 0; |
51 #endif | 49 #endif |
52 } // namespace | 50 } // namespace |
53 | 51 |
54 // static | 52 // static |
55 PanelManager* PanelManager::GetInstance() { | 53 PanelManager* PanelManager::GetInstance() { |
56 static base::LazyInstance<PanelManager> instance = LAZY_INSTANCE_INITIALIZER; | 54 static base::LazyInstance<PanelManager> instance = LAZY_INSTANCE_INITIALIZER; |
57 return instance.Pointer(); | 55 return instance.Pointer(); |
(...skipping 16 matching lines...) Expand all Loading... |
74 | 72 |
75 PanelManager::~PanelManager() { | 73 PanelManager::~PanelManager() { |
76 DCHECK(panels_.empty()); | 74 DCHECK(panels_.empty()); |
77 DCHECK(panels_pending_to_remove_.empty()); | 75 DCHECK(panels_pending_to_remove_.empty()); |
78 DCHECK_EQ(0, minimized_panel_count_); | 76 DCHECK_EQ(0, minimized_panel_count_); |
79 } | 77 } |
80 | 78 |
81 void PanelManager::OnDisplayChanged() { | 79 void PanelManager::OnDisplayChanged() { |
82 scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( | 80 scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( |
83 WindowSizer::CreateDefaultMonitorInfoProvider()); | 81 WindowSizer::CreateDefaultMonitorInfoProvider()); |
84 SetWorkArea(info_provider->GetPrimaryMonitorWorkArea()); | 82 #if defined(OS_MACOSX) |
| 83 // On OSX, panels should be dropped all the way to the bottom edge of the |
| 84 // screen (and overlap Dock). |
| 85 gfx::Rect work_area = info_provider->GetPrimaryMonitorBounds(); |
| 86 #else |
| 87 gfx::Rect work_area = info_provider->GetPrimaryMonitorWorkArea(); |
| 88 #endif |
| 89 SetWorkArea(work_area); |
85 } | 90 } |
86 | 91 |
87 void PanelManager::SetWorkArea(const gfx::Rect& work_area) { | 92 void PanelManager::SetWorkArea(const gfx::Rect& work_area) { |
88 if (work_area == work_area_) | 93 if (work_area == work_area_) |
89 return; | 94 return; |
90 work_area_ = work_area; | 95 work_area_ = work_area; |
91 | 96 |
92 auto_hiding_desktop_bar_->UpdateWorkArea(work_area_); | 97 auto_hiding_desktop_bar_->UpdateWorkArea(work_area_); |
93 AdjustWorkAreaForAutoHidingDesktopBars(); | 98 AdjustWorkAreaForAutoHidingDesktopBars(); |
94 | 99 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 } | 537 } |
533 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_RIGHT)) { | 538 if (auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_RIGHT)) { |
534 int space = auto_hiding_desktop_bar_->GetThickness( | 539 int space = auto_hiding_desktop_bar_->GetThickness( |
535 AutoHidingDesktopBar::ALIGN_RIGHT); | 540 AutoHidingDesktopBar::ALIGN_RIGHT); |
536 adjusted_work_area_.set_width(adjusted_work_area_.width() - space); | 541 adjusted_work_area_.set_width(adjusted_work_area_.width() - space); |
537 } | 542 } |
538 } | 543 } |
539 | 544 |
540 int PanelManager::GetBottomPositionForExpansionState( | 545 int PanelManager::GetBottomPositionForExpansionState( |
541 Panel::ExpansionState expansion_state) const { | 546 Panel::ExpansionState expansion_state) const { |
| 547 int bottom = adjusted_work_area_.bottom(); |
542 // If there is an auto-hiding desktop bar aligned to the bottom edge, we need | 548 // If there is an auto-hiding desktop bar aligned to the bottom edge, we need |
543 // to move the minimize panel down to the bottom edge. | 549 // to move the minimize panel down to the bottom edge. |
544 int bottom = adjusted_work_area_.bottom(); | |
545 if (expansion_state == Panel::MINIMIZED && | 550 if (expansion_state == Panel::MINIMIZED && |
546 auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) { | 551 auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) { |
547 bottom += auto_hiding_desktop_bar_->GetThickness( | 552 bottom += auto_hiding_desktop_bar_->GetThickness( |
548 AutoHidingDesktopBar::ALIGN_BOTTOM); | 553 AutoHidingDesktopBar::ALIGN_BOTTOM); |
549 } | 554 } |
550 | 555 |
551 return bottom; | 556 return bottom; |
552 } | 557 } |
553 | 558 |
554 BrowserWindow* PanelManager::GetNextBrowserWindowToActivate( | 559 BrowserWindow* PanelManager::GetNextBrowserWindowToActivate( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 620 |
616 // Start from the bottom to avoid reshuffling. | 621 // Start from the bottom to avoid reshuffling. |
617 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 622 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
618 iter != panels_copy.rend(); ++iter) | 623 iter != panels_copy.rend(); ++iter) |
619 (*iter)->Close(); | 624 (*iter)->Close(); |
620 } | 625 } |
621 | 626 |
622 bool PanelManager::is_dragging_panel() const { | 627 bool PanelManager::is_dragging_panel() const { |
623 return dragging_panel_index_ != kInvalidPanelIndex; | 628 return dragging_panel_index_ != kInvalidPanelIndex; |
624 } | 629 } |
OLD | NEW |