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

Unified Diff: components/exo/shell_surface.cc

Issue 2177623002: exo: Implement custom fullscreening for ShellSurfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
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
+ 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:
oshima 2016/07/22 19:50:56 ditto
reveman 2016/07/22 19:59:16 ditto
+ 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;
}
« no previous file with comments | « no previous file | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698