mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-27 02:04:16 +00:00
namedscratchpads: rebased and adopted by me
This commit is contained in:
parent
42f83f3d3b
commit
b62bfda94b
@ -2,14 +2,18 @@
|
|||||||
Allows for the creation of multiple scratchpad windows, each assigned to a different keybinding. In simple terms, it enables 'run or raise' functionality
|
Allows for the creation of multiple scratchpad windows, each assigned to a different keybinding. In simple terms, it enables 'run or raise' functionality
|
||||||
|
|
||||||
This patch adds the following functions:
|
This patch adds the following functions:
|
||||||
* `togglescratch`: simply toggles the scratchpad window
|
|
||||||
|
* `togglescratch`: simply toggles the scratchpad window
|
||||||
* `focusortogglescratch`: change the focus to the scratchpad window if it is visible and toggles it if it is already in focus
|
* `focusortogglescratch`: change the focus to the scratchpad window if it is visible and toggles it if it is already in focus
|
||||||
* `focusortogglematchingscratch`: similar to `focusortogglescratch` but also closes all other scratchpad windows
|
* `focusortogglematchingscratch`: similar to `focusortogglescratch` but also closes all other scratchpad windows
|
||||||
|
|
||||||
|
If you don't assign keybindings to any of the above functions and so get a compiler warning about them not being used, just remove them from your dwl branch to stop the warning.
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/namedscratchpads)
|
- [git branch](https://codeberg.org/bencc/dwl/src/branch/namedscratchpads)
|
||||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/namedscratchpads/namedscratchpads.patch)
|
- [2024-07-13](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/namedscratchpads/namedscratchpads.patch)
|
||||||
|
|
||||||
### Authors
|
### Authors
|
||||||
|
- [Ben Collerson](https://codeberg.org/bencc)
|
||||||
- [wochap](https://codeberg.org/wochap)
|
- [wochap](https://codeberg.org/wochap)
|
||||||
- [Louis-Michel Raynauld](https://github.com/loumray)
|
- [Louis-Michel Raynauld](https://github.com/loumray)
|
||||||
|
|||||||
@ -1,35 +1,35 @@
|
|||||||
From 0dc34efe899c9e6dca6eb8770f3dedd2afe5ee83 Mon Sep 17 00:00:00 2001
|
From bd83d56b3a268112b029961ad6ff4232b2d6f00d Mon Sep 17 00:00:00 2001
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
From: Ben Collerson <benc@benc.cc>
|
||||||
Date: Wed, 22 Nov 2023 18:55:15 -0500
|
Date: Thu, 4 Jan 2024 16:35:05 +1000
|
||||||
Subject: [PATCH 1/6] apply main...loumray:namedscratchpads.patch
|
Subject: [PATCH 1/2] namedscratchpads
|
||||||
|
|
||||||
---
|
---
|
||||||
config.def.h | 9 +++++++--
|
config.def.h | 11 ++++++++---
|
||||||
dwl.c | 39 +++++++++++++++++++++++++++++++++++++++
|
dwl.c | 39 +++++++++++++++++++++++++++++++++++++++
|
||||||
2 files changed, 46 insertions(+), 2 deletions(-)
|
2 files changed, 47 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index db0babc..157aee4 100644
|
index 22d2171d..36a691a9 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -20,11 +20,12 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* You can al
|
@@ -22,10 +22,11 @@ static int log_level = WLR_ERROR;
|
||||||
static int log_level = WLR_ERROR;
|
|
||||||
|
|
||||||
|
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
- /* app_id title tags mask isfloating monitor */
|
- /* app_id title tags mask isfloating monitor */
|
||||||
+ /* app_id title tags mask isfloating monitor scratchkey */
|
+ /* app_id title tags mask isfloating monitor scratchkey */
|
||||||
/* examples:
|
/* examples: */
|
||||||
{ "Gimp", NULL, 0, 1, -1 },
|
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||||
*/
|
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
||||||
- { "firefox", NULL, 1 << 8, 0, -1 },
|
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, 0 }, /* Start on currently visible tags floating, not tiled */
|
||||||
+ { "firefox", NULL, 1 << 8, 0, -1, 0 },
|
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, 0 }, /* Start on ONLY tag "9" */
|
||||||
+ { NULL, "scratchpad", 0, 1, -1, 's' },
|
+ { NULL, "scratchpad", 0, 1, -1, 's' },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
@@ -115,11 +116,15 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
@@ -122,11 +123,15 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
||||||
static const char *termcmd[] = { "foot", NULL };
|
static const char *termcmd[] = { "foot", NULL };
|
||||||
static const char *menucmd[] = { "bemenu-run", NULL };
|
static const char *menucmd[] = { "wmenu-run", NULL };
|
||||||
|
|
||||||
+/* named scratchpads - First arg only serves to match against key in rules*/
|
+/* named scratchpads - First arg only serves to match against key in rules*/
|
||||||
+static const char *scratchpadcmd[] = { "s", "alacritty", "-t", "scratchpad", NULL };
|
+static const char *scratchpadcmd[] = { "s", "alacritty", "-t", "scratchpad", NULL };
|
||||||
@ -44,18 +44,18 @@ index db0babc..157aee4 100644
|
|||||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index ef27a1d..81e5db8 100644
|
index dc0437e0..eb0eb775 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -130,6 +130,7 @@ typedef struct {
|
@@ -139,6 +139,7 @@ typedef struct {
|
||||||
|
unsigned int bw;
|
||||||
uint32_t tags;
|
uint32_t tags;
|
||||||
int isfloating, isurgent, isfullscreen;
|
int isfloating, isurgent, isfullscreen;
|
||||||
uint32_t resize; /* configure serial of a pending resize */
|
|
||||||
+ char scratchkey;
|
+ char scratchkey;
|
||||||
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
} Client;
|
} Client;
|
||||||
|
|
||||||
typedef struct {
|
@@ -230,6 +231,7 @@ typedef struct {
|
||||||
@@ -215,6 +216,7 @@ typedef struct {
|
|
||||||
uint32_t tags;
|
uint32_t tags;
|
||||||
int isfloating;
|
int isfloating;
|
||||||
int monitor;
|
int monitor;
|
||||||
@ -63,7 +63,7 @@ index ef27a1d..81e5db8 100644
|
|||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -307,12 +309,14 @@ static void setpsel(struct wl_listener *listener, void *data);
|
@@ -330,12 +332,14 @@ static void setpsel(struct wl_listener *listener, void *data);
|
||||||
static void setsel(struct wl_listener *listener, void *data);
|
static void setsel(struct wl_listener *listener, void *data);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
@ -78,7 +78,7 @@ index ef27a1d..81e5db8 100644
|
|||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
static void unlocksession(struct wl_listener *listener, void *data);
|
||||||
@@ -424,6 +428,7 @@ applyrules(Client *c)
|
@@ -456,6 +460,7 @@ applyrules(Client *c)
|
||||||
Monitor *mon = selmon, *m;
|
Monitor *mon = selmon, *m;
|
||||||
|
|
||||||
c->isfloating = client_is_float_type(c);
|
c->isfloating = client_is_float_type(c);
|
||||||
@ -86,15 +86,15 @@ index ef27a1d..81e5db8 100644
|
|||||||
if (!(appid = client_get_appid(c)))
|
if (!(appid = client_get_appid(c)))
|
||||||
appid = broken;
|
appid = broken;
|
||||||
if (!(title = client_get_title(c)))
|
if (!(title = client_get_title(c)))
|
||||||
@@ -433,6 +438,7 @@ applyrules(Client *c)
|
@@ -465,6 +470,7 @@ applyrules(Client *c)
|
||||||
if ((!r->title || strstr(title, r->title))
|
if ((!r->title || strstr(title, r->title))
|
||||||
&& (!r->id || strstr(appid, r->id))) {
|
&& (!r->id || strstr(appid, r->id))) {
|
||||||
c->isfloating = r->isfloating;
|
c->isfloating = r->isfloating;
|
||||||
+ c->scratchkey = r->scratchkey;
|
+ c->scratchkey = r->scratchkey;
|
||||||
newtags |= r->tags;
|
newtags |= r->tags;
|
||||||
i = 0;
|
i = 0;
|
||||||
wl_list_for_each(m, &mons, link)
|
wl_list_for_each(m, &mons, link) {
|
||||||
@@ -2372,6 +2378,16 @@ spawn(const Arg *arg)
|
@@ -2603,6 +2609,16 @@ spawn(const Arg *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ index ef27a1d..81e5db8 100644
|
|||||||
void
|
void
|
||||||
startdrag(struct wl_listener *listener, void *data)
|
startdrag(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@@ -2454,6 +2470,29 @@ togglefullscreen(const Arg *arg)
|
@@ -2686,6 +2702,29 @@ togglefullscreen(const Arg *arg)
|
||||||
setfullscreen(sel, !sel->isfullscreen);
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,52 +142,104 @@ index ef27a1d..81e5db8 100644
|
|||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
--
|
--
|
||||||
2.42.0
|
2.45.2
|
||||||
|
|
||||||
|
|
||||||
From e750aa243a25ec78e611883b5e72314067326746 Mon Sep 17 00:00:00 2001
|
From 4963c34b4958fba9d53a23a1c9929d554a4e8b3d Mon Sep 17 00:00:00 2001
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
From: Ben Collerson <benc@benc.cc>
|
||||||
Date: Wed, 22 Nov 2023 18:58:57 -0500
|
Date: Sat, 13 Jul 2024 14:50:45 +1000
|
||||||
Subject: [PATCH 2/6] add focusortogglescratch function
|
Subject: [PATCH 2/2] namedscratchpads: focusortoggle functions
|
||||||
|
|
||||||
---
|
---
|
||||||
config.def.h | 1 +
|
config.def.h | 2 ++
|
||||||
dwl.c | 37 +++++++++++++++++++++++++++++++++++++
|
dwl.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
2 files changed, 38 insertions(+)
|
2 files changed, 89 insertions(+)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index 157aee4..0f672d4 100644
|
index 36a691a9..21bb66bb 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -125,6 +125,7 @@ static const Key keys[] = {
|
@@ -132,6 +132,8 @@ static const Key keys[] = {
|
||||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||||
{ MODKEY, XKB_KEY_grave, togglescratch, {.v = scratchpadcmd } },
|
{ MODKEY, XKB_KEY_grave, togglescratch, {.v = scratchpadcmd } },
|
||||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_grave, focusortogglescratch, {.v = scratchpadcmd } },
|
+ // { MODKEY, XKB_KEY_grave, focusortogglescratch, {.v = scratchpadcmd } },
|
||||||
|
+ // { MODKEY, XKB_KEY_grave, focusortogglematchingscratch, {.v = scratchpadcmd } },
|
||||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index 81e5db8..83d771e 100644
|
index eb0eb775..d7c5552f 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -317,6 +317,7 @@ static void tile(Monitor *m);
|
@@ -286,6 +286,8 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
|
||||||
static void togglefloating(const Arg *arg);
|
static Monitor *dirtomon(enum wlr_direction dir);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void focusclient(Client *c, int lift);
|
||||||
static void togglescratch(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
|
+static void focusortogglematchingscratch(const Arg *arg);
|
||||||
+static void focusortogglescratch(const Arg *arg);
|
+static void focusortogglescratch(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void focusstack(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static Client *focustop(Monitor *m);
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||||
@@ -2493,6 +2494,42 @@ togglescratch(const Arg *arg)
|
@@ -1405,6 +1407,91 @@ focusmon(const Arg *arg)
|
||||||
}
|
focusclient(focustop(selmon), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+focusortogglematchingscratch(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Client *c;
|
||||||
|
+ unsigned int found = 0;
|
||||||
|
+ unsigned int hide = 0;
|
||||||
|
+
|
||||||
|
+ wl_list_for_each(c, &clients, link) {
|
||||||
|
+ if (c->scratchkey == 0) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (c->scratchkey == ((char**)arg->v)[0][0]) {
|
||||||
|
+ if (VISIBLEON(c, selmon)) {
|
||||||
|
+ if (found == 1) {
|
||||||
|
+ if (hide == 1) {
|
||||||
|
+ c->tags = 0;
|
||||||
|
+ focusclient(focustop(selmon), 1);
|
||||||
|
+ }
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (focustop(selmon) == c) {
|
||||||
|
+ // hide
|
||||||
|
+ c->tags = 0;
|
||||||
|
+ focusclient(focustop(selmon), 1);
|
||||||
|
+ hide = 1;
|
||||||
|
+ } else {
|
||||||
|
+ // focus
|
||||||
|
+ focusclient(c, 1);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ // show
|
||||||
|
+ c->tags = selmon->tagset[selmon->seltags];
|
||||||
|
+ // focus
|
||||||
|
+ focusclient(c, 1);
|
||||||
|
+ }
|
||||||
|
+ found = 1;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (VISIBLEON(c, selmon)) {
|
||||||
|
+ // hide
|
||||||
|
+ c->tags = 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (found) {
|
||||||
|
+ arrange(selmon);
|
||||||
|
+ } else {
|
||||||
|
+ spawnscratch(arg);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
+void
|
+void
|
||||||
+focusortogglescratch(const Arg *arg)
|
+focusortogglescratch(const Arg *arg)
|
||||||
+{
|
+{
|
||||||
+ Client *c;
|
+ Client *c;
|
||||||
+ Client *cwithfocus;
|
|
||||||
+ unsigned int found = 0;
|
+ unsigned int found = 0;
|
||||||
+
|
+
|
||||||
+ /* search for first window that matches the scratchkey */
|
+ /* search for first window that matches the scratchkey */
|
||||||
@ -199,11 +251,10 @@ index 81e5db8..83d771e 100644
|
|||||||
+
|
+
|
||||||
+ if (found) {
|
+ if (found) {
|
||||||
+ if (VISIBLEON(c, selmon)) {
|
+ if (VISIBLEON(c, selmon)) {
|
||||||
+ cwithfocus = focustop(selmon);
|
+ if (focustop(selmon) == c) {
|
||||||
+ if (cwithfocus == c) {
|
|
||||||
+ // hide
|
+ // hide
|
||||||
+ c->tags = 0;
|
+ c->tags = 0;
|
||||||
+ focusclient(cwithfocus, 1);
|
+ focusclient(focustop(selmon), 1);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ // focus
|
+ // focus
|
||||||
+ focusclient(c, 1);
|
+ focusclient(c, 1);
|
||||||
@ -220,202 +271,8 @@ index 81e5db8..83d771e 100644
|
|||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
focusstack(const Arg *arg)
|
||||||
{
|
{
|
||||||
--
|
--
|
||||||
2.42.0
|
2.45.2
|
||||||
|
|
||||||
|
|
||||||
From 5ee62daed7e4fb60d09ba72793bf872307697203 Mon Sep 17 00:00:00 2001
|
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
|
||||||
Date: Wed, 22 Nov 2023 20:42:20 -0500
|
|
||||||
Subject: [PATCH 3/6] fix focus after hiding
|
|
||||||
|
|
||||||
---
|
|
||||||
dwl.c | 6 ++----
|
|
||||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index 83d771e..6b5d55d 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -2498,7 +2498,6 @@ void
|
|
||||||
focusortogglescratch(const Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
- Client *cwithfocus;
|
|
||||||
unsigned int found = 0;
|
|
||||||
|
|
||||||
/* search for first window that matches the scratchkey */
|
|
||||||
@@ -2510,11 +2509,10 @@ focusortogglescratch(const Arg *arg)
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
if (VISIBLEON(c, selmon)) {
|
|
||||||
- cwithfocus = focustop(selmon);
|
|
||||||
- if (cwithfocus == c) {
|
|
||||||
+ if (focustop(selmon) == c) {
|
|
||||||
// hide
|
|
||||||
c->tags = 0;
|
|
||||||
- focusclient(cwithfocus, 1);
|
|
||||||
+ focusclient(focustop(selmon), 1);
|
|
||||||
} else {
|
|
||||||
// focus
|
|
||||||
focusclient(c, 1);
|
|
||||||
--
|
|
||||||
2.42.0
|
|
||||||
|
|
||||||
|
|
||||||
From 0b3d70706a0aca6d4414d20a3f2ac4928e70d04e Mon Sep 17 00:00:00 2001
|
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
|
||||||
Date: Wed, 6 Mar 2024 14:36:48 -0500
|
|
||||||
Subject: [PATCH 4/6] add focusortogglematchingscratch
|
|
||||||
|
|
||||||
works like focusortoggle but it also hides all others scratchpads
|
|
||||||
---
|
|
||||||
dwl.c | 43 +++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 43 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index 6b5d55d..e179940 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -318,6 +318,7 @@ static void togglefloating(const Arg *arg);
|
|
||||||
static void togglefullscreen(const Arg *arg);
|
|
||||||
static void togglescratch(const Arg *arg);
|
|
||||||
static void focusortogglescratch(const Arg *arg);
|
|
||||||
+static void focusortogglematchingscratch(const Arg *arg);
|
|
||||||
static void toggletag(const Arg *arg);
|
|
||||||
static void toggleview(const Arg *arg);
|
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
|
||||||
@@ -2528,6 +2529,48 @@ focusortogglescratch(const Arg *arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+focusortogglematchingscratch(const Arg *arg)
|
|
||||||
+{
|
|
||||||
+ Client *c;
|
|
||||||
+ unsigned int found = 0;
|
|
||||||
+
|
|
||||||
+ wl_list_for_each(c, &clients, link) {
|
|
||||||
+ if (c->scratchkey == 0) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ if (c->scratchkey == ((char**)arg->v)[0][0]) {
|
|
||||||
+ found = 1;
|
|
||||||
+ if (VISIBLEON(c, selmon)) {
|
|
||||||
+ if (focustop(selmon) == c) {
|
|
||||||
+ // hide
|
|
||||||
+ c->tags = 0;
|
|
||||||
+ focusclient(focustop(selmon), 1);
|
|
||||||
+ } else {
|
|
||||||
+ // focus
|
|
||||||
+ focusclient(c, 1);
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ // show
|
|
||||||
+ c->tags = selmon->tagset[selmon->seltags];
|
|
||||||
+ // focus
|
|
||||||
+ focusclient(c, 1);
|
|
||||||
+ }
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ if (VISIBLEON(c, selmon)) {
|
|
||||||
+ // hide
|
|
||||||
+ c->tags = 0;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (found) {
|
|
||||||
+ arrange(selmon);
|
|
||||||
+ } else {
|
|
||||||
+ spawnscratch(arg);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
toggletag(const Arg *arg)
|
|
||||||
{
|
|
||||||
--
|
|
||||||
2.42.0
|
|
||||||
|
|
||||||
|
|
||||||
From a14d6da36f1a77cd73daf751828224dd407e78f9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
|
||||||
Date: Wed, 6 Mar 2024 15:20:45 -0500
|
|
||||||
Subject: [PATCH 5/6] fix: edge case where there are more than 1 window with
|
|
||||||
the same scratchkey
|
|
||||||
|
|
||||||
---
|
|
||||||
dwl.c | 11 ++++++++++-
|
|
||||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index e179940..4c40f86 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -2534,18 +2534,26 @@ focusortogglematchingscratch(const Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
unsigned int found = 0;
|
|
||||||
+ unsigned int hide = 0;
|
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
|
||||||
if (c->scratchkey == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c->scratchkey == ((char**)arg->v)[0][0]) {
|
|
||||||
- found = 1;
|
|
||||||
if (VISIBLEON(c, selmon)) {
|
|
||||||
+ if (found == 1) {
|
|
||||||
+ if (hide == 1) {
|
|
||||||
+ c->tags = 0;
|
|
||||||
+ focusclient(focustop(selmon), 1);
|
|
||||||
+ }
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
if (focustop(selmon) == c) {
|
|
||||||
// hide
|
|
||||||
c->tags = 0;
|
|
||||||
focusclient(focustop(selmon), 1);
|
|
||||||
+ hide = 1;
|
|
||||||
} else {
|
|
||||||
// focus
|
|
||||||
focusclient(c, 1);
|
|
||||||
@@ -2556,6 +2564,7 @@ focusortogglematchingscratch(const Arg *arg)
|
|
||||||
// focus
|
|
||||||
focusclient(c, 1);
|
|
||||||
}
|
|
||||||
+ found = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (VISIBLEON(c, selmon)) {
|
|
||||||
--
|
|
||||||
2.42.0
|
|
||||||
|
|
||||||
|
|
||||||
From 8d86b275615f4f6242828d2ce4606380ba309c58 Mon Sep 17 00:00:00 2001
|
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
|
||||||
Date: Wed, 6 Mar 2024 15:22:24 -0500
|
|
||||||
Subject: [PATCH 6/6] add examples
|
|
||||||
|
|
||||||
---
|
|
||||||
config.def.h | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 0f672d4..3205165 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -125,7 +125,8 @@ static const Key keys[] = {
|
|
||||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
|
||||||
{ MODKEY, XKB_KEY_grave, togglescratch, {.v = scratchpadcmd } },
|
|
||||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_grave, focusortogglescratch, {.v = scratchpadcmd } },
|
|
||||||
+ // { MODKEY, XKB_KEY_grave, focusortogglescratch, {.v = scratchpadcmd } },
|
|
||||||
+ // { MODKEY, XKB_KEY_grave, focusortogglematchingscratch, {.v = scratchpadcmd } },
|
|
||||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
|
||||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
|
||||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
|
||||||
--
|
|
||||||
2.42.0
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user