aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winclipboardwndproc.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
committermarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
commit76bcc36ed305418a3ddc5752d287ede894243e1b (patch)
treebacb320c825768471ce56f058f17ce863d592376 /xorg-server/hw/xwin/winclipboardwndproc.c
parent7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff)
parent0f834b91a4768673833ab4917e87d86c237bb1a6 (diff)
downloadvcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip
Merge remote-tracking branch 'origin/released'
Conflicts: pixman/pixman/pixman-mmx.c xorg-server/Xext/shm.c xorg-server/Xext/syncsrv.h xorg-server/Xext/xvmain.c xorg-server/Xi/exevents.c xorg-server/Xi/opendev.c xorg-server/composite/compalloc.c xorg-server/composite/compoverlay.c xorg-server/dix/colormap.c xorg-server/dix/devices.c xorg-server/dix/dispatch.c xorg-server/dix/dixfonts.c xorg-server/dix/eventconvert.c xorg-server/dix/events.c xorg-server/dix/gc.c xorg-server/dix/getevents.c xorg-server/dix/main.c xorg-server/dix/privates.c xorg-server/dix/registry.c xorg-server/dix/resource.c xorg-server/exa/exa_accel.c xorg-server/exa/exa_migration_classic.c xorg-server/exa/exa_unaccel.c xorg-server/fb/fb.h xorg-server/fb/fbcopy.c xorg-server/fb/fbpixmap.c xorg-server/glx/dispatch.h xorg-server/glx/glapi.h xorg-server/glx/glapi_gentable.c xorg-server/glx/glapitable.h xorg-server/glx/glprocs.h xorg-server/glx/glxcmds.c xorg-server/glx/glxcmdsswap.c xorg-server/glx/glxdricommon.c xorg-server/glx/glxdriswrast.c xorg-server/glx/glxext.c xorg-server/glx/indirect_dispatch.c xorg-server/glx/indirect_dispatch.h xorg-server/glx/indirect_dispatch_swap.c xorg-server/glx/indirect_size.h xorg-server/glx/indirect_size_get.h xorg-server/glx/indirect_table.c xorg-server/glx/indirect_util.c xorg-server/glx/rensize.c xorg-server/glx/single2swap.c xorg-server/glx/singlepix.c xorg-server/glx/singlepixswap.c xorg-server/glx/singlesize.c xorg-server/hw/dmx/dmxinit.c xorg-server/hw/kdrive/ephyr/ephyr.c xorg-server/hw/kdrive/ephyr/hostx.c xorg-server/hw/kdrive/ephyr/hostx.h xorg-server/hw/kdrive/src/kinput.c xorg-server/hw/xfree86/common/compiler.h xorg-server/hw/xwin/InitInput.c xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/glx/glwrap.c xorg-server/hw/xwin/glx/indirect.c xorg-server/hw/xwin/glx/wgl_ext_api.h xorg-server/hw/xwin/glx/winpriv.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winallpriv.c xorg-server/hw/xwin/winauth.c xorg-server/hw/xwin/winclipboard.h xorg-server/hw/xwin/winclipboardinit.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/wincmap.c xorg-server/hw/xwin/winconfig.c xorg-server/hw/xwin/wincreatewnd.c xorg-server/hw/xwin/wincursor.c xorg-server/hw/xwin/windialogs.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/wingc.c xorg-server/hw/xwin/wingetsp.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winlayouts.h xorg-server/hw/xwin/winmisc.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmsg.c xorg-server/hw/xwin/winmsg.h xorg-server/hw/xwin/winmultiwindowclass.c xorg-server/hw/xwin/winmultiwindowicons.c xorg-server/hw/xwin/winmultiwindowshape.c xorg-server/hw/xwin/winmultiwindowwindow.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winnativegdi.c xorg-server/hw/xwin/winpfbdd.c xorg-server/hw/xwin/winpixmap.c xorg-server/hw/xwin/winpolyline.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winregistry.c xorg-server/hw/xwin/winscrinit.c xorg-server/hw/xwin/winsetsp.c xorg-server/hw/xwin/winshaddd.c xorg-server/hw/xwin/winshadddnl.c xorg-server/hw/xwin/winshadgdi.c xorg-server/hw/xwin/wintrayicon.c xorg-server/hw/xwin/winwin32rootless.c xorg-server/hw/xwin/winwin32rootlesswindow.c xorg-server/hw/xwin/winwin32rootlesswndproc.c xorg-server/hw/xwin/winwindow.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwindowswm.c xorg-server/hw/xwin/winwndproc.c xorg-server/include/callback.h xorg-server/include/dixstruct.h xorg-server/include/misc.h xorg-server/include/os.h xorg-server/include/scrnintstr.h xorg-server/mi/micmap.c xorg-server/mi/miinitext.c xorg-server/mi/mioverlay.c xorg-server/mi/misprite.c xorg-server/mi/mivaltree.c xorg-server/mi/miwindow.c xorg-server/miext/damage/damage.c xorg-server/miext/rootless/rootlessGC.c xorg-server/miext/rootless/rootlessWindow.c xorg-server/os/WaitFor.c xorg-server/os/access.c xorg-server/os/connection.c xorg-server/os/io.c xorg-server/os/log.c xorg-server/os/osinit.c xorg-server/os/utils.c xorg-server/os/xdmcp.c xorg-server/os/xprintf.c xorg-server/os/xstrans.c xorg-server/render/mipict.c xorg-server/xkb/xkbActions.c xorg-server/xkb/xkbInit.c xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/hw/xwin/winclipboardwndproc.c')
-rw-r--r--xorg-server/hw/xwin/winclipboardwndproc.c600
1 files changed, 283 insertions, 317 deletions
diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c
index 50a63001f..0dd39703d 100644
--- a/xorg-server/hw/xwin/winclipboardwndproc.c
+++ b/xorg-server/hw/xwin/winclipboardwndproc.c
@@ -52,36 +52,35 @@
* References to external symbols
*/
-extern Bool g_fUseUnicode;
-extern Bool g_fUnicodeSupport;
-extern void *g_pClipboardDisplay;
-extern Window g_iClipboardWindow;
-extern Atom g_atomLastOwnedSelection;
+extern Bool g_fUseUnicode;
+extern Bool g_fUnicodeSupport;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
extern Bool g_fClipboardStarted;
extern HWND g_hwndClipboard;
extern Bool g_fClipboardPrimary;
-
/*
* Local function prototypes
*/
static int
-winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
- Bool fUseUnicode, int iTimeoutSec);
+winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
+ Bool fUseUnicode, int iTimeoutSec);
/*
* Process X events up to specified timeout
*/
static int
-winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
- Bool fUseUnicode, int iTimeoutSec)
+winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
+ Bool fUseUnicode, int iTimeoutSec)
{
- int iConnNumber;
- struct timeval tv;
- int iReturn;
- DWORD dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
+ int iConnNumber;
+ struct timeval tv;
+ int iReturn;
+ DWORD dwStopTime = (GetTickCount() / 1000) + iTimeoutSec;
/* Make sure the output messages are sent before waiting on a response. */
iReturn = winClipboardFlushXEvents (hwnd,
@@ -95,58 +94,51 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
return iReturn;
}
- /* Get our connection number */
- iConnNumber = ConnectionNumber (pDisplay);
-
- /* Loop for X events */
- while (1)
- {
- fd_set fdsRead;
-
- /* Setup the file descriptor set */
- FD_ZERO (&fdsRead);
- FD_SET (iConnNumber, &fdsRead);
-
- /* Adjust timeout */
- tv.tv_sec = dwStopTime - (GetTickCount () / 1000);
- tv.tv_usec = 0;
-
- /* Break out if no time left */
- if (tv.tv_sec < 0)
- return WIN_XEVENTS_SUCCESS;
-
- /* Wait for an X event */
- iReturn = select (iConnNumber + 1,/* Highest fds number */
- &fdsRead, /* Read mask */
- NULL, /* No write mask */
- NULL, /* No exception mask */
- &tv); /* No timeout */
- if (iReturn < 0)
- {
- ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d (%x). "
- "Bailing.\n", iReturn, WSAGetLastError());
- break;
- }
+ /* Get our connection number */
+ iConnNumber = ConnectionNumber(pDisplay);
+
+ /* Loop for X events */
+ while (1) {
+ fd_set fdsRead;
+
+ /* Setup the file descriptor set */
+ FD_ZERO(&fdsRead);
+ FD_SET(iConnNumber, &fdsRead);
+
+ /* Adjust timeout */
+ tv.tv_sec = dwStopTime - (GetTickCount() / 1000);
+ tv.tv_usec = 0;
+
+ /* Break out if no time left */
+ if (tv.tv_sec < 0)
+ return WIN_XEVENTS_SUCCESS;
+
+ /* Wait for an X event */
+ iReturn = select(iConnNumber + 1, /* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
+ &tv); /* No timeout */
+ if (iReturn < 0) {
+ ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d (%x). "
+ "Bailing.\n", iReturn, WSAGetLastError());
+ break;
+ }
- /* Branch on which descriptor became active */
- if (FD_ISSET (iConnNumber, &fdsRead))
- {
- /* Process X events */
- /* Exit when we see that server is shutting down */
- iReturn = winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode,
- TRUE);
- if (WIN_XEVENTS_NOTIFY == iReturn)
- {
- /* Bail out if notify processed */
- return iReturn;
- }
- }
+ /* Branch on which descriptor became active */
+ if (FD_ISSET(iConnNumber, &fdsRead)) {
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents(hwnd,
+ iWindow, pDisplay, fUseUnicode, TRUE);
+ if (WIN_XEVENTS_NOTIFY == iReturn) {
+ /* Bail out if notify processed */
+ return iReturn;
+ }
+ }
}
- return WIN_XEVENTS_SUCCESS;
+ return WIN_XEVENTS_SUCCESS;
}
/*
@@ -154,35 +146,33 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
*/
LRESULT CALLBACK
-winClipboardWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
+winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static HWND s_hwndNextViewer;
+ static HWND s_hwndNextViewer;
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_DESTROY:
- {
- winDebug ("winClipboardWindowProc - WM_DESTROY\n");
+ {
+ winDebug("winClipboardWindowProc - WM_DESTROY\n");
- /* Remove ourselves from the clipboard chain */
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
-
- s_hwndNextViewer = NULL;
- g_hwndClipboard = NULL;
- PostQuitMessage (0);
- }
- return 0;
+ /* Remove ourselves from the clipboard chain */
+ ChangeClipboardChain(hwnd, s_hwndNextViewer);
+ s_hwndNextViewer = NULL;
+ g_hwndClipboard = NULL;
+ PostQuitMessage(0);
+ }
+ return 0;
case WM_CREATE:
- {
- HWND first, next;
- DWORD error_code = 0;
- winDebug ("winClipboardWindowProc - WM_CREATE\n");
-
- /* Add ourselves to the clipboard viewer chain */
+ {
+ HWND first, next;
+ DWORD error_code = 0;
+
+ winDebug("winClipboardWindowProc - WM_CREATE\n");
+
+ /* Add ourselves to the clipboard viewer chain */
s_hwndNextViewer = SetClipboardViewer (hwnd);
#ifdef _DEBUG
if (s_hwndNextViewer== hwnd)
@@ -192,55 +182,51 @@ winClipboardWindowProc (HWND hwnd, UINT message,
}
#endif
- }
- return 0;
-
+ }
+ return 0;
case WM_CHANGECBCHAIN:
- {
- winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
- "lParam(%x) s_hwndNextViewer(%x)\n",
- wParam, lParam, s_hwndNextViewer);
+ {
+ winDebug("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
+ "lParam(%x) s_hwndNextViewer(%x)\n",
+ wParam, lParam, s_hwndNextViewer);
- if ((HWND) wParam == s_hwndNextViewer)
- {
- s_hwndNextViewer = (HWND) lParam;
- if (s_hwndNextViewer == hwnd)
- {
+ 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??? */
- }
- }
- else if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message,
- wParam, lParam);
+ }
+ }
+ else if (s_hwndNextViewer)
+ SendMessage(s_hwndNextViewer, message, wParam, lParam);
- }
- winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
- return 0;
+ }
+ winDebug("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
+ return 0;
case WM_WM_REINIT:
- {
+ {
/* Ensure that we're in the clipboard chain. Some apps,
* WinXP's remote desktop for one, don't play nice with the
* chain. This message is called whenever we receive a
* WM_ACTIVATEAPP message to ensure that we continue to
* receive clipboard messages.
- *
- * It might be possible to detect if we're still in the chain
- * by calling SendMessage (GetClipboardViewer(),
- * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
- * WM_DRAWCLIPBOARD message. That, however, might be more
- * expensive than just putting ourselves back into the chain.
- */
-
- HWND first, next;
- DWORD error_code = 0;
+ *
+ * It might be possible to detect if we're still in the chain
+ * by calling SendMessage (GetClipboardViewer(),
+ * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
+ * WM_DRAWCLIPBOARD message. That, however, might be more
+ * expensive than just putting ourselves back into the chain.
+ */
+
+ HWND first, next;
+ DWORD error_code = 0;
if (!g_hwndClipboard)
return 0;
- winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
+ winDebug("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
+ first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
if (first != hwnd)
{
winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
@@ -258,17 +244,16 @@ winClipboardWindowProc (HWND hwnd, UINT message,
}
winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
}
- return 0;
-
+ 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;
+ {
+ 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);
@@ -280,50 +265,46 @@ winClipboardWindowProc (HWND hwnd, UINT message,
return 0;
}
- if (generation != serverGeneration)
- {
+ 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.
- */
- if (! s_fProcessingDrawClipboard)
- {
- s_fProcessingDrawClipboard = TRUE;
- }
- else
- {
- /* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
+ 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.
+ */
+ if (!s_fProcessingDrawClipboard) {
+ s_fProcessingDrawClipboard = TRUE;
+ }
+ else {
+ /* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
+ ChangeClipboardChain(hwnd, s_hwndNextViewer);
winFixClipboardChain(1);
ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Nested calls detected. Re-initing.\n");
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- return 0;
- }
-
- /*
- * Do not take ownership of the X11 selections when something
- * other than CF_TEXT or CF_UNICODETEXT has been copied
- * into the Win32 clipboard.
- */
- if (!IsClipboardFormatAvailable (CF_TEXT)
- && !IsClipboardFormatAvailable (CF_UNICODETEXT))
- {
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Clipboard does not contain CF_TEXT nor "
- "CF_UNICODETEXT.\n");
+ "Nested calls detected. Re-initing.\n");
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ return 0;
+ }
- /*
- * We need to make sure that the X Server has processed
- * previous XSetSelectionOwner messages.
- */
- XSync (pDisplay, FALSE);
+ /*
+ * Do not take ownership of the X11 selections when something
+ * other than CF_TEXT or CF_UNICODETEXT has been copied
+ * into the Win32 clipboard.
+ */
+ if (!IsClipboardFormatAvailable(CF_TEXT)
+ && !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
+
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Clipboard does not contain CF_TEXT nor "
+ "CF_UNICODETEXT.\n");
+
+ /*
+ * We need to make sure that the X Server has processed
+ * previous XSetSelectionOwner messages.
+ */
+ XSync(pDisplay, FALSE);
if (g_fClipboardPrimary)
{
@@ -342,28 +323,24 @@ winClipboardWindowProc (HWND hwnd, UINT message,
ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
"XGetSelection failed for PRIMARY: %d\n", iReturn);
}
- /* Release CLIPBOARD selection if owned */
- iReturn = XGetSelectionOwner (pDisplay,
- atomClipboard);
- if (iReturn == g_iClipboardWindow)
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "CLIPBOARD selection is owned by us.\n");
- XSetSelectionOwner (pDisplay,
- atomClipboard,
- None,
- CurrentTime);
- }
- else if (BadWindow == iReturn || BadAtom == iReturn)
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "XGetSelection failed for CLIPBOARD: %d\n", iReturn);
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
- }
+ /* Release CLIPBOARD selection if owned */
+ iReturn = XGetSelectionOwner(pDisplay, atomClipboard);
+ if (iReturn == g_iClipboardWindow) {
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "CLIPBOARD selection is owned by us.\n");
+ XSetSelectionOwner(pDisplay, atomClipboard, None, CurrentTime);
+ }
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelection failed for CLIPBOARD: %d\n",
+ iReturn);
+
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ if (s_hwndNextViewer)
+ SendMessage(s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+ }
/* Only reassert ownership when we did not change the clipboard ourselves */
if (hwnd!=(HWND)wParam)
{
@@ -403,159 +380,148 @@ winClipboardWindowProc (HWND hwnd, UINT message,
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;
+ 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.
- * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
- * above. We only process this message to conform to the specs
- * for delayed clipboard rendering in Win32. You might think
- * that we need to release ownership of the X11 selections, but
- * we do not, because a WM_DRAWCLIPBOARD message will closely
- * follow this message and reassert ownership of the X11
- * selections, handling the issue for us.
- */
- winDebug ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
- return 0;
+ /*
+ * NOTE: Intentionally do nothing.
+ * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
+ * above. We only process this message to conform to the specs
+ * for delayed clipboard rendering in Win32. You might think
+ * that we need to release ownership of the X11 selections, but
+ * we do not, because a WM_DRAWCLIPBOARD message will closely
+ * follow this message and reassert ownership of the X11
+ * selections, handling the issue for us.
+ */
+ winDebug("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
+ return 0;
case WM_RENDERFORMAT:
case WM_RENDERALLFORMATS:
- {
- int iReturn;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
- Bool fConvertToUnicode;
-
- winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
-
- /* Flag whether to convert to Unicode or not */
- if (message == WM_RENDERALLFORMATS)
- fConvertToUnicode = FALSE;
- else
- fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
-
- /* Request the selection contents */
- iReturn = XConvertSelection (pDisplay,
- g_atomLastOwnedSelection,
- XInternAtom (pDisplay,
- "COMPOUND_TEXT", False),
- XInternAtom (pDisplay,
- WIN_LOCAL_PROPERTY, False),
- iWindow,
- CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow)
- {
- ErrorF ("winClipboardWindowProc - WM_RENDER*FORMAT - "
- "XConvertSelection () failed\n");
- break;
- }
+ {
+ int iReturn;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ Bool fConvertToUnicode;
+
+ winDebug("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
+
+ /* Flag whether to convert to Unicode or not */
+ if (message == WM_RENDERALLFORMATS)
+ fConvertToUnicode = FALSE;
+ else
+ fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
+
+ /* Request the selection contents */
+ iReturn = XConvertSelection(pDisplay,
+ g_atomLastOwnedSelection,
+ XInternAtom(pDisplay,
+ "COMPOUND_TEXT", False),
+ XInternAtom(pDisplay,
+ WIN_LOCAL_PROPERTY, False),
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow) {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMAT - "
+ "XConvertSelection () failed\n");
+ break;
+ }
- /* Special handling for WM_RENDERALLFORMATS */
- if (message == WM_RENDERALLFORMATS)
- {
- /* We must open and empty the clipboard */
- if (!OpenClipboard (hwnd))
- {
- ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
- "OpenClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
-
- if (!EmptyClipboard ())
- {
- ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
- "EmptyClipboard () failed: %08x\n",
- GetLastError ());
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS) {
+ /* We must open and empty the clipboard */
+ if (!OpenClipboard(hwnd)) {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "OpenClipboard () failed: %08x\n",
+ GetLastError());
+ break;
+ }
+
+ if (!EmptyClipboard()) {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "EmptyClipboard () failed: %08x\n",
+ GetLastError());
CloseClipboard ();
- break;
- }
- }
+ break;
+ }
+ }
- /* Process the SelectionNotify event */
- iReturn = winProcessXEventsTimeout (hwnd,
- iWindow,
- pDisplay,
- fConvertToUnicode,
- WIN_POLL_TIMEOUT);
-
- /*
- * The last call to winProcessXEventsTimeout
- * from above had better have seen a notify event, or else we
- * are dealing with a buggy or old X11 app. In these cases we
- * have to paste some fake data to the Win32 clipboard to
- * satisfy the requirement that we write something to it.
- */
- if (WIN_XEVENTS_NOTIFY != iReturn)
- {
- ErrorF("winClipboardWindowProc - winProcessXEventsTimeout should have returned WIN_XEVENTS_NOTIFY was %d\n",iReturn);
- /* Paste no data, to satisfy required call to SetClipboardData */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
- SetClipboardData (CF_TEXT, NULL);
+ /* Process the SelectionNotify event */
+ iReturn = winProcessXEventsTimeout(hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode, WIN_POLL_TIMEOUT);
+
+ /*
+ * The last call to winProcessXEventsTimeout
+ * from above had better have seen a notify event, or else we
+ * are dealing with a buggy or old X11 app. In these cases we
+ * have to paste some fake data to the Win32 clipboard to
+ * satisfy the requirement that we write something to it.
+ */
+ if (WIN_XEVENTS_NOTIFY != iReturn) {
+ ErrorF("winClipboardWindowProc - winProcessXEventsTimeout should have returned WIN_XEVENTS_NOTIFY was %d\n",iReturn);
+ /* Paste no data, to satisfy required call to SetClipboardData */
+ if (g_fUnicodeSupport)
+ SetClipboardData(CF_UNICODETEXT, NULL);
+ SetClipboardData(CF_TEXT, NULL);
+
+ ErrorF
+ ("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
+ }
- ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
- }
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS) {
+ /* We must close the clipboard */
- /* Special handling for WM_RENDERALLFORMATS */
- if (message == WM_RENDERALLFORMATS)
- {
- /* We must close the clipboard */
-
- if (!CloseClipboard ())
- {
- ErrorF ("winClipboardWindowProc - WM_RENDERALLFORMATS - "
- "CloseClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
- }
+ if (!CloseClipboard()) {
+ ErrorF ("winClipboardWindowProc - WM_RENDERALLFORMATS - "
+ "CloseClipboard () failed: %08x\n",
+ GetLastError());
+ break;
+ }
+ }
- winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
- return 0;
- }
+ winDebug("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
+ return 0;
+ }
}
- /* Let Windows perform default processing for unhandled messages */
- return DefWindowProc (hwnd, message, wParam, lParam);
+ /* Let Windows perform default processing for unhandled messages */
+ return DefWindowProc(hwnd, message, wParam, lParam);
}
-
/*
* Process any pending Windows messages
*/
BOOL
-winClipboardFlushWindowsMessageQueue (HWND hwnd)
+winClipboardFlushWindowsMessageQueue(HWND hwnd)
{
- MSG msg;
-
- /* Flush the messaging window queue */
- /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
- * as this will filter out many non-window-specific messages that
- * are sent to our thread, such as WM_QUIT.
- */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- /* Dispatch the message if not WM_QUIT */
- if (msg.message == WM_QUIT)
- return FALSE;
- else
- DispatchMessage (&msg);
+ MSG msg;
+
+ /* Flush the messaging window queue */
+ /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
+ * as this will filter out many non-window-specific messages that
+ * are sent to our thread, such as WM_QUIT.
+ */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ /* Dispatch the message if not WM_QUIT */
+ if (msg.message == WM_QUIT)
+ return FALSE;
+ else
+ DispatchMessage(&msg);
}
-
- return TRUE;
+
+ return TRUE;
}