diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 2af0ba9b89..9637ddf7ae 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -350,6 +350,18 @@ fDesktop->LockSingleWindow(); } +void +ServerWindow::RequestRedraw() +{ + PostMessage(AS_REDRAW, 0); + // we don't care if this fails - it's only a notification, and if + // it fails, there are obviously enough messages in the queue + // already + + atomic_add(&fRedrawRequested, 1); +} + + void ServerWindow::SetTitle(const char* newTitle) { @@ -862,9 +874,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) } case AS_REDRAW: - // command issued by Desktop only (via WindowLayer::ProcessDirtyRegion()) - DTRACE(("ServerWindow %s: AS_REDRAW\n", Title())); - fWindowLayer->RedrawDirtyRegion(); + // Nothing to do here - the redraws are actually handled by looking + // at the fRedrawRequested member variable in _MessageLooper(). break; case AS_BEGIN_UPDATE: @@ -2169,6 +2180,10 @@ ServerWindow::_MessageLooper() CRITICAL("ServerWindow: a window must be hidden before it's deleted\n"); } else { fDesktop->LockSingleWindow(); + + if (atomic_and(&fRedrawRequested, 0) != 0) + fWindowLayer->RedrawDirtyRegion(); + _DispatchMessage(code, receiver); fDesktop->UnlockSingleWindow(); } diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index 11e868ecea..781a12d746 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -102,6 +102,8 @@ public: inline int32 ClientToken() const { return fClientToken; } inline int32 ServerToken() const { return fServerToken; } + void RequestRedraw(); + void GetInfo(window_info& info); private: @@ -150,6 +152,7 @@ private: ::EventTarget fEventTarget; BMessage fClientViewsWithInvalidCoords; + int32 fRedrawRequested; int32 fServerToken; int32 fClientToken; diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index 8a79b3472b..03b80e2d28 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -624,7 +624,7 @@ WindowLayer::ProcessDirtyRegion(BRegion& region) // Until the message is processed in the window // thread, the desktop thread can add parts to // the region as it likes. - ServerWindow()->PostMessage(AS_REDRAW); + ServerWindow()->RequestRedraw(); } // this is executed from the desktop thread