| OLD | NEW |
| (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 "ash/system/tray/system_tray_delegate.h" | |
| 13 #include "ui/events/event.h" | |
| 14 | |
| 15 namespace ash { | |
| 16 namespace wm { | |
| 17 namespace { | |
| 18 | |
| 19 // The height of the area in which a touch operation leads to exiting the | |
| 20 // full screen mode. | |
| 21 const int kLeaveFullScreenAreaHeightInPixel = 2; | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 MaximizeModeEventHandler::MaximizeModeEventHandler() {} | |
| 26 | |
| 27 MaximizeModeEventHandler::~MaximizeModeEventHandler() {} | |
| 28 | |
| 29 bool MaximizeModeEventHandler::ToggleFullscreen(const ui::TouchEvent& event) { | |
| 30 if (event.type() != ui::ET_TOUCH_PRESSED) | |
| 31 return false; | |
| 32 | |
| 33 const SessionStateDelegate* delegate = | |
| 34 WmShell::Get()->GetSessionStateDelegate(); | |
| 35 | |
| 36 if (delegate->IsScreenLocked() || | |
| 37 delegate->GetSessionState() != session_manager::SessionState::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 // Do not exit fullscreen in kiosk mode. | |
| 58 SystemTrayDelegate* system_tray_delegate = | |
| 59 WmShell::Get()->system_tray_delegate(); | |
| 60 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP || | |
| 61 system_tray_delegate->GetUserLoginStatus() == | |
| 62 LoginStatus::ARC_KIOSK_APP) { | |
| 63 return false; | |
| 64 } | |
| 65 | |
| 66 WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN); | |
| 67 window->GetWindowState()->OnWMEvent(&toggle_fullscreen); | |
| 68 return true; | |
| 69 } | |
| 70 | |
| 71 } // namespace wm | |
| 72 } // namespace ash | |
| OLD | NEW |