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

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

Issue 594383002: Change behaviour of the Alt-] and Alt-[ keys so that it cycles through SnapLeft/SnapRight to DockLe… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@event
Patch Set: Upload new patch based on dependant change's API name change Created 6 years, 2 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
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 #include "ash/wm/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 in_layout_(false), 409 in_layout_(false),
410 dragged_window_(NULL), 410 dragged_window_(NULL),
411 is_dragged_window_docked_(false), 411 is_dragged_window_docked_(false),
412 is_dragged_from_dock_(false), 412 is_dragged_from_dock_(false),
413 shelf_(NULL), 413 shelf_(NULL),
414 workspace_controller_(workspace_controller), 414 workspace_controller_(workspace_controller),
415 in_fullscreen_(workspace_controller_->GetWindowState() == 415 in_fullscreen_(workspace_controller_->GetWindowState() ==
416 WORKSPACE_WINDOW_STATE_FULL_SCREEN), 416 WORKSPACE_WINDOW_STATE_FULL_SCREEN),
417 docked_width_(0), 417 docked_width_(0),
418 alignment_(DOCKED_ALIGNMENT_NONE), 418 alignment_(DOCKED_ALIGNMENT_NONE),
419 preferred_alignment_(DOCKED_ALIGNMENT_NONE),
419 last_active_window_(NULL), 420 last_active_window_(NULL),
420 last_action_time_(base::Time::Now()), 421 last_action_time_(base::Time::Now()),
421 background_widget_(new DockedBackgroundWidget(dock_container_)) { 422 background_widget_(new DockedBackgroundWidget(dock_container_)) {
422 DCHECK(dock_container); 423 DCHECK(dock_container);
423 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 424 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
424 AddObserver(this); 425 AddObserver(this);
425 Shell::GetInstance()->AddShellObserver(this); 426 Shell::GetInstance()->AddShellObserver(this);
426 } 427 }
427 428
428 DockedWindowLayoutManager::~DockedWindowLayoutManager() { 429 DockedWindowLayoutManager::~DockedWindowLayoutManager() {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 for (size_t i = 0; i < dock_container_->children().size(); ++i) { 589 for (size_t i = 0; i < dock_container_->children().size(); ++i) {
589 aura::Window* child(dock_container_->children()[i]); 590 aura::Window* child(dock_container_->children()[i]);
590 if (window != child && !IsPopupOrTransient(child)) 591 if (window != child && !IsPopupOrTransient(child))
591 return alignment_; 592 return alignment_;
592 } 593 }
593 // No docked windows remain other than possibly the window being queried. 594 // No docked windows remain other than possibly the window being queried.
594 // Return |NONE| to indicate that windows may get docked on either side. 595 // Return |NONE| to indicate that windows may get docked on either side.
595 return DOCKED_ALIGNMENT_NONE; 596 return DOCKED_ALIGNMENT_NONE;
596 } 597 }
597 598
599 void DockedWindowLayoutManager::SetPreferredAlignment(
600 DockedAlignment preferred_alignment) {
601 preferred_alignment_ = preferred_alignment;
602 }
603
598 bool DockedWindowLayoutManager::CanDockWindow( 604 bool DockedWindowLayoutManager::CanDockWindow(
599 aura::Window* window, 605 aura::Window* window,
600 DockedAlignment desired_alignment) { 606 DockedAlignment desired_alignment) {
601 // Don't allow interactive docking of windows with transient parents such as 607 // Don't allow interactive docking of windows with transient parents such as
602 // modal browser dialogs. Prevent docking of panels attached to shelf during 608 // modal browser dialogs. Prevent docking of panels attached to shelf during
603 // the drag. 609 // the drag.
604 wm::WindowState* window_state = wm::GetWindowState(window); 610 wm::WindowState* window_state = wm::GetWindowState(window);
605 bool should_attach_to_shelf = window_state->drag_details() && 611 bool should_attach_to_shelf = window_state->drag_details() &&
606 window_state->drag_details()->should_attach_to_shelf; 612 window_state->drag_details()->should_attach_to_shelf;
607 if (IsPopupOrTransient(window) || should_attach_to_shelf) 613 if (IsPopupOrTransient(window) || should_attach_to_shelf)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (IsPopupOrTransient(child)) 688 if (IsPopupOrTransient(child))
683 return; 689 return;
684 // Dragged windows are already observed by StartDragging and do not change 690 // Dragged windows are already observed by StartDragging and do not change
685 // docked alignment during the drag. 691 // docked alignment during the drag.
686 if (child == dragged_window_) 692 if (child == dragged_window_)
687 return; 693 return;
688 // If this is the first window getting docked - update alignment. 694 // If this is the first window getting docked - update alignment.
689 // A window can be added without proper bounds when window is moved to another 695 // A window can be added without proper bounds when window is moved to another
690 // display via API or due to display configuration change, so the alignment 696 // display via API or due to display configuration change, so the alignment
691 // is set based on which edge is closer in the new display. 697 // is set based on which edge is closer in the new display.
692 if (alignment_ == DOCKED_ALIGNMENT_NONE) 698 if (alignment_ == DOCKED_ALIGNMENT_NONE) {
693 alignment_ = GetEdgeNearestWindow(child); 699 alignment_ = preferred_alignment_ != DOCKED_ALIGNMENT_NONE ?
700 preferred_alignment_ : GetEdgeNearestWindow(child);
701 }
694 MaybeMinimizeChildrenExcept(child); 702 MaybeMinimizeChildrenExcept(child);
695 child->AddObserver(this); 703 child->AddObserver(this);
696 wm::GetWindowState(child)->AddObserver(this); 704 wm::GetWindowState(child)->AddObserver(this);
697 Relayout(); 705 Relayout();
698 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 706 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
699 } 707 }
700 708
701 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 709 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
702 if (IsPopupOrTransient(child)) 710 if (IsPopupOrTransient(child))
703 return; 711 return;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (!window_state->IsDocked()) { 852 if (!window_state->IsDocked()) {
845 if (window != dragged_window_) { 853 if (window != dragged_window_) {
846 UndockWindow(window); 854 UndockWindow(window);
847 if (window_state->IsMaximizedOrFullscreen()) 855 if (window_state->IsMaximizedOrFullscreen())
848 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); 856 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
849 } 857 }
850 } else if (window_state->IsMinimized()) { 858 } else if (window_state->IsMinimized()) {
851 MinimizeDockedWindow(window_state); 859 MinimizeDockedWindow(window_state);
852 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { 860 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) {
853 RestoreDockedWindow(window_state); 861 RestoreDockedWindow(window_state);
862 } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) {
863 NOTREACHED() << "Minimized window in docked layout manager";
854 } 864 }
855 } 865 }
856 866
857 ///////////////////////////////////////////////////////////////////////////// 867 /////////////////////////////////////////////////////////////////////////////
858 // DockedWindowLayoutManager, WindowObserver implementation: 868 // DockedWindowLayoutManager, WindowObserver implementation:
859 869
860 void DockedWindowLayoutManager::OnWindowBoundsChanged( 870 void DockedWindowLayoutManager::OnWindowBoundsChanged(
861 aura::Window* window, 871 aura::Window* window,
862 const gfx::Rect& old_bounds, 872 const gfx::Rect& old_bounds,
863 const gfx::Rect& new_bounds) { 873 const gfx::Rect& new_bounds) {
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 1356
1347 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1357 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1348 const gfx::Rect& keyboard_bounds) { 1358 const gfx::Rect& keyboard_bounds) {
1349 // This bounds change will have caused a change to the Shelf which does not 1359 // This bounds change will have caused a change to the Shelf which does not
1350 // propagate automatically to this class, so manually recalculate bounds. 1360 // propagate automatically to this class, so manually recalculate bounds.
1351 Relayout(); 1361 Relayout();
1352 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1362 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1353 } 1363 }
1354 1364
1355 } // namespace ash 1365 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698