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

Unified Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock on left or right edge Created 7 years, 7 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
« ash/wm/window_properties.h ('K') | « ash/wm/workspace/workspace_window_resizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_window_resizer.cc
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 25430933827c63762fb0e9b7dcc1cc1d348f5370..01eddf5b32be0acd9f3de16ba493637a9ee5c361 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -16,6 +16,9 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/default_window_resizer.h"
+#include "ash/wm/dock/dock_edge_types.h"
+#include "ash/wm/dock/dock_layout_manager.h"
+#include "ash/wm/dock/dock_window_resizer.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/panels/panel_window_resizer.h"
#include "ash/wm/property_util.h"
@@ -65,7 +68,11 @@ scoped_ptr<WindowResizer> CreateWindowResizer(aura::Window* window,
window_resizer = internal::DragWindowResizer::Create(
window_resizer, window, point_in_parent, window_component);
}
- if (window_resizer && window->type() == aura::client::WINDOW_TYPE_PANEL) {
+ if (window_resizer && GetDockEdges(window) != DOCK_EDGE_NONE) {
+ window_resizer = DockWindowResizer::Create(
+ window_resizer, window, point_in_parent, window_component);
+ } else if (window_resizer &&
+ window->type() == aura::client::WINDOW_TYPE_PANEL) {
window_resizer = PanelWindowResizer::Create(
window_resizer, window, point_in_parent, window_component);
}
@@ -220,6 +227,13 @@ uint32 WindowComponentToMagneticEdge(int window_component) {
return 0;
}
+internal::DockLayoutManager* GetDockLayoutManager(aura::Window* window) {
+ aura::Window* dock_container = Shell::GetContainer(
+ window->GetRootWindow(), internal::kShellWindowId_DockContainer);
+ return static_cast<internal::DockLayoutManager*>(
+ dock_container->layout_manager());
+}
+
} // namespace
// static
@@ -303,6 +317,13 @@ class WindowSize {
WorkspaceWindowResizer::~WorkspaceWindowResizer() {
Shell* shell = Shell::GetInstance();
shell->cursor_manager()->UnlockCursor();
+
+ if (GetDockEdges(window()) != dock_edges_mask_ &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshEnableDockedWindows))
+ if (window()->type() != aura::client::WINDOW_TYPE_PANEL ||
+ !window()->GetProperty(internal::kPanelAttachedKey))
+ SetDockEdges(window(), dock_edges_mask_);
}
// static
@@ -368,7 +389,7 @@ void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
if (!did_move_or_resize_ || details_.window_component != HTCAPTION)
return;
- // When the window is not in the normal show state, we do not snap thw window.
+ // When the window is not in the normal show state, we do not snap the window.
// This happens when the user minimizes or maximizes the window by keyboard
// shortcut while dragging it. If the window is the result of dragging a tab
// out of a maximized window, it's already in the normal show state when this
@@ -433,6 +454,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
total_min_(0),
total_initial_size_(0),
snap_type_(SNAP_NONE),
+ dock_edges_mask_(DOCK_EDGE_NONE),
num_mouse_moves_since_bounds_change_(0),
magnetism_window_(NULL) {
DCHECK(details_.is_resizable);
@@ -725,6 +747,7 @@ void WorkspaceWindowResizer::StickToWorkAreaOnMove(
// between snapping to top then bottom.
bounds->set_y(bottom_edge - bounds->height());
}
+ dock_edges_mask_ = CalculateDockEdges(*bounds);
}
void WorkspaceWindowResizer::StickToWorkAreaOnResize(
@@ -756,6 +779,15 @@ void WorkspaceWindowResizer::StickToWorkAreaOnResize(
}
}
+int WorkspaceWindowResizer::CalculateDockEdges(const gfx::Rect& bounds) const {
+ int stuck_edges_mask = DOCK_EDGE_NONE;
+ DockLayoutManager* dock_layout = GetDockLayoutManager(window());
+ if (dock_layout)
+ stuck_edges_mask = dock_layout->CalculateDockEdges(bounds);
+
+ return stuck_edges_mask;
+}
+
int WorkspaceWindowResizer::PrimaryAxisSize(const gfx::Size& size) const {
return PrimaryAxisCoordinate(size.width(), size.height());
}
« ash/wm/window_properties.h ('K') | « ash/wm/workspace/workspace_window_resizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698