From a89a4c9273807320484ebd30075a5f58b71ba2cd Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Wed, 14 Jan 2026 00:21:47 +0100 Subject: Switch from c99 to c23 standard Create sketch for manual testing Disable redundant functions The following functions: movemouse, resizemouse, togglefloating, sendmon, pop, quit and zoom shall be removed. Specific windows (loading screens, notifications) will remain floating but there is no need in a window manager for manually toggling the floating behavior. Killing the session is no longer possible via keybinding. Insted I suggested adding a keybinding for reseting dwm and switching to TTY if it fails after all. --- src/core/dwm.c | 359 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 181 insertions(+), 178 deletions(-) (limited to 'src/core/dwm.c') diff --git a/src/core/dwm.c b/src/core/dwm.c index 6d4cdcd..761c22a 100644 --- a/src/core/dwm.c +++ b/src/core/dwm.c @@ -1141,71 +1141,72 @@ void motionnotify(XEvent *e) mon = m; } -void movemouse(const Arg *arg) -{ - int x, y, ocx, ocy, nx, ny; - Client *c; - Monitor *m; - XEvent ev; - Time lasttime = 0; - - if (!(c = selmon->sel)) - return; - if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ - return; - restack(selmon); - ocx = c->x; - ocy = c->y; - if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, - GrabModeAsync, None, cursor[CurMove]->cursor, - CurrentTime) != GrabSuccess) - return; - if (!getrootptr(&x, &y)) - return; - do { - XMaskEvent(dpy, - MOUSEMASK | ExposureMask | SubstructureRedirectMask, - &ev); - switch (ev.type) { - case ConfigureRequest: - case Expose: - case MapRequest: - handler[ev.type](&ev); - break; - case MotionNotify: - if ((ev.xmotion.time - lasttime) <= (1000 / 60)) - continue; - lasttime = ev.xmotion.time; - - nx = ocx + (ev.xmotion.x - x); - ny = ocy + (ev.xmotion.y - y); - if (abs(selmon->wx - nx) < snap) - nx = selmon->wx; - else if (abs((selmon->wx + selmon->ww) - - (nx + WIDTH(c))) < snap) - nx = selmon->wx + selmon->ww - WIDTH(c); - if (abs(selmon->wy - ny) < snap) - ny = selmon->wy; - else if (abs((selmon->wy + selmon->wh) - - (ny + HEIGHT(c))) < snap) - ny = selmon->wy + selmon->wh - HEIGHT(c); - if (!c->isfloating && - selmon->lt[selmon->sellt]->arrange && - (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) - togglefloating(NULL); - if (!selmon->lt[selmon->sellt]->arrange || - c->isfloating) - resize(c, nx, ny, c->w, c->h, 1); - break; - } - } while (ev.type != ButtonRelease); - XUngrabPointer(dpy, CurrentTime); - if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { - sendmon(c, m); - selmon = m; - focus(NULL); - } -} +// @TODO marked for removal +// void movemouse(const Arg *arg) +// { +// int x, y, ocx, ocy, nx, ny; +// Client *c; +// Monitor *m; +// XEvent ev; +// Time lasttime = 0; +// +// if (!(c = selmon->sel)) +// return; +// if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ +// return; +// restack(selmon); +// ocx = c->x; +// ocy = c->y; +// if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, +// GrabModeAsync, None, cursor[CurMove]->cursor, +// CurrentTime) != GrabSuccess) +// return; +// if (!getrootptr(&x, &y)) +// return; +// do { +// XMaskEvent(dpy, +// MOUSEMASK | ExposureMask | SubstructureRedirectMask, +// &ev); +// switch (ev.type) { +// case ConfigureRequest: +// case Expose: +// case MapRequest: +// handler[ev.type](&ev); +// break; +// case MotionNotify: +// if ((ev.xmotion.time - lasttime) <= (1000 / 60)) +// continue; +// lasttime = ev.xmotion.time; +// +// nx = ocx + (ev.xmotion.x - x); +// ny = ocy + (ev.xmotion.y - y); +// if (abs(selmon->wx - nx) < snap) +// nx = selmon->wx; +// else if (abs((selmon->wx + selmon->ww) - +// (nx + WIDTH(c))) < snap) +// nx = selmon->wx + selmon->ww - WIDTH(c); +// if (abs(selmon->wy - ny) < snap) +// ny = selmon->wy; +// else if (abs((selmon->wy + selmon->wh) - +// (ny + HEIGHT(c))) < snap) +// ny = selmon->wy + selmon->wh - HEIGHT(c); +// if (!c->isfloating && +// selmon->lt[selmon->sellt]->arrange && +// (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) +// togglefloating(NULL); +// if (!selmon->lt[selmon->sellt]->arrange || +// c->isfloating) +// resize(c, nx, ny, c->w, c->h, 1); +// break; +// } +// } while (ev.type != ButtonRelease); +// XUngrabPointer(dpy, CurrentTime); +// if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { +// sendmon(c, m); +// selmon = m; +// focus(NULL); +// } +// } Client *nexttiled(Client *c) { @@ -1214,13 +1215,13 @@ Client *nexttiled(Client *c) return c; } -void pop(Client *c) -{ - detach(c); - attach(c); - focus(c); - arrange(c->mon); -} +// void pop(Client *c) +// { +// detach(c); +// attach(c); +// focus(c); +// arrange(c->mon); +// } void propertynotify(XEvent *e) { @@ -1270,8 +1271,9 @@ void propertynotify(XEvent *e) } } -void quit(const Arg *arg) { running = 0; } - +// @TODO marked for removal +// void quit(const Arg *arg) { running = 0; } +// Monitor *recttomon(int x, int y, int w, int h) { Monitor *m, *r = selmon; @@ -1343,72 +1345,73 @@ void resizerequest(XEvent *e) } } -void resizemouse(const Arg *arg) -{ - int ocx, ocy, nw, nh; - Client *c; - Monitor *m; - XEvent ev; - Time lasttime = 0; - - if (!(c = selmon->sel)) - return; - if (c->isfullscreen) /* no support resizing fullscreen windows by mouse - */ - return; - restack(selmon); - ocx = c->x; - ocy = c->y; - if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, - GrabModeAsync, None, cursor[CurResize]->cursor, - CurrentTime) != GrabSuccess) - return; - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, - c->h + c->bw - 1); - do { - XMaskEvent(dpy, - MOUSEMASK | ExposureMask | SubstructureRedirectMask, - &ev); - switch (ev.type) { - case ConfigureRequest: - case Expose: - case MapRequest: - handler[ev.type](&ev); - break; - case MotionNotify: - if ((ev.xmotion.time - lasttime) <= (1000 / 60)) - continue; - lasttime = ev.xmotion.time; - - nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); - nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); - if (c->mon->wx + nw >= selmon->wx && - c->mon->wx + nw <= selmon->wx + selmon->ww && - c->mon->wy + nh >= selmon->wy && - c->mon->wy + nh <= selmon->wy + selmon->wh) { - if (!c->isfloating && - selmon->lt[selmon->sellt]->arrange && - (abs(nw - c->w) > snap || - abs(nh - c->h) > snap)) - togglefloating(NULL); - } - if (!selmon->lt[selmon->sellt]->arrange || - c->isfloating) - resize(c, c->x, c->y, nw, nh, 1); - break; - } - } while (ev.type != ButtonRelease); - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, - c->h + c->bw - 1); - XUngrabPointer(dpy, CurrentTime); - while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)) - ; - if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { - sendmon(c, m); - selmon = m; - focus(NULL); - } -} +// @TODO marked for removal +// void resizemouse(const Arg *arg) +// { +// int ocx, ocy, nw, nh; +// Client *c; +// Monitor *m; +// XEvent ev; +// Time lasttime = 0; +// +// if (!(c = selmon->sel)) +// return; +// if (c->isfullscreen) /* no support resizing fullscreen windows by mouse +// */ +// return; +// restack(selmon); +// ocx = c->x; +// ocy = c->y; +// if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, +// GrabModeAsync, None, cursor[CurResize]->cursor, +// CurrentTime) != GrabSuccess) +// return; +// XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, +// c->h + c->bw - 1); +// do { +// XMaskEvent(dpy, +// MOUSEMASK | ExposureMask | SubstructureRedirectMask, +// &ev); +// switch (ev.type) { +// case ConfigureRequest: +// case Expose: +// case MapRequest: +// handler[ev.type](&ev); +// break; +// case MotionNotify: +// if ((ev.xmotion.time - lasttime) <= (1000 / 60)) +// continue; +// lasttime = ev.xmotion.time; +// +// nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); +// nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); +// if (c->mon->wx + nw >= selmon->wx && +// c->mon->wx + nw <= selmon->wx + selmon->ww && +// c->mon->wy + nh >= selmon->wy && +// c->mon->wy + nh <= selmon->wy + selmon->wh) { +// if (!c->isfloating && +// selmon->lt[selmon->sellt]->arrange && +// (abs(nw - c->w) > snap || +// abs(nh - c->h) > snap)) +// togglefloating(NULL); +// } +// if (!selmon->lt[selmon->sellt]->arrange || +// c->isfloating) +// resize(c, c->x, c->y, nw, nh, 1); +// break; +// } +// } while (ev.type != ButtonRelease); +// XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, +// c->h + c->bw - 1); +// XUngrabPointer(dpy, CurrentTime); +// while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)) +// ; +// if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { +// sendmon(c, m); +// selmon = m; +// focus(NULL); +// } +// } void restack(Monitor *m) { @@ -1481,20 +1484,20 @@ void scan(void) } } -void sendmon(Client *c, Monitor *m) -{ - if (c->mon == m) - return; - unfocus(c, 1); - detach(c); - detachstack(c); - c->mon = m; - c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ - attach(c); - attachstack(c); - focus(NULL); - arrange(NULL); -} +// void sendmon(Client *c, Monitor *m) +// { +// if (c->mon == m) +// return; +// unfocus(c, 1); +// detach(c); +// detachstack(c); +// c->mon = m; +// c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ +// attach(c); +// attachstack(c); +// focus(NULL); +// arrange(NULL); +// } void setclientstate(Client *c, long state) { @@ -1811,19 +1814,19 @@ void togglebar(const Arg *arg) arrange(selmon); } -void togglefloating(const Arg *arg) -{ - if (!selmon->sel) - return; - if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ - return; - selmon->sel->isfloating = - !selmon->sel->isfloating || selmon->sel->isfixed; - if (selmon->sel->isfloating) - resize(selmon->sel, selmon->sel->x, selmon->sel->y, - selmon->sel->w, selmon->sel->h, 0); - arrange(selmon); -} +// void togglefloating(const Arg *arg) +// { +// if (!selmon->sel) +// return; +// if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ +// return; +// selmon->sel->isfloating = +// !selmon->sel->isfloating || selmon->sel->isfixed; +// if (selmon->sel->isfloating) +// resize(selmon->sel, selmon->sel->x, selmon->sel->y, +// selmon->sel->w, selmon->sel->h, 0); +// arrange(selmon); +// } void togglefullscr(const Arg *arg) { @@ -2534,17 +2537,17 @@ Monitor *systraytomon(Monitor *m) return mons; return t; } - -void zoom(const Arg *arg) -{ - Client *c = selmon->sel; - - if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating) - return; - if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next))) - return; - pop(c); -} +// @TODO marked for removal +// void zoom(const Arg *arg) +// { +// Client *c = selmon->sel; +// +// if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating) +// return; +// if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next))) +// return; +// pop(c); +// } int main(int argc, char *argv[]) { -- cgit v1.2.3