| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ |
| 6 #define ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/shelf/shelf_layout_manager_observer.h" | 9 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 10 #include "ash/shell_observer.h" | 10 #include "ash/shell_observer.h" |
| 11 #include "ash/wm/dock/dock_types.h" | 11 #include "ash/wm/dock/dock_types.h" |
| 12 #include "ash/wm/dock/docked_window_layout_manager_observer.h" | 12 #include "ash/wm/dock/docked_window_layout_manager_observer.h" |
| 13 #include "ash/wm/window_state_observer.h" | 13 #include "ash/wm/window_state_observer.h" |
| 14 #include "ash/wm/workspace/snap_types.h" | 14 #include "ash/wm/workspace/snap_types.h" |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "base/time/time.h" |
| 20 #include "ui/aura/client/activation_change_observer.h" | 21 #include "ui/aura/client/activation_change_observer.h" |
| 21 #include "ui/aura/layout_manager.h" | 22 #include "ui/aura/layout_manager.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
| 24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 25 #include "ui/keyboard/keyboard_controller_observer.h" | 26 #include "ui/keyboard/keyboard_controller_observer.h" |
| 26 | 27 |
| 27 namespace aura { | 28 namespace aura { |
| 28 class Window; | 29 class Window; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace gfx { | 32 namespace gfx { |
| 32 class Point; | 33 class Point; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace views { | 36 namespace views { |
| 36 class Widget; | 37 class Widget; |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace ash { | 40 namespace ash { |
| 40 class Launcher; | 41 class Launcher; |
| 41 | 42 |
| 42 namespace internal { | 43 namespace internal { |
| 43 class DockedWindowLayoutManagerObserver; | 44 class DockedWindowLayoutManagerObserver; |
| 44 class DockedWindowResizerTest; | 45 class DockedWindowResizerTest; |
| 45 class ShelfLayoutManager; | 46 class ShelfLayoutManager; |
| 46 class WorkspaceController; | 47 class WorkspaceController; |
| 47 | 48 |
| 49 // User action recorded for use in UMA histograms. |
| 50 enum DockedAction { |
| 51 DOCKED_ACTION_NONE, // Regular drag of undocked window. Not recorded. |
| 52 DOCKED_ACTION_DOCK, // Dragged and docked a window. |
| 53 DOCKED_ACTION_UNDOCK, // Dragged and undocked a window. |
| 54 DOCKED_ACTION_RESIZE, // Resized a docked window. |
| 55 DOCKED_ACTION_REORDER, // Possibly reordered docked windows. |
| 56 DOCKED_ACTION_EVICT, // A docked window could not stay docked. |
| 57 DOCKED_ACTION_MAXIMIZE, // Maximized a docked window. |
| 58 DOCKED_ACTION_MINIMIZE, // Minimized a docked window. |
| 59 DOCKED_ACTION_RESTORE, // Restored a docked window that was minimized. |
| 60 DOCKED_ACTION_CLOSE, // Closed a window while it was docked. |
| 61 DOCKED_ACTION_COUNT, // Maximum value of this enum for histograms use. |
| 62 }; |
| 63 |
| 64 // Event source for the docking user action (when known). |
| 65 enum DockedActionSource { |
| 66 DOCKED_ACTION_SOURCE_UNKNOWN, |
| 67 DOCKED_ACTION_SOURCE_MOUSE, |
| 68 DOCKED_ACTION_SOURCE_TOUCH, |
| 69 |
| 70 // Maximum value of this enum for histograms use. |
| 71 DOCKED_ACTION_SOURCE_COUNT, |
| 72 }; |
| 73 |
| 48 struct WindowWithHeight { | 74 struct WindowWithHeight { |
| 49 explicit WindowWithHeight(aura::Window* window) : | 75 explicit WindowWithHeight(aura::Window* window) : |
| 50 window_(window), | 76 window_(window), |
| 51 height_(window->bounds().height()) { } | 77 height_(window->bounds().height()) { } |
| 52 aura::Window* window() { return window_; } | 78 aura::Window* window() { return window_; } |
| 53 const aura::Window* window() const { return window_; } | 79 const aura::Window* window() const { return window_; } |
| 54 aura::Window* window_; | 80 aura::Window* window_; |
| 55 int height_; | 81 int height_; |
| 56 }; | 82 }; |
| 57 | 83 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void StartDragging(aura::Window* window); | 123 void StartDragging(aura::Window* window); |
| 98 | 124 |
| 99 // Called by a DockedWindowResizer when a dragged window is docked. | 125 // Called by a DockedWindowResizer when a dragged window is docked. |
| 100 void DockDraggedWindow(aura::Window* window); | 126 void DockDraggedWindow(aura::Window* window); |
| 101 | 127 |
| 102 // Called by a DockedWindowResizer when a dragged window is no longer docked. | 128 // Called by a DockedWindowResizer when a dragged window is no longer docked. |
| 103 void UndockDraggedWindow(); | 129 void UndockDraggedWindow(); |
| 104 | 130 |
| 105 // Called by a DockedWindowResizer when a window is no longer being dragged. | 131 // Called by a DockedWindowResizer when a window is no longer being dragged. |
| 106 // Stops observing the window unless it is a child. | 132 // Stops observing the window unless it is a child. |
| 107 void FinishDragging(); | 133 // Records |action| by |source| in UMA. |
| 134 void FinishDragging(DockedAction action, DockedActionSource source); |
| 108 | 135 |
| 109 ash::Launcher* launcher() { return launcher_; } | 136 ash::Launcher* launcher() { return launcher_; } |
| 110 void SetLauncher(ash::Launcher* launcher); | 137 void SetLauncher(ash::Launcher* launcher); |
| 111 | 138 |
| 112 // Calculates if a window is touching the screen edges and returns edge. | 139 // Calculates if a window is touching the screen edges and returns edge. |
| 113 DockedAlignment GetAlignmentOfWindow(const aura::Window* window) const; | 140 DockedAlignment GetAlignmentOfWindow(const aura::Window* window) const; |
| 114 | 141 |
| 115 // Used to snap docked windows to the side of screen during drag. | 142 // Used to snap docked windows to the side of screen during drag. |
| 116 DockedAlignment CalculateAlignment() const; | 143 DockedAlignment CalculateAlignment() const; |
| 117 | 144 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 static const int kIdealWidth; | 200 static const int kIdealWidth; |
| 174 | 201 |
| 175 // Keep at most kMaxVisibleWindows visible in the dock and minimize the rest | 202 // Keep at most kMaxVisibleWindows visible in the dock and minimize the rest |
| 176 // (except for |child|). | 203 // (except for |child|). |
| 177 void MaybeMinimizeChildrenExcept(aura::Window* child); | 204 void MaybeMinimizeChildrenExcept(aura::Window* child); |
| 178 | 205 |
| 179 // Minimize / restore window and relayout. | 206 // Minimize / restore window and relayout. |
| 180 void MinimizeDockedWindow(wm::WindowState* window_state); | 207 void MinimizeDockedWindow(wm::WindowState* window_state); |
| 181 void RestoreDockedWindow(wm::WindowState* window_state); | 208 void RestoreDockedWindow(wm::WindowState* window_state); |
| 182 | 209 |
| 210 // Record user-initiated |action| by |source| in UMA metrics. |
| 211 void RecordUmaAction(DockedAction action, DockedActionSource source); |
| 212 |
| 213 // Updates |docked_width_| and UMA histograms. |
| 214 void UpdateDockedWidth(int width); |
| 215 |
| 183 // Updates docked layout state when a window gets inside the dock. | 216 // Updates docked layout state when a window gets inside the dock. |
| 184 void OnDraggedWindowDocked(aura::Window* window); | 217 void OnDraggedWindowDocked(aura::Window* window); |
| 185 | 218 |
| 186 // Updates docked layout state when a window gets outside the dock. | 219 // Updates docked layout state when a window gets outside the dock. |
| 187 void OnDraggedWindowUndocked(); | 220 void OnDraggedWindowUndocked(); |
| 188 | 221 |
| 189 // Returns true if there are any windows currently docked. | 222 // Returns true if there are any windows currently docked. |
| 190 bool IsAnyWindowDocked(); | 223 bool IsAnyWindowDocked(); |
| 191 | 224 |
| 192 // Called whenever the window layout might change. | 225 // Called whenever the window layout might change. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Target bounds of a docked window being dragged. | 293 // Target bounds of a docked window being dragged. |
| 261 gfx::Rect dragged_bounds_; | 294 gfx::Rect dragged_bounds_; |
| 262 | 295 |
| 263 // Side of the screen that the dock is positioned at. | 296 // Side of the screen that the dock is positioned at. |
| 264 DockedAlignment alignment_; | 297 DockedAlignment alignment_; |
| 265 | 298 |
| 266 // The last active window. Used to maintain stacking order even if no windows | 299 // The last active window. Used to maintain stacking order even if no windows |
| 267 // are currently focused. | 300 // are currently focused. |
| 268 aura::Window* last_active_window_; | 301 aura::Window* last_active_window_; |
| 269 | 302 |
| 303 // Timestamp of the last user-initiated action that changed docked state. |
| 304 // Used in UMA metrics. |
| 305 base::Time last_action_time_; |
| 306 |
| 270 // Widget used to paint a background for the docked area. | 307 // Widget used to paint a background for the docked area. |
| 271 scoped_ptr<views::Widget> background_widget_; | 308 scoped_ptr<views::Widget> background_widget_; |
| 272 | 309 |
| 273 // Observers of dock bounds changes. | 310 // Observers of dock bounds changes. |
| 274 ObserverList<DockedWindowLayoutManagerObserver> observer_list_; | 311 ObserverList<DockedWindowLayoutManagerObserver> observer_list_; |
| 275 | 312 |
| 276 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManager); | 313 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManager); |
| 277 }; | 314 }; |
| 278 | 315 |
| 279 } // namespace internal | 316 } // namespace internal |
| 280 } // namespace ash | 317 } // namespace ash |
| 281 | 318 |
| 282 #endif // ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ | 319 #endif // ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ |
| OLD | NEW |