| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/shell_surface.h" | 5 #include "components/exo/shell_surface.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // This is a struct for accelerator keys used to close ShellSurfaces. | 49 // This is a struct for accelerator keys used to close ShellSurfaces. |
| 50 const struct Accelerator { | 50 const struct Accelerator { |
| 51 ui::KeyboardCode keycode; | 51 ui::KeyboardCode keycode; |
| 52 int modifiers; | 52 int modifiers; |
| 53 } kCloseWindowAccelerators[] = { | 53 } kCloseWindowAccelerators[] = { |
| 54 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, | 54 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, |
| 55 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, | 55 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, |
| 56 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; | 56 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; |
| 57 | 57 |
| 58 void UpdateShelfStateForFullscreenChange(views::Widget* widget) { | 58 void UpdateShelfStateForFullscreenChange(views::Widget* widget) { |
| 59 ash::wm::WindowState* window_state = | |
| 60 ash::wm::GetWindowState(widget->GetNativeWindow()); | |
| 61 window_state->set_hide_shelf_when_fullscreen(false); | |
| 62 for (ash::WmWindow* root_window : ash::WmShell::Get()->GetAllRootWindows()) | 59 for (ash::WmWindow* root_window : ash::WmShell::Get()->GetAllRootWindows()) |
| 63 ash::WmShelf::ForWindow(root_window)->UpdateVisibilityState(); | 60 ash::WmShelf::ForWindow(root_window)->UpdateVisibilityState(); |
| 64 } | 61 } |
| 65 | 62 |
| 66 class CustomFrameView : public views::NonClientFrameView { | 63 class CustomFrameView : public views::NonClientFrameView { |
| 67 public: | 64 public: |
| 68 explicit CustomFrameView(views::Widget* widget) : widget_(widget) {} | 65 explicit CustomFrameView(views::Widget* widget) : widget_(widget) {} |
| 69 ~CustomFrameView() override {} | 66 ~CustomFrameView() override {} |
| 70 | 67 |
| 71 // Overridden from views::NonClientFrameView: | 68 // Overridden from views::NonClientFrameView: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ~CustomWindowStateDelegate() override { | 157 ~CustomWindowStateDelegate() override { |
| 161 if (widget_) | 158 if (widget_) |
| 162 widget_->RemoveObserver(this); | 159 widget_->RemoveObserver(this); |
| 163 } | 160 } |
| 164 | 161 |
| 165 // Overridden from ash::wm::WindowStateDelegate: | 162 // Overridden from ash::wm::WindowStateDelegate: |
| 166 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { | 163 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { |
| 167 if (widget_) { | 164 if (widget_) { |
| 168 bool enter_fullscreen = !window_state->IsFullscreen(); | 165 bool enter_fullscreen = !window_state->IsFullscreen(); |
| 169 widget_->SetFullscreen(enter_fullscreen); | 166 widget_->SetFullscreen(enter_fullscreen); |
| 167 ash::wm::WindowState* window_state = |
| 168 ash::wm::GetWindowState(widget_->GetNativeWindow()); |
| 169 window_state->set_in_immersive_fullscreen(enter_fullscreen); |
| 170 UpdateShelfStateForFullscreenChange(widget_); | 170 UpdateShelfStateForFullscreenChange(widget_); |
| 171 } | 171 } |
| 172 return true; | 172 return true; |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Overridden from views::WidgetObserver: | 175 // Overridden from views::WidgetObserver: |
| 176 void OnWidgetDestroying(views::Widget* widget) override { | 176 void OnWidgetDestroying(views::Widget* widget) override { |
| 177 widget_->RemoveObserver(this); | 177 widget_->RemoveObserver(this); |
| 178 widget_ = nullptr; | 178 widget_ = nullptr; |
| 179 } | 179 } |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 if (window_state->GetStateType() != ash::wm::WINDOW_STATE_TYPE_NORMAL && | 1042 if (window_state->GetStateType() != ash::wm::WINDOW_STATE_TYPE_NORMAL && |
| 1043 !state_changed_callback_.is_null()) { | 1043 !state_changed_callback_.is_null()) { |
| 1044 state_changed_callback_.Run(ash::wm::WINDOW_STATE_TYPE_NORMAL, | 1044 state_changed_callback_.Run(ash::wm::WINDOW_STATE_TYPE_NORMAL, |
| 1045 window_state->GetStateType()); | 1045 window_state->GetStateType()); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 // Disable movement if initial bounds were specified. | 1048 // Disable movement if initial bounds were specified. |
| 1049 widget_->set_movement_disabled(!initial_bounds_.IsEmpty()); | 1049 widget_->set_movement_disabled(!initial_bounds_.IsEmpty()); |
| 1050 window_state->set_ignore_keyboard_bounds_change(!initial_bounds_.IsEmpty()); | 1050 window_state->set_ignore_keyboard_bounds_change(!initial_bounds_.IsEmpty()); |
| 1051 | 1051 |
| 1052 // AutoHide shelf in fullscreen state. |
| 1053 window_state->set_hide_shelf_when_fullscreen(false); |
| 1054 |
| 1052 // Allow Ash to manage the position of a top-level shell surfaces if show | 1055 // Allow Ash to manage the position of a top-level shell surfaces if show |
| 1053 // state is one that allows auto positioning and |initial_bounds_| has | 1056 // state is one that allows auto positioning and |initial_bounds_| has |
| 1054 // not been set. | 1057 // not been set. |
| 1055 window_state->set_window_position_managed( | 1058 window_state->set_window_position_managed( |
| 1056 ash::wm::ToWindowShowState(ash::wm::WINDOW_STATE_TYPE_AUTO_POSITIONED) == | 1059 ash::wm::ToWindowShowState(ash::wm::WINDOW_STATE_TYPE_AUTO_POSITIONED) == |
| 1057 show_state && | 1060 show_state && |
| 1058 initial_bounds_.IsEmpty()); | 1061 initial_bounds_.IsEmpty()); |
| 1059 | 1062 |
| 1060 // Register close window accelerators. | 1063 // Register close window accelerators. |
| 1061 views::FocusManager* focus_manager = widget_->GetFocusManager(); | 1064 views::FocusManager* focus_manager = widget_->GetFocusManager(); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 shadow_overlay_->layer()->Add(shadow->layer()); | 1402 shadow_overlay_->layer()->Add(shadow->layer()); |
| 1400 window->AddChild(shadow_overlay_); | 1403 window->AddChild(shadow_overlay_); |
| 1401 shadow_overlay_->Show(); | 1404 shadow_overlay_->Show(); |
| 1402 } | 1405 } |
| 1403 shadow_overlay_->SetBounds(shadow_bounds); | 1406 shadow_overlay_->SetBounds(shadow_bounds); |
| 1404 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1407 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
| 1405 } | 1408 } |
| 1406 } | 1409 } |
| 1407 | 1410 |
| 1408 } // namespace exo | 1411 } // namespace exo |
| OLD | NEW |