diff options
| author | philw <dscr@duck.com> | 2025-04-24 11:05:27 +0200 |
|---|---|---|
| committer | philw <dscr@duck.com> | 2025-04-24 11:05:27 +0200 |
| commit | 3067e463f953463d4c604d0c5259475595d89a00 (patch) | |
| tree | 45b451826566e707cc19b17fa872e9ecade7a025 /src/core/dwm.c | |
| parent | 8146021a2ea4130cfb0d2bf846b451ec538b1bb6 (diff) | |
| download | dwm-3067e463f953463d4c604d0c5259475595d89a00.tar.gz dwm-3067e463f953463d4c604d0c5259475595d89a00.zip | |
feat: Refactor dwm.c for modularity, add dwm.h header file, switch compiler to tcc
Refactored dwm.c to improve code organization and maintainability
Added dwm.h header file for better modularity and to define common declarations
Changed the compiler to TCC for faster compilation during development.
Signed-off-by: philw <dscr@duck.com>
Diffstat (limited to 'src/core/dwm.c')
| -rw-r--r-- | src/core/dwm.c | 572 |
1 files changed, 144 insertions, 428 deletions
diff --git a/src/core/dwm.c b/src/core/dwm.c index 6082987..d3782cb 100644 --- a/src/core/dwm.c +++ b/src/core/dwm.c | |||
| @@ -51,6 +51,8 @@ | |||
| 51 | #include "../util/util.h" | 51 | #include "../util/util.h" |
| 52 | #include <X11/XF86keysym.h> | 52 | #include <X11/XF86keysym.h> |
| 53 | 53 | ||
| 54 | #include "dwm.h" | ||
| 55 | |||
| 54 | /* macros */ | 56 | /* macros */ |
| 55 | #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) | 57 | #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) |
| 56 | #define CLEANMASK(mask) \ | 58 | #define CLEANMASK(mask) \ |
| @@ -81,292 +83,6 @@ | |||
| 81 | #define VERSION_MINOR 0 | 83 | #define VERSION_MINOR 0 |
| 82 | #define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR | 84 | #define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR |
| 83 | 85 | ||
| 84 | /* enums */ | ||
| 85 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | ||
| 86 | enum { SchemeNorm, SchemeSel }; /* color schemes */ | ||
| 87 | enum { | ||
| 88 | NetSupported, | ||
| 89 | NetWMName, | ||
| 90 | NetWMState, | ||
| 91 | NetWMCheck, | ||
| 92 | NetSystemTray, | ||
| 93 | NetSystemTrayOP, | ||
| 94 | NetSystemTrayOrientation, | ||
| 95 | NetSystemTrayOrientationHorz, | ||
| 96 | NetWMFullscreen, | ||
| 97 | NetActiveWindow, | ||
| 98 | NetWMWindowType, | ||
| 99 | NetWMWindowTypeDialog, | ||
| 100 | NetClientList, | ||
| 101 | NetLast | ||
| 102 | }; /* EWMH atoms */ | ||
| 103 | enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */ | ||
| 104 | enum { | ||
| 105 | WMProtocols, | ||
| 106 | WMDelete, | ||
| 107 | WMState, | ||
| 108 | WMTakeFocus, | ||
| 109 | WMLast | ||
| 110 | }; /* default atoms */ | ||
| 111 | enum { | ||
| 112 | ClkTagBar, | ||
| 113 | ClkLtSymbol, | ||
| 114 | ClkStatusText, | ||
| 115 | ClkWinTitle, | ||
| 116 | ClkClientWin, | ||
| 117 | ClkRootWin, | ||
| 118 | ClkLast | ||
| 119 | }; /* clicks */ | ||
| 120 | |||
| 121 | typedef union { | ||
| 122 | int i; | ||
| 123 | unsigned int ui; | ||
| 124 | float f; | ||
| 125 | const void *v; | ||
| 126 | } Arg; | ||
| 127 | |||
| 128 | typedef struct { | ||
| 129 | unsigned int click; | ||
| 130 | unsigned int mask; | ||
| 131 | unsigned int button; | ||
| 132 | void (*func)(const Arg *arg); | ||
| 133 | const Arg arg; | ||
| 134 | } Button; | ||
| 135 | |||
| 136 | typedef struct Monitor Monitor; | ||
| 137 | typedef struct Client Client; | ||
| 138 | struct Client { | ||
| 139 | char name[256]; | ||
| 140 | float mina, maxa; | ||
| 141 | int x, y, w, h; | ||
| 142 | int oldx, oldy, oldw, oldh; | ||
| 143 | int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; | ||
| 144 | int bw, oldbw; | ||
| 145 | unsigned int tags; | ||
| 146 | int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, | ||
| 147 | isterminal, noswallow; | ||
| 148 | pid_t pid; | ||
| 149 | Client *next; | ||
| 150 | Client *snext; | ||
| 151 | Client *swallowing; | ||
| 152 | Monitor *mon; | ||
| 153 | Window win; | ||
| 154 | }; | ||
| 155 | |||
| 156 | typedef struct { | ||
| 157 | unsigned int mod; | ||
| 158 | KeySym keysym; | ||
| 159 | void (*func)(const Arg *); | ||
| 160 | const Arg arg; | ||
| 161 | } Key; | ||
| 162 | |||
| 163 | typedef struct { | ||
| 164 | const char *symbol; | ||
| 165 | void (*arrange)(Monitor *); | ||
| 166 | } Layout; | ||
| 167 | |||
| 168 | struct Monitor { | ||
| 169 | char ltsymbol[16]; | ||
| 170 | float mfact; | ||
| 171 | int nmaster; | ||
| 172 | int num; | ||
| 173 | int by; /* bar geometry */ | ||
| 174 | int mx, my, mw, mh; /* screen size */ | ||
| 175 | int wx, wy, ww, wh; /* window area */ | ||
| 176 | int gappih; /* horizontal gap between windows */ | ||
| 177 | int gappiv; /* vertical gap between windows */ | ||
| 178 | int gappoh; /* horizontal outer gaps */ | ||
| 179 | int gappov; /* vertical outer gaps */ | ||
| 180 | unsigned int seltags; | ||
| 181 | unsigned int sellt; | ||
| 182 | unsigned int tagset[2]; | ||
| 183 | int showbar; | ||
| 184 | int topbar; | ||
| 185 | Client *clients; | ||
| 186 | Client *sel; | ||
| 187 | Client *stack; | ||
| 188 | Monitor *next; | ||
| 189 | Window barwin; | ||
| 190 | const Layout *lt[2]; | ||
| 191 | }; | ||
| 192 | |||
| 193 | typedef struct { | ||
| 194 | const char *class; | ||
| 195 | const char *instance; | ||
| 196 | const char *title; | ||
| 197 | unsigned int tags; | ||
| 198 | int isfloating; | ||
| 199 | int isterminal; | ||
| 200 | int noswallow; | ||
| 201 | int monitor; | ||
| 202 | } Rule; | ||
| 203 | |||
| 204 | typedef struct Systray Systray; | ||
| 205 | struct Systray { | ||
| 206 | Window win; | ||
| 207 | Client *icons; | ||
| 208 | }; | ||
| 209 | |||
| 210 | /* function declarations */ | ||
| 211 | static void applyrules(Client *c); | ||
| 212 | static int applysizehints(Client *c, int *x, int *y, int *w, int *h, | ||
| 213 | int interact); | ||
| 214 | static void arrange(Monitor *m); | ||
| 215 | static void arrangemon(Monitor *m); | ||
| 216 | static void attach(Client *c); | ||
| 217 | static void attachstack(Client *c); | ||
| 218 | static void buttonpress(XEvent *e); | ||
| 219 | static void checkotherwm(void); | ||
| 220 | static void cleanup(void); | ||
| 221 | static void cleanupmon(Monitor *mon); | ||
| 222 | static void clientmessage(XEvent *e); | ||
| 223 | static void configure(Client *c); | ||
| 224 | static void configurenotify(XEvent *e); | ||
| 225 | static void configurerequest(XEvent *e); | ||
| 226 | static Monitor *createmon(void); | ||
| 227 | static void destroynotify(XEvent *e); | ||
| 228 | static void detach(Client *c); | ||
| 229 | static void detachstack(Client *c); | ||
| 230 | static Monitor *dirtomon(int dir); | ||
| 231 | static void drawbar(Monitor *m); | ||
| 232 | static void drawbars(void); | ||
| 233 | static void enternotify(XEvent *e); | ||
| 234 | static void expose(XEvent *e); | ||
| 235 | static void focus(Client *c); | ||
| 236 | static void focusin(XEvent *e); | ||
| 237 | static void focusmon(const Arg *arg); | ||
| 238 | static void focusstack(const Arg *arg); | ||
| 239 | static Atom getatomprop(Client *c, Atom prop); | ||
| 240 | static int getrootptr(int *x, int *y); | ||
| 241 | static long getstate(Window w); | ||
| 242 | static unsigned int getsystraywidth(); | ||
| 243 | static int gettextprop(Window w, Atom atom, char *text, unsigned int size); | ||
| 244 | static void grabbuttons(Client *c, int focused); | ||
| 245 | static void grabkeys(void); | ||
| 246 | static void incnmaster(const Arg *arg); | ||
| 247 | static void keypress(XEvent *e); | ||
| 248 | static void killclient(const Arg *arg); | ||
| 249 | static void manage(Window w, XWindowAttributes *wa); | ||
| 250 | static void mappingnotify(XEvent *e); | ||
| 251 | static void maprequest(XEvent *e); | ||
| 252 | static void monocle(Monitor *m); | ||
| 253 | static void motionnotify(XEvent *e); | ||
| 254 | static void movemouse(const Arg *arg); | ||
| 255 | static Client *nexttiled(Client *c); | ||
| 256 | static void pop(Client *c); | ||
| 257 | static void propertynotify(XEvent *e); | ||
| 258 | static void quit(const Arg *arg); | ||
| 259 | static Monitor *recttomon(int x, int y, int w, int h); | ||
| 260 | static void removesystrayicon(Client *i); | ||
| 261 | static void resize(Client *c, int x, int y, int w, int h, int interact); | ||
| 262 | static void resizebarwin(Monitor *m); | ||
| 263 | static void resizeclient(Client *c, int x, int y, int w, int h); | ||
| 264 | static void resizemouse(const Arg *arg); | ||
| 265 | static void resizerequest(XEvent *e); | ||
| 266 | static void restack(Monitor *m); | ||
| 267 | static void run(void); | ||
| 268 | static void scan(void); | ||
| 269 | static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, | ||
| 270 | long d3, long d4); | ||
| 271 | static void sendmon(Client *c, Monitor *m); | ||
| 272 | static void setclientstate(Client *c, long state); | ||
| 273 | static void setfocus(Client *c); | ||
| 274 | static void setfullscreen(Client *c, int fullscreen); | ||
| 275 | static void setgaps(int oh, int ov, int ih, int iv); | ||
| 276 | static void incrgaps(const Arg *arg); | ||
| 277 | static void incrigaps(const Arg *arg); | ||
| 278 | static void incrogaps(const Arg *arg); | ||
| 279 | static void incrohgaps(const Arg *arg); | ||
| 280 | static void incrovgaps(const Arg *arg); | ||
| 281 | static void incrihgaps(const Arg *arg); | ||
| 282 | static void incrivgaps(const Arg *arg); | ||
| 283 | static void togglegaps(const Arg *arg); | ||
| 284 | static void defaultgaps(const Arg *arg); | ||
| 285 | static void setlayout(const Arg *arg); | ||
| 286 | static void setmfact(const Arg *arg); | ||
| 287 | static void setup(void); | ||
| 288 | static void seturgent(Client *c, int urg); | ||
| 289 | static void showhide(Client *c); | ||
| 290 | static void spawn(const Arg *arg); | ||
| 291 | static Monitor *systraytomon(Monitor *m); | ||
| 292 | static void tag(const Arg *arg); | ||
| 293 | static void tagmon(const Arg *arg); | ||
| 294 | static void tile(Monitor *m); | ||
| 295 | static void togglebar(const Arg *arg); | ||
| 296 | static void togglefloating(const Arg *arg); | ||
| 297 | static void togglefullscr(const Arg *arg); | ||
| 298 | static void toggletag(const Arg *arg); | ||
| 299 | static void toggleview(const Arg *arg); | ||
| 300 | static void unfocus(Client *c, int setfocus); | ||
| 301 | static void unmanage(Client *c, int destroyed); | ||
| 302 | static void unmapnotify(XEvent *e); | ||
| 303 | static void updatebarpos(Monitor *m); | ||
| 304 | static void updatebars(void); | ||
| 305 | static void updateclientlist(void); | ||
| 306 | static int updategeom(void); | ||
| 307 | static void updatenumlockmask(void); | ||
| 308 | static void updatesystray(void); | ||
| 309 | static void updatesystrayicongeom(Client *i, int w, int h); | ||
| 310 | static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); | ||
| 311 | static void updatesizehints(Client *c); | ||
| 312 | static void updatestatus(void); | ||
| 313 | static void updatetitle(Client *c); | ||
| 314 | static void updatewindowtype(Client *c); | ||
| 315 | static void updatewmhints(Client *c); | ||
| 316 | static void view(const Arg *arg); | ||
| 317 | static Client *wintoclient(Window w); | ||
| 318 | static Monitor *wintomon(Window w); | ||
| 319 | static Client *wintosystrayicon(Window w); | ||
| 320 | static int xerror(Display *dpy, XErrorEvent *ee); | ||
| 321 | static int xerrordummy(Display *dpy, XErrorEvent *ee); | ||
| 322 | static int xerrorstart(Display *dpy, XErrorEvent *ee); | ||
| 323 | static void zoom(const Arg *arg); | ||
| 324 | |||
| 325 | static pid_t getparentprocess(pid_t p); | ||
| 326 | static int isdescprocess(pid_t p, pid_t c); | ||
| 327 | static Client *swallowingclient(Window w); | ||
| 328 | static Client *termforwin(const Client *c); | ||
| 329 | static pid_t winpid(Window w); | ||
| 330 | |||
| 331 | /* variables */ | ||
| 332 | static Systray *systray = NULL; | ||
| 333 | static const char broken[] = "broken"; | ||
| 334 | static char stext[256]; | ||
| 335 | static int screen; | ||
| 336 | static int sw, sh; /* X display screen geometry width, height */ | ||
| 337 | static int bh; /* bar height */ | ||
| 338 | static int enablegaps = 1; /* enables gaps, used by togglegaps */ | ||
| 339 | static int lrpad; /* sum of left and right padding for text */ | ||
| 340 | static int (*xerrorxlib)(Display *, XErrorEvent *); | ||
| 341 | static unsigned int numlockmask = 0; | ||
| 342 | static void (*handler[LASTEvent])(XEvent *) = { | ||
| 343 | [ButtonPress] = buttonpress, | ||
| 344 | [ClientMessage] = clientmessage, | ||
| 345 | [ConfigureRequest] = configurerequest, | ||
| 346 | [ConfigureNotify] = configurenotify, | ||
| 347 | [DestroyNotify] = destroynotify, | ||
| 348 | [EnterNotify] = enternotify, | ||
| 349 | [Expose] = expose, | ||
| 350 | [FocusIn] = focusin, | ||
| 351 | [KeyPress] = keypress, | ||
| 352 | [MappingNotify] = mappingnotify, | ||
| 353 | [MapRequest] = maprequest, | ||
| 354 | [MotionNotify] = motionnotify, | ||
| 355 | [PropertyNotify] = propertynotify, | ||
| 356 | [ResizeRequest] = resizerequest, | ||
| 357 | [UnmapNotify] = unmapnotify}; | ||
| 358 | |||
| 359 | static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast]; | ||
| 360 | static int running = 1; | ||
| 361 | static Cur *cursor[CurLast]; | ||
| 362 | static Clr **scheme; | ||
| 363 | static Display *dpy; | ||
| 364 | static Drw *drw; | ||
| 365 | static Monitor *mons, *selmon; | ||
| 366 | static Window root, wmcheckwin; | ||
| 367 | |||
| 368 | static xcb_connection_t *xcon; | ||
| 369 | |||
| 370 | /* configuration, allows nested code to access above variables */ | 86 | /* configuration, allows nested code to access above variables */ |
| 371 | #include "../config/config.h" | 87 | #include "../config/config.h" |
| 372 | 88 | ||
| @@ -882,20 +598,20 @@ void detachstack(Client *c) { | |||
| 882 | } | 598 | } |
| 883 | } | 599 | } |
| 884 | 600 | ||
| 885 | Monitor *dirtomon(int dir) { | 601 | // Monitor *dirtomon(int dir) { |
| 886 | Monitor *m = NULL; | 602 | // Monitor *m = NULL; |
| 887 | 603 | // | |
| 888 | if (dir > 0) { | 604 | // if (dir > 0) { |
| 889 | if (!(m = selmon->next)) | 605 | // if (!(m = selmon->next)) |
| 890 | m = mons; | 606 | // m = mons; |
| 891 | } else if (selmon == mons) | 607 | // } else if (selmon == mons) |
| 892 | for (m = mons; m->next; m = m->next) | 608 | // for (m = mons; m->next; m = m->next) |
| 893 | ; | 609 | // ; |
| 894 | else | 610 | // else |
| 895 | for (m = mons; m->next != selmon; m = m->next) | 611 | // for (m = mons; m->next != selmon; m = m->next) |
| 896 | ; | 612 | // ; |
| 897 | return m; | 613 | // return m; |
| 898 | } | 614 | // } |
| 899 | 615 | ||
| 900 | void drawbar(Monitor *m) { | 616 | void drawbar(Monitor *m) { |
| 901 | int x, w, tw = 0, stw = 0; | 617 | int x, w, tw = 0, stw = 0; |
| @@ -1024,43 +740,43 @@ void focusin(XEvent *e) { | |||
| 1024 | setfocus(selmon->sel); | 740 | setfocus(selmon->sel); |
| 1025 | } | 741 | } |
| 1026 | 742 | ||
| 1027 | void focusmon(const Arg *arg) { | 743 | // void focusmon(const Arg *arg) { |
| 1028 | Monitor *m; | 744 | // Monitor *m; |
| 1029 | 745 | // | |
| 1030 | if (!mons->next) | 746 | // if (!mons->next) |
| 1031 | return; | 747 | // return; |
| 1032 | if ((m = dirtomon(arg->i)) == selmon) | 748 | // if ((m = dirtomon(arg->i)) == selmon) |
| 1033 | return; | 749 | // return; |
| 1034 | unfocus(selmon->sel, 0); | 750 | // unfocus(selmon->sel, 0); |
| 1035 | selmon = m; | 751 | // selmon = m; |
| 1036 | focus(NULL); | 752 | // focus(NULL); |
| 1037 | } | 753 | // } |
| 1038 | 754 | ||
| 1039 | void focusstack(const Arg *arg) { | 755 | // void focusstack(const Arg *arg) { |
| 1040 | Client *c = NULL, *i; | 756 | // Client *c = NULL, *i; |
| 1041 | 757 | // | |
| 1042 | if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) | 758 | // if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) |
| 1043 | return; | 759 | // return; |
| 1044 | if (arg->i > 0) { | 760 | // if (arg->i > 0) { |
| 1045 | for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next) | 761 | // for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next) |
| 1046 | ; | 762 | // ; |
| 1047 | if (!c) | 763 | // if (!c) |
| 1048 | for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next) | 764 | // for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next) |
| 1049 | ; | 765 | // ; |
| 1050 | } else { | 766 | // } else { |
| 1051 | for (i = selmon->clients; i != selmon->sel; i = i->next) | 767 | // for (i = selmon->clients; i != selmon->sel; i = i->next) |
| 1052 | if (ISVISIBLE(i)) | 768 | // if (ISVISIBLE(i)) |
| 1053 | c = i; | 769 | // c = i; |
| 1054 | if (!c) | 770 | // if (!c) |
| 1055 | for (; i; i = i->next) | 771 | // for (; i; i = i->next) |
| 1056 | if (ISVISIBLE(i)) | 772 | // if (ISVISIBLE(i)) |
| 1057 | c = i; | 773 | // c = i; |
| 1058 | } | 774 | // } |
| 1059 | if (c) { | 775 | // if (c) { |
| 1060 | focus(c); | 776 | // focus(c); |
| 1061 | restack(selmon); | 777 | // restack(selmon); |
| 1062 | } | 778 | // } |
| 1063 | } | 779 | // } |
| 1064 | 780 | ||
| 1065 | Atom getatomprop(Client *c, Atom prop) { | 781 | Atom getatomprop(Client *c, Atom prop) { |
| 1066 | int di; | 782 | int di; |
| @@ -1185,10 +901,10 @@ void grabkeys(void) { | |||
| 1185 | } | 901 | } |
| 1186 | } | 902 | } |
| 1187 | 903 | ||
| 1188 | void incnmaster(const Arg *arg) { | 904 | // void incnmaster(const Arg *arg) { |
| 1189 | selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); | 905 | // selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); |
| 1190 | arrange(selmon); | 906 | // arrange(selmon); |
| 1191 | } | 907 | // } |
| 1192 | 908 | ||
| 1193 | #ifdef XINERAMA | 909 | #ifdef XINERAMA |
| 1194 | static int isuniquegeom(XineramaScreenInfo *unique, size_t n, | 910 | static int isuniquegeom(XineramaScreenInfo *unique, size_t n, |
| @@ -1321,18 +1037,18 @@ void maprequest(XEvent *e) { | |||
| 1321 | manage(ev->window, &wa); | 1037 | manage(ev->window, &wa); |
| 1322 | } | 1038 | } |
| 1323 | 1039 | ||
| 1324 | void monocle(Monitor *m) { | 1040 | // void monocle(Monitor *m) { |
| 1325 | unsigned int n = 0; | 1041 | // unsigned int n = 0; |
| 1326 | Client *c; | 1042 | // Client *c; |
| 1327 | 1043 | // | |
| 1328 | for (c = m->clients; c; c = c->next) | 1044 | // for (c = m->clients; c; c = c->next) |
| 1329 | if (ISVISIBLE(c)) | 1045 | // if (ISVISIBLE(c)) |
| 1330 | n++; | 1046 | // n++; |
| 1331 | if (n > 0) /* override layout symbol */ | 1047 | // if (n > 0) /* override layout symbol */ |
| 1332 | snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); | 1048 | // snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); |
| 1333 | for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) | 1049 | // for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) |
| 1334 | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); | 1050 | // resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); |
| 1335 | } | 1051 | // } |
| 1336 | 1052 | ||
| 1337 | void motionnotify(XEvent *e) { | 1053 | void motionnotify(XEvent *e) { |
| 1338 | static Monitor *mon = NULL; | 1054 | static Monitor *mon = NULL; |
| @@ -1742,64 +1458,64 @@ void setfullscreen(Client *c, int fullscreen) { | |||
| 1742 | } | 1458 | } |
| 1743 | } | 1459 | } |
| 1744 | 1460 | ||
| 1745 | void setgaps(int oh, int ov, int ih, int iv) { | 1461 | // void setgaps(int oh, int ov, int ih, int iv) { |
| 1746 | if (oh < 0) | 1462 | // if (oh < 0) |
| 1747 | oh = 0; | 1463 | // oh = 0; |
| 1748 | if (ov < 0) | 1464 | // if (ov < 0) |
| 1749 | ov = 0; | 1465 | // ov = 0; |
| 1750 | if (ih < 0) | 1466 | // if (ih < 0) |
| 1751 | ih = 0; | 1467 | // ih = 0; |
| 1752 | if (iv < 0) | 1468 | // if (iv < 0) |
| 1753 | iv = 0; | 1469 | // iv = 0; |
| 1754 | 1470 | // | |
| 1755 | selmon->gappoh = oh; | 1471 | // selmon->gappoh = oh; |
| 1756 | selmon->gappov = ov; | 1472 | // selmon->gappov = ov; |
| 1757 | selmon->gappih = ih; | 1473 | // selmon->gappih = ih; |
| 1758 | selmon->gappiv = iv; | 1474 | // selmon->gappiv = iv; |
| 1759 | arrange(selmon); | 1475 | // arrange(selmon); |
| 1760 | } | 1476 | // } |
| 1761 | 1477 | ||
| 1762 | void togglegaps(const Arg *arg) { | 1478 | // void togglegaps(const Arg *arg) { |
| 1763 | enablegaps = !enablegaps; | 1479 | // enablegaps = !enablegaps; |
| 1764 | arrange(selmon); | 1480 | // arrange(selmon); |
| 1765 | } | 1481 | // } |
| 1766 | 1482 | ||
| 1767 | void defaultgaps(const Arg *arg) { setgaps(gappoh, gappov, gappih, gappiv); } | 1483 | // void defaultgaps(const Arg *arg) { setgaps(gappoh, gappov, gappih, gappiv); } |
| 1768 | 1484 | // | |
| 1769 | void incrgaps(const Arg *arg) { | 1485 | // void incrgaps(const Arg *arg) { |
| 1770 | setgaps(selmon->gappoh + arg->i, selmon->gappov + arg->i, | 1486 | // setgaps(selmon->gappoh + arg->i, selmon->gappov + arg->i, |
| 1771 | selmon->gappih + arg->i, selmon->gappiv + arg->i); | 1487 | // selmon->gappih + arg->i, selmon->gappiv + arg->i); |
| 1772 | } | 1488 | // } |
| 1773 | 1489 | // | |
| 1774 | void incrigaps(const Arg *arg) { | 1490 | // void incrigaps(const Arg *arg) { |
| 1775 | setgaps(selmon->gappoh, selmon->gappov, selmon->gappih + arg->i, | 1491 | // setgaps(selmon->gappoh, selmon->gappov, selmon->gappih + arg->i, |
| 1776 | selmon->gappiv + arg->i); | 1492 | // selmon->gappiv + arg->i); |
| 1777 | } | 1493 | // } |
| 1778 | 1494 | // | |
| 1779 | void incrogaps(const Arg *arg) { | 1495 | // void incrogaps(const Arg *arg) { |
| 1780 | setgaps(selmon->gappoh + arg->i, selmon->gappov + arg->i, selmon->gappih, | 1496 | // setgaps(selmon->gappoh + arg->i, selmon->gappov + arg->i, selmon->gappih, |
| 1781 | selmon->gappiv); | 1497 | // selmon->gappiv); |
| 1782 | } | 1498 | // } |
| 1783 | 1499 | ||
| 1784 | void incrohgaps(const Arg *arg) { | 1500 | // void incrohgaps(const Arg *arg) { |
| 1785 | setgaps(selmon->gappoh + arg->i, selmon->gappov, selmon->gappih, | 1501 | // setgaps(selmon->gappoh + arg->i, selmon->gappov, selmon->gappih, |
| 1786 | selmon->gappiv); | 1502 | // selmon->gappiv); |
| 1787 | } | 1503 | // } |
| 1788 | 1504 | // | |
| 1789 | void incrovgaps(const Arg *arg) { | 1505 | // void incrovgaps(const Arg *arg) { |
| 1790 | setgaps(selmon->gappoh, selmon->gappov + arg->i, selmon->gappih, | 1506 | // setgaps(selmon->gappoh, selmon->gappov + arg->i, selmon->gappih, |
| 1791 | selmon->gappiv); | 1507 | // selmon->gappiv); |
| 1792 | } | 1508 | // } |
| 1793 | 1509 | // | |
| 1794 | void incrihgaps(const Arg *arg) { | 1510 | // void incrihgaps(const Arg *arg) { |
| 1795 | setgaps(selmon->gappoh, selmon->gappov, selmon->gappih + arg->i, | 1511 | // setgaps(selmon->gappoh, selmon->gappov, selmon->gappih + arg->i, |
| 1796 | selmon->gappiv); | 1512 | // selmon->gappiv); |
| 1797 | } | 1513 | // } |
| 1798 | 1514 | // | |
| 1799 | void incrivgaps(const Arg *arg) { | 1515 | // void incrivgaps(const Arg *arg) { |
| 1800 | setgaps(selmon->gappoh, selmon->gappov, selmon->gappih, | 1516 | // setgaps(selmon->gappoh, selmon->gappov, selmon->gappih, |
| 1801 | selmon->gappiv + arg->i); | 1517 | // selmon->gappiv + arg->i); |
| 1802 | } | 1518 | // } |
| 1803 | 1519 | ||
| 1804 | void setlayout(const Arg *arg) { | 1520 | void setlayout(const Arg *arg) { |
| 1805 | if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) | 1521 | if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) |
| @@ -1814,18 +1530,18 @@ void setlayout(const Arg *arg) { | |||
| 1814 | drawbar(selmon); | 1530 | drawbar(selmon); |
| 1815 | } | 1531 | } |
| 1816 | 1532 | ||
| 1817 | /* arg > 1.0 will set mfact absolutely */ | 1533 | // /* arg > 1.0 will set mfact absolutely */ |
| 1818 | void setmfact(const Arg *arg) { | 1534 | // void setmfact(const Arg *arg) { |
| 1819 | float f; | 1535 | // float f; |
| 1820 | 1536 | // | |
| 1821 | if (!arg || !selmon->lt[selmon->sellt]->arrange) | 1537 | // if (!arg || !selmon->lt[selmon->sellt]->arrange) |
| 1822 | return; | 1538 | // return; |
| 1823 | f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; | 1539 | // f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; |
| 1824 | if (f < 0.05 || f > 0.95) | 1540 | // if (f < 0.05 || f > 0.95) |
| 1825 | return; | 1541 | // return; |
| 1826 | selmon->mfact = f; | 1542 | // selmon->mfact = f; |
| 1827 | arrange(selmon); | 1543 | // arrange(selmon); |
| 1828 | } | 1544 | // } |
| 1829 | 1545 | ||
| 1830 | void setup(void) { | 1546 | void setup(void) { |
| 1831 | int i; | 1547 | int i; |
| @@ -1972,11 +1688,11 @@ void tag(const Arg *arg) { | |||
| 1972 | } | 1688 | } |
| 1973 | } | 1689 | } |
| 1974 | 1690 | ||
| 1975 | void tagmon(const Arg *arg) { | 1691 | // void tagmon(const Arg *arg) { |
| 1976 | if (!selmon->sel || !mons->next) | 1692 | // if (!selmon->sel || !mons->next) |
| 1977 | return; | 1693 | // return; |
| 1978 | sendmon(selmon->sel, dirtomon(arg->i)); | 1694 | // sendmon(selmon->sel, dirtomon(arg->i)); |
| 1979 | } | 1695 | // } |
| 1980 | 1696 | ||
| 1981 | void tile(Monitor *m) { | 1697 | void tile(Monitor *m) { |
| 1982 | unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty; | 1698 | unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty; |
