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

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: Address varkha's comments in #7 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (IsPopupOrTransient(child)) 683 if (IsPopupOrTransient(child))
683 return; 684 return;
684 // Dragged windows are already observed by StartDragging and do not change 685 // Dragged windows are already observed by StartDragging and do not change
685 // docked alignment during the drag. 686 // docked alignment during the drag.
686 if (child == dragged_window_) 687 if (child == dragged_window_)
687 return; 688 return;
688 // If this is the first window getting docked - update alignment. 689 // 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 690 // 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 691 // 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. 692 // is set based on which edge is closer in the new display.
692 if (alignment_ == DOCKED_ALIGNMENT_NONE) 693 if (alignment_ == DOCKED_ALIGNMENT_NONE) {
693 alignment_ = GetEdgeNearestWindow(child); 694 alignment_ = preferred_alignment_ != DOCKED_ALIGNMENT_NONE ?
695 preferred_alignment_ : GetEdgeNearestWindow(child);
696 }
694 MaybeMinimizeChildrenExcept(child); 697 MaybeMinimizeChildrenExcept(child);
695 child->AddObserver(this); 698 child->AddObserver(this);
696 wm::GetWindowState(child)->AddObserver(this); 699 wm::GetWindowState(child)->AddObserver(this);
697 Relayout(); 700 Relayout();
698 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 701 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
699 } 702 }
700 703
701 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 704 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
702 if (IsPopupOrTransient(child)) 705 if (IsPopupOrTransient(child))
703 return; 706 return;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (!window_state->IsDocked()) { 847 if (!window_state->IsDocked()) {
845 if (window != dragged_window_) { 848 if (window != dragged_window_) {
846 UndockWindow(window); 849 UndockWindow(window);
847 if (window_state->IsMaximizedOrFullscreen()) 850 if (window_state->IsMaximizedOrFullscreen())
848 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); 851 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
849 } 852 }
850 } else if (window_state->IsMinimized()) { 853 } else if (window_state->IsMinimized()) {
851 MinimizeDockedWindow(window_state); 854 MinimizeDockedWindow(window_state);
852 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { 855 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) {
853 RestoreDockedWindow(window_state); 856 RestoreDockedWindow(window_state);
857 } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) {
858 NOTREACHED() << "Minimized window in docked layout manager";
854 } 859 }
855 } 860 }
856 861
857 ///////////////////////////////////////////////////////////////////////////// 862 /////////////////////////////////////////////////////////////////////////////
858 // DockedWindowLayoutManager, WindowObserver implementation: 863 // DockedWindowLayoutManager, WindowObserver implementation:
859 864
860 void DockedWindowLayoutManager::OnWindowBoundsChanged( 865 void DockedWindowLayoutManager::OnWindowBoundsChanged(
861 aura::Window* window, 866 aura::Window* window,
862 const gfx::Rect& old_bounds, 867 const gfx::Rect& old_bounds,
863 const gfx::Rect& new_bounds) { 868 const gfx::Rect& new_bounds) {
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 1351
1347 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1352 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1348 const gfx::Rect& keyboard_bounds) { 1353 const gfx::Rect& keyboard_bounds) {
1349 // This bounds change will have caused a change to the Shelf which does not 1354 // This bounds change will have caused a change to the Shelf which does not
1350 // propagate automatically to this class, so manually recalculate bounds. 1355 // propagate automatically to this class, so manually recalculate bounds.
1351 Relayout(); 1356 Relayout();
1352 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1357 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1353 } 1358 }
1354 1359
1355 } // namespace ash 1360 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698