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

Side by Side Diff: ash/common/wm/maximize_mode/maximize_mode_event_handler.cc

Issue 2787363002: Moves couple of WmShell methods to standalone functions (Closed)
Patch Set: feedback and fix applist Created 3 years, 8 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/immersive_context_ash.cc ('k') | ash/common/wm/mru_window_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" 5 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h"
6 6
7 #include "ash/common/session/session_controller.h" 7 #include "ash/common/session/session_controller.h"
8 #include "ash/common/system/tray/system_tray_delegate.h" 8 #include "ash/common/system/tray/system_tray_delegate.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm/wm_event.h" 10 #include "ash/common/wm/wm_event.h"
11 #include "ash/common/wm_shell.h"
12 #include "ash/common/wm_window.h" 11 #include "ash/common/wm_window.h"
13 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/wm/window_util.h"
14 #include "ui/events/event.h" 14 #include "ui/events/event.h"
15 15
16 namespace ash { 16 namespace ash {
17 namespace wm { 17 namespace wm {
18 namespace { 18 namespace {
19 19
20 // The height of the area in which a touch operation leads to exiting the 20 // The height of the area in which a touch operation leads to exiting the
21 // full screen mode. 21 // full screen mode.
22 const int kLeaveFullScreenAreaHeightInPixel = 2; 22 const int kLeaveFullScreenAreaHeightInPixel = 2;
23 23
24 } // namespace 24 } // namespace
25 25
26 MaximizeModeEventHandler::MaximizeModeEventHandler() {} 26 MaximizeModeEventHandler::MaximizeModeEventHandler() {}
27 27
28 MaximizeModeEventHandler::~MaximizeModeEventHandler() {} 28 MaximizeModeEventHandler::~MaximizeModeEventHandler() {}
29 29
30 bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) { 30 bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) {
31 if (event.type() != ui::ET_TOUCH_PRESSED) 31 if (event.type() != ui::ET_TOUCH_PRESSED)
32 return false; 32 return false;
33 33
34 const SessionController* controller = Shell::Get()->session_controller(); 34 const SessionController* controller = Shell::Get()->session_controller();
35 35
36 if (controller->IsScreenLocked() || 36 if (controller->IsScreenLocked() ||
37 controller->GetSessionState() != session_manager::SessionState::ACTIVE) { 37 controller->GetSessionState() != session_manager::SessionState::ACTIVE) {
38 return false; 38 return false;
39 } 39 }
40 40
41 // Find the active window (from the primary screen) to un-fullscreen. 41 // Find the active window (from the primary screen) to un-fullscreen.
42 WmWindow* window = WmShell::Get()->GetActiveWindow(); 42 WmWindow* window = WmWindow::Get(GetActiveWindow());
43 if (!window) 43 if (!window)
44 return false; 44 return false;
45 45
46 WindowState* window_state = window->GetWindowState(); 46 WindowState* window_state = window->GetWindowState();
47 if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen()) 47 if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen())
48 return false; 48 return false;
49 49
50 // Test that the touch happened in the top or bottom lines. 50 // Test that the touch happened in the top or bottom lines.
51 int y = event.y(); 51 int y = event.y();
52 if (y >= kLeaveFullScreenAreaHeightInPixel && 52 if (y >= kLeaveFullScreenAreaHeightInPixel &&
(...skipping 10 matching lines...) Expand all
63 return false; 63 return false;
64 } 64 }
65 65
66 WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN); 66 WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN);
67 window->GetWindowState()->OnWMEvent(&toggle_fullscreen); 67 window->GetWindowState()->OnWMEvent(&toggle_fullscreen);
68 return true; 68 return true;
69 } 69 }
70 70
71 } // namespace wm 71 } // namespace wm
72 } // namespace ash 72 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/immersive_context_ash.cc ('k') | ash/common/wm/mru_window_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698