aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/pbproxy
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-28 07:58:00 +0000
committermarha <marha@users.sourceforge.net>2011-04-28 07:58:00 +0000
commit57a879849643e79d9674198a3a77c59532fb79b4 (patch)
tree19ece2254fadb6c2077aa09098dd8a51a5578d2a /xorg-server/hw/xquartz/pbproxy
parent96d6df5da9cddedf4931bf8e17f96e242467c661 (diff)
downloadvcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.tar.gz
vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.tar.bz2
vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.zip
xserver xkeyboard-config mesa git update 28 Apr 2011
Diffstat (limited to 'xorg-server/hw/xquartz/pbproxy')
-rw-r--r--xorg-server/hw/xquartz/pbproxy/Makefile.am2
-rw-r--r--xorg-server/hw/xquartz/pbproxy/app-main.m18
-rw-r--r--xorg-server/hw/xquartz/pbproxy/main.m314
-rw-r--r--xorg-server/hw/xquartz/pbproxy/pbproxy.h10
-rw-r--r--xorg-server/hw/xquartz/pbproxy/x-input.m2
-rw-r--r--xorg-server/hw/xquartz/pbproxy/x-selection.m155
6 files changed, 258 insertions, 243 deletions
diff --git a/xorg-server/hw/xquartz/pbproxy/Makefile.am b/xorg-server/hw/xquartz/pbproxy/Makefile.am
index 188664259..b8b95d232 100644
--- a/xorg-server/hw/xquartz/pbproxy/Makefile.am
+++ b/xorg-server/hw/xquartz/pbproxy/Makefile.am
@@ -1,5 +1,5 @@
AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \
- -DLAUNCHD_ID_PREFIX=\"$(LAUNCHD_ID_PREFIX)\"
+ -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\"
AM_CFLAGS=$(XPBPROXY_CFLAGS)
diff --git a/xorg-server/hw/xquartz/pbproxy/app-main.m b/xorg-server/hw/xquartz/pbproxy/app-main.m
index b00e90a6d..9055bad06 100644
--- a/xorg-server/hw/xquartz/pbproxy/app-main.m
+++ b/xorg-server/hw/xquartz/pbproxy/app-main.m
@@ -34,7 +34,7 @@
#include <unistd.h> /*for getpid*/
#include <Cocoa/Cocoa.h>
-static const char *app_prefs_domain = LAUNCHD_ID_PREFIX".xpbproxy";
+static const char *app_prefs_domain = BUNDLE_ID_PREFIX".xpbproxy";
CFStringRef app_prefs_domain_cfstr;
/* Stubs */
@@ -53,12 +53,22 @@ static void signal_handler (int sig) {
}
}
+void
+ErrorF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+}
+
int main (int argc, const char *argv[]) {
const char *s;
int i;
#ifdef DEBUG
- printf("pid: %u\n", getpid());
+ ErrorF("pid: %u\n", getpid());
#endif
xpbproxy_is_standalone = YES;
@@ -70,13 +80,13 @@ int main (int argc, const char *argv[]) {
if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
app_prefs_domain = argv[++i];
} else if (strcmp (argv[i], "--help") == 0) {
- printf("usage: xpbproxy OPTIONS\n"
+ ErrorF("usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n", app_prefs_domain);
return 0;
} else {
- fprintf(stderr, "usage: xpbproxy OPTIONS...\n"
+ ErrorF("usage: xpbproxy OPTIONS...\n"
"Try 'xpbproxy --help' for more information.\n");
return 1;
}
diff --git a/xorg-server/hw/xquartz/pbproxy/main.m b/xorg-server/hw/xquartz/pbproxy/main.m
index cfdc7696d..dbdb6d05c 100644
--- a/xorg-server/hw/xquartz/pbproxy/main.m
+++ b/xorg-server/hw/xquartz/pbproxy/main.m
@@ -1,165 +1,149 @@
-/* main.m
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
- */
-
-#include "pbproxy.h"
-#import "x-selection.h"
-
-#include <pthread.h>
-#include <unistd.h>
-#include <X11/extensions/applewm.h>
-
-Display *xpbproxy_dpy;
-int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
-int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
-BOOL xpbproxy_have_xfixes;
-
-extern char *display;
-
-#ifdef STANDALONE_XPBPROXY
-BOOL xpbproxy_is_standalone = NO;
-#endif
-
-x_selection *_selection_object;
-
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
-
-static inline void wait_for_server_init(void) {
- /* If the server hasn't finished initializing, wait for it... */
- if(!serverInitComplete) {
- pthread_mutex_lock(&serverInitCompleteMutex);
- while(!serverInitComplete)
- pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
- pthread_mutex_unlock(&serverInitCompleteMutex);
- }
-}
-
-static int x_io_error_handler (Display *dpy) {
- /* We lost our connection to the server. */
-
- TRACE ();
-
- /* trigger the thread to restart?
- * NO - this would be to a "deeper" problem, and restarts would just
- * make things worse...
- */
-#ifdef STANDALONE_XPBPROXY
- if(xpbproxy_is_standalone)
- exit(EXIT_FAILURE);
-#endif
-
- /* Prevent _XIOError from calling exit() */
- pthread_exit(NULL);
- return 0;
-}
-
-static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
- return 0;
-}
-
-int xpbproxy_run (void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- size_t i;
-
- wait_for_server_init();
-
- for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
- xpbproxy_dpy = XOpenDisplay(NULL);
-
- if(!xpbproxy_dpy && display) {
- char _display[32];
- snprintf(_display, sizeof(_display), ":%s", display);
- setenv("DISPLAY", _display, TRUE);
-
- xpbproxy_dpy=XOpenDisplay(_display);
- }
- if(!xpbproxy_dpy)
- sleep(1);
- }
-
- if (xpbproxy_dpy == NULL) {
- fprintf (stderr, "xpbproxy: can't open default display\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- XSetIOErrorHandler (x_io_error_handler);
- XSetErrorHandler (x_error_handler);
-
- if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
- &xpbproxy_apple_wm_error_base)) {
- fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
-
- XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
- AppleWMPasteboardNotifyMask);
-
- _selection_object = [[x_selection alloc] init];
-
- if(!xpbproxy_input_register()) {
- [pool release];
- return EXIT_FAILURE;
- }
-
- [pool release];
-
- CFRunLoopRun();
-
- return EXIT_SUCCESS;
-}
-
-id xpbproxy_selection_object (void) {
- return _selection_object;
-}
-
-Time xpbproxy_current_timestamp (void) {
- /* FIXME: may want to fetch a timestamp from the server.. */
- return CurrentTime;
-}
-
-void debug_printf (const char *fmt, ...) {
- static int spew = -1;
-
- if (spew == -1) {
- char *x = getenv ("DEBUG");
- spew = (x != NULL && atoi (x) != 0);
- }
-
- if (spew) {
- va_list args;
- va_start(args, fmt);
- vfprintf (stderr, fmt, args);
- va_end(args);
- }
-}
+/* main.m
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization.
+ */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <pthread.h>
+#include <unistd.h>
+#include <X11/extensions/applewm.h>
+
+Display *xpbproxy_dpy;
+int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
+int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
+BOOL xpbproxy_have_xfixes;
+
+extern char *display;
+
+#ifdef STANDALONE_XPBPROXY
+BOOL xpbproxy_is_standalone = NO;
+#endif
+
+x_selection *_selection_object;
+
+extern BOOL serverInitComplete;
+extern pthread_mutex_t serverInitCompleteMutex;
+extern pthread_cond_t serverInitCompleteCond;
+
+static inline void wait_for_server_init(void) {
+ /* If the server hasn't finished initializing, wait for it... */
+ if(!serverInitComplete) {
+ pthread_mutex_lock(&serverInitCompleteMutex);
+ while(!serverInitComplete)
+ pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
+ pthread_mutex_unlock(&serverInitCompleteMutex);
+ }
+}
+
+static int x_io_error_handler (Display *dpy) {
+ /* We lost our connection to the server. */
+
+ TRACE ();
+
+ /* trigger the thread to restart?
+ * NO - this would be to a "deeper" problem, and restarts would just
+ * make things worse...
+ */
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_is_standalone)
+ exit(EXIT_FAILURE);
+#endif
+
+ /* Prevent _XIOError from calling exit() */
+ pthread_exit(NULL);
+ return 0;
+}
+
+static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
+ return 0;
+}
+
+int xpbproxy_run (void) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ size_t i;
+
+ wait_for_server_init();
+
+ for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
+ xpbproxy_dpy = XOpenDisplay(NULL);
+
+ if(!xpbproxy_dpy && display) {
+ char _display[32];
+ snprintf(_display, sizeof(_display), ":%s", display);
+ setenv("DISPLAY", _display, TRUE);
+
+ xpbproxy_dpy=XOpenDisplay(_display);
+ }
+ if(!xpbproxy_dpy)
+ sleep(1);
+ }
+
+ if (xpbproxy_dpy == NULL) {
+ ErrorF("xpbproxy: can't open default display\n");
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ XSetIOErrorHandler (x_io_error_handler);
+ XSetErrorHandler (x_error_handler);
+
+ if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
+ &xpbproxy_apple_wm_error_base)) {
+ ErrorF("xpbproxy: can't open AppleWM server extension\n");
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
+
+ XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
+ AppleWMPasteboardNotifyMask);
+
+ _selection_object = [[x_selection alloc] init];
+
+ if(!xpbproxy_input_register()) {
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ [pool release];
+
+ CFRunLoopRun();
+
+ return EXIT_SUCCESS;
+}
+
+id xpbproxy_selection_object (void) {
+ return _selection_object;
+}
+
+Time xpbproxy_current_timestamp (void) {
+ /* FIXME: may want to fetch a timestamp from the server.. */
+ return CurrentTime;
+}
diff --git a/xorg-server/hw/xquartz/pbproxy/pbproxy.h b/xorg-server/hw/xquartz/pbproxy/pbproxy.h
index 013f981d4..fcbf4c4ba 100644
--- a/xorg-server/hw/xquartz/pbproxy/pbproxy.h
+++ b/xorg-server/hw/xquartz/pbproxy/pbproxy.h
@@ -77,14 +77,16 @@ extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */
extern BOOL xpbproxy_input_register (void);
+/* os/log.c or app-main.m */
+extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+
#ifdef DEBUG
/* BEWARE: this can cause a string memory leak, according to the leaks program. */
-# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
+# define DebugF(msg, args...) ErrorF("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
#else
-# define DB(msg, args...) do {} while (0)
+# define DebugF(...) /* */
#endif
-#define TRACE() DB("TRACE\n")
-extern void debug_printf (const char *fmt, ...);
+#define TRACE() DebugF("TRACE\n")
#endif /* PBPROXY_H */
diff --git a/xorg-server/hw/xquartz/pbproxy/x-input.m b/xorg-server/hw/xquartz/pbproxy/x-input.m
index 405ba3c73..ebb89980f 100644
--- a/xorg-server/hw/xquartz/pbproxy/x-input.m
+++ b/xorg-server/hw/xquartz/pbproxy/x-input.m
@@ -87,7 +87,7 @@ static void xpbproxy_process_xevents(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if(pool == nil) {
- fprintf(stderr, "unable to allocate/init auto release pool!\n");
+ ErrorF("unable to allocate/init auto release pool!\n");
return;
}
diff --git a/xorg-server/hw/xquartz/pbproxy/x-selection.m b/xorg-server/hw/xquartz/pbproxy/x-selection.m
index ef84f8bfb..7964f5193 100644
--- a/xorg-server/hw/xquartz/pbproxy/x-selection.m
+++ b/xorg-server/hw/xquartz/pbproxy/x-selection.m
@@ -81,19 +81,19 @@ static struct propdata null_propdata = {NULL, 0, 0};
#ifdef DEBUG
static void
-dump_prefs (FILE *fp) {
- fprintf(fp,
- "pbproxy preferences:\n"
- "\tactive %u\n"
- "\tprimary_on_grab %u\n"
- "\tclipboard_to_pasteboard %u\n"
- "\tpasteboard_to_primary %u\n"
- "\tpasteboard_to_clipboard %u\n",
- pbproxy_prefs.active,
- pbproxy_prefs.primary_on_grab,
- pbproxy_prefs.clipboard_to_pasteboard,
- pbproxy_prefs.pasteboard_to_primary,
- pbproxy_prefs.pasteboard_to_clipboard);
+dump_prefs() {
+ ErrorF(fp,
+ "pbproxy preferences:\n"
+ "\tactive %u\n"
+ "\tprimary_on_grab %u\n"
+ "\tclipboard_to_pasteboard %u\n"
+ "\tpasteboard_to_primary %u\n"
+ "\tpasteboard_to_clipboard %u\n",
+ pbproxy_prefs.active,
+ pbproxy_prefs.primary_on_grab,
+ pbproxy_prefs.clipboard_to_pasteboard,
+ pbproxy_prefs.pasteboard_to_primary,
+ pbproxy_prefs.pasteboard_to_clipboard);
}
#endif
@@ -152,7 +152,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
unsigned char *newbuf = NULL;
#ifdef TEST
- printf("bytesleft %lu\n", bytesleft);
+ ErrorF("bytesleft %lu\n", bytesleft);
#endif
if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
@@ -161,24 +161,29 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
type, &format, &numitems,
&bytesleft, &chunk))
{
- DB ("Error while getting window property.\n");
+ DebugF ("Error while getting window property.\n");
*pdata = null_propdata;
free (buf);
return True;
}
#ifdef TEST
- printf("format %d numitems %lu bytesleft %lu\n",
+ ErrorF("format %d numitems %lu bytesleft %lu\n",
format, numitems, bytesleft);
- printf("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
+ ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
#endif
/* Format is the number of bits. */
- chunkbytesize = numitems * (format / 8);
+ if (format == 8)
+ chunkbytesize = numitems;
+ else if (format == 16)
+ chunkbytesize = numitems * sizeof(short);
+ else if (format == 32)
+ chunkbytesize = numitems * sizeof(long);
#ifdef TEST
- printf("chunkbytesize %zu\n", chunkbytesize);
+ ErrorF("chunkbytesize %zu\n", chunkbytesize);
#endif
newbuflen = buflen + chunkbytesize;
if (newbuflen > 0)
@@ -206,7 +211,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
}
#ifdef TEST
- printf("bytesleft %lu\n", bytesleft);
+ ErrorF("bytesleft %lu\n", bytesleft);
#endif
} while (bytesleft > 0);
@@ -231,13 +236,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (pdata->format != 32)
{
- fprintf(stderr, "Atom list is expected to be formatted as an array of 32bit values.\n");
+ ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
return None;
}
- for (i = 0, step = pdata->format >> 3; i < pdata->length; i += step)
+ for (i = 0, step = sizeof(long); i < pdata->length; i += step)
{
- a = (Atom)*(uint32_t *)(pdata->data + i);
+ a = (Atom)*(long *)(pdata->data + i);
if (a == atoms->image_png)
{
@@ -260,7 +265,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
char *type = XGetAtomName(xpbproxy_dpy, a);
if (type)
{
- DB("Unhandled X11 mime type: %s", type);
+ DebugF("Unhandled X11 mime type: %s", type);
XFree(type);
}
}
@@ -373,7 +378,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (countNow != changeCount)
{
- DB ("changed pasteboard!\n");
+ DebugF ("changed pasteboard!\n");
changeCount = countNow;
if (pbproxy_prefs.pasteboard_to_primary)
@@ -457,9 +462,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return TRUE;
if(owner != None) {
- fprintf (stderr, "A clipboard manager using window 0x%lx "
- "already owns the clipboard selection. "
- "pbproxy will not sync clipboard to pasteboard.\n", owner);
+ ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. "
+ "pbproxy will not sync clipboard to pasteboard.\n", owner);
return FALSE;
}
@@ -486,7 +490,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE ();
- DB ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+ DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
if(e->selection == atoms->clipboard) {
/*
@@ -503,7 +507,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing
* to avoid a race.
*/
- fprintf(stderr, "Another clipboard manager was started! "
+ ErrorF("Another clipboard manager was started! "
"xpbproxy is disabling syncing with clipboard.\n");
pbproxy_prefs.clipboard_to_pasteboard = NO;
}
@@ -528,7 +532,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* The owner probably died or we are just starting up pbproxy.
* Set pbproxy's _selection_window as the owner, and continue.
*/
- DB ("No clipboard owner.\n");
+ DebugF ("No clipboard owner.\n");
[self copy_completed:atoms->clipboard];
return;
} else if (owner == _selection_window) {
@@ -536,7 +540,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return;
}
- DB ("requesting targets\n");
+ DebugF ("requesting targets\n");
request_atom = atoms->targets;
XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
@@ -576,7 +580,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* We are supposed to use an empty event mask, and not propagate
* the event, according to the ICCCM.
*/
- DB ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
+ DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
XFlush (xpbproxy_dpy);
@@ -613,7 +617,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if ([pbtypes containsObject:NSStringPboardType])
{
/* We have a string type that we can convert to UTF8, or Latin-1... */
- DB ("NSStringPboardType\n");
+ DebugF ("NSStringPboardType\n");
list[count] = atoms->utf8_string;
++count;
list[count] = atoms->string;
@@ -625,18 +629,26 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* TODO add the NSPICTPboardType back again, once we have conversion
* functionality in send_image.
*/
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
+#endif
if ([pbtypes containsObject:NSPICTPboardType]
|| [pbtypes containsObject:NSTIFFPboardType])
{
/* We can convert a TIFF to a PNG or JPEG. */
- DB ("NSTIFFPboardType\n");
+ DebugF ("NSTIFFPboardType\n");
list[count] = atoms->image_png;
++count;
list[count] = atoms->image_jpeg;
++count;
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
if (count)
{
/* We have a list of ATOMs to send. */
@@ -671,7 +683,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return;
}
- DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
+ DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
data = [pb stringForType:NSStringPboardType];
@@ -691,19 +703,19 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
length = strlen (bytes);
if (length < 50) {
- DB ("UTF-8: %s\n", bytes);
- DB ("UTF-8 length: %u\n", length);
+ DebugF ("UTF-8: %s\n", bytes);
+ DebugF ("UTF-8 length: %u\n", length);
}
}
else
{
- DB ("Latin-1\n");
+ DebugF ("Latin-1\n");
bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
/*WARNING: bytes is not NUL-terminated. */
length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
}
- DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+ DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
8, PropModeReplace, (unsigned char *) bytes, length);
@@ -745,7 +757,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
if (8 != textprop.format)
- DB ("textprop.format is unexpectedly not 8 - it's %d instead\n",
+ DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
textprop.format);
XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
@@ -837,7 +849,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == data)
{
[img autorelease];
- fprintf(stderr, "unable to convert PICT to TIFF!\n");
+ ErrorF("unable to convert PICT to TIFF!\n");
return YES;
}
@@ -913,7 +925,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
imagetype = NSJPEGFileType;
else
{
- fprintf(stderr, "internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
+ ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
}
pbtypes = [pb types];
@@ -925,7 +937,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype])
return;
}
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
+#endif
else if ([pbtypes containsObject:NSPICTPboardType])
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
{
if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype])
return;
@@ -977,7 +996,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != e->target)
- DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+ DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
if (e->target == atoms->targets)
{
@@ -1029,15 +1048,15 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[self release_pending];
if (None == e->property) {
- DB ("e->property is None.\n");
+ DebugF ("e->property is None.\n");
[self copy_completed:e->selection];
/* Nothing is selected. */
return;
}
#if 0
- printf ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
- printf ("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
+ ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+ ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
#endif
if ([self is_incr_type:e])
@@ -1046,7 +1065,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* This is an INCR-style transfer, which means that we
* will get the data after a series of PropertyNotify events.
*/
- DB ("is INCR\n");
+ DebugF ("is INCR\n");
if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
{
@@ -1063,7 +1082,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pending.requestor = e->requestor;
pending.selection = e->selection;
- DB ("set pending.requestor to 0x%lx\n", pending.requestor);
+ DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
}
else
{
@@ -1076,7 +1095,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* We have the complete selection data.*/
[self handle_selection:e->selection type:type propdata:&pdata];
- DB ("handled selection with the first notify_event\n");
+ DebugF ("handled selection with the first notify_event\n");
}
}
@@ -1096,7 +1115,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (name)
{
- DB ("e->atom %s\n", name);
+ DebugF ("e->atom %s\n", name);
XFree(name);
}
#endif
@@ -1104,7 +1123,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != pending.requestor && PropertyNewValue == e->state)
{
- DB ("pending.requestor 0x%lx\n", pending.requestor);
+ DebugF ("pending.requestor 0x%lx\n", pending.requestor);
if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
{
@@ -1146,7 +1165,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
case XFixesSelectionWindowDestroyNotify:
case XFixesSelectionClientCloseNotify:
default:
- fprintf(stderr, "Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
+ ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
break;
}
}
@@ -1176,7 +1195,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (name)
{
- DB ("requesting %s\n", name);
+ DebugF ("requesting %s\n", name);
}
#endif
request_atom = preferred;
@@ -1200,11 +1219,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == data)
{
- DB ("unable to create NSData object!\n");
+ DebugF ("unable to create NSData object!\n");
return;
}
- DB ("data retainCount before NSBitmapImageRep initWithData: %u\n",
+ DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
[data retainCount]);
bmimage = [[NSBitmapImageRep alloc] initWithData:data];
@@ -1212,11 +1231,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (nil == bmimage)
{
[data autorelease];
- DB ("unable to create NSBitmapImageRep!\n");
+ DebugF ("unable to create NSBitmapImageRep!\n");
return;
}
- DB ("data retainCount after NSBitmapImageRep initWithData: %u\n",
+ DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n",
[data retainCount]);
@try
@@ -1226,13 +1245,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
@catch (NSException *e)
{
- DB ("NSTIFFException!\n");
+ DebugF ("NSTIFFException!\n");
[data autorelease];
[bmimage autorelease];
return;
}
- DB ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
+ DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
@@ -1246,12 +1265,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil];
if (YES != [pb setData:tiff forType:NSTIFFPboardType])
{
- DB ("writing pasteboard data failed!\n");
+ DebugF ("writing pasteboard data failed!\n");
}
[data autorelease];
- DB ("bmimage retainCount before release %u\n", [bmimage retainCount]);
+ DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
[bmimage autorelease];
}
@@ -1279,10 +1298,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) {
- fprintf(stderr, "pasteboard setString:forType: failed!\n");
+ ErrorF("pasteboard setString:forType: failed!\n");
}
[string autorelease];
- DB ("done handling utf8 string\n");
+ DebugF ("done handling utf8 string\n");
}
/* This handles the STRING type, which should be in Latin-1. */
@@ -1308,7 +1327,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
[pb declareTypes:pbtypes owner:nil];
if (YES != [pb setString:string forType:NSStringPboardType]) {
- fprintf(stderr, "pasteboard setString:forType failed in handle_string!\n");
+ ErrorF("pasteboard setString:forType failed in handle_string!\n");
}
[string autorelease];
}
@@ -1374,7 +1393,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
name = XGetAtomName (xpbproxy_dpy, selection);
if (name)
{
- DB ("copy_completed: %s\n", name);
+ DebugF ("copy_completed: %s\n", name);
XFree (name);
}
#endif
@@ -1435,10 +1454,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
/* This is used for debugging. */
- //dump_prefs(stdout);
+ //dump_prefs();
if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
- fprintf(stderr, "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
+ ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
pbproxy_prefs.primary_on_grab = NO;
}