Commit f77a12bd authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11 and Ozone: Move IsVisible to DWTHPlatform

This moves IsVisible impl from DWTHX11 to DWTHPlatform
and adds IsVisible() method to PlatformWindow.

Scenic and Windows implementations are not implemented and
return true.

Drm's implementation is set to NOTREACHED as it is not expected
that the DrmWindowHost::IsVisible is ever called.

X11 and Wayland implementations return visibility for unminimized
windows and mapped windows (in case of Wayland, it means that
either xdg_surface or xdg_popup exist).

Bug: 990756
Change-Id: I09ff60a9064ea5bef674d202c5bee994e238c496
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807239Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#699654}
parent 51154657
......@@ -478,7 +478,7 @@ void XWindow::SetFullscreen(bool fullscreen) {
}
void XWindow::Activate() {
if (!IsVisible() || !activatable_)
if (!IsXWindowVisible() || !activatable_)
return;
BeforeActivationStateChanged();
......@@ -611,7 +611,7 @@ void XWindow::SetBounds(const gfx::Rect& requested_bounds_in_pixels) {
bounds_in_pixels_ = bounds_in_pixels;
}
bool XWindow::IsVisible() const {
bool XWindow::IsXWindowVisible() const {
// On Windows, IsVisible() returns true for minimized windows. On X11, a
// minimized window is not mapped, so an explicit IsMinimized() check is
// necessary.
......
......@@ -111,7 +111,7 @@ class COMPONENT_EXPORT(UI_BASE_X) XWindow {
void SetSize(const gfx::Size& size_in_pixels);
void SetBounds(const gfx::Rect& requested_bounds);
bool IsVisible() const;
bool IsXWindowVisible() const;
bool IsMinimized() const;
bool IsMaximized() const;
bool IsFullscreen() const;
......
......@@ -74,6 +74,11 @@ void DrmWindowHost::Hide() {
void DrmWindowHost::Close() {
}
bool DrmWindowHost::IsVisible() const {
NOTREACHED();
return true;
}
void DrmWindowHost::PrepareForShutdown() {}
void DrmWindowHost::SetBounds(const gfx::Rect& bounds) {
......
......@@ -61,6 +61,7 @@ class DrmWindowHost : public PlatformWindow,
void Show() override;
void Hide() override;
void Close() override;
bool IsVisible() const override;
void PrepareForShutdown() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
......
......@@ -102,6 +102,11 @@ void ScenicWindow::Close() {
delegate_->OnClosed();
}
bool ScenicWindow::IsVisible() const {
NOTIMPLEMENTED_LOG_ONCE();
return true;
}
void ScenicWindow::PrepareForShutdown() {
NOTIMPLEMENTED();
}
......
......@@ -53,6 +53,7 @@ class COMPONENT_EXPORT(OZONE) ScenicWindow
void Show() override;
void Hide() override;
void Close() override;
bool IsVisible() const override;
void PrepareForShutdown() override;
void SetCapture() override;
void ReleaseCapture() override;
......
......@@ -374,6 +374,12 @@ void WaylandWindow::Close() {
delegate_->OnClosed();
}
bool WaylandWindow::IsVisible() const {
// X and Windows return true if the window is minimized. For consistency, do
// the same.
return (!!xdg_surface_ || !!xdg_popup_) || IsMinimized();
}
void WaylandWindow::PrepareForShutdown() {}
void WaylandWindow::SetBounds(const gfx::Rect& bounds_px) {
......
......@@ -116,6 +116,7 @@ class WaylandWindow : public PlatformWindow,
void Show() override;
void Hide() override;
void Close() override;
bool IsVisible() const override;
void PrepareForShutdown() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
......
......@@ -34,6 +34,8 @@ class PlatformWindow : public PropertyHandler {
virtual void Hide() = 0;
virtual void Close() = 0;
virtual bool IsVisible() const = 0;
// Informs the window it is going to be destroyed sometime soon. This is only
// called for specific code paths, for example by Ash, so it shouldn't be
// assumed this will get called before destruction.
......
......@@ -28,6 +28,11 @@ void StubWindow::Close() {
delegate_->OnClosed();
}
bool StubWindow::IsVisible() const {
NOTIMPLEMENTED_LOG_ONCE();
return true;
}
void StubWindow::PrepareForShutdown() {}
void StubWindow::SetBounds(const gfx::Rect& bounds) {
......
......@@ -31,6 +31,7 @@ class STUB_WINDOW_EXPORT StubWindow : public PlatformWindow {
void Show() override;
void Hide() override;
void Close() override;
bool IsVisible() const override;
void PrepareForShutdown() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
......
......@@ -75,6 +75,11 @@ void WinWindow::Close() {
Destroy();
}
bool WinWindow::IsVisible() const {
NOTIMPLEMENTED_LOG_ONCE();
return true;
}
void WinWindow::PrepareForShutdown() {}
void WinWindow::SetBounds(const gfx::Rect& bounds) {
......
......@@ -30,6 +30,7 @@ class WIN_WINDOW_EXPORT WinWindow : public PlatformWindow,
void Show() override;
void Hide() override;
void Close() override;
bool IsVisible() const override;
void PrepareForShutdown() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
......
......@@ -113,6 +113,10 @@ void X11Window::Close() {
platform_window_delegate_->OnClosed();
}
bool X11Window::IsVisible() const {
return XWindow::IsXWindowVisible();
}
void X11Window::PrepareForShutdown() {
PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
}
......
......@@ -49,6 +49,7 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
void Show() override;
void Hide() override;
void Close() override;
bool IsVisible() const override;
void PrepareForShutdown() override;
void SetBounds(const gfx::Rect& bounds) override;
gfx::Rect GetBounds() override;
......
......@@ -33,6 +33,7 @@ class FakePlatformWindow : public ui::PlatformWindow, public ui::WmDragHandler {
void Show() override {}
void Hide() override {}
void Close() override {}
bool IsVisible() const override { return true; }
void PrepareForShutdown() override {}
void SetBounds(const gfx::Rect& bounds) override {}
gfx::Rect GetBounds() override { return gfx::Rect(); }
......
......@@ -277,9 +277,7 @@ void DesktopWindowTreeHostPlatform::Show(ui::WindowShowState show_state,
}
bool DesktopWindowTreeHostPlatform::IsVisible() const {
// TODO: needs PlatformWindow support.
NOTIMPLEMENTED_LOG_ONCE();
return true;
return platform_window()->IsVisible();
}
void DesktopWindowTreeHostPlatform::SetSize(const gfx::Size& size) {
......@@ -572,7 +570,7 @@ bool DesktopWindowTreeHostPlatform::ShouldCreateVisibilityController() const {
gfx::Transform DesktopWindowTreeHostPlatform::GetRootTransform() const {
display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
if (IsVisible()) {
if (platform_window() && IsVisible()) {
display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetWidget()->GetNativeWindow());
}
......
......@@ -280,10 +280,6 @@ void DesktopWindowTreeHostX11::Show(ui::WindowShowState show_state,
content_window()->Show();
}
bool DesktopWindowTreeHostX11::IsVisible() const {
return platform_window() ? GetXWindow()->IsVisible() : false;
}
void DesktopWindowTreeHostX11::SetSize(const gfx::Size& requested_size) {
gfx::Size size_in_pixels = ToPixelRect(gfx::Rect(requested_size)).size();
size_in_pixels = AdjustSizeForDisplay(size_in_pixels);
......
......@@ -96,7 +96,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
DesktopNativeCursorManager* cursor_manager) override;
void Show(ui::WindowShowState show_state,
const gfx::Rect& restore_bounds) override;
bool IsVisible() const override;
void SetSize(const gfx::Size& requested_size) override;
void GetWindowPlacement(gfx::Rect* bounds,
ui::WindowShowState* show_state) const override;
......
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