mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bb6fcd056c |
12
client.h
12
client.h
@@ -131,6 +131,18 @@ client_get_appid(Client *c)
|
|||||||
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken";
|
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
client_get_pid(Client *c)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (client_is_x11(c))
|
||||||
|
return c->surface.xwayland->pid;
|
||||||
|
#endif
|
||||||
|
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
client_get_clip(Client *c, struct wlr_box *clip)
|
client_get_clip(Client *c, struct wlr_box *clip)
|
||||||
{
|
{
|
||||||
|
|||||||
13
config.def.h
13
config.def.h
@@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff);
|
|||||||
static const float urgentcolor[] = COLOR(0xff0000ff);
|
static const float urgentcolor[] = COLOR(0xff0000ff);
|
||||||
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
|
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
|
||||||
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
|
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
|
||||||
|
static int enableautoswallow = 1; /* enables autoswallowing newly spawned clients */
|
||||||
|
static float swallowborder = 1.0f; /* add this multiplied by borderpx to border when a client is swallowed */
|
||||||
|
|
||||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||||
#define TAGCOUNT (9)
|
#define TAGCOUNT (9)
|
||||||
@@ -22,10 +24,11 @@ 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) */
|
/* 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 isterm noswallow monitor */
|
||||||
/* examples: */
|
/* examples: */
|
||||||
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
{ "foot", NULL, 0, 0, 1, 1, -1 },
|
||||||
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
{ "Gimp_EXAMPLE", NULL, 0, 1, 0, 0, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||||
|
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, 0, -1 }, /* Start on ONLY tag "9" */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
@@ -106,8 +109,6 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
|
|||||||
*/
|
*/
|
||||||
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||||
|
|
||||||
static const int cursor_timeout = 5;
|
|
||||||
|
|
||||||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
||||||
#define MODKEY WLR_MODIFIER_ALT
|
#define MODKEY WLR_MODIFIER_ALT
|
||||||
|
|
||||||
@@ -144,6 +145,8 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
|
{ MODKEY, XKB_KEY_a, toggleswallow, {0} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_A, toggleautoswallow,{0} },
|
||||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
|||||||
213
dwl.c
213
dwl.c
@@ -74,7 +74,7 @@
|
|||||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
#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[(M)->seltags]) && !(C)->swallowedby)
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define END(A) ((A) + LENGTH(A))
|
#define END(A) ((A) + LENGTH(A))
|
||||||
#define TAGMASK ((1u << TAGCOUNT) - 1)
|
#define TAGMASK ((1u << TAGCOUNT) - 1)
|
||||||
@@ -101,7 +101,8 @@ typedef struct {
|
|||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
typedef struct Monitor Monitor;
|
typedef struct Monitor Monitor;
|
||||||
typedef struct {
|
typedef struct Client Client;
|
||||||
|
struct Client {
|
||||||
/* Must keep this field first */
|
/* Must keep this field first */
|
||||||
unsigned int type; /* XDGShell or X11* */
|
unsigned int type; /* XDGShell or X11* */
|
||||||
|
|
||||||
@@ -138,8 +139,12 @@ typedef struct {
|
|||||||
unsigned int bw;
|
unsigned int bw;
|
||||||
uint32_t tags;
|
uint32_t tags;
|
||||||
int isfloating, isurgent, isfullscreen;
|
int isfloating, isurgent, isfullscreen;
|
||||||
|
int isterm, noswallow;
|
||||||
uint32_t resize; /* configure serial of a pending resize */
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
} Client;
|
pid_t pid;
|
||||||
|
Client *swallowing; /* client being hidden */
|
||||||
|
Client *swallowedby;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t mod;
|
uint32_t mod;
|
||||||
@@ -227,6 +232,8 @@ typedef struct {
|
|||||||
const char *title;
|
const char *title;
|
||||||
uint32_t tags;
|
uint32_t tags;
|
||||||
int isfloating;
|
int isfloating;
|
||||||
|
int isterm;
|
||||||
|
int noswallow;
|
||||||
int monitor;
|
int monitor;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
@@ -288,8 +295,6 @@ static void focusstack(const Arg *arg);
|
|||||||
static Client *focustop(Monitor *m);
|
static Client *focustop(Monitor *m);
|
||||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||||
static void gpureset(struct wl_listener *listener, void *data);
|
static void gpureset(struct wl_listener *listener, void *data);
|
||||||
static void handlecursoractivity(void);
|
|
||||||
static int hidecursor(void *data);
|
|
||||||
static void handlesig(int signo);
|
static void handlesig(int signo);
|
||||||
static void incnmaster(const Arg *arg);
|
static void incnmaster(const Arg *arg);
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
static void inputdevice(struct wl_listener *listener, void *data);
|
||||||
@@ -310,6 +315,7 @@ static void moveresize(const Arg *arg);
|
|||||||
static void outputmgrapply(struct wl_listener *listener, void *data);
|
static void outputmgrapply(struct wl_listener *listener, void *data);
|
||||||
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
|
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
|
||||||
static void outputmgrtest(struct wl_listener *listener, void *data);
|
static void outputmgrtest(struct wl_listener *listener, void *data);
|
||||||
|
static pid_t parentpid(pid_t pid);
|
||||||
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
||||||
double sx, double sy, uint32_t time);
|
double sx, double sy, uint32_t time);
|
||||||
static void printstatus(void);
|
static void printstatus(void);
|
||||||
@@ -333,11 +339,15 @@ 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);
|
||||||
static void startdrag(struct wl_listener *listener, void *data);
|
static void startdrag(struct wl_listener *listener, void *data);
|
||||||
|
static void swallow(Client *c, Client *toswallow);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
|
static Client *termforwin(Client *c);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void togglefullscreen(const Arg *arg);
|
||||||
|
static void toggleswallow(const Arg *arg);
|
||||||
|
static void toggleautoswallow(const Arg *arg);
|
||||||
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);
|
||||||
@@ -391,14 +401,6 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
|
|||||||
|
|
||||||
static struct wlr_cursor *cursor;
|
static struct wlr_cursor *cursor;
|
||||||
static struct wlr_xcursor_manager *cursor_mgr;
|
static struct wlr_xcursor_manager *cursor_mgr;
|
||||||
static struct wl_event_source *hide_source;
|
|
||||||
static bool cursor_hidden = false;
|
|
||||||
static struct {
|
|
||||||
enum wp_cursor_shape_device_v1_shape shape;
|
|
||||||
struct wlr_surface *surface;
|
|
||||||
int hotspot_x;
|
|
||||||
int hotspot_y;
|
|
||||||
} last_cursor;
|
|
||||||
|
|
||||||
static struct wlr_scene_rect *root_bg;
|
static struct wlr_scene_rect *root_bg;
|
||||||
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
||||||
@@ -497,11 +499,15 @@ applyrules(Client *c)
|
|||||||
appid = client_get_appid(c);
|
appid = client_get_appid(c);
|
||||||
title = client_get_title(c);
|
title = client_get_title(c);
|
||||||
|
|
||||||
|
c->pid = client_get_pid(c);
|
||||||
|
|
||||||
for (r = rules; r < END(rules); r++) {
|
for (r = rules; r < END(rules); r++) {
|
||||||
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;
|
||||||
newtags |= r->tags;
|
newtags |= r->tags;
|
||||||
|
c->isterm = r->isterm;
|
||||||
|
c->noswallow = r->noswallow;
|
||||||
i = 0;
|
i = 0;
|
||||||
wl_list_for_each(m, &mons, link) {
|
wl_list_for_each(m, &mons, link) {
|
||||||
if (r->monitor == i++)
|
if (r->monitor == i++)
|
||||||
@@ -509,6 +515,12 @@ applyrules(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (enableautoswallow && !c->noswallow && !c->isfloating &&
|
||||||
|
!c->surface.xdg->initial_commit) {
|
||||||
|
Client *p = termforwin(c);
|
||||||
|
if (p)
|
||||||
|
swallow(c, p);
|
||||||
|
}
|
||||||
setmon(c, mon, newtags);
|
setmon(c, mon, newtags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,7 +631,6 @@ axisnotify(struct wl_listener *listener, void *data)
|
|||||||
* for example when you move the scroll wheel. */
|
* for example when you move the scroll wheel. */
|
||||||
struct wlr_pointer_axis_event *event = data;
|
struct wlr_pointer_axis_event *event = data;
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
handlecursoractivity();
|
|
||||||
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
|
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
|
||||||
* checking the event's orientation and the delta of the event */
|
* checking the event's orientation and the delta of the event */
|
||||||
/* Notify the client with pointer focus of the axis event. */
|
/* Notify the client with pointer focus of the axis event. */
|
||||||
@@ -638,7 +649,6 @@ buttonpress(struct wl_listener *listener, void *data)
|
|||||||
const Button *b;
|
const Button *b;
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
handlecursoractivity();
|
|
||||||
|
|
||||||
switch (event->state) {
|
switch (event->state) {
|
||||||
case WL_POINTER_BUTTON_STATE_PRESSED:
|
case WL_POINTER_BUTTON_STATE_PRESSED:
|
||||||
@@ -1575,32 +1585,6 @@ handlesig(int signo)
|
|||||||
quit(NULL);
|
quit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
handlecursoractivity(void)
|
|
||||||
{
|
|
||||||
wl_event_source_timer_update(hide_source, cursor_timeout * 1000);
|
|
||||||
|
|
||||||
if (!cursor_hidden)
|
|
||||||
return;
|
|
||||||
|
|
||||||
cursor_hidden = false;
|
|
||||||
|
|
||||||
if (last_cursor.shape)
|
|
||||||
wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
|
||||||
wlr_cursor_shape_v1_name(last_cursor.shape));
|
|
||||||
else
|
|
||||||
wlr_cursor_set_surface(cursor, last_cursor.surface,
|
|
||||||
last_cursor.hotspot_x, last_cursor.hotspot_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
hidecursor(void *data)
|
|
||||||
{
|
|
||||||
wlr_cursor_unset_image(cursor);
|
|
||||||
cursor_hidden = true;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -1942,7 +1926,6 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
|||||||
|
|
||||||
wlr_cursor_move(cursor, device, dx, dy);
|
wlr_cursor_move(cursor, device, dx, dy);
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
handlecursoractivity();
|
|
||||||
|
|
||||||
/* Update selmon (even while dragging a window) */
|
/* Update selmon (even while dragging a window) */
|
||||||
if (sloppyfocus)
|
if (sloppyfocus)
|
||||||
@@ -1967,7 +1950,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
|||||||
/* If there's no client surface under the cursor, set the cursor image to a
|
/* If there's no client surface under the cursor, set the cursor image to a
|
||||||
* default. This is what makes the cursor image appear when you move it
|
* default. This is what makes the cursor image appear when you move it
|
||||||
* off of a client or over its border. */
|
* off of a client or over its border. */
|
||||||
if (!surface && !seat->drag && !cursor_hidden)
|
if (!surface && !seat->drag)
|
||||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||||
|
|
||||||
pointerfocus(c, surface, sx, sy, time);
|
pointerfocus(c, surface, sx, sy, time);
|
||||||
@@ -2093,6 +2076,20 @@ outputmgrtest(struct wl_listener *listener, void *data)
|
|||||||
outputmgrapplyortest(config, 1);
|
outputmgrapplyortest(config, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
parentpid(pid_t pid)
|
||||||
|
{
|
||||||
|
unsigned int v = 0;
|
||||||
|
FILE *f;
|
||||||
|
char buf[256];
|
||||||
|
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)pid);
|
||||||
|
if (!(f = fopen(buf, "r")))
|
||||||
|
return 0;
|
||||||
|
fscanf(f, "%*u %*s %*c %u", &v);
|
||||||
|
fclose(f);
|
||||||
|
return (pid_t)v;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
||||||
uint32_t time)
|
uint32_t time)
|
||||||
@@ -2322,7 +2319,6 @@ run(char *startup_cmd)
|
|||||||
* monitor when displayed here */
|
* monitor when displayed here */
|
||||||
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
|
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
|
||||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||||
handlecursoractivity();
|
|
||||||
|
|
||||||
/* Run the Wayland event loop. This does not return until you exit the
|
/* Run the Wayland event loop. This does not return until you exit the
|
||||||
* compositor. Starting the backend rigged up all of the necessary event
|
* compositor. Starting the backend rigged up all of the necessary event
|
||||||
@@ -2346,17 +2342,10 @@ setcursor(struct wl_listener *listener, void *data)
|
|||||||
* use the provided surface as the cursor image. It will set the
|
* use the provided surface as the cursor image. It will set the
|
||||||
* hardware cursor on the output that it's currently on and continue to
|
* hardware cursor on the output that it's currently on and continue to
|
||||||
* do so as the cursor moves between outputs. */
|
* do so as the cursor moves between outputs. */
|
||||||
if (event->seat_client == seat->pointer_state.focused_client) {
|
if (event->seat_client == seat->pointer_state.focused_client)
|
||||||
last_cursor.shape = 0;
|
|
||||||
last_cursor.surface = event->surface;
|
|
||||||
last_cursor.hotspot_x = event->hotspot_x;
|
|
||||||
last_cursor.hotspot_y = event->hotspot_y;
|
|
||||||
|
|
||||||
if (!cursor_hidden)
|
|
||||||
wlr_cursor_set_surface(cursor, event->surface,
|
wlr_cursor_set_surface(cursor, event->surface,
|
||||||
event->hotspot_x, event->hotspot_y);
|
event->hotspot_x, event->hotspot_y);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setcursorshape(struct wl_listener *listener, void *data)
|
setcursorshape(struct wl_listener *listener, void *data)
|
||||||
@@ -2367,15 +2356,10 @@ setcursorshape(struct wl_listener *listener, void *data)
|
|||||||
/* This can be sent by any client, so we check to make sure this one is
|
/* This can be sent by any client, so we check to make sure this one is
|
||||||
* actually has pointer focus first. If so, we can tell the cursor to
|
* actually has pointer focus first. If so, we can tell the cursor to
|
||||||
* use the provided cursor shape. */
|
* use the provided cursor shape. */
|
||||||
if (event->seat_client == seat->pointer_state.focused_client) {
|
if (event->seat_client == seat->pointer_state.focused_client)
|
||||||
last_cursor.shape = event->shape;
|
|
||||||
last_cursor.surface = NULL;
|
|
||||||
|
|
||||||
if (!cursor_hidden)
|
|
||||||
wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
||||||
wlr_cursor_shape_v1_name(event->shape));
|
wlr_cursor_shape_v1_name(event->shape));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setfloating(Client *c, int floating)
|
setfloating(Client *c, int floating)
|
||||||
@@ -2398,7 +2382,7 @@ setfullscreen(Client *c, int fullscreen)
|
|||||||
c->isfullscreen = fullscreen;
|
c->isfullscreen = fullscreen;
|
||||||
if (!c->mon || !client_surface(c)->mapped)
|
if (!c->mon || !client_surface(c)->mapped)
|
||||||
return;
|
return;
|
||||||
c->bw = fullscreen ? 0 : borderpx;
|
c->bw = fullscreen ? 0 : BORDERPX(c);
|
||||||
client_set_fullscreen(c, fullscreen);
|
client_set_fullscreen(c, fullscreen);
|
||||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
|
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
|
||||||
? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
|
? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
|
||||||
@@ -2465,6 +2449,9 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
|||||||
setfloating(c, c->isfloating);
|
setfloating(c, c->isfloating);
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
|
|
||||||
|
if (c->swallowing)
|
||||||
|
setmon(c->swallowing, m, newtags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2665,9 +2652,6 @@ setup(void)
|
|||||||
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
|
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
|
||||||
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
|
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
|
||||||
|
|
||||||
hide_source = wl_event_loop_add_timer(wl_display_get_event_loop(dpy),
|
|
||||||
hidecursor, cursor);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configures a seat, which is a single "seat" at which a user sits and
|
* Configures a seat, which is a single "seat" at which a user sits and
|
||||||
* operates the computer. This conceptually includes up to one keyboard,
|
* operates the computer. This conceptually includes up to one keyboard,
|
||||||
@@ -2738,6 +2722,44 @@ startdrag(struct wl_listener *listener, void *data)
|
|||||||
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
|
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
swallow(Client *c, Client *toswallow)
|
||||||
|
{
|
||||||
|
/* Do not allow a client to swallow itself */
|
||||||
|
if (c == toswallow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Swallow */
|
||||||
|
if (toswallow && !c->swallowing) {
|
||||||
|
c->swallowing = toswallow;
|
||||||
|
toswallow->swallowedby = c;
|
||||||
|
toswallow->mon = c->mon;
|
||||||
|
toswallow->mon = c->mon;
|
||||||
|
wl_list_remove(&c->link);
|
||||||
|
wl_list_insert(&c->swallowing->link, &c->link);
|
||||||
|
wl_list_remove(&c->flink);
|
||||||
|
wl_list_insert(&c->swallowing->flink, &c->flink);
|
||||||
|
c->bw = BORDERPX(c);
|
||||||
|
c->tags = toswallow->tags;
|
||||||
|
c->isfloating = toswallow->isfloating;
|
||||||
|
c->geom = toswallow->geom;
|
||||||
|
setfullscreen(toswallow, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unswallow */
|
||||||
|
else if (c->swallowing) {
|
||||||
|
wl_list_remove(&c->swallowing->link);
|
||||||
|
wl_list_insert(&c->link, &c->swallowing->link);
|
||||||
|
wl_list_remove(&c->swallowing->flink);
|
||||||
|
wl_list_insert(&c->flink, &c->swallowing->flink);
|
||||||
|
c->swallowing->tags = c->tags;
|
||||||
|
c->swallowing->swallowedby = NULL;
|
||||||
|
c->swallowing = NULL;
|
||||||
|
c->bw = BORDERPX(c);
|
||||||
|
setfullscreen(c, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tag(const Arg *arg)
|
tag(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -2759,6 +2781,40 @@ tagmon(const Arg *arg)
|
|||||||
setmon(sel, dirtomon(arg->i), 0);
|
setmon(sel, dirtomon(arg->i), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Client *
|
||||||
|
termforwin(Client *c)
|
||||||
|
{
|
||||||
|
Client *p;
|
||||||
|
pid_t pid;
|
||||||
|
pid_t pids[32];
|
||||||
|
size_t i, pids_len;
|
||||||
|
|
||||||
|
if (!c->pid || c->isterm)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Get all parent pids */
|
||||||
|
pids_len = 0;
|
||||||
|
pid = c->pid;
|
||||||
|
while (pids_len < LENGTH(pids)) {
|
||||||
|
pid = parentpid(pid);
|
||||||
|
if (!pid)
|
||||||
|
break;
|
||||||
|
pids[pids_len++] = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find closest parent */
|
||||||
|
for (i = 0; i < pids_len; i++) {
|
||||||
|
wl_list_for_each(p, &clients, link) {
|
||||||
|
if (!p->pid || !p->isterm || p->swallowedby)
|
||||||
|
continue;
|
||||||
|
if (pids[i] == p->pid)
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tile(Monitor *m)
|
tile(Monitor *m)
|
||||||
{
|
{
|
||||||
@@ -2810,6 +2866,32 @@ togglefullscreen(const Arg *arg)
|
|||||||
setfullscreen(sel, !sel->isfullscreen);
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
toggleswallow(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c, *sel = focustop(selmon);
|
||||||
|
if (!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sel->swallowing) {
|
||||||
|
swallow(sel, NULL);
|
||||||
|
} else {
|
||||||
|
wl_list_for_each(c, &sel->flink, flink) {
|
||||||
|
if (&c->flink == &fstack)
|
||||||
|
continue; /* wrap past the sentinel node */
|
||||||
|
if (VISIBLEON(c, selmon))
|
||||||
|
break; /* found it */
|
||||||
|
}
|
||||||
|
swallow(sel, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
toggleautoswallow(const Arg *arg)
|
||||||
|
{
|
||||||
|
enableautoswallow = !enableautoswallow;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -2870,6 +2952,12 @@ unmapnotify(struct wl_listener *listener, void *data)
|
|||||||
grabc = NULL;
|
grabc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->swallowing) {
|
||||||
|
swallow(c, NULL);
|
||||||
|
} else if (c->swallowedby) {
|
||||||
|
swallow(c->swallowedby, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (client_is_unmanaged(c)) {
|
if (client_is_unmanaged(c)) {
|
||||||
if (c == exclusive_focus) {
|
if (c == exclusive_focus) {
|
||||||
exclusive_focus = NULL;
|
exclusive_focus = NULL;
|
||||||
@@ -3052,7 +3140,6 @@ virtualpointer(struct wl_listener *listener, void *data)
|
|||||||
wlr_cursor_attach_input_device(cursor, device);
|
wlr_cursor_attach_input_device(cursor, device);
|
||||||
if (event->suggested_output)
|
if (event->suggested_output)
|
||||||
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
|
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
|
||||||
handlecursoractivity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor *
|
Monitor *
|
||||||
|
|||||||
351
swallow.patch
Normal file
351
swallow.patch
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
From a220e1ed4b04a66c837dfc8e3363d3e696cbf541 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
||||||
|
Date: Wed, 5 Feb 2025 02:34:39 +0100
|
||||||
|
Subject: [PATCH] Swallow: hide the terminal when it spawns a client
|
||||||
|
|
||||||
|
---
|
||||||
|
client.h | 12 ++++
|
||||||
|
config.def.h | 11 +++-
|
||||||
|
dwl.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
3 files changed, 168 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/client.h b/client.h
|
||||||
|
index 42f225f..bc9cad2 100644
|
||||||
|
--- a/client.h
|
||||||
|
+++ b/client.h
|
||||||
|
@@ -131,6 +131,18 @@ client_get_appid(Client *c)
|
||||||
|
return c->surface.xdg->toplevel->app_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static inline int
|
||||||
|
+client_get_pid(Client *c)
|
||||||
|
+{
|
||||||
|
+ pid_t pid;
|
||||||
|
+#ifdef XWAYLAND
|
||||||
|
+ if (client_is_x11(c))
|
||||||
|
+ return c->surface.xwayland->pid;
|
||||||
|
+#endif
|
||||||
|
+ wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||||
|
+ return pid;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static inline void
|
||||||
|
client_get_clip(Client *c, struct wlr_box *clip)
|
||||||
|
{
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 22d2171..42342f1 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff);
|
||||||
|
static const float urgentcolor[] = COLOR(0xff0000ff);
|
||||||
|
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
|
||||||
|
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
|
||||||
|
+static int enableautoswallow = 1; /* enables autoswallowing newly spawned clients */
|
||||||
|
+static float swallowborder = 1.0f; /* add this multiplied by borderpx to border when a client is swallowed */
|
||||||
|
|
||||||
|
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||||
|
#define TAGCOUNT (9)
|
||||||
|
@@ -22,10 +24,11 @@ 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[] = {
|
||||||
|
- /* app_id title tags mask isfloating monitor */
|
||||||
|
+ /* app_id title tags mask isfloating isterm noswallow monitor */
|
||||||
|
/* examples: */
|
||||||
|
- { "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" */
|
||||||
|
+ { "foot", NULL, 0, 0, 1, 1, -1 },
|
||||||
|
+ { "Gimp_EXAMPLE", NULL, 0, 1, 0, 0, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||||
|
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, 0, -1 }, /* Start on ONLY tag "9" */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
@@ -142,6 +145,8 @@ static const Key keys[] = {
|
||||||
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
|
+ { MODKEY, XKB_KEY_a, toggleswallow, {0} },
|
||||||
|
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_A, toggleautoswallow,{0} },
|
||||||
|
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index def2562..71d500a 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -73,12 +73,13 @@
|
||||||
|
#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[(M)->seltags]) && !(C)->swallowedby)
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define END(A) ((A) + LENGTH(A))
|
||||||
|
#define TAGMASK ((1u << TAGCOUNT) - 1)
|
||||||
|
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
|
||||||
|
#define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
|
||||||
|
+#define BORDERPX(C) (borderpx + ((C)->swallowing ? (int)ceilf(swallowborder * (C)->swallowing->bw) : 0))
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||||
|
@@ -104,7 +105,8 @@ typedef struct {
|
||||||
|
} Button;
|
||||||
|
|
||||||
|
typedef struct Monitor Monitor;
|
||||||
|
-typedef struct {
|
||||||
|
+typedef struct Client Client;
|
||||||
|
+struct Client {
|
||||||
|
/* Must keep these three elements in this order */
|
||||||
|
unsigned int type; /* XDGShell or X11* */
|
||||||
|
struct wlr_box geom; /* layout-relative, includes border */
|
||||||
|
@@ -140,8 +142,12 @@ typedef struct {
|
||||||
|
unsigned int bw;
|
||||||
|
uint32_t tags;
|
||||||
|
int isfloating, isurgent, isfullscreen;
|
||||||
|
+ int isterm, noswallow;
|
||||||
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
|
-} Client;
|
||||||
|
+ pid_t pid;
|
||||||
|
+ Client *swallowing; /* client being hidden */
|
||||||
|
+ Client *swallowedby;
|
||||||
|
+};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t mod;
|
||||||
|
@@ -230,6 +236,8 @@ typedef struct {
|
||||||
|
const char *title;
|
||||||
|
uint32_t tags;
|
||||||
|
int isfloating;
|
||||||
|
+ int isterm;
|
||||||
|
+ int noswallow;
|
||||||
|
int monitor;
|
||||||
|
} Rule;
|
||||||
|
|
||||||
|
@@ -311,6 +319,7 @@ static void moveresize(const Arg *arg);
|
||||||
|
static void outputmgrapply(struct wl_listener *listener, void *data);
|
||||||
|
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
|
||||||
|
static void outputmgrtest(struct wl_listener *listener, void *data);
|
||||||
|
+static pid_t parentpid(pid_t pid);
|
||||||
|
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
||||||
|
double sx, double sy, uint32_t time);
|
||||||
|
static void printstatus(void);
|
||||||
|
@@ -335,11 +344,15 @@ static void setsel(struct wl_listener *listener, void *data);
|
||||||
|
static void setup(void);
|
||||||
|
static void spawn(const Arg *arg);
|
||||||
|
static void startdrag(struct wl_listener *listener, void *data);
|
||||||
|
+static void swallow(Client *c, Client *toswallow);
|
||||||
|
static void tag(const Arg *arg);
|
||||||
|
static void tagmon(const Arg *arg);
|
||||||
|
+static Client *termforwin(Client *c);
|
||||||
|
static void tile(Monitor *m);
|
||||||
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void togglefullscreen(const Arg *arg);
|
||||||
|
+static void toggleswallow(const Arg *arg);
|
||||||
|
+static void toggleautoswallow(const Arg *arg);
|
||||||
|
static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
static void unlocksession(struct wl_listener *listener, void *data);
|
||||||
|
@@ -466,11 +479,15 @@ applyrules(Client *c)
|
||||||
|
if (!(title = client_get_title(c)))
|
||||||
|
title = broken;
|
||||||
|
|
||||||
|
+ c->pid = client_get_pid(c);
|
||||||
|
+
|
||||||
|
for (r = rules; r < END(rules); r++) {
|
||||||
|
if ((!r->title || strstr(title, r->title))
|
||||||
|
&& (!r->id || strstr(appid, r->id))) {
|
||||||
|
c->isfloating = r->isfloating;
|
||||||
|
newtags |= r->tags;
|
||||||
|
+ c->isterm = r->isterm;
|
||||||
|
+ c->noswallow = r->noswallow;
|
||||||
|
i = 0;
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (r->monitor == i++)
|
||||||
|
@@ -478,6 +495,12 @@ applyrules(Client *c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ if (enableautoswallow && !c->noswallow && !c->isfloating &&
|
||||||
|
+ !c->surface.xdg->initial_commit) {
|
||||||
|
+ Client *p = termforwin(c);
|
||||||
|
+ if (p)
|
||||||
|
+ swallow(c, p);
|
||||||
|
+ }
|
||||||
|
setmon(c, mon, newtags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2006,6 +2029,20 @@ outputmgrtest(struct wl_listener *listener, void *data)
|
||||||
|
outputmgrapplyortest(config, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+pid_t
|
||||||
|
+parentpid(pid_t pid)
|
||||||
|
+{
|
||||||
|
+ unsigned int v = 0;
|
||||||
|
+ FILE *f;
|
||||||
|
+ char buf[256];
|
||||||
|
+ snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)pid);
|
||||||
|
+ if (!(f = fopen(buf, "r")))
|
||||||
|
+ return 0;
|
||||||
|
+ fscanf(f, "%*u %*s %*c %u", &v);
|
||||||
|
+ fclose(f);
|
||||||
|
+ return (pid_t)v;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
||||||
|
uint32_t time)
|
||||||
|
@@ -2326,7 +2363,7 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
|
c->isfullscreen = fullscreen;
|
||||||
|
if (!c->mon || !client_surface(c)->mapped)
|
||||||
|
return;
|
||||||
|
- c->bw = fullscreen ? 0 : borderpx;
|
||||||
|
+ c->bw = fullscreen ? 0 : BORDERPX(c);
|
||||||
|
client_set_fullscreen(c, fullscreen);
|
||||||
|
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
|
||||||
|
? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
|
||||||
|
@@ -2404,6 +2441,9 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||||
|
setfloating(c, c->isfloating);
|
||||||
|
}
|
||||||
|
focusclient(focustop(selmon), 1);
|
||||||
|
+
|
||||||
|
+ if (c->swallowing)
|
||||||
|
+ setmon(c->swallowing, m, newtags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -2669,6 +2709,44 @@ startdrag(struct wl_listener *listener, void *data)
|
||||||
|
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+swallow(Client *c, Client *toswallow)
|
||||||
|
+{
|
||||||
|
+ /* Do not allow a client to swallow itself */
|
||||||
|
+ if (c == toswallow)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ /* Swallow */
|
||||||
|
+ if (toswallow && !c->swallowing) {
|
||||||
|
+ c->swallowing = toswallow;
|
||||||
|
+ toswallow->swallowedby = c;
|
||||||
|
+ toswallow->mon = c->mon;
|
||||||
|
+ toswallow->mon = c->mon;
|
||||||
|
+ wl_list_remove(&c->link);
|
||||||
|
+ wl_list_insert(&c->swallowing->link, &c->link);
|
||||||
|
+ wl_list_remove(&c->flink);
|
||||||
|
+ wl_list_insert(&c->swallowing->flink, &c->flink);
|
||||||
|
+ c->bw = BORDERPX(c);
|
||||||
|
+ c->tags = toswallow->tags;
|
||||||
|
+ c->isfloating = toswallow->isfloating;
|
||||||
|
+ c->geom = toswallow->geom;
|
||||||
|
+ setfullscreen(toswallow, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Unswallow */
|
||||||
|
+ else if (c->swallowing) {
|
||||||
|
+ wl_list_remove(&c->swallowing->link);
|
||||||
|
+ wl_list_insert(&c->link, &c->swallowing->link);
|
||||||
|
+ wl_list_remove(&c->swallowing->flink);
|
||||||
|
+ wl_list_insert(&c->flink, &c->swallowing->flink);
|
||||||
|
+ c->swallowing->tags = c->tags;
|
||||||
|
+ c->swallowing->swallowedby = NULL;
|
||||||
|
+ c->swallowing = NULL;
|
||||||
|
+ c->bw = BORDERPX(c);
|
||||||
|
+ setfullscreen(c, 0);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
tag(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -2690,6 +2768,40 @@ tagmon(const Arg *arg)
|
||||||
|
setmon(sel, dirtomon(arg->i), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+Client *
|
||||||
|
+termforwin(Client *c)
|
||||||
|
+{
|
||||||
|
+ Client *p;
|
||||||
|
+ pid_t pid;
|
||||||
|
+ pid_t pids[32];
|
||||||
|
+ size_t i, pids_len;
|
||||||
|
+
|
||||||
|
+ if (!c->pid || c->isterm)
|
||||||
|
+ return NULL;
|
||||||
|
+
|
||||||
|
+ /* Get all parent pids */
|
||||||
|
+ pids_len = 0;
|
||||||
|
+ pid = c->pid;
|
||||||
|
+ while (pids_len < LENGTH(pids)) {
|
||||||
|
+ pid = parentpid(pid);
|
||||||
|
+ if (!pid)
|
||||||
|
+ break;
|
||||||
|
+ pids[pids_len++] = pid;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Find closest parent */
|
||||||
|
+ for (i = 0; i < pids_len; i++) {
|
||||||
|
+ wl_list_for_each(p, &clients, link) {
|
||||||
|
+ if (!p->pid || !p->isterm || p->swallowedby)
|
||||||
|
+ continue;
|
||||||
|
+ if (pids[i] == p->pid)
|
||||||
|
+ return p;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
tile(Monitor *m)
|
||||||
|
{
|
||||||
|
@@ -2741,6 +2853,32 @@ togglefullscreen(const Arg *arg)
|
||||||
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+toggleswallow(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Client *c, *sel = focustop(selmon);
|
||||||
|
+ if (!sel)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ if (sel->swallowing) {
|
||||||
|
+ swallow(sel, NULL);
|
||||||
|
+ } else {
|
||||||
|
+ wl_list_for_each(c, &sel->flink, flink) {
|
||||||
|
+ if (&c->flink == &fstack)
|
||||||
|
+ continue; /* wrap past the sentinel node */
|
||||||
|
+ if (VISIBLEON(c, selmon))
|
||||||
|
+ break; /* found it */
|
||||||
|
+ }
|
||||||
|
+ swallow(sel, c);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+toggleautoswallow(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ enableautoswallow = !enableautoswallow;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
toggletag(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -2801,6 +2939,12 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||||
|
grabc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (c->swallowing) {
|
||||||
|
+ swallow(c, NULL);
|
||||||
|
+ } else if (c->swallowedby) {
|
||||||
|
+ swallow(c->swallowedby, NULL);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (client_is_unmanaged(c)) {
|
||||||
|
if (c == exclusive_focus) {
|
||||||
|
exclusive_focus = NULL;
|
||||||
|
--
|
||||||
|
2.49.0
|
||||||
|
|
||||||
188
unclutter.patch
188
unclutter.patch
@@ -1,188 +0,0 @@
|
|||||||
From 52d5a05a6b4ca9555c072e103c2db454d2b35021 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Guido Cella <guido@guidocella.xyz>
|
|
||||||
Date: Thu, 25 Jul 2024 17:59:05 +0200
|
|
||||||
Subject: [PATCH] =?UTF-8?q?hide=20the=20mouse=20cursor=20if=20it=20isn?=
|
|
||||||
=?UTF-8?q?=E2=80=99t=20being=20used?=
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
---
|
|
||||||
config.def.h | 2 ++
|
|
||||||
dwl.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++------
|
|
||||||
2 files changed, 65 insertions(+), 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 22d2171..790c73d 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -106,6 +106,8 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
|
|
||||||
*/
|
|
||||||
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
|
||||||
|
|
||||||
+static const int cursor_timeout = 5;
|
|
||||||
+
|
|
||||||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
|
||||||
#define MODKEY WLR_MODIFIER_ALT
|
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index 72892d9..4090d73 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -292,6 +292,8 @@ static void focusstack(const Arg *arg);
|
|
||||||
static Client *focustop(Monitor *m);
|
|
||||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
|
||||||
static void gpureset(struct wl_listener *listener, void *data);
|
|
||||||
+static void handlecursoractivity(void);
|
|
||||||
+static int hidecursor(void *data);
|
|
||||||
static void handlesig(int signo);
|
|
||||||
static void incnmaster(const Arg *arg);
|
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
|
||||||
@@ -396,6 +398,14 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
|
|
||||||
|
|
||||||
static struct wlr_cursor *cursor;
|
|
||||||
static struct wlr_xcursor_manager *cursor_mgr;
|
|
||||||
+static struct wl_event_source *hide_source;
|
|
||||||
+static bool cursor_hidden = false;
|
|
||||||
+static struct {
|
|
||||||
+ enum wp_cursor_shape_device_v1_shape shape;
|
|
||||||
+ struct wlr_surface *surface;
|
|
||||||
+ int hotspot_x;
|
|
||||||
+ int hotspot_y;
|
|
||||||
+} last_cursor;
|
|
||||||
|
|
||||||
static struct wlr_scene_rect *root_bg;
|
|
||||||
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
|
||||||
@@ -588,6 +598,7 @@ axisnotify(struct wl_listener *listener, void *data)
|
|
||||||
* for example when you move the scroll wheel. */
|
|
||||||
struct wlr_pointer_axis_event *event = data;
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
|
||||||
+ handlecursoractivity();
|
|
||||||
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
|
|
||||||
* checking the event's orientation and the delta of the event */
|
|
||||||
/* Notify the client with pointer focus of the axis event. */
|
|
||||||
@@ -606,6 +617,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
|
||||||
const Button *b;
|
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
|
||||||
+ handlecursoractivity();
|
|
||||||
|
|
||||||
switch (event->state) {
|
|
||||||
case WL_POINTER_BUTTON_STATE_PRESSED:
|
|
||||||
@@ -1517,6 +1529,32 @@ handlesig(int signo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+handlecursoractivity(void)
|
|
||||||
+{
|
|
||||||
+ wl_event_source_timer_update(hide_source, cursor_timeout * 1000);
|
|
||||||
+
|
|
||||||
+ if (!cursor_hidden)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ cursor_hidden = false;
|
|
||||||
+
|
|
||||||
+ if (last_cursor.shape)
|
|
||||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
|
||||||
+ wlr_cursor_shape_v1_name(last_cursor.shape));
|
|
||||||
+ else
|
|
||||||
+ wlr_cursor_set_surface(cursor, last_cursor.surface,
|
|
||||||
+ last_cursor.hotspot_x, last_cursor.hotspot_y);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+hidecursor(void *data)
|
|
||||||
+{
|
|
||||||
+ wlr_cursor_unset_image(cursor);
|
|
||||||
+ cursor_hidden = true;
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
incnmaster(const Arg *arg)
|
|
||||||
{
|
|
||||||
@@ -1856,6 +1894,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
|
||||||
|
|
||||||
wlr_cursor_move(cursor, device, dx, dy);
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
|
||||||
+ handlecursoractivity();
|
|
||||||
|
|
||||||
/* Update selmon (even while dragging a window) */
|
|
||||||
if (sloppyfocus)
|
|
||||||
@@ -1880,7 +1919,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
|
||||||
/* If there's no client surface under the cursor, set the cursor image to a
|
|
||||||
* default. This is what makes the cursor image appear when you move it
|
|
||||||
* off of a client or over its border. */
|
|
||||||
- if (!surface && !seat->drag)
|
|
||||||
+ if (!surface && !seat->drag && !cursor_hidden)
|
|
||||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
|
||||||
|
|
||||||
pointerfocus(c, surface, sx, sy, time);
|
|
||||||
@@ -2263,6 +2302,7 @@ run(char *startup_cmd)
|
|
||||||
* monitor when displayed here */
|
|
||||||
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
|
|
||||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
|
||||||
+ handlecursoractivity();
|
|
||||||
|
|
||||||
/* Run the Wayland event loop. This does not return until you exit the
|
|
||||||
* compositor. Starting the backend rigged up all of the necessary event
|
|
||||||
@@ -2286,9 +2326,16 @@ setcursor(struct wl_listener *listener, void *data)
|
|
||||||
* use the provided surface as the cursor image. It will set the
|
|
||||||
* hardware cursor on the output that it's currently on and continue to
|
|
||||||
* do so as the cursor moves between outputs. */
|
|
||||||
- if (event->seat_client == seat->pointer_state.focused_client)
|
|
||||||
- wlr_cursor_set_surface(cursor, event->surface,
|
|
||||||
- event->hotspot_x, event->hotspot_y);
|
|
||||||
+ if (event->seat_client == seat->pointer_state.focused_client) {
|
|
||||||
+ last_cursor.shape = 0;
|
|
||||||
+ last_cursor.surface = event->surface;
|
|
||||||
+ last_cursor.hotspot_x = event->hotspot_x;
|
|
||||||
+ last_cursor.hotspot_y = event->hotspot_y;
|
|
||||||
+
|
|
||||||
+ if (!cursor_hidden)
|
|
||||||
+ wlr_cursor_set_surface(cursor, event->surface,
|
|
||||||
+ event->hotspot_x, event->hotspot_y);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -2300,9 +2347,14 @@ setcursorshape(struct wl_listener *listener, void *data)
|
|
||||||
/* This can be sent by any client, so we check to make sure this one is
|
|
||||||
* actually has pointer focus first. If so, we can tell the cursor to
|
|
||||||
* use the provided cursor shape. */
|
|
||||||
- if (event->seat_client == seat->pointer_state.focused_client)
|
|
||||||
- wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
|
||||||
- wlr_cursor_shape_v1_name(event->shape));
|
|
||||||
+ if (event->seat_client == seat->pointer_state.focused_client) {
|
|
||||||
+ last_cursor.shape = event->shape;
|
|
||||||
+ last_cursor.surface = NULL;
|
|
||||||
+
|
|
||||||
+ if (!cursor_hidden)
|
|
||||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
|
||||||
+ wlr_cursor_shape_v1_name(event->shape));
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -2604,6 +2656,9 @@ setup(void)
|
|
||||||
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
|
|
||||||
LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape);
|
|
||||||
|
|
||||||
+ hide_source = wl_event_loop_add_timer(wl_display_get_event_loop(dpy),
|
|
||||||
+ hidecursor, cursor);
|
|
||||||
+
|
|
||||||
/*
|
|
||||||
* Configures a seat, which is a single "seat" at which a user sits and
|
|
||||||
* operates the computer. This conceptually includes up to one keyboard,
|
|
||||||
@@ -2986,6 +3041,7 @@ virtualpointer(struct wl_listener *listener, void *data)
|
|
||||||
wlr_cursor_attach_input_device(cursor, device);
|
|
||||||
if (event->suggested_output)
|
|
||||||
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
|
|
||||||
+ handlecursoractivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
Monitor *
|
|
||||||
--
|
|
||||||
2.45.2
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user