| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_MANAGER_H_ | |
| 6 #define ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_MANAGER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <map> | |
| 11 #include <unordered_set> | |
| 12 | |
| 13 #include "ash/ash_export.h" | |
| 14 #include "ash/shell_observer.h" | |
| 15 #include "ash/wm/window_state.h" | |
| 16 #include "base/macros.h" | |
| 17 #include "ui/aura/window_observer.h" | |
| 18 #include "ui/display/display_observer.h" | |
| 19 | |
| 20 namespace aura { | |
| 21 class Window; | |
| 22 } | |
| 23 | |
| 24 namespace ash { | |
| 25 class TabletModeController; | |
| 26 class TabletModeWindowState; | |
| 27 | |
| 28 namespace wm { | |
| 29 class TabletModeEventHandler; | |
| 30 } | |
| 31 | |
| 32 // A window manager which - when created - will force all windows into tablet | |
| 33 // mode. Exception are panels and windows which cannot be maximized. | |
| 34 // Windows which cannot be maximized / resized are centered with a layer placed | |
| 35 // behind the window so that no other windows are visible and/or obscured. | |
| 36 // With the destruction of the manager all windows will be restored to their | |
| 37 // original state. | |
| 38 class ASH_EXPORT TabletModeWindowManager : public aura::WindowObserver, | |
| 39 public display::DisplayObserver, | |
| 40 public ShellObserver { | |
| 41 public: | |
| 42 // This should only be deleted by the creator (ash::Shell). | |
| 43 ~TabletModeWindowManager() override; | |
| 44 | |
| 45 // Returns the number of maximized & tracked windows by this manager. | |
| 46 int GetNumberOfManagedWindows(); | |
| 47 | |
| 48 // Adds a window which needs to be maximized. This is used by other window | |
| 49 // managers for windows which needs to get tracked due to (upcoming) state | |
| 50 // changes. | |
| 51 // The call gets ignored if the window was already or should not be handled. | |
| 52 void AddWindow(aura::Window* window); | |
| 53 | |
| 54 // Called from a window state object when it gets destroyed. | |
| 55 void WindowStateDestroyed(aura::Window* window); | |
| 56 | |
| 57 // ShellObserver overrides: | |
| 58 void OnOverviewModeStarting() override; | |
| 59 void OnOverviewModeEnded() override; | |
| 60 | |
| 61 // Overridden from WindowObserver: | |
| 62 void OnWindowDestroying(aura::Window* window) override; | |
| 63 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; | |
| 64 void OnWindowPropertyChanged(aura::Window* window, | |
| 65 const void* key, | |
| 66 intptr_t old) override; | |
| 67 void OnWindowBoundsChanged(aura::Window* window, | |
| 68 const gfx::Rect& old_bounds, | |
| 69 const gfx::Rect& new_bounds) override; | |
| 70 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | |
| 71 | |
| 72 // display::DisplayObserver overrides: | |
| 73 void OnDisplayAdded(const display::Display& display) override; | |
| 74 void OnDisplayRemoved(const display::Display& display) override; | |
| 75 void OnDisplayMetricsChanged(const display::Display& display, | |
| 76 uint32_t metrics) override; | |
| 77 | |
| 78 // Tell all managing windows not to handle WM events. | |
| 79 void SetIgnoreWmEventsForExit(); | |
| 80 | |
| 81 protected: | |
| 82 friend class TabletModeController; | |
| 83 | |
| 84 // The object should only be created by the ash::Shell. | |
| 85 TabletModeWindowManager(); | |
| 86 | |
| 87 private: | |
| 88 using WindowToState = std::map<aura::Window*, TabletModeWindowState*>; | |
| 89 | |
| 90 // Maximize all windows and restore their current state. | |
| 91 void MaximizeAllWindows(); | |
| 92 | |
| 93 // Restore all windows to their previous state. | |
| 94 void RestoreAllWindows(); | |
| 95 | |
| 96 // Set whether to defer bounds updates on all tracked windows. When set to | |
| 97 // false bounds will be updated as they may be stale. | |
| 98 void SetDeferBoundsUpdates(bool defer_bounds_updates); | |
| 99 | |
| 100 // If the given window should be handled by us, this function will maximize it | |
| 101 // and add it to the list of known windows (remembering the initial show | |
| 102 // state). | |
| 103 // Note: If the given window cannot be handled by us the function will return | |
| 104 // immediately. | |
| 105 void MaximizeAndTrackWindow(aura::Window* window); | |
| 106 | |
| 107 // Remove a window from our tracking list. | |
| 108 void ForgetWindow(aura::Window* window); | |
| 109 | |
| 110 // Returns true when the given window should be modified in any way by us. | |
| 111 bool ShouldHandleWindow(aura::Window* window); | |
| 112 | |
| 113 // Add window creation observers to track creation of new windows. | |
| 114 void AddWindowCreationObservers(); | |
| 115 | |
| 116 // Remove Window creation observers. | |
| 117 void RemoveWindowCreationObservers(); | |
| 118 | |
| 119 // Change the internal state (e.g. observers) when the display configuration | |
| 120 // changes. | |
| 121 void DisplayConfigurationChanged(); | |
| 122 | |
| 123 // Returns true when the |window| is a container window. | |
| 124 bool IsContainerWindow(aura::Window* window); | |
| 125 | |
| 126 // Add a backdrop behind the currently active window on each desktop. | |
| 127 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable); | |
| 128 | |
| 129 // Every window which got touched by our window manager gets added here. | |
| 130 WindowToState window_state_map_; | |
| 131 | |
| 132 // All container windows which have to be tracked. | |
| 133 std::unordered_set<aura::Window*> observed_container_windows_; | |
| 134 | |
| 135 // Windows added to the container, but not yet shown. | |
| 136 std::unordered_set<aura::Window*> added_windows_; | |
| 137 | |
| 138 std::unique_ptr<wm::TabletModeEventHandler> event_handler_; | |
| 139 | |
| 140 DISALLOW_COPY_AND_ASSIGN(TabletModeWindowManager); | |
| 141 }; | |
| 142 | |
| 143 } // namespace ash | |
| 144 | |
| 145 #endif // ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_MANAGER_H_ | |
| OLD | NEW |