inhibit idle if fullscreen client is focused

This commit is contained in:
korei999 2023-11-29 22:37:25 +02:00
parent fc14399c31
commit 34ac3849c3
2 changed files with 19 additions and 3 deletions

View file

@ -231,7 +231,7 @@ static const Key keys[] = {
{ SUPER, Key_s, setlayout, { .v = &layouts[1] } }, { SUPER, Key_s, setlayout, { .v = &layouts[1] } },
{ SUPER, Key_v, setlayout, { .v = &layouts[2] } }, { SUPER, Key_v, setlayout, { .v = &layouts[2] } },
{ SUPER, Key_grave, togglefloating, { 0 } }, { SUPER, Key_grave, togglefloating, { 0 } },
// { SUPER | SHIFT, Key_s, togglesticky, { 0 } }, { SUPER | SHIFT, Key_s, togglesticky, { 0 } },
{ SUPER, Key_f, togglefullscreen, { 0 } }, { SUPER, Key_f, togglefullscreen, { 0 } },
{ SUPER, Key_g, zoom, { 0 } }, { SUPER, Key_g, zoom, { 0 } },
{ SUPER, Key_Tab, view, { 0 } }, { SUPER, Key_Tab, view, { 0 } },

20
dwl.c
View file

@ -68,7 +68,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)->issticky))
#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)
@ -131,7 +131,7 @@ typedef struct {
#endif #endif
unsigned int bw; unsigned int bw;
uint32_t tags; uint32_t tags;
int isfloating, isurgent, isfullscreen; int isfloating, isurgent, isfullscreen, issticky;
uint32_t resize; /* configure serial of a pending resize */ uint32_t resize; /* configure serial of a pending resize */
xkb_layout_index_t layout_idx; xkb_layout_index_t layout_idx;
} Client; } Client;
@ -342,6 +342,7 @@ static void tile(Monitor *m);
static void vertile(Monitor *m); static void vertile(Monitor *m);
static void togglebar(const Arg *arg); static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglesticky(const Arg *arg);
static void togglefullscreen(const Arg *arg); static void togglefullscreen(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);
@ -666,6 +667,8 @@ void
checkidleinhibitor(struct wlr_surface *exclude) checkidleinhibitor(struct wlr_surface *exclude)
{ {
int inhibited = 0, unused_lx, unused_ly; int inhibited = 0, unused_lx, unused_ly;
Client *c = focustop(selmon, 0);
struct wlr_idle_inhibitor_v1 *inhibitor; struct wlr_idle_inhibitor_v1 *inhibitor;
wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) { wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) {
struct wlr_surface *surface = wlr_surface_get_root_surface(inhibitor->surface); struct wlr_surface *surface = wlr_surface_get_root_surface(inhibitor->surface);
@ -677,6 +680,9 @@ checkidleinhibitor(struct wlr_surface *exclude)
} }
} }
if (c && c->isfullscreen)
inhibited = 1;
wlr_idle_notifier_v1_set_inhibited(idle_notifier, inhibited); wlr_idle_notifier_v1_set_inhibited(idle_notifier, inhibited);
} }
@ -2871,6 +2877,16 @@ togglefloating(const Arg *arg)
setfloating(sel, !sel->isfloating); setfloating(sel, !sel->isfloating);
} }
void
togglesticky(const Arg *arg)
{
Client *sel = focustop(selmon, 0);
if (!sel)
return;
sel->issticky = !sel->issticky;
arrange(selmon);
}
void void
togglefullscreen(const Arg *arg) togglefullscreen(const Arg *arg)
{ {