xquartz: Create a separate category for organizing user preferences
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
parent
83d0d91106
commit
963ba6d9ad
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// NSUserDefaults+XQuartzDefaults.h
|
||||
// XQuartz
|
||||
//
|
||||
// Created by Jeremy Huddleston Sequoia on 2021.02.19.
|
||||
// Copyright (c) 2021 Apple Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString * const XQuartzPrefKeyAppsMenu;
|
||||
extern NSString * const XQuartzPrefKeyFakeButtons;
|
||||
extern NSString * const XQuartzPrefKeyFakeButton2;
|
||||
extern NSString * const XQuartzPrefKeyFakeButton3;
|
||||
extern NSString * const XQuartzPrefKeyKeyEquivs;
|
||||
extern NSString * const XQuartzPrefKeyFullscreenHotkeys;
|
||||
extern NSString * const XQuartzPrefKeyFullscreenMenu;
|
||||
extern NSString * const XQuartzPrefKeySyncKeymap;
|
||||
extern NSString * const XQuartzPrefKeyDepth;
|
||||
extern NSString * const XQuartzPrefKeyNoAuth;
|
||||
extern NSString * const XQuartzPrefKeyNoTCP;
|
||||
extern NSString * const XQuartzPrefKeyDoneXinitCheck;
|
||||
extern NSString * const XQuartzPrefKeyNoQuitAlert;
|
||||
extern NSString * const XQuartzPrefKeyNoRANDRAlert;
|
||||
extern NSString * const XQuartzPrefKeyOptionSendsAlt;
|
||||
extern NSString * const XQuartzPrefKeyAppKitModifiers;
|
||||
extern NSString * const XQuartzPrefKeyWindowItemModifiers;
|
||||
extern NSString * const XQuartzPrefKeyRootless;
|
||||
extern NSString * const XQuartzPrefKeyRENDERExtension;
|
||||
extern NSString * const XQuartzPrefKeyTESTExtension;
|
||||
extern NSString * const XQuartzPrefKeyLoginShell;
|
||||
extern NSString * const XQuartzPrefKeyClickThrough;
|
||||
extern NSString * const XQuartzPrefKeyFocusFollowsMouse;
|
||||
extern NSString * const XQuartzPrefKeyFocusOnNewWindow;
|
||||
|
||||
extern NSString * const XQuartzPrefKeyScrollInDeviceDirection;
|
||||
extern NSString * const XQuartzPrefKeySyncPasteboard;
|
||||
extern NSString * const XQuartzPrefKeySyncPasteboardToClipboard;
|
||||
extern NSString * const XQuartzPrefKeySyncPasteboardToPrimary;
|
||||
extern NSString * const XQuartzPrefKeySyncClipboardToPasteBoard;
|
||||
extern NSString * const XQuartzPrefKeySyncPrimaryOnSelect;
|
||||
|
||||
@interface NSUserDefaults (XQuartzDefaults)
|
||||
|
||||
+ (NSUserDefaults *)xquartzDefaults;
|
||||
|
||||
@end
|
|
@ -0,0 +1,111 @@
|
|||
//
|
||||
// NSUserDefaults+XQuartzDefaults.m
|
||||
// XQuartz
|
||||
//
|
||||
// Created by Jeremy Huddleston Sequoia on 2021.02.19.
|
||||
// Copyright (c) 2021 Apple Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSUserDefaults+XQuartzDefaults.h"
|
||||
#import <dispatch/dispatch.h>
|
||||
|
||||
NSString * const XQuartzPrefKeyAppsMenu = @"apps_menu";
|
||||
NSString * const XQuartzPrefKeyFakeButtons = @"enable_fake_buttons";
|
||||
NSString * const XQuartzPrefKeyFakeButton2 = @"fake_button2";
|
||||
NSString * const XQuartzPrefKeyFakeButton3 = @"fake_button3";
|
||||
NSString * const XQuartzPrefKeyKeyEquivs = @"enable_key_equivalents";
|
||||
NSString * const XQuartzPrefKeyFullscreenHotkeys = @"fullscreen_hotkeys";
|
||||
NSString * const XQuartzPrefKeyFullscreenMenu = @"fullscreen_menu";
|
||||
NSString * const XQuartzPrefKeySyncKeymap = @"sync_keymap";
|
||||
NSString * const XQuartzPrefKeyDepth = @"depth";
|
||||
NSString * const XQuartzPrefKeyNoAuth = @"no_auth";
|
||||
NSString * const XQuartzPrefKeyNoTCP = @"nolisten_tcp";
|
||||
NSString * const XQuartzPrefKeyDoneXinitCheck = @"done_xinit_check";
|
||||
NSString * const XQuartzPrefKeyNoQuitAlert = @"no_quit_alert";
|
||||
NSString * const XQuartzPrefKeyNoRANDRAlert = @"no_randr_alert";
|
||||
NSString * const XQuartzPrefKeyOptionSendsAlt = @"option_sends_alt";
|
||||
NSString * const XQuartzPrefKeyAppKitModifiers = @"appkit_modifiers";
|
||||
NSString * const XQuartzPrefKeyWindowItemModifiers = @"window_item_modifiers";
|
||||
NSString * const XQuartzPrefKeyRootless = @"rootless";
|
||||
NSString * const XQuartzPrefKeyRENDERExtension = @"enable_render_extension";
|
||||
NSString * const XQuartzPrefKeyTESTExtension = @"enable_test_extensions";
|
||||
NSString * const XQuartzPrefKeyLoginShell = @"login_shell";
|
||||
NSString * const XQuartzPrefKeyUpdateFeed = @"update_feed";
|
||||
NSString * const XQuartzPrefKeyClickThrough = @"wm_click_through";
|
||||
NSString * const XQuartzPrefKeyFocusFollowsMouse = @"wm_ffm";
|
||||
NSString * const XQuartzPrefKeyFocusOnNewWindow = @"wm_focus_on_new_window";
|
||||
|
||||
NSString * const XQuartzPrefKeyScrollInDeviceDirection = @"scroll_in_device_direction";
|
||||
NSString * const XQuartzPrefKeySyncPasteboard = @"sync_pasteboard";
|
||||
NSString * const XQuartzPrefKeySyncPasteboardToClipboard = @"sync_pasteboard_to_clipboard";
|
||||
NSString * const XQuartzPrefKeySyncPasteboardToPrimary = @"sync_pasteboard_to_primary";
|
||||
NSString * const XQuartzPrefKeySyncClipboardToPasteBoard = @"sync_clipboard_to_pasteboard";
|
||||
NSString * const XQuartzPrefKeySyncPrimaryOnSelect = @"sync_primary_on_select";
|
||||
|
||||
@implementation NSUserDefaults (XQuartzDefaults)
|
||||
|
||||
+ (NSUserDefaults *)xquartzDefaults
|
||||
{
|
||||
static dispatch_once_t once;
|
||||
static NSUserDefaults *defaults;
|
||||
|
||||
dispatch_once(&once, ^{
|
||||
NSString * const defaultsDomain = @(BUNDLE_ID_PREFIX ".X11");
|
||||
NSString * const defaultDefaultsDomain = NSBundle.mainBundle.bundleIdentifier;
|
||||
if ([defaultsDomain isEqualToString:defaultDefaultsDomain]) {
|
||||
defaults = [NSUserDefaults.standardUserDefaults retain];
|
||||
} else {
|
||||
defaults = [[[NSUserDefaults alloc] initWithSuiteName:defaultsDomain] retain];
|
||||
}
|
||||
|
||||
NSArray * const defaultAppsMenu = @[
|
||||
@[NSLocalizedString(@"Terminal", @"Terminal"), @"xterm", @"n"],
|
||||
];
|
||||
|
||||
NSString *defaultWindowItemModifiers = @"command";
|
||||
NSString * const defaultWindowItemModifiersLocalized = NSLocalizedString(@"window item modifiers", @"window item modifiers");
|
||||
if (![defaultWindowItemModifiersLocalized isEqualToString:@"window item modifiers"]) {
|
||||
defaultWindowItemModifiers = defaultWindowItemModifiersLocalized;
|
||||
}
|
||||
|
||||
NSDictionary<NSString *, id> * const defaultDefaultsDict = @{
|
||||
XQuartzPrefKeyAppsMenu : defaultAppsMenu,
|
||||
XQuartzPrefKeyFakeButtons : @(NO),
|
||||
// XQuartzPrefKeyFakeButton2 nil default
|
||||
// XQuartzPrefKeyFakeButton3 nil default
|
||||
XQuartzPrefKeyKeyEquivs : @(YES),
|
||||
XQuartzPrefKeyFullscreenHotkeys : @(NO),
|
||||
XQuartzPrefKeyFullscreenMenu : @(NO),
|
||||
XQuartzPrefKeySyncKeymap : @(NO),
|
||||
XQuartzPrefKeyDepth : @(-1),
|
||||
XQuartzPrefKeyNoAuth : @(NO),
|
||||
XQuartzPrefKeyNoTCP : @(NO),
|
||||
XQuartzPrefKeyDoneXinitCheck : @(NO),
|
||||
XQuartzPrefKeyNoQuitAlert : @(NO),
|
||||
XQuartzPrefKeyNoRANDRAlert : @(NO),
|
||||
XQuartzPrefKeyOptionSendsAlt : @(NO),
|
||||
// XQuartzPrefKeyAppKitModifiers nil default
|
||||
XQuartzPrefKeyWindowItemModifiers : defaultWindowItemModifiers,
|
||||
XQuartzPrefKeyRootless : @(YES),
|
||||
XQuartzPrefKeyRENDERExtension : @(YES),
|
||||
XQuartzPrefKeyTESTExtension : @(NO),
|
||||
XQuartzPrefKeyLoginShell : @"/bin/sh",
|
||||
XQuartzPrefKeyClickThrough : @(NO),
|
||||
XQuartzPrefKeyFocusFollowsMouse : @(NO),
|
||||
XQuartzPrefKeyFocusOnNewWindow : @(YES),
|
||||
|
||||
XQuartzPrefKeyScrollInDeviceDirection : @(NO),
|
||||
XQuartzPrefKeySyncPasteboard : @(YES),
|
||||
XQuartzPrefKeySyncPasteboardToClipboard : @(YES),
|
||||
XQuartzPrefKeySyncPasteboardToPrimary : @(YES),
|
||||
XQuartzPrefKeySyncClipboardToPasteBoard : @(YES),
|
||||
XQuartzPrefKeySyncPrimaryOnSelect : @(NO),
|
||||
};
|
||||
|
||||
[defaults registerDefaults:defaultDefaultsDict];
|
||||
});
|
||||
|
||||
return defaults;
|
||||
}
|
||||
|
||||
@end
|
|
@ -42,20 +42,6 @@
|
|||
@property (nonatomic, readwrite, strong) X11Controller *controller;
|
||||
@property (nonatomic, readonly, assign) OSX_BOOL x_active;
|
||||
|
||||
- (CFPropertyListRef)prefs_get_copy:(NSString *)key CF_RETURNS_RETAINED;
|
||||
- (int)prefs_get_integer:(NSString *)key default:(int)def;
|
||||
- (const char *)prefs_get_string:(NSString *)key default:(const char *)def;
|
||||
- (float)prefs_get_float:(NSString *)key default:(float)def;
|
||||
- (int)prefs_get_boolean:(NSString *)key default:(int)def;
|
||||
- (NSURL *)prefs_copy_url:(NSString *)key default:(NSURL *)def
|
||||
NS_RETURNS_RETAINED;
|
||||
- (NSArray *)prefs_get_array:(NSString *)key;
|
||||
- (void)prefs_set_integer:(NSString *)key value:(int)value;
|
||||
- (void)prefs_set_float:(NSString *)key value:(float)value;
|
||||
- (void)prefs_set_boolean:(NSString *)key value:(int)value;
|
||||
- (void)prefs_set_array:(NSString *)key value:(NSArray *)value;
|
||||
- (void)prefs_set_string:(NSString *)key value:(NSString *)value;
|
||||
- (void)prefs_synchronize;
|
||||
@end
|
||||
|
||||
extern X11Application * X11App;
|
||||
|
@ -84,40 +70,6 @@ X11ApplicationCanEnterRandR(void);
|
|||
void
|
||||
X11ApplicationMain(int argc, char **argv, char **envp);
|
||||
|
||||
#define PREFS_APPSMENU "apps_menu"
|
||||
#define PREFS_FAKEBUTTONS "enable_fake_buttons"
|
||||
#define PREFS_KEYEQUIVS "enable_key_equivalents"
|
||||
#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
|
||||
#define PREFS_FULLSCREEN_MENU "fullscreen_menu"
|
||||
#define PREFS_SYNC_KEYMAP "sync_keymap"
|
||||
#define PREFS_DEPTH "depth"
|
||||
#define PREFS_NO_AUTH "no_auth"
|
||||
#define PREFS_NO_TCP "nolisten_tcp"
|
||||
#define PREFS_DONE_XINIT_CHECK "done_xinit_check"
|
||||
#define PREFS_NO_QUIT_ALERT "no_quit_alert"
|
||||
#define PREFS_NO_RANDR_ALERT "no_randr_alert"
|
||||
#define PREFS_OPTION_SENDS_ALT "option_sends_alt"
|
||||
#define PREFS_FAKE_BUTTON2 "fake_button2"
|
||||
#define PREFS_FAKE_BUTTON3 "fake_button3"
|
||||
#define PREFS_APPKIT_MODIFIERS "appkit_modifiers"
|
||||
#define PREFS_WINDOW_ITEM_MODIFIERS "window_item_modifiers"
|
||||
#define PREFS_ROOTLESS "rootless"
|
||||
#define PREFS_RENDER_EXTENSION "enable_render_extension"
|
||||
#define PREFS_TEST_EXTENSIONS "enable_test_extensions"
|
||||
#define PREFS_XP_OPTIONS "xp_options"
|
||||
#define PREFS_LOGIN_SHELL "login_shell"
|
||||
#define PREFS_UPDATE_FEED "update_feed"
|
||||
#define PREFS_CLICK_THROUGH "wm_click_through"
|
||||
#define PREFS_FFM "wm_ffm"
|
||||
#define PREFS_FOCUS_ON_NEW_WINDOW "wm_focus_on_new_window"
|
||||
|
||||
#define PREFS_SCROLL_IN_DEV_DIRECTION "scroll_in_device_direction"
|
||||
extern Bool XQuartzScrollInDeviceDirection;
|
||||
|
||||
#define PREFS_SYNC_PB "sync_pasteboard"
|
||||
#define PREFS_SYNC_PB_TO_CLIPBOARD "sync_pasteboard_to_clipboard"
|
||||
#define PREFS_SYNC_PB_TO_PRIMARY "sync_pasteboard_to_primary"
|
||||
#define PREFS_SYNC_CLIPBOARD_TO_PB "sync_clipboard_to_pasteboard"
|
||||
#define PREFS_SYNC_PRIMARY_ON_SELECT "sync_primary_on_select"
|
||||
|
||||
#endif /* X11APPLICATION_H */
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#endif
|
||||
|
||||
#import "X11Application.h"
|
||||
#import "NSUserDefaults+XQuartzDefaults.h"
|
||||
|
||||
#include "darwin.h"
|
||||
#include "quartz.h"
|
||||
|
@ -55,8 +56,6 @@
|
|||
extern int
|
||||
xpbproxy_run(void);
|
||||
|
||||
#define DEFAULTS_FILE X11LIBDIR "/X11/xserver/Xquartz.plist"
|
||||
|
||||
#ifndef XSERVER_VERSION
|
||||
#define XSERVER_VERSION "?"
|
||||
#endif
|
||||
|
@ -101,8 +100,6 @@ static BOOL bgMouseLocationUpdated = FALSE;
|
|||
|
||||
X11Application *X11App;
|
||||
|
||||
CFStringRef app_prefs_domain_cfstr = NULL;
|
||||
|
||||
#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | \
|
||||
NSAlternateKeyMask | NSCommandKeyMask)
|
||||
|
||||
|
@ -524,404 +521,50 @@ QuartzModeBundleInit(void);
|
|||
(void)[self.controller application:self openFile:cmd];
|
||||
}
|
||||
|
||||
/* user preferences */
|
||||
|
||||
/* Note that these functions only work for arrays whose elements
|
||||
can be toll-free-bridged between NS and CF worlds. */
|
||||
|
||||
static const void *
|
||||
cfretain(CFAllocatorRef a, const void *b)
|
||||
{
|
||||
return CFRetain(b);
|
||||
}
|
||||
|
||||
static void
|
||||
cfrelease(CFAllocatorRef a, const void *b)
|
||||
{
|
||||
CFRelease(b);
|
||||
}
|
||||
|
||||
CF_RETURNS_RETAINED
|
||||
static CFMutableArrayRef
|
||||
nsarray_to_cfarray(NSArray *in)
|
||||
{
|
||||
CFMutableArrayRef out;
|
||||
CFArrayCallBacks cb;
|
||||
NSObject *ns;
|
||||
const CFTypeRef *cf;
|
||||
int i, count;
|
||||
|
||||
memset(&cb, 0, sizeof(cb));
|
||||
cb.version = 0;
|
||||
cb.retain = cfretain;
|
||||
cb.release = cfrelease;
|
||||
|
||||
count = [in count];
|
||||
out = CFArrayCreateMutable(NULL, count, &cb);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ns = [in objectAtIndex:i];
|
||||
|
||||
if ([ns isKindOfClass:[NSArray class]])
|
||||
cf = (CFTypeRef)nsarray_to_cfarray((NSArray *)ns);
|
||||
else
|
||||
cf = CFRetain((CFTypeRef)ns);
|
||||
|
||||
CFArrayAppendValue(out, cf);
|
||||
CFRelease(cf);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static NSMutableArray *
|
||||
cfarray_to_nsarray(CFArrayRef in)
|
||||
{
|
||||
NSMutableArray *out;
|
||||
const CFTypeRef *cf;
|
||||
NSObject *ns;
|
||||
int i, count;
|
||||
|
||||
count = CFArrayGetCount(in);
|
||||
out = [[NSMutableArray alloc] initWithCapacity:count];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
cf = CFArrayGetValueAtIndex(in, i);
|
||||
|
||||
if (CFGetTypeID(cf) == CFArrayGetTypeID())
|
||||
ns = cfarray_to_nsarray((CFArrayRef)cf);
|
||||
else
|
||||
ns = [(id) cf retain];
|
||||
|
||||
[out addObject:ns];
|
||||
[ns release];
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
- (CFPropertyListRef) prefs_get_copy:(NSString *)key
|
||||
{
|
||||
CFPropertyListRef value;
|
||||
|
||||
value = CFPreferencesCopyAppValue((CFStringRef)key,
|
||||
app_prefs_domain_cfstr);
|
||||
|
||||
if (value == NULL) {
|
||||
static CFDictionaryRef defaults;
|
||||
|
||||
if (defaults == NULL) {
|
||||
CFStringRef error = NULL;
|
||||
CFDataRef data;
|
||||
CFURLRef url;
|
||||
SInt32 error_code;
|
||||
|
||||
url = (CFURLCreateFromFileSystemRepresentation
|
||||
(NULL, (unsigned char *)DEFAULTS_FILE,
|
||||
strlen(DEFAULTS_FILE), false));
|
||||
if (CFURLCreateDataAndPropertiesFromResource(NULL, url, &data,
|
||||
NULL, NULL,
|
||||
&error_code)) {
|
||||
defaults = (CFPropertyListCreateFromXMLData
|
||||
(NULL, data,
|
||||
kCFPropertyListMutableContainersAndLeaves,
|
||||
&error));
|
||||
if (error != NULL) CFRelease(error);
|
||||
CFRelease(data);
|
||||
}
|
||||
CFRelease(url);
|
||||
|
||||
if (defaults != NULL) {
|
||||
NSMutableArray *apps, *elt;
|
||||
int count, i;
|
||||
NSString *name, *nname;
|
||||
|
||||
/* Localize the names in the default apps menu. */
|
||||
|
||||
apps =
|
||||
[(NSDictionary *) defaults objectForKey:@PREFS_APPSMENU];
|
||||
if (apps != nil) {
|
||||
count = [apps count];
|
||||
for (i = 0; i < count; i++) {
|
||||
elt = [apps objectAtIndex:i];
|
||||
if (elt != nil &&
|
||||
[elt isKindOfClass:[NSArray class]]) {
|
||||
name = [elt objectAtIndex:0];
|
||||
if (name != nil) {
|
||||
nname = NSLocalizedString(name, nil);
|
||||
if (nname != nil && nname != name)
|
||||
[elt replaceObjectAtIndex:0 withObject:
|
||||
nname];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaults != NULL) value = CFDictionaryGetValue(defaults, key);
|
||||
if (value != NULL) CFRetain(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
- (int) prefs_get_integer:(NSString *)key default:(int)def
|
||||
{
|
||||
CFPropertyListRef value;
|
||||
int ret;
|
||||
|
||||
value = [self prefs_get_copy:key];
|
||||
|
||||
if (value != NULL && CFGetTypeID(value) == CFNumberGetTypeID())
|
||||
CFNumberGetValue(value, kCFNumberIntType, &ret);
|
||||
else if (value != NULL && CFGetTypeID(value) == CFStringGetTypeID())
|
||||
ret = CFStringGetIntValue(value);
|
||||
else
|
||||
ret = def;
|
||||
|
||||
if (value != NULL) CFRelease(value);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (const char *) prefs_get_string:(NSString *)key default:(const char *)def
|
||||
{
|
||||
CFPropertyListRef value;
|
||||
const char *ret = NULL;
|
||||
|
||||
value = [self prefs_get_copy:key];
|
||||
|
||||
if (value != NULL && CFGetTypeID(value) == CFStringGetTypeID()) {
|
||||
NSString *s = (NSString *)value;
|
||||
|
||||
ret = [s UTF8String];
|
||||
}
|
||||
|
||||
if (value != NULL) CFRelease(value);
|
||||
|
||||
return ret != NULL ? ret : def;
|
||||
}
|
||||
|
||||
- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def
|
||||
{
|
||||
CFPropertyListRef value;
|
||||
NSURL *ret = NULL;
|
||||
|
||||
value = [self prefs_get_copy:key];
|
||||
|
||||
if (value != NULL && CFGetTypeID(value) == CFStringGetTypeID()) {
|
||||
NSString *s = (NSString *)value;
|
||||
|
||||
ret = [NSURL URLWithString:s];
|
||||
[ret retain];
|
||||
}
|
||||
|
||||
if (value != NULL) CFRelease(value);
|
||||
|
||||
return ret != NULL ? ret : def;
|
||||
}
|
||||
|
||||
- (float) prefs_get_float:(NSString *)key default:(float)def
|
||||
{
|
||||
CFPropertyListRef value;
|
||||
float ret = def;
|
||||
|
||||
value = [self prefs_get_copy:key];
|
||||
|
||||
if (value != NULL
|
||||
&& CFGetTypeID(value) == CFNumberGetTypeID()
|
||||
&& CFNumberIsFloatType(value))
|
||||
CFNumberGetValue(value, kCFNumberFloatType, &ret);
|
||||
else if (value != NULL && CFGetTypeID(value) == CFStringGetTypeID())
|
||||
ret = CFStringGetDoubleValue(value);
|
||||
|
||||
if (value != NULL) CFRelease(value);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (int) prefs_get_boolean:(NSString *)key default:(int)def
|
||||
{
|
||||
CFPropertyListRef value;
|
||||
int ret = def;
|
||||
|
||||
value = [self prefs_get_copy:key];
|
||||
|
||||
if (value != NULL) {
|
||||
if (CFGetTypeID(value) == CFNumberGetTypeID())
|
||||
CFNumberGetValue(value, kCFNumberIntType, &ret);
|
||||
else if (CFGetTypeID(value) == CFBooleanGetTypeID())
|
||||
ret = CFBooleanGetValue(value);
|
||||
else if (CFGetTypeID(value) == CFStringGetTypeID()) {
|
||||
const char *tem = [(NSString *) value UTF8String];
|
||||
if (strcasecmp(tem, "true") == 0 || strcasecmp(tem, "yes") == 0)
|
||||
ret = YES;
|
||||
else
|
||||
ret = NO;
|
||||
}
|
||||
|
||||
CFRelease(value);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (NSArray *) prefs_get_array:(NSString *)key
|
||||
{
|
||||
NSArray *ret = nil;
|
||||
CFPropertyListRef value;
|
||||
|
||||
value = [self prefs_get_copy:key];
|
||||
|
||||
if (value != NULL) {
|
||||
if (CFGetTypeID(value) == CFArrayGetTypeID())
|
||||
ret = [cfarray_to_nsarray (value)autorelease];
|
||||
|
||||
CFRelease(value);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (void) prefs_set_integer:(NSString *)key value:(int)value
|
||||
{
|
||||
CFNumberRef x;
|
||||
|
||||
x = CFNumberCreate(NULL, kCFNumberIntType, &value);
|
||||
|
||||
CFPreferencesSetValue((CFStringRef)key, (CFTypeRef)x,
|
||||
app_prefs_domain_cfstr,
|
||||
kCFPreferencesCurrentUser,
|
||||
kCFPreferencesAnyHost);
|
||||
|
||||
CFRelease(x);
|
||||
}
|
||||
|
||||
- (void) prefs_set_float:(NSString *)key value:(float)value
|
||||
{
|
||||
CFNumberRef x;
|
||||
|
||||
x = CFNumberCreate(NULL, kCFNumberFloatType, &value);
|
||||
|
||||
CFPreferencesSetValue((CFStringRef)key, (CFTypeRef)x,
|
||||
app_prefs_domain_cfstr,
|
||||
kCFPreferencesCurrentUser,
|
||||
kCFPreferencesAnyHost);
|
||||
|
||||
CFRelease(x);
|
||||
}
|
||||
|
||||
- (void) prefs_set_boolean:(NSString *)key value:(int)value
|
||||
{
|
||||
CFPreferencesSetValue(
|
||||
(CFStringRef)key,
|
||||
(CFTypeRef)(value ? kCFBooleanTrue
|
||||
: kCFBooleanFalse),
|
||||
app_prefs_domain_cfstr,
|
||||
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
|
||||
}
|
||||
|
||||
- (void) prefs_set_array:(NSString *)key value:(NSArray *)value
|
||||
{
|
||||
CFArrayRef cfarray;
|
||||
|
||||
cfarray = nsarray_to_cfarray(value);
|
||||
CFPreferencesSetValue((CFStringRef)key,
|
||||
(CFTypeRef)cfarray,
|
||||
app_prefs_domain_cfstr,
|
||||
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFRelease(cfarray);
|
||||
}
|
||||
|
||||
- (void) prefs_set_string:(NSString *)key value:(NSString *)value
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)key, (CFTypeRef)value,
|
||||
app_prefs_domain_cfstr, kCFPreferencesCurrentUser,
|
||||
kCFPreferencesAnyHost);
|
||||
}
|
||||
|
||||
- (void) prefs_synchronize
|
||||
{
|
||||
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
||||
}
|
||||
|
||||
- (void) read_defaults
|
||||
{
|
||||
NSString *nsstr;
|
||||
const char *tem;
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
|
||||
XQuartzRootlessDefault = [self prefs_get_boolean:@PREFS_ROOTLESS
|
||||
default :XQuartzRootlessDefault];
|
||||
XQuartzFullscreenMenu = [self prefs_get_boolean:@PREFS_FULLSCREEN_MENU
|
||||
default :XQuartzFullscreenMenu];
|
||||
XQuartzFullscreenDisableHotkeys =
|
||||
![self prefs_get_boolean:@PREFS_FULLSCREEN_HOTKEYS
|
||||
default :!
|
||||
XQuartzFullscreenDisableHotkeys];
|
||||
darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
|
||||
default :darwinFakeButtons];
|
||||
XQuartzOptionSendsAlt = [self prefs_get_boolean:@PREFS_OPTION_SENDS_ALT
|
||||
default :XQuartzOptionSendsAlt];
|
||||
XQuartzRootlessDefault = [defaults boolForKey:XQuartzPrefKeyRootless];
|
||||
XQuartzFullscreenMenu = [defaults boolForKey:XQuartzPrefKeyFullscreenMenu];
|
||||
XQuartzFullscreenDisableHotkeys = ![defaults boolForKey:XQuartzPrefKeyFullscreenHotkeys];
|
||||
|
||||
darwinFakeButtons = [defaults boolForKey:XQuartzPrefKeyFakeButtons];
|
||||
XQuartzOptionSendsAlt = [defaults boolForKey:XQuartzPrefKeyOptionSendsAlt];
|
||||
|
||||
if (darwinFakeButtons) {
|
||||
const char *fake2, *fake3;
|
||||
NSString * const fake2 = [defaults stringForKey:XQuartzPrefKeyFakeButton2];
|
||||
if (fake2) {
|
||||
darwinFakeMouse2Mask = DarwinParseModifierList(fake2.UTF8String, TRUE);
|
||||
}
|
||||
|
||||
fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
|
||||
fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
|
||||
|
||||
if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(
|
||||
fake2, TRUE);
|
||||
if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(
|
||||
fake3, TRUE);
|
||||
}
|
||||
|
||||
tem = [self prefs_get_string:@PREFS_APPKIT_MODIFIERS default:NULL];
|
||||
if (tem != NULL) darwinAppKitModMask = DarwinParseModifierList(tem, TRUE);
|
||||
|
||||
tem = [self prefs_get_string:@PREFS_WINDOW_ITEM_MODIFIERS default:NULL];
|
||||
if (tem != NULL) {
|
||||
windowItemModMask = DarwinParseModifierList(tem, FALSE);
|
||||
}
|
||||
else {
|
||||
nsstr = NSLocalizedString(@"window item modifiers",
|
||||
@"window item modifiers");
|
||||
if (nsstr != NULL) {
|
||||
tem = [nsstr UTF8String];
|
||||
if ((tem != NULL) && strcmp(tem, "window item modifiers")) {
|
||||
windowItemModMask = DarwinParseModifierList(tem, FALSE);
|
||||
}
|
||||
NSString * const fake3 = [defaults stringForKey:XQuartzPrefKeyFakeButton3];
|
||||
if (fake3) {
|
||||
darwinFakeMouse3Mask = DarwinParseModifierList(fake3.UTF8String, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
XQuartzEnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
|
||||
default :
|
||||
XQuartzEnableKeyEquivalents];
|
||||
|
||||
darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
|
||||
default :darwinSyncKeymap];
|
||||
|
||||
darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
|
||||
default :darwinDesiredDepth];
|
||||
|
||||
noTestExtensions = ![self prefs_get_boolean:@PREFS_TEST_EXTENSIONS
|
||||
default :FALSE];
|
||||
|
||||
noRenderExtension = ![self prefs_get_boolean:@PREFS_RENDER_EXTENSION
|
||||
default :TRUE];
|
||||
|
||||
XQuartzScrollInDeviceDirection =
|
||||
[self prefs_get_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION
|
||||
default :
|
||||
XQuartzScrollInDeviceDirection];
|
||||
|
||||
#if XQUARTZ_SPARKLE
|
||||
NSURL *url = [self prefs_copy_url:@PREFS_UPDATE_FEED default:nil];
|
||||
if (url) {
|
||||
[[SUUpdater sharedUpdater] setFeedURL:url];
|
||||
[url release];
|
||||
NSString * const appKitModifiers = [defaults stringForKey:XQuartzPrefKeyAppKitModifiers];
|
||||
if (appKitModifiers) {
|
||||
darwinAppKitModMask = DarwinParseModifierList(appKitModifiers.UTF8String, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSString * const windowItemModifiers = [defaults stringForKey:XQuartzPrefKeyWindowItemModifiers];
|
||||
if (windowItemModifiers) {
|
||||
windowItemModMask = DarwinParseModifierList(windowItemModifiers.UTF8String, FALSE);
|
||||
}
|
||||
|
||||
XQuartzEnableKeyEquivalents = [defaults boolForKey:XQuartzPrefKeyKeyEquivs];
|
||||
|
||||
darwinSyncKeymap = [defaults boolForKey:XQuartzPrefKeySyncKeymap];
|
||||
|
||||
darwinDesiredDepth = [defaults integerForKey:XQuartzPrefKeyDepth];
|
||||
|
||||
noTestExtensions = ![defaults boolForKey:XQuartzPrefKeyTESTExtension];
|
||||
noRenderExtension = ![defaults boolForKey:XQuartzPrefKeyRENDERExtension];
|
||||
|
||||
XQuartzScrollInDeviceDirection = [defaults boolForKey:XQuartzPrefKeyScrollInDeviceDirection];
|
||||
}
|
||||
|
||||
/* This will end up at the end of the responder chain. */
|
||||
|
@ -1018,8 +661,9 @@ Bool
|
|||
X11ApplicationCanEnterRandR(void)
|
||||
{
|
||||
NSString *title, *msg;
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
|
||||
if ([X11App prefs_get_boolean:@PREFS_NO_RANDR_ALERT default:NO] ||
|
||||
if ([defaults boolForKey:XQuartzPrefKeyNoRANDRAlert] ||
|
||||
XQuartzShieldingWindowLevel != 0)
|
||||
return TRUE;
|
||||
|
||||
|
@ -1042,8 +686,7 @@ X11ApplicationCanEnterRandR(void)
|
|||
|
||||
switch (alert_result) {
|
||||
case NSAlertOtherReturn:
|
||||
[X11App prefs_set_boolean:@PREFS_NO_RANDR_ALERT value:YES];
|
||||
[X11App prefs_synchronize];
|
||||
[defaults setBool:YES forKey:XQuartzPrefKeyNoRANDRAlert];
|
||||
|
||||
case NSAlertDefaultReturn:
|
||||
return YES;
|
||||
|
@ -1058,8 +701,9 @@ check_xinitrc(void)
|
|||
{
|
||||
char *tem, buf[1024];
|
||||
NSString *msg;
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
|
||||
if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
|
||||
if ([defaults boolForKey:XQuartzPrefKeyDoneXinitCheck])
|
||||
return;
|
||||
|
||||
tem = getenv("HOME");
|
||||
|
@ -1093,8 +737,7 @@ check_xinitrc(void)
|
|||
}
|
||||
|
||||
done:
|
||||
[X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
|
||||
[X11App prefs_synchronize];
|
||||
[defaults setBool:YES forKey:XQuartzPrefKeyDoneXinitCheck];
|
||||
}
|
||||
|
||||
static inline pthread_t
|
||||
|
@ -1130,15 +773,8 @@ X11ApplicationMain(int argc, char **argv, char **envp)
|
|||
|
||||
@autoreleasepool {
|
||||
X11App = (X11Application *)[X11Application sharedApplication];
|
||||
[X11App read_defaults];
|
||||
|
||||
app_prefs_domain_cfstr = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
|
||||
|
||||
if (app_prefs_domain_cfstr == NULL) {
|
||||
ErrorF("X11ApplicationMain: Unable to determine bundle identifier. Your installation of XQuartz may be broken.\n");
|
||||
app_prefs_domain_cfstr = CFSTR(BUNDLE_ID_PREFIX ".X11");
|
||||
}
|
||||
|
||||
[NSApp read_defaults];
|
||||
[NSBundle loadNibNamed:@"main" owner:NSApp];
|
||||
[NSNotificationCenter.defaultCenter addObserver:NSApp
|
||||
selector:@selector (became_key:)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#import "X11Controller.h"
|
||||
#import "X11Application.h"
|
||||
#import "NSUserDefaults+XQuartzDefaults.h"
|
||||
|
||||
#include "opaque.h"
|
||||
#include "darwin.h"
|
||||
|
@ -74,21 +75,19 @@ extern char *bundle_id_prefix;
|
|||
- (void) awakeFromNib
|
||||
{
|
||||
X11Application *xapp = NSApp;
|
||||
NSArray *array;
|
||||
|
||||
/* Point X11Application at ourself. */
|
||||
xapp.controller = self;
|
||||
|
||||
array = [xapp prefs_get_array:@PREFS_APPSMENU];
|
||||
if (array != nil) {
|
||||
int count;
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
NSArray *appsMenu = [defaults arrayForKey:XQuartzPrefKeyAppsMenu];
|
||||
|
||||
if (appsMenu) {
|
||||
int count = appsMenu.count;
|
||||
|
||||
/* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
|
||||
to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
|
||||
|
||||
count = [array count];
|
||||
if (count > 0
|
||||
&& ![[array objectAtIndex:0] isKindOfClass:[NSArray class]]) {
|
||||
if (count > 0 && ![appsMenu[0] isKindOfClass:NSArray.class]) {
|
||||
int i;
|
||||
NSMutableArray *copy, *sub;
|
||||
|
||||
|
@ -96,24 +95,24 @@ extern char *bundle_id_prefix;
|
|||
|
||||
for (i = 0; i < count / 2; i++) {
|
||||
sub = [[NSMutableArray alloc] initWithCapacity:3];
|
||||
[sub addObject:[array objectAtIndex:i * 2]];
|
||||
[sub addObject:[array objectAtIndex:i * 2 + 1]];
|
||||
[sub addObject:appsMenu[i * 2]];
|
||||
[sub addObject:appsMenu[i * 2 + 1]];
|
||||
[sub addObject:@""];
|
||||
[copy addObject:sub];
|
||||
[sub release];
|
||||
}
|
||||
|
||||
array = copy;
|
||||
appsMenu = copy;
|
||||
[defaults setObject:appsMenu forKey:XQuartzPrefKeyAppsMenu];
|
||||
}
|
||||
|
||||
[self set_apps_menu:array];
|
||||
[self set_apps_menu:appsMenu];
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(apps_table_done:)
|
||||
name: NSWindowWillCloseNotification
|
||||
object: self.apps_table.window];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self
|
||||
selector:@selector(apps_table_done:)
|
||||
name:NSWindowWillCloseNotification
|
||||
object:self.apps_table.window];
|
||||
}
|
||||
|
||||
- (void) item_selected:sender
|
||||
|
@ -349,9 +348,12 @@ extern char *bundle_id_prefix;
|
|||
int stdout_pipe[2];
|
||||
int stderr_pipe[2];
|
||||
|
||||
newargv[0] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
NSString * const shell = [defaults stringForKey:XQuartzPrefKeyLoginShell];
|
||||
|
||||
newargv[0] = shell.fileSystemRepresentation;
|
||||
newargv[1] = "-c";
|
||||
newargv[2] = [filename UTF8String];
|
||||
newargv[2] = filename.fileSystemRepresentation;
|
||||
newargv[3] = NULL;
|
||||
|
||||
s = getenv("DISPLAY");
|
||||
|
@ -494,8 +496,8 @@ extern char *bundle_id_prefix;
|
|||
[self remove_apps_menu];
|
||||
[self install_apps_menu:table_apps];
|
||||
|
||||
[NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
|
||||
[NSApp prefs_synchronize];
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
[defaults setObject:table_apps forKey:XQuartzPrefKeyAppsMenu];
|
||||
|
||||
[[apps_table window] orderOut:sender];
|
||||
|
||||
|
@ -672,15 +674,15 @@ extern char *bundle_id_prefix;
|
|||
|
||||
- (IBAction) enable_fullscreen_changed:sender
|
||||
{
|
||||
XQuartzRootlessDefault = !self.enable_fullscreen.intValue;
|
||||
XQuartzRootlessDefault = !self.enable_fullscreen.state;
|
||||
|
||||
[self.enable_fullscreen_menu setEnabled:!XQuartzRootlessDefault];
|
||||
[self.enable_fullscreen_menu_text setTextColor:XQuartzRootlessDefault ? NSColor.disabledControlTextColor : NSColor.controlTextColor];
|
||||
|
||||
DarwinSendDDXEvent(kXquartzSetRootless, 1, XQuartzRootlessDefault);
|
||||
|
||||
[NSApp prefs_set_boolean:@PREFS_ROOTLESS value:XQuartzRootlessDefault];
|
||||
[NSApp prefs_synchronize];
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
[defaults setBool:XQuartzRootlessDefault forKey:XQuartzPrefKeyRootless];
|
||||
}
|
||||
|
||||
- (IBAction) toggle_fullscreen:sender
|
||||
|
@ -693,55 +695,43 @@ extern char *bundle_id_prefix;
|
|||
if (!sender)
|
||||
return;
|
||||
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
|
||||
if (sender == self.fake_buttons) {
|
||||
darwinFakeButtons = self.fake_buttons.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
|
||||
}
|
||||
else if (sender == self.enable_keyequivs) {
|
||||
XQuartzEnableKeyEquivalents = self.enable_keyequivs.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:
|
||||
XQuartzEnableKeyEquivalents];
|
||||
}
|
||||
else if (sender == self.sync_keymap) {
|
||||
darwinSyncKeymap = self.sync_keymap.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
|
||||
}
|
||||
else if (sender == self.enable_fullscreen_menu) {
|
||||
XQuartzFullscreenMenu = self.enable_fullscreen_menu.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_FULLSCREEN_MENU value:
|
||||
XQuartzFullscreenMenu];
|
||||
}
|
||||
else if (sender == self.option_sends_alt) {
|
||||
darwinFakeButtons = !!self.fake_buttons.state;
|
||||
[defaults setBool:darwinFakeButtons forKey:XQuartzPrefKeyFakeButtons];
|
||||
} else if (sender == self.enable_keyequivs) {
|
||||
XQuartzEnableKeyEquivalents = !!self.enable_keyequivs.state;
|
||||
[defaults setBool:XQuartzEnableKeyEquivalents forKey:XQuartzPrefKeyKeyEquivs];
|
||||
} else if (sender == self.sync_keymap) {
|
||||
darwinSyncKeymap = !!self.sync_keymap.state;
|
||||
[defaults setBool:darwinSyncKeymap forKey:XQuartzPrefKeySyncKeymap];
|
||||
} else if (sender == self.enable_fullscreen_menu) {
|
||||
XQuartzFullscreenMenu = !!self.enable_fullscreen_menu.state;
|
||||
[defaults setBool:XQuartzFullscreenMenu forKey:XQuartzPrefKeyFullscreenMenu];
|
||||
} else if (sender == self.option_sends_alt) {
|
||||
BOOL prev_opt_sends_alt = XQuartzOptionSendsAlt;
|
||||
|
||||
XQuartzOptionSendsAlt = self.option_sends_alt.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_OPTION_SENDS_ALT value:
|
||||
XQuartzOptionSendsAlt];
|
||||
XQuartzOptionSendsAlt = !!self.option_sends_alt.state;
|
||||
[defaults setBool:XQuartzOptionSendsAlt forKey:XQuartzPrefKeyOptionSendsAlt];
|
||||
|
||||
if (prev_opt_sends_alt != XQuartzOptionSendsAlt)
|
||||
QuartsResyncKeymap(TRUE);
|
||||
}
|
||||
else if (sender == self.click_through) {
|
||||
[NSApp prefs_set_boolean:@PREFS_CLICK_THROUGH value:self.click_through.intValue];
|
||||
}
|
||||
else if (sender == self.focus_follows_mouse) {
|
||||
[NSApp prefs_set_boolean:@PREFS_FFM value:self.focus_follows_mouse.intValue];
|
||||
}
|
||||
else if (sender == self.focus_on_new_window) {
|
||||
[NSApp prefs_set_boolean:@PREFS_FOCUS_ON_NEW_WINDOW value:self.focus_on_new_window.intValue];
|
||||
}
|
||||
else if (sender == self.enable_auth) {
|
||||
[NSApp prefs_set_boolean:@PREFS_NO_AUTH value:!self.enable_auth.intValue];
|
||||
}
|
||||
else if (sender == self.enable_tcp) {
|
||||
[NSApp prefs_set_boolean:@PREFS_NO_TCP value:!self.enable_tcp.intValue];
|
||||
}
|
||||
else if (sender == self.depth) {
|
||||
[NSApp prefs_set_integer:@PREFS_DEPTH value:self.depth.selectedTag];
|
||||
}
|
||||
else if (sender == self.sync_pasteboard) {
|
||||
} else if (sender == self.click_through) {
|
||||
[defaults setBool:!!self.click_through.state forKey:XQuartzPrefKeyClickThrough];
|
||||
} else if (sender == self.focus_follows_mouse) {
|
||||
[defaults setBool:!!self.focus_follows_mouse.state forKey:XQuartzPrefKeyFocusFollowsMouse];
|
||||
} else if (sender == self.focus_on_new_window) {
|
||||
[defaults setBool:!!self.focus_on_new_window.state forKey:XQuartzPrefKeyFocusOnNewWindow];
|
||||
} else if (sender == self.enable_auth) {
|
||||
[defaults setBool:!self.enable_auth.state forKey:XQuartzPrefKeyNoAuth];
|
||||
} else if (sender == self.enable_tcp) {
|
||||
[defaults setBool:!self.enable_tcp.state forKey:XQuartzPrefKeyNoTCP];
|
||||
} else if (sender == self.depth) {
|
||||
[defaults setInteger:self.depth.selectedTag forKey:XQuartzPrefKeyDepth];
|
||||
} else if (sender == self.sync_pasteboard) {
|
||||
BOOL pbproxy_active = self.sync_pasteboard.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_SYNC_PB value:pbproxy_active];
|
||||
[defaults setBool:pbproxy_active forKey:XQuartzPrefKeySyncPasteboard];
|
||||
|
||||
[self.sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
|
||||
[self.sync_pasteboard_to_primary setEnabled:pbproxy_active];
|
||||
|
@ -751,33 +741,27 @@ extern char *bundle_id_prefix;
|
|||
// setEnabled doesn't do this...
|
||||
[self.sync_text1 setTextColor:pbproxy_active ? NSColor.controlTextColor : NSColor.disabledControlTextColor];
|
||||
[self.sync_text2 setTextColor:pbproxy_active ? NSColor.controlTextColor : NSColor.disabledControlTextColor];
|
||||
} else if (sender == self.sync_pasteboard_to_clipboard) {
|
||||
[defaults setBool:!!self.sync_pasteboard_to_clipboard.state forKey:XQuartzPrefKeySyncPasteboardToClipboard];
|
||||
} else if (sender == self.sync_pasteboard_to_primary) {
|
||||
[defaults setBool:!!self.sync_pasteboard_to_primary.state forKey:XQuartzPrefKeySyncPasteboardToPrimary];
|
||||
} else if (sender == self.sync_clipboard_to_pasteboard) {
|
||||
[defaults setBool:!!self.sync_clipboard_to_pasteboard.state forKey:XQuartzPrefKeySyncClipboardToPasteBoard];
|
||||
} else if (sender == self.sync_primary_immediately) {
|
||||
[defaults setBool:!!self.sync_primary_immediately.state forKey:XQuartzPrefKeySyncPrimaryOnSelect];
|
||||
} else if (sender == self.scroll_in_device_direction) {
|
||||
XQuartzScrollInDeviceDirection = !!self.scroll_in_device_direction.state;
|
||||
[defaults setBool:XQuartzScrollInDeviceDirection forKey:XQuartzPrefKeyScrollInDeviceDirection];
|
||||
}
|
||||
else if (sender == self.sync_pasteboard_to_clipboard) {
|
||||
[NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD value:self.sync_pasteboard_to_clipboard.intValue];
|
||||
}
|
||||
else if (sender == self.sync_pasteboard_to_primary) {
|
||||
[NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_PRIMARY value:self.sync_pasteboard_to_primary.intValue];
|
||||
}
|
||||
else if (sender == self.sync_clipboard_to_pasteboard) {
|
||||
[NSApp prefs_set_boolean:@PREFS_SYNC_CLIPBOARD_TO_PB value:self.sync_clipboard_to_pasteboard.intValue];
|
||||
}
|
||||
else if (sender == self.sync_primary_immediately) {
|
||||
[NSApp prefs_set_boolean:@PREFS_SYNC_PRIMARY_ON_SELECT value:self.sync_primary_immediately.intValue];
|
||||
}
|
||||
else if (sender == self.scroll_in_device_direction) {
|
||||
XQuartzScrollInDeviceDirection = self.scroll_in_device_direction.intValue;
|
||||
[NSApp prefs_set_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION value:XQuartzScrollInDeviceDirection];
|
||||
}
|
||||
|
||||
[NSApp prefs_synchronize];
|
||||
|
||||
DarwinSendDDXEvent(kXquartzReloadPreferences, 0);
|
||||
}
|
||||
|
||||
- (IBAction) prefs_show:sender
|
||||
{
|
||||
BOOL pbproxy_active =
|
||||
[NSApp prefs_get_boolean:@PREFS_SYNC_PB default:YES];
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
|
||||
BOOL pbproxy_active = [defaults boolForKey:XQuartzPrefKeySyncPasteboard];
|
||||
|
||||
[self.scroll_in_device_direction setIntValue:XQuartzScrollInDeviceDirection];
|
||||
|
||||
|
@ -785,20 +769,20 @@ extern char *bundle_id_prefix;
|
|||
[self.enable_keyequivs setIntValue:XQuartzEnableKeyEquivalents];
|
||||
[self.sync_keymap setIntValue:darwinSyncKeymap];
|
||||
[self.option_sends_alt setIntValue:XQuartzOptionSendsAlt];
|
||||
[self.click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_CLICK_THROUGH default:NO]];
|
||||
[self.focus_follows_mouse setIntValue:[NSApp prefs_get_boolean:@PREFS_FFM default:NO]];
|
||||
[self.focus_on_new_window setIntValue:[NSApp prefs_get_boolean:@PREFS_FOCUS_ON_NEW_WINDOW default:YES]];
|
||||
[self.click_through setIntValue:[defaults boolForKey:XQuartzPrefKeyClickThrough]];
|
||||
[self.focus_follows_mouse setIntValue:[defaults boolForKey:XQuartzPrefKeyFocusFollowsMouse]];
|
||||
[self.focus_on_new_window setIntValue:[defaults boolForKey:XQuartzPrefKeyFocusOnNewWindow]];
|
||||
|
||||
[self.enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
|
||||
[self.enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
|
||||
[self.enable_auth setIntValue:![defaults boolForKey:XQuartzPrefKeyNoAuth]];
|
||||
[self.enable_tcp setIntValue:![defaults boolForKey:XQuartzPrefKeyNoTCP]];
|
||||
|
||||
[self.depth selectItemAtIndex:[self.depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
|
||||
[self.depth selectItemAtIndex:[self.depth indexOfItemWithTag:[defaults integerForKey:XQuartzPrefKeyDepth]]];
|
||||
|
||||
[self.sync_pasteboard setIntValue:pbproxy_active];
|
||||
[self.sync_pasteboard_to_clipboard setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD default:YES]];
|
||||
[self.sync_pasteboard_to_primary setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PB_TO_PRIMARY default:YES]];
|
||||
[self.sync_clipboard_to_pasteboard setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_CLIPBOARD_TO_PB default:YES]];
|
||||
[self.sync_primary_immediately setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PRIMARY_ON_SELECT default:NO]];
|
||||
[self.sync_pasteboard_to_clipboard setIntValue:[defaults boolForKey:XQuartzPrefKeySyncPasteboardToClipboard]];
|
||||
[self.sync_pasteboard_to_primary setIntValue:[defaults boolForKey:XQuartzPrefKeySyncPasteboardToPrimary]];
|
||||
[self.sync_clipboard_to_pasteboard setIntValue:[defaults boolForKey:XQuartzPrefKeySyncClipboardToPasteBoard]];
|
||||
[self.sync_primary_immediately setIntValue:[defaults boolForKey:XQuartzPrefKeySyncPrimaryOnSelect]];
|
||||
|
||||
[self.sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
|
||||
[self.sync_pasteboard_to_primary setEnabled:pbproxy_active];
|
||||
|
@ -863,9 +847,11 @@ extern char *bundle_id_prefix;
|
|||
NSString *msg;
|
||||
NSString *title;
|
||||
|
||||
if (self.can_quit ||
|
||||
[X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
|
||||
NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults;
|
||||
|
||||
if (self.can_quit || [defaults boolForKey:XQuartzPrefKeyNoQuitAlert]) {
|
||||
return NSTerminateNow;
|
||||
}
|
||||
|
||||
/* Make sure we're frontmost. */
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
|
@ -887,8 +873,6 @@ extern char *bundle_id_prefix;
|
|||
|
||||
- (void) applicationWillTerminate:(NSNotification *)aNotification _X_NORETURN
|
||||
{
|
||||
[X11App prefs_synchronize];
|
||||
|
||||
/* shutdown the X server, it will exit () for us. */
|
||||
DarwinSendDDXEvent(kXquartzQuit, 0);
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
|
||||
<!-- This file contains system-wide defaults for the Apple X11 server -->
|
||||
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>apps_menu</key>
|
||||
<array>
|
||||
<array>
|
||||
<string>Terminal</string>
|
||||
<string>xterm</string>
|
||||
<string>n</string>
|
||||
</array>
|
||||
<array>
|
||||
<string>xman</string>
|
||||
<string>xman</string>
|
||||
<string></string>
|
||||
</array>
|
||||
<array>
|
||||
<string>xlogo</string>
|
||||
<string>xlogo</string>
|
||||
<string></string>
|
||||
</array>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -20,6 +20,7 @@ endif
|
|||
|
||||
# libxquartz
|
||||
srcs_libxquartz = [
|
||||
'NSUserDefaults+XQuartzDefaults.m',
|
||||
'X11Application.m',
|
||||
'X11Controller.m',
|
||||
'applewm.c',
|
||||
|
|
|
@ -85,14 +85,16 @@ int aquaMenuBarHeight = 0;
|
|||
QuartzModeProcsPtr quartzProcs = NULL;
|
||||
const char *quartzOpenGLBundle = NULL;
|
||||
|
||||
Bool XQuartzFullscreenDisableHotkeys = TRUE;
|
||||
Bool XQuartzOptionSendsAlt = FALSE;
|
||||
Bool XQuartzEnableKeyEquivalents = TRUE;
|
||||
/* These are initialized by X11Application with default values set in NSUserDefaults+XQuartzDefaults */
|
||||
Bool XQuartzFullscreenDisableHotkeys;
|
||||
Bool XQuartzOptionSendsAlt;
|
||||
Bool XQuartzEnableKeyEquivalents;
|
||||
Bool XQuartzFullscreenMenu;
|
||||
Bool XQuartzRootlessDefault;
|
||||
|
||||
Bool XQuartzFullscreenVisible = FALSE;
|
||||
Bool XQuartzRootlessDefault = TRUE;
|
||||
Bool XQuartzIsRootless = TRUE;
|
||||
Bool XQuartzServerVisible = FALSE;
|
||||
Bool XQuartzFullscreenMenu = FALSE;
|
||||
|
||||
int32_t XQuartzShieldingWindowLevel = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue