diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2022-08-31 11:25:20 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2022-08-31 11:25:20 +0000 |
commit | be9f365c075c78cfa670e2ee7d939cfc20807ed5 (patch) | |
tree | b1197eb17d32e65b1c667ef70b529c73719f7971 /xserver/hw | |
parent | 63ff66483d961ba4416764b5fd61c5500c2070ea (diff) |
Update xserver to version 21.1.4.
The security patches were already committed as part of july 24 errata.
This brings a few other bug fixes.
Tested by Walter Alejandro Iglesias.
Diffstat (limited to 'xserver/hw')
-rw-r--r-- | xserver/hw/xfree86/ddc/print_edid.c | 2 | ||||
-rw-r--r-- | xserver/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c | 45 | ||||
-rw-r--r-- | xserver/hw/xquartz/Makefile.am | 3 | ||||
-rw-r--r-- | xserver/hw/xquartz/Makefile.in | 7 | ||||
-rw-r--r-- | xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.h | 49 | ||||
-rw-r--r-- | xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.m | 149 | ||||
-rw-r--r-- | xserver/hw/xquartz/X11Application.h | 48 | ||||
-rw-r--r-- | xserver/hw/xquartz/X11Application.m | 481 | ||||
-rw-r--r-- | xserver/hw/xquartz/X11Controller.m | 231 | ||||
-rw-r--r-- | xserver/hw/xquartz/bundle/Info.plist.cpp | 33 | ||||
-rw-r--r-- | xserver/hw/xquartz/bundle/Makefile.am | 6 | ||||
-rw-r--r-- | xserver/hw/xquartz/bundle/Makefile.in | 74 | ||||
-rw-r--r-- | xserver/hw/xquartz/bundle/Xquartz.plist | 27 | ||||
-rw-r--r-- | xserver/hw/xquartz/bundle/chown-bundle.sh | 7 | ||||
-rw-r--r-- | xserver/hw/xquartz/pbproxy/Makefile.am | 4 | ||||
-rw-r--r-- | xserver/hw/xquartz/pbproxy/Makefile.in | 26 | ||||
-rw-r--r-- | xserver/hw/xquartz/pbproxy/app-main.m | 40 | ||||
-rw-r--r-- | xserver/hw/xquartz/pbproxy/x-selection.m | 45 | ||||
-rw-r--r-- | xserver/hw/xquartz/quartz.c | 12 |
19 files changed, 493 insertions, 796 deletions
diff --git a/xserver/hw/xfree86/ddc/print_edid.c b/xserver/hw/xfree86/ddc/print_edid.c index 699cbe11d..f5215bd1c 100644 --- a/xserver/hw/xfree86/ddc/print_edid.c +++ b/xserver/hw/xfree86/ddc/print_edid.c @@ -507,7 +507,7 @@ handle_detailed_print(struct detailed_monitor_section *det_mon, void *data) } if (det_mon->type >= DS_VENDOR && det_mon->type <= DS_VENDOR_MAX) { xf86DrvMsg(scrnIndex, X_INFO, - "Unknown vendor-specific block %hx\n", + "Unknown vendor-specific block %x\n", det_mon->type - DS_VENDOR); } diff --git a/xserver/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c b/xserver/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c index 70f8fe964..dd19f47a9 100644 --- a/xserver/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c +++ b/xserver/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c @@ -856,39 +856,48 @@ read_input_from_connection(InputInfoPtr pInfo) driver_data->buffer.valid_length += read_size; while (1) { - xf86ITEventHeader *event_header; + xf86ITEventHeader event_header; char *event_begin = driver_data->buffer.data + processed_size; if (driver_data->buffer.valid_length - processed_size < sizeof(xf86ITEventHeader)) break; - event_header = (xf86ITEventHeader*) event_begin; + /* Note that event_begin pointer is not aligned, accessing it directly is + undefined behavior. We must use memcpy to copy the data to aligned data + area. Most compilers will optimize out this call out and use whatever + is most efficient to access unaligned data on a particular platform */ + memcpy(&event_header, event_begin, sizeof(xf86ITEventHeader)); - if (event_header->length >= EVENT_BUFFER_SIZE) { + if (event_header.length >= EVENT_BUFFER_SIZE) { xf86IDrvMsg(pInfo, X_ERROR, "Received event with too long length: %d\n", - event_header->length); + event_header.length); teardown_client_connection(pInfo); return; } - if (driver_data->buffer.valid_length - processed_size < event_header->length) + if (driver_data->buffer.valid_length - processed_size < event_header.length) break; - if (is_supported_event(event_header->type)) { - int expected_event_size = get_event_size(event_header->type); + if (is_supported_event(event_header.type)) { + int expected_event_size = get_event_size(event_header.type); - if (event_header->length != expected_event_size) { + if (event_header.length != expected_event_size) { xf86IDrvMsg(pInfo, X_ERROR, "Unexpected event length: was %d bytes, " "expected %d (event type: %d)\n", - event_header->length, expected_event_size, - (int) event_header->type); + event_header.length, expected_event_size, + (int) event_header.type); teardown_client_connection(pInfo); return; } - handle_event(pInfo, (xf86ITEventAny*) event_begin); + /* We could use event_begin pointer directly, but we want to ensure correct + data alignment (if only so that address sanitizer does not complain) */ + xf86ITEventAny event_data; + memset(&event_data, 0, sizeof(event_data)); + memcpy(&event_data, event_begin, event_header.length); + handle_event(pInfo, &event_data); } - processed_size += event_header->length; + processed_size += event_header.length; } if (processed_size > 0) { @@ -1005,7 +1014,19 @@ pre_init(InputDriverPtr drv, InputInfoPtr pInfo, int flags) unlink(driver_data->socket_path); +#ifdef SOCK_NONBLOCK driver_data->socket_fd = socket(PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); +#else + int fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (fd >= 0) { + flags = fcntl(fd, F_GETFL, 0); + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { + fd = -1; + } + } + driver_data->socket_fd = fd; +#endif + if (driver_data->socket_fd < 0) { xf86IDrvMsg(pInfo, X_ERROR, "Failed to create a socket for communication: %s\n", strerror(errno)); diff --git a/xserver/hw/xquartz/Makefile.am b/xserver/hw/xquartz/Makefile.am index bcc6dabfe..222f3b1d4 100644 --- a/xserver/hw/xquartz/Makefile.am +++ b/xserver/hw/xquartz/Makefile.am @@ -3,6 +3,7 @@ AM_CFLAGS = $(DIX_CFLAGS) AM_OBJCFLAGS = $(DIX_CFLAGS) AM_CPPFLAGS = \ -DXSERVER_VERSION=\"$(VERSION)\" \ + -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" \ -DUSE_NEW_CLUT \ -DXFree86Server \ -I$(top_srcdir)/miext/rootless \ @@ -21,6 +22,7 @@ DIST_SUBDIRS = bundle . GL xpr pbproxy mach-startup man libXquartz_la_SOURCES = \ $(top_srcdir)/mi/miinitext.c \ $(top_srcdir)/mi/miinitext.h \ + NSUserDefaults+XQuartzDefaults.m \ X11Application.m \ X11Controller.m \ applewm.c \ @@ -36,6 +38,7 @@ libXquartz_la_SOURCES = \ libXquartz_la_LIBADD = $(top_builddir)/pseudoramiX/libPseudoramiX.la EXTRA_DIST = \ + NSUserDefaults+XQuartzDefaults.h \ X11Application.h \ X11Controller.h \ applewmExt.h \ diff --git a/xserver/hw/xquartz/Makefile.in b/xserver/hw/xquartz/Makefile.in index 6405ee136..922bbacae 100644 --- a/xserver/hw/xquartz/Makefile.in +++ b/xserver/hw/xquartz/Makefile.in @@ -74,7 +74,8 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libXquartz_la_DEPENDENCIES = \ $(top_builddir)/pseudoramiX/libPseudoramiX.la -am_libXquartz_la_OBJECTS = miinitext.lo X11Application.lo \ +am_libXquartz_la_OBJECTS = miinitext.lo \ + NSUserDefaults+XQuartzDefaults.lo X11Application.lo \ X11Controller.lo applewm.lo darwin.lo darwinEvents.lo \ darwinXinput.lo keysym2ucs.lo quartz.lo quartzKeyboard.lo \ quartzStartup.lo quartzRandR.lo @@ -510,6 +511,7 @@ AM_CFLAGS = $(DIX_CFLAGS) AM_OBJCFLAGS = $(DIX_CFLAGS) AM_CPPFLAGS = \ -DXSERVER_VERSION=\"$(VERSION)\" \ + -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" \ -DUSE_NEW_CLUT \ -DXFree86Server \ -I$(top_srcdir)/miext/rootless \ @@ -523,6 +525,7 @@ DIST_SUBDIRS = bundle . GL xpr pbproxy mach-startup man libXquartz_la_SOURCES = \ $(top_srcdir)/mi/miinitext.c \ $(top_srcdir)/mi/miinitext.h \ + NSUserDefaults+XQuartzDefaults.m \ X11Application.m \ X11Controller.m \ applewm.c \ @@ -537,6 +540,7 @@ libXquartz_la_SOURCES = \ libXquartz_la_LIBADD = $(top_builddir)/pseudoramiX/libPseudoramiX.la EXTRA_DIST = \ + NSUserDefaults+XQuartzDefaults.h \ X11Application.h \ X11Controller.h \ applewmExt.h \ @@ -604,6 +608,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NSUserDefaults+XQuartzDefaults.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/X11Application.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/X11Controller.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/applewm.Plo@am__quote@ diff --git a/xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.h b/xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.h new file mode 100644 index 000000000..2f180b241 --- /dev/null +++ b/xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.h @@ -0,0 +1,49 @@ +// +// 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 *)globalDefaults; ++ (NSUserDefaults *)dockDefaults; ++ (NSUserDefaults *)xquartzDefaults; + +@end diff --git a/xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.m b/xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.m new file mode 100644 index 000000000..bd5dd2305 --- /dev/null +++ b/xserver/hw/xquartz/NSUserDefaults+XQuartzDefaults.m @@ -0,0 +1,149 @@ +// +// 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 *)globalDefaults +{ + static dispatch_once_t once; + static NSUserDefaults *defaults; + + dispatch_once(&once, ^{ + NSString * const defaultsDomain = @".GlobalPreferences"; + defaults = [[[NSUserDefaults alloc] initWithSuiteName:defaultsDomain] retain]; + + NSDictionary<NSString *, id> * const defaultDefaultsDict = @{ + @"AppleSpacesSwitchOnActivate" : @(YES), + }; + + [defaults registerDefaults:defaultDefaultsDict]; + }); + + return defaults; +} + ++ (NSUserDefaults *)dockDefaults +{ + static dispatch_once_t once; + static NSUserDefaults *defaults; + + dispatch_once(&once, ^{ + NSString * const defaultsDomain = @"com.apple.dock"; + defaults = [[[NSUserDefaults alloc] initWithSuiteName:defaultsDomain] retain]; + + NSDictionary<NSString *, id> * const defaultDefaultsDict = @{ + @"workspaces" : @(NO), + }; + + [defaults registerDefaults:defaultDefaultsDict]; + }); + + return defaults; +} + ++ (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 diff --git a/xserver/hw/xquartz/X11Application.h b/xserver/hw/xquartz/X11Application.h index d3ff4ebd0..1ef98bee3 100644 --- a/xserver/hw/xquartz/X11Application.h +++ b/xserver/hw/xquartz/X11Application.h @@ -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 */ diff --git a/xserver/hw/xquartz/X11Application.m b/xserver/hw/xquartz/X11Application.m index 3db0b2487..dd96e89f7 100644 --- a/xserver/hw/xquartz/X11Application.m +++ b/xserver/hw/xquartz/X11Application.m @@ -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) @@ -270,6 +267,8 @@ QuartzModeBundleInit(void); case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp: + case NSScrollWheel: + if ([e window] != nil) { /* Pointer event has an (AppKit) window. Probably something for the kit. */ for_x = NO; @@ -420,7 +419,7 @@ QuartzModeBundleInit(void); case NSApplicationActivatedEventType: for_x = NO; if ([e window] == nil && x_was_active) { - BOOL order_all_windows = YES, workspaces, ok; + BOOL order_all_windows = YES; for_appkit = NO; #if APPKIT_APPFLAGS_HACK @@ -433,26 +432,9 @@ QuartzModeBundleInit(void); [self set_front_process:nil]; /* Get the Spaces preference for SwitchOnActivate */ - (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock")); - workspaces = - CFPreferencesGetAppBooleanValue(CFSTR("workspaces"), - CFSTR( - "com.apple.dock"), - &ok); - if (!ok) - workspaces = NO; - + BOOL const workspaces = [NSUserDefaults.dockDefaults boolForKey:@"workspaces"]; if (workspaces) { - (void)CFPreferencesAppSynchronize(CFSTR( - ".GlobalPreferences")); - order_all_windows = - CFPreferencesGetAppBooleanValue(CFSTR( - "AppleSpacesSwitchOnActivate"), - CFSTR( - ".GlobalPreferences"), - &ok); - if (!ok) - order_all_windows = YES; + order_all_windows = [NSUserDefaults.globalDefaults boolForKey:@"AppleSpacesSwitchOnActivate"]; } /* TODO: In the workspaces && !AppleSpacesSwitchOnActivate case, the windows are ordered @@ -463,8 +445,7 @@ QuartzModeBundleInit(void); * be restoring one of them. */ if ([e data2] & 0x10) { // 0x10 (bfCPSOrderAllWindowsForward) is set when we use cmd-tab or the dock icon - DarwinSendDDXEvent(kXquartzBringAllToFront, 1, - order_all_windows); + DarwinSendDDXEvent(kXquartzBringAllToFront, 1, order_all_windows); } } break; @@ -487,12 +468,14 @@ QuartzModeBundleInit(void); break; /* for gcc */ } - if (for_appkit) [super sendEvent:e]; + if (for_appkit) { + [super sendEvent:e]; + } if (for_x) { dispatch_async(eventTranslationQueue, ^{ - [self sendX11NSEvent:e]; - }); + [self sendX11NSEvent:e]; + }); } } @@ -524,404 +507,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) +- (void) read_defaults { - 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); + NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults; - if (CFGetTypeID(cf) == CFArrayGetTypeID()) - ns = cfarray_to_nsarray((CFArrayRef)cf); - else - ns = [(id) cf retain]; - - [out addObject:ns]; - [ns release]; - } + XQuartzRootlessDefault = [defaults boolForKey:XQuartzPrefKeyRootless]; + XQuartzFullscreenMenu = [defaults boolForKey:XQuartzPrefKeyFullscreenMenu]; + XQuartzFullscreenDisableHotkeys = ![defaults boolForKey:XQuartzPrefKeyFullscreenHotkeys]; - return out; -} + darwinFakeButtons = [defaults boolForKey:XQuartzPrefKeyFakeButtons]; + XQuartzOptionSendsAlt = [defaults boolForKey:XQuartzPrefKeyOptionSendsAlt]; -- (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 (darwinFakeButtons) { + NSString * const fake2 = [defaults stringForKey:XQuartzPrefKeyFakeButton2]; + if (fake2) { + darwinFakeMouse2Mask = DarwinParseModifierList(fake2.UTF8String, TRUE); } - 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; + NSString * const fake3 = [defaults stringForKey:XQuartzPrefKeyFakeButton3]; + if (fake3) { + darwinFakeMouse3Mask = DarwinParseModifierList(fake3.UTF8String, TRUE); } - - 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; - - 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]; - - if (darwinFakeButtons) { - const char *fake2, *fake3; - - 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); + NSString * const appKitModifiers = [defaults stringForKey:XQuartzPrefKeyAppKitModifiers]; + if (appKitModifiers) { + darwinAppKitModMask = DarwinParseModifierList(appKitModifiers.UTF8String, 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); + NSString * const windowItemModifiers = [defaults stringForKey:XQuartzPrefKeyWindowItemModifiers]; + if (windowItemModifiers) { + windowItemModMask = DarwinParseModifierList(windowItemModifiers.UTF8String, 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); - } - } - } - - XQuartzEnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS - default : - XQuartzEnableKeyEquivalents]; - darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP - default :darwinSyncKeymap]; + XQuartzEnableKeyEquivalents = [defaults boolForKey:XQuartzPrefKeyKeyEquivs]; - darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH - default :darwinDesiredDepth]; + darwinSyncKeymap = [defaults boolForKey:XQuartzPrefKeySyncKeymap]; - noTestExtensions = ![self prefs_get_boolean:@PREFS_TEST_EXTENSIONS - default :FALSE]; + darwinDesiredDepth = [defaults integerForKey:XQuartzPrefKeyDepth]; - noRenderExtension = ![self prefs_get_boolean:@PREFS_RENDER_EXTENSION - default :TRUE]; + noTestExtensions = ![defaults boolForKey:XQuartzPrefKeyTESTExtension]; + noRenderExtension = ![defaults boolForKey:XQuartzPrefKeyRENDERExtension]; - 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]; - } -#endif + XQuartzScrollInDeviceDirection = [defaults boolForKey:XQuartzPrefKeyScrollInDeviceDirection]; } /* This will end up at the end of the responder chain. */ @@ -1018,8 +647,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 +672,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 +687,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 +723,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 +759,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:) @@ -1701,8 +1323,17 @@ handle_mouse: } if (darwinSyncKeymap) { - TISInputSourceRef key_layout = - TISCopyCurrentKeyboardLayoutInputSource(); + __block TISInputSourceRef key_layout; + dispatch_block_t copyCurrentKeyboardLayoutInputSource = ^{ + key_layout = TISCopyCurrentKeyboardLayoutInputSource(); + }; + /* This is an ugly ant-pattern, but it is more expedient to address the problem right now. */ + if (pthread_main_np()) { + copyCurrentKeyboardLayoutInputSource(); + } else { + dispatch_sync(dispatch_get_main_queue(), copyCurrentKeyboardLayoutInputSource); + } + TISInputSourceRef clear; if (CFEqual(key_layout, last_key_layout)) { CFRelease(key_layout); diff --git a/xserver/hw/xquartz/X11Controller.m b/xserver/hw/xquartz/X11Controller.m index 3efda5083..e21aed0d3 100644 --- a/xserver/hw/xquartz/X11Controller.m +++ b/xserver/hw/xquartz/X11Controller.m @@ -36,6 +36,7 @@ #import "X11Controller.h" #import "X11Application.h" +#import "NSUserDefaults+XQuartzDefaults.h" #include "opaque.h" #include "darwin.h" @@ -61,8 +62,8 @@ extern char *bundle_id_prefix; @property (nonatomic, readwrite, strong) NSMenuItem *check_for_updates_item; // Programatically enabled #endif -@property (nonatomic, readwrite, strong) NSArray *apps; -@property (nonatomic, readwrite, strong) NSMutableArray *table_apps; +@property (nonatomic, readwrite, strong) NSArray <NSArray <NSString *> *> *apps; +@property (nonatomic, readwrite, strong) NSMutableArray <NSMutableArray <NSString *> *> *table_apps; @property (nonatomic, readwrite, assign) NSInteger windows_menu_nitems; @property (nonatomic, readwrite, assign) int checked_window_item; @property (nonatomic, readwrite, assign) x_list *pending_apps; @@ -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 @@ -156,10 +155,10 @@ extern char *bundle_id_prefix; self.apps = nil; } -- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu +- (void) prepend_apps_item:(NSArray <NSArray <NSString *> *> *)list index:(int)i menu:(NSMenu *)menu { NSString *title, *shortcut = @""; - NSArray *group; + NSArray <NSString *> *group; NSMenuItem *item; group = [list objectAtIndex:i]; @@ -183,7 +182,7 @@ extern char *bundle_id_prefix; [item setTag:i + 1]; /* can't be zero, so add one */ } -- (void) install_apps_menu:(NSArray *)list +- (void) install_apps_menu:(NSArray <NSArray <NSString *> *> *)list { NSMenu *menu; int i, count; @@ -207,7 +206,7 @@ extern char *bundle_id_prefix; self.apps = list; } -- (void) set_window_menu:(NSArray *)list +- (void) set_window_menu:(NSArray <NSArray <NSString *> *> *)list { NSMenu * const menu = X11App.windowsMenu; NSMenu * const dock_menu = self.dock_menu; @@ -303,7 +302,7 @@ extern char *bundle_id_prefix; self.checked_window_item = n; } -- (void) set_apps_menu:(NSArray *)list +- (void) set_apps_menu:(NSArray <NSArray <NSString *> *> *)list { [self remove_apps_menu]; [self install_apps_menu:list]; @@ -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"); @@ -446,7 +448,7 @@ extern char *bundle_id_prefix; { int tag; NSString *item; - NSArray * const apps = self.apps; + NSArray <NSArray <NSString *> *> * const apps = self.apps; tag = [sender tag] - 1; if (apps == nil || tag < 0 || tag >= [apps count]) @@ -460,15 +462,18 @@ extern char *bundle_id_prefix; - (IBAction) apps_table_show:sender { NSArray *columns; - NSMutableArray *oldapps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const oldapps = self.table_apps; NSTableView * const apps_table = self.apps_table; - NSMutableArray * const table_apps = [[NSMutableArray alloc] initWithCapacity:1]; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = [[NSMutableArray alloc] initWithCapacity:1]; self.table_apps = table_apps; - NSArray * const apps = self.apps; - if (apps != nil) - [table_apps addObjectsFromArray:apps]; + NSArray <NSArray <NSString *> *> * const apps = self.apps; + if (apps != nil) { + for (NSArray <NSString *> * row in apps) { + [table_apps addObject:row.mutableCopy]; + } + } columns = [apps_table tableColumns]; [[columns objectAtIndex:0] setIdentifier:@"0"]; @@ -487,15 +492,15 @@ extern char *bundle_id_prefix; - (IBAction) apps_table_done:sender { - NSMutableArray * const table_apps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; NSTableView * const apps_table = self.apps_table; [apps_table deselectAll:sender]; /* flush edits? */ [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]; @@ -505,7 +510,7 @@ extern char *bundle_id_prefix; - (IBAction) apps_table_new:sender { NSMutableArray *item; - NSMutableArray * const table_apps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; NSTableView * const apps_table = self.apps_table; int row = [apps_table selectedRow], i; @@ -534,10 +539,10 @@ extern char *bundle_id_prefix; - (IBAction) apps_table_duplicate:sender { - NSMutableArray * const table_apps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; NSTableView * const apps_table = self.apps_table; int row = [apps_table selectedRow], i; - NSObject *item; + NSMutableArray <NSString *> *item; if (row < 0) { [self apps_table_new:sender]; @@ -560,7 +565,7 @@ extern char *bundle_id_prefix; - (IBAction) apps_table_delete:sender { - NSMutableArray * const table_apps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; NSTableView * const apps_table = self.apps_table; int row = [apps_table selectedRow]; @@ -584,7 +589,7 @@ extern char *bundle_id_prefix; - (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView { - NSMutableArray * const table_apps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; if (table_apps == nil) return 0; return [table_apps count]; @@ -593,7 +598,7 @@ extern char *bundle_id_prefix; - (id) tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - NSMutableArray * const table_apps = self.table_apps; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; NSArray *item; int col; @@ -611,8 +616,8 @@ extern char *bundle_id_prefix; - (void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - NSMutableArray * const table_apps = self.table_apps; - NSMutableArray *item; + NSMutableArray <NSMutableArray <NSString *> *> * const table_apps = self.table_apps; + NSMutableArray <NSString *> *item; int col; if (table_apps == nil) return; @@ -672,15 +677,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 +698,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 +744,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) { - [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]; + } 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]; } - [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 +772,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 +850,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 +876,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); diff --git a/xserver/hw/xquartz/bundle/Info.plist.cpp b/xserver/hw/xquartz/bundle/Info.plist.cpp index 6314c7181..7cb59ea77 100644 --- a/xserver/hw/xquartz/bundle/Info.plist.cpp +++ b/xserver/hw/xquartz/bundle/Info.plist.cpp @@ -28,20 +28,45 @@ <true/> <key>NSSupportsAutomaticGraphicsSwitching</key> <true/> + + <!-- Add generic usage descriptions for TCC + https://github.com/XQuartz/XQuartz/issues/245 + --> + <key>NSAppleEventsUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants to use AppleScript.</string> + <key>NSCalendarsUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your calendar data.</string> + <key>NSCameraUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your camera.</string> + <key>NSContactsUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your contacts.</string> + <key>NSLocationAlwaysUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your location information, even when not in use.</string> + <key>NSLocationUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your location information.</string> + <key>NSLocationWhenInUseUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your location information when in use.</string> + <key>NSMicrophoneUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your microphone.</string> + <key>NSRemindersUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants access to your reminders.</string> + <key>NSSystemAdministrationUsageDescription</key> + <string>A process launched by APPLE_APPLICATION_NAME wants admin privileges.</string> + #ifdef XQUARTZ_SPARKLE <key>SUEnableAutomaticChecks</key> <true/> - <key>SUPublicDSAKeyFile</key> - <string>sparkle.pem</string> + <key>SUPublicEDKey</key> + <string>XQUARTZ_SPARKLE_PUBLIC_EDKEY</string> <key>SUFeedURL</key> <string>XQUARTZ_SPARKLE_FEED_URL</string> #endif <key>LSApplicationCategoryType</key> <string>public.app-category.utilities</string> <key>NSHumanReadableCopyright</key> - <string>© 2003-2021 Apple Inc. + <string>© 2003-2022 Apple Inc. © 2003 XFree86 Project, Inc. -© 2003-2021 X.org Foundation, Inc. +© 2003-2022 X.org Foundation, Inc. </string> <key>NSMainNibFile</key> <string>main</string> diff --git a/xserver/hw/xquartz/bundle/Makefile.am b/xserver/hw/xquartz/bundle/Makefile.am index d97de1e71..be7d28b8a 100644 --- a/xserver/hw/xquartz/bundle/Makefile.am +++ b/xserver/hw/xquartz/bundle/Makefile.am @@ -23,10 +23,8 @@ noinst_DATA = $(noinst_PRE:plist.cpp=plist) CLEANFILES = $(noinst_DATA) -resourcedir=$(libdir)/X11/xserver -resource_DATA = Xquartz.plist - EXTRA_DIST = \ + chown-bundle.sh \ mk_bundke.sh \ X11.sh \ Info.plist.cpp \ @@ -181,5 +179,5 @@ EXTRA_DIST = \ Resources/zh_TW.lproj/Localizable.strings \ Resources/zh_TW.lproj/locversion.plist \ Resources/zh_TW.lproj/main.nib/designable.nib \ - Resources/zh_TW.lproj/main.nib/keyedobjects.nib + Resources/zh_TW.lproj/main.nib/keyedobjects.nib \ Resources/zh_TW.lproj/main.nib/keyedobjects-110000.nib diff --git a/xserver/hw/xquartz/bundle/Makefile.in b/xserver/hw/xquartz/bundle/Makefile.in index e7e80d494..46b0f6507 100644 --- a/xserver/hw/xquartz/bundle/Makefile.in +++ b/xserver/hw/xquartz/bundle/Makefile.in @@ -98,35 +98,7 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(resourcedir)" -DATA = $(noinst_DATA) $(resource_DATA) +DATA = $(noinst_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ @@ -472,9 +444,8 @@ CPP_FILES_FLAGS = \ noinst_PRE = Info.plist.cpp noinst_DATA = $(noinst_PRE:plist.cpp=plist) CLEANFILES = $(noinst_DATA) -resourcedir = $(libdir)/X11/xserver -resource_DATA = Xquartz.plist EXTRA_DIST = \ + chown-bundle.sh \ mk_bundke.sh \ X11.sh \ Info.plist.cpp \ @@ -629,7 +600,8 @@ EXTRA_DIST = \ Resources/zh_TW.lproj/Localizable.strings \ Resources/zh_TW.lproj/locversion.plist \ Resources/zh_TW.lproj/main.nib/designable.nib \ - Resources/zh_TW.lproj/main.nib/keyedobjects.nib + Resources/zh_TW.lproj/main.nib/keyedobjects.nib \ + Resources/zh_TW.lproj/main.nib/keyedobjects-110000.nib all: all-am @@ -672,27 +644,6 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -install-resourceDATA: $(resource_DATA) - @$(NORMAL_INSTALL) - @list='$(resource_DATA)'; test -n "$(resourcedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(resourcedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(resourcedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(resourcedir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(resourcedir)" || exit $$?; \ - done - -uninstall-resourceDATA: - @$(NORMAL_UNINSTALL) - @list='$(resource_DATA)'; test -n "$(resourcedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(resourcedir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: @@ -736,9 +687,6 @@ check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: - for dir in "$(DESTDIR)$(resourcedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -790,7 +738,7 @@ info: info-am info-am: -install-data-am: install-resourceDATA +install-data-am: @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-am @@ -835,7 +783,7 @@ ps: ps-am ps-am: -uninstall-am: uninstall-resourceDATA +uninstall-am: @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook .MAKE: install-am install-data-am install-strip uninstall-am @@ -847,11 +795,10 @@ uninstall-am: uninstall-resourceDATA install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ - install-resourceDATA install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ - uninstall-hook uninstall-resourceDATA + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am uninstall-hook .cpp: @@ -864,7 +811,6 @@ uninstall-hook: $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Resources $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Info.plist $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/PkgInfo - Resources/zh_TW.lproj/main.nib/keyedobjects-110000.nib # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/xserver/hw/xquartz/bundle/Xquartz.plist b/xserver/hw/xquartz/bundle/Xquartz.plist deleted file mode 100644 index e15704516..000000000 --- a/xserver/hw/xquartz/bundle/Xquartz.plist +++ /dev/null @@ -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> diff --git a/xserver/hw/xquartz/bundle/chown-bundle.sh b/xserver/hw/xquartz/bundle/chown-bundle.sh new file mode 100644 index 000000000..ac62f289f --- /dev/null +++ b/xserver/hw/xquartz/bundle/chown-bundle.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +BUNDLE_ROOT=$1 + +if [[ $(id -u) == 0 ]] ; then + chown -R root:admin ${BUNDLE_ROOT} +fi diff --git a/xserver/hw/xquartz/pbproxy/Makefile.am b/xserver/hw/xquartz/pbproxy/Makefile.am index 9429ea25d..3314855d7 100644 --- a/xserver/hw/xquartz/pbproxy/Makefile.am +++ b/xserver/hw/xquartz/pbproxy/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS=-DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" +AM_CPPFLAGS=-I.. AM_CFLAGS=$(XPBPROXY_CFLAGS) AM_OBJCFLAGS=$(XPBPROXY_CFLAGS) @@ -15,7 +15,7 @@ libxpbproxy_la_LDFLAGS=$(XPBPROXY_LIBS) if STANDALONE_XPBPROXY bin_PROGRAMS = xpbproxy -xpbproxy_SOURCES = app-main.m +xpbproxy_SOURCES = app-main.m ../NSUserDefaults+XQuartzDefaults.m xpbproxy_LDADD = libxpbproxy.la xpbproxy_LDFLAGS = -Wl,-framework,Cocoa diff --git a/xserver/hw/xquartz/pbproxy/Makefile.in b/xserver/hw/xquartz/pbproxy/Makefile.in index 2e026edfe..160070964 100644 --- a/xserver/hw/xquartz/pbproxy/Makefile.in +++ b/xserver/hw/xquartz/pbproxy/Makefile.in @@ -88,8 +88,10 @@ libxpbproxy_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(OBJCFLAGS) $(libxpbproxy_la_LDFLAGS) $(LDFLAGS) -o $@ am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am__xpbproxy_SOURCES_DIST = app-main.m -@STANDALONE_XPBPROXY_TRUE@am_xpbproxy_OBJECTS = app-main.$(OBJEXT) +am__xpbproxy_SOURCES_DIST = app-main.m \ + ../NSUserDefaults+XQuartzDefaults.m +@STANDALONE_XPBPROXY_TRUE@am_xpbproxy_OBJECTS = app-main.$(OBJEXT) \ +@STANDALONE_XPBPROXY_TRUE@ NSUserDefaults+XQuartzDefaults.$(OBJEXT) xpbproxy_OBJECTS = $(am_xpbproxy_OBJECTS) @STANDALONE_XPBPROXY_TRUE@xpbproxy_DEPENDENCIES = libxpbproxy.la xpbproxy_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ @@ -480,8 +482,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CPPFLAGS = -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" \ - $(am__append_1) +AM_CPPFLAGS = -I.. $(am__append_1) AM_CFLAGS = $(XPBPROXY_CFLAGS) AM_OBJCFLAGS = $(XPBPROXY_CFLAGS) noinst_LTLIBRARIES = libxpbproxy.la @@ -492,7 +493,7 @@ libxpbproxy_la_SOURCES = \ x-selection.m libxpbproxy_la_LDFLAGS = $(XPBPROXY_LIBS) -@STANDALONE_XPBPROXY_TRUE@xpbproxy_SOURCES = app-main.m +@STANDALONE_XPBPROXY_TRUE@xpbproxy_SOURCES = app-main.m ../NSUserDefaults+XQuartzDefaults.m @STANDALONE_XPBPROXY_TRUE@xpbproxy_LDADD = libxpbproxy.la @STANDALONE_XPBPROXY_TRUE@xpbproxy_LDFLAGS = -Wl,-framework,Cocoa EXTRA_DIST = \ @@ -602,6 +603,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NSUserDefaults+XQuartzDefaults.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/app-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trick_autotools.Plo@am__quote@ @@ -650,6 +652,20 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepOBJC_FALSE@ DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepOBJC_FALSE@ $(AM_V_OBJC@am__nodep@)$(LTOBJCCOMPILE) -c -o $@ $< +NSUserDefaults+XQuartzDefaults.o: ../NSUserDefaults+XQuartzDefaults.m +@am__fastdepOBJC_TRUE@ $(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT NSUserDefaults+XQuartzDefaults.o -MD -MP -MF $(DEPDIR)/NSUserDefaults+XQuartzDefaults.Tpo -c -o NSUserDefaults+XQuartzDefaults.o `test -f '../NSUserDefaults+XQuartzDefaults.m' || echo '$(srcdir)/'`../NSUserDefaults+XQuartzDefaults.m +@am__fastdepOBJC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/NSUserDefaults+XQuartzDefaults.Tpo $(DEPDIR)/NSUserDefaults+XQuartzDefaults.Po +@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ $(AM_V_OBJC)source='../NSUserDefaults+XQuartzDefaults.m' object='NSUserDefaults+XQuartzDefaults.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepOBJC_FALSE@ $(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o NSUserDefaults+XQuartzDefaults.o `test -f '../NSUserDefaults+XQuartzDefaults.m' || echo '$(srcdir)/'`../NSUserDefaults+XQuartzDefaults.m + +NSUserDefaults+XQuartzDefaults.obj: ../NSUserDefaults+XQuartzDefaults.m +@am__fastdepOBJC_TRUE@ $(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT NSUserDefaults+XQuartzDefaults.obj -MD -MP -MF $(DEPDIR)/NSUserDefaults+XQuartzDefaults.Tpo -c -o NSUserDefaults+XQuartzDefaults.obj `if test -f '../NSUserDefaults+XQuartzDefaults.m'; then $(CYGPATH_W) '../NSUserDefaults+XQuartzDefaults.m'; else $(CYGPATH_W) '$(srcdir)/../NSUserDefaults+XQuartzDefaults.m'; fi` +@am__fastdepOBJC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/NSUserDefaults+XQuartzDefaults.Tpo $(DEPDIR)/NSUserDefaults+XQuartzDefaults.Po +@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ $(AM_V_OBJC)source='../NSUserDefaults+XQuartzDefaults.m' object='NSUserDefaults+XQuartzDefaults.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepOBJC_FALSE@ $(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o NSUserDefaults+XQuartzDefaults.obj `if test -f '../NSUserDefaults+XQuartzDefaults.m'; then $(CYGPATH_W) '../NSUserDefaults+XQuartzDefaults.m'; else $(CYGPATH_W) '$(srcdir)/../NSUserDefaults+XQuartzDefaults.m'; fi` + mostlyclean-libtool: -rm -f *.lo diff --git a/xserver/hw/xquartz/pbproxy/app-main.m b/xserver/hw/xquartz/pbproxy/app-main.m index eda9a9e67..825980caf 100644 --- a/xserver/hw/xquartz/pbproxy/app-main.m +++ b/xserver/hw/xquartz/pbproxy/app-main.m @@ -31,13 +31,6 @@ #include "pbproxy.h" #import "x-selection.h" -#include <pthread.h> -#include <unistd.h> /*for getpid*/ -#include <Cocoa/Cocoa.h> - -static const char *app_prefs_domain = BUNDLE_ID_PREFIX ".xpbproxy"; -CFStringRef app_prefs_domain_cfstr; - /* Stubs */ char *display = NULL; @@ -82,41 +75,8 @@ xq_asl_log(int level, const char *subsystem, const char *file, int main(int argc, const char *argv[]) { - const char *s; - int i; - -#ifdef DEBUG - ErrorF("pid: %u\n", getpid()); -#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) { - 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 { - ErrorF("usage: xpbproxy OPTIONS...\n" - "Try 'xpbproxy --help' for more information.\n"); - return 1; - } - } - - app_prefs_domain_cfstr = CFStringCreateWithCString(NULL, app_prefs_domain, - kCFStringEncodingUTF8); - signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGHUP, signal_handler); diff --git a/xserver/hw/xquartz/pbproxy/x-selection.m b/xserver/hw/xquartz/pbproxy/x-selection.m index 21b5b3172..f4f2b9a6b 100644 --- a/xserver/hw/xquartz/pbproxy/x-selection.m +++ b/xserver/hw/xquartz/pbproxy/x-selection.m @@ -38,6 +38,8 @@ #import <AppKit/NSImage.h> #import <AppKit/NSBitmapImageRep.h> +#import "NSUserDefaults+XQuartzDefaults.h" + /* * The basic design of the pbproxy code is as follows. * @@ -99,18 +101,6 @@ dump_prefs() } #endif -extern CFStringRef app_prefs_domain_cfstr; - -static BOOL -prefs_get_bool(CFStringRef key, BOOL defaultValue) -{ - Boolean value, ok; - - value = CFPreferencesGetAppBooleanValue(key, app_prefs_domain_cfstr, &ok); - - return ok ? (BOOL)value : defaultValue; -} - static void init_propdata(struct propdata *pdata) { @@ -1394,35 +1384,18 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, - (void) reload_preferences { - /* - * 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(app_prefs_domain_cfstr); + NSUserDefaults * const defaults = NSUserDefaults.xquartzDefaults; + #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); - pbproxy_prefs.pasteboard_to_primary = - prefs_get_bool(CFSTR( - "sync_pasteboard_to_primary"), - pbproxy_prefs.pasteboard_to_primary); - pbproxy_prefs.pasteboard_to_clipboard = - prefs_get_bool(CFSTR( - "sync_pasteboard_to_clipboard"), - pbproxy_prefs.pasteboard_to_clipboard); + pbproxy_prefs.active = [defaults boolForKey:XQuartzPrefKeySyncPasteboard]; + pbproxy_prefs.primary_on_grab = [defaults boolForKey:XQuartzPrefKeySyncPrimaryOnSelect]; + pbproxy_prefs.clipboard_to_pasteboard = [defaults boolForKey:XQuartzPrefKeySyncClipboardToPasteBoard]; + pbproxy_prefs.pasteboard_to_primary = [defaults boolForKey:XQuartzPrefKeySyncPasteboardToPrimary]; + pbproxy_prefs.pasteboard_to_clipboard = [defaults boolForKey:XQuartzPrefKeySyncPasteboardToClipboard]; /* This is used for debugging. */ //dump_prefs(); diff --git a/xserver/hw/xquartz/quartz.c b/xserver/hw/xquartz/quartz.c index 233570a75..4bbe56b93 100644 --- a/xserver/hw/xquartz/quartz.c +++ b/xserver/hw/xquartz/quartz.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; |