Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: components/exo/shell_surface.cc

Issue 2679403003: exo: ShellSurface: Remove the CustomWindowStateDelegate (Closed)
Patch Set: Fix review issue Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/frame/custom_frame_view_ash.h" 9 #include "ash/common/frame/custom_frame_view_ash.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/wm/window_resizer.h" 11 #include "ash/common/wm/window_resizer.h"
12 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm/window_state_delegate.h"
14 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
15 #include "ash/public/cpp/shell_window_ids.h" 14 #include "ash/public/cpp/shell_window_ids.h"
16 #include "ash/wm/window_state_aura.h" 15 #include "ash/wm/window_state_aura.h"
17 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
18 #include "base/logging.h" 17 #include "base/logging.h"
19 #include "base/macros.h" 18 #include "base/macros.h"
20 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
21 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
22 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
23 #include "base/trace_event/trace_event_argument.h" 22 #include "base/trace_event/trace_event_argument.h"
24 #include "components/exo/surface.h" 23 #include "components/exo/surface.h"
25 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/client/cursor_client.h" 25 #include "ui/aura/client/cursor_client.h"
27 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
28 #include "ui/aura/window_event_dispatcher.h" 27 #include "ui/aura/window_event_dispatcher.h"
29 #include "ui/aura/window_targeter.h" 28 #include "ui/aura/window_targeter.h"
30 #include "ui/aura/window_tree_host.h" 29 #include "ui/aura/window_tree_host.h"
31 #include "ui/base/accelerators/accelerator.h" 30 #include "ui/base/accelerators/accelerator.h"
32 #include "ui/base/class_property.h" 31 #include "ui/base/class_property.h"
33 #include "ui/gfx/path.h" 32 #include "ui/gfx/path.h"
34 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
35 #include "ui/views/widget/widget_observer.h"
36 #include "ui/wm/core/coordinate_conversion.h" 34 #include "ui/wm/core/coordinate_conversion.h"
37 #include "ui/wm/core/shadow.h" 35 #include "ui/wm/core/shadow.h"
38 #include "ui/wm/core/shadow_controller.h" 36 #include "ui/wm/core/shadow_controller.h"
39 #include "ui/wm/core/shadow_types.h" 37 #include "ui/wm/core/shadow_types.h"
40 #include "ui/wm/core/window_animations.h" 38 #include "ui/wm/core/window_animations.h"
41 #include "ui/wm/core/window_util.h" 39 #include "ui/wm/core/window_util.h"
42 40
43 #if defined(OS_CHROMEOS) 41 #if defined(OS_CHROMEOS)
44 #include "chromeos/audio/chromeos_sounds.h" 42 #include "chromeos/audio/chromeos_sounds.h"
45 #endif 43 #endif
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 136 }
139 return aura::WindowTargeter::FindTargetForEvent(root, event); 137 return aura::WindowTargeter::FindTargetForEvent(root, event);
140 } 138 }
141 139
142 private: 140 private:
143 views::Widget* const widget_; 141 views::Widget* const widget_;
144 142
145 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); 143 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
146 }; 144 };
147 145
148 // Handles a user's fullscreen request (Shift+F4/F4).
149 class CustomWindowStateDelegate : public ash::wm::WindowStateDelegate,
150 public views::WidgetObserver {
151 public:
152 explicit CustomWindowStateDelegate(views::Widget* widget) : widget_(widget) {
153 widget_->AddObserver(this);
154 }
155 ~CustomWindowStateDelegate() override {
156 if (widget_)
157 widget_->RemoveObserver(this);
158 }
159
160 // Overridden from ash::wm::WindowStateDelegate:
161 bool ToggleFullscreen(ash::wm::WindowState* window_state) override {
162 if (widget_) {
163 bool enter_fullscreen = !window_state->IsFullscreen();
164 widget_->SetFullscreen(enter_fullscreen);
165 ash::wm::WindowState* window_state =
166 ash::wm::GetWindowState(widget_->GetNativeWindow());
167 window_state->set_in_immersive_fullscreen(enter_fullscreen);
168 }
169 return true;
170 }
171
172 // Overridden from views::WidgetObserver:
173 void OnWidgetDestroying(views::Widget* widget) override {
174 widget_->RemoveObserver(this);
175 widget_ = nullptr;
176 }
177
178 private:
179 views::Widget* widget_;
180
181 DISALLOW_COPY_AND_ASSIGN(CustomWindowStateDelegate);
182 };
183
184 class ShellSurfaceWidget : public views::Widget { 146 class ShellSurfaceWidget : public views::Widget {
185 public: 147 public:
186 explicit ShellSurfaceWidget(ShellSurface* shell_surface) 148 explicit ShellSurfaceWidget(ShellSurface* shell_surface)
187 : shell_surface_(shell_surface) {} 149 : shell_surface_(shell_surface) {}
188 150
189 // Overridden from views::Widget 151 // Overridden from views::Widget
190 void Close() override { shell_surface_->Close(); } 152 void Close() override { shell_surface_->Close(); }
191 void OnKeyEvent(ui::KeyEvent* event) override { 153 void OnKeyEvent(ui::KeyEvent* event) override {
192 // TODO(hidehiko): Handle ESC + SHIFT + COMMAND accelerator key 154 // TODO(hidehiko): Handle ESC + SHIFT + COMMAND accelerator key
193 // to escape pinned mode. 155 // to escape pinned mode.
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return widget_; 798 return widget_;
837 } 799 }
838 800
839 views::View* ShellSurface::GetContentsView() { 801 views::View* ShellSurface::GetContentsView() {
840 return this; 802 return this;
841 } 803 }
842 804
843 views::NonClientFrameView* ShellSurface::CreateNonClientFrameView( 805 views::NonClientFrameView* ShellSurface::CreateNonClientFrameView(
844 views::Widget* widget) { 806 views::Widget* widget) {
845 aura::Window* window = widget_->GetNativeWindow(); 807 aura::Window* window = widget_->GetNativeWindow();
846 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); 808 // ShellSurfaces always use immersive mode.
847 // Set delegate for handling of fullscreening. 809 window->SetProperty(aura::client::kImmersiveFullscreenKey, true);
848 window_state->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>(
849 new CustomWindowStateDelegate(widget_)));
850
851 if (frame_enabled_) 810 if (frame_enabled_)
852 return new ash::CustomFrameViewAsh(widget); 811 return new ash::CustomFrameViewAsh(widget);
853 812
854 return new CustomFrameView(widget); 813 return new CustomFrameView(widget);
855 } 814 }
856 815
857 bool ShellSurface::WidgetHasHitTestMask() const { 816 bool ShellSurface::WidgetHasHitTestMask() const {
858 return surface_ ? surface_->HasHitTestMask() : false; 817 return surface_ ? surface_->HasHitTestMask() : false;
859 } 818 }
860 819
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 // small style shadow for them. 1502 // small style shadow for them.
1544 if (!activatable_) 1503 if (!activatable_)
1545 shadow->SetElevation(wm::ShadowElevation::SMALL); 1504 shadow->SetElevation(wm::ShadowElevation::SMALL);
1546 // We don't have rounded corners unless frame is enabled. 1505 // We don't have rounded corners unless frame is enabled.
1547 if (!frame_enabled_) 1506 if (!frame_enabled_)
1548 shadow->SetRoundedCornerRadius(0); 1507 shadow->SetRoundedCornerRadius(0);
1549 } 1508 }
1550 } 1509 }
1551 1510
1552 } // namespace exo 1511 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698