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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.h

Issue 23431009: Windows docking should get triggered by pressing against the screen edge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows docking by pressing against the screen edge (rebase) Created 7 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/property_util.h" 12 #include "ash/wm/property_util.h"
13 #include "ash/wm/workspace/snap_types.h"
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "ui/aura/client/activation_change_observer.h" 19 #include "ui/aura/client/activation_change_observer.h"
19 #include "ui/aura/layout_manager.h" 20 #include "ui/aura/layout_manager.h"
20 #include "ui/aura/window_observer.h" 21 #include "ui/aura/window_observer.h"
21 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
22 #include "ui/keyboard/keyboard_controller_observer.h" 23 #include "ui/keyboard/keyboard_controller_observer.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // TODO(varkha): extend BaseLayoutManager instead of LayoutManager to inherit 55 // TODO(varkha): extend BaseLayoutManager instead of LayoutManager to inherit
55 // common functionality. 56 // common functionality.
56 class ASH_EXPORT DockedWindowLayoutManager 57 class ASH_EXPORT DockedWindowLayoutManager
57 : public aura::LayoutManager, 58 : public aura::LayoutManager,
58 public ash::ShellObserver, 59 public ash::ShellObserver,
59 public aura::WindowObserver, 60 public aura::WindowObserver,
60 public aura::client::ActivationChangeObserver, 61 public aura::client::ActivationChangeObserver,
61 public keyboard::KeyboardControllerObserver, 62 public keyboard::KeyboardControllerObserver,
62 public ash::ShelfLayoutManagerObserver { 63 public ash::ShelfLayoutManagerObserver {
63 public: 64 public:
65 // Maximum width of the docked windows area.
66 static const int kMaxDockWidth;
67
64 explicit DockedWindowLayoutManager(aura::Window* dock_container); 68 explicit DockedWindowLayoutManager(aura::Window* dock_container);
65 virtual ~DockedWindowLayoutManager(); 69 virtual ~DockedWindowLayoutManager();
66 70
67 // Disconnects observers before container windows get destroyed. 71 // Disconnects observers before container windows get destroyed.
68 void Shutdown(); 72 void Shutdown();
69 73
70 // Management of the observer list. 74 // Management of the observer list.
71 virtual void AddObserver(DockedWindowLayoutManagerObserver* observer); 75 virtual void AddObserver(DockedWindowLayoutManagerObserver* observer);
72 virtual void RemoveObserver(DockedWindowLayoutManagerObserver* observer); 76 virtual void RemoveObserver(DockedWindowLayoutManagerObserver* observer);
73 77
(...skipping 13 matching lines...) Expand all
87 91
88 ash::Launcher* launcher() { return launcher_; } 92 ash::Launcher* launcher() { return launcher_; }
89 void SetLauncher(ash::Launcher* launcher); 93 void SetLauncher(ash::Launcher* launcher);
90 94
91 // Calculates if a window is touching the screen edges and returns edge. 95 // Calculates if a window is touching the screen edges and returns edge.
92 DockedAlignment GetAlignmentOfWindow(const aura::Window* window) const; 96 DockedAlignment GetAlignmentOfWindow(const aura::Window* window) const;
93 97
94 // Used to snap docked windows to the side of screen during drag. 98 // Used to snap docked windows to the side of screen during drag.
95 DockedAlignment CalculateAlignment() const; 99 DockedAlignment CalculateAlignment() const;
96 100
101 // Returns true when a window can be docked. Windows cannot be docked at the
102 // edge used by the launcher shelf or the edge opposite from existing dock.
103 bool CanDockWindow(aura::Window* window, SnapType edge);
104
97 aura::Window* dock_container() const { return dock_container_; } 105 aura::Window* dock_container() const { return dock_container_; }
98 106
99 // Returns current bounding rectangle of docked windows area. 107 // Returns current bounding rectangle of docked windows area.
100 const gfx::Rect& docked_bounds() const { return docked_bounds_; } 108 const gfx::Rect& docked_bounds() const { return docked_bounds_; }
101 109
102 // Returns last known coordinates of |dragged_window_| after Relayout. 110 // Returns last known coordinates of |dragged_window_| after Relayout.
103 const gfx::Rect dragged_bounds() const { return dragged_bounds_;} 111 const gfx::Rect dragged_bounds() const { return dragged_bounds_;}
104 112
113 // Returns true if currently dragged window is docked at the screen edge.
114 bool is_dragged_window_docked() const { return is_dragged_window_docked_; }
115
105 // aura::LayoutManager: 116 // aura::LayoutManager:
106 virtual void OnWindowResized() OVERRIDE; 117 virtual void OnWindowResized() OVERRIDE;
107 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; 118 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
108 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} 119 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
109 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; 120 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
110 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 121 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
111 bool visibile) OVERRIDE; 122 bool visibile) OVERRIDE;
112 virtual void SetChildBounds(aura::Window* child, 123 virtual void SetChildBounds(aura::Window* child,
113 const gfx::Rect& requested_bounds) OVERRIDE; 124 const gfx::Rect& requested_bounds) OVERRIDE;
114 125
(...skipping 19 matching lines...) Expand all
134 145
135 private: 146 private:
136 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, AttachTwoWindowsDetachOne); 147 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, AttachTwoWindowsDetachOne);
137 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, AttachWindowMaximizeOther); 148 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, AttachWindowMaximizeOther);
138 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, AttachOneTestSticky); 149 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, AttachOneTestSticky);
139 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, ResizeTwoWindows); 150 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, ResizeTwoWindows);
140 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, DragToShelf); 151 FRIEND_TEST_ALL_PREFIXES(DockedWindowResizerTest, DragToShelf);
141 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest, AutoPlacingLeft); 152 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest, AutoPlacingLeft);
142 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest, AutoPlacingRight); 153 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest, AutoPlacingRight);
143 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest, 154 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest,
144 AutoPlacingLeftSecondScreen);
145 FRIEND_TEST_ALL_PREFIXES(DockedWindowLayoutManagerTest,
146 AutoPlacingRightSecondScreen); 155 AutoPlacingRightSecondScreen);
147 friend class DockedWindowLayoutManagerTest; 156 friend class DockedWindowLayoutManagerTest;
148 friend class DockedWindowResizerTest; 157 friend class DockedWindowResizerTest;
149 158
150 // Minimum width of the docked windows area. 159 // Minimum width of the docked windows area.
151 static const int kMinDockWidth; 160 static const int kMinDockWidth;
152 161
153 // Maximum width of the docked windows area.
154 static const int kMaxDockWidth;
155
156 // Width of the gap between the docked windows and a workspace. 162 // Width of the gap between the docked windows and a workspace.
157 static const int kMinDockGap; 163 static const int kMinDockGap;
158 164
159 // Minimize / restore window and relayout. 165 // Minimize / restore window and relayout.
160 void MinimizeWindow(aura::Window* window); 166 void MinimizeWindow(aura::Window* window);
161 void RestoreWindow(aura::Window* window); 167 void RestoreWindow(aura::Window* window);
162 168
163 // Updates docked layout state when a window gets inside the dock. 169 // Updates docked layout state when a window gets inside the dock.
164 void OnWindowDocked(aura::Window* window); 170 void OnWindowDocked(aura::Window* window);
165 171
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Observers of dock bounds changes. 238 // Observers of dock bounds changes.
233 ObserverList<DockedWindowLayoutManagerObserver> observer_list_; 239 ObserverList<DockedWindowLayoutManagerObserver> observer_list_;
234 240
235 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManager); 241 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManager);
236 }; 242 };
237 243
238 } // namespace internal 244 } // namespace internal
239 } // namespace ash 245 } // namespace ash
240 246
241 #endif // ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ 247 #endif // ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/wm/dock/docked_window_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698