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

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: Use Compound Events for snap/dock as per oshima's request 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 alignment != DOCKED_ALIGNMENT_NONE && 631 alignment != DOCKED_ALIGNMENT_NONE &&
631 alignment != desired_alignment) { 632 alignment != desired_alignment) {
632 return false; 633 return false;
633 } 634 }
634 // Do not allow docking on the same side as shelf. 635 // Do not allow docking on the same side as shelf.
635 return IsDockedAlignmentValid(desired_alignment); 636 return IsDockedAlignmentValid(desired_alignment);
636 } 637 }
637 638
638 bool DockedWindowLayoutManager::IsDockedAlignmentValid( 639 bool DockedWindowLayoutManager::IsDockedAlignmentValid(
639 DockedAlignment alignment) const { 640 DockedAlignment alignment) const {
640 ShelfAlignment shelf_alignment = shelf_ ? shelf->alignment() : 641 ShelfAlignment shelf_alignment = shelf_ ? shelf_->alignment() :
641 SHELF_ALIGNMENT_BOTTOM; 642 SHELF_ALIGNMENT_BOTTOM;
642 if ((alignment == DOCKED_ALIGNMENT_LEFT && 643 if ((alignment == DOCKED_ALIGNMENT_LEFT &&
643 shelf_alignment == SHELF_ALIGNMENT_LEFT) || 644 shelf_alignment == SHELF_ALIGNMENT_LEFT) ||
644 (alignment == DOCKED_ALIGNMENT_RIGHT && 645 (alignment == DOCKED_ALIGNMENT_RIGHT &&
645 shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { 646 shelf_alignment == SHELF_ALIGNMENT_RIGHT)) {
646 return false; 647 return false;
647 } 648 }
648 return true; 649 return true;
649 } 650 }
650 651
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (IsPopupOrTransient(child)) 686 if (IsPopupOrTransient(child))
686 return; 687 return;
687 // Dragged windows are already observed by StartDragging and do not change 688 // Dragged windows are already observed by StartDragging and do not change
688 // docked alignment during the drag. 689 // docked alignment during the drag.
689 if (child == dragged_window_) 690 if (child == dragged_window_)
690 return; 691 return;
691 // If this is the first window getting docked - update alignment. 692 // If this is the first window getting docked - update alignment.
692 // A window can be added without proper bounds when window is moved to another 693 // A window can be added without proper bounds when window is moved to another
693 // display via API or due to display configuration change, so the alignment 694 // display via API or due to display configuration change, so the alignment
694 // is set based on which edge is closer in the new display. 695 // is set based on which edge is closer in the new display.
695 if (alignment_ == DOCKED_ALIGNMENT_NONE) 696 if (alignment_ == DOCKED_ALIGNMENT_NONE) {
696 alignment_ = GetEdgeNearestWindow(child); 697 alignment_ = preferred_alignment_ != DOCKED_ALIGNMENT_NONE ?
698 preferred_alignment_ : GetEdgeNearestWindow(child);
699 }
697 MaybeMinimizeChildrenExcept(child); 700 MaybeMinimizeChildrenExcept(child);
698 child->AddObserver(this); 701 child->AddObserver(this);
699 wm::GetWindowState(child)->AddObserver(this); 702 wm::GetWindowState(child)->AddObserver(this);
700 Relayout(); 703 Relayout();
701 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 704 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
702 } 705 }
703 706
704 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 707 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
705 if (IsPopupOrTransient(child)) 708 if (IsPopupOrTransient(child))
706 return; 709 return;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 if (!window_state->IsDocked()) { 850 if (!window_state->IsDocked()) {
848 if (window != dragged_window_) { 851 if (window != dragged_window_) {
849 UndockWindow(window); 852 UndockWindow(window);
850 if (window_state->IsMaximizedOrFullscreen()) 853 if (window_state->IsMaximizedOrFullscreen())
851 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); 854 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
852 } 855 }
853 } else if (window_state->IsMinimized()) { 856 } else if (window_state->IsMinimized()) {
854 MinimizeDockedWindow(window_state); 857 MinimizeDockedWindow(window_state);
855 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { 858 } else if (old_type == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) {
856 RestoreDockedWindow(window_state); 859 RestoreDockedWindow(window_state);
860 } else if (old_type == wm::WINDOW_STATE_TYPE_MINIMIZED) {
861 NOTREACHED() << "Minimized window in docked layout manager";
857 } 862 }
858 } 863 }
859 864
860 ///////////////////////////////////////////////////////////////////////////// 865 /////////////////////////////////////////////////////////////////////////////
861 // DockedWindowLayoutManager, WindowObserver implementation: 866 // DockedWindowLayoutManager, WindowObserver implementation:
862 867
863 void DockedWindowLayoutManager::OnWindowBoundsChanged( 868 void DockedWindowLayoutManager::OnWindowBoundsChanged(
864 aura::Window* window, 869 aura::Window* window,
865 const gfx::Rect& old_bounds, 870 const gfx::Rect& old_bounds,
866 const gfx::Rect& new_bounds) { 871 const gfx::Rect& new_bounds) {
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 1354
1350 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1355 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1351 const gfx::Rect& keyboard_bounds) { 1356 const gfx::Rect& keyboard_bounds) {
1352 // This bounds change will have caused a change to the Shelf which does not 1357 // This bounds change will have caused a change to the Shelf which does not
1353 // propagate automatically to this class, so manually recalculate bounds. 1358 // propagate automatically to this class, so manually recalculate bounds.
1354 Relayout(); 1359 Relayout();
1355 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1360 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1356 } 1361 }
1357 1362
1358 } // namespace ash 1363 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698