Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: chrome/browser/ui/panels/panel_manager.cc

Issue 8341098: Mac: Added a delay before panels go to minimized state from title-only state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/panels/panel_manager.cc
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
index 5bb2bc8d0dc8b9280c3408159ef4e5e4dda75585..ef350aa23d2bb0d805c3b43af383b0631f6f6e3d 100644
--- a/chrome/browser/ui/panels/panel_manager.cc
+++ b/chrome/browser/ui/panels/panel_manager.cc
@@ -32,11 +32,21 @@ const double kPanelMaxHeightFactor = 0.5;
// After the time expires, we bring up/down the titlebars as planned.
const int kMaxMillisecondsWaitForBottomBarVisibilityChange = 1000;
+// See usage below.
+#if defined (OS_MACOSX)
jianli 2011/10/28 01:04:11 Extra empty space.
Dmitry Titov 2011/10/28 20:58:23 Done.
+const int kMillisecondsBeforeCollapsingFromTitleonlyState = 3000;
+#else
+const int kMillisecondsBeforeCollapsingFromTitleonlyState = 0;
+#endif
+
// Single instance of PanelManager.
scoped_refptr<PanelManager> panel_manager_instance;
} // namespace
// static
+int PanelManager::sLastTaskIndex = 0;
+
+// static
PanelManager* PanelManager::GetInstance() {
if (!panel_manager_instance.get())
panel_manager_instance = new PanelManager();
@@ -411,22 +421,54 @@ void PanelManager::BringUpOrDownTitlebars(bool bring_up) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &PanelManager::DelayedBringUpOrDownTitlebarsCheck),
+ &PanelManager::DelayedBringUpOrDownTitlebarsCheck,
+ ++sLastTaskIndex),
jianli 2011/10/28 01:04:11 Where do we reset sLastTaskIndex? What if increasi
Dmitry Titov 2011/10/28 20:58:23 If we post a task every time user moves the mouse
kMaxMillisecondsWaitForBottomBarVisibilityChange);
return;
}
}
+ // On some OSes, the interaction with native Taskbars/Docks may be improved
+ // if the panels are not go back to minimized state too fast. For example,
jianli 2011/10/28 01:04:11 are not => do not
Dmitry Titov 2011/10/28 20:58:23 Done.
+ // it makes it possible to hit the titlebar on OSX if Dock has Magnifying
+ // enabled - the panels stay up for a while after Dock magnification effect
+ // stops covering the panels.
+ if (!bring_up) {
+ delayed_titlebar_action_ = BRING_DOWN;
+ MessageLoop::current()->PostDelayedTask(
jianli 2011/10/28 01:04:11 This seems to be similar to the above PostDelayed
Dmitry Titov 2011/10/28 20:58:23 Done.
+ FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &PanelManager::DelayedBringUpOrDownTitlebarsCheck,
+ ++sLastTaskIndex),
+ kMillisecondsBeforeCollapsingFromTitleonlyState);
+ return;
+ }
+
+
DoBringUpOrDownTitlebars(bring_up);
}
-void PanelManager::DelayedBringUpOrDownTitlebarsCheck() {
+void PanelManager::DelayedBringUpOrDownTitlebarsCheck(int taskIndex) {
jianli 2011/10/28 01:04:11 taskIndex => task_index
Dmitry Titov 2011/10/28 20:58:23 Done.
+ // task was already processed or cancelled - bail out.
jianli 2011/10/28 01:04:11 task needs to be capitalized.
Dmitry Titov 2011/10/28 20:58:23 Done.
if (delayed_titlebar_action_ == NO_ACTION)
return;
- DoBringUpOrDownTitlebars(delayed_titlebar_action_ == BRING_UP);
+ // In case we posted multiple tasks because user was moving mouse back and
+ // forth, ignore all but the last one.
+ if (taskIndex < sLastTaskIndex)
+ return;
+ DCHECK(taskIndex == sLastTaskIndex);
+
+ // We are going to process the task one way or another after this point.
delayed_titlebar_action_ = NO_ACTION;
+
+ // Check if the action is still needed based on mouse position. In case the
+ // mouse moved and does not call for the titlebars change, cancel.
+ if (are_titlebars_up_ != (delayed_titlebar_action_ == BRING_UP))
+ return;
+
+ DoBringUpOrDownTitlebars(delayed_titlebar_action_ == BRING_UP);
}
void PanelManager::DoBringUpOrDownTitlebars(bool bring_up) {
« chrome/browser/ui/panels/panel_manager.h ('K') | « chrome/browser/ui/panels/panel_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698