aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2015-02-24 07:44:41 +0100
committermarha <marha@users.sourceforge.net>2015-02-24 07:44:41 +0100
commitf64e43decd0fdac938feddeedee255dc4508aaa5 (patch)
tree34e1cfaaea9ad73d9335197ee79b4f99affe4ea9 /xorg-server/hw
parent462f18c7b25fe3e467f837647d07ab0a78aa8d2b (diff)
parentac2c8a704aac7569f4ae85b890a546644bd86c60 (diff)
downloadvcxsrv-f64e43decd0fdac938feddeedee255dc4508aaa5.tar.gz
vcxsrv-f64e43decd0fdac938feddeedee255dc4508aaa5.tar.bz2
vcxsrv-f64e43decd0fdac938feddeedee255dc4508aaa5.zip
Merge remote-tracking branch 'origin/released'
Conflicts: apps/xcalc/math.c freetype/src/base/ftbdf.c freetype/src/base/fttype1.c freetype/src/pfr/pfrobjs.c mesalib/src/mesa/main/.gitignore openssl/Configure openssl/Makefile openssl/crypto/cryptlib.c openssl/crypto/opensslconf.h openssl/test/v3nametest.c openssl/util/mk1mf.pl openssl/util/pl/VC-32.pl xorg-server/Xi/xipassivegrab.c xorg-server/dix/dispatch.c xorg-server/dix/getevents.c xorg-server/glx/glxcmds.c xorg-server/glx/indirect_reqsize.c xorg-server/glx/indirect_reqsize.h xorg-server/hw/xwin/winclipboard/internal.h xorg-server/hw/xwin/winclipboard/thread.c xorg-server/hw/xwin/winclipboard/wndproc.c xorg-server/hw/xwin/winclipboard/xevents.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winprocarg.c xorg-server/render/render.c
Diffstat (limited to 'xorg-server/hw')
-rwxr-xr-xxorg-server/hw/xwin/winclipboard/internal.h1
-rwxr-xr-xxorg-server/hw/xwin/winclipboard/thread.c86
-rwxr-xr-xxorg-server/hw/xwin/winclipboard/wndproc.c224
-rwxr-xr-xxorg-server/hw/xwin/winclipboard/xevents.c38
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xwin/winclipboardinit.c6
-rwxr-xr-xxorg-server/hw/xwin/winclipboardwrappers.c165
-rwxr-xr-xxorg-server/hw/xwin/winglobals.c2
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xwin/winglobals.h1
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xwin/winmsgwindow.c1
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xwin/winmultiwindowwndproc.c9
-rwxr-xr-xxorg-server/hw/xwin/winprocarg.c26
-rw-r--r--xorg-server/hw/xwin/xlaunch/main.cc2
12 files changed, 204 insertions, 357 deletions
diff --git a/xorg-server/hw/xwin/winclipboard/internal.h b/xorg-server/hw/xwin/winclipboard/internal.h
index 73a330fc6..b1ac02b2a 100755
--- a/xorg-server/hw/xwin/winclipboard/internal.h
+++ b/xorg-server/hw/xwin/winclipboard/internal.h
@@ -133,7 +133,6 @@ typedef struct
} ClipboardConversionData;
int
-
winClipboardFlushXEvents(HWND hwnd,
Window iWindow, Display * pDisplay, ClipboardConversionData *data, ClipboardAtoms *atom);
diff --git a/xorg-server/hw/xwin/winclipboard/thread.c b/xorg-server/hw/xwin/winclipboard/thread.c
index 42edad89c..20c473dd8 100755
--- a/xorg-server/hw/xwin/winclipboard/thread.c
+++ b/xorg-server/hw/xwin/winclipboard/thread.c
@@ -54,6 +54,9 @@
#endif
#include "misc.h"
#include "winmsg.h"
+
+#include <X11/Xatom.h>
+#include <X11/extensions/Xfixes.h>
#include "winclipboard.h"
#include "internal.h"
@@ -83,7 +86,6 @@ extern Bool g_fClipboardLaunched;
extern HWND g_hwndClipboard;
extern void *g_pClipboardDisplay;
extern Window g_iClipboardWindow;
-extern Bool g_fClipboardPrimary;
/*
* Global variables
@@ -93,6 +95,9 @@ static jmp_buf g_jmpEntry;
static XIOErrorHandler g_winClipboardOldIOErrorHandler;
static pthread_t g_winClipboardProcThread;
+int xfixes_event_base;
+int xfixes_error_base;
+
Bool g_fUseUnicode = FALSE;
/*
@@ -110,8 +115,11 @@ static int
static void
winClipboardThreadExit(void *arg);
+
/*
- * Main thread function
+ * Create X11 and Win32 messaging windows, and run message processing loop
+ *
+ * returns TRUE if shutdown was signalled to loop, FALSE if some error occurred
*/
Bool
@@ -121,7 +129,6 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay)
int iReturn;
HWND hwnd = NULL;
int iConnectionNumber = 0;
- Bool bShutDown = TRUE;
#ifdef HAS_DEVWINDOWS
int fdMessageQueue = 0;
@@ -133,27 +140,37 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay)
Display *pDisplay = NULL;
Window iWindow = None;
int iSelectError;
+ Bool fShutDown = TRUE;
+ static Bool fErrorHandlerSet = FALSE;
pthread_cleanup_push(&winClipboardThreadExit, NULL);
ClipboardConversionData data;
- winDebug ("winClipboardProc - Hello\n");
+ winDebug("winClipboardProc - Hello\n");
/* Save the Unicode support flag in a global */
g_fUseUnicode = fUseUnicode;
- /* Create Windows messaging window */
- hwnd = winClipboardCreateMessagingWindow ();
+ /* Allow multiple threads to access Xlib */
+ if (XInitThreads() == 0) {
+ ErrorF("winClipboardProc - XInitThreads failed.\n");
+ goto thread_errorexit;
+ }
- /* Save copy of HWND in screen privates */
- g_hwndClipboard = hwnd;
+ /* See if X supports the current locale */
+ if (XSupportsLocale() == False) {
+ ErrorF("winClipboardProc - Warning: Locale not supported by X.\n");
+ }
g_winClipboardProcThread = pthread_self();
/* Set error handler */
- XSetErrorHandler(winClipboardErrorHandler);
- g_winClipboardOldIOErrorHandler =
- XSetIOErrorHandler(winClipboardIOErrorHandler);
+ if (!fErrorHandlerSet) {
+ XSetErrorHandler(winClipboardErrorHandler);
+ g_winClipboardOldIOErrorHandler =
+ XSetIOErrorHandler(winClipboardIOErrorHandler);
+ fErrorHandlerSet = TRUE;
+ }
/* Set jump point for Error exits */
iReturn = setjmp(g_jmpEntry);
@@ -173,7 +190,7 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay)
pDisplay = XOpenDisplay(szDisplay);
if (pDisplay == NULL) {
ErrorF("winClipboardProc - Failed opening the display, giving up\n");
- bShutDown = FALSE;
+ fShutDown = FALSE;
goto thread_errorexit;
}
@@ -186,18 +203,16 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay)
/* Get our connection number */
iConnectionNumber = ConnectionNumber(pDisplay);
- winDebug("Clipboard is using socket %d\n",iConnectionNumber);
-
#ifdef HAS_DEVWINDOWS
/* Open a file descriptor for the windows message queue */
- fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, _O_RDONLY);
+ fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
if (fdMessageQueue == -1) {
ErrorF("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
goto thread_errorexit;
}
/* Find max of our file descriptors */
- iMaxDescriptor = max(fdMessageQueue, iConnectionNumber) + 1;
+ iMaxDescriptor = MAX(fdMessageQueue, iConnectionNumber) + 1;
#else
iMaxDescriptor = iConnectionNumber + 1;
#endif
@@ -248,30 +263,31 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay)
/* Save the window in the screen privates */
g_iClipboardWindow = iWindow;
+ /* Initialize monitored selection state */
+ winClipboardInitMonitoredSelections();
+ /* Create Windows messaging window */
+ hwnd = winClipboardCreateMessagingWindow(pDisplay, iWindow, &atoms);
+
+ /* Save copy of HWND */
+ g_hwndClipboard = hwnd;
/* Assert ownership of selections if Win32 clipboard is owned */
if (NULL != GetClipboardOwner()) {
- if (g_fClipboardPrimary)
- {
- /* PRIMARY */
- winDebug("winClipboardProc - asserted ownership.\n");
- iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
- iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow /*||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow*/)
- {
- ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
- goto thread_errorexit;
- }
+ /* PRIMARY */
+ iReturn = XSetSelectionOwner(pDisplay, XA_PRIMARY,
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner(pDisplay, XA_PRIMARY) != iWindow) {
+ ErrorF("winClipboardProc - Could not set PRIMARY owner\n");
+ goto thread_errorexit;
}
/* CLIPBOARD */
- iReturn = XSetSelectionOwner(pDisplay, atomClipboard,
+ iReturn = XSetSelectionOwner(pDisplay, atoms.atomClipboard,
iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow /*||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow*/)
- {
- ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner(pDisplay, atoms.atomClipboard) != iWindow) {
+ ErrorF("winClipboardProc - Could not set CLIPBOARD owner\n");
goto thread_errorexit;
}
}
@@ -429,14 +445,14 @@ commonexit:
pthread_cleanup_pop(0);
- return bShutDown;
+ return fShutDown;
}
/*
* Create the Windows window that we use to receive Windows messages
*/
-HWND
+static HWND
winClipboardCreateMessagingWindow(Display *pDisplay, Window iWindow, ClipboardAtoms *atoms)
{
WNDCLASSEX wc;
diff --git a/xorg-server/hw/xwin/winclipboard/wndproc.c b/xorg-server/hw/xwin/winclipboard/wndproc.c
index d522e1f30..c99975193 100755
--- a/xorg-server/hw/xwin/winclipboard/wndproc.c
+++ b/xorg-server/hw/xwin/winclipboard/wndproc.c
@@ -26,7 +26,7 @@
*the sale, use or other dealings in this Software without prior written
*authorization from the copyright holder(s) and author(s).
*
- * Authors: Harold L Hunt II
+ * Authors: Harold L Hunt II
* Colin Harrison
*/
@@ -46,19 +46,22 @@
#include <sys/types.h>
#include <sys/time.h>
#include <limits.h>
-#include "winclipboard.h"
+
+#include <X11/Xatom.h>
+
#include "misc.h"
#include "winmsg.h"
#include "objbase.h"
#include "ddraw.h"
#include "winwindow.h"
#include "internal.h"
+#include "winclipboard.h"
/*
* Constants
*/
-#define WIN_POLL_TIMEOUT 1
+#define WIN_POLL_TIMEOUT 1
/*
* References to external symbols
@@ -69,14 +72,13 @@ extern Window g_iClipboardWindow;
extern Atom g_atomLastOwnedSelection;
extern Bool g_fClipboardStarted;
extern HWND g_hwndClipboard;
-extern Bool g_fClipboardPrimary;
/*
* Process X events up to specified timeout
*/
static int
-winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
+winProcessXEventsTimeout(HWND hwnd, Window iWindow, Display * pDisplay,
ClipboardConversionData *data, ClipboardAtoms *atoms, int iTimeoutSec)
{
int iConnNumber;
@@ -151,6 +153,10 @@ LRESULT CALLBACK
winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND s_hwndNextViewer;
+ static Bool s_fCBCInitialized;
+ static Display *pDisplay;
+ static Window iWindow;
+ static ClipboardAtoms *atoms;
static Bool fRunning;
/* Branch on message type */
@@ -179,20 +185,25 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND first, next;
DWORD error_code = 0;
+ ClipboardWindowCreationParams *cwcp = (ClipboardWindowCreationParams *)((CREATESTRUCT *)lParam)->lpCreateParams;
winDebug("winClipboardWindowProc - WM_CREATE\n");
+ pDisplay = cwcp->pClipboardDisplay;
+ iWindow = cwcp->iClipboardWindow;
+ atoms = cwcp->atoms;
fRunning = TRUE;
- /* Add ourselves to the clipboard viewer chain */
- s_hwndNextViewer = SetClipboardViewer (hwnd);
- #ifdef _DEBUG
- if (s_hwndNextViewer== hwnd)
- {
- ErrorF("WM_CREATE: SetClipboardViewer returned own window. This causes an endless loop, so reset s_hwndNextViewer. ");
- s_hwndNextViewer=NULL;
- }
- #endif
+ first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
+ if (first == hwnd)
+ return 0; /* Make sure it's not us! */
+ /* Add ourselves to the clipboard viewer chain */
+ next = SetClipboardViewer(hwnd);
+ error_code = GetLastError();
+ if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
+ s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
+ else
+ s_fCBCInitialized = FALSE;
}
return 0;
@@ -205,8 +216,9 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((HWND) wParam == s_hwndNextViewer) {
s_hwndNextViewer = (HWND) lParam;
if (s_hwndNextViewer == hwnd) {
- winDebug("WM_CHANGECBCHAIN: trying to set s_hwndNextViewer to own window. Resetting it back to NULL. ");
- s_hwndNextViewer=NULL; /* This would cause an endless loop, so break it by ending the loop here. I have seen this happening, why??? */
+ s_hwndNextViewer = NULL;
+ ErrorF("winClipboardWindowProc - WM_CHANGECBCHAIN: "
+ "attempted to set next window to ourselves.");
}
}
else if (s_hwndNextViewer)
@@ -238,32 +250,31 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
winDebug("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
- if (first != hwnd)
- {
- winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
- "of chain\n", hwnd, s_hwndNextViewer);
- if (!wParam) ChangeClipboardChain (hwnd, s_hwndNextViewer); /* When wParam is set, the window was already removed from the chain */
- winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
- s_hwndNextViewer = SetClipboardViewer (hwnd);
- #ifdef _DEBUG
- if (s_hwndNextViewer== hwnd)
- {
- ErrorF("WM_WM_REINIT: SetClipboardViewer returned own window. This causes an endless loop, so reset s_hwndNextViewer. ");
- s_hwndNextViewer=NULL;
- }
- #endif
- }
- winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
+ if (first == hwnd)
+ return 0; /* Make sure it's not us! */
+ winDebug(" WM_WM_REINIT: Replacing us(%x) with %x at head "
+ "of chain\n", hwnd, s_hwndNextViewer);
+ s_fCBCInitialized = FALSE;
+ ChangeClipboardChain(hwnd, s_hwndNextViewer);
+ s_hwndNextViewer = NULL;
+ s_fCBCInitialized = FALSE;
+ winDebug(" WM_WM_REINIT: Putting us back at head of chain.\n");
+ first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
+ if (first == hwnd)
+ return 0; /* Make sure it's not us! */
+ next = SetClipboardViewer(hwnd);
+ error_code = GetLastError();
+ if (SUCCEEDED(error_code) && (next == first)) /* SetClipboardViewer must have succeeded, and the handle */
+ s_hwndNextViewer = next; /* it returned must have been the first window in the chain */
+ else
+ s_fCBCInitialized = FALSE;
}
+ winDebug("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
return 0;
case WM_DRAWCLIPBOARD:
{
- static Atom atomClipboard;
- static int generation;
static Bool s_fProcessingDrawClipboard = FALSE;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
int iReturn;
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD 0x%x 0x%x 0x%x: Enter\n",hwnd,wParam,lParam);
@@ -275,11 +286,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
- if (generation != serverGeneration) {
- generation = serverGeneration;
- atomClipboard = XInternAtom(pDisplay, "CLIPBOARD", False);
- }
-
/*
* We've occasionally seen a loop in the clipboard chain.
* Try and fix it on the first hint of recursion.
@@ -289,15 +295,44 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
}
else {
/* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
+ s_fCBCInitialized = FALSE;
ChangeClipboardChain(hwnd, s_hwndNextViewer);
winFixClipboardChain(1);
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Nested calls detected. Re-initing.\n");
+ ErrorF("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Nested calls detected. Re-initing.\n");
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
s_fProcessingDrawClipboard = FALSE;
return 0;
}
+ /* Bail on first message */
+ if (!s_fCBCInitialized) {
+ s_fCBCInitialized = TRUE;
+ s_fProcessingDrawClipboard = FALSE;
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ return 0;
+ }
+
+ /*
+ * NOTE: We cannot bail out when NULL == GetClipboardOwner ()
+ * because some applications deal with the clipboard in a manner
+ * that causes the clipboard owner to be NULL when they are in
+ * fact taking ownership. One example of this is the Win32
+ * native compile of emacs.
+ */
+
+ /* Bail when we still own the clipboard */
+ if (hwnd == GetClipboardOwner()) {
+
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "We own the clipboard, returning.\n");
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ if (s_hwndNextViewer)
+ SendMessage(s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+ }
+
/* Bail when shutting down */
if (!fRunning)
return 0;
@@ -320,31 +355,31 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
*/
XSync(pDisplay, FALSE);
- if (g_fClipboardPrimary)
- {
- /* Release PRIMARY selection if owned */
- iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY);
- if (iReturn == g_iClipboardWindow) {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "PRIMARY selection is owned by us.\n");
- XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
- }
- else if (BadWindow == iReturn || BadAtom == iReturn)
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "XGetSelection failed for PRIMARY: %d\n",
- iReturn);
+ winDebug("winClipboardWindowProc - XSync done.\n");
+
+ /* Release PRIMARY selection if owned */
+ iReturn = XGetSelectionOwner(pDisplay, XA_PRIMARY);
+ if (iReturn == iWindow) {
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "PRIMARY selection is owned by us.\n");
+ XSetSelectionOwner(pDisplay, XA_PRIMARY, None, CurrentTime);
}
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ ErrorF("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelectionOwner failed for PRIMARY: %d\n",
+ iReturn);
+
/* Release CLIPBOARD selection if owned */
- iReturn = XGetSelectionOwner(pDisplay, atomClipboard);
- if (iReturn == g_iClipboardWindow) {
+ iReturn = XGetSelectionOwner(pDisplay, atoms->atomClipboard);
+ if (iReturn == iWindow) {
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "CLIPBOARD selection is owned by us.\n");
- XSetSelectionOwner(pDisplay, atomClipboard, None, CurrentTime);
+ "CLIPBOARD selection is owned by us, releasing\n");
+ XSetSelectionOwner(pDisplay, atoms->atomClipboard, None, CurrentTime);
}
else if (BadWindow == iReturn || BadAtom == iReturn)
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "XGetSelection failed for CLIPBOARD: %d\n",
- iReturn);
+ ErrorF("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelectionOwner failed for CLIPBOARD: %d\n",
+ iReturn);
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
s_fProcessingDrawClipboard = FALSE;
@@ -352,48 +387,45 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage(s_hwndNextViewer, message, wParam, lParam);
return 0;
}
- /* Only reassert ownership when we did not change the clipboard ourselves */
- if (hwnd!=(HWND)wParam) {
- if (g_fClipboardPrimary) {
- /* Reassert ownership of PRIMARY */
- iReturn = XSetSelectionOwner (pDisplay,
- XA_PRIMARY, iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow) {
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Could not reassert ownership of PRIMARY\n");
- }
- else {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Reasserted ownership of PRIMARY\n");
- }
- }
- /* Reassert ownership of the CLIPBOARD */
- iReturn = XSetSelectionOwner (pDisplay,
- atomClipboard, iWindow, CurrentTime);
-
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow) {
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Could not reassert ownership of CLIPBOARD\n");
- }
- else {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Reasserted ownership of CLIPBOARD\n");
- }
- /* Flush the pending SetSelectionOwner event now */
- XFlush (pDisplay);
+ /* Reassert ownership of PRIMARY */
+ iReturn = XSetSelectionOwner(pDisplay,
+ XA_PRIMARY, iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner(pDisplay, XA_PRIMARY) != iWindow) {
+ ErrorF("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of PRIMARY\n");
+ }
+ else {
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of PRIMARY\n");
+ }
+
+ /* Reassert ownership of the CLIPBOARD */
+ iReturn = XSetSelectionOwner(pDisplay,
+ atoms->atomClipboard, iWindow, CurrentTime);
+
+ if (iReturn == BadAtom || iReturn == BadWindow ||
+ XGetSelectionOwner(pDisplay, atoms->atomClipboard) != iWindow) {
+ ErrorF("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of CLIPBOARD\n");
+ }
+ else {
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of CLIPBOARD\n");
}
+ /* Flush the pending SetSelectionOwner event now */
+ XFlush(pDisplay);
+
s_fProcessingDrawClipboard = FALSE;
+ }
winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
/* Pass the message on the next window in the clipboard viewer chain */
if (s_hwndNextViewer)
SendMessage(s_hwndNextViewer, message, wParam, lParam);
return 0;
- }
case WM_DESTROYCLIPBOARD:
/*
* NOTE: Intentionally do nothing.
@@ -425,8 +457,6 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_RENDERFORMAT:
{
int iReturn;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
Bool fConvertToUnicode;
Bool pasted = FALSE;
Atom selection;
diff --git a/xorg-server/hw/xwin/winclipboard/xevents.c b/xorg-server/hw/xwin/winclipboard/xevents.c
index 640efeb4e..5f426322d 100755
--- a/xorg-server/hw/xwin/winclipboard/xevents.c
+++ b/xorg-server/hw/xwin/winclipboard/xevents.c
@@ -34,6 +34,7 @@
#include <xwin-config.h>
#endif
#include "winclipboard.h"
+#include "winglobals.h"
#include "misc.h"
#include "winmsg.h"
/*
@@ -50,7 +51,7 @@
#include <wchar.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
-//#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/Xfixes.h>
#include "winclipboard.h"
#include "internal.h"
@@ -71,8 +72,6 @@
extern int xfixes_event_base;
Bool fPrimarySelection = TRUE;
-extern Bool g_fClipboardPrimary;
-
/*
* Local variables
*/
@@ -308,23 +307,24 @@ winClipboardFlushXEvents(HWND hwnd,
break;
}
- /* Access the clipboard */
- if (!ClipboardOpened)
- {
- if (!OpenClipboard (hwnd))
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ /* Close clipboard if we have it open already */
+ if (GetOpenClipboardWindow() == hwnd) {
+ CloseClipboard();
+ }
+
+ /* Access the clipboard */
+ if (!OpenClipboard(hwnd)) {
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
"OpenClipboard () failed: %08lx\n", GetLastError());
/* Abort */
fAbort = TRUE;
goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Indicate that clipboard was opened */
- fCloseClipboard = TRUE;
}
+ /* Indicate that clipboard was opened */
+ fCloseClipboard = TRUE;
+
/* Check that clipboard format is available */
if (data->fUseUnicode && !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
static int count; /* Hack to stop acroread spamming the log */
@@ -374,13 +374,13 @@ winClipboardFlushXEvents(HWND hwnd,
hGlobal = GetClipboardData(CF_TEXT);
}
if (!hGlobal) {
- if (GetLastError()==ERROR_CLIPBOARD_NOT_OPEN && ClipboardOpened)
+ if (GetLastError()==ERROR_CLIPBOARD_NOT_OPEN && g_fClipboardStarted)
{
ErrorF("We should not have received a SelectionRequest????\n"
"The owner is the clipboard, but in reality it was"
"an X window\n");
/* Set the owner to None */
- if (g_fClipboardPrimary) XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
+ if (fPrimarySelection) XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
}
ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
@@ -470,11 +470,9 @@ winClipboardFlushXEvents(HWND hwnd,
/* Release the clipboard data */
GlobalUnlock(hGlobal);
pszGlobalData = NULL;
- if (fCloseClipboard)
- {
- fCloseClipboard = FALSE;
- CloseClipboard ();
- }
+ fCloseClipboard = FALSE;
+ CloseClipboard();
+
/* Clean up */
XFree(xtpText.value);
xtpText.value = NULL;
diff --git a/xorg-server/hw/xwin/winclipboardinit.c b/xorg-server/hw/xwin/winclipboardinit.c
index 6451acaa5..0ef49fa1a 100644..100755
--- a/xorg-server/hw/xwin/winclipboardinit.c
+++ b/xorg-server/hw/xwin/winclipboardinit.c
@@ -111,12 +111,6 @@ 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 */
diff --git a/xorg-server/hw/xwin/winclipboardwrappers.c b/xorg-server/hw/xwin/winclipboardwrappers.c
index c0598f9b3..cf0d5f951 100755
--- a/xorg-server/hw/xwin/winclipboardwrappers.c
+++ b/xorg-server/hw/xwin/winclipboardwrappers.c
@@ -58,7 +58,6 @@ extern Bool g_fClipboardStarted;
extern Window g_iClipboardWindow;
extern Atom g_atomLastOwnedSelection;
extern HWND g_hwndClipboard;
-extern Bool g_fClipboardPrimary;
/*
* Wrapper for internal EstablishConnection function.
@@ -166,167 +165,3 @@ winProcEstablishConnection(ClientPtr client)
return iReturn;
}
-
-/*
- * Wrapper for internal SetSelectionOwner function.
- * Grabs ownership of Windows clipboard when X11 clipboard owner changes.
- */
-int
-winProcSetSelectionOwner(ClientPtr client)
-{
- int i;
- DrawablePtr pDrawable;
- WindowPtr pWindow = None;
- static Window s_iOwners[CLIP_NUM_SELECTIONS] = { None };
- static unsigned long s_ulServerGeneration = 0;
-
- REQUEST(xSetSelectionOwnerReq);
-
- REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
-
- winDebug("winProcSetSelectionOwner - Hello.\n");
-
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration) {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
-
- /* Initialize static variables */
- for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
- s_iOwners[i] = None;
- }
-
- /* Abort if clipboard not completely initialized yet */
- if (!g_fClipboardStarted) {
- winDebug ("winProcSetSelectionOwner - Clipboard not yet started, "
- "aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Grab window if we have one */
- if (None != stuff->window) {
- /* Grab the Window from the request */
- int rc =
- dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
- if (rc != Success) {
- ErrorF("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
- }
-
- /* Now we either have a valid window or None */
-
- /* Save selection owners for monitored selections, ignore other selections */
- if (XA_PRIMARY == stuff->selection && g_fClipboardPrimary) {
- /* Look for owned -> not owned transition */
- if (None == stuff->window && None != s_iOwners[CLIP_OWN_PRIMARY]) {
- winDebug("winProcSetSelectionOwner - PRIMARY - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
- g_atomLastOwnedSelection = MakeAtom("CLIPBOARD", 9, TRUE);
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
-
- winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: 0x%x (clipboard is 0x%x)\n",
- stuff->window,g_iClipboardWindow);
- }
- else if (MakeAtom("CLIPBOARD", 9, TRUE) == stuff->selection) {
- /* Look for owned -> not owned transition */
- if (None == stuff->window && None != s_iOwners[CLIP_OWN_CLIPBOARD]) {
- winDebug("winProcSetSelectionOwner - CLIPBOARD - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if ((None != s_iOwners[CLIP_OWN_PRIMARY]) && g_fClipboardPrimary)
- g_atomLastOwnedSelection = XA_PRIMARY;
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
-
- winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: 0x%x, clipboard is 0x%x\n",
- stuff->window,g_iClipboardWindow);
- }
- else
- goto winProcSetSelectionOwner_Done;
-
- /*
- * At this point, if one of the selections is still owned by the
- * clipboard manager then it should be marked as unowned since
- * we will be taking ownership of the Win32 clipboard.
- */
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
- s_iOwners[CLIP_OWN_PRIMARY] = None;
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
- s_iOwners[CLIP_OWN_CLIPBOARD] = None;
-
- /* Abort if no window at this point */
- if (None == stuff->window) {
- winDebug ("winProcSetSelectionOwner - No window, returning.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if invalid selection */
- if (!ValidAtom(stuff->selection)) {
- winDebug ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Cast Window to Drawable */
- pDrawable = (DrawablePtr) pWindow;
-
- /* Abort if clipboard manager is owning the selection */
- if (pDrawable->id == g_iClipboardWindow) {
- winDebug ("winProcSetSelectionOwner - We changed ownership, "
- "aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Abort if root window is taking ownership */
- if (pDrawable->id == 0) {
- winDebug ("winProcSetSelectionOwner - Root window taking ownership, "
- "aborting\n");
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Access the Windows clipboard */
- if (!OpenClipboard(g_hwndClipboard)) {
- ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x, hwnd: %08x\n",
- (int) GetLastError (),g_hwndClipboard);
- goto winProcSetSelectionOwner_Done;
- }
-
- /* Take ownership of the Windows clipboard */
- if (!EmptyClipboard()) {
- ErrorF("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
- (int) GetLastError());
- CloseClipboard ();
- goto winProcSetSelectionOwner_Done;
- }
-
- winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n");
- /* Advertise regular text and unicode */
- SetClipboardData(CF_UNICODETEXT, NULL);
- SetClipboardData(CF_TEXT, NULL);
-
- /* Save handle to last owned selection */
- g_atomLastOwnedSelection = stuff->selection;
-
- /* Release the clipboard */
- if (!CloseClipboard()) {
- ErrorF("winProcSetSelectionOwner - CloseClipboard () failed: "
- "%08x\n", (int) GetLastError());
- goto winProcSetSelectionOwner_Done;
- }
-
-winProcSetSelectionOwner_Done:
- return (*winProcSetSelectionOwnerOrig) (client);
-}
diff --git a/xorg-server/hw/xwin/winglobals.c b/xorg-server/hw/xwin/winglobals.c
index 54e5e0ba2..46202369e 100755
--- a/xorg-server/hw/xwin/winglobals.c
+++ b/xorg-server/hw/xwin/winglobals.c
@@ -87,7 +87,6 @@ pthread_mutex_t g_pmTerminating = PTHREAD_MUTEX_INITIALIZER;
* Wrapped DIX functions
*/
winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
-winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
/*
* Clipboard variables
@@ -95,7 +94,6 @@ winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
Bool g_fUnicodeClipboard = TRUE;
Bool g_fClipboard = TRUE;
-Bool g_fClipboardPrimary = TRUE;
Bool g_fClipboardLaunched = FALSE;
Bool g_fClipboardStarted = FALSE;
pthread_t g_ptClipboardProc;
diff --git a/xorg-server/hw/xwin/winglobals.h b/xorg-server/hw/xwin/winglobals.h
index f697085bc..9c282e2b4 100644..100755
--- a/xorg-server/hw/xwin/winglobals.h
+++ b/xorg-server/hw/xwin/winglobals.h
@@ -73,7 +73,6 @@ typedef int (*winDispatchProcPtr) (ClientPtr);
* Wrapped DIX functions
*/
extern winDispatchProcPtr winProcEstablishConnectionOrig;
-extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
#endif
extern Bool g_fUnicodeClipboard;
extern Bool g_fClipboard;
diff --git a/xorg-server/hw/xwin/winmsgwindow.c b/xorg-server/hw/xwin/winmsgwindow.c
index 37fe950c4..f5649b722 100644..100755
--- a/xorg-server/hw/xwin/winmsgwindow.c
+++ b/xorg-server/hw/xwin/winmsgwindow.c
@@ -25,6 +25,7 @@
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
+
#include "win.h"
/*
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c
index ef40fca6d..8c9ca6305 100644..100755
--- a/xorg-server/hw/xwin/winmultiwindowwndproc.c
+++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c
@@ -328,7 +328,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
static Bool s_fTracking = FALSE;
Bool needRestack = FALSE;
LRESULT ret;
- static Bool hasEnteredSizeMove = FALSE;
+ static Bool hasEnteredSizeMove = FALSE;
winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam,
lParam);
@@ -586,7 +586,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSELEAVE:
/* We can't do anything without privates */
if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
+ break;
/* Mouse has left our client area */
/* Flag that we are no longer tracking */
@@ -813,8 +813,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Tell our Window Manager thread to activate the window */
wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized && pWin->realized && !pWin->overrideRedirect /* for OOo menus */)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ if (fWMMsgInitialized &&
+ pWin->realized && !pWin->overrideRedirect /* for OOo menus */)
+ winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
}
/* Prevent the mouse wheel from stalling when another window is minimized */
if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c
index 29fcbc9ed..dd328ee80 100755
--- a/xorg-server/hw/xwin/winprocarg.c
+++ b/xorg-server/hw/xwin/winprocarg.c
@@ -734,30 +734,6 @@ ddxProcessArgument(int argc, char *argv[], int i)
/* Indicate that we have processed this argument */
return 1;
}
-
- /*
- * Look for the '-clipboard' argument
- */
- if (IS_OPTION ("-clipboardprimary"))
- {
- /* Now the default, we still accept the arg for backwards compatibility */
- g_fClipboardPrimary = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-noclipboard' argument
- */
- if (IS_OPTION ("-noclipboardprimary"))
- {
- g_fClipboardPrimary = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
#endif
/*
@@ -1046,7 +1022,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
if (IS_OPTION("-logverbose")) {
CHECK_ARGS(1);
g_iLogVerbose = atoi(argv[++i]);
- LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose);
+ LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose);
return 2;
}
diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc
index bf4f5e6a5..e6b04d6b3 100644
--- a/xorg-server/hw/xwin/xlaunch/main.cc
+++ b/xorg-server/hw/xwin/xlaunch/main.cc
@@ -701,7 +701,7 @@ class CMyWizard : public CWizard
if (config.clipboard)
buffer += "-clipboard ";
if (!config.clipboardprimary)
- buffer += "-noclipboardprimary ";
+ buffer += "-noprimary ";
if (config.wgl)
buffer += "-wgl ";
else