diff options
| author | Abhinav <abhinav.prsai@gmail.com> | 2025-06-24 16:56:23 +0100 |
|---|---|---|
| committer | Abhinav <abhinav.prsai@gmail.com> | 2025-06-24 16:56:23 +0100 |
| commit | 8418960055da3337e767afb49f59c7eec229dc3c (patch) | |
| tree | 6555adbe7dd562018d358b2b3df69f590bcb413b /src/sxwm.c | |
| parent | de5be2ff9d3e8d0c0f3c725a9fb9ea7046c12862 (diff) | |
add window centering
the user can now center any floating window with default bind
centre_window
Diffstat (limited to 'src/sxwm.c')
| -rw-r--r-- | src/sxwm.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -38,6 +38,7 @@ #include "parser.h" Client *add_client(Window w, int ws); +/* void centre_window(); */ void change_workspace(int ws); int clean_mask(int mask); /* void close_focused(void); */ @@ -253,6 +254,20 @@ Client *add_client(Window w, int ws) return c; } +void centre_window() +{ + if (!focused || !focused->mapped || !focused->floating) { + return; + } + + int x = mons[focused->mon].x + (mons[focused->mon].w - focused->w) / 2; + int y = mons[focused->mon].y + (mons[focused->mon].h - focused->h) / 2; + + focused->x = x; + focused->y = y; + XMoveWindow(dpy, focused->win, x, y); +} + void change_workspace(int ws) { if (ws >= NUM_WORKSPACES || ws == current_ws) { @@ -2657,4 +2672,4 @@ int main(int ac, char **av) printf("sxwm: starting...\n"); run(); return 0; -}
\ No newline at end of file +} |
