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

Unified Diff: ash/wm/window_cycle_controller.cc

Issue 260883005: Separated alt-tab window cycle from overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed some compile errors Created 6 years, 7 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
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_cycle_controller.cc
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4946081d53a0e8baf8a4b2b9f4ef2bb77aef7a76
--- /dev/null
+++ b/ash/wm/window_cycle_controller.cc
@@ -0,0 +1,106 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/window_cycle_controller.h"
+
+#include <algorithm>
flackr 2014/05/07 00:07:55 Don't think this is used.
Nina 2014/05/07 14:55:42 Removed. However, I get a warning from lint if I r
+
+#include "ash/session/session_state_delegate.h"
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
flackr 2014/05/07 00:07:55 This isn't used either.
Nina 2014/05/07 14:55:42 Done.
+#include "ash/wm/mru_window_tracker.h"
+#include "ash/wm/window_cycle_list.h"
+#include "ash/wm/window_util.h"
flackr 2014/05/07 00:07:55 or this.
Nina 2014/05/07 14:55:42 Done.
+#include "ash/wm/workspace_controller.h"
flackr 2014/05/07 00:07:55 Possibly not this either.
Nina 2014/05/07 14:55:42 Done.
+#include "ui/events/event.h"
+#include "ui/events/event_handler.h"
+
+namespace ash {
+
+namespace {
+
+// Filter to watch for the termination of a keyboard gesture to cycle through
+// multiple windows.
+class WindowCycleEventFilter : public ui::EventHandler {
+ public:
+ WindowCycleEventFilter();
+ virtual ~WindowCycleEventFilter();
+
+ // Overridden from ui::EventHandler:
+ virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter);
+};
+
+WindowCycleEventFilter::WindowCycleEventFilter() {
+}
+
+WindowCycleEventFilter::~WindowCycleEventFilter() {
+}
+
+void WindowCycleEventFilter::OnKeyEvent(ui::KeyEvent* event) {
+ // Views uses VKEY_MENU for both left and right Alt keys.
+ if (event->key_code() == ui::VKEY_MENU &&
+ event->type() == ui::ET_KEY_RELEASED) {
+ Shell::GetInstance()->window_cycle_controller()->StopCycling();
+ // Warning: |this| will be deleted from here on.
+ }
+}
+
+} // namespace
+
+
+// WindowCycleController, public:
+
+WindowCycleController::WindowCycleController() {
+}
+
+WindowCycleController::~WindowCycleController() {
+ StopCycling();
flackr 2014/05/07 00:07:55 With the comment on line 86 fixed, this probably d
Nina 2014/05/07 14:55:42 Done.
+}
+
+// static
+bool WindowCycleController::CanCycle() {
+ // Don't allow window cycling if the screen is locked or a modal dialog is
+ // open.
+ return !Shell::GetInstance()->session_state_delegate()->IsScreenLocked() &&
+ !Shell::GetInstance()->IsSystemModalWindowOpen();
+}
+
+void WindowCycleController::HandleCycleWindow(Direction direction) {
+ if (!CanCycle())
+ return;
+
+ if (!IsCycling())
+ StartCycling();
+
+ Step(direction);
+}
+
+void WindowCycleController::StartCycling() {
+ window_cycle_list_.reset(new WindowCycleList(ash::Shell::GetInstance()->
+ mru_window_tracker()->BuildMruWindowList()));
+ event_handler_.reset(new WindowCycleEventFilter());
flackr 2014/05/07 16:03:45 Sorry, didn't mean to move the event_handler_ cons
+ Shell::GetInstance()->AddPreTargetHandler(event_handler_.get());
flackr 2014/05/07 00:07:55 Add and remove the pretarget handler from the Wind
Nina 2014/05/07 14:55:42 Done.
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// WindowCycleController, private:
+
+void WindowCycleController::Step(Direction direction) {
+ DCHECK(window_cycle_list_.get());
+ window_cycle_list_->Step(direction);
+}
+
+void WindowCycleController::StopCycling() {
+ window_cycle_list_.reset();
+ // Remove our key event filter.
+ if (event_handler_) {
flackr 2014/05/07 00:07:55 And with the comment on line 86, event_handler_ ca
Nina 2014/05/07 14:55:42 Done.
+ Shell::GetInstance()->RemovePreTargetHandler(event_handler_.get());
+ event_handler_.reset();
+ }
+}
+
+} // namespace ash
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698