updated: implemented inhibit protocol in dwl

This commit is contained in:
Clay Gomera 2023-10-21 14:02:35 -04:00
parent a3bc0af419
commit 22ddae8831
5 changed files with 135 additions and 3585 deletions

View file

@ -22,7 +22,9 @@ pipewire-pulse &
wireplumber &
# Desktop portals and authentication agents
/usr/libexec/xdg-desktop-portal &
/usr/libexec/xdg-desktop-portal-wlr &
/usr/libexec/xdg-desktop-portal-gtk &
/usr/libexec/polkit-gnome-authentication-agent-1 &
# Clipboard manager

View file

@ -46,7 +46,6 @@ static const Rule rules[] = {
{ "^Chromium$", NULL, 1 << 2, 0, -1, 0 },
{ "^org.qutebrowser.qutebrowser$", NULL, 1 << 2, 0, -1, 0 },
{ "^Brave-browser$", NULL, 1 << 2, 0, -1, 0 },
{ "^Bitwarden$", NULL, 1 << 2, 0, -1, 0 },
{ "^org.qbittorrent.qBittorrent$", NULL, 1 << 2, 0, -1, 0 },
{ "^gomuks$", NULL, 1 << 3, 0, -1, 0 },
{ "^Signal$", NULL, 1 << 3, 0, -1, 0 },
@ -71,7 +70,8 @@ static const Rule rules[] = {
{ "^com.obsproject.Studio$", NULL, 1 << 5, 0, -1, 0 },
{ "^fr.handbrake.ghb$", NULL, 1 << 5, 0, -1, 0 },
{ "^org.inkscape.Inkscape$", NULL, 1 << 6, 0, -1, 0 },
{ "^Gimp-2.10$", NULL, 1 << 6, 0, -1, 0 }, { "^xournalpp$", NULL, 1 << 6, 0, -1, 0 },
{ "^Gimp-2.10$", NULL, 1 << 6, 0, -1, 0 },
{ "^xournalpp$", NULL, 1 << 6, 0, -1, 0 },
{ "^krita$", NULL, 1 << 6, 0, -1, 0 },
{ "^darktable$", NULL, 1 << 6, 0, -1, 0 },
{ "^org.kde.digikam$", NULL, 1 << 6, 0, -1, 0 },
@ -101,6 +101,7 @@ static const Rule rules[] = {
{ "^spanic$", NULL, 0, 1, -1, 'a' },
{ "^spytfz$", NULL, 0, 1, -1, 'y' },
{ "^spytfm$", NULL, 0, 1, -1, 'n' },
{ "^Bitwarden$", NULL, 0, 1, -1, 'k' },
};
/* layout(s) */
@ -211,8 +212,9 @@ static const char *sprang[] = { "v", "wezterm", "start", "--class", "sprang", "r
static const char *spnews[] = { "r", "wezterm", "start", "--class", "spnews", "newsboat", NULL };
static const char *spflix[] = { "f", "wezterm", "start", "--class", "spflix", "flix-cli", NULL };
static const char *spanic[] = { "a", "wezterm", "start", "--class", "spanic", "ani-cli", NULL };
static const char *spytfz[] = { "y", "wezterm", "start", "--class", "spytfz", "ytfzf", "-flst", NULL };
static const char *spytfm[] = { "n", "wezterm", "start", "--class", "spytfm", "ytfzf", "-mlst", NULL };
static const char *spytfz[] = { "y", "wezterm", "start", "--class", "spytfz", "ytfzf", "-flstT", "chafa", NULL };
static const char *spytfm[] = { "n", "wezterm", "start", "--class", "spytfm", "ytfzf", "-mlstT", "chafa", NULL };
static const char *spbitw[] = { "k", "flatpak", "run", "com.bitwarden.desktop", NULL };
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
@ -253,7 +255,6 @@ static const Key keys[] = {
{ MODKEY, Key_s, spawn, SHCMD("flatpak run org.signal.Signal") },
{ MODKEY|WLR_MODIFIER_SHIFT, Key_r, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, Key_d, spawn, {.v = dmenucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, Key_d, spawn, SHCMD("pkill wofi || $HOME/.config/wofi/scripts/rs_drun") },
{ MODKEY|WLR_MODIFIER_SHIFT, Key_i, spawn, SHCMD("pkill wofi || $HOME/.config/wofi/scripts/rs_wifi") },
{ MODKEY, Key_Print, spawn, SHCMD("pkill wofi || $HOME/.config/wofi/scripts/rs_scrot") },
{ MODKEY|WLR_MODIFIER_SHIFT, Key_w, spawn, SHCMD("pkill wofi || $HOME/.config/wofi/scripts/rs_wall") },
@ -284,6 +285,7 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_ALT, Key_a, togglescratch, {.v = spanic } },
{ MODKEY|WLR_MODIFIER_ALT, Key_y, togglescratch, {.v = spytfz } },
{ MODKEY|WLR_MODIFIER_ALT, Key_n, togglescratch, {.v = spytfm } },
{ MODKEY|WLR_MODIFIER_ALT, Key_k, togglescratch, {.v = spbitw } },
TAGKEYS( Key_1, 0 ),
TAGKEYS( Key_2, 1 ),
TAGKEYS( Key_3, 2 ),

View file

@ -29,6 +29,7 @@
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
@ -263,6 +264,7 @@ static void createlocksurface(struct wl_listener *listener, void *data);
static void createmon(struct wl_listener *listener, void *data);
static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer);
static void createshortcutsinhibitor(struct wl_listener *listener, void *data);
static void createtouch(struct wlr_touch *touch);
static void cursorframe(struct wl_listener *listener, void *data);
static void destroydragicon(struct wl_listener *listener, void *data);
@ -273,6 +275,7 @@ static void destroylocksurface(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
static void destroyshortcutsinhibitmgr(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id);
static void dwl_ipc_manager_destroy(struct wl_resource *resource);
@ -391,6 +394,7 @@ static struct wlr_idle *idle;
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_input_inhibit_manager *input_inhibit_mgr;
static struct wlr_keyboard_shortcuts_inhibit_manager_v1 *shortcuts_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr;
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
@ -436,6 +440,7 @@ static struct wl_listener layout_change = {.notify = updatemons};
static struct wl_listener new_input = {.notify = inputdevice};
static struct wl_listener new_virtual_keyboard = {.notify = virtualkeyboard};
static struct wl_listener new_output = {.notify = createmon};
static struct wl_listener new_shortcuts_inhibitor = {.notify = createshortcutsinhibitor};
static struct wl_listener new_xdg_surface = {.notify = createnotify};
static struct wl_listener new_xdg_decoration = {.notify = createdecoration};
static struct wl_listener new_layer_shell_surface = {.notify = createlayersurface};
@ -449,6 +454,7 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener session_lock_create_lock = {.notify = locksession};
static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmgr};
static struct wl_listener shortcuts_inhibit_mgr_destroy = {.notify = destroyshortcutsinhibitmgr};
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@ -1292,6 +1298,10 @@ createtouch(struct wlr_touch *touch)
wlr_cursor_attach_input_device(cursor, &touch->base);
}
void createshortcutsinhibitor(struct wl_listener *listener, void *data) {
wlr_keyboard_shortcuts_inhibitor_v1_activate(data);
}
void
cursorframe(struct wl_listener *listener, void *data)
{
@ -1413,6 +1423,11 @@ destroysessionmgr(struct wl_listener *listener, void *data)
wl_list_remove(&session_lock_mgr_destroy.link);
}
void destroyshortcutsinhibitmgr(struct wl_listener *listener, void *data) {
wl_list_remove(&new_shortcuts_inhibitor.link);
wl_list_remove(&shortcuts_inhibit_mgr_destroy.link);
}
Monitor *
dirtomon(enum wlr_direction dir)
{
@ -1886,7 +1901,8 @@ keypress(struct wl_listener *listener, void *data)
/* On _press_ if there is no active screen locker,
* attempt to process a compositor keybinding. */
if (!locked && !input_inhibit_mgr->active_inhibitor
&& event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
&& event->state == WL_KEYBOARD_KEY_STATE_PRESSED
&& wl_list_empty(&shortcuts_inhibit_mgr->inhibitors))
handled = keybinding(mods, keycode);
if (handled && kb->wlr_keyboard->repeat_info.delay > 0) {
@ -2708,6 +2724,10 @@ setup(void)
(float [4]){0.1, 0.1, 0.1, 1.0});
wlr_scene_node_set_enabled(&locked_bg->node, 0);
shortcuts_inhibit_mgr = wlr_keyboard_shortcuts_inhibit_v1_create(dpy);
wl_signal_add(&shortcuts_inhibit_mgr->events.new_inhibitor, &new_shortcuts_inhibitor);
wl_signal_add(&shortcuts_inhibit_mgr->events.destroy, &shortcuts_inhibit_mgr_destroy);
/* Use decoration protocols to negotiate server-side decorations */
wlr_server_decoration_manager_set_default_mode(
wlr_server_decoration_manager_create(dpy),

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,105 @@
From cd7954be78ba9abe38423f2537c39c29ca7695db Mon Sep 17 00:00:00 2001
From: MadcowOG <N/A>
Date: Mon, 1 May 2023 02:35:42 -0700
Subject: [PATCH] Implemented wlr_keyboard_shortcuts_inhibit
---
dwl.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index b7436bb4f..842e0b147 100644
--- a/dwl.c
+++ b/dwl.c
@@ -28,6 +28,7 @@
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_keyboard.h>
+#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
@@ -245,6 +246,7 @@ static void createlocksurface(struct wl_listener *listener, void *data);
static void createmon(struct wl_listener *listener, void *data);
static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer);
+static void createshortcutsinhibitor(struct wl_listener *listener, void *data);
static void cursorframe(struct wl_listener *listener, void *data);
static void destroydragicon(struct wl_listener *listener, void *data);
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
@@ -254,6 +256,7 @@ static void destroylocksurface(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
+static void destroyshortcutsinhibitmgr(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
@@ -342,6 +345,7 @@ static struct wlr_idle *idle;
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_input_inhibit_manager *input_inhibit_mgr;
+static struct wlr_keyboard_shortcuts_inhibit_manager_v1 *shortcuts_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr;
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
@@ -377,6 +381,7 @@ static struct wl_listener layout_change = {.notify = updatemons};
static struct wl_listener new_input = {.notify = inputdevice};
static struct wl_listener new_virtual_keyboard = {.notify = virtualkeyboard};
static struct wl_listener new_output = {.notify = createmon};
+static struct wl_listener new_shortcuts_inhibitor = {.notify = createshortcutsinhibitor};
static struct wl_listener new_xdg_surface = {.notify = createnotify};
static struct wl_listener new_xdg_decoration = {.notify = createdecoration};
static struct wl_listener new_layer_shell_surface = {.notify = createlayersurface};
@@ -390,6 +395,7 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener session_lock_create_lock = {.notify = locksession};
static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmgr};
+static struct wl_listener shortcuts_inhibit_mgr_destroy = {.notify = destroyshortcutsinhibitmgr};
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -1061,6 +1067,10 @@ createpointer(struct wlr_pointer *pointer)
wlr_cursor_attach_input_device(cursor, &pointer->base);
}
+void createshortcutsinhibitor(struct wl_listener *listener, void *data) {
+ wlr_keyboard_shortcuts_inhibitor_v1_activate(data);
+}
+
void
cursorframe(struct wl_listener *listener, void *data)
{
@@ -1181,6 +1191,11 @@ destroysessionmgr(struct wl_listener *listener, void *data)
wl_list_remove(&session_lock_mgr_destroy.link);
}
+void destroyshortcutsinhibitmgr(struct wl_listener *listener, void *data) {
+ wl_list_remove(&new_shortcuts_inhibitor.link);
+ wl_list_remove(&shortcuts_inhibit_mgr_destroy.link);
+}
+
Monitor *
dirtomon(enum wlr_direction dir)
{
@@ -1407,7 +1422,8 @@ keypress(struct wl_listener *listener, void *data)
/* On _press_ if there is no active screen locker,
* attempt to process a compositor keybinding. */
if (!locked && !input_inhibit_mgr->active_inhibitor
- && event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
+ && event->state == WL_KEYBOARD_KEY_STATE_PRESSED
+ && wl_list_empty(&shortcuts_inhibit_mgr->inhibitors))
for (i = 0; i < nsyms; i++)
handled = keybinding(mods, syms[i]) || handled;
@@ -2233,6 +2249,10 @@ setup(void)
(float [4]){0.1, 0.1, 0.1, 1.0});
wlr_scene_node_set_enabled(&locked_bg->node, 0);
+ shortcuts_inhibit_mgr = wlr_keyboard_shortcuts_inhibit_v1_create(dpy);
+ wl_signal_add(&shortcuts_inhibit_mgr->events.new_inhibitor, &new_shortcuts_inhibitor);
+ wl_signal_add(&shortcuts_inhibit_mgr->events.destroy, &shortcuts_inhibit_mgr_destroy);
+
/* Use decoration protocols to negotiate server-side decorations */
wlr_server_decoration_manager_set_default_mode(
wlr_server_decoration_manager_create(dpy),