diff options
| author | tslil clingman <tslil@posteo.de> | 2023-02-14 20:34:12 +0100 |
|---|---|---|
| committer | tslil clingman <tslil@posteo.de> | 2023-02-14 20:34:54 +0100 |
| commit | 819d795ba8472cc0c5b9f1f58fd4422d8c41ec71 (patch) | |
| tree | 72fc3a44b7e654c2d7f83b32f52fdb205b8aa11d | |
| parent | e9d8f093021dc416a5c790e2161d047426db2592 (diff) | |
[dwl] merge main, fix pertag/view(0), rule can prevent client focus
| -rw-r--r-- | dwl/.gitignore (renamed from dwl-0.4/.gitignore) | 0 | ||||
| -rw-r--r-- | dwl/LICENSE (renamed from dwl-0.4/LICENSE) | 0 | ||||
| -rw-r--r-- | dwl/LICENSE.dwm (renamed from dwl-0.4/LICENSE.dwm) | 0 | ||||
| -rw-r--r-- | dwl/LICENSE.sway (renamed from dwl-0.4/LICENSE.sway) | 0 | ||||
| -rw-r--r-- | dwl/LICENSE.tinywl (renamed from dwl-0.4/LICENSE.tinywl) | 0 | ||||
| -rw-r--r-- | dwl/Makefile (renamed from dwl-0.4/Makefile) | 0 | ||||
| -rw-r--r-- | dwl/README.md (renamed from dwl-0.4/README.md) | 0 | ||||
| -rw-r--r-- | dwl/bottomstack.patch (renamed from dwl-0.4/bottomstack.patch) | 0 | ||||
| -rw-r--r-- | dwl/client.h (renamed from dwl-0.4/client.h) | 0 | ||||
| -rw-r--r-- | dwl/config.def.h (renamed from dwl-0.4/config.def.h) | 6 | ||||
| -rw-r--r-- | dwl/config.h (renamed from dwl-0.4/config.h) | 18 | ||||
| -rw-r--r-- | dwl/config.mk (renamed from dwl-0.4/config.mk) | 0 | ||||
| -rw-r--r-- | dwl/dwl.1 (renamed from dwl-0.4/dwl.1) | 0 | ||||
| -rw-r--r-- | dwl/dwl.c (renamed from dwl-0.4/dwl.c) | 122 | ||||
| -rw-r--r-- | dwl/pertag.patch (renamed from dwl-0.4/pertag.patch) | 0 | ||||
| -rw-r--r-- | dwl/protocols/wlr-layer-shell-unstable-v1.xml (renamed from dwl-0.4/protocols/wlr-layer-shell-unstable-v1.xml) | 0 | ||||
| -rw-r--r-- | dwl/util.c (renamed from dwl-0.4/util.c) | 0 | ||||
| -rw-r--r-- | dwl/util.h (renamed from dwl-0.4/util.h) | 0 |
18 files changed, 104 insertions, 42 deletions
diff --git a/dwl-0.4/.gitignore b/dwl/.gitignore index 0dde90e..0dde90e 100644 --- a/dwl-0.4/.gitignore +++ b/dwl/.gitignore diff --git a/dwl-0.4/LICENSE b/dwl/LICENSE index 658085a..658085a 100644 --- a/dwl-0.4/LICENSE +++ b/dwl/LICENSE diff --git a/dwl-0.4/LICENSE.dwm b/dwl/LICENSE.dwm index 507e4dc..507e4dc 100644 --- a/dwl-0.4/LICENSE.dwm +++ b/dwl/LICENSE.dwm diff --git a/dwl-0.4/LICENSE.sway b/dwl/LICENSE.sway index 3e0cacc..3e0cacc 100644 --- a/dwl-0.4/LICENSE.sway +++ b/dwl/LICENSE.sway diff --git a/dwl-0.4/LICENSE.tinywl b/dwl/LICENSE.tinywl index 7023690..7023690 100644 --- a/dwl-0.4/LICENSE.tinywl +++ b/dwl/LICENSE.tinywl diff --git a/dwl-0.4/Makefile b/dwl/Makefile index ccca079..ccca079 100644 --- a/dwl-0.4/Makefile +++ b/dwl/Makefile diff --git a/dwl-0.4/README.md b/dwl/README.md index 05f149c..05f149c 100644 --- a/dwl-0.4/README.md +++ b/dwl/README.md diff --git a/dwl-0.4/bottomstack.patch b/dwl/bottomstack.patch index ed17954..ed17954 100644 --- a/dwl-0.4/bottomstack.patch +++ b/dwl/bottomstack.patch diff --git a/dwl-0.4/client.h b/dwl/client.h index 5a45edc..5a45edc 100644 --- a/dwl-0.4/client.h +++ b/dwl/client.h diff --git a/dwl-0.4/config.def.h b/dwl/config.def.h index b721b08..61e5953 100644 --- a/dwl-0.4/config.def.h +++ b/dwl/config.def.h @@ -31,12 +31,12 @@ static const Layout layouts[] = { /* monitors */ static const MonitorRule monrules[] = { - /* name mfact nmaster scale layout rotate/reflect */ + /* name mfact nmaster scale layout rotate/reflect x y */ /* example of a HiDPI laptop monitor: - { "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, + { "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL -1, -1 }, */ /* defaults */ - { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, + { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, }; /* keyboard */ diff --git a/dwl-0.4/config.h b/dwl/config.h index 319b74b..6fdee76 100644 --- a/dwl-0.4/config.h +++ b/dwl/config.h @@ -13,9 +13,9 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; static const char *tags[] = { "F", "U", "H", ".", "V", "L", "O", "M" }; static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ - { "firefox", "DWL_EMPTY_TITLE", 0, 1, -1 }, - { "firefox", "Firefox — Sharing Indicator", 0, 1, -1 } + /* app_id title tags mask isfloating monitor keep_focus */ + { "firefox", "DWL_EMPTY_TITLE", 0, 1, -1, 0 }, + { "firefox", "Firefox — Sharing Indicator", 0, 1, -1, 0 } }; /* layout(s) */ @@ -30,11 +30,11 @@ static const Layout layouts[] = { /* monitors */ static const MonitorRule monrules[] = { - /* name mfact nmaster scale layout rotate/reflect */ - { "DP-1", 0.6, 1, 1, &layouts[2], WL_OUTPUT_TRANSFORM_90 }, - { "DP-3", 0.6, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, + /* name mfact nmaster scale layout rotate/reflect x y*/ + { "DP-3", 0.6, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0 }, + { "DP-1", 0.6, 1, 1, &layouts[2], WL_OUTPUT_TRANSFORM_90, -1, -1 }, /* defaults */ - { NULL, 0.6, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, + { NULL, 0.6, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, }; /* keyboard */ @@ -146,7 +146,6 @@ static const Key keys[] = { { MODKEY, XKB_KEY_e, setmfact, {.f = -0.05} }, { MODKEY, XKB_KEY_n, setmfact, {.f = +0.05} }, { MODKEY, XKB_KEY_Return, zoom, {0} }, - { MODKEY, XKB_KEY_Tab, view, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, killclient, {0} }, // Layout @@ -161,9 +160,10 @@ static const Key keys[] = { // Tags { MODKEY, XKB_KEY_0, view, {.ui = ~0 } }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0 } }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,tag, {.ui = ~0 } }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_RIGHT } }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, tagmon, {.i = WLR_DIRECTION_LEFT } }, + { MODKEY, XKB_KEY_Tab, view, {.ui = 0 } }, TAGKEYS( XKB_KEY_f, XKB_KEY_F, 0), TAGKEYS( XKB_KEY_u, XKB_KEY_U, 1), TAGKEYS( XKB_KEY_h, XKB_KEY_H, 2), diff --git a/dwl-0.4/config.mk b/dwl/config.mk index f50156f..f50156f 100644 --- a/dwl-0.4/config.mk +++ b/dwl/config.mk diff --git a/dwl-0.4/dwl.1 b/dwl/dwl.1 index cae1036..cae1036 100644 --- a/dwl-0.4/dwl.1 +++ b/dwl/dwl.1 diff --git a/dwl-0.4/dwl.c b/dwl/dwl.c index 3aa0415..2bb6f59 100644 --- a/dwl-0.4/dwl.c +++ b/dwl/dwl.c @@ -65,7 +65,7 @@ #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) -#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) +#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset)) #define LENGTH(X) (sizeof X / sizeof X[0]) #define END(A) ((A) + LENGTH(A)) #define TAGMASK ((1 << LENGTH(tags)) - 1) @@ -140,6 +140,10 @@ typedef struct { typedef struct { struct wl_list link; struct wlr_keyboard *wlr_keyboard; + int nsyms; + const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */ + uint32_t mods; /* invalid if nsyms == 0 */ + struct wl_event_source *key_repeat_source; struct wl_listener modifiers; struct wl_listener key; @@ -183,9 +187,8 @@ struct Monitor { struct wl_list layers[4]; /* LayerSurface::link */ const Layout *lt[2]; Pertag *pertag; - unsigned int seltags; unsigned int sellt; - unsigned int tagset[2]; + unsigned int tagset; double mfact; int nmaster; }; @@ -197,6 +200,7 @@ typedef struct { float scale; const Layout *lt; enum wl_output_transform rr; + int x, y; } MonitorRule; typedef struct { @@ -205,6 +209,7 @@ typedef struct { unsigned int tags; int isfloating; int monitor; + int focus_client; } Rule; typedef struct { @@ -261,6 +266,7 @@ static void inputdevice(struct wl_listener *listener, void *data); static int keybinding(uint32_t mods, xkb_keysym_t sym); static void keypress(struct wl_listener *listener, void *data); static void keypressmod(struct wl_listener *listener, void *data); +static int keyrepeat(void *data); static void killclient(const Arg *arg); static void locksession(struct wl_listener *listener, void *data); static void maplayersurfacenotify(struct wl_listener *listener, void *data); @@ -455,6 +461,7 @@ applyrules(Client *c) unsigned int i, newtags = 0; const Rule *r; Monitor *mon = selmon, *m; + bool fix_focus_at_end = false; c->isfloating = client_is_float_type(c); if (!(appid = client_get_appid(c))) @@ -468,6 +475,7 @@ applyrules(Client *c) if ((!r->title || strstr(title, r->title)) && (!r->id || strstr(appid, r->id))) { c->isfloating = r->isfloating; + fix_focus_at_end |= (r->focus_client == 0); newtags |= r->tags; i = 0; wl_list_for_each(m, &mons, link) @@ -477,6 +485,15 @@ applyrules(Client *c) } wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]); setmon(c, mon, newtags); + if (fix_focus_at_end) { + Client *old; + wl_list_for_each(old, &fstack, flink) { + if (old!=c) { + focusclient(old, 0); + return; + }; + } + } } void @@ -681,6 +698,7 @@ cleanupkeyboard(struct wl_listener *listener, void *data) { Keyboard *kb = wl_container_of(listener, kb, destroy); + wl_event_source_remove(kb->key_repeat_source); wl_list_remove(&kb->link); wl_list_remove(&kb->modifiers.link); wl_list_remove(&kb->key.link); @@ -826,6 +844,9 @@ createkeyboard(struct wlr_keyboard *keyboard) wlr_seat_set_keyboard(seat, keyboard); + kb->key_repeat_source = wl_event_loop_add_timer( + wl_display_get_event_loop(dpy), keyrepeat, kb); + /* And add the keyboard to our list of keyboards */ wl_list_insert(&keyboards, &kb->link); } @@ -914,7 +935,7 @@ createmon(struct wl_listener *listener, void *data) /* Initialize monitor state using configured rules */ for (i = 0; i < LENGTH(m->layers); i++) wl_list_init(&m->layers[i]); - m->tagset[0] = m->tagset[1] = 1; + m->tagset = 1; for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { m->mfact = r->mfact; @@ -923,6 +944,8 @@ createmon(struct wl_listener *listener, void *data) wlr_xcursor_manager_load(cursor_mgr, r->scale); m->lt[0] = m->lt[1] = r->lt; wlr_output_set_transform(wlr_output, r->rr); + m->m.x = r->x; + m->m.y = r->y; break; } } @@ -972,7 +995,6 @@ createmon(struct wl_listener *listener, void *data) m->pertag->ltidxs[i][1] = m->lt[1]; m->pertag->sellts[i] = m->sellt; } - /* Adds this to the output layout in the order it was configured in. * * The output layout utility automatically adds a wl_output global to the @@ -980,7 +1002,10 @@ createmon(struct wl_listener *listener, void *data) * output (such as DPI, scale factor, manufacturer, etc). */ m->scene_output = wlr_scene_output_create(scene, wlr_output); - wlr_output_layout_add_auto(output_layout, wlr_output); + if (m->m.x < 0 || m->m.y < 0) + wlr_output_layout_add_auto(output_layout, wlr_output); + else + wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y); } void @@ -1421,6 +1446,17 @@ keypress(struct wl_listener *listener, void *data) for (i = 0; i < nsyms; i++) handled = keybinding(mods, syms[i]) || handled; + if (handled && kb->wlr_keyboard->repeat_info.delay > 0) { + kb->mods = mods; + kb->keysyms = syms; + kb->nsyms = nsyms; + wl_event_source_timer_update(kb->key_repeat_source, + kb->wlr_keyboard->repeat_info.delay); + } else { + kb->nsyms = 0; + wl_event_source_timer_update(kb->key_repeat_source, 0); + } + if (!handled) { /* Pass unhandled keycodes along to the client. */ wlr_seat_set_keyboard(seat, kb->wlr_keyboard); @@ -1447,6 +1483,22 @@ keypressmod(struct wl_listener *listener, void *data) &kb->wlr_keyboard->modifiers); } +int +keyrepeat(void *data) +{ + Keyboard *kb = data; + int i; + if (kb->nsyms && kb->wlr_keyboard->repeat_info.rate > 0) { + wl_event_source_timer_update(kb->key_repeat_source, + 1000 / kb->wlr_keyboard->repeat_info.rate); + + for (i = 0; i < kb->nsyms; i++) + keybinding(kb->mods, kb->keysyms[i]); + } + + return 0; +} + void killclient(const Arg *arg) { @@ -1510,7 +1562,6 @@ mapnotify(struct wl_listener *listener, void *data) } c->scene->node.data = c->scene_surface->node.data = c; -#ifdef XWAYLAND /* Handle unmanaged clients first so we can return prior create borders */ if (client_is_unmanaged(c)) { client_get_geometry(c, &c->geom); @@ -1524,7 +1575,6 @@ mapnotify(struct wl_listener *listener, void *data) } goto unset_fullscreen; } -#endif for (i = 0; i < 4; i++) { c->border[i] = wlr_scene_rect_create(c->scene, 0, 0, bordercolor); @@ -1807,6 +1857,7 @@ printstatus(void) Monitor *m = NULL; Client *c; unsigned int occ, urg, sel; + const char *appid, *title; wl_list_for_each(m, &mons, link) { occ = urg = 0; @@ -1818,19 +1869,23 @@ printstatus(void) urg |= c->tags; } if ((c = focustop(m))) { - printf("%s title %s (%s)\n", m->wlr_output->name, client_get_title(c), client_get_appid(c)); + title = client_get_title(c); + appid = client_get_appid(c); + printf("%s title %s\n", m->wlr_output->name, title ? title : broken); + printf("%s appid %s\n", m->wlr_output->name, appid ? appid : broken); printf("%s fullscreen %u\n", m->wlr_output->name, c->isfullscreen); printf("%s floating %u\n", m->wlr_output->name, c->isfloating); sel = c->tags; } else { printf("%s title \n", m->wlr_output->name); + printf("%s appid \n", m->wlr_output->name); printf("%s fullscreen \n", m->wlr_output->name); printf("%s floating \n", m->wlr_output->name); sel = 0; } printf("%s selmon %u\n", m->wlr_output->name, m == selmon); - printf("%s tags %u %u %u %u\n", m->wlr_output->name, occ, m->tagset[m->seltags], + printf("%s tags %u %u %u %u\n", m->wlr_output->name, occ, m->tagset, sel, urg); printf("%s layout %s\n", m->wlr_output->name, m->lt[m->sellt]->symbol); } @@ -1912,6 +1967,8 @@ run(char *startup_cmd) { /* Add a Unix socket to the Wayland display. */ const char *socket = wl_display_add_socket_auto(dpy); + struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = SIG_IGN}; + sigemptyset(&sa.sa_mask); if (!socket) die("startup: display_add_socket_auto"); setenv("WAYLAND_DISPLAY", socket, 1); @@ -1940,7 +1997,7 @@ run(char *startup_cmd) close(piperw[0]); } /* If nobody is reading the status output, don't terminate */ - signal(SIGPIPE, SIG_IGN); + sigaction(SIGPIPE, &sa, NULL); printstatus(); /* At this point the outputs are initialized, choose initial selmon based on @@ -1955,7 +2012,7 @@ run(char *startup_cmd) wlr_xcursor_manager_set_cursor_image(cursor_mgr, cursor_image, cursor); // HACK - focusmon(&(Arg){.i = WLR_DIRECTION_RIGHT }); + // focusmon(&(Arg){.i = WLR_DIRECTION_RIGHT }); /* Run the Wayland event loop. This does not return until you exit the * compositor. Starting the backend rigged up all of the necessary event @@ -2065,7 +2122,7 @@ setmon(Client *c, Monitor *m, unsigned int newtags) /* Make sure window actually overlaps with the monitor */ resize(c, c->geom, 0); wlr_surface_send_enter(client_surface(c), m->wlr_output); - c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */ + c->tags = newtags ? newtags : m->tagset; /* assign tags of target monitor */ setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */ } focusclient(focustop(selmon), 1); @@ -2096,18 +2153,26 @@ setsel(struct wl_listener *listener, void *data) void setup(void) { + struct sigaction sa_term = {.sa_flags = SA_RESTART, .sa_handler = quitsignal}; + struct sigaction sa_sigchld = { +#ifdef XWAYLAND + .sa_flags = SA_RESTART, + .sa_handler = sigchld, +#else + .sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART, + .sa_handler = SIG_IGN, +#endif + }; + sigemptyset(&sa_term.sa_mask); + sigemptyset(&sa_sigchld.sa_mask); /* The Wayland display is managed by libwayland. It handles accepting * clients from the Unix socket, manging Wayland globals, and so on. */ dpy = wl_display_create(); /* Set up signal handlers */ -#ifdef XWAYLAND - sigchld(0); -#else - signal(SIGCHLD, SIG_IGN); -#endif - signal(SIGINT, quitsignal); - signal(SIGTERM, quitsignal); + sigaction(SIGCHLD, &sa_sigchld, NULL); + sigaction(SIGINT, &sa_term, NULL); + sigaction(SIGTERM, &sa_term, NULL); /* The backend is a wlroots feature which abstracts the underlying input and * output hardware. The autocreate option will choose the most suitable @@ -2406,11 +2471,11 @@ toggletag(const Arg *arg) void toggleview(const Arg *arg) { - unsigned int newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0; + unsigned int newtagset = selmon ? selmon->tagset ^ (arg->ui & TAGMASK) : 0; size_t i; if (newtagset) { - selmon->tagset[selmon->seltags] = newtagset; + selmon->tagset = newtagset; if (newtagset == ~0) { selmon->pertag->prevtag = selmon->pertag->curtag; @@ -2598,14 +2663,11 @@ view(const Arg *arg) { size_t i, tmptag; - if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) + if (!selmon || (arg->ui & TAGMASK) == selmon->tagset) return; - if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) - - selmon->seltags ^= 1; /* toggle sel tagset */ if (arg->ui & TAGMASK) { - selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + selmon->tagset = arg->ui & TAGMASK; selmon->pertag->prevtag = selmon->pertag->curtag; if (arg->ui == ~0) @@ -2618,6 +2680,7 @@ view(const Arg *arg) tmptag = selmon->pertag->prevtag; selmon->pertag->prevtag = selmon->pertag->curtag; selmon->pertag->curtag = tmptag; + selmon->tagset = tmptag; } selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; @@ -2787,12 +2850,11 @@ sigchld(int unused) { siginfo_t in; /* We should be able to remove this function in favor of a simple - * signal(SIGCHLD, SIG_IGN); + * struct sigaction sa = {.sa_handler = SIG_IGN}; + * sigaction(SIGCHLD, &sa, NULL); * but the Xwayland implementation in wlroots currently prevents us from * setting our own disposition for SIGCHLD. */ - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("can't install SIGCHLD handler:"); /* WNOWAIT leaves the child in a waitable state, in case this is the * XWayland process */ diff --git a/dwl-0.4/pertag.patch b/dwl/pertag.patch index d762efa..d762efa 100644 --- a/dwl-0.4/pertag.patch +++ b/dwl/pertag.patch diff --git a/dwl-0.4/protocols/wlr-layer-shell-unstable-v1.xml b/dwl/protocols/wlr-layer-shell-unstable-v1.xml index d62fd51..d62fd51 100644 --- a/dwl-0.4/protocols/wlr-layer-shell-unstable-v1.xml +++ b/dwl/protocols/wlr-layer-shell-unstable-v1.xml diff --git a/dwl-0.4/util.c b/dwl/util.c index cca7c19..cca7c19 100644 --- a/dwl-0.4/util.c +++ b/dwl/util.c diff --git a/dwl-0.4/util.h b/dwl/util.h index 4c94117..4c94117 100644 --- a/dwl-0.4/util.h +++ b/dwl/util.h |
