diff options
| author | Filip Wandzio <contact@philw.dev> | 2025-12-30 02:45:11 +0100 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2025-12-30 02:45:11 +0100 |
| commit | 4c90d1d9e4092f9ee0106d316829144653a276ea (patch) | |
| tree | cba5e7697a1334da068c5fa5e5951e00696fb903 /src/core | |
| parent | 11b1ff4691ff3e0f8346e7431fa3f90cc846fc5d (diff) | |
| download | dwm-4c90d1d9e4092f9ee0106d316829144653a276ea.tar.gz dwm-4c90d1d9e4092f9ee0106d316829144653a276ea.zip | |
Split monolithic dwm.h into modular headers and group them by it's functionalities
The new plan of refactoring this project is to split entire monolithic codebase into separate, (kind of) independent modules. This will help with understanding the code by turning off modules and deciding which ones require some work.
Signed-off-by: Filip Wandzio <contact@philw.dev>
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/dwm.c | 4 | ||||
| -rw-r--r-- | src/core/dwm.h | 2 | ||||
| -rw-r--r-- | src/core/globals.h | 21 | ||||
| -rw-r--r-- | src/core/types.h | 158 |
4 files changed, 182 insertions, 3 deletions
diff --git a/src/core/dwm.c b/src/core/dwm.c index cd7fdb0..6d4cdcd 100644 --- a/src/core/dwm.c +++ b/src/core/dwm.c | |||
| @@ -851,7 +851,7 @@ Atom getatomprop(Client *c, Atom prop) | |||
| 851 | return atom; | 851 | return atom; |
| 852 | } | 852 | } |
| 853 | 853 | ||
| 854 | unsigned int getsystraywidth() | 854 | unsigned int getsystraywidth(void) |
| 855 | { | 855 | { |
| 856 | unsigned int w = 0; | 856 | unsigned int w = 0; |
| 857 | Client *i; | 857 | Client *i; |
| @@ -1970,7 +1970,7 @@ void updatebarpos(Monitor *m) | |||
| 1970 | m->by = -bh; | 1970 | m->by = -bh; |
| 1971 | } | 1971 | } |
| 1972 | 1972 | ||
| 1973 | void updateclientlist() | 1973 | void updateclientlist(void) |
| 1974 | { | 1974 | { |
| 1975 | Client *c; | 1975 | Client *c; |
| 1976 | Monitor *m; | 1976 | Monitor *m; |
diff --git a/src/core/dwm.h b/src/core/dwm.h index 273645a..d3bdf5a 100644 --- a/src/core/dwm.h +++ b/src/core/dwm.h | |||
| @@ -153,7 +153,7 @@ static void focusin(XEvent *e); | |||
| 153 | static Atom getatomprop(Client *c, Atom prop); | 153 | static Atom getatomprop(Client *c, Atom prop); |
| 154 | static int getrootptr(int *x, int *y); | 154 | static int getrootptr(int *x, int *y); |
| 155 | static long getstate(Window w); | 155 | static long getstate(Window w); |
| 156 | static unsigned int getsystraywidth(); | 156 | static unsigned int getsystraywidth(void); |
| 157 | static int gettextprop(Window w, Atom atom, char *text, unsigned int size); | 157 | static int gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 158 | static void grabbuttons(Client *c, int focused); | 158 | static void grabbuttons(Client *c, int focused); |
| 159 | static void grabkeys(void); | 159 | static void grabkeys(void); |
diff --git a/src/core/globals.h b/src/core/globals.h new file mode 100644 index 0000000..4b800fe --- /dev/null +++ b/src/core/globals.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "types.h" | ||
| 5 | |||
| 6 | extern Display *dpy; | ||
| 7 | extern Window root, wmcheckwin; | ||
| 8 | |||
| 9 | extern Monitor *mons, *selmon; | ||
| 10 | |||
| 11 | extern int screen; | ||
| 12 | extern int sw, sh; | ||
| 13 | extern int bh; | ||
| 14 | extern int running; | ||
| 15 | extern unsigned int numlockmask; | ||
| 16 | |||
| 17 | extern Atom wmatom[WMLast]; | ||
| 18 | extern Atom netatom[NetLast]; | ||
| 19 | extern Atom xatom[XLast]; | ||
| 20 | |||
| 21 | extern Systray *systray; | ||
diff --git a/src/core/types.h b/src/core/types.h new file mode 100644 index 0000000..dc10fc0 --- /dev/null +++ b/src/core/types.h | |||
| @@ -0,0 +1,158 @@ | |||
| 1 | |||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <X11/Xatom.h> | ||
| 5 | #include <X11/Xlib.h> | ||
| 6 | #include <sys/types.h> | ||
| 7 | |||
| 8 | /* cursors */ | ||
| 9 | enum { CurNormal, CurResize, CurMove, CurLast }; | ||
| 10 | |||
| 11 | /* color schemes */ | ||
| 12 | enum { SchemeNorm, SchemeSel }; | ||
| 13 | |||
| 14 | /* EWMH atoms */ | ||
| 15 | enum { | ||
| 16 | NetSupported, | ||
| 17 | NetWMName, | ||
| 18 | NetWMState, | ||
| 19 | NetWMCheck, | ||
| 20 | NetSystemTray, | ||
| 21 | NetSystemTrayOP, | ||
| 22 | NetSystemTrayOrientation, | ||
| 23 | NetSystemTrayOrientationHorz, | ||
| 24 | NetWMFullscreen, | ||
| 25 | NetActiveWindow, | ||
| 26 | NetWMWindowType, | ||
| 27 | NetWMWindowTypeDialog, | ||
| 28 | NetClientList, | ||
| 29 | NetLast | ||
| 30 | }; | ||
| 31 | |||
| 32 | /* XEmbed */ | ||
| 33 | enum { Manager, Xembed, XembedInfo, XLast }; | ||
| 34 | |||
| 35 | /* ICCCM */ | ||
| 36 | enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; | ||
| 37 | |||
| 38 | /* clicks */ | ||
| 39 | enum { | ||
| 40 | ClkTagBar, | ||
| 41 | ClkLtSymbol, | ||
| 42 | ClkStatusText, | ||
| 43 | ClkWinTitle, | ||
| 44 | ClkClientWin, | ||
| 45 | ClkRootWin, | ||
| 46 | ClkLast | ||
| 47 | }; | ||
| 48 | |||
| 49 | /* generic argument */ | ||
| 50 | typedef union { | ||
| 51 | int i; | ||
| 52 | unsigned int ui; | ||
| 53 | float f; | ||
| 54 | const void *v; | ||
| 55 | } Arg; | ||
| 56 | |||
| 57 | /* input */ | ||
| 58 | typedef struct { | ||
| 59 | unsigned int click; | ||
| 60 | unsigned int mask; | ||
| 61 | unsigned int button; | ||
| 62 | void (*func)(const Arg *arg); | ||
| 63 | const Arg arg; | ||
| 64 | } Button; | ||
| 65 | |||
| 66 | typedef struct { | ||
| 67 | unsigned int mod; | ||
| 68 | KeySym keysym; | ||
| 69 | void (*func)(const Arg *); | ||
| 70 | const Arg arg; | ||
| 71 | } Key; | ||
| 72 | |||
| 73 | /* forward decls */ | ||
| 74 | typedef struct Client Client; | ||
| 75 | typedef struct Monitor Monitor; | ||
| 76 | |||
| 77 | /* layout */ | ||
| 78 | typedef struct { | ||
| 79 | const char *symbol; | ||
| 80 | void (*arrange)(Monitor *); | ||
| 81 | } Layout; | ||
| 82 | |||
| 83 | /* client */ | ||
| 84 | struct Client { | ||
| 85 | char name[256]; | ||
| 86 | |||
| 87 | float mina, maxa; | ||
| 88 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | ||
| 89 | int hintsvalid; | ||
| 90 | |||
| 91 | int x, y, w, h; | ||
| 92 | int oldx, oldy, oldw, oldh; | ||
| 93 | int bw, oldbw; | ||
| 94 | |||
| 95 | unsigned int tags; | ||
| 96 | int isfixed, isfloating, isurgent, neverfocus; | ||
| 97 | int oldstate, isfullscreen; | ||
| 98 | int isterminal, noswallow; | ||
| 99 | |||
| 100 | pid_t pid; | ||
| 101 | |||
| 102 | Client *next; | ||
| 103 | Client *snext; | ||
| 104 | Client *swallowing; | ||
| 105 | |||
| 106 | Monitor *mon; | ||
| 107 | Window win; | ||
| 108 | }; | ||
| 109 | |||
| 110 | /* monitor */ | ||
| 111 | struct Monitor { | ||
| 112 | char ltsymbol[16]; | ||
| 113 | |||
| 114 | float mfact; | ||
| 115 | int nmaster; | ||
| 116 | int num; | ||
| 117 | |||
| 118 | int mx, my, mw, mh; | ||
| 119 | int wx, wy, ww, wh; | ||
| 120 | int by; | ||
| 121 | |||
| 122 | int gappih, gappiv; | ||
| 123 | int gappoh, gappov; | ||
| 124 | |||
| 125 | unsigned int seltags; | ||
| 126 | unsigned int sellt; | ||
| 127 | unsigned int tagset[2]; | ||
| 128 | |||
| 129 | int showbar; | ||
| 130 | int topbar; | ||
| 131 | |||
| 132 | Client *clients; | ||
| 133 | Client *sel; | ||
| 134 | Client *stack; | ||
| 135 | |||
| 136 | Monitor *next; | ||
| 137 | Window barwin; | ||
| 138 | |||
| 139 | const Layout *lt[2]; | ||
| 140 | }; | ||
| 141 | |||
| 142 | /* rules */ | ||
| 143 | typedef struct { | ||
| 144 | const char *class; | ||
| 145 | const char *instance; | ||
| 146 | const char *title; | ||
| 147 | unsigned int tags; | ||
| 148 | int isfloating; | ||
| 149 | int isterminal; | ||
| 150 | int noswallow; | ||
| 151 | int monitor; | ||
| 152 | } Rule; | ||
| 153 | |||
| 154 | /* systray */ | ||
| 155 | typedef struct Systray { | ||
| 156 | Window win; | ||
| 157 | Client *icons; | ||
| 158 | } Systray; | ||
