hw/xwin: Eliminate g_pClipboardDisplay and g_iClipboardWindow globals
Eliminate the g_pClipboardDisplay and g_iClipboardWindow globals used to make those values available to the clipboard wndproc, by passing them in via the WM_CREATE message instead. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
229a0a83a4
commit
a3c1e405cb
|
@ -107,6 +107,12 @@ BOOL winClipboardFlushWindowsMessageQueue(HWND hwnd);
|
||||||
LRESULT CALLBACK
|
LRESULT CALLBACK
|
||||||
winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Display *pClipboardDisplay;
|
||||||
|
Window iClipboardWindow;
|
||||||
|
} ClipboardWindowCreationParams;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* winclipboardxevents.c
|
* winclipboardxevents.c
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,8 +58,6 @@
|
||||||
extern Bool g_fUnicodeClipboard;
|
extern Bool g_fUnicodeClipboard;
|
||||||
extern Bool g_fClipboard;
|
extern Bool g_fClipboard;
|
||||||
extern HWND g_hwndClipboard;
|
extern HWND g_hwndClipboard;
|
||||||
extern void *g_pClipboardDisplay;
|
|
||||||
extern Window g_iClipboardWindow;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
|
@ -78,7 +76,7 @@ int xfixes_error_base;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static HWND
|
static HWND
|
||||||
winClipboardCreateMessagingWindow(void);
|
winClipboardCreateMessagingWindow(Display *pDisplay, Window iWindow);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
winClipboardErrorHandler(Display * pDisplay, XErrorEvent * pErr);
|
winClipboardErrorHandler(Display * pDisplay, XErrorEvent * pErr);
|
||||||
|
@ -192,9 +190,6 @@ winClipboardProc(void *pvNotUsed)
|
||||||
goto winClipboardProc_Done;
|
goto winClipboardProc_Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the display in a global used by the wndproc */
|
|
||||||
g_pClipboardDisplay = pDisplay;
|
|
||||||
|
|
||||||
ErrorF("winClipboardProc - XOpenDisplay () returned and "
|
ErrorF("winClipboardProc - XOpenDisplay () returned and "
|
||||||
"successfully opened the display.\n");
|
"successfully opened the display.\n");
|
||||||
|
|
||||||
|
@ -255,14 +250,11 @@ winClipboardProc(void *pvNotUsed)
|
||||||
XFixesSelectionWindowDestroyNotifyMask |
|
XFixesSelectionWindowDestroyNotifyMask |
|
||||||
XFixesSelectionClientCloseNotifyMask);
|
XFixesSelectionClientCloseNotifyMask);
|
||||||
|
|
||||||
/* Save the window in the screen privates */
|
|
||||||
g_iClipboardWindow = iWindow;
|
|
||||||
|
|
||||||
/* Initialize monitored selection state */
|
/* Initialize monitored selection state */
|
||||||
winClipboardInitMonitoredSelections();
|
winClipboardInitMonitoredSelections();
|
||||||
|
|
||||||
/* Create Windows messaging window */
|
/* Create Windows messaging window */
|
||||||
hwnd = winClipboardCreateMessagingWindow();
|
hwnd = winClipboardCreateMessagingWindow(pDisplay, iWindow);
|
||||||
|
|
||||||
/* Save copy of HWND in screen privates */
|
/* Save copy of HWND in screen privates */
|
||||||
g_hwndClipboard = hwnd;
|
g_hwndClipboard = hwnd;
|
||||||
|
@ -419,8 +411,6 @@ winClipboardProc(void *pvNotUsed)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* global clipboard variable reset */
|
/* global clipboard variable reset */
|
||||||
g_iClipboardWindow = None;
|
|
||||||
g_pClipboardDisplay = NULL;
|
|
||||||
g_hwndClipboard = NULL;
|
g_hwndClipboard = NULL;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -431,9 +421,10 @@ winClipboardProc(void *pvNotUsed)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static HWND
|
static HWND
|
||||||
winClipboardCreateMessagingWindow(void)
|
winClipboardCreateMessagingWindow(Display *pDisplay, Window iWindow)
|
||||||
{
|
{
|
||||||
WNDCLASSEX wc;
|
WNDCLASSEX wc;
|
||||||
|
ClipboardWindowCreationParams cwcp;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
|
||||||
/* Setup our window class */
|
/* Setup our window class */
|
||||||
|
@ -451,6 +442,10 @@ winClipboardCreateMessagingWindow(void)
|
||||||
wc.hIconSm = 0;
|
wc.hIconSm = 0;
|
||||||
RegisterClassEx(&wc);
|
RegisterClassEx(&wc);
|
||||||
|
|
||||||
|
/* Information to be passed to WM_CREATE */
|
||||||
|
cwcp.pClipboardDisplay = pDisplay;
|
||||||
|
cwcp.iClipboardWindow = iWindow;
|
||||||
|
|
||||||
/* Create the window */
|
/* Create the window */
|
||||||
hwnd = CreateWindowExA(0, /* Extended styles */
|
hwnd = CreateWindowExA(0, /* Extended styles */
|
||||||
WIN_CLIPBOARD_WINDOW_CLASS, /* Class name */
|
WIN_CLIPBOARD_WINDOW_CLASS, /* Class name */
|
||||||
|
@ -463,7 +458,7 @@ winClipboardCreateMessagingWindow(void)
|
||||||
(HWND) NULL, /* No parent or owner window */
|
(HWND) NULL, /* No parent or owner window */
|
||||||
(HMENU) NULL, /* No menu */
|
(HMENU) NULL, /* No menu */
|
||||||
GetModuleHandle(NULL), /* Instance handle */
|
GetModuleHandle(NULL), /* Instance handle */
|
||||||
NULL); /* Creation data */
|
&cwcp); /* Creation data */
|
||||||
assert(hwnd != NULL);
|
assert(hwnd != NULL);
|
||||||
|
|
||||||
/* I'm not sure, but we may need to call this to start message processing */
|
/* I'm not sure, but we may need to call this to start message processing */
|
||||||
|
|
|
@ -44,12 +44,6 @@
|
||||||
|
|
||||||
#define WIN_POLL_TIMEOUT 1
|
#define WIN_POLL_TIMEOUT 1
|
||||||
|
|
||||||
/*
|
|
||||||
* References to external symbols
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern void *g_pClipboardDisplay;
|
|
||||||
extern Window g_iClipboardWindow;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process X events up to specified timeout
|
* Process X events up to specified timeout
|
||||||
|
@ -138,6 +132,8 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static HWND s_hwndNextViewer;
|
static HWND s_hwndNextViewer;
|
||||||
static Bool s_fCBCInitialized;
|
static Bool s_fCBCInitialized;
|
||||||
|
static Display *pDisplay;
|
||||||
|
static Window iWindow;
|
||||||
|
|
||||||
/* Branch on message type */
|
/* Branch on message type */
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
@ -158,9 +154,13 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HWND first, next;
|
HWND first, next;
|
||||||
DWORD error_code = 0;
|
DWORD error_code = 0;
|
||||||
|
ClipboardWindowCreationParams *cwcp = (ClipboardWindowCreationParams *)((CREATESTRUCT *)lParam)->lpCreateParams;
|
||||||
|
|
||||||
winDebug("winClipboardWindowProc - WM_CREATE\n");
|
winDebug("winClipboardWindowProc - WM_CREATE\n");
|
||||||
|
|
||||||
|
pDisplay = cwcp->pClipboardDisplay;
|
||||||
|
iWindow = cwcp->iClipboardWindow;
|
||||||
|
|
||||||
first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
|
first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
|
||||||
if (first == hwnd)
|
if (first == hwnd)
|
||||||
return 0; /* Make sure it's not us! */
|
return 0; /* Make sure it's not us! */
|
||||||
|
@ -243,8 +243,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
static Atom atomClipboard;
|
static Atom atomClipboard;
|
||||||
static int generation;
|
static int generation;
|
||||||
static Bool s_fProcessingDrawClipboard = FALSE;
|
static Bool s_fProcessingDrawClipboard = FALSE;
|
||||||
Display *pDisplay = g_pClipboardDisplay;
|
|
||||||
Window iWindow = g_iClipboardWindow;
|
|
||||||
int iReturn;
|
int iReturn;
|
||||||
|
|
||||||
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
|
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
|
||||||
|
@ -323,7 +321,7 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
/* Release PRIMARY selection if owned */
|
/* Release PRIMARY selection if owned */
|
||||||
iReturn = XGetSelectionOwner(pDisplay, XA_PRIMARY);
|
iReturn = XGetSelectionOwner(pDisplay, XA_PRIMARY);
|
||||||
if (iReturn == g_iClipboardWindow) {
|
if (iReturn == iWindow) {
|
||||||
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
||||||
"PRIMARY selection is owned by us.\n");
|
"PRIMARY selection is owned by us.\n");
|
||||||
XSetSelectionOwner(pDisplay, XA_PRIMARY, None, CurrentTime);
|
XSetSelectionOwner(pDisplay, XA_PRIMARY, None, CurrentTime);
|
||||||
|
@ -335,7 +333,7 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
/* Release CLIPBOARD selection if owned */
|
/* Release CLIPBOARD selection if owned */
|
||||||
iReturn = XGetSelectionOwner(pDisplay, atomClipboard);
|
iReturn = XGetSelectionOwner(pDisplay, atomClipboard);
|
||||||
if (iReturn == g_iClipboardWindow) {
|
if (iReturn == iWindow) {
|
||||||
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
||||||
"CLIPBOARD selection is owned by us.\n");
|
"CLIPBOARD selection is owned by us.\n");
|
||||||
XSetSelectionOwner(pDisplay, atomClipboard, None, CurrentTime);
|
XSetSelectionOwner(pDisplay, atomClipboard, None, CurrentTime);
|
||||||
|
@ -408,8 +406,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_RENDERALLFORMATS:
|
case WM_RENDERALLFORMATS:
|
||||||
{
|
{
|
||||||
int iReturn;
|
int iReturn;
|
||||||
Display *pDisplay = g_pClipboardDisplay;
|
|
||||||
Window iWindow = g_iClipboardWindow;
|
|
||||||
Bool fConvertToUnicode;
|
Bool fConvertToUnicode;
|
||||||
|
|
||||||
winDebug("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
|
winDebug("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
|
||||||
|
|
|
@ -95,8 +95,6 @@ Bool g_fUnicodeClipboard = TRUE;
|
||||||
Bool g_fClipboard = TRUE;
|
Bool g_fClipboard = TRUE;
|
||||||
Bool g_fClipboardStarted = FALSE;
|
Bool g_fClipboardStarted = FALSE;
|
||||||
HWND g_hwndClipboard = NULL;
|
HWND g_hwndClipboard = NULL;
|
||||||
void *g_pClipboardDisplay = NULL;
|
|
||||||
Window g_iClipboardWindow = None;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -109,8 +107,6 @@ winInitializeGlobals(void)
|
||||||
{
|
{
|
||||||
g_dwCurrentThreadID = GetCurrentThreadId();
|
g_dwCurrentThreadID = GetCurrentThreadId();
|
||||||
#ifdef XWIN_CLIPBOARD
|
#ifdef XWIN_CLIPBOARD
|
||||||
g_iClipboardWindow = None;
|
|
||||||
g_pClipboardDisplay = NULL;
|
|
||||||
g_hwndClipboard = NULL;
|
g_hwndClipboard = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue