From a3d502338d9db0407232ff7c05ccacd73b47de7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 28 Jun 2013 14:23:22 +0200 Subject: [PATCH] delay adding Unmanaged clients by 50ms This provides some sort of synthetic XSYNC support for unmanaged clients and allows them to do an initial update after mapping and before being painted (prevent flicker) Also it helps with Unmanaged clients performing quick map/unmap/map cycles what also seems to induce the black window issue on the nvidia blob. CCBUG: 284888 BUG: 319184 FIXED-IN: 4.11 REVIEW: 111292 --- effects.cpp | 14 +++++++++++--- effects.h | 1 + toplevel.h | 2 +- unmanaged.cpp | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/effects.cpp b/effects.cpp index b07004ad3d..11781d6751 100644 --- a/effects.cpp +++ b/effects.cpp @@ -555,9 +555,9 @@ void EffectsHandlerImpl::slotClientAdded(Client *c) } void EffectsHandlerImpl::slotUnmanagedAdded(Unmanaged *u) -{ // regardless, unmanaged windows are -yet?- not synced anyway - setupUnmanagedConnections(u); - emit windowAdded(u->effectWindow()); +{ + // it's never initially ready but has synthetic 50ms delay + connect(u, SIGNAL(windowShown(KWin::Toplevel*)), SLOT(slotUnmanagedShown(KWin::Toplevel*))); } void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *t) @@ -569,6 +569,14 @@ void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *t) emit windowAdded(c->effectWindow()); } +void EffectsHandlerImpl::slotUnmanagedShown(KWin::Toplevel *t) +{ // regardless, unmanaged windows are -yet?- not synced anyway + Q_ASSERT(dynamic_cast(t)); + Unmanaged *u = static_cast(t); + setupUnmanagedConnections(u); + emit windowAdded(u->effectWindow()); +} + void EffectsHandlerImpl::slotDeletedRemoved(KWin::Deleted *d) { emit windowDeleted(d->effectWindow()); diff --git a/effects.h b/effects.h index 17dc4d9002..b641bfbe7d 100644 --- a/effects.h +++ b/effects.h @@ -217,6 +217,7 @@ protected Q_SLOTS: void slotClientAdded(KWin::Client *c); void slotClientShown(KWin::Toplevel*); void slotUnmanagedAdded(KWin::Unmanaged *u); + void slotUnmanagedShown(KWin::Toplevel*); void slotWindowClosed(KWin::Toplevel *c); void slotClientActivated(KWin::Client *c); void slotDeletedRemoved(KWin::Deleted *d); diff --git a/toplevel.h b/toplevel.h index 3ad7563d4f..83b1512c0c 100644 --- a/toplevel.h +++ b/toplevel.h @@ -342,6 +342,7 @@ protected Q_SLOTS: void checkScreen(); void setupCheckScreenConnection(); void removeCheckScreenConnection(); + void setReadyForPainting(); protected: virtual ~Toplevel(); @@ -353,7 +354,6 @@ protected: void addDamageFull(); void getWmClientLeader(); void getWmClientMachine(); - void setReadyForPainting(); /** * @returns Whether there is a compositor and it is active. **/ diff --git a/unmanaged.cpp b/unmanaged.cpp index f782180a87..4583ce076f 100644 --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -25,6 +25,7 @@ along with this program. If not, see . #include "deleted.h" #include "xcbutils.h" +#include #include #include @@ -35,7 +36,9 @@ namespace KWin Unmanaged::Unmanaged() : Toplevel() { + ready_for_painting = false; connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SIGNAL(geometryChanged())); + QTimer::singleShot(50, this, SLOT(setReadyForPainting())); } Unmanaged::~Unmanaged()