From 81c9b0e554b303f41b33f48288f6b0b19890bdc4 Mon Sep 17 00:00:00 2001 From: uint23 Date: Mon, 21 Apr 2025 19:54:44 +0100 Subject: if global_floating, open new window at centre --- src/defs.h | 2 +- src/sxwm.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/defs.h b/src/defs.h index 2cdc933..8059099 100644 --- a/src/defs.h +++ b/src/defs.h @@ -9,7 +9,7 @@ #define ulong unsigned long #define u_char unsigned char -#define SXWM_VERSION "sxwm ver. 1.1.0" +#define SXWM_VERSION "sxwm ver. 1.1.1" #define SXWM_AUTHOR "(C) Abhinav Prasai 2025" #define SXWM_LICINFO "See LICENSE for more info" diff --git a/src/sxwm.c b/src/sxwm.c index b6bb007..27dafba 100644 --- a/src/sxwm.c +++ b/src/sxwm.c @@ -167,6 +167,7 @@ add_client(Window w) c->fullscreen = False; if (global_floating) { + c->floating = True; XSetWindowBorder(dpy, c->win, border_foc_col); XSetWindowBorderWidth(dpy, c->win, BORDER_WIDTH); } @@ -587,9 +588,7 @@ hdl_map_req(XEvent *xev) atom_wm_window_type, 0, 1, False, XA_ATOM, &type, &format, &nitems, &bytes_after, - (u_char**)&types) == Success && types) - - { + (u_char**)&types) == Success && types) { if (nitems > 0 && types[0] == atom_net_wm_window_type_dock) { XFree(types); @@ -648,6 +647,20 @@ hdl_map_req(XEvent *xev) (c == focused ? border_foc_col : border_ufoc_col)); } + if (c->floating && !c->fullscreen) { + int w = (c->w < 64 ? 640 : c->w); + int h = (c->h < 64 ? 480 : c->h); + int x = (scr_width - w) / 2; + int y = (scr_height - h) / 2; + + c->x = x; + c->y = y; + c->w = w; + c->h = h; + + XMoveResizeWindow(dpy, c->win, x, y, w, h); + } + { Window transient; if (XGetTransientForHint(dpy, cr->window, &transient)) { -- cgit v1.2.3