diff options
author | uint23 <[email protected]> | 2025-04-17 17:41:52 +0100 |
---|---|---|
committer | uint23 <[email protected]> | 2025-04-17 17:41:52 +0100 |
commit | df1e03f5cbfb4f40c6457d49bdcabfe26f1abd2d (patch) | |
tree | faf6e5ea8e8f4d2b20d44cc2cefcffbbb138a0a7 | |
parent | 57477a4dd0726153e759562ec5c7969a6d0147c7 (diff) |
global toggle floating
-rw-r--r-- | src/sxwm.c | 48 | ||||
-rw-r--r-- | src/usercfg.h | 5 |
2 files changed, 46 insertions, 7 deletions
@@ -53,6 +53,7 @@ static void setup(void); static void spawn(const char **cmd); static void tile(void); static void toggle_floating(void); +static void toggle_floating_global(void); static void update_borders(void); static int xerr(Display *dpy, XErrorEvent *ee); static void xev_case(XEvent *xev); @@ -606,6 +607,43 @@ toggle_floating(void) } static void +toggle_floating_global(void) +{ + Bool any_tiled = False; + for (Client *c = clients; c; c = c->next) { + if (!c->floating) { + any_tiled = True; + break; + } + } + + for (Client *c = clients; c; c = c->next) { + c->floating = any_tiled; + if (c->floating) { + XWindowAttributes wa; + XGetWindowAttributes(dpy, c->win, &wa); + c->x = wa.x; + c->y = wa.y; + c->w = wa.width; + c->h = wa.height; + + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight, + &(XWindowChanges){ + .x = c->x, + .y = c->y, + .width = c->w, + .height = c->h + } + ); + XRaiseWindow(dpy, c->win); + } + } + + tile(); + update_borders(); +} + +static void update_borders(void) { for (Client *c = clients; c; c = c->next) { @@ -627,13 +665,13 @@ xerr(Display *dpy, XErrorEvent *ee) XGetErrorText(dpy, ee->error_code, buf, sizeof(buf)); fprintf(stderr, "sxwm: X error:\n" - " request code: %d\n" - " error code: %d (%s)\n" - " resource id: 0x%lx\n", + "\trequest code: %d\n" + "\terror code: %d (%s)\n" + "\tresource id: 0x%lx\n", ee->request_code, ee->error_code, buf, - ee->resourceid - ); return 0; + ee->resourceid); + return 0; if (dpy && ee) return 0; } diff --git a/src/usercfg.h b/src/usercfg.h index 738ecd1..bc1ae89 100644 --- a/src/usercfg.h +++ b/src/usercfg.h @@ -4,13 +4,13 @@ #include <X11/keysym.h> #include "defs.h" -#define BORDER_WIDTH 1 +#define BORDER_WIDTH 5 #define BORDER_FOC_COL "#AAFFFA" // the border color when focused #define BORDER_UFOC_COL "#FF4439" // the border color when unfocused #define GAPS 10 // how many pixels wide the border is #define MASTER_WIDTH 0.6 // how much of the screen the master window takes up (0.0-1.0) #define MOTION_THROTTLE 144 // set this to your screen refreshrate -#define SNAP_DISTANCE 5 // snap distance +#define SNAP_DISTANCE 10 // snap distance static const char *termcmd[] = {"st", NULL}; @@ -24,6 +24,7 @@ static const Binding binds[] = { CALL(MOD, f, toggle_floating), CALL(MOD, equal, inc_gaps), CALL(MOD, minus, dec_gaps), + CALL(MOD, space, toggle_floating_global), }; #endif |