Commit 369b768f authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

wayland: Mark Xwayland windows ready for painting when mapped

This makes the logic that determines when Xwayland windows can be marked
as ready for painting more robust.

At the moment, we call setReadyForPainting() when the surface is damaged,
but we want Toplevel stop managing damages.
parent 0bb5a51d
......@@ -21,6 +21,10 @@
#include <xcb/shape.h>
#include <KWaylandServer/surface_interface.h>
using namespace KWaylandServer;
namespace KWin
{
......@@ -34,13 +38,36 @@ const NET::WindowTypes SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK = NET::NormalMask |
Unmanaged::Unmanaged()
: Toplevel()
{
QTimer::singleShot(50, this, &Unmanaged::setReadyForPainting);
switch (kwinApp()->operationMode()) {
case Application::OperationModeXwayland:
if (surface()) {
associate();
} else {
connect(this, &Toplevel::surfaceChanged, this, &Unmanaged::associate);
}
break;
case Application::OperationModeX11:
// It's probably not ready for painting yet, show it after synthetic 50ms delay.
QTimer::singleShot(50, this, &Unmanaged::setReadyForPainting);
break;
case Application::OperationModeWaylandOnly:
Q_UNREACHABLE();
}
}
Unmanaged::~Unmanaged()
{
}
void Unmanaged::associate()
{
if (surface()->isMapped()) {
setReadyForPainting();
} else {
connect(surface(), &SurfaceInterface::mapped, this, &Unmanaged::setReadyForPainting);
}
}
bool Unmanaged::track(xcb_window_t w)
{
XServerGrabber xserverGrabber;
......
......@@ -48,6 +48,7 @@ private:
// handlers for X11 events
void configureNotifyEvent(xcb_configure_notify_event_t *e);
QWindow *findInternalWindow() const;
void associate();
bool m_outline = false;
bool m_scheduledRelease = false;
};
......
......@@ -9,9 +9,37 @@
#include "xwaylandclient.h"
#include <KWaylandServer/surface_interface.h>
using namespace KWaylandServer;
namespace KWin
{
XwaylandClient::XwaylandClient()
{
if (surface()) {
associate();
} else {
connect(this, &Toplevel::surfaceChanged, this, &XwaylandClient::associate);
}
}
void XwaylandClient::associate()
{
if (surface()->isMapped()) {
initialize();
} else {
connect(surface(), &SurfaceInterface::mapped, this, &XwaylandClient::initialize);
}
}
void XwaylandClient::initialize()
{
setReadyForPainting();
setupWindowManagementInterface();
}
bool XwaylandClient::wantsSyncCounter() const
{
// When the frame window is resized, the attached buffer will be destroyed by
......
......@@ -22,7 +22,13 @@ class XwaylandClient : public X11Client
Q_OBJECT
public:
explicit XwaylandClient();
bool wantsSyncCounter() const override;
private:
void associate();
void initialize();
};
} // namespace KWin
Supports Markdown
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