Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[wayland] Clear exposure of windows when client rendering is disabled…
…. Contributes to JB#42628

Setting the window visiblity to Hidden hides the window and
effectively destroys the window surface. Send an empty exposure
event instead so the client will stop rendering to the surface
without actually hiding the window.
  • Loading branch information
denexter committed Aug 28, 2018
1 parent a734dcb commit 37fbb80
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/client/qwaylandextendedsurface.cpp
Expand Up @@ -56,6 +56,7 @@ namespace QtWaylandClient {
QWaylandExtendedSurface::QWaylandExtendedSurface(QWaylandWindow *window)
: QtWayland::qt_extended_surface(window->display()->windowExtension()->get_extended_surface(window->object()))
, m_window(window)
, m_clientRenderingEnabled(true)
{
}

Expand All @@ -64,6 +65,11 @@ QWaylandExtendedSurface::~QWaylandExtendedSurface()
qt_extended_surface_destroy(object());
}

bool QWaylandExtendedSurface::isClientRenderingEnabled() const
{
return m_clientRenderingEnabled;
}

void QWaylandExtendedSurface::updateGenericProperty(const QString &name, const QVariant &value)
{
QByteArray byteValue;
Expand All @@ -89,6 +95,22 @@ void QWaylandExtendedSurface::setContentOrientationMask(Qt::ScreenOrientations m
set_content_orientation_mask(wlmask);
}

void QWaylandExtendedSurface::extended_surface_client_rendering_enabled(int enabled)
{

if (m_clientRenderingEnabled != (enabled != 0)) {
m_clientRenderingEnabled = enabled != 0;

QWindow * const window = m_window->window();

if (window->isVisible()) {
QWindowSystemInterface::handleExposeEvent(window, m_clientRenderingEnabled
? QRect(QPoint(), m_window->geometry().size())
: QRect());
}
}
}

void QWaylandExtendedSurface::extended_surface_onscreen_visibility(int32_t visibility)
{
m_window->window()->setVisibility(static_cast<QWindow::Visibility>(visibility));
Expand Down
4 changes: 4 additions & 0 deletions src/client/qwaylandextendedsurface_p.h
Expand Up @@ -72,6 +72,8 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandExtendedSurface : public QtWayland::qt_ext
QWaylandExtendedSurface(QWaylandWindow *window);
~QWaylandExtendedSurface();

bool isClientRenderingEnabled() const;

void setContentOrientationMask(Qt::ScreenOrientations mask);

void updateGenericProperty(const QString &name, const QVariant &value);
Expand All @@ -80,11 +82,13 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandExtendedSurface : public QtWayland::qt_ext

private:
void extended_surface_onscreen_visibility(int32_t visibility) override;
void extended_surface_client_rendering_enabled(int enabled) override;
void extended_surface_set_generic_property(const QString &name, wl_array *value) override;
void extended_surface_close() override;

QWaylandWindow *m_window;
QVariantMap m_properties;
bool m_clientRenderingEnabled;
};

}
Expand Down
10 changes: 10 additions & 0 deletions src/client/qwaylandwlshellsurface.cpp
Expand Up @@ -123,6 +123,16 @@ void QWaylandWlShellSurface::sendProperty(const QString &name, const QVariant &v
m_extendedWindow->updateGenericProperty(name, value);
}

bool QWaylandWlShellSurface::isExposed() const
{
return !m_extendedWindow || m_extendedWindow->isClientRenderingEnabled();
}

bool QWaylandWlShellSurface::handleExpose(const QRegion &)
{
return m_extendedWindow && !m_extendedWindow->isClientRenderingEnabled();
}

void QWaylandWlShellSurface::setMaximized()
{
m_maximized = true;
Expand Down
3 changes: 3 additions & 0 deletions src/client/qwaylandwlshellsurface_p.h
Expand Up @@ -92,6 +92,9 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfa
void setWindowFlags(Qt::WindowFlags flags) override;
void sendProperty(const QString &name, const QVariant &value) override;

bool isExposed() const override;
bool handleExpose(const QRegion &) override;

void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/compositor/extensions/qwlextendedsurface.cpp
Expand Up @@ -83,7 +83,7 @@ void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &v

void ExtendedSurface::sendOnScreenVisibilityChange(bool onScreen)
{
setVisibility(onScreen ? QWindow::AutomaticVisibility : QWindow::Hidden);
send_client_rendering_enabled(onScreen ? 1 : 0);
}

void ExtendedSurface::setVisibility(QWindow::Visibility visibility)
Expand Down
4 changes: 4 additions & 0 deletions src/extensions/surface-extension.xml
Expand Up @@ -50,6 +50,10 @@
<arg name="visible" type="int"/>
</event>

<event name="client_rendering_enabled">
<arg name="enabled" type="int"/>
</event>

<event name="set_generic_property">
<arg name="name" type="string"/>
<arg name="value" type="array"/>
Expand Down

0 comments on commit 37fbb80

Please sign in to comment.