Commit 942ebd88 authored by Tim Song's avatar Tim Song Committed by Commit Bot

Ash Tray: Fix system menu bubble position in tablet mode home screen.

In this state, the padding is already applied by the shelf in bottom alignment,
so we need to make a special case.

BUG=1011924

Change-Id: I211d5d0181a8c7419f6b8a587c6d05d3ec87235a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880569Reviewed-by: default avatarAhmed Mehfooz <amehfooz@chromium.org>
Commit-Queue: Tim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710111}
parent ac02073c
......@@ -5,6 +5,7 @@
#include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "ash/system/message_center/unified_message_center_bubble.h"
......@@ -18,6 +19,7 @@
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/work_area_insets.h"
#include "base/metrics/histogram_macros.h"
#include "chromeos/constants/chromeos_switches.h"
#include "ui/aura/window.h"
#include "ui/native_theme/native_theme_dark_aura.h"
#include "ui/wm/core/window_util.h"
......@@ -85,11 +87,7 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
init_params.anchor_view = nullptr;
init_params.anchor_mode = TrayBubbleView::AnchorMode::kRect;
init_params.anchor_rect = tray->shelf()->GetSystemTrayAnchorRect();
// Decrease bottom and right insets to compensate for the adjustment of
// the respective edges in Shelf::GetSystemTrayAnchorRect().
init_params.insets = gfx::Insets(
kUnifiedMenuPadding, kUnifiedMenuPadding, kUnifiedMenuPadding - 1,
kUnifiedMenuPadding - (base::i18n::IsRTL() ? 0 : 1));
init_params.insets = GetInsets();
init_params.corner_radius = kUnifiedTrayCornerRadius;
init_params.has_shadow = false;
init_params.show_by_click = show_by_click;
......@@ -410,4 +408,26 @@ void UnifiedSystemTrayBubble::SetFrameVisible(bool visible) {
bubble_widget_->non_client_view()->frame_view()->SetVisible(visible);
}
gfx::Insets UnifiedSystemTrayBubble::GetInsets() {
// Decrease bottom and right insets to compensate for the adjustment of
// the respective edges in Shelf::GetSystemTrayAnchorRect().
gfx::Insets insets = gfx::Insets(
kUnifiedMenuPadding, kUnifiedMenuPadding, kUnifiedMenuPadding - 1,
kUnifiedMenuPadding - (base::i18n::IsRTL() ? 0 : 1));
// A special case exists on the homescreen in tablet mode in which the padding
// is already applied in the status area. We should not set the padding again
// for the bubble. See crbug.com/1011924.
bool in_tablet_mode = Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
bool is_bottom_alignment =
tray_->shelf()->alignment() == SHELF_ALIGNMENT_BOTTOM;
if (chromeos::switches::ShouldShowShelfHotseat() && in_tablet_mode &&
!ShelfConfig::Get()->is_in_app() && is_bottom_alignment) {
insets.set_bottom(0);
}
return insets;
}
} // namespace ash
......@@ -15,6 +15,7 @@
#include "base/macros.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/wm/public/activation_change_observer.h"
......@@ -147,6 +148,9 @@ class ASH_EXPORT UnifiedSystemTrayBubble
// animation.
void SetFrameVisible(bool visible);
// Returns the insets for the bubble.
gfx::Insets GetInsets();
// Controller of UnifiedSystemTrayView. As the view is owned by views
// hierarchy, we have to own the controller here.
std::unique_ptr<UnifiedSystemTrayController> controller_;
......
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