diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index a68fb990eb..db08174242 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -1006,14 +1006,21 @@ BView::SetViewCursor(const BCursor *cursor, bool sync) fOwner->fLink->StartMessage(AS_LAYER_SET_CURSOR); fOwner->fLink->Attach(cursor->fServerToken); + fOwner->fLink->Attach(sync); if (!sync) { cursor->fPendingViewCursor = true; // this avoids a race condition in case the cursor is // immediately deleted after this call, as the deletion // is handled by the application, not the window - } else - fOwner->fLink->Flush(); + } else { + // make sure the server has processed the + // message and "acquired" the cursor in + // the window thread before returning from + // this function + int32 code; + fOwner->fLink->FlushWithReply(code); + } } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 57456b9ce4..232d1af79f 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1254,7 +1254,9 @@ ServerWindow::_DispatchViewMessage(int32 code, fCurrentLayer->Name())); int32 token; - if (link.Read(&token) != B_OK) + bool sync; + link.Read(&token); + if (link.Read(&sync) != B_OK) break; ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token); @@ -1265,6 +1267,12 @@ ServerWindow::_DispatchViewMessage(int32 code, if (fDesktop->ViewUnderMouse(fWindowLayer) == fCurrentLayer->Token()) fServerApp->SetCurrentCursor(cursor); } + if (sync) { + // sync the client (it can now delete the cursor) + fLink.StartMessage(B_OK); + fLink.Flush(); + } + break; } case AS_LAYER_SET_FLAGS: