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

Unified Diff: ash/common/wm/maximize_mode/maximize_mode_event_handler.cc

Issue 2106823004: Refactors maximize mode event handling into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 6 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/common/wm/maximize_mode/maximize_mode_event_handler.h ('k') | ash/common/wm_shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/wm/maximize_mode/maximize_mode_event_handler.cc
diff --git a/ash/common/wm/maximize_mode/maximize_mode_event_handler.cc b/ash/common/wm/maximize_mode/maximize_mode_event_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b852f526cdd35f8f3dbdf5f2f8cf5b0ac8a1faba
--- /dev/null
+++ b/ash/common/wm/maximize_mode/maximize_mode_event_handler.cc
@@ -0,0 +1,63 @@
+// Copyright 2016 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/common/wm/maximize_mode/maximize_mode_event_handler.h"
+
+#include "ash/common/session/session_state_delegate.h"
+#include "ash/common/wm/window_state.h"
+#include "ash/common/wm/wm_event.h"
+#include "ash/common/wm_shell.h"
+#include "ash/common/wm_window.h"
+#include "ui/events/event.h"
+
+namespace ash {
+namespace wm {
+namespace {
+
+// The height of the area in which a touch operation leads to exiting the
+// full screen mode.
+const int kLeaveFullScreenAreaHeightInPixel = 2;
James Cook 2016/06/28 23:10:21 Aside: This seems like a weird feature. A 2-pixel
+
+} // namespace
+
+MaximizeModeEventHandler::MaximizeModeEventHandler() {}
+
+MaximizeModeEventHandler::~MaximizeModeEventHandler() {}
+
+bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) {
+ if (event.type() != ui::ET_TOUCH_PRESSED)
+ return false;
+
+ const SessionStateDelegate* delegate =
+ WmShell::Get()->GetSessionStateDelegate();
+
+ if (delegate->IsScreenLocked() ||
+ delegate->GetSessionState() !=
+ SessionStateDelegate::SESSION_STATE_ACTIVE) {
+ return false;
+ }
+
+ // Find the active window (from the primary screen) to un-fullscreen.
+ WmWindow* window = WmShell::Get()->GetActiveWindow();
+ if (!window)
+ return false;
+
+ WindowState* window_state = window->GetWindowState();
+ if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen())
+ return false;
+
+ // Test that the touch happened in the top or bottom lines.
+ int y = event.y();
+ if (y >= kLeaveFullScreenAreaHeightInPixel &&
+ y < (window->GetBounds().height() - kLeaveFullScreenAreaHeightInPixel)) {
+ return false;
+ }
+
+ WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN);
+ window->GetWindowState()->OnWMEvent(&toggle_fullscreen);
+ return true;
+}
+
+} // namespace wm
+} // namespace ash
« no previous file with comments | « ash/common/wm/maximize_mode/maximize_mode_event_handler.h ('k') | ash/common/wm_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698