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 "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/shell_window_ids.h" | 8 #include "ash/common/shell_window_ids.h" |
9 #include "ash/common/wm/window_resizer.h" | 9 #include "ash/common/wm/window_resizer.h" |
10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // This is a struct for accelerator keys used to close ShellSurfaces. | 44 // This is a struct for accelerator keys used to close ShellSurfaces. |
45 const struct Accelerator { | 45 const struct Accelerator { |
46 ui::KeyboardCode keycode; | 46 ui::KeyboardCode keycode; |
47 int modifiers; | 47 int modifiers; |
48 } kCloseWindowAccelerators[] = { | 48 } kCloseWindowAccelerators[] = { |
49 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, | 49 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, |
50 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, | 50 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, |
51 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; | 51 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; |
52 | 52 |
53 void UpdateShelfStateForFullscreenChange(views::Widget* widget) { | |
54 ash::wm::WindowState* window_state = | |
55 ash::wm::GetWindowState(widget->GetNativeWindow()); | |
56 window_state->set_shelf_mode_in_fullscreen( | |
57 ash::wm::WindowState::SHELF_AUTO_HIDE_INVISIBLE); | |
58 ash::Shell::GetInstance()->UpdateShelfVisibility(); | |
59 } | |
60 | |
61 class CustomFrameView : public views::NonClientFrameView { | 53 class CustomFrameView : public views::NonClientFrameView { |
62 public: | 54 public: |
63 explicit CustomFrameView(views::Widget* widget) : widget_(widget) {} | 55 explicit CustomFrameView(views::Widget* widget) : widget_(widget) {} |
64 ~CustomFrameView() override {} | 56 ~CustomFrameView() override {} |
65 | 57 |
66 // Overridden from views::NonClientFrameView: | 58 // Overridden from views::NonClientFrameView: |
67 gfx::Rect GetBoundsForClientView() const override { return bounds(); } | 59 gfx::Rect GetBoundsForClientView() const override { return bounds(); } |
68 gfx::Rect GetWindowBoundsForClientBounds( | 60 gfx::Rect GetWindowBoundsForClientBounds( |
69 const gfx::Rect& client_bounds) const override { | 61 const gfx::Rect& client_bounds) const override { |
70 return client_bounds; | 62 return client_bounds; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 ~CustomWindowStateDelegate() override { | 111 ~CustomWindowStateDelegate() override { |
120 if (widget_) | 112 if (widget_) |
121 widget_->RemoveObserver(this); | 113 widget_->RemoveObserver(this); |
122 } | 114 } |
123 | 115 |
124 // Overridden from ash::wm::WindowStateDelegate: | 116 // Overridden from ash::wm::WindowStateDelegate: |
125 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { | 117 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { |
126 if (widget_) { | 118 if (widget_) { |
127 bool enter_fullscreen = !window_state->IsFullscreen(); | 119 bool enter_fullscreen = !window_state->IsFullscreen(); |
128 widget_->SetFullscreen(enter_fullscreen); | 120 widget_->SetFullscreen(enter_fullscreen); |
129 UpdateShelfStateForFullscreenChange(widget_); | |
130 } | 121 } |
131 return true; | 122 return true; |
132 } | 123 } |
133 | 124 |
134 // Overridden from views::WidgetObserver: | 125 // Overridden from views::WidgetObserver: |
135 void OnWidgetDestroying(views::Widget* widget) override { | 126 void OnWidgetDestroying(views::Widget* widget) override { |
136 widget_->RemoveObserver(this); | 127 widget_->RemoveObserver(this); |
137 widget_ = nullptr; | 128 widget_ = nullptr; |
138 } | 129 } |
139 | 130 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 void ShellSurface::SetFullscreen(bool fullscreen) { | 383 void ShellSurface::SetFullscreen(bool fullscreen) { |
393 TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen); | 384 TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen); |
394 | 385 |
395 if (!widget_) | 386 if (!widget_) |
396 CreateShellSurfaceWidget(ui::SHOW_STATE_FULLSCREEN); | 387 CreateShellSurfaceWidget(ui::SHOW_STATE_FULLSCREEN); |
397 | 388 |
398 // Note: This will ask client to configure its surface even if fullscreen | 389 // Note: This will ask client to configure its surface even if fullscreen |
399 // state doesn't change. | 390 // state doesn't change. |
400 ScopedConfigure scoped_configure(this, true); | 391 ScopedConfigure scoped_configure(this, true); |
401 widget_->SetFullscreen(fullscreen); | 392 widget_->SetFullscreen(fullscreen); |
402 UpdateShelfStateForFullscreenChange(widget_); | |
403 } | 393 } |
404 | 394 |
405 void ShellSurface::SetPinned(bool pinned) { | 395 void ShellSurface::SetPinned(bool pinned) { |
406 TRACE_EVENT1("exo", "ShellSurface::SetPinned", "pinned", pinned); | 396 TRACE_EVENT1("exo", "ShellSurface::SetPinned", "pinned", pinned); |
407 | 397 |
408 if (!widget_) | 398 if (!widget_) |
409 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL); | 399 CreateShellSurfaceWidget(ui::SHOW_STATE_NORMAL); |
410 | 400 |
411 // Note: This will ask client to configure its surface even if pinned | 401 // Note: This will ask client to configure its surface even if pinned |
412 // state doesn't change. | 402 // state doesn't change. |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 shadow_overlay_->layer()->Add(shadow->layer()); | 1259 shadow_overlay_->layer()->Add(shadow->layer()); |
1270 window->AddChild(shadow_overlay_); | 1260 window->AddChild(shadow_overlay_); |
1271 shadow_overlay_->Show(); | 1261 shadow_overlay_->Show(); |
1272 } | 1262 } |
1273 shadow_overlay_->SetBounds(shadow_bounds); | 1263 shadow_overlay_->SetBounds(shadow_bounds); |
1274 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1264 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
1275 } | 1265 } |
1276 } | 1266 } |
1277 | 1267 |
1278 } // namespace exo | 1268 } // namespace exo |
OLD | NEW |