hw/xwin: Hoist use of winSetAuthorization() and winGetDisplayName() up one level

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 02:01:27 +01:00
parent a3c1e405cb
commit 8f9fba5bc1
3 changed files with 23 additions and 20 deletions

View File

@ -71,7 +71,6 @@
* References to external symbols
*/
extern char *display;
extern void winDebug(const char *format, ...);
extern void winErrorFVerb(int verb, const char *format, ...);
@ -96,7 +95,7 @@ void
* winclipboardthread.c
*/
void *winClipboardProc(void *);
void *winClipboardProc(char *szDisplay);
/*
* winclipboardwndproc.c

View File

@ -37,10 +37,13 @@
#include "os.h"
#include "winclipboard.h"
#include "windisplay.h"
#define WIN_CLIPBOARD_RETRIES 40
#define WIN_CLIPBOARD_DELAY 1
extern void winSetAuthorization(void);
/*
* References to external symbols
*/
@ -61,16 +64,33 @@ static pthread_t g_ptClipboardProc;
static void *
winClipboardThreadProc(void *arg)
{
char szDisplay[512];
int clipboardRestarts = 0;
while (1)
{
++clipboardRestarts;
/* Use our generated cookie for authentication */
winSetAuthorization();
/* Setup the display connection string */
/*
* NOTE: Always connect to screen 0 since we require that screen
* numbers start at 0 and increase without gaps. We only need
* to connect to one screen on the display to get events
* for all screens on the display. That is why there is only
* one clipboard client thread.
*/
winGetDisplayName(szDisplay, 0);
/* Print the display connection string */
ErrorF("winClipboardThreadProc - DISPLAY=%s\n", szDisplay);
/* Flag that clipboard client has been launched */
g_fClipboardStarted = TRUE;
winClipboardProc(arg);
winClipboardProc(szDisplay);
/* Flag that clipboard client has stopped */
g_fClipboardStarted = FALSE;

View File

@ -89,7 +89,7 @@ static int
*/
void *
winClipboardProc(void *pvNotUsed)
winClipboardProc(char *szDisplay)
{
Atom atomClipboard;
int iReturn;
@ -107,7 +107,6 @@ winClipboardProc(void *pvNotUsed)
Window iWindow = None;
int iRetries;
Bool fUseUnicode;
char szDisplay[512];
int iSelectError;
winDebug("winClipboardProc - Hello\n");
@ -150,24 +149,9 @@ winClipboardProc(void *pvNotUsed)
goto winClipboardProc_Done;
}
/* Use our generated cookie for authentication */
winSetAuthorization();
/* Initialize retry count */
iRetries = 0;
/* Setup the display connection string x */
/*
* NOTE: Always connect to screen 0 since we require that screen
* numbers start at 0 and increase without gaps. We only need
* to connect to one screen on the display to get events
* for all screens on the display. That is why there is only
* one clipboard client thread.
*/
winGetDisplayName(szDisplay, 0);
/* Print the display connection string */
ErrorF("winClipboardProc - DISPLAY=%s\n", szDisplay);
/* Open the X display */
do {