Commit 4c51f61a authored by chinsenj's avatar chinsenj Committed by Chromium LUCI CQ

cros: Add toast for visible on all desks window in overview.

When a user tries to drag a visible on all desks window to a specific
desk in overview mode, they are unable to. Currently there is no visual
indicator that nothing happened.

This CL adds a toast for when this happens and also prevents the desks
mini views from highlighting when a user drags a visible on all desks
window over the mini views.

Test: manual
Bug: 1163697
Change-Id: I43acbfb9b90567dbeef294ac97c0e6cc5af33bdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616319Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Jeremy Chinsen <chinsenj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842191}
parent 7960df5e
...@@ -1359,6 +1359,9 @@ This file contains the strings for ash. ...@@ -1359,6 +1359,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_OVERVIEW_WINDOW_CLOSING_A11Y_ALERT" desc="The accessibility alert read by screen readers to alert the user that a window in overview mode is closing."> <message name="IDS_ASH_OVERVIEW_WINDOW_CLOSING_A11Y_ALERT" desc="The accessibility alert read by screen readers to alert the user that a window in overview mode is closing.">
Window <ph name="WINDOW_TITILE">$1<ex>1</ex></ph> closed. Window <ph name="WINDOW_TITILE">$1<ex>1</ex></ph> closed.
</message> </message>
<message name="IDS_ASH_OVERVIEW_VISIBLE_ON_ALL_DESKS_TOAST" desc="The text for the toast that appears when user tries to drag a visible on all desks window to a desk.">
Already assigned to all desks.
</message>
<!-- Virtual Desks --> <!-- Virtual Desks -->
<message name="IDS_ASH_DESKS_NEW_DESK_BUTTON" desc="The label of the new virtual desk (a.k.a. workspaces) button."> <message name="IDS_ASH_DESKS_NEW_DESK_BUTTON" desc="The label of the new virtual desk (a.k.a. workspaces) button.">
......
0feb78aa3efb3b45ffd5e7ec3c2ad58b3a51026a
\ No newline at end of file
...@@ -496,7 +496,6 @@ bool DesksController::MoveWindowFromActiveDeskTo( ...@@ -496,7 +496,6 @@ bool DesksController::MoveWindowFromActiveDeskTo(
if (source == DesksMoveWindowFromActiveDeskSource::kDragAndDrop) { if (source == DesksMoveWindowFromActiveDeskSource::kDragAndDrop) {
// Since a visible on all desks window is on all desks, prevent users from // Since a visible on all desks window is on all desks, prevent users from
// moving them manually in overview. // moving them manually in overview.
// TODO(chinsenj): Add a UX indication for users.
return false; return false;
} else if (source == DesksMoveWindowFromActiveDeskSource::kShortcut) { } else if (source == DesksMoveWindowFromActiveDeskSource::kShortcut) {
window->SetProperty(aura::client::kVisibleOnAllWorkspacesKey, false); window->SetProperty(aura::client::kVisibleOnAllWorkspacesKey, false);
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "ash/rotator/screen_rotation_animator.h" #include "ash/rotator/screen_rotation_animator.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/toast/toast_manager_impl.h"
#include "ash/wallpaper/wallpaper_controller_impl.h" #include "ash/wallpaper/wallpaper_controller_impl.h"
#include "ash/wm/desks/desk_mini_view.h" #include "ash/wm/desks/desk_mini_view.h"
#include "ash/wm/desks/desk_name_view.h" #include "ash/wm/desks/desk_name_view.h"
...@@ -56,6 +58,7 @@ ...@@ -56,6 +58,7 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/throughput_tracker.h" #include "ui/compositor/throughput_tracker.h"
#include "ui/gfx/geometry/vector2d_f.h" #include "ui/gfx/geometry/vector2d_f.h"
...@@ -90,6 +93,12 @@ constexpr base::TimeDelta kOcclusionUnpauseDurationForScroll = ...@@ -90,6 +93,12 @@ constexpr base::TimeDelta kOcclusionUnpauseDurationForScroll =
constexpr base::TimeDelta kOcclusionUnpauseDurationForRotation = constexpr base::TimeDelta kOcclusionUnpauseDurationForRotation =
base::TimeDelta::FromMilliseconds(300); base::TimeDelta::FromMilliseconds(300);
// Toast id for the toast that is displayed when a user tries to move a window
// that is visible on all desks to another desk.
constexpr char kMoveVisibleOnAllDesksWindowToastId[] =
"ash.wm.overview.move_visible_on_all_desks_window_toast";
constexpr int kToastDurationMs = 2500;
// Histogram names for overview enter/exit smoothness in clamshell, // Histogram names for overview enter/exit smoothness in clamshell,
// tablet mode and splitview. // tablet mode and splitview.
constexpr char kOverviewEnterClamshellHistogram[] = constexpr char kOverviewEnterClamshellHistogram[] =
...@@ -1358,19 +1367,33 @@ bool OverviewGrid::MaybeDropItemOnDeskMiniView( ...@@ -1358,19 +1367,33 @@ bool OverviewGrid::MaybeDropItemOnDeskMiniView(
OverviewItem* drag_item) { OverviewItem* drag_item) {
DCHECK(desks_util::ShouldDesksBarBeCreated()); DCHECK(desks_util::ShouldDesksBarBeCreated());
aura::Window* const dragged_window = drag_item->GetWindow();
const bool dragged_window_is_visible_on_all_desks =
dragged_window &&
dragged_window->GetProperty(aura::client::kVisibleOnAllWorkspacesKey);
// End the drag for the DesksBarView. // End the drag for the DesksBarView.
if (!IntersectsWithDesksBar(screen_location, if (!IntersectsWithDesksBar(screen_location,
/*update_desks_bar_drag_details=*/true, /*update_desks_bar_drag_details=*/
!dragged_window_is_visible_on_all_desks,
/*for_drop=*/true)) { /*for_drop=*/true)) {
return false; return false;
} }
if (dragged_window_is_visible_on_all_desks) {
// Show toast since items that are visible on all desks should not be able
// to be unassigned during overview.
Shell::Get()->toast_manager()->Show(ToastData(
kMoveVisibleOnAllDesksWindowToastId,
l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_VISIBLE_ON_ALL_DESKS_TOAST),
kToastDurationMs, base::nullopt));
return false;
}
auto* desks_controller = DesksController::Get(); auto* desks_controller = DesksController::Get();
for (auto* mini_view : desks_bar_view_->mini_views()) { for (auto* mini_view : desks_bar_view_->mini_views()) {
if (!mini_view->IsPointOnMiniView(screen_location)) if (!mini_view->IsPointOnMiniView(screen_location))
continue; continue;
aura::Window* const dragged_window = drag_item->GetWindow();
Desk* const target_desk = mini_view->desk(); Desk* const target_desk = mini_view->desk();
if (target_desk == desks_controller->active_desk()) if (target_desk == desks_controller->active_desk())
return false; return false;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/numerics/ranges.h" #include "base/numerics/ranges.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -79,6 +80,13 @@ bool GetVirtualDesksBarEnabled(OverviewItem* item) { ...@@ -79,6 +80,13 @@ bool GetVirtualDesksBarEnabled(OverviewItem* item) {
item->overview_grid()->IsDesksBarViewActive(); item->overview_grid()->IsDesksBarViewActive();
} }
// Returns whether |item|'s window is visible on all desks.
bool DraggedItemIsVisibleOnAllDesks(OverviewItem* item) {
aura::Window* const dragged_window = item->GetWindow();
return dragged_window &&
dragged_window->GetProperty(aura::client::kVisibleOnAllWorkspacesKey);
}
// Returns the scaled-down size of the dragged item that should be used when // Returns the scaled-down size of the dragged item that should be used when
// it's dragged over the DesksBarView that belongs to |overview_grid|. // it's dragged over the DesksBarView that belongs to |overview_grid|.
// |window_original_size| is the size of the item's window before it was scaled // |window_original_size| is the size of the item's window before it was scaled
...@@ -520,10 +528,12 @@ void OverviewWindowDragController::ContinueNormalDrag( ...@@ -520,10 +528,12 @@ void OverviewWindowDragController::ContinueNormalDrag(
if (desks_bar_data.shrink_bounds.Contains(location_in_screen)) { if (desks_bar_data.shrink_bounds.Contains(location_in_screen)) {
// Update the mini views borders by checking if |location_in_screen| // Update the mini views borders by checking if |location_in_screen|
// intersects. // intersects. Only update the borders if the dragged item is not visible
// on all desks.
overview_grid->IntersectsWithDesksBar( overview_grid->IntersectsWithDesksBar(
gfx::ToRoundedPoint(location_in_screen), gfx::ToRoundedPoint(location_in_screen),
/*update_desks_bar_drag_details=*/true, /*for_drop=*/false); /*update_desks_bar_drag_details=*/
!DraggedItemIsVisibleOnAllDesks(item_), /*for_drop=*/false);
float value = 0.f; float value = 0.f;
if (centerpoint.y() < desks_bar_data.desks_bar_bounds.y() || if (centerpoint.y() < desks_bar_data.desks_bar_bounds.y() ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment