Commit 5ba8d730 authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Fix "show taps" circle painting after display rotation

The tap visualizer mojo app creates a fullscreen widget in the overlay
container. It draws "tap point" circles in that widget. When the
display work area changes (for example, after display rotation) the
widget needs to be resized. Add a layout manager that handles the
resize.

In theory we should do this for maximized and pinned windows as well.
However, I'm limiting it to fullscreen windows because I intend to
backport the fix to M69. (The bug is a user-visible regression that
affects recording demo videos on detachable and tablet devices.)

Bug: 869130
Test: ash_unittests, enable "Show taps" in about:flags, rotate display, tap near the bottom of the display
Change-Id: If54c65e2964f2a709c707e255c1b80d8e16666d9
Reviewed-on: https://chromium-review.googlesource.com/1165956Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581364}
parent b0ba8294
......@@ -602,6 +602,7 @@ component("ash") {
"wm/native_cursor_manager_ash_classic.h",
"wm/non_client_frame_controller.h",
"wm/overlay_event_filter.h",
"wm/overlay_layout_manager.h",
"wm/overview/cleanup_animation_observer.h",
"wm/overview/overview_animation_type.h",
"wm/overview/overview_utils.h",
......@@ -1209,6 +1210,7 @@ component("ash") {
"wm/native_cursor_manager_ash_classic.cc",
"wm/non_client_frame_controller.cc",
"wm/overlay_event_filter.cc",
"wm/overlay_layout_manager.cc",
"wm/overview/cleanup_animation_observer.cc",
"wm/overview/overview_utils.cc",
"wm/overview/overview_window_drag_controller.cc",
......@@ -1923,6 +1925,7 @@ test("ash_unittests") {
"wm/native_cursor_manager_ash_unittest.cc",
"wm/non_client_frame_controller_unittest.cc",
"wm/overlay_event_filter_unittest.cc",
"wm/overlay_layout_manager_unittest.cc",
"wm/overview/cleanup_animation_observer_unittest.cc",
"wm/overview/window_selector_unittest.cc",
"wm/resize_shadow_and_cursor_unittest.cc",
......
......@@ -48,6 +48,7 @@
#include "ash/wm/fullscreen_window_finder.h"
#include "ash/wm/lock_action_handler_layout_manager.h"
#include "ash/wm/lock_layout_manager.h"
#include "ash/wm/overlay_layout_manager.h"
#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/stacking_controller.h"
#include "ash/wm/switchable_windows.h"
......@@ -948,6 +949,8 @@ void RootWindowController::CreateContainers() {
lock_screen_related_containers);
wm::SetSnapsChildrenToPhysicalPixelBoundary(overlay_container);
overlay_container->SetProperty(::wm::kUsesScreenCoordinatesKey, true);
overlay_container->SetLayoutManager(
new OverlayLayoutManager(overlay_container)); // Takes ownership.
CreateContainer(kShellWindowId_DockedMagnifierContainer,
"DockedMagnifierContainer", lock_screen_related_containers);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/overlay_layout_manager.h"
#include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
using display::Screen;
namespace ash {
OverlayLayoutManager::OverlayLayoutManager(aura::Window* overlay_container)
: overlay_container_(overlay_container) {
DCHECK(overlay_container_);
Screen::GetScreen()->AddObserver(this);
}
OverlayLayoutManager::~OverlayLayoutManager() {
Screen::GetScreen()->RemoveObserver(this);
}
void OverlayLayoutManager::OnDisplayMetricsChanged(
const display::Display& display,
uint32_t changed_metrics) {
if (display.id() !=
Screen::GetScreen()->GetDisplayNearestWindow(overlay_container_).id()) {
// The update wasn't for this container's display.
return;
}
for (aura::Window* child : overlay_container_->children()) {
wm::WindowState* window_state = wm::GetWindowState(child);
if (window_state->IsFullscreen()) {
const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
window_state->OnWMEvent(&event);
}
}
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_OVERLAY_LAYOUT_MANAGER_H_
#define ASH_WM_OVERLAY_LAYOUT_MANAGER_H_
#include "ash/ash_export.h"
#include "ash/wm/wm_snap_to_pixel_layout_manager.h"
#include "base/macros.h"
#include "ui/display/display_observer.h"
namespace aura {
class Window;
}
namespace ash {
// Updates the bounds of widgets in the overlay container whenever the display
// bounds change. Keeps children snapped to pixel bounds.
class ASH_EXPORT OverlayLayoutManager : public wm::WmSnapToPixelLayoutManager,
public display::DisplayObserver {
public:
explicit OverlayLayoutManager(aura::Window* overlay_container);
~OverlayLayoutManager() override;
// display::DisplayObserver:
void OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) override;
private:
aura::Window* overlay_container_;
DISALLOW_COPY_AND_ASSIGN(OverlayLayoutManager);
};
} // namespace ash
#endif // ASH_WM_OVERLAY_LAYOUT_MANAGER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/overlay_layout_manager.h"
#include <memory>
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
using OverlayLayoutManagerTest = AshTestBase;
// Verifies that a fullscreen widget in the overlay container has its bounds
// updated when the display rotates. https://crbug.com/869130
TEST_F(OverlayLayoutManagerTest, FullscreenWidgetWithDisplayRotation) {
UpdateDisplay("800x600");
// Create a fullscreen widget in the overlay container.
std::unique_ptr<views::Widget> widget =
CreateTestWidget(nullptr, kShellWindowId_OverlayContainer);
widget->SetFullscreen(true);
EXPECT_EQ(gfx::Rect(0, 0, 800, 600), widget->GetWindowBoundsInScreen());
// Widget bounds update after display rotation.
UpdateDisplay("800x600/r");
EXPECT_EQ(gfx::Rect(0, 0, 600, 800), widget->GetWindowBoundsInScreen());
}
} // namespace
} // namespace ash
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