aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winclipboardinit.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xwin/winclipboardinit.c')
-rw-r--r--xorg-server/hw/xwin/winclipboardinit.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/xorg-server/hw/xwin/winclipboardinit.c b/xorg-server/hw/xwin/winclipboardinit.c
index 8aef8fe02..6451acaa5 100644
--- a/xorg-server/hw/xwin/winclipboardinit.c
+++ b/xorg-server/hw/xwin/winclipboardinit.c
@@ -46,7 +46,7 @@
* Local variables
*/
-static pthread_t g_ptClipboardProc;
+int winProcSetSelectionOwner(ClientPtr /* client */ );
/*
*
@@ -79,9 +79,6 @@ winClipboardThreadProc(void *arg)
/* Print the display connection string */
ErrorF("winClipboardThreadProc - DISPLAY=%s\n", szDisplay);
- /* Flag that clipboard client has been launched */
- g_fClipboardStarted = TRUE;
-
fShutdown = winClipboardProc(g_fUnicodeClipboard, szDisplay);
/* Flag that clipboard client has stopped */
@@ -114,6 +111,12 @@ winInitClipboard(void)
{
winDebug("winInitClipboard ()\n");
+ /* Wrap some internal server functions */
+ if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner) {
+ winProcSetSelectionOwnerOrig = ProcVector[X_SetSelectionOwner];
+ ProcVector[X_SetSelectionOwner] = winProcSetSelectionOwner;
+ }
+
/* Spawn a thread for the Clipboard module */
if (pthread_create(&g_ptClipboardProc, NULL, winClipboardThreadProc, NULL)) {
/* Bail if thread creation failed */
@@ -127,16 +130,21 @@ winInitClipboard(void)
void
winClipboardShutdown(void)
{
- /* Close down clipboard resources */
- if (g_fClipboard && g_fClipboardStarted) {
- /* Synchronously destroy the clipboard window */
- winClipboardWindowDestroy();
-
- /* Wait for the clipboard thread to exit */
- pthread_join(g_ptClipboardProc, NULL);
-
- g_fClipboardStarted = FALSE;
-
- winDebug("winClipboardShutdown - Clipboard thread has exited.\n");
- }
+ /* Close down clipboard resources */
+ if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted) {
+ /* Synchronously destroy the clipboard window */
+ if (g_hwndClipboard != NULL) {
+ g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
+ SendMessage(g_hwndClipboard, WM_DESTROY, 0, 0);
+ /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */
+ }
+ else
+ return;
+
+ /* Wait for the clipboard thread to exit */
+ pthread_join(g_ptClipboardProc, NULL);
+
+ winDebug("winClipboardShutdown - Clipboard thread has exited.\n");
+ }
}
+