XQuartz: Don't hardcode values of org.x.X11 for the preferences domain

This commit is contained in:
Jeremy Huddleston 2008-11-25 00:15:53 -08:00
parent dcb0f6a2e6
commit 3a500d9247
4 changed files with 39 additions and 11 deletions

View File

@ -75,8 +75,6 @@ void X11ApplicationMain(int argc, char **argv, char **envp);
extern int X11EnableKeyEquivalents;
extern int quartzHasRoot, quartzEnableRootless, quartzFullscreenMenu;
#define APP_PREFS "org.x.X11"
#define PREFS_APPSMENU "apps_menu"
#define PREFS_FAKEBUTTONS "enable_fake_buttons"
#define PREFS_SYSBEEP "enable_system_beep"

View File

@ -76,6 +76,8 @@ extern int darwinFakeButtons;
X11Application *X11App;
CFStringRef app_prefs_domain_cfstr = NULL;
#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
@interface X11Application (Private)
@ -466,7 +468,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
- (CFPropertyListRef) prefs_get:(NSString *)key {
CFPropertyListRef value;
value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
value = CFPreferencesCopyAppValue ((CFStringRef) key, app_prefs_domain_cfstr);
if (value == NULL) {
static CFDictionaryRef defaults;
@ -618,7 +620,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
x = CFNumberCreate (NULL, kCFNumberIntType, &value);
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease (x);
@ -629,7 +631,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease (x);
@ -638,7 +640,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
- (void) prefs_set_boolean:(NSString *)key value:(int)value {
CFPreferencesSetValue ((CFStringRef) key,
(CFTypeRef) (value ? kCFBooleanTrue
: kCFBooleanFalse), CFSTR (APP_PREFS),
: kCFBooleanFalse), app_prefs_domain_cfstr,
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
}
@ -649,14 +651,14 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
cfarray = nsarray_to_cfarray (value);
CFPreferencesSetValue ((CFStringRef) key,
(CFTypeRef) cfarray,
CFSTR (APP_PREFS),
app_prefs_domain_cfstr,
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease (cfarray);
}
- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
app_prefs_domain_cfstr, kCFPreferencesCurrentUser,
kCFPreferencesAnyHost);
}
@ -856,6 +858,9 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
pool = [[NSAutoreleasePool alloc] init];
X11App = (X11Application *) [X11Application sharedApplication];
init_ports ();
app_prefs_domain_cfstr = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
[NSApp read_defaults];
[NSBundle loadNibNamed:@"main" owner:NSApp];
[[NSNotificationCenter defaultCenter] addObserver:NSApp

View File

@ -34,6 +34,9 @@
#include <unistd.h> /*for getpid*/
#include <Cocoa/Cocoa.h>
static const char *app_prefs_domain = "org.x.X11";
CFStringRef app_prefs_domain_cfstr;
static void signal_handler (int sig) {
switch(sig) {
case SIGHUP:
@ -50,6 +53,27 @@ int main (int argc, const char *argv[]) {
#endif
xpbproxy_is_standalone = YES;
if((s = getenv("X11_PREFS_DOMAIN")))
app_prefs_domain = s;
for (i = 1; i < argc; i++) {
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"
"Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: org.x.X11)\n");
return 0;
} else {
fprintf(stderr, "usage: xpbproxy OPTIONS...\n"
"Try 'xpbproxy --help' for more information.\n");
return 1;
}
}
app_prefs_domain_cfstr = CFStringCreateWithCString(NULL, app_prefs_domain, kCFStringEncodingUTF8);
if(!xpbproxy_init())
return EXIT_FAILURE;

View File

@ -97,12 +97,13 @@ dump_prefs (FILE *fp) {
}
#endif
#define APP_PREFS "org.x.X11"
extern CFStringRef app_prefs_domain_cfstr;
static BOOL
prefs_get_bool (CFStringRef key, BOOL defaultValue) {
Boolean value, ok;
value = CFPreferencesGetAppBooleanValue (key, CFSTR (APP_PREFS), &ok);
value = CFPreferencesGetAppBooleanValue (key, app_prefs_domain_cfstr, &ok);
return ok ? (BOOL) value : defaultValue;
}
@ -1425,7 +1426,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
* It's uncertain how we could handle the synchronization failing, so cast to void.
* 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));
(void)CFPreferencesAppSynchronize(app_prefs_domain_cfstr);
#ifdef STANDALONE_XPBPROXY
if(xpbproxy_is_standalone)
pbproxy_prefs.active = YES;