mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
1 Commits
hide-behin
...
unclutter
| Author | SHA1 | Date | |
|---|---|---|---|
| 772c7869b8 |
@@ -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
|
||||
|
||||
|
||||
137
dwl.c
137
dwl.c
@@ -285,11 +285,12 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m, int onlytiled);
|
||||
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 hidebehindmonocle(Monitor *m);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
@@ -390,6 +391,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;
|
||||
@@ -519,7 +528,7 @@ arrange(Monitor *m)
|
||||
}
|
||||
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
||||
(c = focustop(m, 0)) && c->isfullscreen);
|
||||
(c = focustop(m)) && c->isfullscreen);
|
||||
|
||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
||||
|
||||
@@ -610,6 +619,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. */
|
||||
@@ -628,6 +638,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:
|
||||
@@ -811,7 +822,7 @@ closemon(Monitor *m)
|
||||
if (c->mon == m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -1248,7 +1259,7 @@ void
|
||||
destroydragicon(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
wl_list_remove(&listener->link);
|
||||
free(listener);
|
||||
@@ -1287,7 +1298,7 @@ destroylock(SessionLock *lock, int unlock)
|
||||
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
||||
|
||||
focusclient(focustop(selmon, 0), 0);
|
||||
focusclient(focustop(selmon), 0);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
|
||||
destroy:
|
||||
@@ -1316,7 +1327,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
|
||||
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
||||
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
||||
} else if (!locked) {
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
} else {
|
||||
wlr_seat_keyboard_clear_focus(seat);
|
||||
}
|
||||
@@ -1427,7 +1438,6 @@ focusclient(Client *c, int lift)
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
selmon = c->mon;
|
||||
c->isurgent = 0;
|
||||
hidebehindmonocle(c->mon);
|
||||
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
@@ -1481,14 +1491,14 @@ focusmon(const Arg *arg)
|
||||
selmon = dirtomon(arg->i);
|
||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
||||
}
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
/* Focus the next or previous client (in tiling order) on selmon */
|
||||
Client *c, *sel = focustop(selmon, 0);
|
||||
Client *c, *sel = focustop(selmon);
|
||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
@@ -1514,16 +1524,13 @@ focusstack(const Arg *arg)
|
||||
* will focus the topmost client of this mon, when actually will
|
||||
* only return that client */
|
||||
Client *
|
||||
focustop(Monitor *m, int onlytiled)
|
||||
focustop(Monitor *m)
|
||||
{
|
||||
Client *c;
|
||||
wl_list_for_each(c, &fstack, flink) {
|
||||
if (VISIBLEON(c, m)) {
|
||||
if (onlytiled && c->isfloating)
|
||||
continue;
|
||||
if (VISIBLEON(c, m))
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1569,22 +1576,29 @@ handlesig(int signo)
|
||||
}
|
||||
|
||||
void
|
||||
hidebehindmonocle(Monitor *m)
|
||||
handlecursoractivity(void)
|
||||
{
|
||||
Client *c;
|
||||
if (m && m->lt[m->sellt]->arrange == monocle) {
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
||||
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);
|
||||
}
|
||||
|
||||
c = NULL;
|
||||
|
||||
/* Enable top tiled client, fullscreen is considered tiled */
|
||||
if ((c = focustop(m, 1)))
|
||||
wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
}
|
||||
int
|
||||
hidecursor(void *data)
|
||||
{
|
||||
wlr_cursor_unset_image(cursor);
|
||||
cursor_hidden = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1725,7 +1739,7 @@ keyrepeat(void *data)
|
||||
void
|
||||
killclient(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon, 0);
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
client_send_close(sel);
|
||||
}
|
||||
@@ -1854,7 +1868,8 @@ monocle(Monitor *m)
|
||||
}
|
||||
if (n)
|
||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
||||
hidebehindmonocle(m);
|
||||
if ((c = focustop(m)))
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1927,6 +1942,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)
|
||||
@@ -1951,7 +1967,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);
|
||||
@@ -2121,7 +2137,7 @@ printstatus(void)
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
if ((c = focustop(m, 0))) {
|
||||
if ((c = focustop(m))) {
|
||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
||||
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
|
||||
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
|
||||
@@ -2306,6 +2322,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
|
||||
@@ -2329,10 +2346,17 @@ 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)
|
||||
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
|
||||
setcursorshape(struct wl_listener *listener, void *data)
|
||||
@@ -2343,10 +2367,15 @@ 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)
|
||||
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
|
||||
setfloating(Client *c, int floating)
|
||||
@@ -2435,7 +2464,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||
setfloating(c, c->isfloating);
|
||||
}
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2636,6 +2665,9 @@ setup(void)
|
||||
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);
|
||||
|
||||
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,
|
||||
@@ -2709,12 +2741,12 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon, 0);
|
||||
Client *sel = focustop(selmon);
|
||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
||||
return;
|
||||
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2722,7 +2754,7 @@ tag(const Arg *arg)
|
||||
void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon, 0);
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
}
|
||||
@@ -2764,7 +2796,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon, 0);
|
||||
Client *sel = focustop(selmon);
|
||||
/* return if fullscreen */
|
||||
if (sel && !sel->isfullscreen)
|
||||
setfloating(sel, !sel->isfloating);
|
||||
@@ -2773,7 +2805,7 @@ togglefloating(const Arg *arg)
|
||||
void
|
||||
togglefullscreen(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon, 0);
|
||||
Client *sel = focustop(selmon);
|
||||
if (sel)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
@@ -2782,12 +2814,12 @@ void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
uint32_t newtags;
|
||||
Client *sel = focustop(selmon, 0);
|
||||
Client *sel = focustop(selmon);
|
||||
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
||||
return;
|
||||
|
||||
sel->tags = newtags;
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2800,7 +2832,7 @@ toggleview(const Arg *arg)
|
||||
return;
|
||||
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2824,7 +2856,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
||||
arrangelayers(l->mon);
|
||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -2841,7 +2873,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
if (client_is_unmanaged(c)) {
|
||||
if (c == exclusive_focus) {
|
||||
exclusive_focus = NULL;
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
} else {
|
||||
wl_list_remove(&c->link);
|
||||
@@ -2922,7 +2954,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
/* Don't move clients to the left output when plugging monitors */
|
||||
arrange(m);
|
||||
/* make sure fullscreen clients have the right size */
|
||||
if ((c = focustop(m, 0)) && c->isfullscreen)
|
||||
if ((c = focustop(m)) && c->isfullscreen)
|
||||
resize(c, m->m, 0);
|
||||
|
||||
/* Try to re-set the gamma LUT when updating monitors,
|
||||
@@ -2942,7 +2974,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
if (!c->mon && client_surface(c)->mapped)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
if (selmon->lock_surface) {
|
||||
client_notify_enter(selmon->lock_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
@@ -2964,7 +2996,7 @@ void
|
||||
updatetitle(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_title);
|
||||
if (c == focustop(c->mon, 0))
|
||||
if (c == focustop(c->mon))
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -2974,7 +3006,7 @@ urgent(struct wl_listener *listener, void *data)
|
||||
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
||||
Client *c = NULL;
|
||||
toplevel_from_wlr_surface(event->surface, &c, NULL);
|
||||
if (!c || c == focustop(selmon, 0))
|
||||
if (!c || c == focustop(selmon))
|
||||
return;
|
||||
|
||||
c->isurgent = 1;
|
||||
@@ -2992,7 +3024,7 @@ view(const Arg *arg)
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & TAGMASK)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -3020,6 +3052,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 *
|
||||
@@ -3063,7 +3096,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
Client *c, *sel = focustop(selmon, 0);
|
||||
Client *c, *sel = focustop(selmon);
|
||||
|
||||
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
||||
return;
|
||||
@@ -3174,7 +3207,7 @@ sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_hints);
|
||||
struct wlr_surface *surface = client_surface(c);
|
||||
if (c == focustop(selmon, 0) || !c->surface.xwayland->hints)
|
||||
if (c == focustop(selmon) || !c->surface.xwayland->hints)
|
||||
return;
|
||||
|
||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
From 8022376ee59d616831271dbc9f289a8bfd4fedda Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
|
||||
<leohdz172@proton.me>
|
||||
Date: Sat, 8 Jul 2023 17:25:16 -0600
|
||||
Subject: [PATCH] hide behind monocle
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
|
||||
---
|
||||
dwl.c | 87 +++++++++++++++++++++++++++++++++++++----------------------
|
||||
1 file changed, 55 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index ad21e1ba..cad3b0b2 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -285,10 +285,11 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
-static Client *focustop(Monitor *m);
|
||||
+static Client *focustop(Monitor *m, int onlytiled);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
+static void hidebehindmonocle(Monitor *m);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
@@ -518,7 +519,7 @@ arrange(Monitor *m)
|
||||
}
|
||||
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
||||
- (c = focustop(m)) && c->isfullscreen);
|
||||
+ (c = focustop(m, 0)) && c->isfullscreen);
|
||||
|
||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
||||
|
||||
@@ -807,7 +808,7 @@ closemon(Monitor *m)
|
||||
if (c->mon == m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -1243,7 +1244,7 @@ void
|
||||
destroydragicon(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
wl_list_remove(&listener->link);
|
||||
}
|
||||
@@ -1280,7 +1281,7 @@ destroylock(SessionLock *lock, int unlock)
|
||||
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
||||
|
||||
- focusclient(focustop(selmon), 0);
|
||||
+ focusclient(focustop(selmon, 0), 0);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
|
||||
destroy:
|
||||
@@ -1309,7 +1310,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
|
||||
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
||||
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
||||
} else if (!locked) {
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
} else {
|
||||
wlr_seat_keyboard_clear_focus(seat);
|
||||
}
|
||||
@@ -1420,6 +1421,7 @@ focusclient(Client *c, int lift)
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
selmon = c->mon;
|
||||
c->isurgent = 0;
|
||||
+ hidebehindmonocle(c->mon);
|
||||
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
@@ -1473,14 +1475,14 @@ focusmon(const Arg *arg)
|
||||
selmon = dirtomon(arg->i);
|
||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
}
|
||||
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
/* Focus the next or previous client (in tiling order) on selmon */
|
||||
- Client *c, *sel = focustop(selmon);
|
||||
+ Client *c, *sel = focustop(selmon, 0);
|
||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
@@ -1506,12 +1508,15 @@ focusstack(const Arg *arg)
|
||||
* will focus the topmost client of this mon, when actually will
|
||||
* only return that client */
|
||||
Client *
|
||||
-focustop(Monitor *m)
|
||||
+focustop(Monitor *m, int onlytiled)
|
||||
{
|
||||
Client *c;
|
||||
wl_list_for_each(c, &fstack, flink) {
|
||||
- if (VISIBLEON(c, m))
|
||||
+ if (VISIBLEON(c, m)) {
|
||||
+ if (onlytiled && c->isfloating)
|
||||
+ continue;
|
||||
return c;
|
||||
+ }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1557,6 +1562,25 @@ handlesig(int signo)
|
||||
quit(NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+hidebehindmonocle(Monitor *m)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ if (m && m->lt[m->sellt]->arrange == monocle) {
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon != m)
|
||||
+ continue;
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
||||
+ }
|
||||
+
|
||||
+ c = NULL;
|
||||
+
|
||||
+ /* Enable top tiled client, fullscreen is considered tiled */
|
||||
+ if ((c = focustop(m, 1)))
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -1695,7 +1719,7 @@ keyrepeat(void *data)
|
||||
void
|
||||
killclient(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
client_send_close(sel);
|
||||
}
|
||||
@@ -1824,8 +1848,7 @@ monocle(Monitor *m)
|
||||
}
|
||||
if (n)
|
||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
||||
- if ((c = focustop(m)))
|
||||
- wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
+ hidebehindmonocle(m);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2092,7 +2115,7 @@ printstatus(void)
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
- if ((c = focustop(m))) {
|
||||
+ if ((c = focustop(m, 0))) {
|
||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
||||
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
|
||||
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
|
||||
@@ -2406,7 +2429,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||
setfloating(c, c->isfloating);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2680,12 +2703,12 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
||||
return;
|
||||
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2693,7 +2716,7 @@ tag(const Arg *arg)
|
||||
void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
}
|
||||
@@ -2735,7 +2758,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
/* return if fullscreen */
|
||||
if (sel && !sel->isfullscreen)
|
||||
setfloating(sel, !sel->isfloating);
|
||||
@@ -2744,7 +2767,7 @@ togglefloating(const Arg *arg)
|
||||
void
|
||||
togglefullscreen(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
@@ -2753,12 +2776,12 @@ void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
uint32_t newtags;
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
||||
return;
|
||||
|
||||
sel->tags = newtags;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2771,7 +2794,7 @@ toggleview(const Arg *arg)
|
||||
return;
|
||||
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2795,7 +2818,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
||||
arrangelayers(l->mon);
|
||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -2812,7 +2835,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
if (client_is_unmanaged(c)) {
|
||||
if (c == exclusive_focus) {
|
||||
exclusive_focus = NULL;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
}
|
||||
} else {
|
||||
wl_list_remove(&c->link);
|
||||
@@ -2893,7 +2916,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
/* Don't move clients to the left output when plugging monitors */
|
||||
arrange(m);
|
||||
/* make sure fullscreen clients have the right size */
|
||||
- if ((c = focustop(m)) && c->isfullscreen)
|
||||
+ if ((c = focustop(m, 0)) && c->isfullscreen)
|
||||
resize(c, m->m, 0);
|
||||
|
||||
/* Try to re-set the gamma LUT when updating monitors,
|
||||
@@ -2913,7 +2936,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
if (!c->mon && client_surface(c)->mapped)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
if (selmon->lock_surface) {
|
||||
client_notify_enter(selmon->lock_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
@@ -2935,7 +2958,7 @@ void
|
||||
updatetitle(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_title);
|
||||
- if (c == focustop(c->mon))
|
||||
+ if (c == focustop(c->mon, 0))
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -2945,7 +2968,7 @@ urgent(struct wl_listener *listener, void *data)
|
||||
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
||||
Client *c = NULL;
|
||||
toplevel_from_wlr_surface(event->surface, &c, NULL);
|
||||
- if (!c || c == focustop(selmon))
|
||||
+ if (!c || c == focustop(selmon, 0))
|
||||
return;
|
||||
|
||||
c->isurgent = 1;
|
||||
@@ -2963,7 +2986,7 @@ view(const Arg *arg)
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & TAGMASK)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -3034,7 +3057,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
- Client *c, *sel = focustop(selmon);
|
||||
+ Client *c, *sel = focustop(selmon, 0);
|
||||
|
||||
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
||||
return;
|
||||
@@ -3145,7 +3168,7 @@ sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_hints);
|
||||
struct wlr_surface *surface = client_surface(c);
|
||||
- if (c == focustop(selmon))
|
||||
+ if (c == focustop(selmon, 0))
|
||||
return;
|
||||
|
||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
--
|
||||
2.48.0
|
||||
|
||||
188
unclutter.patch
Normal file
188
unclutter.patch
Normal file
@@ -0,0 +1,188 @@
|
||||
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