Repository navigation
Expand file tree
/
Copy pathAppController.m
More file actions
142 lines (129 loc) · 5.31 KB
/
Copy pathAppController.m
File metadata and controls
142 lines (129 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* DockWM
*
* Copyright (C) 2026 Gregory Casamento <greg.casamento@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#import "AppControllerPrivate.h"
@implementation AppController
- (void) applicationDidFinishLaunching: (NSNotification *)notification
{
NSRect frame;
_items = [NSMutableArray new];
_recyclerController = [RecyclerController new];
_preferences = [[DockPreferences alloc] init];
[_preferences applyIconManagerPreference];
_applicationScanner = [RunningApplicationScanner new];
_applicationStore = [[DockApplicationStore alloc]
initWithScanner:_applicationScanner];
_applicationIconManager = [[ApplicationIconManager alloc]
initWithScanner:_applicationScanner];
_launchedApplicationPaths = [NSMutableSet new];
_dockPlacement = [self savedDockPlacement];
_dockCellSizeMode = [self savedDockCellSizeMode];
_runningIndicatorMode = [self savedRunningIndicatorMode];
_backgroundColor = RETAIN([self savedBackgroundColor]);
_windowAlpha = [self savedWindowAlpha];
_useCellTileBackground = [self savedUseCellTileBackground];
_showDockBorder = [self savedShowDockBorder];
_magnifiesHoveredIcons = [_preferences savedMagnifiesHoveredIcons];
_hoverIconScale = [_preferences savedHoverIconScale];
_dockScale = [_preferences savedDockScale];
_wigglesOnLaunch = [_preferences savedWigglesOnLaunch];
_wigglesOnActivation = [_preferences savedWigglesOnActivation];
_wigglesOnAttentionRequest = [_preferences savedWigglesOnAttentionRequest];
_playsSoundOnRemove = [_preferences savedPlaysSoundOnRemove];
_singleClickLaunchesApplications = [self savedSingleClickLaunchesApplications];
_hidesMiniwindows = [_preferences savedHidesMiniwindows];
[self loadPersistedApplications];
frame = [self dockWindowFrameForPlacement:_dockPlacement];
_window = [[DockWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
[_window setLevel:NSDockWindowLevel];
[_window setCollectionBehavior:(NSWindowCollectionBehaviorCanJoinAllSpaces |
NSWindowCollectionBehaviorStationary)];
[_window setOpaque:NO];
[_window setAlphaValue:1.0];
[_window setBackgroundColor:[NSColor clearColor]];
[_window setTitle:@"AppsDockWM"];
[_window setAcceptsMouseMovedEvents:YES];
_dockView = [[DockView alloc] initWithFrame:NSMakeRect(0, 0,
NSWidth(frame),
NSHeight(frame))];
[_dockView setDelegate:self];
[_dockView setHorizontal:[DockPreferences placementIsHorizontal:_dockPlacement]];
[self applyDockCellSizeToView];
[_dockView setBackgroundColor:_backgroundColor];
[_dockView setBackgroundAlpha:_windowAlpha];
[_dockView setShowsBorder:_showDockBorder];
[_dockView setRunningIndicatorMode:_runningIndicatorMode];
[_dockView setMagnifiesHoveredIcons:_magnifiesHoveredIcons];
[_dockView setHoverIconScale:_hoverIconScale];
[_dockView setTooltipDelay:[_preferences savedTooltipDelay]];
[_dockView setSingleClickLaunchesApplications:_singleClickLaunchesApplications];
[_dockView setItems:_items];
[_dockView setPinnedItemCount:[self pinnedApplicationCount]];
[_dockView setMenu:[self dockMenu]];
[_window setContentView:_dockView];
[self updateDockBackground];
[_window makeKeyAndOrderFront:nil];
[_window orderFrontRegardless];
[_window display];
_x11 = [[X11DockManager alloc] initWithDockView:_dockView];
[_x11 setDelegate:self];
[_x11 setHidesMiniwindows:_hidesMiniwindows];
if ([_x11 start])
{
/* GNUstep window numbers are backend tags, not native X11 IDs. */
[_x11 makeWindowSticky:(unsigned long)[_window windowRef]];
[_x11 setDockPlacement:_dockPlacement];
}
[self performSelector:@selector(performInitialApplicationScans)
withObject:nil
afterDelay:0.5];
}
- (void) dealloc
{
[_x11EventTimer invalidate];
[_scanTimer invalidate];
[_processScanTimer invalidate];
[_applicationExitTimer invalidate];
DESTROY(_settingsController);
DESTROY(_recyclerController);
DESTROY(_preferences);
DESTROY(_dockMenu);
DESTROY(_x11);
DESTROY(_dockView);
DESTROY(_window);
DESTROY(_applicationStore);
DESTROY(_applicationIconManager);
DESTROY(_applicationScanner);
DESTROY(_launchedApplicationPaths);
DESTROY(_backgroundColor);
DESTROY(_items);
DEALLOC;
}
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)sender
{
return NO;
}
- (void) applicationWillTerminate: (NSNotification *)notification
{
[self savePersistedApplications];
[[NSUserDefaults standardUserDefaults] synchronize];
}
@end