diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 05:57:52 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 05:57:52 +0000 |
commit | 0578bfb59485bb09740b611ecb12c059278f300f (patch) | |
tree | ef7339124986b60bfd45f12ce2e47cddf9a08ded | |
parent | 8f547ea7edbf6bfd0d94dea2d9a250af0bc422ab (diff) | |
download | chromium_src-0578bfb59485bb09740b611ecb12c059278f300f.zip chromium_src-0578bfb59485bb09740b611ecb12c059278f300f.tar.gz chromium_src-0578bfb59485bb09740b611ecb12c059278f300f.tar.bz2 |
Use 100ms delay before overview and add a flag for setting the delay.
BUG=310269
TEST=Alt tabbing should very quickly enter overview mode.
Review URL: https://codereview.chromium.org/37273002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230656 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/ash_switches.cc | 4 | ||||
-rw-r--r-- | ash/ash_switches.h | 1 | ||||
-rw-r--r-- | ash/wm/overview/window_selector.cc | 37 | ||||
-rw-r--r-- | ash/wm/overview/window_selector.h | 1 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 18 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 21 |
6 files changed, 79 insertions, 3 deletions
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc index 118f787..5800bbc 100644 --- a/ash/ash_switches.cc +++ b/ash/ash_switches.cc @@ -153,6 +153,10 @@ const char kAshImmersiveHideTabIndicators[] = const char kAshOemWallpaperLarge[] = "ash-oem-wallpaper-large"; const char kAshOemWallpaperSmall[] = "ash-oem-wallpaper-small"; +// Specifies the delay in milliseconds before beginning overview mode after +// getting an alt tab keypress. +const char kAshOverviewDelayOnAltTab[] = "ash-overview-delay-on-alt-tab"; + // Specifies the layout mode and offsets for the secondary display for // testing. The format is "<t|r|b|l>,<offset>" where t=TOP, r=RIGHT, // b=BOTTOM and L=LEFT. For example, 'r,-100' means the secondary display diff --git a/ash/ash_switches.h b/ash/ash_switches.h index 908c897..d502c82 100644 --- a/ash/ash_switches.h +++ b/ash/ash_switches.h @@ -62,6 +62,7 @@ ASH_EXPORT extern const char kAshHostWindowBounds[]; ASH_EXPORT extern const char kAshImmersiveHideTabIndicators[]; ASH_EXPORT extern const char kAshOemWallpaperLarge[]; ASH_EXPORT extern const char kAshOemWallpaperSmall[]; +ASH_EXPORT extern const char kAshOverviewDelayOnAltTab[]; ASH_EXPORT extern const char kAshSecondaryDisplayLayout[]; ASH_EXPORT extern const char kAshTouchHud[]; ASH_EXPORT extern const char kAshUseAlternateShelfLayout[]; diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc index 47d3c49..e23f5b3 100644 --- a/ash/wm/overview/window_selector.cc +++ b/ash/wm/overview/window_selector.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "ash/ash_switches.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/wm/mru_window_tracker.h" @@ -15,7 +16,9 @@ #include "ash/wm/overview/window_selector_window.h" #include "ash/wm/window_state.h" #include "base/auto_reset.h" +#include "base/command_line.h" #include "base/metrics/histogram.h" +#include "base/strings/string_number_conversions.h" #include "base/timer/timer.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/focus_client.h" @@ -29,7 +32,29 @@ namespace ash { namespace { -const int kOverviewDelayOnCycleMilliseconds = 500; +// The time from when the user pressed alt+tab while still holding alt before +// overview is engaged. +const int kOverviewDelayOnCycleMilliseconds = 100; + +// The maximum amount of time allowed for the delay before overview on cycling. +// If the specified time exceeds this the timer will not be started. +const int kMaxOverviewDelayOnCycleMilliseconds = 10000; + +int GetOverviewDelayOnCycleMilliseconds() { + static int value = -1; + if (value == -1) { + value = kOverviewDelayOnCycleMilliseconds; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAshOverviewDelayOnAltTab)) { + if (!base::StringToInt(CommandLine::ForCurrentProcess()-> + GetSwitchValueASCII(switches::kAshOverviewDelayOnAltTab), &value)) { + LOG(ERROR) << "Expected int value for " + << switches::kAshOverviewDelayOnAltTab; + } + } + } + return value; +} // A comparator for locating a given target window. struct WindowSelectorItemComparator @@ -209,8 +234,11 @@ WindowSelector::WindowSelector(const WindowList& windows, WindowSelector::Mode mode, WindowSelectorDelegate* delegate) : mode_(mode), + timer_enabled_(GetOverviewDelayOnCycleMilliseconds() < + kMaxOverviewDelayOnCycleMilliseconds), start_overview_timer_(FROM_HERE, - base::TimeDelta::FromMilliseconds(kOverviewDelayOnCycleMilliseconds), + base::TimeDelta::FromMilliseconds( + GetOverviewDelayOnCycleMilliseconds()), this, &WindowSelector::StartOverview), delegate_(delegate), selected_window_(0), @@ -259,7 +287,8 @@ WindowSelector::WindowSelector(const WindowList& windows, if (mode == WindowSelector::CYCLE) { event_handler_.reset(new WindowSelectorEventFilter(this)); - start_overview_timer_.Reset(); + if (timer_enabled_) + start_overview_timer_.Reset(); } else { StartOverview(); } @@ -307,6 +336,8 @@ void WindowSelector::Step(WindowSelector::Direction direction) { showing_window_.reset(new ScopedShowWindow); showing_window_->Show(windows_[selected_window_]->SelectionWindow()); start_overview_timer_.Reset(); + if (timer_enabled_) + start_overview_timer_.Reset(); } } diff --git a/ash/wm/overview/window_selector.h b/ash/wm/overview/window_selector.h index 2f178b6..4fc29d1 100644 --- a/ash/wm/overview/window_selector.h +++ b/ash/wm/overview/window_selector.h @@ -117,6 +117,7 @@ class ASH_EXPORT WindowSelector // of the stacking order and made visible). scoped_ptr<ScopedShowWindow> showing_window_; + bool timer_enabled_; base::DelayTimer<WindowSelector> start_overview_timer_; scoped_ptr<WindowOverview> window_overview_; diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 95a04e3..03e5202 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6028,6 +6028,24 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_DISABLE_OVERVIEW_MODE_DESCRIPTION" desc="Description for the flag to disable window overview mode."> Disable overview mode, activated by pushing the switch window button. </message> + <message name="IDS_FLAGS_OVERVIEW_DELAY_NAME" desc="Title for the delay before engaging overview on alt+tab."> + Delay before engaging overview when cycling. + </message> + <message name="IDS_FLAGS_OVERVIEW_DELAY_DESCRIPTION" desc="Description for what the delay before engaging overview means."> + The time from the last alt+tab press before engaging overview mode when cycling through windows. + </message> + <message name="IDS_FLAGS_OVERVIEW_DELAY_INSTANT" desc="The choice to have overview engage immediately on alt+tab."> + Instant + </message> + <message name="IDS_FLAGS_OVERVIEW_DELAY_SHORT" desc="The choice to have overview engage almost immediately on alt+tab."> + Very short + </message> + <message name="IDS_FLAGS_OVERVIEW_DELAY_LONG" desc="The choice to have overview engage after a fairly long delay."> + Long + </message> + <message name="IDS_FLAGS_OVERVIEW_DELAY_NEVER" desc="The choice to have overview not engage on alt+tab."> + Never + </message> <message name="IDS_FLAGS_SCROLL_END_EFFECT_NAME" desc="Title for the flag for scroll end effect from vertical overscroll."> Scroll end effect </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 89fc692..c79dff3 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -261,6 +261,20 @@ const Experiment::Choice kDefaultTileWidthChoices[] = { switches::kDefaultTileWidth, "1024"} }; +#if defined(USE_ASH) +const Experiment::Choice kAshOverviewDelayChoices[] = { + { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, + { IDS_FLAGS_OVERVIEW_DELAY_INSTANT, + ash::switches::kAshOverviewDelayOnAltTab, "0" }, + { IDS_FLAGS_OVERVIEW_DELAY_SHORT, + ash::switches::kAshOverviewDelayOnAltTab, "100" }, + { IDS_FLAGS_OVERVIEW_DELAY_LONG, + ash::switches::kAshOverviewDelayOnAltTab, "500" }, + { IDS_FLAGS_OVERVIEW_DELAY_NEVER, + ash::switches::kAshOverviewDelayOnAltTab, "10000" }, +}; +#endif + const Experiment::Choice kDefaultTileHeightChoices[] = { { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, { IDS_FLAGS_DEFAULT_TILE_HEIGHT_SHORT, @@ -1064,6 +1078,13 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(ash::switches::kAshDisableOverviewMode) }, { + "overview-delay-on-alt-tab", + IDS_FLAGS_OVERVIEW_DELAY_NAME, + IDS_FLAGS_OVERVIEW_DELAY_DESCRIPTION, + kOsCrOS, + MULTI_VALUE_TYPE(kAshOverviewDelayChoices) + }, + { "show-touch-hud", IDS_FLAGS_SHOW_TOUCH_HUD_NAME, IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION, |