Chromium Code Reviews| 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/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 Loading... | |
| 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, | |
|
oshima
2017/02/09 00:37:01
I believe we still need this to go fullscreen usin
| |
| 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 return widget_; | 788 return widget_; |
| 827 } | 789 } |
| 828 | 790 |
| 829 views::View* ShellSurface::GetContentsView() { | 791 views::View* ShellSurface::GetContentsView() { |
| 830 return this; | 792 return this; |
| 831 } | 793 } |
| 832 | 794 |
| 833 views::NonClientFrameView* ShellSurface::CreateNonClientFrameView( | 795 views::NonClientFrameView* ShellSurface::CreateNonClientFrameView( |
| 834 views::Widget* widget) { | 796 views::Widget* widget) { |
| 835 aura::Window* window = widget_->GetNativeWindow(); | 797 aura::Window* window = widget_->GetNativeWindow(); |
| 836 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); | 798 window->SetProperty(aura::client::kImmersiveFullscreenKey, true); |
|
oshima
2017/02/09 19:38:59
Please add comment that we assume the exo windows
Peng
2017/02/10 16:03:57
Done.
| |
| 837 // Set delegate for handling of fullscreening. | |
| 838 window_state->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>( | |
| 839 new CustomWindowStateDelegate(widget_))); | |
| 840 | |
| 841 if (frame_enabled_) | 799 if (frame_enabled_) |
| 842 return new ash::CustomFrameViewAsh(widget); | 800 return new ash::CustomFrameViewAsh(widget); |
| 843 | 801 |
| 844 return new CustomFrameView(widget); | 802 return new CustomFrameView(widget); |
| 845 } | 803 } |
| 846 | 804 |
| 847 bool ShellSurface::WidgetHasHitTestMask() const { | 805 bool ShellSurface::WidgetHasHitTestMask() const { |
| 848 return surface_ ? surface_->HasHitTestMask() : false; | 806 return surface_ ? surface_->HasHitTestMask() : false; |
| 849 } | 807 } |
| 850 | 808 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 // small style shadow for them. | 1468 // small style shadow for them. |
| 1511 if (!activatable_) | 1469 if (!activatable_) |
| 1512 shadow->SetElevation(wm::ShadowElevation::SMALL); | 1470 shadow->SetElevation(wm::ShadowElevation::SMALL); |
| 1513 // We don't have rounded corners unless frame is enabled. | 1471 // We don't have rounded corners unless frame is enabled. |
| 1514 if (!frame_enabled_) | 1472 if (!frame_enabled_) |
| 1515 shadow->SetRoundedCornerRadius(0); | 1473 shadow->SetRoundedCornerRadius(0); |
| 1516 } | 1474 } |
| 1517 } | 1475 } |
| 1518 | 1476 |
| 1519 } // namespace exo | 1477 } // namespace exo |
| OLD | NEW |