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/shell.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" |
22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
23 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
24 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
25 #include "ui/aura/window_targeter.h" | 26 #include "ui/aura/window_targeter.h" |
26 #include "ui/aura/window_tree_host.h" | 27 #include "ui/aura/window_tree_host.h" |
27 #include "ui/base/accelerators/accelerator.h" | 28 #include "ui/base/accelerators/accelerator.h" |
28 #include "ui/gfx/path.h" | 29 #include "ui/gfx/path.h" |
29 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
31 #include "ui/views/widget/widget_observer.h" | |
30 #include "ui/wm/core/shadow.h" | 32 #include "ui/wm/core/shadow.h" |
31 #include "ui/wm/core/shadow_controller.h" | 33 #include "ui/wm/core/shadow_controller.h" |
32 #include "ui/wm/core/shadow_types.h" | 34 #include "ui/wm/core/shadow_types.h" |
33 #include "ui/wm/core/window_util.h" | 35 #include "ui/wm/core/window_util.h" |
34 #include "ui/wm/public/activation_client.h" | 36 #include "ui/wm/public/activation_client.h" |
35 | 37 |
36 DECLARE_WINDOW_PROPERTY_TYPE(std::string*) | 38 DECLARE_WINDOW_PROPERTY_TYPE(std::string*) |
37 | 39 |
38 namespace exo { | 40 namespace exo { |
39 namespace { | 41 namespace { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 &local_point); | 93 &local_point); |
92 | 94 |
93 aura::Window::ConvertPointToTarget(window, surface->window(), &local_point); | 95 aura::Window::ConvertPointToTarget(window, surface->window(), &local_point); |
94 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); | 96 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); |
95 } | 97 } |
96 | 98 |
97 private: | 99 private: |
98 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); | 100 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); |
99 }; | 101 }; |
100 | 102 |
103 // Handles a user's fullscreen request (Shift+F4/F4). | |
104 class CustomWindowStateDelegate : public ash::wm::WindowStateDelegate, | |
105 public views::WidgetObserver { | |
106 public: | |
107 explicit CustomWindowStateDelegate(views::Widget* widget) : widget_(widget) { | |
108 widget_->AddObserver(this); | |
109 } | |
110 ~CustomWindowStateDelegate() override { | |
111 if (widget_) | |
112 widget_->RemoveObserver(this); | |
113 } | |
114 | |
115 // Overridden from ash::wm::WindowStateDelegate: | |
oshima
2016/07/22 19:50:56
nit: // ash::wm::WindowStateDelegate:
reveman
2016/07/22 19:59:16
as discussed, I'll change the style for all exo/ c
| |
116 bool ToggleFullscreen(ash::wm::WindowState* window_state) override { | |
117 if (widget_) { | |
118 bool enter_fullscreen = !window_state->IsFullscreen(); | |
119 widget_->SetFullscreen(enter_fullscreen); | |
120 } | |
121 return true; | |
122 } | |
123 | |
124 // Overridden from views::WidgetObserver: | |
oshima
2016/07/22 19:50:56
ditto
reveman
2016/07/22 19:59:16
ditto
| |
125 void OnWidgetDestroying(views::Widget* widget) override { | |
126 widget_->RemoveObserver(this); | |
127 widget_ = nullptr; | |
128 } | |
129 | |
130 private: | |
131 views::Widget* widget_; | |
132 | |
133 DISALLOW_COPY_AND_ASSIGN(CustomWindowStateDelegate); | |
134 }; | |
135 | |
101 class ShellSurfaceWidget : public views::Widget { | 136 class ShellSurfaceWidget : public views::Widget { |
102 public: | 137 public: |
103 explicit ShellSurfaceWidget(ShellSurface* shell_surface) | 138 explicit ShellSurfaceWidget(ShellSurface* shell_surface) |
104 : shell_surface_(shell_surface) {} | 139 : shell_surface_(shell_surface) {} |
105 | 140 |
106 // Overridden from views::Widget | 141 // Overridden from views::Widget |
107 void Close() override { shell_surface_->Close(); } | 142 void Close() override { shell_surface_->Close(); } |
108 void OnKeyEvent(ui::KeyEvent* event) override { | 143 void OnKeyEvent(ui::KeyEvent* event) override { |
109 // TODO(hidehiko): Handle ESC + SHIFT + COMMAND accelerator key | 144 // TODO(hidehiko): Handle ESC + SHIFT + COMMAND accelerator key |
110 // to escape pinned mode. | 145 // to escape pinned mode. |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 initial_bounds_.IsEmpty()); | 936 initial_bounds_.IsEmpty()); |
902 | 937 |
903 // Register close window accelerators. | 938 // Register close window accelerators. |
904 views::FocusManager* focus_manager = widget_->GetFocusManager(); | 939 views::FocusManager* focus_manager = widget_->GetFocusManager(); |
905 for (const auto& entry : kCloseWindowAccelerators) { | 940 for (const auto& entry : kCloseWindowAccelerators) { |
906 focus_manager->RegisterAccelerator( | 941 focus_manager->RegisterAccelerator( |
907 ui::Accelerator(entry.keycode, entry.modifiers), | 942 ui::Accelerator(entry.keycode, entry.modifiers), |
908 ui::AcceleratorManager::kNormalPriority, this); | 943 ui::AcceleratorManager::kNormalPriority, this); |
909 } | 944 } |
910 | 945 |
946 // Set delegate for handling of fullscreening. | |
947 window_state->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>( | |
948 new CustomWindowStateDelegate(widget_))); | |
949 | |
911 // Show widget next time Commit() is called. | 950 // Show widget next time Commit() is called. |
912 pending_show_widget_ = true; | 951 pending_show_widget_ = true; |
913 } | 952 } |
914 | 953 |
915 void ShellSurface::Configure() { | 954 void ShellSurface::Configure() { |
916 DCHECK(widget_); | 955 DCHECK(widget_); |
917 | 956 |
918 // Delay configure callback if |scoped_configure_| is set. | 957 // Delay configure callback if |scoped_configure_| is set. |
919 if (scoped_configure_) { | 958 if (scoped_configure_) { |
920 scoped_configure_->set_needs_configure(); | 959 scoped_configure_->set_needs_configure(); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 shadow_origin -= origin.OffsetFromOrigin(); | 1224 shadow_origin -= origin.OffsetFromOrigin(); |
1186 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size()); | 1225 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size()); |
1187 | 1226 |
1188 shadow_overlay_->SetBounds(shadow_bounds); | 1227 shadow_overlay_->SetBounds(shadow_bounds); |
1189 shadow_underlay_->SetBounds(shadow_bounds); | 1228 shadow_underlay_->SetBounds(shadow_bounds); |
1190 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1229 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
1191 } | 1230 } |
1192 } | 1231 } |
1193 | 1232 |
1194 } // namespace exo | 1233 } // namespace exo |
OLD | NEW |