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

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

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (small fix for shelf auto-hide) Created 7 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_
6 #define ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/shelf/shelf_layout_manager_observer.h"
10 #include "ash/shell_observer.h"
11 #include "ash/wm/dock/dock_types.h"
12 #include "ash/wm/property_util.h"
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "ui/aura/client/activation_change_observer.h"
16 #include "ui/aura/layout_manager.h"
17 #include "ui/aura/window_observer.h"
18 #include "ui/keyboard/keyboard_controller_observer.h"
19
20 namespace aura {
21 class Window;
22 }
23
24 namespace gfx {
25 class Point;
26 class Rect;
27 }
28
29 namespace ash {
30 class Launcher;
31
32 namespace internal {
33 class ShelfLayoutManager;
34
35 // DockedWindowLayoutManager is responsible for organizing windows when they are
36 // docked to the side of a screen. It is associated with a specific container
37 // window (i.e. kShellWindowId_DockContainer) and controls the layout of any
38 // windows added to that container.
39 //
40 // The constructor takes a |dock_container| argument which is expected to set
41 // its layout manager to this instance, e.g.:
42 // dock_container->SetLayoutManager(
43 // new DockedWindowLayoutManager(dock_container));
44
45 class ASH_EXPORT DockedWindowLayoutManager
46 : public aura::LayoutManager,
47 public ash::ShellObserver,
48 public aura::WindowObserver,
49 public aura::client::ActivationChangeObserver,
50 public keyboard::KeyboardControllerObserver,
51 public ash::ShelfLayoutManagerObserver {
52 public:
53 explicit DockedWindowLayoutManager(aura::Window* dock_container);
54 virtual ~DockedWindowLayoutManager();
55
56 // Called by a DockedWindowResizer to update which window is being dragged.
57 void StartDragging(aura::Window* window);
58 void FinishDragging();
59
60 // Returns true if a window is touching the side of the screen
61 // unless when other windows are already docked on the other side or
stevenjb 2013/06/13 17:54:41 nit: s/unless when/except when/
varkha 2013/06/13 20:19:14 Done.
62 // unless launcher (shelf) is aligned on the same side.
63 static bool ShouldWindowDock(aura::Window* window,
64 const gfx::Point& location);
65
66 ash::Launcher* launcher() { return launcher_; }
67 void SetLauncher(ash::Launcher* launcher);
68
69 // Used to snap docked windows to the side of screen during drag.
70 DockedAlignment alignment() const { return alignment_; }
71
72 // Currently dragged window should be able to dock on another screen
73 aura::Window* dragged_window() const { return dragged_window_;}
74
75 // aura::LayoutManager:
76 virtual void OnWindowResized() OVERRIDE;
77 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
78 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
79 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
80 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
81 bool visibile) OVERRIDE;
82 virtual void SetChildBounds(aura::Window* child,
83 const gfx::Rect& requested_bounds) OVERRIDE;
84
85 // ash::ShellObserver:
86 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE;
87
88 // aura::WindowObserver:
89 virtual void OnWindowPropertyChanged(aura::Window* window,
90 const void* key,
91 intptr_t old) OVERRIDE;
92
93 // aura::client::ActivationChangeObserver:
94 virtual void OnWindowActivated(aura::Window* gained_active,
95 aura::Window* lost_active) OVERRIDE;
96
97 // ShelfLayoutManagerObserver:
98 virtual void WillChangeVisibilityState(
99 ShelfVisibilityState new_state) OVERRIDE;
100
101 private:
102 friend class DockedWindowLayoutManagerTest;
103 friend class DockedWindowResizerTest;
104
105 // Minimize / restore window and relayout.
106 void MinimizeWindow(aura::Window* window);
107 void RestoreWindow(aura::Window* window);
108
109 // Called whenever the window layout might change.
110 void Relayout();
111
112 // Called whenever the window stacking order needs to be updated (e.g. focus
113 // changes or a window is moved).
114 void UpdateStacking(aura::Window* active_window);
115
116 // keyboard::KeyboardControllerObserver:
117 virtual void OnKeyboardBoundsChanging(
118 const gfx::Rect& keyboard_bounds) OVERRIDE;
119
120 // Parent window associated with this layout manager.
121 aura::Window* dock_container_;
122 // Protect against recursive calls to Relayout().
123 bool in_layout_;
124 // The docked window being dragged.
125 aura::Window* dragged_window_;
126 // The launcher we are observing for launcher icon changes.
127 Launcher* launcher_;
128 // The shelf layout manager being observed for visibility changes.
129 ShelfLayoutManager* shelf_layout_manager_;
130 // Tracks the visibility of the shelf. Defaults to false when there is no
131 // shelf.
132 bool shelf_hidden_;
133
134 // Side of the screen that the dock is positioned at.
135 DockedAlignment alignment_;
136
137 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManager);
138 };
139
140 } // namespace internal
141 } // namespace ash
142
143 #endif // ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698