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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 2200963002: ShelfLayoutManager virtual keyboard - do not change work area of screen if in non-sticky mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ShelfLayoutManager virtual keyboard - do not change work area of screen if in non-sticky mode. Created 4 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/common/ash_switches.h"
11 #include "ash/common/material_design/material_design_controller.h" 12 #include "ash/common/material_design/material_design_controller.h"
12 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shelf/shelf_constants.h" 14 #include "ash/common/shelf/shelf_constants.h"
14 #include "ash/common/shelf/shelf_delegate.h" 15 #include "ash/common/shelf/shelf_delegate.h"
15 #include "ash/common/shelf/wm_shelf_util.h" 16 #include "ash/common/shelf/wm_shelf_util.h"
16 #include "ash/common/shell_window_ids.h" 17 #include "ash/common/shell_window_ids.h"
17 #include "ash/common/system/status_area_widget.h" 18 #include "ash/common/system/status_area_widget.h"
18 #include "ash/common/wm/fullscreen_window_finder.h" 19 #include "ash/common/wm/fullscreen_window_finder.h"
19 #include "ash/common/wm/mru_window_tracker.h" 20 #include "ash/common/wm/mru_window_tracker.h"
20 #include "ash/common/wm/window_state.h" 21 #include "ash/common/wm/window_state.h"
21 #include "ash/common/wm_lookup.h" 22 #include "ash/common/wm_lookup.h"
22 #include "ash/common/wm_root_window_controller.h" 23 #include "ash/common/wm_root_window_controller.h"
23 #include "ash/common/wm_root_window_controller_observer.h" 24 #include "ash/common/wm_root_window_controller_observer.h"
24 #include "ash/common/wm_shell.h" 25 #include "ash/common/wm_shell.h"
25 #include "ash/common/wm_window.h" 26 #include "ash/common/wm_window.h"
26 #include "ash/screen_util.h" 27 #include "ash/screen_util.h"
27 #include "ash/shelf/shelf.h" 28 #include "ash/shelf/shelf.h"
28 #include "ash/shelf/shelf_bezel_event_filter.h" 29 #include "ash/shelf/shelf_bezel_event_filter.h"
29 #include "ash/shelf/shelf_layout_manager_observer.h" 30 #include "ash/shelf/shelf_layout_manager_observer.h"
30 #include "ash/shell.h" 31 #include "ash/shell.h"
31 #include "ash/wm/gestures/shelf_gesture_handler.h" 32 #include "ash/wm/gestures/shelf_gesture_handler.h"
32 #include "ash/wm/window_animations.h" 33 #include "ash/wm/window_animations.h"
33 #include "ash/wm/workspace_controller.h" 34 #include "ash/wm/workspace_controller.h"
34 #include "base/auto_reset.h" 35 #include "base/auto_reset.h"
36 #include "base/command_line.h"
35 #include "base/i18n/rtl.h" 37 #include "base/i18n/rtl.h"
36 #include "ui/compositor/layer.h" 38 #include "ui/compositor/layer.h"
37 #include "ui/compositor/layer_animation_observer.h" 39 #include "ui/compositor/layer_animation_observer.h"
38 #include "ui/compositor/layer_animator.h" 40 #include "ui/compositor/layer_animator.h"
39 #include "ui/compositor/scoped_layer_animation_settings.h" 41 #include "ui/compositor/scoped_layer_animation_settings.h"
40 #include "ui/display/display.h" 42 #include "ui/display/display.h"
41 #include "ui/display/screen.h" 43 #include "ui/display/screen.h"
42 #include "ui/events/event.h" 44 #include "ui/events/event.h"
43 #include "ui/events/event_handler.h" 45 #include "ui/events/event_handler.h"
46 #include "ui/keyboard/keyboard_controller.h"
44 #include "ui/keyboard/keyboard_util.h" 47 #include "ui/keyboard/keyboard_util.h"
45 #include "ui/views/border.h" 48 #include "ui/views/border.h"
46 #include "ui/views/widget/widget.h" 49 #include "ui/views/widget/widget.h"
47 50
48 namespace ash { 51 namespace ash {
49 namespace { 52 namespace {
50 53
51 // Delay before showing the shelf. This is after the mouse stops moving. 54 // Delay before showing the shelf. This is after the mouse stops moving.
52 const int kAutoHideDelayMS = 200; 55 const int kAutoHideDelayMS = 200;
53 56
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 gfx::Rect(rect.right() - shelf_size, rect.y(), shelf_size, 260 gfx::Rect(rect.right() - shelf_size, rect.y(), shelf_size,
258 rect.height())); 261 rect.height()));
259 } 262 }
260 263
261 gfx::Size ShelfLayoutManager::GetPreferredSize() { 264 gfx::Size ShelfLayoutManager::GetPreferredSize() {
262 TargetBounds target_bounds; 265 TargetBounds target_bounds;
263 CalculateTargetBounds(state_, &target_bounds); 266 CalculateTargetBounds(state_, &target_bounds);
264 return target_bounds.shelf_bounds_in_root.size(); 267 return target_bounds.shelf_bounds_in_root.size();
265 } 268 }
266 269
267 void ShelfLayoutManager::LayoutShelf() { 270 void ShelfLayoutManager::LayoutShelfAndUpdateBounds(bool change_work_area) {
268 TargetBounds target_bounds; 271 TargetBounds target_bounds;
269 CalculateTargetBounds(state_, &target_bounds); 272 CalculateTargetBounds(state_, &target_bounds);
270 UpdateBoundsAndOpacity(target_bounds, false, NULL); 273 UpdateBoundsAndOpacity(target_bounds, false, change_work_area, NULL);
271 274
272 // Update insets in ShelfWindowTargeter when shelf bounds change. 275 // Update insets in ShelfWindowTargeter when shelf bounds change.
273 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 276 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
274 WillChangeVisibilityState(visibility_state())); 277 WillChangeVisibilityState(visibility_state()));
275 } 278 }
276 279
280 void ShelfLayoutManager::LayoutShelf() {
281 LayoutShelfAndUpdateBounds(true);
282 }
283
277 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { 284 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() {
278 switch (shelf_widget_->shelf()->auto_hide_behavior()) { 285 switch (shelf_widget_->shelf()->auto_hide_behavior()) {
279 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 286 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
280 return SHELF_AUTO_HIDE; 287 return SHELF_AUTO_HIDE;
281 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 288 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
282 return SHELF_VISIBLE; 289 return SHELF_VISIBLE;
283 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 290 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
284 return SHELF_HIDDEN; 291 return SHELF_HIDDEN;
285 } 292 }
286 return SHELF_VISIBLE; 293 return SHELF_VISIBLE;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 549
543 void ShelfLayoutManager::OnWindowActivated(WmWindow* gained_active, 550 void ShelfLayoutManager::OnWindowActivated(WmWindow* gained_active,
544 WmWindow* lost_active) { 551 WmWindow* lost_active) {
545 UpdateAutoHideStateNow(); 552 UpdateAutoHideStateNow();
546 } 553 }
547 554
548 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { 555 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
549 bool keyboard_is_about_to_hide = false; 556 bool keyboard_is_about_to_hide = false;
550 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) 557 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty())
551 keyboard_is_about_to_hide = true; 558 keyboard_is_about_to_hide = true;
559 // If new window behavior flag enabled and in non-sticky mode, do not change
560 // the work area.
561 bool change_work_area =
562 (!base::CommandLine::ForCurrentProcess()->HasSwitch(
563 switches::kAshUseNewVKWindowBehavior) ||
564 keyboard::KeyboardController::GetInstance()->get_lock_keyboard());
552 565
553 keyboard_bounds_ = new_bounds; 566 keyboard_bounds_ = new_bounds;
554 OnWindowResized(); 567 LayoutShelfAndUpdateBounds(change_work_area);
555 568
556 // On login screen if keyboard has been just hidden, update bounds just once 569 // On login screen if keyboard has been just hidden, update bounds just once
557 // but ignore target_bounds.work_area_insets since shelf overlaps with login 570 // but ignore target_bounds.work_area_insets since shelf overlaps with login
558 // window. 571 // window.
559 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() && 572 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() &&
560 keyboard_is_about_to_hide) { 573 keyboard_is_about_to_hide) {
561 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, gfx::Insets()); 574 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, gfx::Insets());
562 } 575 }
563 } 576 }
564 577
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } else { 682 } else {
670 UpdateShelfBackground(change_type); 683 UpdateShelfBackground(change_type);
671 } 684 }
672 685
673 shelf_widget_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE && 686 shelf_widget_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE &&
674 state.window_state == 687 state.window_state ==
675 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED); 688 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED);
676 689
677 TargetBounds target_bounds; 690 TargetBounds target_bounds;
678 CalculateTargetBounds(state_, &target_bounds); 691 CalculateTargetBounds(state_, &target_bounds);
679 UpdateBoundsAndOpacity(target_bounds, true, delay_background_change 692 UpdateBoundsAndOpacity(target_bounds, true, true, delay_background_change
oshima 2016/08/03 21:22:38 nit: can you add the comment to bool value like t
hariank 2016/08/03 21:29:37 Done.
680 ? update_shelf_observer_ 693 ? update_shelf_observer_
681 : NULL); 694 : NULL);
682 695
683 // The delegate must be notified after |state_| is updated so that it can 696 // The delegate must be notified after |state_| is updated so that it can
684 // query the new target bounds. 697 // query the new target bounds.
685 ShelfDelegate* shelf_delegate = WmShell::Get()->shelf_delegate(); 698 ShelfDelegate* shelf_delegate = WmShell::Get()->shelf_delegate();
686 DCHECK(shelf_delegate); 699 DCHECK(shelf_delegate);
687 if (old_state.visibility_state != state_.visibility_state) 700 if (old_state.visibility_state != state_.visibility_state)
688 shelf_delegate->OnShelfVisibilityStateChanged(shelf_widget_->shelf()); 701 shelf_delegate->OnShelfVisibilityStateChanged(shelf_widget_->shelf());
689 702
690 // OnAutoHideStateChanged Should be emitted when: 703 // OnAutoHideStateChanged Should be emitted when:
691 // - firstly state changed to auto-hide from other state 704 // - firstly state changed to auto-hide from other state
692 // - or, auto_hide_state has changed 705 // - or, auto_hide_state has changed
693 if ((old_state.visibility_state != state_.visibility_state && 706 if ((old_state.visibility_state != state_.visibility_state &&
694 state_.visibility_state == SHELF_AUTO_HIDE) || 707 state_.visibility_state == SHELF_AUTO_HIDE) ||
695 old_state.auto_hide_state != state_.auto_hide_state) { 708 old_state.auto_hide_state != state_.auto_hide_state) {
696 shelf_delegate->OnShelfAutoHideStateChanged(shelf_widget_->shelf()); 709 shelf_delegate->OnShelfAutoHideStateChanged(shelf_widget_->shelf());
697 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 710 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
698 OnAutoHideStateChanged(state_.auto_hide_state)); 711 OnAutoHideStateChanged(state_.auto_hide_state));
699 } 712 }
700 } 713 }
701 714
702 void ShelfLayoutManager::UpdateBoundsAndOpacity( 715 void ShelfLayoutManager::UpdateBoundsAndOpacity(
703 const TargetBounds& target_bounds, 716 const TargetBounds& target_bounds,
704 bool animate, 717 bool animate,
718 bool change_work_area,
705 ui::ImplicitAnimationObserver* observer) { 719 ui::ImplicitAnimationObserver* observer) {
706 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); 720 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true);
707 { 721 {
708 ui::ScopedLayerAnimationSettings shelf_animation_setter( 722 ui::ScopedLayerAnimationSettings shelf_animation_setter(
709 GetLayer(shelf_widget_)->GetAnimator()); 723 GetLayer(shelf_widget_)->GetAnimator());
710 ui::ScopedLayerAnimationSettings status_animation_setter( 724 ui::ScopedLayerAnimationSettings status_animation_setter(
711 GetLayer(shelf_widget_->status_area_widget())->GetAnimator()); 725 GetLayer(shelf_widget_->status_area_widget())->GetAnimator());
712 if (animate) { 726 if (animate) {
713 int duration = duration_override_in_ms_ ? duration_override_in_ms_ 727 int duration = duration_override_in_ms_ ? duration_override_in_ms_
714 : kCrossFadeDurationMS; 728 : kCrossFadeDurationMS;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // mash::wm::ShelfLayout manages window bounds when running mash. 770 // mash::wm::ShelfLayout manages window bounds when running mash.
757 if (!Shell::GetInstance()->in_mus()) { 771 if (!Shell::GetInstance()->in_mus()) {
758 shelf_widget_->status_area_widget()->SetBounds( 772 shelf_widget_->status_area_widget()->SetBounds(
759 ScreenUtil::ConvertRectToScreen( 773 ScreenUtil::ConvertRectToScreen(
760 shelf_widget_->status_area_widget()->GetNativeView()->parent(), 774 shelf_widget_->status_area_widget()->GetNativeView()->parent(),
761 status_bounds)); 775 status_bounds));
762 } 776 }
763 // For crbug.com/622431, when the shelf alignment is BOTTOM_LOCKED, we 777 // For crbug.com/622431, when the shelf alignment is BOTTOM_LOCKED, we
764 // don't set display work area, as it is not real user-set alignment. 778 // don't set display work area, as it is not real user-set alignment.
765 if (!state_.is_screen_locked && 779 if (!state_.is_screen_locked &&
766 shelf_widget_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED) { 780 shelf_widget_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED &&
781 change_work_area) {
767 gfx::Insets insets; 782 gfx::Insets insets;
768 // If user session is blocked (login to new user session or add user to 783 // If user session is blocked (login to new user session or add user to
769 // the existing session - multi-profile) then give 100% of work area only 784 // the existing session - multi-profile) then give 100% of work area only
770 // if keyboard is not shown. 785 // if keyboard is not shown.
771 if (!state_.is_adding_user_screen || !keyboard_bounds_.IsEmpty()) 786 if (!state_.is_adding_user_screen || !keyboard_bounds_.IsEmpty())
772 insets = target_bounds.work_area_insets; 787 insets = target_bounds.work_area_insets;
773 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets); 788 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
774 } 789 }
775 } 790 }
776 791
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 // Check transition changes to/from the add user to session and change the 1173 // Check transition changes to/from the add user to session and change the
1159 // shelf alignment accordingly 1174 // shelf alignment accordingly
1160 bool add_user = state == SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY; 1175 bool add_user = state == SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY;
1161 if (add_user != state_.is_adding_user_screen) { 1176 if (add_user != state_.is_adding_user_screen) {
1162 state_.is_adding_user_screen = add_user; 1177 state_.is_adding_user_screen = add_user;
1163 UpdateShelfVisibilityAfterLoginUIChange(); 1178 UpdateShelfVisibilityAfterLoginUIChange();
1164 return; 1179 return;
1165 } 1180 }
1166 TargetBounds target_bounds; 1181 TargetBounds target_bounds;
1167 CalculateTargetBounds(state_, &target_bounds); 1182 CalculateTargetBounds(state_, &target_bounds);
1168 UpdateBoundsAndOpacity(target_bounds, true, NULL); 1183 UpdateBoundsAndOpacity(target_bounds, true, true, NULL);
1169 UpdateVisibilityState(); 1184 UpdateVisibilityState();
1170 } 1185 }
1171 1186
1172 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { 1187 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
1173 UpdateVisibilityState(); 1188 UpdateVisibilityState();
1174 LayoutShelf(); 1189 LayoutShelf();
1175 } 1190 }
1176 1191
1177 float ShelfLayoutManager::ComputeTargetOpacity(const State& state) { 1192 float ShelfLayoutManager::ComputeTargetOpacity(const State& state) {
1178 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || 1193 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
1179 state.visibility_state == SHELF_VISIBLE) { 1194 state.visibility_state == SHELF_VISIBLE) {
1180 return 1.0f; 1195 return 1.0f;
1181 } 1196 }
1182 // In Chrome OS Material Design, when shelf is hidden during auto hide state, 1197 // In Chrome OS Material Design, when shelf is hidden during auto hide state,
1183 // target bounds are also hidden. So the window can extend to the edge of 1198 // target bounds are also hidden. So the window can extend to the edge of
1184 // screen. 1199 // screen.
1185 if (ash::MaterialDesignController::IsShelfMaterial()) { 1200 if (ash::MaterialDesignController::IsShelfMaterial()) {
1186 return (state.visibility_state == SHELF_AUTO_HIDE && 1201 return (state.visibility_state == SHELF_AUTO_HIDE &&
1187 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN) 1202 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)
1188 ? 1.0f 1203 ? 1.0f
1189 : 0.0f; 1204 : 0.0f;
1190 } 1205 }
1191 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; 1206 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
1192 } 1207 }
1193 1208
1194 } // namespace ash 1209 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698