| Index: components/exo/shell_surface.cc
|
| diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
|
| index 9f3aaadd0097b18454bf31baeb7052db47771fae..06c277d2b644693846f47f9f7e80cee1a638d89e 100644
|
| --- a/components/exo/shell_surface.cc
|
| +++ b/components/exo/shell_surface.cc
|
| @@ -8,6 +8,7 @@
|
| #include "ash/common/shell_window_ids.h"
|
| #include "ash/common/wm/window_resizer.h"
|
| #include "ash/common/wm/window_state.h"
|
| +#include "ash/common/wm/window_state_delegate.h"
|
| #include "ash/shell.h"
|
| #include "ash/wm/window_state_aura.h"
|
| #include "ash/wm/window_util.h"
|
| @@ -27,6 +28,7 @@
|
| #include "ui/base/accelerators/accelerator.h"
|
| #include "ui/gfx/path.h"
|
| #include "ui/views/widget/widget.h"
|
| +#include "ui/views/widget/widget_observer.h"
|
| #include "ui/wm/core/shadow.h"
|
| #include "ui/wm/core/shadow_controller.h"
|
| #include "ui/wm/core/shadow_types.h"
|
| @@ -98,6 +100,39 @@ class CustomWindowTargeter : public aura::WindowTargeter {
|
| DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
|
| };
|
|
|
| +// Handles a user's fullscreen request (Shift+F4/F4).
|
| +class CustomWindowStateDelegate : public ash::wm::WindowStateDelegate,
|
| + public views::WidgetObserver {
|
| + public:
|
| + explicit CustomWindowStateDelegate(views::Widget* widget) : widget_(widget) {
|
| + widget_->AddObserver(this);
|
| + }
|
| + ~CustomWindowStateDelegate() override {
|
| + if (widget_)
|
| + widget_->RemoveObserver(this);
|
| + }
|
| +
|
| + // Overridden from ash::wm::WindowStateDelegate:
|
| + bool ToggleFullscreen(ash::wm::WindowState* window_state) override {
|
| + if (widget_) {
|
| + bool enter_fullscreen = !window_state->IsFullscreen();
|
| + widget_->SetFullscreen(enter_fullscreen);
|
| + }
|
| + return true;
|
| + }
|
| +
|
| + // Overridden from views::WidgetObserver:
|
| + void OnWidgetDestroying(views::Widget* widget) override {
|
| + widget_->RemoveObserver(this);
|
| + widget_ = nullptr;
|
| + }
|
| +
|
| + private:
|
| + views::Widget* widget_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CustomWindowStateDelegate);
|
| +};
|
| +
|
| class ShellSurfaceWidget : public views::Widget {
|
| public:
|
| explicit ShellSurfaceWidget(ShellSurface* shell_surface)
|
| @@ -908,6 +943,10 @@ void ShellSurface::CreateShellSurfaceWidget(ui::WindowShowState show_state) {
|
| ui::AcceleratorManager::kNormalPriority, this);
|
| }
|
|
|
| + // Set delegate for handling of fullscreening.
|
| + window_state->SetDelegate(std::unique_ptr<ash::wm::WindowStateDelegate>(
|
| + new CustomWindowStateDelegate(widget_)));
|
| +
|
| // Show widget next time Commit() is called.
|
| pending_show_widget_ = true;
|
| }
|
|
|