summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruint23 <[email protected]>2025-04-21 19:54:44 +0100
committeruint23 <[email protected]>2025-04-21 19:54:44 +0100
commit81c9b0e554b303f41b33f48288f6b0b19890bdc4 (patch)
tree13aa4c7da2d4d24a1baffa3a42f649cb31d5ae99 /src
parent94e37e2eea875928a56d00f6c664c0c3485ed1b7 (diff)
if global_floating, open new window at centre
Diffstat (limited to 'src')
-rw-r--r--src/defs.h2
-rw-r--r--src/sxwm.c19
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)) {