4
4
#include <X11/Xft/Xft.h>
5
5
#include <X11/Xlib.h>
6
6
7
- /* forward declarations */
7
+ /* Forward Declarations */
8
8
typedef struct Monitor Monitor ;
9
9
typedef struct Client Client ;
10
10
typedef struct Drw Drw ;
11
11
typedef struct Fnt Fnt ;
12
12
13
- /* enums */
14
- enum { CurNormal , CurResize , CurMove , CurLast }; /* cursor */
15
- enum { SchemeNorm , SchemeSel }; /* color schemes */
16
- enum { ColFg , ColBg , ColBorder };
13
+ /* Enumerations */
14
+ // Cursor types
15
+ enum {
16
+ CurNormal , // Default cursor
17
+ CurResize , // Cursor when resizing windows
18
+ CurMove , // Cursor when moving windows
19
+ CurLast // Marker for last cursor type
20
+ };
21
+
22
+ // Color scheme indices
23
+ enum {
24
+ SchemeNorm , // Normal color scheme
25
+ SchemeSel // Selected color scheme
26
+ };
27
+
28
+ // Color indices within schemes
29
+ enum {
30
+ ColFg , // Foreground color
31
+ ColBg , // Background color
32
+ ColBorder // Border color
33
+ };
34
+
35
+ // EWMH (Extended Window Manager Hints) atoms
17
36
enum {
18
37
NetSupported ,
19
38
NetWMName ,
@@ -25,132 +44,147 @@ enum {
25
44
NetWMWindowTypeDialog ,
26
45
NetClientList ,
27
46
NetLast
28
- }; /* EWMH atoms */
29
- enum {
30
- WMProtocols ,
31
- WMDelete ,
32
- WMState ,
33
- WMTakeFocus ,
34
- WMLast
35
- }; /* default atoms */
47
+ };
48
+
49
+ // Default X11 atoms
50
+ enum { WMProtocols , WMDelete , WMState , WMTakeFocus , WMLast };
51
+
52
+ // Click locations for event handling
36
53
enum {
37
- ClkTagBar ,
38
- ClkLtSymbol ,
39
- ClkStatusText ,
40
- ClkWinTitle ,
41
- ClkClientWin ,
42
- ClkRootWin ,
43
- ClkLast
44
- }; /* clicks */
45
-
46
- /* structs */
54
+ ClkTagBar , // Tag bar area
55
+ ClkLtSymbol , // Layout symbol
56
+ ClkStatusText , // Status text area
57
+ ClkWinTitle , // Window title area
58
+ ClkClientWin , // Client window
59
+ ClkRootWin , // Root window
60
+ ClkLast // Marker for last click type
61
+ };
62
+
63
+ /* Data Structures */
64
+
65
+ // Generic argument union for flexible parameter passing
47
66
typedef union {
48
- int i ;
49
- unsigned int ui ;
50
- float f ;
51
- const void * v ;
67
+ int i ; // Integer value
68
+ unsigned int ui ; // Unsigned integer value
69
+ float f ; // Float value
70
+ const void * v ; // Void pointer for generic data
52
71
} Arg ;
53
72
73
+ // Mouse button configuration
54
74
typedef struct {
55
- unsigned int click ;
56
- unsigned int mask ;
57
- unsigned int button ;
58
- void (* func )(const Arg * arg );
59
- const Arg arg ;
75
+ unsigned int click ; // Click type
76
+ unsigned int mask ; // Modifier mask
77
+ unsigned int button ; // Button number
78
+ void (* func )(const Arg * arg ); // Function to call
79
+ const Arg arg ; // Argument to pass
60
80
} Button ;
61
81
82
+ // Keyboard shortcut configuration
62
83
typedef struct {
63
- unsigned int mod ;
64
- KeySym keysym ;
65
- void (* func )(const Arg * );
66
- const Arg arg ;
84
+ unsigned int mod ; // Modifier keys
85
+ KeySym keysym ; // Key symbol
86
+ void (* func )(const Arg * ); // Function to call
87
+ const Arg arg ; // Argument to pass
67
88
} Key ;
68
89
90
+ // Window rule configuration
69
91
typedef struct {
70
- const char * class ;
71
- const char * instance ;
72
- const char * title ;
73
- unsigned int tags ;
74
- int isfloating ;
75
- int monitor ;
92
+ const char * class ; // Window class
93
+ const char * instance ; // Window instance
94
+ const char * title ; // Window title
95
+ unsigned int tags ; // Tag mask
96
+ int isfloating ; // Floating state
97
+ int monitor ; // Monitor number
76
98
} Rule ;
77
99
100
+ // Cursor structure
78
101
typedef struct {
79
- Cursor cursor ;
102
+ Cursor cursor ; // X11 cursor
80
103
} Cur ;
81
104
105
+ // Font structure
82
106
struct Fnt {
83
- Display * dpy ;
84
- unsigned int h ;
85
- XftFont * xfont ;
86
- FcPattern * pattern ;
87
- struct Fnt * next ;
107
+ Display * dpy ; // Display connection
108
+ unsigned int h ; // Font height
109
+ XftFont * xfont ; // Xft font
110
+ FcPattern * pattern ; // Font pattern
111
+ struct Fnt * next ; // Next font in chain
88
112
};
89
113
114
+ // Color type definition
90
115
typedef XftColor Clr ;
91
116
117
+ // Drawing context structure
92
118
struct Drw {
93
- unsigned int w , h ;
94
- Display * dpy ;
95
- int screen ;
96
- Window root ;
97
- Drawable drawable ;
98
- GC gc ;
99
- Clr * scheme ;
100
- Fnt * fonts ;
119
+ unsigned int w , h ; // Width and height
120
+ Display * dpy ; // Display connection
121
+ int screen ; // Screen number
122
+ Window root ; // Root window
123
+ Drawable drawable ; // Drawing surface
124
+ GC gc ; // Graphics context
125
+ Clr * scheme ; // Color scheme
126
+ Fnt * fonts ; // Font set
101
127
};
102
128
129
+ // Client (window) structure
103
130
struct Client {
104
- char name [256 ];
105
- float minAspectRatio , maxAspectRatio ;
106
- int x , y , w , h ;
107
- int oldx , oldy , oldw , oldh ;
108
- float horizontalRatio , verticalRatio ;
109
- int basew , baseh , incw , inch , maxw , maxh , minw , minh , hintsvalid ;
110
- int borderWidth , oldBorderWidth ;
111
- unsigned int tags ;
112
- int isFixedSize , isFloating , isUrgent , neverFocus , previousState ,
113
- isFullscreen ;
114
- Client * next ;
115
- Client * snext ;
116
- Monitor * mon ;
117
- Window win ;
131
+ char name [256 ]; // Window title
132
+ float minAspectRatio , maxAspectRatio ; // Window aspect ratio constraints
133
+ int x , y , w , h ; // Current geometry
134
+ int oldx , oldy , oldw , oldh ; // Previous geometry
135
+ float horizontalRatio , verticalRatio ; // Position ratios
136
+ int basew , baseh , incw , inch , maxw , maxh , minw , minh ; // Size constraints
137
+ int hintsvalid ; // Whether size hints are valid
138
+ int borderWidth , oldBorderWidth ; // Border widths
139
+ unsigned int tags ; // Tags (virtual desktops)
140
+ int isFixedSize ; // Whether size is fixed
141
+ int isFloating ; // Whether window is floating
142
+ int isUrgent ; // Whether window needs attention
143
+ int neverFocus ; // Whether window should never get focus
144
+ int previousState ; // Previous state
145
+ int isFullscreen ; // Whether window is fullscreen
146
+ Client * next ; // Next client in list
147
+ Client * snext ; // Next client in stack
148
+ Monitor * mon ; // Monitor containing this client
149
+ Window win ; // X11 window ID
118
150
};
119
151
152
+ // Layout structure
120
153
typedef struct {
121
- const char * symbol ;
122
- void (* arrange )(Monitor * );
154
+ const char * symbol ; // Layout symbol
155
+ void (* arrange )(Monitor * ); // Layout arrangement function
123
156
} Layout ;
124
157
158
+ // Monitor structure
125
159
struct Monitor {
126
- char ltsymbol [16 ];
127
- float masterFactor ;
128
- int numMasterWindows ;
129
- int num ;
130
- int by ; /* bar geometry */
131
- int mx , my , mw , mh ; /* screen size */
132
- int wx , wy , ww , wh ; /* window area */
133
- unsigned int selectedTags ;
134
- unsigned int selectedLayout ;
135
- unsigned int tagset [2 ];
136
- int showbar ;
137
- int topbar ;
138
- Client * clients ;
139
- Client * sel ;
140
- Client * stack ;
141
- Monitor * next ;
142
- Window barwin ;
143
- const Layout * layouts [2 ];
160
+ char ltsymbol [16 ]; // Current layout symbol
161
+ float masterFactor ; // Size of master area
162
+ int numMasterWindows ; // Number of windows in master area
163
+ int num ; // Monitor number
164
+ int by ; // Bar y position
165
+ int mx , my , mw , mh ; // Monitor geometry
166
+ int wx , wy , ww , wh ; // Window area geometry
167
+ unsigned int selectedTags ; // Current tag selection
168
+ unsigned int selectedLayout ; // Current layout
169
+ unsigned int tagset [2 ]; // Tag sets
170
+ int showbar ; // Bar visibility
171
+ int topbar ; // Bar position
172
+ Client * clients ; // List of clients
173
+ Client * sel ; // Selected client
174
+ Client * stack ; // Client stack
175
+ Monitor * next ; // Next monitor
176
+ Window barwin ; // Bar window
177
+ const Layout * layouts [2 ]; // Available layouts
144
178
};
145
179
146
180
/* Drawing Functions */
147
- /* Drawable abstraction */
181
+ // Drawable creation and management
148
182
Drw * drw_create (Display * dpy , int screen , Window win , unsigned int w ,
149
183
unsigned int h );
150
184
void drw_resize (Drw * drw , unsigned int w , unsigned int h );
151
185
void drw_free (Drw * drw );
152
186
153
- /* Fnt abstraction */
187
+ // Font management
154
188
Fnt * drw_fontset_create (Drw * drw , const char * fonts [], size_t fontcount );
155
189
void drw_fontset_free (Fnt * set );
156
190
unsigned int drw_fontset_getwidth (Drw * drw , const char * text );
@@ -159,29 +193,27 @@ unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text,
159
193
void drw_font_getexts (Fnt * font , const char * text , unsigned int len ,
160
194
unsigned int * w , unsigned int * h );
161
195
162
- /* Colorscheme abstraction */
196
+ // Color management
163
197
void drw_clr_create (Drw * drw , Clr * dest , const char * clrname );
164
198
Clr * drw_scm_create (Drw * drw , const char * clrnames [], size_t clrcount );
165
199
166
- /* Cursor abstraction */
200
+ // Cursor management
167
201
Cur * drw_cur_create (Drw * drw , int shape );
168
202
void drw_cur_free (Drw * drw , Cur * cursor );
169
203
170
- /* Drawing context manipulation */
204
+ // Drawing context manipulation
171
205
void drw_setfontset (Drw * drw , Fnt * set );
172
206
void drw_setscheme (Drw * drw , Clr * scm );
173
207
174
- /* Drawing functions */
208
+ // Basic drawing operations
175
209
void drw_rect (Drw * drw , int x , int y , unsigned int w , unsigned int h ,
176
210
int filled , int invert );
177
211
int drw_text (Drw * drw , int x , int y , unsigned int w , unsigned int h ,
178
212
unsigned int lpad , const char * text , int invert );
179
-
180
- /* Map functions */
181
213
void drw_map (Drw * drw , Window win , int x , int y , unsigned int w ,
182
214
unsigned int h );
183
215
184
- /* Macros */
216
+ /* Utility Macros */
185
217
#define HEIGHT (X ) ((X)->h + 2 * (X)->borderWidth)
186
218
#define WIDTH (X ) ((X)->w + 2 * (X)->borderWidth)
187
219
#define ISVISIBLE (C ) ((C->tags & C->mon->tagset[C->mon->selectedTags]))
@@ -190,107 +222,125 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w,
190
222
#define BETWEEN (X , A , B ) ((A) <= (X) && (X) <= (B))
191
223
#define LENGTH (X ) (sizeof(X) / sizeof(X[0]))
192
224
193
- /* function declarations */
225
+ /* Function Declarations */
226
+ // Window Functions
227
+ void manage (Window w , XWindowAttributes * wa );
228
+ void unmanage (Client * c , int destroyed );
229
+ void updateWindowTitle (Client * c );
230
+ void updateWindowTypeProps (Client * c );
231
+ void updateWindowManagerHints (Client * c );
232
+ void updateWindowSizeHints (Client * c );
233
+ void configure (Client * c );
194
234
void applyWindowRules (Client * c );
195
235
int applyWindowSizeConstraints (Client * c , int * x , int * y , int * w , int * h ,
196
236
int interact );
197
- void arrange (Monitor * m );
198
- void arrangeMonitor (Monitor * m );
237
+ void setWindowFullscreen (Client * c , int fullscreen );
238
+ void setWindowUrgent (Client * c , int urg );
239
+ void toggleWindowFloating (const Arg * arg );
240
+ void toggleWindowVisibility (Client * c );
241
+ void resize (Client * c , int x , int y , int w , int h , int interact );
242
+ void resizeclient (Client * c , int x , int y , int w , int h );
243
+ void setclientstate (Client * c , long state );
244
+ int sendevent (Client * c , Atom proto );
245
+ int shouldscale (Client * c );
246
+ void scaleclient (Client * c , int x , int y , int w , int h , float scale );
247
+ Atom getatomprop (Client * c , Atom prop );
248
+ long getstate (Window w );
249
+ int gettextprop (Window w , Atom atom , char * text , unsigned int size );
250
+
251
+ // Focus Functions
252
+ void focus (Client * c );
253
+ void unfocus (Client * c , int setfocus );
254
+ void focusstack (const Arg * arg );
255
+ void focusMonitor (const Arg * arg );
256
+ void setfocus (Client * c );
257
+ void moveCursorToClientCenter (Client * c );
258
+
259
+ // Monitor Functions
260
+ Monitor * createMonitor (void );
261
+ void cleanupMonitor (Monitor * mon );
262
+ int updateMonitorGeometry (void );
263
+ Monitor * findMonitorFromWindow (Window w );
264
+ Monitor * findMonitorInDirection (int dir );
265
+ Monitor * getMonitorForArea (int x , int y , int w , int h );
266
+ void sendWindowToMonitor (Client * c , Monitor * m );
267
+ void directWindowToMonitor (const Arg * arg );
268
+
269
+ // Client Functions
199
270
void attach (Client * c );
271
+ void detach (Client * c );
200
272
void attachWindowToStack (Client * c );
273
+ void detachWindowFromStack (Client * c );
274
+ Client * findClientFromWindow (Window w );
275
+ Client * getNextTiledWindow (Client * c );
276
+ void updateclientlist (void );
277
+
278
+ // Event Handling Functions
201
279
void handleMouseButtonPress (XEvent * e );
202
- void checkForOtherWM (void );
203
- void cleanup (void );
204
- void cleanupMonitor (Monitor * mon );
205
280
void handleClientMessage (XEvent * e );
206
- void configure (Client * c );
207
- void configurenotify (XEvent * e );
208
281
void handleConfigureRequest (XEvent * e );
209
- Monitor * createMonitor (void );
210
282
void handleWindowDestroy (XEvent * e );
211
- void detach (Client * c );
212
- void detachWindowFromStack (Client * c );
213
- Monitor * findMonitorInDirection (int dir );
214
- void drawDash (Monitor * m );
215
- void drawDashes (void );
216
283
void handleMouseEnter (XEvent * e );
217
284
void handleExpose (XEvent * e );
218
- void focus (Client * c );
219
285
void handleFocusIn (XEvent * e );
220
- void focusMonitor (const Arg * arg );
221
- void focusstack (const Arg * arg );
222
- Atom getatomprop (Client * c , Atom prop );
223
- int getrootptr (int * x , int * y );
224
- long getstate (Window w );
225
- int gettextprop (Window w , Atom atom , char * text , unsigned int size );
226
- Client * getNextTiledWindow (Client * c );
227
- void registerMouseButtons (Client * c , int focused );
228
- void registerKeyboardShortcuts (void );
229
- void incNumMasterWindows (const Arg * arg );
230
- void keypress (XEvent * e );
231
- void killclient (const Arg * arg );
232
- void manage (Window w , XWindowAttributes * wa );
233
- void mappingnotify (XEvent * e );
234
- void maprequest (XEvent * e );
235
286
void handleMouseMotion (XEvent * e );
236
- void movemouse (const Arg * arg );
237
- void moveCursorToClientCenter (Client * c );
238
- void pop (Client * c );
239
287
void handlePropertyChange (XEvent * e );
240
- void quit (const Arg * arg );
241
- Monitor * getMonitorForArea (int x , int y , int w , int h );
242
- void resize (Client * c , int x , int y , int w , int h , int interact );
243
- void resizeclient (Client * c , int x , int y , int w , int h );
244
- void resizemouse (const Arg * arg );
245
- void restack (Monitor * m );
246
- void run (void );
247
- void scan (void );
248
- int sendevent (Client * c , Atom proto );
249
- void sendWindowToMonitor (Client * c , Monitor * m );
250
- void setclientstate (Client * c , long state );
251
- void setfocus (Client * c );
252
- void setWindowFullscreen (Client * c , int fullscreen );
288
+ void handleWindowUnmap (XEvent * e );
289
+ void mappingnotify (XEvent * e );
290
+ void maprequest (XEvent * e );
291
+ void keypress (XEvent * e );
292
+ void configurenotify (XEvent * e );
293
+
294
+ // Dashboard Functions
295
+ void drawDash (Monitor * m );
296
+ void drawDashes (void );
297
+ void updateDashPosition (Monitor * m );
298
+ void updatebars (void );
299
+ void updatestatus (void );
300
+ void toggleDash (const Arg * arg );
301
+
302
+ // Layout Functions
303
+ void arrange (Monitor * m );
304
+ void arrangeMonitor (Monitor * m );
253
305
void setlayout (const Arg * arg );
254
306
void setMasterRatio (const Arg * arg );
255
- void setup (void );
256
- void setWindowUrgent (Client * c , int urg );
257
- void toggleWindowVisibility (Client * c );
307
+ void incNumMasterWindows (const Arg * arg );
308
+ void tile (Monitor * m );
309
+ void monocle (Monitor * m );
310
+ void dwindle (Monitor * m );
311
+ void dwindlegaps (Monitor * m );
312
+ void restack (Monitor * m );
313
+
314
+ // Input Handling Functions
315
+ void registerMouseButtons (Client * c , int focused );
316
+ void registerKeyboardShortcuts (void );
317
+ void updatenumlockmask (void );
318
+ void movemouse (const Arg * arg );
319
+ void resizemouse (const Arg * arg );
320
+ int getrootptr (int * x , int * y );
321
+
322
+ // Action Functions
323
+ void killclient (const Arg * arg );
324
+ void quit (const Arg * arg );
258
325
void spawn (const Arg * arg );
259
326
void tag (const Arg * arg );
260
- void directWindowToMonitor (const Arg * arg );
261
- void toggleDash (const Arg * arg );
262
- void toggleWindowFloating (const Arg * arg );
263
327
void toggletag (const Arg * arg );
264
328
void toggleview (const Arg * arg );
265
- void unfocus (Client * c , int setfocus );
266
- void unmanage (Client * c , int destroyed );
267
- void handleWindowUnmap (XEvent * e );
268
- void updateDashPosition (Monitor * m );
269
- void updatebars (void );
270
- void updateclientlist (void );
271
- int updateMonitorGeometry (void );
272
- void updatenumlockmask (void );
273
- void updateWindowSizeHints (Client * c );
274
- void updatestatus (void );
275
- void updateWindowTitle (Client * c );
276
- void updateWindowTypeProps (Client * c );
277
- void updateWindowManagerHints (Client * c );
278
329
void view (const Arg * arg );
279
- Client * findClientFromWindow (Window w );
280
- Monitor * findMonitorFromWindow (Window w );
330
+ void zoom (const Arg * arg );
331
+ void pop (Client * c );
332
+
333
+ // Main Functions
334
+ void checkForOtherWM (void );
335
+ void cleanup (void );
336
+ void run (void );
337
+ void scan (void );
338
+ void setup (void );
281
339
int xerror (Display * dpy , XErrorEvent * ee );
282
340
int xerrordummy (Display * dpy , XErrorEvent * ee );
283
341
int xerrorstart (Display * dpy , XErrorEvent * ee );
284
- void zoom (const Arg * arg );
285
-
286
- /* Layout functions */
287
- void tile (Monitor * m );
288
- void monocle (Monitor * m );
289
- void dwindle (Monitor * m );
290
- void dwindlegaps (Monitor * m );
291
- int shouldscale (Client * c );
292
- void scaleclient (Client * c , int x , int y , int w , int h , float scale );
293
342
343
+ /* External Variables */
294
344
extern Display * dpy ;
295
345
extern Monitor * monitors ;
296
346
extern Monitor * selectedMonitor ;
@@ -299,4 +349,4 @@ extern int bh;
299
349
extern Window root ;
300
350
extern unsigned int numlockmask ;
301
351
302
- #endif // _ATLASWM_H_endif // _ATLASWM_H_
352
+ #endif // _ATLASWM_H_
0 commit comments