From e965001a732a6b573c374f6a3503e172df01e8ec Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 17 Jun 2013 13:18:16 +0100 Subject: [PATCH] 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 Reviewed-by: Colin Harrison --- hw/xwin/winclipboard.h | 3 +++ hw/xwin/winclipboardinit.c | 16 +--------------- hw/xwin/winclipboardthread.c | 25 +++++++++++++++++++------ hw/xwin/winglobals.c | 4 ---- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/hw/xwin/winclipboard.h b/hw/xwin/winclipboard.h index fa32c6253..41c0a538b 100644 --- a/hw/xwin/winclipboard.h +++ b/hw/xwin/winclipboard.h @@ -97,6 +97,9 @@ void void *winClipboardProc(char *szDisplay); +void +winClipboardWindowDestroy(void); + /* * winclipboardwndproc.c */ diff --git a/hw/xwin/winclipboardinit.c b/hw/xwin/winclipboardinit.c index 335e37920..d16c121c6 100644 --- a/hw/xwin/winclipboardinit.c +++ b/hw/xwin/winclipboardinit.c @@ -49,7 +49,6 @@ extern void winSetAuthorization(void); */ extern Bool g_fClipboard; -extern HWND g_hwndClipboard; extern Bool g_fClipboardStarted; /* @@ -135,12 +134,7 @@ winClipboardShutdown(void) /* Close down clipboard resources */ if (g_fClipboard && g_fClipboardStarted) { /* Synchronously destroy the clipboard window */ - if (g_hwndClipboard != NULL) { - SendMessage(g_hwndClipboard, WM_DESTROY, 0, 0); - /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */ - } - else - return; + winClipboardWindowDestroy(); /* Wait for the clipboard thread to exit */ pthread_join(g_ptClipboardProc, NULL); @@ -150,11 +144,3 @@ winClipboardShutdown(void) winDebug("winClipboardShutdown - Clipboard thread has exited.\n"); } } - -void -winFixClipboardChain(void) -{ - if (g_fClipboard && g_hwndClipboard) { - PostMessage(g_hwndClipboard, WM_WM_REINIT, 0, 0); - } -} diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 3d49606ba..2641e2099 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -57,12 +57,12 @@ extern Bool g_fUnicodeClipboard; extern Bool g_fClipboard; -extern HWND g_hwndClipboard; /* * Global variables */ +static HWND g_hwndClipboard = NULL; static jmp_buf g_jmpEntry; static XIOErrorHandler g_winClipboardOldIOErrorHandler; static pthread_t g_winClipboardProcThread; @@ -240,7 +240,7 @@ winClipboardProc(char *szDisplay) /* Create Windows messaging window */ hwnd = winClipboardCreateMessagingWindow(pDisplay, iWindow); - /* Save copy of HWND in screen privates */ + /* Save copy of HWND */ g_hwndClipboard = hwnd; /* Assert ownership of selections if Win32 clipboard is owned */ @@ -355,10 +355,7 @@ winClipboardProc(char *szDisplay) winClipboardProc_Done: /* Close our Windows window */ if (g_hwndClipboard) { - /* Destroy the Window window (hwnd) */ - winDebug("winClipboardProc - Destroy Windows window\n"); - PostMessage(g_hwndClipboard, WM_DESTROY, 0, 0); - winClipboardFlushWindowsMessageQueue(g_hwndClipboard); + winClipboardWindowDestroy(); } /* Close our X window */ @@ -489,3 +486,19 @@ winClipboardIOErrorHandler(Display * pDisplay) 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); + } +} diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index 8eaaf385a..ad82b83f6 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -94,7 +94,6 @@ winDispatchProcPtr winProcEstablishConnectionOrig = NULL; Bool g_fUnicodeClipboard = TRUE; Bool g_fClipboard = TRUE; Bool g_fClipboardStarted = FALSE; -HWND g_hwndClipboard = NULL; #endif /* @@ -106,7 +105,4 @@ void winInitializeGlobals(void) { g_dwCurrentThreadID = GetCurrentThreadId(); -#ifdef XWIN_CLIPBOARD - g_hwndClipboard = NULL; -#endif }