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

Side by Side 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, 5 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h"
6
7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm/wm_event.h"
10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h"
12 #include "ui/events/event.h"
13
14 namespace ash {
15 namespace wm {
16 namespace {
17
18 // The height of the area in which a touch operation leads to exiting the
19 // full screen mode.
20 const int kLeaveFullScreenAreaHeightInPixel = 2;
James Cook 2016/06/28 23:10:21 Aside: This seems like a weird feature. A 2-pixel
21
22 } // namespace
23
24 MaximizeModeEventHandler::MaximizeModeEventHandler() {}
25
26 MaximizeModeEventHandler::~MaximizeModeEventHandler() {}
27
28 bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) {
29 if (event.type() != ui::ET_TOUCH_PRESSED)
30 return false;
31
32 const SessionStateDelegate* delegate =
33 WmShell::Get()->GetSessionStateDelegate();
34
35 if (delegate->IsScreenLocked() ||
36 delegate->GetSessionState() !=
37 SessionStateDelegate::SESSION_STATE_ACTIVE) {
38 return false;
39 }
40
41 // Find the active window (from the primary screen) to un-fullscreen.
42 WmWindow* window = WmShell::Get()->GetActiveWindow();
43 if (!window)
44 return false;
45
46 WindowState* window_state = window->GetWindowState();
47 if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen())
48 return false;
49
50 // Test that the touch happened in the top or bottom lines.
51 int y = event.y();
52 if (y >= kLeaveFullScreenAreaHeightInPixel &&
53 y < (window->GetBounds().height() - kLeaveFullScreenAreaHeightInPixel)) {
54 return false;
55 }
56
57 WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN);
58 window->GetWindowState()->OnWMEvent(&toggle_fullscreen);
59 return true;
60 }
61
62 } // namespace wm
63 } // namespace ash
OLDNEW
« 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