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