From ab47f3c117c04728b8af263928d54723a1058986 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 8 Jan 2026 23:24:45 +0100 Subject: [PATCH] chore: update c files --- src/client.c | 22 ++++++++++++++++++++++ src/decorations.c | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/client.c b/src/client.c index d9a6088..3b8ca85 100644 --- a/src/client.c +++ b/src/client.c @@ -361,6 +361,9 @@ void client_focus(Client *client) client_raise(client); + /* Ungrab buttons so the application receives events directly */ + XUngrabButton(dwn->display, Button1, AnyModifier, client->window); + client_sync_log("client_focus: decorations"); decorations_render(client, true); @@ -379,6 +382,12 @@ void client_unfocus(Client *client) return; } + /* Grab buttons to intercept clicks for focus */ + if (dwn != NULL && dwn->display != NULL && client->window != None) { + XGrabButton(dwn->display, Button1, AnyModifier, client->window, False, + ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); + } + decorations_render(client, false); } @@ -428,6 +437,18 @@ void client_minimize(Client *client) client->flags |= CLIENT_MINIMIZED; client_hide(client); + + Workspace *ws = workspace_get(client->workspace); + if (ws != NULL && ws->focused == client) { + Client *next = workspace_mru_get_previous(client->workspace, client); + if (next != NULL) { + client_focus(next); + } else { + ws->focused = NULL; + XSetInputFocus(dwn->display, dwn->root, RevertToPointerRoot, CurrentTime); + atoms_set_active_window(None); + } + } } void client_restore(Client *client) @@ -749,6 +770,7 @@ void client_set_maximize(Client *client, bool maximized) client_configure(client); decorations_render(client, true); client_raise(client); + client_focus(client); } else { client->flags &= ~CLIENT_MAXIMIZED; diff --git a/src/decorations.c b/src/decorations.c index 304c2e9..95e023a 100644 --- a/src/decorations.c +++ b/src/decorations.c @@ -302,7 +302,7 @@ void decorations_button_press(Client *client, ButtonType button) case BUTTON_MAXIMIZE: LOG_DEBUG("Maximize button pressed for %s", client->title); - client_toggle_fullscreen(client); + client_toggle_maximize(client); break; case BUTTON_MINIMIZE: