The count of wchar_t returned by MultiByteToWideChar() includes the terminating
null character, so don't add one to it.
Also, reduce the scope of various length variables
Signed-off-by: Colin Harrison <colin.harrison@virgin.net>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
If we are the clipboard owner when we are shutdown, we recieve a
WM_RENDERALLFORMATS, to render the clipboard, so it's contents will remain
available to other applications. Unfortunately, this is far too late to do
anything useful with, as the server is waiting for the clipboard thread to exit,
and so can't process requests to convert clipboard contents.
Change so we just do nothing on WM_RENDERALLFORMATS. (I'm not convinced that
WM_RENDERALLFORMATS has ever worked usefully, in any case).
(To make this work, I guess we would need to rearrange the way shutdown works
completely: first synchronously stop the clipboard, then stop the X server)
We also then receive a WM_DRAWCLIPBOARD, perhaps telling us that the available
clipboard formats have changed (as ones which haven't been rendered are now
removed), but the clipboard owner is now the system, not us, which we have to
arrange to ignore.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
It seems that the clipboard thread restart mechanism has been broken for a
while, which can be demonstrated using XDMCP with KDM (e.g. to a Kubutunu 12.04
host)
KDM kills all attached clients, including the clipboard integration client,
which restarts, but then exits on WM_QUIT.
Using PostQuitMessage() in WM_DESTROY is unhelpful, as we may not actually be
quitting the thread, if we just destroyed the window because the clipboard
thread is about to retry, because he WM_QUIT message sticks around, and is
noticed the next time we look at the window message queue and confuses us into
thinking we need to quit.
Sending a WM_DESTROY is apparently never correct anyhow, see [1]
So:
1/ Use DestroyWindow() to destroy the clipboard messaging window when cleaning
up for retry or exit in winClipboardProc (the clipboard thread main proc)
2/ Send a special WM_WM_QUIT message in winClipboardWindowDestroy() from the X
server thread when the X server is resetting.
3/ When processing that WM_WM_QUIT message in the clipboard thread, cause the
clipboard window to PostQuitMessage(), which causes the clipboard thread to
exit.
[1] http://blogs.msdn.com/b/oldnewthing/archive/2011/09/26/10216420.aspx
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Sometimes, particularly with large clipboard pastes to Windows, we could end up
waiting for the timeout to expire, rather than pasting the data.
Various changes to improve reliability:
1. Use XFlush() not XSync() in winProcessXEventsTimeout().
It makes no sense to ensure we have received replies to outstanding requests if
we are going to wait for them using select()
2. Add XFlush() to winClipboardProc()
Make sure we have sent any requests before we wait using select()
3. Don't use FD_ISSET() to check which fd is ready
This looks like a Cygwin select() bug in that it sometimes returns 0 with an
empty fd set before the timeout expires, but a fd appears to be ready.
Add select() return value to debug output when we are warning that this has
happened.
4. Drain event queues before entering select()
Unconditionally drain event queues before entering select(). This seems to be
the recommended way of writing select() and X event processing loops.
winClipboardFlushXEvents() checks using XPending(), and
winClipboardFlushWindowsMessageQueue() checks using PeekMessage() so this is
safe against blocking, but means that may not need to enter select() at all
sometimes.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
xwinclip: Add -noprimary option
Xwin: Add -primary and -noprimary options and tray-menu control
v2:
Use Bool type for fPrimarySelection
Add -noprimary to usage message
Fix indentation in hw/xwin/winwndproc.c
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
See http://cygwin.com/ml/cygwin-xfree/2013-07/msg00016.html
It looks like the change in a9aca218f5 had some
unforseen consequences.
If the X11 selection contents are not convertable to COMPOUND_TEXT, UTF8_STRING
or STRING format (for example, if it is an image), after those conversion
attempts have failed, we sit in winProcessXEventsTimeout() until the timeout
expires.
It also seems that maybe gnuplot doesn't respond correctly to this sequence of
conversion requests and doesn't reply to some of them, which also causes us to
sit in winProcessXEventsTimeout() until the timeout expires.
The Windows application which has requested the clipboard contents via
GetClipboardContents() is blocked until we return from WM_RENDERFORMAT, so
sitting waiting for this timeout to expire should be avoided.
So instead, explicitly request conversion to the TARGETS target, choose
the most preferred format, and request conversion to that.
Also: if there is no owned selection, there is nothing to paste, so don't bother
trying to convert it.
v2: Fix compilation with -Werror=declaration-after-statement
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Don't pointlessly retrieve just the size of the property, if we are then going
to assume we can retrieve the whole property in one request anyhow...
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winmsgwindow.c:99:11: warning: variable ‘winClass’ set but not used [-Wunused-but-set-variable]
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winprefslex.l:40:12: warning: redundant redeclaration of ‘yyparse’ [-Wredundant-decls]
winprefsyacc.h:130:5: note: previous declaration of ‘yyparse’ was here
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winprefsyacc.y:257:3: warning: nested extern declaration of ‘yylineno’ [-Wnested-externs]
Promote yylineno declaration to file scope
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winprefs.c:643:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winprefsyacc.y:174:5: warning: passing argument 1 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
winprefsyacc.y:174:5: warning: passing argument 3 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
winprefsyacc.y:175:5: warning: passing argument 3 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
winprefsyacc.y:178:5: warning: passing argument 3 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
winprefsyacc.c:1737:9: warning: passing argument 1 of ‘yyerror’ discards ‘const’ qualifier from pointer target type [enabled by default]
winprefsyacc.y:82:12: note: expected ‘char *’ but argument is of type ‘const char *’
winprefsyacc.c:1854:3: warning: passing argument 1 of ‘yyerror’ discards ‘const’ qualifier from pointer target type [enabled by default]
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
InitOutput.c:1032:19: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winmultiwindowicons.c:403:29: warning: passing argument 8 of ‘XGetWindowProperty’ from incompatible pointer type [enabled by default]
/usr/include/X11/Xlib.h:2688:12: note: expected ‘Atom *’ but argument is of type ‘long unsigned int *’
Looks like this has been wrong since I added it in 527cf131 :-(
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Fix various pieces of debug output, mainly under --enable-debug, which use a
"%08x" printf format for a pointer type. Use "%p" format for 64-bit portability.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
glext.h currently requires GL_GLEXT_PROTOTYPES in order to prototype
glCompressedTexImmage* functions
generated_gl_shim.c:2859:6: warning: no previous prototype for 'glCompressedTexImage3DARB' [-Wmissing-prototypes]
generated_gl_shim.c:2866:6: warning: no previous prototype for 'glCompressedTexImage2DARB' [-Wmissing-prototypes]
generated_gl_shim.c:2873:6: warning: no previous prototype for 'glCompressedTexImage1DARB' [-Wmissing-prototypes]
generated_gl_shim.c:2880:6: warning: no previous prototype for 'glCompressedTexSubImage3DARB' [-Wmissing-prototypes]
generated_gl_shim.c:2887:6: warning: no previous prototype for 'glCompressedTexSubImage2DARB' [-Wmissing-prototypes]
generated_gl_shim.c:2894:6: warning: no previous prototype for 'glCompressedTexSubImage1DARB' [-Wmissing-prototypes]
generated_gl_shim.c:2901:6: warning: no previous prototype for 'glGetCompressedTexImageARB' [-Wmissing-prototypes]
Also, explicitly prototype glXGetProcAddressARB(), as glx/glxdri*.c does, as
it's not practical to include glx.h here...
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
xevents.c: In function 'winClipboardInitMonitoredSelections':
xevents.c:129:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < CLIP_NUM_SELECTIONS; ++i)
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
winshadddnl.c: In function ‘winRedrawScreenShadowDDNL’:
winshadddnl.c:991:9: error: ‘return’ with no value, in function returning non-void [-Werror=return-type]
Just wrong in 1c34e774
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Again, as the documentation says, "unsupported, obsolete".
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Adam Jackson <ajax@redhat.com>
As the man page says, "unsupported, experimental, and barely
functional". The last even minor updates to any of this were back in
2004, presumably it's not getting better any time soon.
This is also the only GC ops implementation in the tree that actually
falls all the way down to the spans routines for everything, so that's
pretty nice to be rid of.
v2: Fix stray break statement (Jon)
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Adam Jackson <ajax@redhat.com>
No modern driver pays attention to this. Presumably there existed
hardware once where you couldn't just read the right values out of the
CRTC.
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Including any server header might define the macro _XSERVER64 on 64 bit
machines. That macro must _NOT_ be defined for Xlib client code, otherwise bad
things happen. So let's undef that macro if necessary.
Remove server directories from include path to ensure no server includes are
included
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Only use XSetIOErrorHandler() to add to the global XSetIOErrorHandler() chain
once. If we do it every restart, then we make a loop in the handler chain, and
we end up with a thread spinning in that loop when the server shuts down...
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Remove XOpenDisplay() retry code. This isn't a sensible thing for the
application to be doing, and XWin server needs to retry much more than just
XOpenDisplay().
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Check specially that setjmp() returned a value which we don't pass to longjmp()
seems a bit over-complex.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Also removing server headers we might clash with and no longer need. Make
a few adjustments to allow for this change:
- provide a prototype of ErrorF()
- use the MAX() macro provided by sys/param.h, not the max() macro provided by misc.h
- use the X 'Bool' type rather than the unwrapped Windows 'BOOL' type
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Add xwinclip test client, which includes stubs for winDebug(), ErrorF()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Consistently use ErrorF() rather than winErrorFVerb()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Look up all atoms of interest in clipboard code in winClipboardProc() and pass
them down.
This avoids the need to check serverGeneration to notice when we need to
invalidate cached atom values.
Also consistently use cached atom values everywhere, rather than sometimes just
doing XInternAtom() again.
Remove WIN_LOCAL_PROPERTY as unused now, as we only refer to CYGX_CUT_BUFFER
once and do that directly.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Add fUseUnicode as parameter to winClipboardProc()
Access g_fUseUnicode global when calling it
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Rename the libwinclipboard internal header from winclipboard.h to internal.h
Put libwinclipboard's public interface into winclipboard.h
This lets winclipboardinit.c partake of that public interface, and all X server
headers without clashes
winInitClipboard() prototype belongs in a server header
v2: Remove duplicate declaration of winClipboardWindowDestroy()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Return a shutdown flag from winClipboardProc(), and use it in
winClipboardThreadProc() to determine if we should stop.
Currently this is set if the clipboard messaging window received a WM_QUIT.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Move clipboard integration code down to a subdirectory and build as a
convenience library
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Move winFixClipboardChain() into winclipboardthread.c
Add winCLipboardWindowDestroy() function to access it for WM_DESTROY
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
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>
Move winClipboardCreateMessagingWindow() from winclipboardinit.c to
winclipboardthread.c, the only place that uses it, and make it static.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>