xquartz: Fold spaces related preferences into NSUserDefaults+XQuartzDefaults
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
parent
6134c73aeb
commit
f40610e0b4
|
@ -42,6 +42,8 @@ extern NSString * const XQuartzPrefKeySyncPrimaryOnSelect;
|
||||||
|
|
||||||
@interface NSUserDefaults (XQuartzDefaults)
|
@interface NSUserDefaults (XQuartzDefaults)
|
||||||
|
|
||||||
|
+ (NSUserDefaults *)globalDefaults;
|
||||||
|
+ (NSUserDefaults *)dockDefaults;
|
||||||
+ (NSUserDefaults *)xquartzDefaults;
|
+ (NSUserDefaults *)xquartzDefaults;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -44,6 +44,44 @@ NSString * const XQuartzPrefKeySyncPrimaryOnSelect = @"sync_primary_on_select";
|
||||||
|
|
||||||
@implementation NSUserDefaults (XQuartzDefaults)
|
@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
|
+ (NSUserDefaults *)xquartzDefaults
|
||||||
{
|
{
|
||||||
static dispatch_once_t once;
|
static dispatch_once_t once;
|
||||||
|
|
|
@ -417,7 +417,7 @@ QuartzModeBundleInit(void);
|
||||||
case NSApplicationActivatedEventType:
|
case NSApplicationActivatedEventType:
|
||||||
for_x = NO;
|
for_x = NO;
|
||||||
if ([e window] == nil && x_was_active) {
|
if ([e window] == nil && x_was_active) {
|
||||||
BOOL order_all_windows = YES, workspaces, ok;
|
BOOL order_all_windows = YES;
|
||||||
for_appkit = NO;
|
for_appkit = NO;
|
||||||
|
|
||||||
#if APPKIT_APPFLAGS_HACK
|
#if APPKIT_APPFLAGS_HACK
|
||||||
|
@ -430,26 +430,9 @@ QuartzModeBundleInit(void);
|
||||||
[self set_front_process:nil];
|
[self set_front_process:nil];
|
||||||
|
|
||||||
/* Get the Spaces preference for SwitchOnActivate */
|
/* Get the Spaces preference for SwitchOnActivate */
|
||||||
(void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock"));
|
BOOL const workspaces = [NSUserDefaults.dockDefaults boolForKey:@"workspaces"];
|
||||||
workspaces =
|
|
||||||
CFPreferencesGetAppBooleanValue(CFSTR("workspaces"),
|
|
||||||
CFSTR(
|
|
||||||
"com.apple.dock"),
|
|
||||||
&ok);
|
|
||||||
if (!ok)
|
|
||||||
workspaces = NO;
|
|
||||||
|
|
||||||
if (workspaces) {
|
if (workspaces) {
|
||||||
(void)CFPreferencesAppSynchronize(CFSTR(
|
order_all_windows = [NSUserDefaults.globalDefaults boolForKey:@"AppleSpacesSwitchOnActivate"];
|
||||||
".GlobalPreferences"));
|
|
||||||
order_all_windows =
|
|
||||||
CFPreferencesGetAppBooleanValue(CFSTR(
|
|
||||||
"AppleSpacesSwitchOnActivate"),
|
|
||||||
CFSTR(
|
|
||||||
".GlobalPreferences"),
|
|
||||||
&ok);
|
|
||||||
if (!ok)
|
|
||||||
order_all_windows = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: In the workspaces && !AppleSpacesSwitchOnActivate case, the windows are ordered
|
/* TODO: In the workspaces && !AppleSpacesSwitchOnActivate case, the windows are ordered
|
||||||
|
@ -460,8 +443,7 @@ QuartzModeBundleInit(void);
|
||||||
* be restoring one of them.
|
* be restoring one of them.
|
||||||
*/
|
*/
|
||||||
if ([e data2] & 0x10) { // 0x10 (bfCPSOrderAllWindowsForward) is set when we use cmd-tab or the dock icon
|
if ([e data2] & 0x10) { // 0x10 (bfCPSOrderAllWindowsForward) is set when we use cmd-tab or the dock icon
|
||||||
DarwinSendDDXEvent(kXquartzBringAllToFront, 1,
|
DarwinSendDDXEvent(kXquartzBringAllToFront, 1, order_all_windows);
|
||||||
order_all_windows);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue