Add restore-monitor patch
This commit is contained in:
10
README.org
10
README.org
@@ -9,6 +9,7 @@
|
|||||||
- [[#patches][Patches]]
|
- [[#patches][Patches]]
|
||||||
- [[#attach-top][Attach Top]]
|
- [[#attach-top][Attach Top]]
|
||||||
- [[#auto-start][Auto Start]]
|
- [[#auto-start][Auto Start]]
|
||||||
|
- [[#restore-monitor][Restore Monitor]]
|
||||||
- [[#warp-cursor][Warp Cursor]]
|
- [[#warp-cursor][Warp Cursor]]
|
||||||
- [[#dwl-configuration][dwl Configuration]]
|
- [[#dwl-configuration][dwl Configuration]]
|
||||||
- [[#appearance][Appearance]]
|
- [[#appearance][Appearance]]
|
||||||
@@ -70,6 +71,14 @@ Note: Commands from array are executed using execvp(). So if you need to execute
|
|||||||
#define AUTOSTART_PATCH 1
|
#define AUTOSTART_PATCH 1
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/restore-monitor][Restore Monitor]]
|
||||||
|
|
||||||
|
Moves clients to their old output when it is reattached.
|
||||||
|
|
||||||
|
#+BEGIN_SRC c :tangle patches.def.h
|
||||||
|
#define RESTORE_MONITOR_PATCH 1
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/warpcursor][Warp Cursor]]
|
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/warpcursor][Warp Cursor]]
|
||||||
|
|
||||||
Warp cursor to the centre of newly focused clients.
|
Warp cursor to the centre of newly focused clients.
|
||||||
@@ -82,7 +91,6 @@ This is my version of the orphaned cursorwarp patch except I left out the config
|
|||||||
#define WARPCURSOR_PATCH 1
|
#define WARPCURSOR_PATCH 1
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
||||||
* dwl Configuration
|
* dwl Configuration
|
||||||
|
|
||||||
Taken from https://github.com/djpohly/dwl/issues/466.
|
Taken from https://github.com/djpohly/dwl/issues/466.
|
||||||
|
39
dwl.c
39
dwl.c
@@ -110,6 +110,9 @@ typedef struct {
|
|||||||
unsigned int type; /* XDGShell or X11* */
|
unsigned int type; /* XDGShell or X11* */
|
||||||
struct wlr_box geom; /* layout-relative, includes border */
|
struct wlr_box geom; /* layout-relative, includes border */
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
|
#if RESTORE_MONITOR_PATCH
|
||||||
|
char *output;
|
||||||
|
#endif // RESTORE_MONITOR_PATCH
|
||||||
struct wlr_scene_tree *scene;
|
struct wlr_scene_tree *scene;
|
||||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||||
struct wlr_scene_tree *scene_surface;
|
struct wlr_scene_tree *scene_surface;
|
||||||
@@ -1033,6 +1036,9 @@ createmon(struct wl_listener *listener, void *data)
|
|||||||
size_t i;
|
size_t i;
|
||||||
struct wlr_output_state state;
|
struct wlr_output_state state;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
#if RESTORE_MONITOR_PATCH
|
||||||
|
Client *c;
|
||||||
|
#endif // RESTORE_MONITOR_PATCH
|
||||||
|
|
||||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||||
return;
|
return;
|
||||||
@@ -1102,6 +1108,15 @@ createmon(struct wl_listener *listener, void *data)
|
|||||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||||
else
|
else
|
||||||
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||||
|
|
||||||
|
#if RESTORE_MONITOR_PATCH
|
||||||
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
if (strcmp(wlr_output->name, c->output) == 0) {
|
||||||
|
c->mon = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
#endif // RESTORE_MONITOR_PATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1331,6 +1346,9 @@ destroynotify(struct wl_listener *listener, void *data)
|
|||||||
wl_list_remove(&c->map.link);
|
wl_list_remove(&c->map.link);
|
||||||
wl_list_remove(&c->unmap.link);
|
wl_list_remove(&c->unmap.link);
|
||||||
}
|
}
|
||||||
|
#if RESTORE_MONITOR_PATCH
|
||||||
|
free(c->output);
|
||||||
|
#endif // RESTORE_MONITOR_PATCH
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1841,6 +1859,12 @@ mapnotify(struct wl_listener *listener, void *data)
|
|||||||
} else {
|
} else {
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
}
|
}
|
||||||
|
#if RESTORE_MONITOR_PATCH
|
||||||
|
c->output = strdup(c->mon->wlr_output->name);
|
||||||
|
if (c->output == NULL) {
|
||||||
|
die("oom");
|
||||||
|
}
|
||||||
|
#endif // RESTORE_MONITOR_PATCH
|
||||||
printstatus();
|
printstatus();
|
||||||
|
|
||||||
unset_fullscreen:
|
unset_fullscreen:
|
||||||
@@ -2790,8 +2814,19 @@ void
|
|||||||
tagmon(const Arg *arg)
|
tagmon(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = focustop(selmon);
|
Client *sel = focustop(selmon);
|
||||||
if (sel)
|
#if RESTORE_MONITOR_PATCH
|
||||||
setmon(sel, dirtomon(arg->i), 0);
|
if (!sel)
|
||||||
|
return;
|
||||||
|
setmon(sel, dirtomon(arg->i), 0);
|
||||||
|
free(sel->output);
|
||||||
|
sel->output = strdup(sel->mon->wlr_output->name);
|
||||||
|
if (sel->output == NULL) {
|
||||||
|
die("oom");
|
||||||
|
}
|
||||||
|
#else // RESTORE_MONITOR_PATCH
|
||||||
|
if (sel)
|
||||||
|
setmon(sel, dirtomon(arg->i), 0);
|
||||||
|
#endif // RESTORE_MONITOR_PATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
#define AUTOSTART_PATCH 1
|
#define AUTOSTART_PATCH 1
|
||||||
|
|
||||||
|
#define RESTORE_MONITOR_PATCH 1
|
||||||
|
|
||||||
#define WARPCURSOR_PATCH 1
|
#define WARPCURSOR_PATCH 1
|
||||||
|
82
patches/restore-monitor-20240510.patch
Normal file
82
patches/restore-monitor-20240510.patch
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
From e42ca1c539437d3098d80983cfe2ad6f938d7a08 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Eldar Yusupov <eyusupov@gmail.com>
|
||||||
|
Date: Sun, 17 Mar 2024 19:12:29 +0300
|
||||||
|
Subject: [PATCH] Restore correct montior for client when it is reattached
|
||||||
|
|
||||||
|
---
|
||||||
|
dwl.c | 24 ++++++++++++++++++++++--
|
||||||
|
1 file changed, 22 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index bf763df..d8d8139 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -107,6 +107,7 @@ typedef struct {
|
||||||
|
unsigned int type; /* XDGShell or X11* */
|
||||||
|
struct wlr_box geom; /* layout-relative, includes border */
|
||||||
|
Monitor *mon;
|
||||||
|
+ char *output;
|
||||||
|
struct wlr_scene_tree *scene;
|
||||||
|
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||||
|
struct wlr_scene_tree *scene_surface;
|
||||||
|
@@ -869,6 +870,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||||
|
size_t i;
|
||||||
|
struct wlr_output_state state;
|
||||||
|
Monitor *m;
|
||||||
|
+ Client *c;
|
||||||
|
|
||||||
|
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||||
|
return;
|
||||||
|
@@ -938,6 +940,13 @@ createmon(struct wl_listener *listener, void *data)
|
||||||
|
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||||
|
else
|
||||||
|
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||||
|
+
|
||||||
|
+ wl_list_for_each(c, &clients, link) {
|
||||||
|
+ if (strcmp(wlr_output->name, c->output) == 0) {
|
||||||
|
+ c->mon = m;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ updatemons(NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -1186,6 +1195,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||||
|
wl_list_remove(&c->map.link);
|
||||||
|
wl_list_remove(&c->unmap.link);
|
||||||
|
}
|
||||||
|
+ free(c->output);
|
||||||
|
free(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1618,6 +1628,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||||
|
} else {
|
||||||
|
applyrules(c);
|
||||||
|
}
|
||||||
|
+ c->output = strdup(c->mon->wlr_output->name);
|
||||||
|
+ if (c->output == NULL) {
|
||||||
|
+ die("oom");
|
||||||
|
+ }
|
||||||
|
printstatus();
|
||||||
|
|
||||||
|
unset_fullscreen:
|
||||||
|
@@ -2565,8 +2579,14 @@ void
|
||||||
|
tagmon(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *sel = focustop(selmon);
|
||||||
|
- if (sel)
|
||||||
|
- setmon(sel, dirtomon(arg->i), 0);
|
||||||
|
+ if (!sel)
|
||||||
|
+ return;
|
||||||
|
+ setmon(sel, dirtomon(arg->i), 0);
|
||||||
|
+ free(sel->output);
|
||||||
|
+ sel->output = strdup(sel->mon->wlr_output->name);
|
||||||
|
+ if (sel->output == NULL) {
|
||||||
|
+ die("oom");
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
Reference in New Issue
Block a user