hw/xwin: Make g_hwndClipboard static

Move winFixClipboardChain() into winclipboardthread.c
Add winCLipboardWindowDestroy() function to access it for WM_DESTROY

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2013-06-17 13:18:16 +01:00
parent 03a59e7f78
commit e965001a73
4 changed files with 23 additions and 25 deletions

View File

@ -97,6 +97,9 @@ void
void *winClipboardProc(char *szDisplay); void *winClipboardProc(char *szDisplay);
void
winClipboardWindowDestroy(void);
/* /*
* winclipboardwndproc.c * winclipboardwndproc.c
*/ */

View File

@ -49,7 +49,6 @@ extern void winSetAuthorization(void);
*/ */
extern Bool g_fClipboard; extern Bool g_fClipboard;
extern HWND g_hwndClipboard;
extern Bool g_fClipboardStarted; extern Bool g_fClipboardStarted;
/* /*
@ -135,12 +134,7 @@ winClipboardShutdown(void)
/* Close down clipboard resources */ /* Close down clipboard resources */
if (g_fClipboard && g_fClipboardStarted) { if (g_fClipboard && g_fClipboardStarted) {
/* Synchronously destroy the clipboard window */ /* Synchronously destroy the clipboard window */
if (g_hwndClipboard != NULL) { winClipboardWindowDestroy();
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 */ /* Wait for the clipboard thread to exit */
pthread_join(g_ptClipboardProc, NULL); pthread_join(g_ptClipboardProc, NULL);
@ -150,11 +144,3 @@ winClipboardShutdown(void)
winDebug("winClipboardShutdown - Clipboard thread has exited.\n"); winDebug("winClipboardShutdown - Clipboard thread has exited.\n");
} }
} }
void
winFixClipboardChain(void)
{
if (g_fClipboard && g_hwndClipboard) {
PostMessage(g_hwndClipboard, WM_WM_REINIT, 0, 0);
}
}

View File

@ -57,12 +57,12 @@
extern Bool g_fUnicodeClipboard; extern Bool g_fUnicodeClipboard;
extern Bool g_fClipboard; extern Bool g_fClipboard;
extern HWND g_hwndClipboard;
/* /*
* Global variables * Global variables
*/ */
static HWND g_hwndClipboard = NULL;
static jmp_buf g_jmpEntry; static jmp_buf g_jmpEntry;
static XIOErrorHandler g_winClipboardOldIOErrorHandler; static XIOErrorHandler g_winClipboardOldIOErrorHandler;
static pthread_t g_winClipboardProcThread; static pthread_t g_winClipboardProcThread;
@ -240,7 +240,7 @@ winClipboardProc(char *szDisplay)
/* Create Windows messaging window */ /* Create Windows messaging window */
hwnd = winClipboardCreateMessagingWindow(pDisplay, iWindow); hwnd = winClipboardCreateMessagingWindow(pDisplay, iWindow);
/* Save copy of HWND in screen privates */ /* Save copy of HWND */
g_hwndClipboard = hwnd; g_hwndClipboard = hwnd;
/* Assert ownership of selections if Win32 clipboard is owned */ /* Assert ownership of selections if Win32 clipboard is owned */
@ -355,10 +355,7 @@ winClipboardProc(char *szDisplay)
winClipboardProc_Done: winClipboardProc_Done:
/* Close our Windows window */ /* Close our Windows window */
if (g_hwndClipboard) { if (g_hwndClipboard) {
/* Destroy the Window window (hwnd) */ winClipboardWindowDestroy();
winDebug("winClipboardProc - Destroy Windows window\n");
PostMessage(g_hwndClipboard, WM_DESTROY, 0, 0);
winClipboardFlushWindowsMessageQueue(g_hwndClipboard);
} }
/* Close our X window */ /* Close our X window */
@ -489,3 +486,19 @@ winClipboardIOErrorHandler(Display * pDisplay)
return 0; return 0;
} }
void
winClipboardWindowDestroy(void)
{
if (g_hwndClipboard) {
SendMessage(g_hwndClipboard, WM_DESTROY, 0, 0);
}
}
void
winFixClipboardChain(void)
{
if (g_hwndClipboard) {
PostMessage(g_hwndClipboard, WM_WM_REINIT, 0, 0);
}
}

View File

@ -94,7 +94,6 @@ winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
Bool g_fUnicodeClipboard = TRUE; Bool g_fUnicodeClipboard = TRUE;
Bool g_fClipboard = TRUE; Bool g_fClipboard = TRUE;
Bool g_fClipboardStarted = FALSE; Bool g_fClipboardStarted = FALSE;
HWND g_hwndClipboard = NULL;
#endif #endif
/* /*
@ -106,7 +105,4 @@ void
winInitializeGlobals(void) winInitializeGlobals(void)
{ {
g_dwCurrentThreadID = GetCurrentThreadId(); g_dwCurrentThreadID = GetCurrentThreadId();
#ifdef XWIN_CLIPBOARD
g_hwndClipboard = NULL;
#endif
} }