| OLD | NEW |
| 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_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/common/wm/wm_event.h" | 9 #include "ash/common/wm/wm_event.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 MaximizeModeEventHandler::~MaximizeModeEventHandler() {} | 26 MaximizeModeEventHandler::~MaximizeModeEventHandler() {} |
| 27 | 27 |
| 28 bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) { | 28 bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) { |
| 29 if (event.type() != ui::ET_TOUCH_PRESSED) | 29 if (event.type() != ui::ET_TOUCH_PRESSED) |
| 30 return false; | 30 return false; |
| 31 | 31 |
| 32 const SessionStateDelegate* delegate = | 32 const SessionStateDelegate* delegate = |
| 33 WmShell::Get()->GetSessionStateDelegate(); | 33 WmShell::Get()->GetSessionStateDelegate(); |
| 34 | 34 |
| 35 if (delegate->IsScreenLocked() || | 35 if (delegate->IsScreenLocked() || |
| 36 delegate->GetSessionState() != | 36 delegate->GetSessionState() != session_manager::SessionState::ACTIVE) { |
| 37 SessionStateDelegate::SESSION_STATE_ACTIVE) { | |
| 38 return false; | 37 return false; |
| 39 } | 38 } |
| 40 | 39 |
| 41 // Find the active window (from the primary screen) to un-fullscreen. | 40 // Find the active window (from the primary screen) to un-fullscreen. |
| 42 WmWindow* window = WmShell::Get()->GetActiveWindow(); | 41 WmWindow* window = WmShell::Get()->GetActiveWindow(); |
| 43 if (!window) | 42 if (!window) |
| 44 return false; | 43 return false; |
| 45 | 44 |
| 46 WindowState* window_state = window->GetWindowState(); | 45 WindowState* window_state = window->GetWindowState(); |
| 47 if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen()) | 46 if (!window_state->IsFullscreen() || window_state->in_immersive_fullscreen()) |
| 48 return false; | 47 return false; |
| 49 | 48 |
| 50 // Test that the touch happened in the top or bottom lines. | 49 // Test that the touch happened in the top or bottom lines. |
| 51 int y = event.y(); | 50 int y = event.y(); |
| 52 if (y >= kLeaveFullScreenAreaHeightInPixel && | 51 if (y >= kLeaveFullScreenAreaHeightInPixel && |
| 53 y < (window->GetBounds().height() - kLeaveFullScreenAreaHeightInPixel)) { | 52 y < (window->GetBounds().height() - kLeaveFullScreenAreaHeightInPixel)) { |
| 54 return false; | 53 return false; |
| 55 } | 54 } |
| 56 | 55 |
| 57 WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN); | 56 WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN); |
| 58 window->GetWindowState()->OnWMEvent(&toggle_fullscreen); | 57 window->GetWindowState()->OnWMEvent(&toggle_fullscreen); |
| 59 return true; | 58 return true; |
| 60 } | 59 } |
| 61 | 60 |
| 62 } // namespace wm | 61 } // namespace wm |
| 63 } // namespace ash | 62 } // namespace ash |
| OLD | NEW |