summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-11-15 19:52:34 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-11-15 19:52:34 -0800
commite8112784e8ef80a96ed54eca7e148b424001a38f (patch)
treeb396d0d050ae849861ca768b2873dbf979f3e614 /hw
parent24928b85dc996c8d0a052ddf383df25718ee5305 (diff)
XQuartz: Integrated xpbproxy into the server.
Added a configure option called --enable-standalone-xpbproxy which is useful for deveoping xpbproxy. The 'active' switch in preferences just disables the in-server xpbproxy (not this standalone). (cherry picked from commit 42944936326ef8732f622db9f75b79a92980550d)
Diffstat (limited to 'hw')
-rw-r--r--hw/xquartz/Makefile.am4
-rw-r--r--hw/xquartz/X11Application.m6
-rw-r--r--hw/xquartz/mach-startup/Makefile.am5
-rw-r--r--hw/xquartz/pbproxy/Makefile.am8
-rw-r--r--hw/xquartz/pbproxy/app-main.m10
-rw-r--r--hw/xquartz/pbproxy/main.m51
-rw-r--r--hw/xquartz/pbproxy/pbproxy.h35
-rw-r--r--hw/xquartz/pbproxy/thread-main.m42
-rw-r--r--hw/xquartz/pbproxy/x-input.m62
-rw-r--r--hw/xquartz/pbproxy/x-selection.m126
10 files changed, 211 insertions, 138 deletions
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index cc1ff833b..f9d782382 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -13,9 +13,9 @@ if GLX
GL_DIR = GL
endif
-SUBDIRS = bundle . GL xpr mach-startup doc pbproxy
+SUBDIRS = bundle . GL xpr pbproxy mach-startup doc
-DIST_SUBDIRS = bundle . $(GL_DIR) xpr mach-startup doc pbproxy
+DIST_SUBDIRS = bundle . $(GL_DIR) xpr pbproxy mach-startup doc
libXquartz_la_SOURCES = \
$(top_srcdir)/fb/fbcmap_mi.c \
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index dbab3659d..5d77feaf2 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -50,6 +50,9 @@
#include <Xplugin.h>
+// pbproxy/pbproxy.h
+extern BOOL xpbproxy_init (void);
+
#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
#ifndef XSERVER_VERSION
@@ -884,6 +887,9 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
* an mieqEnqueue() - <rdar://problem/6300249>
*/
check_xinitrc();
+
+ if(!xpbproxy_init())
+ fprintf(stderr, "Error initializing xpbproxy\n");
[NSApp run];
/* not reached */
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index aa71f8e6f..64a53f354 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -17,12 +17,9 @@ X11_LDADD = \
$(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \
$(top_builddir)/dix/dixfonts.lo \
$(top_builddir)/miext/rootless/librootless.la \
+ $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin -lX11
-if INTEGRATED_XPBPROXY
-X11_LDADD += $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la
-endif
-
X11_LDFLAGS = \
-XCClinker -Objc \
-Wl,-u,_miDCInitialize \
diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index 2eee766ed..65e5e4a60 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -1,16 +1,14 @@
AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
AM_LDFLAGS=-L/usr/X11/lib -lX11 -lXfixes -lAppleWM -framework AppKit -framework Foundation -framework ApplicationServices
-SOURCE_FILES = \
+noinst_LTLIBRARIES = libxpbproxy.la
+libxpbproxy_la_SOURCES = \
trick_autotools.c \
main.m \
x-input.m \
x-selection.m
-noinst_LTLIBRARIES = libxpbproxy.la
-libxpbproxy_la_SOURCES = $(SOURCE_FILES)
-
-if !INTEGRATED_XPBPROXY
+if STANDALONE_XPBPROXY
bin_PROGRAMS = xpbproxy
xpbproxy_SOURCES = app-main.m
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 4fb5ea0b6..02ff96b52 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -10,12 +10,10 @@
#include <unistd.h> /*for getpid*/
#include <Cocoa/Cocoa.h>
-BOOL prefs_reload = NO;
-
static void signal_handler (int sig) {
switch(sig) {
case SIGHUP:
- prefs_reload = YES;
+ xpbproxy_prefs_reload = YES;
break;
default:
_exit(EXIT_SUCCESS);
@@ -23,11 +21,13 @@ static void signal_handler (int sig) {
}
int main (int argc, const char *argv[]) {
-#ifdef TEST
+#ifdef DEBUG
printf("pid: %u\n", getpid());
#endif
- if(!x_init())
+ xpbproxy_is_standalone = YES;
+
+ if(!xpbproxy_init())
return EXIT_FAILURE;
signal (SIGINT, signal_handler);
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index f023eee18..0d54099e9 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -9,10 +9,14 @@
#include <pthread.h>
#include <X11/extensions/applewm.h>
-Display *x_dpy;
-int x_apple_wm_event_base, x_apple_wm_error_base;
-int x_xfixes_event_base, x_xfixes_error_base;
-BOOL have_xfixes;
+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;
+
+#ifdef STANDALONE_XPBPROXY
+BOOL xpbproxy_is_standalone = NO;
+#endif
x_selection *_selection_object;
@@ -21,11 +25,15 @@ static int x_io_error_handler (Display *dpy) {
TRACE ();
- /* TODO: trigger the thread to restart? */
-#ifndef INTEGRATED_XPBPROXY
- exit(1);
+ /* 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
-
+
return 0;
}
@@ -33,45 +41,50 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
return 0;
}
-BOOL x_init (void) {
+BOOL xpbproxy_init (void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- x_dpy = XOpenDisplay (NULL);
- if (x_dpy == NULL) {
+ xpbproxy_dpy = XOpenDisplay (NULL);
+ if (xpbproxy_dpy == NULL) {
fprintf (stderr, "can't open default display\n");
+ [pool release];
return FALSE;
}
XSetIOErrorHandler (x_io_error_handler);
XSetErrorHandler (x_error_handler);
- if (!XAppleWMQueryExtension (x_dpy, &x_apple_wm_event_base,
- &x_apple_wm_error_base)) {
+ if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
+ &xpbproxy_apple_wm_error_base)) {
fprintf (stderr, "can't open AppleWM server extension\n");
+ [pool release];
return FALSE;
}
- have_xfixes = XFixesQueryExtension(x_dpy, &x_xfixes_event_base, &x_xfixes_error_base);
+ xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
- XAppleWMSelectInput (x_dpy, AppleWMActivationNotifyMask |
+ XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
AppleWMPasteboardNotifyMask);
_selection_object = [[x_selection alloc] init];
- if(!x_input_register())
+ if(!xpbproxy_input_register()) {
+ [pool release];
return FALSE;
- x_input_run();
+ }
+
+ xpbproxy_input_run();
[pool release];
return TRUE;
}
-id x_selection_object (void) {
+id xpbproxy_selection_object (void) {
return _selection_object;
}
-Time x_current_timestamp (void) {
+Time xpbproxy_current_timestamp (void) {
/* FIXME: may want to fetch a timestamp from the server.. */
return CurrentTime;
}
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index 60566a627..a807707cd 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -12,25 +12,34 @@
#include <X11/extensions/shape.h>
#undef Cursor
-#ifndef INTEGRATED_XPBPROXY
-extern BOOL prefs_reload;
+#ifdef STANDALONE_XPBPROXY
+/* Just used for the standalone to respond to SIGHUP to reload prefs */
+extern BOOL xpbproxy_prefs_reload;
+
+/* Setting this to YES (for the standalone app) causes us to ignore the
+ * 'sync_pasteboard' defaults preference since we assume it to be on... this is
+ * mainly useful for debugging/developing xpbproxy with XQuartz still running.
+ * Just disable the one in the server with X11's preference pane, then run
+ * the standalone app.
+ */
+extern BOOL xpbproxy_is_standalone;
#endif
/* from main.m */
-extern void x_set_is_active (BOOL state);
-extern BOOL x_get_is_active (void);
-extern id x_selection_object (void);
-extern Time x_current_timestamp (void);
-extern BOOL x_init (void);
+extern void xpbproxy_set_is_active (BOOL state);
+extern BOOL xpbproxy_get_is_active (void);
+extern id xpbproxy_selection_object (void);
+extern Time xpbproxy_current_timestamp (void);
+extern BOOL xpbproxy_init (void);
-extern Display *x_dpy;
-extern int x_apple_wm_event_base, x_apple_wm_error_base;
-extern int x_xfixes_event_base, x_xfixes_error_base;
-extern BOOL have_xfixes;
+extern Display *xpbproxy_dpy;
+extern int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
+extern int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
+extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */
-extern BOOL x_input_register (void);
-extern void x_input_run (void);
+extern BOOL xpbproxy_input_register (void);
+extern void xpbproxy_input_run (void);
#ifdef DEBUG
/* BEWARE: this can cause a string memory leak, according to the leaks program. */
diff --git a/hw/xquartz/pbproxy/thread-main.m b/hw/xquartz/pbproxy/thread-main.m
new file mode 100644
index 000000000..02ff96b52
--- /dev/null
+++ b/hw/xquartz/pbproxy/thread-main.m
@@ -0,0 +1,42 @@
+/* app-main.m
+ $Id: main.m,v 1.29 2007-04-07 20:39:03 jharper Exp $
+
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <pthread.h>
+#include <unistd.h> /*for getpid*/
+#include <Cocoa/Cocoa.h>
+
+static void signal_handler (int sig) {
+ switch(sig) {
+ case SIGHUP:
+ xpbproxy_prefs_reload = YES;
+ break;
+ default:
+ _exit(EXIT_SUCCESS);
+ }
+}
+
+int main (int argc, const char *argv[]) {
+#ifdef DEBUG
+ printf("pid: %u\n", getpid());
+#endif
+
+ xpbproxy_is_standalone = YES;
+
+ if(!xpbproxy_init())
+ return EXIT_FAILURE;
+
+ signal (SIGINT, signal_handler);
+ signal (SIGTERM, signal_handler);
+ signal (SIGHUP, signal_handler);
+ signal (SIGPIPE, SIG_IGN);
+
+ [NSApplication sharedApplication];
+ [NSApp run];
+
+ return EXIT_SUCCESS;
+}
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index e091ef15b..d71e9a5f8 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -15,21 +15,25 @@
#include <unistd.h>
-static CFRunLoopSourceRef x_dpy_source;
+static CFRunLoopSourceRef xpbproxy_dpy_source;
+
+#ifdef STANDALONE_XPBPROXY
+BOOL xpbproxy_prefs_reload = NO;
+#endif
/* Timestamp when the X server last told us it's active */
static Time last_activation_time;
static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
- int type = e->type - x_apple_wm_event_base;
+ int type = e->type - xpbproxy_apple_wm_event_base;
int kind = e->kind;
/* We want to reload prefs even if we're not active */
if(type == AppleWMActivationNotify &&
kind == AppleWMReloadPreferences)
- [x_selection_object() reload_preferences];
+ [xpbproxy_selection_object() reload_preferences];
- if(![x_selection_object() is_active])
+ if(![xpbproxy_selection_object() is_active])
return;
switch (type) {
@@ -37,11 +41,11 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
switch (kind) {
case AppleWMIsActive:
last_activation_time = e->time;
- [x_selection_object() x_active:e->time];
+ [xpbproxy_selection_object() x_active:e->time];
break;
case AppleWMIsInactive:
- [x_selection_object() x_inactive:e->time];
+ [xpbproxy_selection_object() x_inactive:e->time];
break;
}
break;
@@ -49,13 +53,13 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
case AppleWMPasteboardNotify:
switch (kind) {
case AppleWMCopyToPasteboard:
- [x_selection_object() x_copy:e->time];
+ [xpbproxy_selection_object() x_copy:e->time];
}
break;
}
}
-void x_input_run (void) {
+void xpbproxy_input_run (void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (nil == pool)
@@ -64,39 +68,39 @@ void x_input_run (void) {
return;
}
- while (XPending (x_dpy) != 0) {
+ while (XPending (xpbproxy_dpy) != 0) {
XEvent e;
- XNextEvent (x_dpy, &e);
+ XNextEvent (xpbproxy_dpy, &e);
switch (e.type) {
case SelectionClear:
- if([x_selection_object() is_active])
- [x_selection_object () clear_event:&e.xselectionclear];
+ if([xpbproxy_selection_object() is_active])
+ [xpbproxy_selection_object () clear_event:&e.xselectionclear];
break;
case SelectionRequest:
- [x_selection_object () request_event:&e.xselectionrequest];
+ [xpbproxy_selection_object () request_event:&e.xselectionrequest];
break;
case SelectionNotify:
- [x_selection_object () notify_event:&e.xselection];
+ [xpbproxy_selection_object () notify_event:&e.xselection];
break;
case PropertyNotify:
- [x_selection_object () property_event:&e.xproperty];
+ [xpbproxy_selection_object () property_event:&e.xproperty];
break;
default:
- if(e.type >= x_apple_wm_event_base &&
- e.type < x_apple_wm_event_base + AppleWMNumberEvents) {
+ if(e.type >= xpbproxy_apple_wm_event_base &&
+ e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
- } else if(e.type == x_xfixes_event_base + XFixesSelectionNotify) {
- [x_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
+ } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
+ [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
}
break;
}
- XFlush(x_dpy);
+ XFlush(xpbproxy_dpy);
}
[pool release];
@@ -129,17 +133,17 @@ static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
CFDataRef address, const void *data, void *info) {
-#ifndef INTEGRATED_XPBPROXY
- if(prefs_reload) {
- [x_selection_object() reload_preferences];
- prefs_reload = NO;
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_prefs_reload) {
+ [xpbproxy_selection_object() reload_preferences];
+ xpbproxy_prefs_reload = NO;
}
#endif
-
- x_input_run();
+
+ xpbproxy_input_run();
}
-BOOL x_input_register(void) {
- return add_input_socket(ConnectionNumber(x_dpy), kCFSocketReadCallBack,
- x_input_callback, NULL, &x_dpy_source);
+BOOL xpbproxy_input_register(void) {
+ return add_input_socket(ConnectionNumber(xpbproxy_dpy), kCFSocketReadCallBack,
+ x_input_callback, NULL, &xpbproxy_dpy_source);
}
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 490fceced..153e7ad5b 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -155,7 +155,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
printf("bytesleft %lu\n", bytesleft);
#endif
- if (Success != XGetWindowProperty (x_dpy, win, property,
+ if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
offset, length, delete,
AnyPropertyType,
type, &format, &numitems,
@@ -171,7 +171,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
printf("format %d numitems %lu bytesleft %lu\n",
format, numitems, bytesleft);
- printf("type %s\n", XGetAtomName (x_dpy, *type));
+ printf("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
#endif
/* Format is the number of bits. */
@@ -257,7 +257,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
}
else
{
- char *type = XGetAtomName(x_dpy, a);
+ char *type = XGetAtomName(xpbproxy_dpy, a);
if (type)
{
DB("Unhandled X11 mime type: %s", type);
@@ -293,7 +293,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE ();
- if (Success != XGetWindowProperty (x_dpy, e->requestor, e->property,
+ if (Success != XGetWindowProperty (xpbproxy_dpy, e->requestor, e->property,
/*offset*/ 0L, /*length*/ 4UL,
/*Delete*/ False,
AnyPropertyType, &seltype, &format,
@@ -378,7 +378,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (pbproxy_prefs.pasteboard_to_primary)
{
- XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
+ XSetSelectionOwner (xpbproxy_dpy, atoms->primary, _selection_window, CurrentTime);
}
if (pbproxy_prefs.pasteboard_to_clipboard) {
@@ -393,9 +393,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* Pasteboard has data we should proxy; I think it makes
sense to put it on both CLIPBOARD and PRIMARY */
- XSetSelectionOwner (x_dpy, atoms->clipboard,
+ XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard,
_selection_window, timestamp);
- XSetSelectionOwner (x_dpy, atoms->primary,
+ XSetSelectionOwner (xpbproxy_dpy, atoms->primary,
_selection_window, timestamp);
}
#endif
@@ -413,7 +413,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE ();
request_atom = atoms->targets;
- XConvertSelection (x_dpy, atoms->primary, atoms->targets,
+ XConvertSelection (xpbproxy_dpy, atoms->primary, atoms->targets,
atoms->primary, _selection_window, CurrentTime);
}
@@ -425,7 +425,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE ();
- w = XGetSelectionOwner (x_dpy, atoms->primary);
+ w = XGetSelectionOwner (xpbproxy_dpy, atoms->primary);
if (None != w)
{
@@ -442,7 +442,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
}
else
{
- XBell (x_dpy, 0);
+ XBell (xpbproxy_dpy, 0);
}
}
@@ -454,7 +454,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
TRACE ();
- Window owner = XGetSelectionOwner (x_dpy, atoms->clipboard_manager);
+ Window owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard_manager);
if(value) {
if(owner == _selection_window)
@@ -467,14 +467,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
return FALSE;
}
- XSetSelectionOwner(x_dpy, atoms->clipboard_manager, _selection_window, CurrentTime);
- return (_selection_window == XGetSelectionOwner(x_dpy, atoms->clipboard_manager));
+ XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, _selection_window, CurrentTime);
+ return (_selection_window == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
} else {
if(owner != _selection_window)
return TRUE;
- XSetSelectionOwner(x_dpy, atoms->clipboard_manager, None, CurrentTime);
- return(None == XGetSelectionOwner(x_dpy, atoms->clipboard_manager));
+ XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, None, CurrentTime);
+ return(None == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
}
return FALSE;
@@ -490,7 +490,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
TRACE ();
- DB ("e->selection %s\n", XGetAtomName (x_dpy, e->selection));
+ DB ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
if(e->selection == atoms->clipboard) {
/*
@@ -526,7 +526,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (!pbproxy_prefs.clipboard_to_pasteboard)
return;
- owner = XGetSelectionOwner (x_dpy, atoms->clipboard);
+ owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard);
if (None == owner) {
/*
* The owner probably died or we are just starting up pbproxy.
@@ -543,9 +543,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
DB ("requesting targets\n");
request_atom = atoms->targets;
- XConvertSelection (x_dpy, atoms->clipboard, atoms->targets,
+ XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
atoms->clipboard, _selection_window, CurrentTime);
- XFlush (x_dpy);
+ XFlush (xpbproxy_dpy);
/* Now we will get a SelectionNotify event in the future. */
}
@@ -558,9 +558,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* We should perhaps have a boundary limit on the number of iterations... */
do
{
- XSetSelectionOwner (x_dpy, atoms->clipboard, _selection_window,
+ XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard, _selection_window,
CurrentTime);
- } while (_selection_window != XGetSelectionOwner (x_dpy,
+ } while (_selection_window != XGetSelectionOwner (xpbproxy_dpy,
atoms->clipboard));
}
@@ -582,8 +582,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
*/
DB ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
- XSendEvent (x_dpy, reply->xselection.requestor, False, 0, reply);
- XFlush (x_dpy);
+ XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
+ XFlush (xpbproxy_dpy);
}
/*
@@ -644,7 +644,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (count)
{
/* We have a list of ATOMs to send. */
- XChangeProperty (x_dpy, e->requestor, e->property, atoms->atom, 32,
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, atoms->atom, 32,
PropModeReplace, (unsigned char *) list, count);
reply.xselection.property = e->property;
@@ -707,9 +707,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
}
- DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
+ DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
- XChangeProperty (x_dpy, e->requestor, e->property, e->target,
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
8, PropModeReplace, (unsigned char *) bytes, length);
reply.xselection.property = e->property;
@@ -743,7 +743,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
textprop.value = NULL;
- if (Success == Xutf8TextListToTextProperty (x_dpy, list, 1,
+ if (Success == Xutf8TextListToTextProperty (xpbproxy_dpy, list, 1,
XCompoundTextStyle,
&textprop))
{
@@ -752,7 +752,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
DB ("textprop.format is unexpectedly not 8 - it's %d instead\n",
textprop.format);
- XChangeProperty (x_dpy, e->requestor, e->property,
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
atoms->compound_text, textprop.format,
PropModeReplace, textprop.value,
textprop.nitems);
@@ -857,7 +857,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
length = [encdata length];
bytes = [encdata bytes];
- XChangeProperty (x_dpy, e->requestor, e->property, e->target,
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
8, PropModeReplace, bytes, length);
reply.xselection.property = e->property;
@@ -895,7 +895,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
length = [encdata length];
bytes = [encdata bytes];
- XChangeProperty (x_dpy, e->requestor, e->property, e->target,
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
8, PropModeReplace, bytes, length);
reply.xselection.property = e->property;
@@ -981,7 +981,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != e->target)
- DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
+ DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
if (e->target == atoms->targets)
{
@@ -1040,8 +1040,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
}
#if 0
- printf ("e->selection %s\n", XGetAtomName (x_dpy, e->selection));
- printf ("e->property %s\n", XGetAtomName (x_dpy, e->property));
+ printf ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+ printf ("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
#endif
if ([self is_incr_type:e])
@@ -1096,7 +1096,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (None != e->atom)
{
#ifdef DEBUG
- char *name = XGetAtomName (x_dpy, e->atom);
+ char *name = XGetAtomName (xpbproxy_dpy, e->atom);
if (name)
{
@@ -1176,7 +1176,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
(void)name; /* Avoid a warning with non-debug compiles. */
#ifdef DEBUG
- name = XGetAtomName (x_dpy, preferred);
+ name = XGetAtomName (xpbproxy_dpy, preferred);
if (name)
{
@@ -1184,7 +1184,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
}
#endif
request_atom = preferred;
- XConvertSelection (x_dpy, selection, preferred, selection,
+ XConvertSelection (xpbproxy_dpy, selection, preferred, selection,
_selection_window, CurrentTime);
}
@@ -1375,7 +1375,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
(void)name; /* Avoid warning with non-debug compiles. */
#ifdef DEBUG
- name = XGetAtomName (x_dpy, selection);
+ name = XGetAtomName (xpbproxy_dpy, selection);
if (name)
{
DB ("copy_completed: %s\n", name);
@@ -1427,7 +1427,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* The prefs_get_bool should fall back to defaults if the org.x.X11 plist doesn't exist or is invalid.
*/
(void)CFPreferencesAppSynchronize(CFSTR(APP_PREFS));
-
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_is_standalone)
+ pbproxy_prefs.active = YES;
+ else
+#endif
pbproxy_prefs.active = prefs_get_bool(CFSTR("sync_pasteboard"), pbproxy_prefs.active);
pbproxy_prefs.primary_on_grab = prefs_get_bool(CFSTR("sync_primary_on_select"), pbproxy_prefs.primary_on_grab);
pbproxy_prefs.clipboard_to_pasteboard = prefs_get_bool(CFSTR("sync_clipboard_to_pasteboard"), pbproxy_prefs.clipboard_to_pasteboard);
@@ -1437,7 +1441,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
/* This is used for debugging. */
//dump_prefs(stdout);
- if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !have_xfixes) {
+ 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");
pbproxy_prefs.primary_on_grab = NO;
}
@@ -1484,28 +1488,28 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
if (self == nil)
return nil;
- atoms->primary = XInternAtom (x_dpy, "PRIMARY", False);
- atoms->clipboard = XInternAtom (x_dpy, "CLIPBOARD", False);
- atoms->text = XInternAtom (x_dpy, "TEXT", False);
- atoms->utf8_string = XInternAtom (x_dpy, "UTF8_STRING", False);
- atoms->string = XInternAtom (x_dpy, "STRING", False);
- atoms->targets = XInternAtom (x_dpy, "TARGETS", False);
- atoms->multiple = XInternAtom (x_dpy, "MULTIPLE", False);
- atoms->cstring = XInternAtom (x_dpy, "CSTRING", False);
- atoms->image_png = XInternAtom (x_dpy, "image/png", False);
- atoms->image_jpeg = XInternAtom (x_dpy, "image/jpeg", False);
- atoms->incr = XInternAtom (x_dpy, "INCR", False);
- atoms->atom = XInternAtom (x_dpy, "ATOM", False);
- atoms->clipboard_manager = XInternAtom (x_dpy, "CLIPBOARD_MANAGER", False);
- atoms->compound_text = XInternAtom (x_dpy, "COMPOUND_TEXT", False);
- atoms->atom_pair = XInternAtom (x_dpy, "ATOM_PAIR", False);
-
- pixel = BlackPixel (x_dpy, DefaultScreen (x_dpy));
- _selection_window = XCreateSimpleWindow (x_dpy, DefaultRootWindow (x_dpy),
+ atoms->primary = XInternAtom (xpbproxy_dpy, "PRIMARY", False);
+ atoms->clipboard = XInternAtom (xpbproxy_dpy, "CLIPBOARD", False);
+ atoms->text = XInternAtom (xpbproxy_dpy, "TEXT", False);
+ atoms->utf8_string = XInternAtom (xpbproxy_dpy, "UTF8_STRING", False);
+ atoms->string = XInternAtom (xpbproxy_dpy, "STRING", False);
+ atoms->targets = XInternAtom (xpbproxy_dpy, "TARGETS", False);
+ atoms->multiple = XInternAtom (xpbproxy_dpy, "MULTIPLE", False);
+ atoms->cstring = XInternAtom (xpbproxy_dpy, "CSTRING", False);
+ atoms->image_png = XInternAtom (xpbproxy_dpy, "image/png", False);
+ atoms->image_jpeg = XInternAtom (xpbproxy_dpy, "image/jpeg", False);
+ atoms->incr = XInternAtom (xpbproxy_dpy, "INCR", False);
+ atoms->atom = XInternAtom (xpbproxy_dpy, "ATOM", False);
+ atoms->clipboard_manager = XInternAtom (xpbproxy_dpy, "CLIPBOARD_MANAGER", False);
+ atoms->compound_text = XInternAtom (xpbproxy_dpy, "COMPOUND_TEXT", False);
+ atoms->atom_pair = XInternAtom (xpbproxy_dpy, "ATOM_PAIR", False);
+
+ pixel = BlackPixel (xpbproxy_dpy, DefaultScreen (xpbproxy_dpy));
+ _selection_window = XCreateSimpleWindow (xpbproxy_dpy, DefaultRootWindow (xpbproxy_dpy),
0, 0, 1, 1, 0, pixel, pixel);
/* This is used to get PropertyNotify events when doing INCR transfers. */
- XSelectInput (x_dpy, _selection_window, PropertyChangeMask);
+ XSelectInput (xpbproxy_dpy, _selection_window, PropertyChangeMask);
request_atom = None;
@@ -1516,8 +1520,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
pending_copy = 0;
pending_clipboard = 0;
- if(have_xfixes)
- XFixesSelectSelectionInput(x_dpy, _selection_window, atoms->primary,
+ if(xpbproxy_have_xfixes)
+ XFixesSelectSelectionInput(xpbproxy_dpy, _selection_window, atoms->primary,
XFixesSetSelectionOwnerNotifyMask);
[self reload_preferences];
@@ -1529,7 +1533,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
{
if (None != _selection_window)
{
- XDestroyWindow (x_dpy, _selection_window);
+ XDestroyWindow (xpbproxy_dpy, _selection_window);
_selection_window = None;
}