Commit 46931c64 authored by Qiang Xu's avatar Qiang Xu Committed by Commit Bot

cros: ensure minimum window visibility for setting arc window bounds

changes:
Applying minimum window visibility (25DIPs) when setting arc window
bounds.

Bug: 806094
Test: tested on device
Change-Id: Ia89080bfc4a984395dea327e2ed3ab6229c43467
Reviewed-on: https://chromium-review.googlesource.com/899961Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Commit-Queue: Qiang Xu <warx@google.com>
Cr-Commit-Position: refs/heads/master@{#536879}
parent 53cddfe6
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/public/cpp/window_state_type.h" #include "ash/public/cpp/window_state_type.h"
#include "ash/public/interfaces/window_pin_type.mojom.h" #include "ash/public/interfaces/window_pin_type.mojom.h"
#include "ash/screen_util.h"
#include "ash/wm/drag_window_resizer.h" #include "ash/wm/drag_window_resizer.h"
#include "ash/wm/window_positioning_utils.h"
#include "ash/wm/window_resizer.h" #include "ash/wm/window_resizer.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/window_state_delegate.h" #include "ash/wm/window_state_delegate.h"
...@@ -1219,6 +1221,14 @@ void ShellSurfaceBase::UpdateWidgetBounds() { ...@@ -1219,6 +1221,14 @@ void ShellSurfaceBase::UpdateWidgetBounds() {
visible_bounds); visible_bounds);
new_widget_bounds.set_origin(GetWidgetOrigin()); new_widget_bounds.set_origin(GetWidgetOrigin());
// Adjust window bounds to ensure minimum window visibility.
aura::Window* window = widget_->GetNativeWindow();
wm::ConvertRectFromScreen(window->GetRootWindow(), &new_widget_bounds);
gfx::Rect display_area = ash::screen_util::GetDisplayBoundsInParent(window);
ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(display_area,
&new_widget_bounds);
wm::ConvertRectToScreen(window->GetRootWindow(), &new_widget_bounds);
// Set |ignore_window_bounds_changes_| as this change to window bounds // Set |ignore_window_bounds_changes_| as this change to window bounds
// should not result in a configure request. // should not result in a configure request.
DCHECK(!ignore_window_bounds_changes_); DCHECK(!ignore_window_bounds_changes_);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_port.h" #include "ash/shell_port.h"
#include "ash/shell_test_api.h" #include "ash/shell_test_api.h"
#include "ash/wm/window_positioning_utils.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h" #include "ash/wm/wm_event.h"
#include "ash/wm/workspace/workspace_window_resizer.h" #include "ash/wm/workspace/workspace_window_resizer.h"
...@@ -476,5 +477,30 @@ TEST_F(ShellSurfaceTest, ToggleFullscreen) { ...@@ -476,5 +477,30 @@ TEST_F(ShellSurfaceTest, ToggleFullscreen) {
shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); shell_surface->GetWidget()->GetWindowBoundsInScreen().width());
} }
TEST_F(ShellSurfaceTest, EnsureMinimumVisibility) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
gfx::Size content_size(100, 100);
gfx::Rect original_bounds(gfx::Point(16, 16), content_size);
shell_surface->SetGeometry(original_bounds);
surface->Attach(buffer.get());
surface->Commit();
display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
int display_width = display.bounds().width();
gfx::Rect new_bounds(gfx::Point(display_width + 100, 10), content_size);
shell_surface->GetWidget()->SetBounds(new_bounds);
surface->Commit();
const gfx::Rect expected_bounds(display_width - ash::wm::kMinimumOnScreenArea,
10, 100, 100);
EXPECT_EQ(expected_bounds,
shell_surface->GetWidget()->GetWindowBoundsInScreen());
}
} // namespace } // namespace
} // namespace exo } // namespace exo
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