diff options
| -rw-r--r-- | README.md | 28 | ||||
| -rw-r--r-- | default_sxwmrc | 1 | ||||
| -rw-r--r-- | src/defs.h | 1 | ||||
| -rw-r--r-- | src/parser.c | 10 | ||||
| -rw-r--r-- | src/sxwm.c | 13 |
5 files changed, 40 insertions, 13 deletions
@@ -47,11 +47,7 @@ --- ## Screenshots - -<img src="images/1.png" width="100%"> -<img src="images/x.png" width="100%"> -<img src="images/3.png" width="100%"> -<img src="images/4.png" width="100%"> +See on the [website](https://uint23.xyz/sxwm.html) --- @@ -76,6 +72,7 @@ The file uses a `key : value` format. Lines starting with `#` are ignored. | `snap_distance` | Integer | `5` | Distance (px) before a floating window snaps to edge. | | `motion_throttle` | Integer | `60` | Target FPS for mouse drag actions. | | `should_float` | String | `"st"` | Always-float rule. Multiple entries should be comma-seperated. Optionally, entries can be enclosed in quotes.| +| `new_win_focus` | Bool | `true` | Whether openening new windows should also set focus to them or keep on current window.| --- @@ -91,6 +88,16 @@ bind : modifier + modifier + ... + key : action - **Key**: Case-insensitive keysym (e.g., `Return`, `q`, `1`) - **Action**: Either an external command (in quotes) or internal function. +```sh +workspace : modifier + modifier + ... + key : move n +workspace : modifier + modifier + ... + key : swap n +``` +- **Modifiers**: `mod`, `shift`, `ctrl`, `alt`, `super` +- **Key**: Case-insensitive keysym (e.g., `Return`, `q`, `1`) +- **move**: Move to that worspace +- **swap**: Swap window to that workspace +- **n**: Workspace number + ### Available Functions | Function Name | Description | @@ -109,23 +116,19 @@ bind : modifier + modifier + ... + key : action | `toggle_floating` | Toggles floating state of current window. | | `global_floating` | Toggles floating state for all windows. | | `fullscreen` | Fullscreen toggle. | -| `change_wsX` | Switches to workspace `X` (1–9). | -| `moveto_wsX` | Moves current window to workspace `X` (1–9). | ### Example Bindings ```yaml # Launch terminal bind : mod + Return : "st" - # Close window bind : mod + shift + q : close_window # Switch workspace -bind : mod + 3 : change_ws3 - +workspace : mod + 3 : move 3 # Move window to workspace -bind : mod + shift + 5 : moveto_ws5 +workspace : mod + shift + 5 : swap 5 ``` --- @@ -163,6 +166,7 @@ bind : mod + shift + 5 : moveto_ws5 - `libX11` (Xorg client library) - `Xinerama` +- `XCursor` - GCC or Clang & Make <details> @@ -248,6 +252,8 @@ sudo pkg install gcc gmake libX11 libXinerama</code></pre> ```sh yay -S sxwm +# OR for latest features: +yay -S sxwm-git ``` ### Build from Source diff --git a/default_sxwmrc b/default_sxwmrc index c318190..53e3f32 100644 --- a/default_sxwmrc +++ b/default_sxwmrc @@ -11,6 +11,7 @@ resize_master_amount : 1 snap_distance : 5 motion_throttle : 60 # Set to screen refresh rate for smoothest motions should_float : st +new_win_focus : true # Keybinds: # Commands must be surrounded with "" @@ -89,6 +89,7 @@ typedef struct { int resize_master_amt; int snap_distance; int bindsn; + Bool new_win_focus; Binding binds[256]; char **should_float[256]; } Config; diff --git a/src/parser.c b/src/parser.c index bef8852..801d852 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,11 +1,11 @@ #define _POSIX_C_SOURCE 200809L +#include <X11/Xlib.h> #include <ctype.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <errno.h> #include <X11/keysym.h> #include "parser.h" @@ -222,6 +222,14 @@ found:; else if (!strcmp(key, "swap_border_colour")) { cfg->border_swap_col = parse_col(rest); } + else if (!strcmp(key, "new_win_focus")) { + if (!strcmp(rest, "true")) { + cfg->new_win_focus = True; + } + else { + cfg->new_win_focus = False; + } + } else if (!strcmp(key, "master_width")) { float mf = (float)atoi(rest) / 100.0f; for (int i = 0; i < MAX_MONITORS; i++) { @@ -14,6 +14,7 @@ * (C) Abhinav Prasai 2025 */ +#include <X11/X.h> #include <err.h> #include <stdio.h> #include <limits.h> @@ -828,10 +829,19 @@ void hdl_map_req(XEvent *xev) tile(); else if (c->floating) XRaiseWindow(dpy, w); + + if (user_config.new_win_focus) { + focused = c; + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + send_wm_take_focus(c->win); + } + XMapWindow(dpy, w); for (Client *c = workspaces[current_ws]; c; c = c->next) if (c->win == w) c->mapped = True; + + update_borders(); } @@ -1044,6 +1054,7 @@ void init_defaults(void) default_config.resize_master_amt = 5; default_config.snap_distance = 5; default_config.bindsn = 0; + default_config.new_win_focus = True; for (unsigned long i = 0; i < LENGTH(binds); i++) { default_config.binds[i].mods = binds[i].mods; @@ -1778,4 +1789,4 @@ int main(int ac, char **av) printf("sxwm: starting...\n"); run(); return 0; -}
\ No newline at end of file +} |
