Dotfiles config update (2022-12-04)
This commit is contained in:
parent
2b7d8ec03c
commit
a2bbdfd909
|
@ -1,6 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd ~/.config/dwl
|
||||
sudo make install clean
|
||||
mkdir -p /etc/root &> /dev/null
|
||||
administrator=$?
|
||||
if [ ${administrator} -eq 0 ] ; then
|
||||
rm -rf /etc/root
|
||||
else
|
||||
echo ""
|
||||
echo "* Administrator permissions are required"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
|
||||
#cd ~/.config/dwl
|
||||
echo "" ; echo "# INSTALLING DWL"
|
||||
echo ""
|
||||
make install clean
|
||||
echo "" ; echo "# INSTALLING SOMEBAR (FOR DWL)"
|
||||
cd somebar
|
||||
sudo ./install.sh
|
||||
./install.sh
|
||||
echo "" ; echo "# INSTALLING BEMENU (FOR DWL)"
|
||||
cd ../menu
|
||||
./build-install.sh
|
||||
echo "" ; echo "# FINISHED" ; echo ""
|
||||
|
|
|
@ -15,7 +15,7 @@ static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0};
|
|||
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
||||
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
static const char *tags[] = { "term", "www", "chat", "files", "media", "game", "mail", "dev", "vm" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* app_id title tags mask isfloating monitor */
|
||||
|
@ -94,7 +94,7 @@ static const double accel_speed = 0.0;
|
|||
|
||||
/* Autostart */
|
||||
static const char *const autostart[] = {
|
||||
"sh", "-c", "swaybg --image /xap/local/background", NULL,
|
||||
"sh", "-c", "bash ~/.config/dwl/autostart.sh", NULL,
|
||||
NULL /* terminate */
|
||||
};
|
||||
|
||||
|
@ -111,8 +111,8 @@ static const char *const autostart[] = {
|
|||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static const char *termcmd[] = { "kitty", NULL };
|
||||
static const char *menucmd[] = { "dmenu_run", NULL };
|
||||
static const char *termcmd[] = { "foot", NULL };
|
||||
static const char *menucmd[] = { "wofi --show run", NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||
|
@ -143,7 +143,7 @@ static const Key keys[] = {
|
|||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, incovgaps, {.i = -1 } },
|
||||
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, killclient, {0} },
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
|
@ -165,7 +165,7 @@ static const Key keys[] = {
|
|||
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
|
||||
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
|
||||
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, quit, {0} },
|
||||
|
||||
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
|
||||
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
static const int sloppyfocus = 1; /* focus follows mouse */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
static const unsigned int gappih = 10; /* horiz inner gap between windows */
|
||||
static const unsigned int gappiv = 10; /* vert inner gap between windows */
|
||||
static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
||||
static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
||||
static const unsigned int gappih = 6; /* horiz inner gap between windows */
|
||||
static const unsigned int gappiv = 6; /* vert inner gap between windows */
|
||||
static const unsigned int gappoh = 6; /* horiz outer gap between windows and screen edge */
|
||||
static const unsigned int gappov = 6; /* vert outer gap between windows and screen edge */
|
||||
static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||
static const int monoclegaps = 0; /* 1 means outer gaps in monocle layout */
|
||||
static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0};
|
||||
|
@ -118,44 +118,49 @@ static const Key keys[] = {
|
|||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_Return, spawn, SHCMD("kitty") },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, SHCMD("wofi --show drun") },
|
||||
{ MODKEY, XKB_KEY_o, spawn, SHCMD("/usr/bin/bemenu_drun") },
|
||||
{ MODKEY, XKB_KEY_p, spawn, SHCMD("/usr/bin/bemenu_run") },
|
||||
{ MODKEY, XKB_KEY_n, spawn, SHCMD("pcmanfm") },
|
||||
{ MODKEY, XKB_KEY_b, spawn, SHCMD("firefox") },
|
||||
{ MODKEY, XKB_KEY_e, spawn, SHCMD("geany") },
|
||||
{ MODKEY, XKB_KEY_m, spawn, SHCMD("telegram") },
|
||||
{ MODKEY, XKB_KEY_u, spawn, SHCMD("kitty") },
|
||||
{ MODKEY, XKB_KEY_a, spawn, SHCMD("lxappearance") },
|
||||
{ MODKEY, XKB_KEY_x, spawn, SHCMD("wdisplays") },
|
||||
{ MODKEY, XKB_KEY_s, spawn, SHCMD("~/.config/dwl/scripts/wayland-screenshot") },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_S, spawn, SHCMD("kitty -e wf-recorder") },
|
||||
{ MODKEY, XKB_KEY_c, spawn, SHCMD("/usr/bin/bemenu_cmd") },
|
||||
{ MODKEY, XKB_KEY_t, spawn, SHCMD("/usr/bin/bemenu_themes") },
|
||||
{ MODKEY, XKB_KEY_f, spawn, SHCMD("/usr/bin/bemenu_fbrun") },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, spawn, SHCMD("/usr/bin/bemenu_close") },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_q, spawn, SHCMD("/usr/bin/bemenu_close") },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_I, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_h, incgaps, {.i = +1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_l, incgaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_L, incogaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_h, incigaps, {.i = +1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_l, incigaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_G, incgaps, {.i = +1 } },
|
||||
{ MODKEY, XKB_KEY_g, incgaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_0, togglegaps, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,defaultgaps, {0} },
|
||||
{ MODKEY, XKB_KEY_y, incihgaps, {.i = +1 } },
|
||||
{ MODKEY, XKB_KEY_o, incihgaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_y, incivgaps, {.i = +1 } },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_o, incivgaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_y, incohgaps, {.i = +1 } },
|
||||
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_o, incohgaps, {.i = -1 } },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y, incovgaps, {.i = +1 } },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, incovgaps, {.i = -1 } },
|
||||
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
/*{ MODKEY, XKB_KEY_Return, zoom, {0} },*/
|
||||
{ MODKEY, XKB_KEY_Tab, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, killclient, {0} },
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Tab, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_T, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_M, setlayout, {.v = &layouts[2]} },
|
||||
/*{ MODKEY, XKB_KEY_space, setlayout, {0} },*/
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_F, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_space, togglefullscreen, {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} },
|
||||
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_comma, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
|
@ -165,7 +170,16 @@ static const Key keys[] = {
|
|||
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
|
||||
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
|
||||
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, quit, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_r, quit, {0} },
|
||||
|
||||
// Volume
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_h, spawn, SHCMD("pactl set-sink-volume @DEFAULT_SINK@ +5%") },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_g, spawn, SHCMD("pactl set-sink-volume @DEFAULT_SINK@ -5%") },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_f, spawn, SHCMD("pactl set-sink-mute @DEFAULT_SINK@ toggle") },
|
||||
|
||||
// Brightness
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_p, spawn, SHCMD("brightnessctl set 10%-") },
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_o, spawn, SHCMD("brightnessctl set 10%+") },
|
||||
|
||||
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
|
||||
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
|
||||
|
|
185
.config/dwl/menu/GNUmakefile
Normal file
185
.config/dwl/menu/GNUmakefile
Normal file
|
@ -0,0 +1,185 @@
|
|||
VERSION ?= $(shell cat VERSION)
|
||||
PREFIX ?= /usr/local
|
||||
includedir ?= /include
|
||||
bindir ?= /bin
|
||||
libdir ?= /lib
|
||||
mandir ?= /share/man/man1
|
||||
PKG_CONFIG ?= pkg-config
|
||||
|
||||
GIT_SHA1 = $(shell git rev-parse HEAD 2>/dev/null || printf 'nogit')
|
||||
GIT_TAG = $(shell git tag --points-at HEAD 2>/dev/null || cat VERSION)
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
WARNINGS = -Wall -Wextra -Wpedantic -Wformat=2 -Wstrict-aliasing=3 -Wstrict-overflow=5 -Wstack-usage=12500 \
|
||||
-Wcast-align -Wpointer-arith -Wchar-subscripts -Warray-bounds=2 -Wno-unknown-warning-option
|
||||
VISIBILITY ?= -fvisibility=hidden
|
||||
|
||||
override CFLAGS ?= -g -O2 $(WARNINGS) $(EXTRA_WARNINGS)
|
||||
override CFLAGS += -std=c99 $(VISIBILITY)
|
||||
override CPPFLAGS ?= -D_FORTIFY_SOURCE=2
|
||||
override CPPFLAGS += -DBM_VERSION=\"$(VERSION)\" -DBM_PLUGIN_VERSION=\"$(VERSION)-$(GIT_SHA1)\" -DINSTALL_LIBDIR=\"$(PREFIX)$(libdir)\"
|
||||
override CPPFLAGS += -D_DEFAULT_SOURCE -Ilib
|
||||
|
||||
libs = libbemenu.so
|
||||
pkgconfigs = bemenu.pc
|
||||
bins = bemenu bemenu-run
|
||||
mans = bemenu.1
|
||||
renderers = bemenu-renderer-x11.so bemenu-renderer-curses.so bemenu-renderer-wayland.so
|
||||
all: $(bins) $(renderers) $(mans)
|
||||
clients: $(bins)
|
||||
curses: bemenu-renderer-curses.so
|
||||
x11: bemenu-renderer-x11.so
|
||||
wayland: bemenu-renderer-wayland.so
|
||||
|
||||
# support non git builds
|
||||
.git/index:
|
||||
mkdir -p .git
|
||||
touch .git/index
|
||||
|
||||
%.a:
|
||||
$(LINK.c) -c $(filter %.c,$^) $(LDLIBS) -o $@
|
||||
|
||||
$(libs): private override full=$(addsuffix .$(VERSION), $@)
|
||||
$(libs): private override major=$(addsuffix .$(firstword $(subst ., ,$(VERSION))), $@)
|
||||
$(libs): %: VERSION .git/index
|
||||
$(LINK.c) -shared -fPIC $(filter %.c %.a,$^) $(LDLIBS) -o $(full) -Wl,-soname,$(major)
|
||||
ln -fs $(full) $(major)
|
||||
ln -fs $(full) $@
|
||||
|
||||
$(pkgconfigs): %: VERSION %.in
|
||||
sed "s/@VERSION@/$(VERSION)/;s,@PREFIX@,$(PREFIX),;s,@LIBDIR@,$(libdir),;s,@INCLUDEDIR@,$(includedir)," $(addsuffix .in, $@) > $@
|
||||
|
||||
bemenu.1: man/bemenu.1.scd.in
|
||||
-sed 's,@LIBDIR@,$(PREFIX)$(libdir),' $< | scdoc > $@
|
||||
|
||||
$(renderers): %: VERSION .git/index | $(libs)
|
||||
$(LINK.c) -shared -fPIC $(filter %.c %.a,$^) $(LDLIBS) -L. -lbemenu -o $@
|
||||
|
||||
$(bins): %: | $(libs)
|
||||
$(LINK.c) $(filter %.c %.a,$^) $(LDLIBS) -L. -lbemenu -o $@
|
||||
|
||||
cdl.a: private override LDFLAGS += -fPIC
|
||||
cdl.a: lib/3rdparty/cdl.c lib/3rdparty/cdl.h
|
||||
|
||||
util.a: private override LDFLAGS += -fPIC
|
||||
util.a: lib/util.c lib/internal.h
|
||||
|
||||
libbemenu.so: private override LDLIBS += -ldl
|
||||
libbemenu.so: lib/bemenu.h lib/internal.h lib/filter.c lib/item.c lib/library.c lib/list.c lib/menu.c lib/vim.c util.a cdl.a
|
||||
|
||||
bemenu-renderer-curses.so: private override LDLIBS += $(shell $(PKG_CONFIG) --libs ncursesw) -lm
|
||||
bemenu-renderer-curses.so: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I ncursesw)
|
||||
bemenu-renderer-curses.so: lib/renderers/curses/curses.c util.a
|
||||
|
||||
bemenu-renderer-x11.so: private override LDLIBS += $(shell $(PKG_CONFIG) --libs x11 xinerama cairo pango pangocairo)
|
||||
bemenu-renderer-x11.so: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I x11 xinerama cairo pango pangocairo)
|
||||
bemenu-renderer-x11.so: lib/renderers/cairo_renderer.h lib/renderers/x11/x11.c lib/renderers/x11/x11.h lib/renderers/x11/window.c lib/renderers/x11/xkb_unicode.c lib/renderers/x11/xkb_unicode.h util.a
|
||||
|
||||
lib/renderers/wayland/xdg-shell.c:
|
||||
wayland-scanner private-code < "$$($(PKG_CONFIG) --variable=pkgdatadir wayland-protocols)/stable/xdg-shell/xdg-shell.xml" > $@
|
||||
|
||||
lib/renderers/wayland/wlr-layer-shell-unstable-v1.h: lib/renderers/wayland/wlr-layer-shell-unstable-v1.xml
|
||||
wayland-scanner client-header < $^ > $@
|
||||
|
||||
lib/renderers/wayland/wlr-layer-shell-unstable-v1.c: lib/renderers/wayland/wlr-layer-shell-unstable-v1.xml
|
||||
wayland-scanner private-code < $^ > $@
|
||||
|
||||
lib/renderers/wayland/xdg-output-unstable-v1.h: lib/renderers/wayland/xdg-output-unstable-v1.xml
|
||||
wayland-scanner client-header < $^ > $@
|
||||
|
||||
lib/renderers/wayland/xdg-output-unstable-v1.c: lib/renderers/wayland/xdg-output-unstable-v1.xml
|
||||
wayland-scanner private-code < $^ > $@
|
||||
|
||||
xdg-shell.a: private override LDFLAGS += -fPIC
|
||||
xdg-shell.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
||||
xdg-shell.a: lib/renderers/wayland/xdg-shell.c
|
||||
wlr-layer-shell.a: private override LDFLAGS += -fPIC
|
||||
wlr-layer-shell.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
||||
wlr-layer-shell.a: lib/renderers/wayland/wlr-layer-shell-unstable-v1.c lib/renderers/wayland/wlr-layer-shell-unstable-v1.h
|
||||
xdg-output.a: private override LDFLAGS += -fPIC
|
||||
xdg-output.a: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client)
|
||||
xdg-output.a: lib/renderers/wayland/xdg-output-unstable-v1.c lib/renderers/wayland/xdg-output-unstable-v1.h
|
||||
bemenu-renderer-wayland.so: private override LDLIBS += $(shell $(PKG_CONFIG) --libs wayland-client cairo pango pangocairo xkbcommon)
|
||||
bemenu-renderer-wayland.so: private override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I wayland-client cairo pango pangocairo xkbcommon)
|
||||
bemenu-renderer-wayland.so: lib/renderers/cairo_renderer.h lib/renderers/wayland/wayland.c lib/renderers/wayland/wayland.h lib/renderers/wayland/registry.c lib/renderers/wayland/window.c xdg-shell.a wlr-layer-shell.a xdg-output.a util.a
|
||||
|
||||
common.a: client/common/common.c client/common/common.h
|
||||
bemenu: common.a client/bemenu.c
|
||||
bemenu-run: common.a client/bemenu-run.c
|
||||
|
||||
install-pkgconfig: $(pkgconfigs)
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/pkgconfig"
|
||||
cp $^ "$(DESTDIR)$(PREFIX)$(libdir)/pkgconfig"
|
||||
|
||||
install-include: lib/bemenu.h
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(includedir)"
|
||||
cp $^ "$(DESTDIR)$(PREFIX)$(includedir)"
|
||||
|
||||
install-libs: $(libs)
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)"
|
||||
cp $(addsuffix .$(VERSION), $^) "$(DESTDIR)$(PREFIX)$(libdir)"
|
||||
|
||||
install-lib-symlinks: $(libs) | install-libs
|
||||
cp -RP $^ $(addsuffix .$(firstword $(subst ., ,$(VERSION))), $^) "$(DESTDIR)$(PREFIX)$(libdir)"
|
||||
|
||||
install-bins:
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(bindir)"
|
||||
-cp $(bins) "$(DESTDIR)$(PREFIX)$(bindir)"
|
||||
-chmod 0755 $(addprefix "$(DESTDIR)$(PREFIX)$(bindir)"/,$(bins))
|
||||
|
||||
install-man: bemenu.1
|
||||
-hash scdoc && mkdir -p "$(DESTDIR)$(PREFIX)$(mandir)"
|
||||
-hash scdoc && cp $< "$(DESTDIR)$(PREFIX)$(mandir)"
|
||||
|
||||
install-renderers: install-curses install-wayland install-x11
|
||||
|
||||
install-curses:
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
-cp bemenu-renderer-curses.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
|
||||
install-wayland:
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
-cp bemenu-renderer-wayland.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
|
||||
install-x11:
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
-cp bemenu-renderer-x11.so "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
|
||||
install-docs: install-man
|
||||
|
||||
install-base: install-pkgconfig install-include install-lib-symlinks install-bins
|
||||
|
||||
install: install-base install-renderers install-docs
|
||||
@echo "Install OK!"
|
||||
|
||||
doxygen:
|
||||
BM_VERSION=$(VERSION) doxygen doxygen/Doxyfile
|
||||
cp -R doxygen/doxygen-qmi-style/navtree html
|
||||
cp -R doxygen/doxygen-qmi-style/search html/search
|
||||
|
||||
sign:
|
||||
test "x$(GIT_TAG)" = "x$(VERSION)"
|
||||
git archive --prefix="bemenu-$(VERSION)/" -o "bemenu-$(VERSION).tar.gz" "$(GIT_TAG)"
|
||||
gpg --default-key "$(GPG_KEY_ID)" --armor --detach-sign "bemenu-$(VERSION).tar.gz"
|
||||
|
||||
check-symbols: libbemenu.so lib/bemenu.h
|
||||
sh scripts/check-symbols.sh $^ bemenu-renderer-*.so
|
||||
|
||||
clean:
|
||||
$(RM) -r *.dSYM # OSX generates .dSYM dirs with -g ...
|
||||
$(RM) $(pkgconfigs) $(libs) $(bins) $(renderers) $(mans) *.a *.so.*
|
||||
$(RM) lib/renderers/wayland/wlr-*.h lib/renderers/wayland/wlr-*.c lib/renderers/wayland/xdg-shell.c
|
||||
$(RM) -r html
|
||||
|
||||
uninstall:
|
||||
$(RM) -r "$(DESTDIR)$(PREFIX)$(libdir)/bemenu"
|
||||
$(RM) "$(DESTDIR)$(PREFIX)$(mandir)/bemenu.1"
|
||||
$(RM) "$(DESTDIR)$(PREFIX)$(bindir)/bemenu"
|
||||
$(RM) "$(DESTDIR)$(PREFIX)$(bindir)/bemenu-run"
|
||||
$(RM) "$(DESTDIR)$(PREFIX)$(libdir)"/libbemenu.so*
|
||||
$(RM) "$(DESTDIR)$(PREFIX)$(includedir)/bemenu.h"
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
.PHONY: all clean uninstall install install-base install-pkgconfig install-include install-libs install-lib-symlinks \
|
||||
install-man install-bins install-docs install-renderers install-curses install-wayland install-x11 \
|
||||
doxygen sign check-symbols clients curses x11 wayland
|
674
.config/dwl/menu/LICENSE-CLIENT
Normal file
674
.config/dwl/menu/LICENSE-CLIENT
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
165
.config/dwl/menu/LICENSE-LIB
Normal file
165
.config/dwl/menu/LICENSE-LIB
Normal file
|
@ -0,0 +1,165 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
1
.config/dwl/menu/VERSION
Normal file
1
.config/dwl/menu/VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
0.6.13
|
9
.config/dwl/menu/bemenu.pc.in
Normal file
9
.config/dwl/menu/bemenu.pc.in
Normal file
|
@ -0,0 +1,9 @@
|
|||
prefix=@PREFIX@
|
||||
libdir=${prefix}@LIBDIR@
|
||||
includedir=${prefix}@INCLUDEDIR@
|
||||
|
||||
Name: bemenu
|
||||
Description: Dynamic menu library
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lbemenu
|
||||
Cflags: -I${includedir}
|
10
.config/dwl/menu/build-install.sh
Executable file
10
.config/dwl/menu/build-install.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
make clients x11 wayland curses
|
||||
mv -v bemenu bemenu-renderer
|
||||
cp -rf scripts/bemenu bemenu
|
||||
make install PREFIX=/usr
|
||||
cp -rfv bemenu-renderer /usr/bin
|
||||
rm -rfv bemenu-renderer
|
||||
make clean
|
||||
cp -rfv scripts/bemenu_* /usr/bin/
|
192
.config/dwl/menu/client/bemenu-run.c
Normal file
192
.config/dwl/menu/client/bemenu-run.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <assert.h>
|
||||
#include "common/common.h"
|
||||
|
||||
static struct client client = {
|
||||
.filter_mode = BM_FILTER_MODE_DMENU,
|
||||
.title = "bemenu-run",
|
||||
.monitor = -1,
|
||||
};
|
||||
|
||||
struct paths {
|
||||
char *path;
|
||||
char *paths;
|
||||
};
|
||||
|
||||
static char*
|
||||
c_strdup(const char *str)
|
||||
{
|
||||
return cstrcopy(str, strlen(str));
|
||||
}
|
||||
|
||||
static char*
|
||||
strip_slash(char *str)
|
||||
{
|
||||
size_t size = strlen(str);
|
||||
if (size > 0)
|
||||
for (char *s = str + size - 1; *s == '/'; --s)
|
||||
*s = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
static const char*
|
||||
get_paths(const char *env, const char *default_paths, struct paths *state)
|
||||
{
|
||||
if (state->path && !*state->path) {
|
||||
free(state->paths);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!state->paths) {
|
||||
const char *paths;
|
||||
if (!(paths = getenv(env)) || !paths[0])
|
||||
paths = default_paths;
|
||||
|
||||
state->path = state->paths = c_strdup(paths);
|
||||
}
|
||||
|
||||
if (!state->path || !state->paths)
|
||||
return NULL;
|
||||
|
||||
char *path;
|
||||
do {
|
||||
size_t f;
|
||||
path = state->path;
|
||||
if ((f = strcspn(state->path, ":")) > 0) {
|
||||
state->path += f + (path[f] ? 1 : 0);
|
||||
path[f] = 0;
|
||||
} else {
|
||||
state->path += 1;
|
||||
}
|
||||
|
||||
if (!*path) {
|
||||
free(state->paths);
|
||||
return NULL;
|
||||
}
|
||||
} while (path[0] != '/');
|
||||
|
||||
return strip_slash(path);
|
||||
}
|
||||
|
||||
static int
|
||||
compare(const void *a, const void *b)
|
||||
{
|
||||
const struct bm_item *ia = *(struct bm_item**)a, *ib = *(struct bm_item**)b;
|
||||
return strcmp(bm_item_get_text(ia), bm_item_get_text(ib));
|
||||
}
|
||||
|
||||
static void
|
||||
read_items_to_menu_from_dir(struct bm_menu *menu, const char *path)
|
||||
{
|
||||
assert(menu && path);
|
||||
|
||||
DIR *dir;
|
||||
if (!(dir = opendir(path)))
|
||||
return;
|
||||
|
||||
struct dirent *file;
|
||||
while ((file = readdir(dir))) {
|
||||
if (file->d_type != DT_DIR && strlen(file->d_name) && file->d_name[0] != '.') {
|
||||
struct bm_item *item;
|
||||
if (!(item = bm_item_new(file->d_name)))
|
||||
break;
|
||||
|
||||
bm_menu_add_item(menu, item);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
uint32_t count;
|
||||
struct bm_item **items = bm_menu_get_items(menu, &count);
|
||||
qsort(items, count, sizeof(struct bm_item*), compare);
|
||||
|
||||
bool unique = true;
|
||||
for (uint32_t i = 0; i + 1 < count; i += unique) {
|
||||
if (!(unique = strcmp(bm_item_get_text(items[i]), bm_item_get_text(items[i + 1])))) {
|
||||
bm_item_free(items[i]);
|
||||
bm_menu_remove_item_at(menu, i);
|
||||
items = bm_menu_get_items(menu, &count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
read_items_to_menu_from_path(struct bm_menu *menu)
|
||||
{
|
||||
assert(menu);
|
||||
|
||||
const char *path;
|
||||
struct paths state;
|
||||
memset(&state, 0, sizeof(state));
|
||||
while ((path = get_paths("PATH", "/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin", &state)))
|
||||
read_items_to_menu_from_dir(menu, path);
|
||||
}
|
||||
|
||||
static inline void ignore_ret(int useless, ...) { (void)useless; }
|
||||
|
||||
static void
|
||||
launch(const struct client *client, const char *bin)
|
||||
{
|
||||
if (!bin)
|
||||
return;
|
||||
|
||||
if (!client->fork || fork() == 0) {
|
||||
if (client->fork) {
|
||||
setsid();
|
||||
ignore_ret(0, freopen("/dev/null", "w", stdout));
|
||||
ignore_ret(0, freopen("/dev/null", "w", stderr));
|
||||
}
|
||||
|
||||
char **tokens;
|
||||
if (!(tokens = tokenize_quoted_to_argv(bin, NULL, NULL)))
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
execvp(tokens[0], tokens);
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
item_cb(const struct client *client, struct bm_item *item)
|
||||
{
|
||||
if (client->no_exec) {
|
||||
const char *text = bm_item_get_text(item);
|
||||
printf("%s\n", (text ? text : ""));
|
||||
} else {
|
||||
launch(client, bm_item_get_text(item));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct sigaction action = {
|
||||
.sa_handler = SIG_DFL,
|
||||
.sa_flags = SA_NOCLDWAIT
|
||||
};
|
||||
|
||||
// do not care about childs
|
||||
sigaction(SIGCHLD, &action, NULL);
|
||||
|
||||
if (!bm_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
parse_args(&client, &argc, &argv);
|
||||
|
||||
struct bm_menu *menu;
|
||||
if (!(menu = menu_with_options(&client)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
read_items_to_menu_from_path(menu);
|
||||
const enum bm_run_result status = run_menu(&client, menu, item_cb);
|
||||
bm_menu_free(menu);
|
||||
return (status == BM_RUN_RESULT_SELECTED ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
84
.config/dwl/menu/client/bemenu.c
Normal file
84
.config/dwl/menu/client/bemenu.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "common/common.h"
|
||||
|
||||
static struct client client = {
|
||||
.filter_mode = BM_FILTER_MODE_DMENU,
|
||||
.title = "bemenu",
|
||||
.monitor = -1,
|
||||
};
|
||||
|
||||
static void
|
||||
read_items_to_menu_from_stdin(struct bm_menu *menu)
|
||||
{
|
||||
assert(menu);
|
||||
|
||||
ssize_t n;
|
||||
size_t llen = 0;
|
||||
char *line = NULL;
|
||||
|
||||
while ((n = getline(&line, &llen, stdin)) > 0) {
|
||||
// Remove trailing newline (if any)
|
||||
if (line[n - 1] == '\n')
|
||||
line[n - 1] = '\0';
|
||||
|
||||
struct bm_item *item;
|
||||
if (!(item = bm_item_new(line)))
|
||||
break;
|
||||
|
||||
bm_menu_add_item(menu, item);
|
||||
}
|
||||
free(line);
|
||||
|
||||
if (ferror(stdin)) {
|
||||
fprintf(stderr, "getline failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
item_cb(const struct client *client, struct bm_item *item)
|
||||
{
|
||||
(void)client;
|
||||
const char *text = bm_item_get_text(item);
|
||||
printf("%s\n", (text ? text : ""));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (!bm_init())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
parse_args(&client, &argc, &argv);
|
||||
|
||||
struct bm_menu *menu;
|
||||
if (!(menu = menu_with_options(&client)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
read_items_to_menu_from_stdin(menu);
|
||||
const enum bm_run_result status = run_menu(&client, menu, item_cb);
|
||||
bm_menu_free(menu);
|
||||
switch (status) {
|
||||
case BM_RUN_RESULT_SELECTED:
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
case BM_RUN_RESULT_CUSTOM_1: return 10;
|
||||
case BM_RUN_RESULT_CUSTOM_2: return 11;
|
||||
case BM_RUN_RESULT_CUSTOM_3: return 12;
|
||||
case BM_RUN_RESULT_CUSTOM_4: return 13;
|
||||
case BM_RUN_RESULT_CUSTOM_5: return 14;
|
||||
case BM_RUN_RESULT_CUSTOM_6: return 15;
|
||||
case BM_RUN_RESULT_CUSTOM_7: return 16;
|
||||
case BM_RUN_RESULT_CUSTOM_8: return 17;
|
||||
case BM_RUN_RESULT_CUSTOM_9: return 18;
|
||||
case BM_RUN_RESULT_CUSTOM_10: return 19;
|
||||
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
636
.config/dwl/menu/client/common/common.c
Normal file
636
.config/dwl/menu/client/common/common.c
Normal file
|
@ -0,0 +1,636 @@
|
|||
#include "internal.h"
|
||||
|
||||
#include "common.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <assert.h>
|
||||
|
||||
static void
|
||||
disco_trap(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
fprintf(stderr, "\x1B[?25h");
|
||||
fflush(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void
|
||||
disco(void)
|
||||
{
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(struct sigaction));
|
||||
action.sa_handler = disco_trap;
|
||||
sigaction(SIGABRT, &action, NULL);
|
||||
sigaction(SIGSEGV, &action, NULL);
|
||||
sigaction(SIGTRAP, &action, NULL);
|
||||
sigaction(SIGINT, &action, NULL);
|
||||
|
||||
uint32_t cc, c = 80;
|
||||
fprintf(stderr, "\x1B[?25l");
|
||||
while (1) {
|
||||
for (uint32_t i = 1; i < c - 1; ++i) {
|
||||
fprintf(stderr, "\r %*s%s %s %s ", (i > c / 2 ? c - i : i), " ", ((i % 2) ? "<o/" : "\\o>"), ((i % 4) ? "DISCO" : " "), ((i %2) ? "\\o>" : "<o/"));
|
||||
for (cc = 0; cc < (i < c / 2 ? c / 2 - i : i - c / 2); ++cc) fprintf(stderr, ((i % 2) ? "^" : "'"));
|
||||
fprintf(stderr, "%s %s \r %s %s", ((i % 2) ? "*" : "•"), ((i % 3) ? "\\o" : "<o"), ((i % 3) ? "o/" : "o>"), ((i % 2) ? "*" : "•"));
|
||||
for (cc = 2; cc < (i > c / 2 ? c - i : i); ++cc) fprintf(stderr, ((i % 2) ? "^" : "'"));
|
||||
fflush(stderr);
|
||||
usleep(140 * 1000);
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\x1B[?25h");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#define WHITESPACE " \t\n\r"
|
||||
|
||||
static const char*
|
||||
tokenize(const char *cstr, size_t *out_len, const char *separator, bool skip_whitespace, const char **state)
|
||||
{
|
||||
assert(out_len && separator && state);
|
||||
const char *current = (state && *state ? *state : cstr);
|
||||
|
||||
if (!current || !*current || !cstr || !*cstr)
|
||||
return NULL;
|
||||
|
||||
current += strspn(current, separator);
|
||||
|
||||
if (skip_whitespace)
|
||||
current += strspn(current, WHITESPACE);
|
||||
|
||||
*out_len = strcspn(current, separator);
|
||||
*state = current + *out_len;
|
||||
|
||||
if (skip_whitespace) {
|
||||
const size_t ws = strcspn(current, WHITESPACE);
|
||||
*out_len -= (ws < *out_len ? *out_len - ws : 0);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
static const char*
|
||||
tokenize_quoted(const char *cstr, size_t *out_len, const char *separator, const char *quotes, const char **state)
|
||||
{
|
||||
assert(out_len && separator && quotes && state);
|
||||
const char *e, *current = tokenize(cstr, out_len, separator, true, state);
|
||||
|
||||
if (!current)
|
||||
return NULL;
|
||||
|
||||
for (const char *q = quotes; *q; ++q) {
|
||||
if (*current != *q)
|
||||
continue;
|
||||
|
||||
bool escaped = false;
|
||||
for (e = ++current; *e; ++e) {
|
||||
if (escaped)
|
||||
escaped = false;
|
||||
else if (*e == '\\')
|
||||
escaped = true;
|
||||
else if (*e == *q)
|
||||
break;
|
||||
}
|
||||
|
||||
*out_len = e - current;
|
||||
e = (!*e ? e : e + 1);
|
||||
|
||||
if (*e) {
|
||||
size_t tmp;
|
||||
const char *state2 = NULL;
|
||||
*state = tokenize(e, &tmp, separator, true, &state2);
|
||||
} else {
|
||||
*state = e;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
char*
|
||||
cstrcopy(const char *str, size_t size)
|
||||
{
|
||||
char *cpy = calloc(1, size + 1);
|
||||
return (cpy ? memcpy(cpy, str, size) : NULL);
|
||||
}
|
||||
|
||||
char**
|
||||
tokenize_quoted_to_argv(const char *str, char *argv0, int *out_argc)
|
||||
{
|
||||
if (out_argc) *out_argc = 0;
|
||||
|
||||
size_t count = !!argv0;
|
||||
{
|
||||
size_t len;
|
||||
const char *state = NULL;
|
||||
while (tokenize_quoted(str, &len, " ", "\"'", &state))
|
||||
++count;
|
||||
}
|
||||
|
||||
char **tokens;
|
||||
if (!count || !(tokens = calloc(count + 1, sizeof(char*))))
|
||||
return NULL;
|
||||
|
||||
{
|
||||
tokens[0] = argv0;
|
||||
size_t i = !!argv0, len;
|
||||
const char *t, *state = NULL;
|
||||
while (i < count && (t = tokenize_quoted(str, &len, " ", "\"'", &state))) {
|
||||
if (!(tokens[i++] = cstrcopy(t, len)))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (out_argc) *out_argc = count;
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static void
|
||||
version(const char *name)
|
||||
{
|
||||
assert(name);
|
||||
char *base = strrchr(name, '/');
|
||||
printf("%s v%s\n", (base ? base + 1 : name), bm_version());
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(FILE *out, const char *name)
|
||||
{
|
||||
assert(out && name);
|
||||
|
||||
char *base = strrchr(name, '/');
|
||||
fprintf(out, "usage: %s [options]\n", (base ? base + 1 : name));
|
||||
fputs("Options\n"
|
||||
" -h, --help display this help and exit.\n"
|
||||
" -v, --version display version.\n"
|
||||
" -i, --ignorecase match items case insensitively.\n"
|
||||
" -F, --filter filter entries for a given string.\n"
|
||||
" -w, --wrap wraps cursor selection.\n"
|
||||
" -l, --list list items vertically with the given number of lines.\n"
|
||||
" -p, --prompt defines the prompt text to be displayed.\n"
|
||||
" -P, --prefix text to show before highlighted item.\n"
|
||||
" -I, --index select item at index automatically.\n"
|
||||
" -x, --password hide input.\n"
|
||||
" -s, --no-spacing disable the title spacing on entries.\n"
|
||||
" -C, --no-cursor ignore cursor events.\n"
|
||||
" -T, --no-touch ignore touch events.\n"
|
||||
" -K, --no-keyboard ignore keyboard events.\n"
|
||||
" --binding use alternative key bindings. Available options: vim\n"
|
||||
" --scrollbar display scrollbar. (none (default), always, autohide)\n"
|
||||
" --accept-single immediately return if there is only one item.\n"
|
||||
" --ifne only display menu if there are items.\n"
|
||||
" --fork always fork. (bemenu-run)\n"
|
||||
" --no-exec do not execute command. (bemenu-run)\n\n"
|
||||
|
||||
"Use BEMENU_BACKEND env variable to force backend:\n"
|
||||
" curses ncurses based terminal backend\n"
|
||||
" wayland wayland backend\n"
|
||||
" x11 x11 backend\n\n"
|
||||
|
||||
"If BEMENU_BACKEND is empty, one of the GUI backends is selected automatically.\n\n"
|
||||
|
||||
"Backend specific options\n"
|
||||
" c = ncurses, w == wayland, x == x11\n"
|
||||
" (...) At end of help indicates the backend support for option.\n\n"
|
||||
|
||||
" -b, --bottom appears at the bottom of the screen. (wx)\n"
|
||||
" -c, --center appears at the center of the screen. (wx)\n"
|
||||
" -f, --grab show the menu before reading stdin. (wx)\n"
|
||||
" -n, --no-overlap adjust geometry to not overlap with panels. (w)\n"
|
||||
" -m, --monitor index of monitor where menu will appear. (wx)\n"
|
||||
" -H, --line-height defines the height to make each menu line (0 = default height). (wx)\n"
|
||||
" -M, --margin defines the empty space on either side of the menu. (wx)\n"
|
||||
" -W, --width-factor defines the relative width factor of the menu (from 0 to 1). (wx)\n"
|
||||
" -B, --border defines the width of the border in pixels around the menu. (wx)\n"
|
||||
" --ch defines the height of the cursor (0 = scales with line height). (wx)\n"
|
||||
" --cw defines the width of the cursor. (wx)\n"
|
||||
" --hp defines the horizontal padding for the entries in single line mode. (wx)\n"
|
||||
" --fn defines the font to be used ('name [size]'). (wx)\n"
|
||||
" --tb defines the title background color. (wx)\n"
|
||||
" --tf defines the title foreground color. (wx)\n"
|
||||
" --fb defines the filter background color. (wx)\n"
|
||||
" --ff defines the filter foreground color. (wx)\n"
|
||||
" --nb defines the normal background color. (wx)\n"
|
||||
" --nf defines the normal foreground color. (wx)\n"
|
||||
" --hb defines the highlighted background color. (wx)\n"
|
||||
" --hf defines the highlighted foreground color. (wx)\n"
|
||||
" --fbb defines the feedback background color. (wx)\n"
|
||||
" --fbf defines the feedback foreground color. (wx)\n"
|
||||
" --sb defines the selected background color. (wx)\n"
|
||||
" --sf defines the selected foreground color. (wx)\n"
|
||||
" --ab defines the alternating background color. (wx)\n"
|
||||
" --af defines the alternating foreground color. (wx)\n"
|
||||
" --scb defines the scrollbar background color. (wx)\n"
|
||||
" --scf defines the scrollbar foreground color. (wx)\n"
|
||||
" --bdr defines the border color. (wx)\n", out);
|
||||
|
||||
exit((out == stderr ? EXIT_FAILURE : EXIT_SUCCESS));
|
||||
}
|
||||
|
||||
static void
|
||||
set_monitor(struct client *client, char *arg)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
long num = strtol(arg, &endptr, 10);
|
||||
if (arg == endptr) { // No digits found
|
||||
if (!strcmp(arg, "focused")) {
|
||||
client->monitor = -1;
|
||||
} else if (!strcmp(arg, "all")) {
|
||||
client->monitor = -2;
|
||||
} else {
|
||||
client->monitor_name = arg;
|
||||
}
|
||||
} else {
|
||||
client->monitor = num;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_getopt(struct client *client, int *argc, char **argv[])
|
||||
{
|
||||
assert(client && argc && argv);
|
||||
|
||||
static const struct option opts[] = {
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "version", no_argument, 0, 'v' },
|
||||
|
||||
{ "ignorecase", no_argument, 0, 'i' },
|
||||
{ "filter", required_argument, 0, 'F' },
|
||||
{ "wrap", no_argument, 0, 'w' },
|
||||
{ "list", required_argument, 0, 'l' },
|
||||
{ "center", no_argument, 0, 'c' },
|
||||
{ "prompt", required_argument, 0, 'p' },
|
||||
{ "index", required_argument, 0, 'I' },
|
||||
{ "prefix", required_argument, 0, 'P' },
|
||||
{ "password", no_argument, 0, 'x' },
|
||||
{ "scrollbar", required_argument, 0, 0x100 },
|
||||
{ "accept-single",no_argument, 0, 0x11a },
|
||||
{ "ifne", no_argument, 0, 0x117 },
|
||||
{ "fork", no_argument, 0, 0x118 },
|
||||
{ "no-exec", no_argument, 0, 0x119 },
|
||||
{ "bottom", no_argument, 0, 'b' },
|
||||
{ "grab", no_argument, 0, 'f' },
|
||||
{ "no-overlap", no_argument, 0, 'n' },
|
||||
{ "no-spacing", no_argument, 0, 's' },
|
||||
{ "no-cursor", no_argument, 0, 'C' },
|
||||
{ "no-touch", no_argument, 0, 'T' },
|
||||
{ "no-keyboard", no_argument, 0, 'K' },
|
||||
{ "monitor", required_argument, 0, 'm' },
|
||||
{ "line-height", required_argument, 0, 'H' },
|
||||
{ "margin", required_argument, 0, 'M' },
|
||||
{ "width-factor", required_argument, 0, 'W' },
|
||||
{ "border", required_argument, 0, 'B' },
|
||||
{ "ch", required_argument, 0, 0x120 },
|
||||
{ "cw", required_argument, 0, 0x125 },
|
||||
{ "hp", required_argument, 0, 0x122 },
|
||||
{ "fn", required_argument, 0, 0x101 },
|
||||
{ "tb", required_argument, 0, 0x102 },
|
||||
{ "tf", required_argument, 0, 0x103 },
|
||||
{ "fb", required_argument, 0, 0x104 },
|
||||
{ "ff", required_argument, 0, 0x105 },
|
||||
{ "cb", required_argument, 0, 0x126 },
|
||||
{ "cf", required_argument, 0, 0x127 },
|
||||
{ "nb", required_argument, 0, 0x106 },
|
||||
{ "nf", required_argument, 0, 0x107 },
|
||||
{ "hb", required_argument, 0, 0x108 },
|
||||
{ "hf", required_argument, 0, 0x109 },
|
||||
{ "fbb", required_argument, 0, 0x110 },
|
||||
{ "fbf", required_argument, 0, 0x111 },
|
||||
{ "sb", required_argument, 0, 0x112 },
|
||||
{ "sf", required_argument, 0, 0x113 },
|
||||
{ "ab", required_argument, 0, 0x123 },
|
||||
{ "af", required_argument, 0, 0x124 },
|
||||
{ "scb", required_argument, 0, 0x114 },
|
||||
{ "scf", required_argument, 0, 0x115 },
|
||||
{ "bdr", required_argument, 0, 0x121 },
|
||||
{ "binding", required_argument, 0, 0x128 },
|
||||
|
||||
{ "disco", no_argument, 0, 0x116 },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/* TODO: getopt does not support -sf, -sb etc..
|
||||
* Either break the interface and make them --sf, --sb (like they are now),
|
||||
* or parse them before running getopt.. */
|
||||
|
||||
for (optind = 0;;) {
|
||||
int32_t opt;
|
||||
|
||||
if ((opt = getopt_long(*argc, *argv, "hviwxcl:I:p:P:I:bfm:H:M:W:B:nsCTK", opts, NULL)) < 0)
|
||||
break;
|
||||
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
usage(stdout, *argv[0]);
|
||||
break;
|
||||
case 'v':
|
||||
version(*argv[0]);
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
client->filter_mode = BM_FILTER_MODE_DMENU_CASE_INSENSITIVE;
|
||||
break;
|
||||
case 'F':
|
||||
client->initial_filter = optarg;
|
||||
break;
|
||||
case 'w':
|
||||
client->wrap = true;
|
||||
break;
|
||||
case 'l':
|
||||
client->lines = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 'c':
|
||||
client->center = true;
|
||||
break;
|
||||
case 'p':
|
||||
client->title = optarg;
|
||||
break;
|
||||
case 'P':
|
||||
client->prefix = optarg;
|
||||
break;
|
||||
case 'I':
|
||||
client->selected = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 0x100:
|
||||
client->scrollbar = (!strcmp(optarg, "none") ? BM_SCROLLBAR_NONE : (!strcmp(optarg, "always") ? BM_SCROLLBAR_ALWAYS : (!strcmp(optarg, "autohide") ? BM_SCROLLBAR_AUTOHIDE : BM_SCROLLBAR_NONE)));
|
||||
break;
|
||||
case 0x11a:
|
||||
client->accept_single = true;
|
||||
break;
|
||||
case 0x117:
|
||||
client->ifne = true;
|
||||
break;
|
||||
case 0x118:
|
||||
client->force_fork = true;
|
||||
break;
|
||||
case 0x119:
|
||||
client->no_exec = true;
|
||||
break;
|
||||
case 'x':
|
||||
client->password = true;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
client->bottom = true;
|
||||
break;
|
||||
case 'f':
|
||||
client->grab = true;
|
||||
break;
|
||||
case 'm':
|
||||
set_monitor(client, optarg);
|
||||
break;
|
||||
case 'n':
|
||||
client->no_overlap = true;
|
||||
break;
|
||||
case 's':
|
||||
client->no_spacing = true;
|
||||
break;
|
||||
case 'C':
|
||||
client->no_cursor = true;
|
||||
break;
|
||||
case 'T':
|
||||
client->no_touch = true;
|
||||
break;
|
||||
case 'K':
|
||||
client->no_keyboard = true;
|
||||
break;
|
||||
case 'H':
|
||||
client->line_height = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 'M':
|
||||
client->hmargin_size = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 'W':
|
||||
client->width_factor = strtof(optarg, NULL);
|
||||
break;
|
||||
case 'B':
|
||||
client->border_size = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 0x120:
|
||||
client->cursor_height = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 0x125:
|
||||
client->cursor_width = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 0x122:
|
||||
client->hpadding = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
case 0x101:
|
||||
client->font = optarg;
|
||||
break;
|
||||
case 0x102:
|
||||
client->colors[BM_COLOR_TITLE_BG] = optarg;
|
||||
break;
|
||||
case 0x103:
|
||||
client->colors[BM_COLOR_TITLE_FG] = optarg;
|
||||
break;
|
||||
case 0x104:
|
||||
client->colors[BM_COLOR_FILTER_BG] = optarg;
|
||||
break;
|
||||
case 0x105:
|
||||
client->colors[BM_COLOR_FILTER_FG] = optarg;
|
||||
break;
|
||||
case 0x126:
|
||||
client->colors[BM_COLOR_CURSOR_BG] = optarg;
|
||||
break;
|
||||
case 0x127:
|
||||
client->colors[BM_COLOR_CURSOR_FG] = optarg;
|
||||
break;
|
||||
case 0x106:
|
||||
client->colors[BM_COLOR_ITEM_BG] = optarg;
|
||||
break;
|
||||
case 0x107:
|
||||
client->colors[BM_COLOR_ITEM_FG] = optarg;
|
||||
break;
|
||||
case 0x108:
|
||||
client->colors[BM_COLOR_HIGHLIGHTED_BG] = optarg;
|
||||
break;
|
||||
case 0x109:
|
||||
client->colors[BM_COLOR_HIGHLIGHTED_FG] = optarg;
|
||||
break;
|
||||
case 0x110:
|
||||
client->colors[BM_COLOR_FEEDBACK_BG] = optarg;
|
||||
break;
|
||||
case 0x111:
|
||||
client->colors[BM_COLOR_FEEDBACK_FG] = optarg;
|
||||
break;
|
||||
case 0x112:
|
||||
client->colors[BM_COLOR_SELECTED_BG] = optarg;
|
||||
break;
|
||||
case 0x113:
|
||||
client->colors[BM_COLOR_SELECTED_FG] = optarg;
|
||||
break;
|
||||
case 0x123:
|
||||
client->colors[BM_COLOR_ALTERNATE_BG] = optarg;
|
||||
break;
|
||||
case 0x124:
|
||||
client->colors[BM_COLOR_ALTERNATE_FG] = optarg;
|
||||
break;
|
||||
case 0x114:
|
||||
client->colors[BM_COLOR_SCROLLBAR_BG] = optarg;
|
||||
break;
|
||||
case 0x115:
|
||||
client->colors[BM_COLOR_SCROLLBAR_FG] = optarg;
|
||||
break;
|
||||
case 0x121:
|
||||
client->colors[BM_COLOR_BORDER] = optarg;
|
||||
break;
|
||||
case 0x128:
|
||||
if(strcmp(optarg, "vim") == 0){
|
||||
client->key_binding = BM_KEY_BINDING_VIM;
|
||||
} else {
|
||||
client->key_binding = BM_KEY_BINDING_DEFAULT;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x116:
|
||||
disco();
|
||||
break;
|
||||
|
||||
case ':':
|
||||
case '?':
|
||||
fputs("\n", stderr);
|
||||
usage(stderr, *argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*argc -= optind;
|
||||
*argv += optind;
|
||||
}
|
||||
|
||||
void
|
||||
parse_args(struct client *client, int *argc, char **argv[])
|
||||
{
|
||||
int num_opts;
|
||||
char **opts;
|
||||
const char *env;
|
||||
if ((env = getenv("BEMENU_OPTS")) && (opts = tokenize_quoted_to_argv(env, (*argv)[0], &num_opts)))
|
||||
do_getopt(client, &num_opts, &opts);
|
||||
do_getopt(client, argc, argv);
|
||||
}
|
||||
|
||||
struct bm_menu*
|
||||
menu_with_options(struct client *client)
|
||||
{
|
||||
struct bm_menu *menu;
|
||||
if (!(menu = bm_menu_new(NULL)))
|
||||
return NULL;
|
||||
|
||||
client->fork = (client->force_fork || (bm_renderer_get_priorty(bm_menu_get_renderer(menu)) != BM_PRIO_TERMINAL));
|
||||
|
||||
bm_menu_set_font(menu, client->font);
|
||||
bm_menu_set_line_height(menu, client->line_height);
|
||||
bm_menu_set_cursor_height(menu, client->cursor_height);
|
||||
bm_menu_set_cursor_width(menu, client->cursor_width);
|
||||
bm_menu_set_hpadding(menu, client->hpadding);
|
||||
bm_menu_set_title(menu, client->title);
|
||||
bm_menu_set_prefix(menu, client->prefix);
|
||||
bm_menu_set_filter_mode(menu, client->filter_mode);
|
||||
bm_menu_set_lines(menu, client->lines);
|
||||
bm_menu_set_wrap(menu, client->wrap);
|
||||
bm_menu_set_monitor(menu, client->monitor);
|
||||
bm_menu_set_monitor_name(menu, client->monitor_name);
|
||||
bm_menu_set_scrollbar(menu, client->scrollbar);
|
||||
bm_menu_set_panel_overlap(menu, !client->no_overlap);
|
||||
bm_menu_set_spacing(menu, !client->no_spacing);
|
||||
bm_menu_set_password(menu, client->password);
|
||||
bm_menu_set_width(menu, client->hmargin_size, client->width_factor);
|
||||
bm_menu_set_border_size(menu, client->border_size);
|
||||
bm_menu_set_key_binding(menu, client->key_binding);
|
||||
|
||||
if (client->center) {
|
||||
bm_menu_set_align(menu, BM_ALIGN_CENTER);
|
||||
} else if (client->bottom) {
|
||||
bm_menu_set_align(menu, BM_ALIGN_BOTTOM);
|
||||
} else {
|
||||
bm_menu_set_align(menu, BM_ALIGN_TOP);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < BM_COLOR_LAST; ++i)
|
||||
bm_menu_set_color(menu, i, client->colors[i]);
|
||||
|
||||
if (client->grab) {
|
||||
bm_menu_set_filter(menu, "Loading...");
|
||||
// bm_menu_grab_keyboard(menu, true);
|
||||
bm_menu_render(menu);
|
||||
bm_menu_set_filter(menu, NULL);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
enum bm_run_result
|
||||
run_menu(const struct client *client, struct bm_menu *menu, void (*item_cb)(const struct client *client, struct bm_item *item))
|
||||
{
|
||||
{
|
||||
uint32_t total_item_count;
|
||||
struct bm_item **items = bm_menu_get_items(menu, &total_item_count);
|
||||
|
||||
if (client->ifne && total_item_count == 0) {
|
||||
return BM_RUN_RESULT_CANCEL;
|
||||
}
|
||||
|
||||
if (client->accept_single && total_item_count == 1) {
|
||||
item_cb(client, *items);
|
||||
return BM_RUN_RESULT_SELECTED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bm_menu_set_highlighted_index(menu, client->selected);
|
||||
bm_menu_grab_keyboard(menu, true);
|
||||
bm_menu_set_filter(menu, client->initial_filter);
|
||||
|
||||
uint32_t unicode;
|
||||
enum bm_key key = BM_KEY_NONE;
|
||||
struct bm_pointer pointer;
|
||||
struct bm_touch touch;
|
||||
enum bm_run_result status = BM_RUN_RESULT_RUNNING;
|
||||
do {
|
||||
if (!bm_menu_render(menu)) {
|
||||
status = BM_RUN_RESULT_CANCEL;
|
||||
break;
|
||||
}
|
||||
if (!client->no_keyboard) {
|
||||
key = bm_menu_poll_key(menu, &unicode);
|
||||
}
|
||||
if (!client->no_cursor) {
|
||||
pointer = bm_menu_poll_pointer(menu);
|
||||
}
|
||||
if (!client->no_touch) {
|
||||
touch = bm_menu_poll_touch(menu);
|
||||
}
|
||||
} while ((status = bm_menu_run_with_events(menu, key, pointer, touch, unicode)) == BM_RUN_RESULT_RUNNING);
|
||||
|
||||
switch (status) {
|
||||
case BM_RUN_RESULT_SELECTED:
|
||||
case BM_RUN_RESULT_CUSTOM_1:
|
||||
case BM_RUN_RESULT_CUSTOM_2:
|
||||
case BM_RUN_RESULT_CUSTOM_3:
|
||||
case BM_RUN_RESULT_CUSTOM_4:
|
||||
case BM_RUN_RESULT_CUSTOM_5:
|
||||
case BM_RUN_RESULT_CUSTOM_6:
|
||||
case BM_RUN_RESULT_CUSTOM_7:
|
||||
case BM_RUN_RESULT_CUSTOM_8:
|
||||
case BM_RUN_RESULT_CUSTOM_9:
|
||||
case BM_RUN_RESULT_CUSTOM_10:
|
||||
{
|
||||
uint32_t i, count;
|
||||
struct bm_item **items = bm_menu_get_selected_items(menu, &count);
|
||||
for (i = 0; i < count; ++i) item_cb(client, items[i]);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
51
.config/dwl/menu/client/common/common.h
Normal file
51
.config/dwl/menu/client/common/common.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef _BM_COMMON_H_
|
||||
#define _BM_COMMON_H_
|
||||
|
||||
#include <bemenu.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct client {
|
||||
enum bm_filter_mode filter_mode;
|
||||
enum bm_scrollbar_mode scrollbar;
|
||||
const char *colors[BM_COLOR_LAST];
|
||||
const char *title;
|
||||
const char *prefix;
|
||||
const char *font;
|
||||
const char *initial_filter;
|
||||
uint32_t line_height;
|
||||
uint32_t cursor_height;
|
||||
uint32_t cursor_width;
|
||||
uint32_t hpadding;
|
||||
uint32_t lines;
|
||||
uint32_t selected;
|
||||
uint32_t monitor;
|
||||
uint32_t hmargin_size;
|
||||
uint32_t border_size;
|
||||
float width_factor;
|
||||
bool bottom;
|
||||
bool center;
|
||||
bool grab;
|
||||
bool wrap;
|
||||
bool accept_single;
|
||||
bool ifne;
|
||||
bool no_overlap;
|
||||
bool no_spacing;
|
||||
bool no_cursor;
|
||||
bool no_touch;
|
||||
bool no_keyboard;
|
||||
bool force_fork, fork;
|
||||
bool no_exec;
|
||||
bool password;
|
||||
enum bm_key_binding key_binding;
|
||||
char *monitor_name;
|
||||
};
|
||||
|
||||
char* cstrcopy(const char *str, size_t size);
|
||||
char** tokenize_quoted_to_argv(const char *str, char *argv0, int *out_argc);
|
||||
void parse_args(struct client *client, int *argc, char **argv[]);
|
||||
struct bm_menu* menu_with_options(struct client *client);
|
||||
enum bm_run_result run_menu(const struct client *client, struct bm_menu *menu, void (*item_cb)(const struct client *client, struct bm_item *item));
|
||||
|
||||
#endif /* _BM_COMMON_H_ */
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
38
.config/dwl/menu/darwin.nix
Normal file
38
.config/dwl/menu/darwin.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
let
|
||||
src = pkgs.copyPathToStore ./.;
|
||||
semver = builtins.readFile "${src}/VERSION";
|
||||
revision = builtins.readFile (pkgs.runCommand "get-rev" {
|
||||
nativeBuildInputs = with pkgs; [ git ];
|
||||
} "GIT_DIR=${src}/.git git rev-parse --short HEAD | tr -d '\n' > $out");
|
||||
in pkgs.stdenv.mkDerivation rec {
|
||||
inherit src;
|
||||
pname = "bemenu";
|
||||
version = "${semver}${revision}";
|
||||
nativeBuildInputs = with pkgs; [ pkg-config scdoc ];
|
||||
buildInputs = with pkgs; [ ncurses ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace GNUmakefile --replace '-soname' '-install_name'
|
||||
'';
|
||||
|
||||
makeFlags = ["PREFIX=$(out)"];
|
||||
buildFlags = ["PREFIX=$(out)" "clients" "curses"];
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh
|
||||
# ^ does not handle .so files
|
||||
postInstall = ''
|
||||
so="$(find "$out/lib" -name "libbemenu.so.[0-9]" -print -quit)"
|
||||
for f in "$out/bin/"*; do
|
||||
install_name_tool -change "$(basename $so)" "$so" $f
|
||||
done
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
homepage = "https://github.com/Cloudef/bemenu";
|
||||
description = "Dynamic menu library and client program inspired by dmenu";
|
||||
license = licenses.gpl3Plus;
|
||||
platforms = with platforms; darwin;
|
||||
};
|
||||
}
|
2305
.config/dwl/menu/doxygen/Doxyfile
Normal file
2305
.config/dwl/menu/doxygen/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
23
.config/dwl/menu/doxygen/Mainpage.dox
Normal file
23
.config/dwl/menu/doxygen/Mainpage.dox
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
@mainpage Main Page
|
||||
|
||||
bemenu is a dynamic menu library and client program inspired by dmenu.
|
||||
You can create flexible menu oriented programs using the library interface in your favorite language that has bemenu bindings available.
|
||||
|
||||
Unlike old dmenu approach, with library you don't have to feed unneccessary metadata into client program and parse the result.
|
||||
Instead your program will be aware of the items and possible metadata inside the menu.
|
||||
It's also possible to use multiple menus or dynamically remove/insert items.
|
||||
|
||||
Features:
|
||||
- Multiple layouts
|
||||
- Different filtering algorithms:
|
||||
- Vanilla dmenu filtering
|
||||
- Rendering backends (UI toolkits are loaded dynamically, not depended):
|
||||
- Wayland (cairo + pango)
|
||||
- X11 (cairo + pango)
|
||||
- Curses
|
||||
|
||||
bemenu also provides 'bemenu' and 'bemenu-run' executables that are compatible with dmenu interface.
|
||||
|
||||
Get started on the <a href="modules.html">Modules</a> page.
|
||||
*/
|
41
.config/dwl/menu/doxygen/doxygen-qmi-style/README.md
Normal file
41
.config/dwl/menu/doxygen/doxygen-qmi-style/README.md
Normal file
|
@ -0,0 +1,41 @@
|
|||
Qmi is a "**Q**t **Mi**nimal" theme for the Doxygen HTML documentation.
|
||||
It based on official Qt4 documentation's style.
|
||||
|
||||
# How to setup
|
||||
|
||||
To use `qmi` style make the following changes in your Doxyfile:
|
||||
|
||||
# Project section
|
||||
BRIEF_MEMBER_DESC = NO
|
||||
|
||||
# HTML section
|
||||
HTML_HEADER = ${path_to_qmi}/header.html
|
||||
HTML_FOOTER = ${path_to_qmi}/footer.html
|
||||
HTML_STYLESHEET = ${path_to_qmi}/qmi.css
|
||||
|
||||
**NOTE**:
|
||||
|
||||
* If you use **_tree navigation panel_** then copy contents of the `navtree` dir to the documentation html dir.
|
||||
* If you use **_search_** feature then copy contents of the `search` dir to the `html/search`.
|
||||
|
||||
# Examples
|
||||
|
||||
If you want to see `qmi` style in action then use the following links with examples:
|
||||
|
||||
* [Qwt docs](http://skozlovf.github.com/doxygen-qmi-style/qwt)
|
||||
* [libxml++ docs](http://skozlovf.github.com/doxygen-qmi-style/libxmlpp) (with tree navigation and search)
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
||||
* **Main page**:
|
||||
|
||||
![](http://skozlovf.github.com/doxygen-qmi-style/shot1.png)
|
||||
|
||||
* **Index page**:
|
||||
|
||||
![](http://skozlovf.github.com/doxygen-qmi-style/shot2.png)
|
||||
|
||||
* **Member description**:
|
||||
|
||||
![](http://skozlovf.github.com/doxygen-qmi-style/shot3.png)
|
20
.config/dwl/menu/doxygen/doxygen-qmi-style/footer.html
Normal file
20
.config/dwl/menu/doxygen/doxygen-qmi-style/footer.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!-- HTML footer for doxygen 1.8.6-->
|
||||
<!-- start footer part -->
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
$navpath
|
||||
<li class="footer">$generatedby
|
||||
<span class="qmi"><a href="http://github.com/skozlovf/doxygen-qmi-style">qmi style</a> | </span>
|
||||
<a href="http://www.doxygen.org/index.html">doxygen</a> $doxygenversion </li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
<span class="qmi"><a href="http://github.com/skozlovf/doxygen-qmi-style">qmi style</a></span>
|
||||
$generatedby <a href="http://www.doxygen.org/index.html">doxygen</a> $doxygenversion
|
||||
</small></address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
</body>
|
||||
</html>
|
55
.config/dwl/menu/doxygen/doxygen-qmi-style/header.html
Normal file
55
.config/dwl/menu/doxygen/doxygen-qmi-style/header.html
Normal file
|
@ -0,0 +1,55 @@
|
|||
<!-- HTML header for doxygen 1.8.6-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath$qmi.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo"><img alt="Logo" src="$relpath$$projectlogo"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<!--td style="padding-left: 0.5em;"-->
|
||||
<td>
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--><span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
Binary file not shown.
After Width: | Height: | Size: 285 B |
BIN
.config/dwl/menu/doxygen/doxygen-qmi-style/navtree/ftv2mnode.png
Normal file
BIN
.config/dwl/menu/doxygen/doxygen-qmi-style/navtree/ftv2mnode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 285 B |
Binary file not shown.
After Width: | Height: | Size: 277 B |
BIN
.config/dwl/menu/doxygen/doxygen-qmi-style/navtree/ftv2pnode.png
Normal file
BIN
.config/dwl/menu/doxygen/doxygen-qmi-style/navtree/ftv2pnode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 282 B |
117
.config/dwl/menu/doxygen/doxygen-qmi-style/navtree/navtree.css
Normal file
117
.config/dwl/menu/doxygen/doxygen-qmi-style/navtree/navtree.css
Normal file
|
@ -0,0 +1,117 @@
|
|||
#nav-tree .children_ul {
|
||||
margin:0;
|
||||
padding:4px;
|
||||
}
|
||||
|
||||
#nav-tree ul {
|
||||
list-style:none outside none;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree li {
|
||||
white-space:nowrap;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree .plus {
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
#nav-tree .selected {
|
||||
background-image: none;
|
||||
background-color: #B0B0B0;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#nav-tree img {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
border:0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#nav-tree a {
|
||||
text-decoration:none;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
outline:none;
|
||||
}
|
||||
|
||||
#nav-tree .label {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree .label a {
|
||||
padding:2px;
|
||||
}
|
||||
|
||||
#nav-tree .selected a {
|
||||
text-decoration:none;
|
||||
padding:2px;
|
||||
margin:0px;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
#nav-tree .children_ul {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree .item {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
#nav-tree {
|
||||
padding: 0px 0px;
|
||||
background-image:none;
|
||||
background-color: #F6F6F6;
|
||||
font-size:14px;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#doc-content {
|
||||
overflow:auto;
|
||||
display:block;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
#side-nav {
|
||||
padding:0 4px 0 0;
|
||||
margin: 0px;
|
||||
display:block;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.ui-resizable .ui-resizable-handle {
|
||||
display:block;
|
||||
}
|
||||
|
||||
.ui-resizable-e {
|
||||
background: none;
|
||||
background-color: #EBEBEB;
|
||||
cursor:e-resize;
|
||||
height:100%;
|
||||
right:0;
|
||||
top:0;
|
||||
width:4px;
|
||||
}
|
||||
|
||||
.ui-resizable-handle {
|
||||
display:none;
|
||||
font-size:0.1px;
|
||||
position:absolute;
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
#nav-tree-contents {
|
||||
margin: 6px 0px 0px 0px;
|
||||
}
|
||||
|
||||
|
1033
.config/dwl/menu/doxygen/doxygen-qmi-style/qmi.css
Normal file
1033
.config/dwl/menu/doxygen/doxygen-qmi-style/qmi.css
Normal file
File diff suppressed because it is too large
Load Diff
238
.config/dwl/menu/doxygen/doxygen-qmi-style/search/search.css
Normal file
238
.config/dwl/menu/doxygen/doxygen-qmi-style/search/search.css
Normal file
|
@ -0,0 +1,238 @@
|
|||
/*---------------- Search Box */
|
||||
|
||||
#FSearchBox {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#MSearchBox {
|
||||
white-space : nowrap;
|
||||
position: absolute;
|
||||
float: none;
|
||||
display: inline;
|
||||
margin-top: 3px;
|
||||
right: 0px;
|
||||
width: 170px;
|
||||
z-index: 102;
|
||||
}
|
||||
|
||||
#MSearchBox .left
|
||||
{
|
||||
display:block;
|
||||
position:absolute;
|
||||
left:10px;
|
||||
width:20px;
|
||||
height:19px;
|
||||
background:url('search_l.png') no-repeat;
|
||||
background-position:right;
|
||||
}
|
||||
|
||||
#MSearchSelect {
|
||||
display:block;
|
||||
position:absolute;
|
||||
width:20px;
|
||||
height:19px;
|
||||
}
|
||||
|
||||
.left #MSearchSelect {
|
||||
left:4px;
|
||||
}
|
||||
|
||||
.right #MSearchSelect {
|
||||
right:5px;
|
||||
}
|
||||
|
||||
#MSearchField {
|
||||
display:block;
|
||||
position:absolute;
|
||||
padding:0;
|
||||
margin:0;
|
||||
height:19px;
|
||||
background:url('search_m.png') repeat-x;
|
||||
border:none;
|
||||
width:116px;
|
||||
margin-left:20px;
|
||||
padding-left:4px;
|
||||
color:#909090;
|
||||
outline:none;
|
||||
font:9pt Arial, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
#FSearchBox #MSearchField {
|
||||
margin-left:15px;
|
||||
}
|
||||
|
||||
#MSearchBox .right {
|
||||
display:block;
|
||||
position:absolute;
|
||||
right:10px;
|
||||
width:20px;
|
||||
height:19px;
|
||||
background:url('search_r.png') no-repeat;
|
||||
background-position:left;
|
||||
}
|
||||
|
||||
#MSearchClose {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
background : none;
|
||||
border: none;
|
||||
margin: 0px 4px 0px 0px;
|
||||
padding: 0px 0px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.left #MSearchClose {
|
||||
left: 6px;
|
||||
}
|
||||
|
||||
.right #MSearchClose {
|
||||
right: 2px;
|
||||
}
|
||||
|
||||
.MSearchBoxActive #MSearchField {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/*---------------- Search filter selection */
|
||||
|
||||
#MSearchSelectWindow {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border: 1px solid #E6E6E6;
|
||||
background-color: #F6F6F6;
|
||||
z-index: 1;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.SelectItem {
|
||||
font: 8pt Arial, Verdana, sans-serif;
|
||||
padding-left: 2px;
|
||||
padding-right: 12px;
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
span.SelectionMark {
|
||||
margin-right: 4px;
|
||||
font-family: monospace;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.SelectItem {
|
||||
display: block;
|
||||
outline-style: none;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
padding-left: 6px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
a.SelectItem:focus,
|
||||
a.SelectItem:active {
|
||||
color: #000000;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.SelectItem:hover {
|
||||
color: #FFFFFF;
|
||||
background-color: #B0B0B0;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*---------------- Search results window */
|
||||
|
||||
iframe#MSearchResults {
|
||||
width: 60ex;
|
||||
height: 15em;
|
||||
}
|
||||
|
||||
#MSearchResultsWindow {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border: 1px solid #8A8A8A;
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
|
||||
#SRIndex {
|
||||
clear:both;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.SREntry {
|
||||
font-size: 10pt;
|
||||
padding-left: 1ex;
|
||||
}
|
||||
|
||||
.SRPage .SREntry {
|
||||
font-size: 8pt;
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
body.SRPage {
|
||||
margin: 5px 2px;
|
||||
}
|
||||
|
||||
.SRChildren {
|
||||
padding-left: 3ex; padding-bottom: .5em
|
||||
}
|
||||
|
||||
.SRPage .SRChildren {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.SRSymbol {
|
||||
font-weight: bold;
|
||||
color: #00732F;
|
||||
font-family: Arial, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a.SRScope {
|
||||
display: block;
|
||||
color: #00732F;
|
||||
font-family: Arial, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a.SRSymbol:focus, a.SRSymbol:active,
|
||||
a.SRScope:focus, a.SRScope:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
span.SRScope {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.SRPage .SRStatus {
|
||||
padding: 2px 5px;
|
||||
font-size: 8pt;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.SRResult {
|
||||
display: none;
|
||||
}
|
||||
|
||||
DIV.searchresults {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
96
.config/dwl/menu/lib/3rdparty/cdl.c
vendored
Normal file
96
.config/dwl/menu/lib/3rdparty/cdl.c
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef size_t
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# include <windows.h>
|
||||
#elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__APPLE__)
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# warning "cdl: unsupported os"
|
||||
#endif
|
||||
|
||||
void* chckDlLoad(const char *file, const char **outError)
|
||||
{
|
||||
assert(file);
|
||||
void *handle = NULL;
|
||||
const char *error = NULL;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(__WINRT__)
|
||||
/**
|
||||
* WinRT only publically supports LoadPackagedLibrary() for loading .dll
|
||||
* files. LoadLibrary() is a private API, and not available for apps
|
||||
* (that can be published to MS' Windows Store.)
|
||||
*/
|
||||
handle = (void*)LoadPackagedLibrary(file, 0);
|
||||
#else
|
||||
handle = (void*)LoadLibrary(file);
|
||||
#endif
|
||||
|
||||
if (!handle)
|
||||
error = "Failed to load dll file.";
|
||||
#elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__APPLE__)
|
||||
if (!(handle = dlopen(file, RTLD_NOW | RTLD_LOCAL)))
|
||||
error = dlerror();
|
||||
#else
|
||||
error = "cdl: unsupported os";
|
||||
#endif
|
||||
|
||||
if (outError)
|
||||
*outError = error;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void* chckDlLoadSymbol(void *handle, const char *name, const char **outError)
|
||||
{
|
||||
assert(handle);
|
||||
void *symbol = NULL;
|
||||
const char *error = NULL;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
if (!(symbol = (void*)GetProcAddress((HMODULE)handle, name)))
|
||||
error = "Failed to load symbol.";
|
||||
#elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__APPLE__)
|
||||
if (!(symbol = dlsym(handle, name))) {
|
||||
size_t len = strlen(name) + 1;
|
||||
char *nname = calloc(1, len + 1);
|
||||
|
||||
if (nname) {
|
||||
/* append an underscore for platforms that need that. */
|
||||
nname[0] = '_';
|
||||
memcpy(nname + 1, name, len);
|
||||
symbol = dlsym(handle, nname);
|
||||
free(nname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!symbol)
|
||||
error = dlerror();
|
||||
#else
|
||||
error = "cdl: unsupported os";
|
||||
#endif
|
||||
|
||||
if (outError)
|
||||
*outError = error;
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void chckDlUnload(void *handle)
|
||||
{
|
||||
assert(handle);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
FreeLibrary((HMODULE)handle);
|
||||
#elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__APPLE__)
|
||||
dlclose(handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=3 tw=0 :*/
|
10
.config/dwl/menu/lib/3rdparty/cdl.h
vendored
Normal file
10
.config/dwl/menu/lib/3rdparty/cdl.h
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef __chck_cdl__
|
||||
#define __chck_cdl__
|
||||
|
||||
void* chckDlLoad(const char *file, const char **outError);
|
||||
void* chckDlLoadSymbol(void *handle, const char *name, const char **outError);
|
||||
void chckDlUnload(void *handle);
|
||||
|
||||
#endif /* __chck_cdl__ */
|
||||
|
||||
/* vim: set ts=8 sw=3 tw=0 :*/
|
1119
.config/dwl/menu/lib/bemenu.h
Normal file
1119
.config/dwl/menu/lib/bemenu.h
Normal file
File diff suppressed because it is too large
Load Diff
182
.config/dwl/menu/lib/filter.c
Normal file
182
.config/dwl/menu/lib/filter.c
Normal file
|
@ -0,0 +1,182 @@
|
|||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Shrink struct bm_item** list pointer.
|
||||
*
|
||||
* Useful helper function for filter functions.
|
||||
*
|
||||
* @param in_out_list Pointer to pointer to list of bm_item pointers.
|
||||
* @param osize Current size of the list.
|
||||
* @param nsize New size the list will be shrinked to.
|
||||
* @return Pointer to list of bm_item pointers.
|
||||
*/
|
||||
static struct bm_item**
|
||||
shrink_list(struct bm_item ***in_out_list, size_t osize, size_t nsize)
|
||||
{
|
||||
assert(in_out_list);
|
||||
|
||||
if (nsize == 0) {
|
||||
free(*in_out_list);
|
||||
return (*in_out_list = NULL);
|
||||
}
|
||||
|
||||
if (nsize >= osize)
|
||||
return *in_out_list;
|
||||
|
||||
void *tmp = malloc(sizeof(struct bm_item*) * nsize);
|
||||
if (!tmp)
|
||||
return *in_out_list;
|
||||
|
||||
memcpy(tmp, *in_out_list, sizeof(struct bm_item*) * nsize);
|
||||
free(*in_out_list);
|
||||
return (*in_out_list = tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Text filter tokenizer helper.
|
||||
*
|
||||
* @param menu bm_menu instance which filter to tokenize.
|
||||
* @param out_tokv char pointer reference to list of tokens, this should be freed after use.
|
||||
* @param out_tokc uint32_t reference to number of tokens.
|
||||
* @return Pointer to buffer that contains tokenized string, this should be freed after use.
|
||||
*/
|
||||
static char*
|
||||
tokenize(struct bm_menu *menu, char ***out_tokv, uint32_t *out_tokc)
|
||||
{
|
||||
assert(menu && out_tokv && out_tokc);
|
||||
*out_tokv = NULL;
|
||||
*out_tokc = 0;
|
||||
|
||||
char **tokv = NULL, *buffer = NULL;
|
||||
if (!(buffer = bm_strdup(menu->filter)))
|
||||
goto fail;
|
||||
|
||||
char *s;
|
||||
for (s = buffer; *s && *s == ' '; ++s);
|
||||
|
||||
char **tmp = NULL;
|
||||
size_t pos = 0, next;
|
||||
uint32_t tokc = 0, tokn = 0;
|
||||
for (; (pos = bm_strip_token(s, " ", &next)) > 0; tokv = tmp) {
|
||||
if (++tokc > tokn && !(tmp = realloc(tokv, ++tokn * sizeof(char*))))
|
||||
goto fail;
|
||||
|
||||
tmp[tokc - 1] = s;
|
||||
s += next;
|
||||
for (; *s && *s == ' '; ++s);
|
||||
}
|
||||
|
||||
*out_tokv = tmp;
|
||||
*out_tokc = tokc;
|
||||
return buffer;
|
||||
|
||||
fail:
|
||||
free(buffer);
|
||||
free(tokv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dmenu filterer that accepts substring function.
|
||||
*
|
||||
* @param menu bm_menu instance to filter.
|
||||
* @param addition This will be 1, if filter is same as previous filter with something appended.
|
||||
* @param fstrstr Substring function used to match items.
|
||||
* @param out_nmemb uint32_t reference to filtered items count.
|
||||
* @return Pointer to array of bm_item pointers.
|
||||
*/
|
||||
static struct bm_item**
|
||||
filter_dmenu_fun(struct bm_menu *menu, char addition, char* (*fstrstr)(const char *a, const char *b), int (*fstrncmp)(const char *a, const char *b, size_t len), uint32_t *out_nmemb)
|
||||
{
|
||||
assert(menu && fstrstr && fstrncmp && out_nmemb);
|
||||
*out_nmemb = 0;
|
||||
|
||||
uint32_t count;
|
||||
struct bm_item **items;
|
||||
|
||||
if (addition) {
|
||||
items = bm_menu_get_filtered_items(menu, &count);
|
||||
} else {
|
||||
items = bm_menu_get_items(menu, &count);
|
||||
}
|
||||
|
||||
char *buffer = NULL;
|
||||
struct bm_item **filtered;
|
||||
if (!(filtered = calloc(count, sizeof(struct bm_item*))))
|
||||
goto fail;
|
||||
|
||||
char **tokv;
|
||||
uint32_t tokc;
|
||||
if (!(buffer = tokenize(menu, &tokv, &tokc)))
|
||||
goto fail;
|
||||
|
||||
size_t len = (tokc ? strlen(tokv[0]) : 0);
|
||||
uint32_t i, f, e;
|
||||
for (e = f = i = 0; i < count; ++i) {
|
||||
struct bm_item *item = items[i];
|
||||
if (!item->text && tokc != 0)
|
||||
continue;
|
||||
|
||||
if (tokc && item->text) {
|
||||
uint32_t t;
|
||||
for (t = 0; t < tokc && fstrstr(item->text, tokv[t]); ++t);
|
||||
if (t < tokc)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokc && item->text && !fstrncmp(tokv[0], item->text, len + 1)) { /* exact matches */
|
||||
memmove(&filtered[1], filtered, f * sizeof(struct bm_item*));
|
||||
filtered[0] = item;
|
||||
e++; /* where do exact matches end */
|
||||
} else if (tokc && item->text && !fstrncmp(tokv[0], item->text, len)) { /* prefixes */
|
||||
memmove(&filtered[e + 1], &filtered[e], (f - e) * sizeof(struct bm_item*));
|
||||
filtered[e] = item;
|
||||
e++; /* where do exact matches end */
|
||||
} else {
|
||||
filtered[f] = item;
|
||||
}
|
||||
f++; /* where do all matches end */
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
free(tokv);
|
||||
return shrink_list(&filtered, menu->items.count, (*out_nmemb = f));
|
||||
|
||||
fail:
|
||||
free(filtered);
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter that mimics the vanilla dmenu filtering.
|
||||
*
|
||||
* @param menu bm_menu instance to filter.
|
||||
* @param addition This will be 1, if filter is same as previous filter with something appended.
|
||||
* @param outNmemb uint32_t reference to filtered items count.
|
||||
* @return Pointer to array of bm_item pointers.
|
||||
*/
|
||||
struct bm_item**
|
||||
bm_filter_dmenu(struct bm_menu *menu, bool addition, uint32_t *out_nmemb)
|
||||
{
|
||||
return filter_dmenu_fun(menu, addition, strstr, strncmp, out_nmemb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter that mimics the vanilla case-insensitive dmenu filtering.
|
||||
*
|
||||
* @param menu bm_menu instance to filter.
|
||||
* @param addition This will be 1, if filter is same as previous filter with something appended.
|
||||
* @param outNmemb uint32_t reference to filtered items count.
|
||||
* @return Pointer to array of bm_item pointers.
|
||||
*/
|
||||
struct bm_item**
|
||||
bm_filter_dmenu_case_insensitive(struct bm_menu *menu, bool addition, uint32_t *out_nmemb)
|
||||
{
|
||||
return filter_dmenu_fun(menu, addition, bm_strupstr, bm_strnupcmp, out_nmemb);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
470
.config/dwl/menu/lib/internal.h
Normal file
470
.config/dwl/menu/lib/internal.h
Normal file
|
@ -0,0 +1,470 @@
|
|||
#ifndef _BEMENU_INTERNAL_H_
|
||||
#define _BEMENU_INTERNAL_H_
|
||||
|
||||
#include "bemenu.h"
|
||||
|
||||
#if __GNUC__
|
||||
# define BM_LOG_ATTR(x, y) __attribute__((format(printf, x, y)))
|
||||
#else
|
||||
# define BM_LOG_ATTR(x, y)
|
||||
#endif
|
||||
|
||||
#ifndef __GLIBC__
|
||||
# define secure_getenv getenv
|
||||
#else
|
||||
extern char *secure_getenv(const char *name);
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include <stdarg.h>
|
||||
|
||||
//minimum allowed window width when setting margin
|
||||
#define WINDOW_MIN_WIDTH 80
|
||||
|
||||
/**
|
||||
* Destructor function pointer for some list calls.
|
||||
*/
|
||||
typedef void (*list_free_fun)(void*);
|
||||
|
||||
/**
|
||||
* List type
|
||||
*/
|
||||
struct list {
|
||||
/**
|
||||
* Items in the list.
|
||||
*/
|
||||
void **items;
|
||||
|
||||
/**
|
||||
* Number of items.
|
||||
*/
|
||||
uint32_t count;
|
||||
|
||||
/**
|
||||
* Number of allocated items.
|
||||
*/
|
||||
uint32_t allocated;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal render api struct.
|
||||
* Renderers should be able to fill this one as they see fit.
|
||||
*/
|
||||
struct render_api {
|
||||
/**
|
||||
* Create underlying renderer.
|
||||
*/
|
||||
bool (*constructor)(struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Release underlying renderer.
|
||||
*/
|
||||
void (*destructor)(struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Get count of displayed items by the underlying renderer.
|
||||
*/
|
||||
uint32_t (*get_displayed_count)(const struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Get height by the underlying renderer;
|
||||
*/
|
||||
uint32_t (*get_height)(const struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Get width by the underlying renderer;
|
||||
*/
|
||||
uint32_t (*get_width)(const struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* If the underlying renderer is a UI toolkit. (curses, etc...)
|
||||
* There might be possibility to get user input, and this should be thus implemented.
|
||||
*/
|
||||
enum bm_key (*poll_key)(const struct bm_menu *menu, uint32_t *unicode);
|
||||
|
||||
/**
|
||||
* If the underlying renderer is a UI toolkit. (curses, etc...)
|
||||
* There might be possibility to get user pointer, and this should be thus implemented.
|
||||
*/
|
||||
struct bm_pointer (*poll_pointer)(const struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* If the underlying renderer is a UI toolkit. (curses, etc...)
|
||||
* There might be possibility to get user touch, and this should be thus implemented.
|
||||
*/
|
||||
struct bm_touch (*poll_touch)(const struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Enforce a release of the touches
|
||||
* There might be possibility to get user touch, and this should be thus implemented.
|
||||
*/
|
||||
void (*release_touch)(const struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Tells underlying renderer to draw the menu.
|
||||
*/
|
||||
bool (*render)(struct bm_menu *menu);
|
||||
|
||||
/**
|
||||
* Set vertical alignment of the bar.
|
||||
*/
|
||||
void (*set_align)(const struct bm_menu *menu, enum bm_align align);
|
||||
|
||||
/**
|
||||
* Set horizontal margin and relative width factor.
|
||||
*/
|
||||
void (*set_width)(const struct bm_menu *menu, uint32_t margin, float factor);
|
||||
|
||||
/**
|
||||
* Set monitor indeax where menu will appear
|
||||
*/
|
||||
void (*set_monitor)(const struct bm_menu *menu, int32_t monitor);
|
||||
|
||||
/**
|
||||
* Set monitor name where menu will appear
|
||||
*/
|
||||
void (*set_monitor_name)(const struct bm_menu *menu, char *monitor_name);
|
||||
|
||||
/**
|
||||
* Grab/Ungrab keyboard
|
||||
*/
|
||||
void (*grab_keyboard)(const struct bm_menu *menu, bool grab);
|
||||
|
||||
/**
|
||||
* Control overlap with panels
|
||||
*/
|
||||
void (*set_overlap)(const struct bm_menu *menu, bool overlap);
|
||||
|
||||
/**
|
||||
* Version of the plugin.
|
||||
* Should match BM_PLUGIN_VERSION or failure.
|
||||
*/
|
||||
const char *version;
|
||||
|
||||
/**
|
||||
* Priorty of the plugin.
|
||||
* Terminal renderers should be first, then graphicals.
|
||||
*/
|
||||
enum bm_priorty priorty;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal bm_renderer struct.
|
||||
*/
|
||||
struct bm_renderer {
|
||||
/**
|
||||
* Name of the renderer.
|
||||
*/
|
||||
char *name;
|
||||
|
||||
/**
|
||||
* File path of the renderer.
|
||||
*/
|
||||
char *file;
|
||||
|
||||
/**
|
||||
* Open handle to the plugin file of this renderer.
|
||||
*/
|
||||
void *handle;
|
||||
|
||||
/**
|
||||
* Data used by the renderer internally.
|
||||
* Nobody else should touch this.
|
||||
*/
|
||||
void *internal;
|
||||
|
||||
/**
|
||||
* API
|
||||
*/
|
||||
struct render_api api;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal bm_item struct that is not exposed to public.
|
||||
* Represents a single item in menu.
|
||||
*/
|
||||
struct bm_item {
|
||||
/**
|
||||
* Userdata pointer.
|
||||
* This pointer will be passed around with the item untouched.
|
||||
*/
|
||||
void *userdata;
|
||||
|
||||
/**
|
||||
* Primary text shown on item as null terminated C "string".
|
||||
* Matching will be done against this text as well.
|
||||
*/
|
||||
char *text;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal bm_hex_color struct that is not exposed to public.
|
||||
* Represent a color for element.
|
||||
*/
|
||||
struct bm_hex_color {
|
||||
/**
|
||||
* Provided hex for the color.
|
||||
*/
|
||||
char *hex;
|
||||
|
||||
/**
|
||||
* RGB values.
|
||||
*/
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal bm_font struct that is not exposed to public.
|
||||
* Represent a font for text.
|
||||
*/
|
||||
struct bm_font {
|
||||
/**
|
||||
* Name of the font.
|
||||
*/
|
||||
char *name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal bm_menu struct that is not exposed to public.
|
||||
*/
|
||||
struct bm_menu {
|
||||
/**
|
||||
* Userdata pointer.
|
||||
* This pointer will be passed around with the menu untouched.
|
||||
*/
|
||||
void *userdata;
|
||||
|
||||
/**
|
||||
* Underlying renderer access.
|
||||
*/
|
||||
struct bm_renderer *renderer;
|
||||
|
||||
/**
|
||||
* Items contained in menu instance.
|
||||
*/
|
||||
struct list items;
|
||||
|
||||
/**
|
||||
* Filtered/displayed items contained in menu instance.
|
||||
*/
|
||||
struct list filtered;
|
||||
|
||||
/**
|
||||
* Selected items.
|
||||
*/
|
||||
struct list selection;
|
||||
|
||||
/**
|
||||
* Menu instance title.
|
||||
*/
|
||||
char *title;
|
||||
|
||||
/**
|
||||
* Font.
|
||||
*/
|
||||
struct bm_font font;
|
||||
|
||||
/**
|
||||
* Line height.
|
||||
*/
|
||||
uint32_t line_height;
|
||||
|
||||
/**
|
||||
* Cursor height.
|
||||
*/
|
||||
uint32_t cursor_height;
|
||||
|
||||
/**
|
||||
* Cursor width.
|
||||
*/
|
||||
uint32_t cursor_width;
|
||||
|
||||
/**
|
||||
* Horizontal Padding.
|
||||
*/
|
||||
uint32_t hpadding;
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
struct bm_hex_color colors[BM_COLOR_LAST];
|
||||
|
||||
/**
|
||||
* Prefix shown for highlighted item.
|
||||
* Vertical mode only.
|
||||
*/
|
||||
char *prefix;
|
||||
|
||||
/**
|
||||
* Text used to filter matches.
|
||||
*/
|
||||
char *filter;
|
||||
|
||||
/**
|
||||
* Used as optimization.
|
||||
*/
|
||||
char *old_filter;
|
||||
|
||||
/**
|
||||
* Used when selecting the filter text (ex. SHIFT_RETURN)
|
||||
*/
|
||||
struct bm_item *filter_item;
|
||||
|
||||
/**
|
||||
* Size of filter buffer
|
||||
*/
|
||||
size_t filter_size;
|
||||
|
||||
/**
|
||||
* Current byte offset on filter text.
|
||||
*/
|
||||
uint32_t cursor;
|
||||
|
||||
/**
|
||||
* Current column/cursor position on filter text.
|
||||
*/
|
||||
uint32_t curses_cursor;
|
||||
|
||||
/**
|
||||
* Current filtered/highlighted item index in menu instance.
|
||||
* This index is valid for the list returned by bmMenuGetFilteredItems.
|
||||
*/
|
||||
uint32_t index;
|
||||
|
||||
/**
|
||||
* Max number of vertical lines to be shown.
|
||||
* Some renderers such as ncurses may ignore this when it does not make sense.
|
||||
*/
|
||||
uint32_t lines;
|
||||
|
||||
/**
|
||||
* Current monitor.
|
||||
*/
|
||||
int32_t monitor;
|
||||
|
||||
/**
|
||||
* Current monitor name. Wayland only.
|
||||
*/
|
||||
char *monitor_name;
|
||||
|
||||
/**
|
||||
* Current filtering method in menu instance.
|
||||
*/
|
||||
enum bm_filter_mode filter_mode;
|
||||
|
||||
/**
|
||||
* Current Scrollbar display mode.
|
||||
*/
|
||||
enum bm_scrollbar_mode scrollbar;
|
||||
|
||||
/**
|
||||
* Should selection be wrapped?
|
||||
*/
|
||||
bool wrap;
|
||||
|
||||
/**
|
||||
* Vertical alignment.
|
||||
*/
|
||||
enum bm_align align;
|
||||
|
||||
/**
|
||||
* Horizontal margin.
|
||||
*/
|
||||
uint32_t hmargin_size;
|
||||
|
||||
/**
|
||||
* Relative width factor.
|
||||
*/
|
||||
float width_factor;
|
||||
|
||||
/**
|
||||
* Border size
|
||||
*/
|
||||
uint32_t border_size;
|
||||
|
||||
/**
|
||||
* Is menu grabbed?
|
||||
*/
|
||||
bool grabbed;
|
||||
|
||||
/**
|
||||
* Should the menu overlap panels
|
||||
*/
|
||||
bool overlap;
|
||||
|
||||
/**
|
||||
* Should the input be hidden
|
||||
*/
|
||||
bool password;
|
||||
|
||||
/**
|
||||
* Should the entry should follow the title spacing
|
||||
*/
|
||||
bool spacing;
|
||||
|
||||
/**
|
||||
* Mask representing a feedback to bring to user
|
||||
*/
|
||||
uint32_t event_feedback;
|
||||
|
||||
/**
|
||||
* Is the menu needing a redraw ?
|
||||
*/
|
||||
bool dirty;
|
||||
|
||||
/**
|
||||
* Key binding that should be used.
|
||||
*/
|
||||
enum bm_key_binding key_binding;
|
||||
|
||||
/**
|
||||
* Vim binding specific variables.
|
||||
*/
|
||||
char vim_mode;
|
||||
uint32_t vim_last_key;
|
||||
};
|
||||
|
||||
/* library.c */
|
||||
bool bm_renderer_activate(struct bm_renderer *renderer, struct bm_menu *menu);
|
||||
|
||||
/* filter.c */
|
||||
struct bm_item** bm_filter_dmenu(struct bm_menu *menu, bool addition, uint32_t *out_nmemb);
|
||||
struct bm_item** bm_filter_dmenu_case_insensitive(struct bm_menu *menu, bool addition, uint32_t *out_nmemb);
|
||||
|
||||
/* list.c */
|
||||
void list_free_list(struct list *list);
|
||||
void list_free_items(struct list *list, list_free_fun destructor);
|
||||
void* list_get_items(const struct list *list, uint32_t *out_nmemb);
|
||||
bool list_set_items_no_copy(struct list *list, void *items, uint32_t nmemb);
|
||||
bool list_set_items(struct list *list, const void *items, uint32_t nmemb, list_free_fun destructor);
|
||||
bool list_grow(struct list *list, uint32_t step);
|
||||
bool list_add_item_at(struct list *list, void *item, uint32_t index);
|
||||
bool list_add_item(struct list *list, void *item);
|
||||
bool list_remove_item_at(struct list *list, uint32_t index);
|
||||
bool list_remove_item(struct list *list, const void *item);
|
||||
void list_sort(struct list *list, int (*compar)(const void *a, const void *b));
|
||||
|
||||
/* util.c
|
||||
* Functions here may be used in renderers also. They will be statically compiled to all units,
|
||||
* so do not mark them as a BM_PUBLIC.
|
||||
*/
|
||||
char* bm_strdup(const char *s);
|
||||
bool bm_resize_buffer(char **in_out_buffer, size_t *in_out_size, size_t nsize);
|
||||
BM_LOG_ATTR(1, 2) char* bm_dprintf(const char *fmt, ...);
|
||||
BM_LOG_ATTR(3, 0) bool bm_vrprintf(char **in_out_buffer, size_t *in_out_len, const char *fmt, va_list args);
|
||||
size_t bm_strip_token(char *string, const char *token, size_t *out_next);
|
||||
int bm_strupcmp(const char *hay, const char *needle);
|
||||
int bm_strnupcmp(const char *hay, const char *needle, size_t len);
|
||||
char* bm_strupstr(const char *hay, const char *needle);
|
||||
int32_t bm_utf8_string_screen_width(const char *string);
|
||||
size_t bm_utf8_rune_next(const char *string, size_t start);
|
||||
size_t bm_utf8_rune_prev(const char *string, size_t start);
|
||||
size_t bm_utf8_rune_width(const char *rune, uint32_t u8len);
|
||||
size_t bm_utf8_rune_remove(char *string, size_t start, size_t *out_rune_width);
|
||||
size_t bm_utf8_rune_insert(char **string, size_t *bufSize, size_t start, const char *rune, uint32_t u8len, size_t *out_rune_width);
|
||||
size_t bm_unicode_insert(char **string, size_t *bufSize, size_t start, uint32_t unicode, size_t *out_rune_width);
|
||||
bool bm_menu_item_is_selected(const struct bm_menu *menu, const struct bm_item *item);
|
||||
|
||||
#endif /* _BEMENU_INTERNAL_H_ */
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
60
.config/dwl/menu/lib/item.c
Normal file
60
.config/dwl/menu/lib/item.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
struct bm_item*
|
||||
bm_item_new(const char *text)
|
||||
{
|
||||
struct bm_item *item;
|
||||
if (!(item = calloc(1, sizeof(struct bm_item))))
|
||||
return NULL;
|
||||
|
||||
bm_item_set_text(item, text);
|
||||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
bm_item_free(struct bm_item *item)
|
||||
{
|
||||
assert(item);
|
||||
free(item->text);
|
||||
free(item);
|
||||
}
|
||||
|
||||
void
|
||||
bm_item_set_userdata(struct bm_item *item, void *userdata)
|
||||
{
|
||||
assert(item);
|
||||
item->userdata = userdata;
|
||||
}
|
||||
|
||||
void*
|
||||
bm_item_get_userdata(struct bm_item *item)
|
||||
{
|
||||
assert(item);
|
||||
return item->userdata;
|
||||
}
|
||||
|
||||
bool
|
||||
bm_item_set_text(struct bm_item *item, const char *text)
|
||||
{
|
||||
assert(item);
|
||||
|
||||
char *copy = NULL;
|
||||
if (text && !(copy = bm_strdup(text)))
|
||||
return false;
|
||||
|
||||
free(item->text);
|
||||
item->text = copy;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char*
|
||||
bm_item_get_text(const struct bm_item *item)
|
||||
{
|
||||
assert(item);
|
||||
return item->text;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
190
.config/dwl/menu/lib/library.c
Normal file
190
.config/dwl/menu/lib/library.c
Normal file
|
@ -0,0 +1,190 @@
|
|||
#include "internal.h"
|
||||
|
||||
#include "3rdparty/cdl.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
static struct list renderers;
|
||||
|
||||
static void
|
||||
bm_renderer_free(struct bm_renderer *renderer)
|
||||
{
|
||||
assert(renderer);
|
||||
|
||||
if (renderer->handle)
|
||||
chckDlUnload(renderer->handle);
|
||||
|
||||
free(renderer->name);
|
||||
free(renderer->file);
|
||||
free(renderer);
|
||||
}
|
||||
|
||||
static bool
|
||||
load(const char *file, struct bm_renderer *renderer)
|
||||
{
|
||||
void *handle;
|
||||
const char *error = NULL;
|
||||
|
||||
if (!(handle = chckDlLoad(file, &error)))
|
||||
goto load_fail;
|
||||
|
||||
union {
|
||||
const char* (*fun)(struct render_api*);
|
||||
void *ptr;
|
||||
} reg;
|
||||
|
||||
if (!(reg.ptr = chckDlLoadSymbol(handle, "register_renderer", &error)))
|
||||
goto load_fail;
|
||||
|
||||
const char *name;
|
||||
if (!(name = reg.fun(&renderer->api)))
|
||||
goto fail;
|
||||
|
||||
if (strcmp(renderer->api.version, BM_PLUGIN_VERSION))
|
||||
goto mismatch_fail;
|
||||
|
||||
if (!renderer->name)
|
||||
renderer->name = bm_strdup(name);
|
||||
|
||||
if (!renderer->file)
|
||||
renderer->file = bm_strdup(file);
|
||||
|
||||
renderer->handle = handle;
|
||||
return true;
|
||||
|
||||
load_fail:
|
||||
fprintf(stderr, "%s\n", error);
|
||||
goto fail;
|
||||
mismatch_fail:
|
||||
fprintf(stderr, "%s: version mismatch (%s != %s)\n", name, renderer->api.version, BM_PLUGIN_VERSION);
|
||||
fail:
|
||||
if (handle)
|
||||
chckDlUnload(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
compare(const void *a, const void *b)
|
||||
{
|
||||
const struct bm_renderer *ra = *(struct bm_renderer**)a, *rb = *(struct bm_renderer**)b;
|
||||
return (ra->api.priorty > rb->api.priorty);
|
||||
}
|
||||
|
||||
static bool
|
||||
load_to_list(const char *file)
|
||||
{
|
||||
struct bm_renderer *renderer;
|
||||
if (!(renderer = calloc(1, sizeof(struct bm_renderer))))
|
||||
goto fail;
|
||||
|
||||
if (!load(file, renderer))
|
||||
goto fail;
|
||||
|
||||
chckDlUnload(renderer->handle);
|
||||
renderer->handle = NULL;
|
||||
|
||||
if (!list_add_item(&renderers, renderer))
|
||||
goto fail;
|
||||
|
||||
list_sort(&renderers, compare);
|
||||
return true;
|
||||
|
||||
fail:
|
||||
if (renderer)
|
||||
bm_renderer_free(renderer);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
bm_renderer_activate(struct bm_renderer *renderer, struct bm_menu *menu)
|
||||
{
|
||||
assert(renderer);
|
||||
|
||||
if (!load(renderer->file, renderer))
|
||||
return false;
|
||||
|
||||
menu->renderer = renderer;
|
||||
|
||||
if (!renderer->api.constructor(menu))
|
||||
goto fail;
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
chckDlUnload(renderer->handle);
|
||||
menu->renderer = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
bm_init(void)
|
||||
{
|
||||
if (renderers.count > 0)
|
||||
return true;
|
||||
|
||||
static const char *rpath = INSTALL_LIBDIR "/bemenu";
|
||||
const char *path = secure_getenv("BEMENU_RENDERER");
|
||||
|
||||
if (path)
|
||||
return load_to_list(path);
|
||||
|
||||
path = secure_getenv("BEMENU_RENDERERS");
|
||||
|
||||
if (!path || access(path, R_OK) == -1)
|
||||
path = rpath;
|
||||
|
||||
DIR *dir;
|
||||
if (!(dir = opendir(path)))
|
||||
goto fail;
|
||||
|
||||
struct dirent *file;
|
||||
while ((file = readdir(dir))) {
|
||||
if (file->d_type != DT_DIR && !strncmp(file->d_name, "bemenu-renderer-", strlen("bemenu-renderer-"))) {
|
||||
char *fpath;
|
||||
if ((fpath = bm_dprintf("%s/%s", path, file->d_name))) {
|
||||
load_to_list(fpath);
|
||||
free(fpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return (renderers.count > 0 ? true : false);
|
||||
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
const struct bm_renderer**
|
||||
bm_get_renderers(uint32_t *out_nmemb)
|
||||
{
|
||||
assert(out_nmemb);
|
||||
return list_get_items(&renderers, out_nmemb);
|
||||
}
|
||||
|
||||
const char*
|
||||
bm_version(void)
|
||||
{
|
||||
return BM_VERSION;
|
||||
}
|
||||
|
||||
const char*
|
||||
bm_renderer_get_name(const struct bm_renderer *renderer)
|
||||
{
|
||||
assert(renderer);
|
||||
return renderer->name;
|
||||
}
|
||||
|
||||
enum bm_priorty
|
||||
bm_renderer_get_priorty(const struct bm_renderer *renderer)
|
||||
{
|
||||
assert(renderer);
|
||||
return renderer->api.priorty;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
147
.config/dwl/menu/lib/list.c
Normal file
147
.config/dwl/menu/lib/list.c
Normal file
|
@ -0,0 +1,147 @@
|
|||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
void
|
||||
list_free_list(struct list *list)
|
||||
{
|
||||
assert(list);
|
||||
free(list->items);
|
||||
list->allocated = list->count = 0;
|
||||
list->items = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
list_free_items(struct list *list, list_free_fun destructor)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
for (uint32_t i = 0; i < list->count; ++i)
|
||||
destructor(list->items[i]);
|
||||
|
||||
list_free_list(list);
|
||||
}
|
||||
|
||||
void*
|
||||
list_get_items(const struct list *list, uint32_t *out_nmemb)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
if (out_nmemb)
|
||||
*out_nmemb = list->count;
|
||||
|
||||
return list->items;
|
||||
}
|
||||
|
||||
/** !!! Frees the old list, not items !!! */
|
||||
bool
|
||||
list_set_items_no_copy(struct list *list, void *items, uint32_t nmemb)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
list_free_list(list);
|
||||
|
||||
if (!items || nmemb == 0) {
|
||||
items = NULL;
|
||||
nmemb = 0;
|
||||
}
|
||||
|
||||
list->items = items;
|
||||
list->allocated = list->count = nmemb;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** !!! Frees the old items and list !!! */
|
||||
bool
|
||||
list_set_items(struct list *list, const void *items, uint32_t nmemb, list_free_fun destructor)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
if (!items || nmemb == 0) {
|
||||
list_free_items(list, destructor);
|
||||
return true;
|
||||
}
|
||||
|
||||
void *new_items;
|
||||
if (!(new_items = calloc(sizeof(void*), nmemb)))
|
||||
return false;
|
||||
|
||||
memcpy(new_items, items, sizeof(void*) * nmemb);
|
||||
return list_set_items_no_copy(list, new_items, nmemb);
|
||||
}
|
||||
|
||||
bool
|
||||
list_grow(struct list *list, uint32_t step)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
void *tmp;
|
||||
uint32_t nsize = sizeof(void*) * (list->allocated + step);
|
||||
|
||||
if (!(tmp = realloc(list->items, nsize)))
|
||||
return false;
|
||||
|
||||
list->items = tmp;
|
||||
list->allocated += step;
|
||||
memset(&list->items[list->count], 0, sizeof(void*) * (list->allocated - list->count));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
list_add_item_at(struct list *list, void *item, uint32_t index)
|
||||
{
|
||||
assert(list && item);
|
||||
|
||||
if ((!list->items || list->allocated <= list->count) && !list_grow(list, 32))
|
||||
return false;
|
||||
|
||||
if (index + 1 != list->count) {
|
||||
uint32_t i = index;
|
||||
memmove(&list->items[i + 1], &list->items[i], sizeof(void*) * (list->count - i));
|
||||
}
|
||||
|
||||
list->items[index] = item;
|
||||
list->count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
list_add_item(struct list *list, void *item)
|
||||
{
|
||||
assert(list);
|
||||
return list_add_item_at(list, item, list->count);
|
||||
}
|
||||
|
||||
bool
|
||||
list_remove_item_at(struct list *list, uint32_t index)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
uint32_t i = index;
|
||||
if (!list->items || list->count <= i)
|
||||
return false;
|
||||
|
||||
memmove(&list->items[i], &list->items[i + 1], sizeof(void*) * (list->count - i));
|
||||
list->count--;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
list_remove_item(struct list *list, const void *item)
|
||||
{
|
||||
assert(list && item);
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < list->count && list->items[i] != item; ++i);
|
||||
return list_remove_item_at(list, i);
|
||||
}
|
||||
|
||||
void
|
||||
list_sort(struct list *list, int (*compar)(const void *a, const void *b))
|
||||
{
|
||||
assert(list && compar);
|
||||
qsort(list->items, list->count, sizeof(void*), compar);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
1378
.config/dwl/menu/lib/menu.c
Normal file
1378
.config/dwl/menu/lib/menu.c
Normal file
File diff suppressed because it is too large
Load Diff
482
.config/dwl/menu/lib/renderers/cairo_renderer.h
Normal file
482
.config/dwl/menu/lib/renderers/cairo_renderer.h
Normal file
|
@ -0,0 +1,482 @@
|
|||
#ifndef _BM_CAIRO_H_
|
||||
#define _BM_CAIRO_H_
|
||||
|
||||
#include "internal.h"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <cairo.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
struct cairo {
|
||||
cairo_t *cr;
|
||||
cairo_surface_t *surface;
|
||||
PangoContext *pango;
|
||||
int scale;
|
||||
};
|
||||
|
||||
struct cairo_color {
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
struct cairo_paint {
|
||||
struct cairo_color fg;
|
||||
struct cairo_color bg;
|
||||
const char *font;
|
||||
int32_t baseline;
|
||||
uint32_t cursor;
|
||||
uint32_t cursor_height;
|
||||
uint32_t cursor_width;
|
||||
struct cairo_color cursor_fg;
|
||||
struct cairo_color cursor_bg;
|
||||
uint32_t hpadding;
|
||||
bool draw_cursor;
|
||||
|
||||
struct box {
|
||||
int32_t lx, rx; // left/right offset (pos.x - lx, box.w + rx)
|
||||
int32_t ty, by; // top/bottom offset (pos.y - ty, box.h + by)
|
||||
int32_t w, h; // 0 for text width/height
|
||||
} box;
|
||||
|
||||
struct pos {
|
||||
int32_t x, y;
|
||||
} pos;
|
||||
};
|
||||
|
||||
struct cairo_result {
|
||||
uint32_t x_advance;
|
||||
uint32_t height;
|
||||
uint32_t baseline;
|
||||
};
|
||||
|
||||
struct cairo_paint_result {
|
||||
uint32_t displayed;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
static size_t blen = 0;
|
||||
static char *buffer = NULL;
|
||||
|
||||
static inline bool
|
||||
bm_cairo_create_for_surface(struct cairo *cairo, cairo_surface_t *surface)
|
||||
{
|
||||
assert(cairo && surface);
|
||||
if (!(cairo->cr = cairo_create(surface)))
|
||||
goto fail;
|
||||
|
||||
if (!(cairo->pango = pango_cairo_create_context(cairo->cr)))
|
||||
goto fail;
|
||||
|
||||
cairo->surface = surface;
|
||||
assert(cairo->scale > 0);
|
||||
cairo_surface_set_device_scale(surface, cairo->scale, cairo->scale);
|
||||
return true;
|
||||
|
||||
fail:
|
||||
if (cairo->cr)
|
||||
cairo_destroy(cairo->cr);
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void
|
||||
bm_cairo_destroy(struct cairo *cairo)
|
||||
{
|
||||
if (cairo->cr)
|
||||
cairo_destroy(cairo->cr);
|
||||
if (cairo->surface)
|
||||
cairo_surface_destroy(cairo->surface);
|
||||
}
|
||||
|
||||
static inline PangoLayout*
|
||||
bm_pango_get_layout(struct cairo *cairo, struct cairo_paint *paint, const char *buffer)
|
||||
{
|
||||
PangoLayout *layout = pango_cairo_create_layout(cairo->cr);
|
||||
pango_layout_set_text(layout, buffer, -1);
|
||||
PangoFontDescription *desc = pango_font_description_from_string(paint->font);
|
||||
pango_layout_set_font_description(layout, desc);
|
||||
pango_layout_set_single_paragraph_mode(layout, 1);
|
||||
pango_font_description_free(desc);
|
||||
return layout;
|
||||
}
|
||||
|
||||
BM_LOG_ATTR(4, 5) static inline bool
|
||||
bm_pango_get_text_extents(struct cairo *cairo, struct cairo_paint *paint, struct cairo_result *result, const char *fmt, ...)
|
||||
{
|
||||
assert(cairo && paint && result && fmt);
|
||||
memset(result, 0, sizeof(struct cairo_result));
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
bool ret = bm_vrprintf(&buffer, &blen, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
PangoRectangle rect;
|
||||
PangoLayout *layout = bm_pango_get_layout(cairo, paint, buffer);
|
||||
pango_layout_get_pixel_extents(layout, NULL, &rect);
|
||||
int baseline = pango_layout_get_baseline(layout) / PANGO_SCALE;
|
||||
g_object_unref(layout);
|
||||
|
||||
result->x_advance = rect.x + rect.width;
|
||||
result->height = rect.height;
|
||||
result->baseline = baseline;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bm_cairo_draw_line_str(struct cairo *cairo, struct cairo_paint *paint, struct cairo_result *result, const char *buffer)
|
||||
{
|
||||
PangoLayout *layout = bm_pango_get_layout(cairo, paint, buffer);
|
||||
pango_cairo_update_layout(cairo->cr, layout);
|
||||
|
||||
int width, height;
|
||||
pango_layout_get_pixel_size(layout, &width, &height);
|
||||
height = paint->box.h > 0 ? paint->box.h : height;
|
||||
int base = pango_layout_get_baseline(layout) / PANGO_SCALE;
|
||||
|
||||
uint32_t line_height = height + paint->box.by + paint->box.ty;
|
||||
cairo_set_source_rgba(cairo->cr, paint->bg.r, paint->bg.b, paint->bg.g, paint->bg.a);
|
||||
cairo_rectangle(cairo->cr,
|
||||
paint->pos.x - paint->box.lx, paint->pos.y - paint->box.ty,
|
||||
(paint->box.w > 0 ? paint->box.w : width) + paint->box.rx + paint->box.lx,
|
||||
line_height);
|
||||
cairo_fill(cairo->cr);
|
||||
|
||||
cairo_set_source_rgba(cairo->cr, paint->fg.r, paint->fg.b, paint->fg.g, paint->fg.a);
|
||||
cairo_move_to(cairo->cr, paint->box.lx + paint->pos.x, paint->pos.y - base + paint->baseline);
|
||||
pango_cairo_show_layout(cairo->cr, layout);
|
||||
|
||||
if (paint->draw_cursor) {
|
||||
PangoRectangle rect;
|
||||
pango_layout_index_to_pos(layout, paint->cursor, &rect);
|
||||
|
||||
if (!rect.width) {
|
||||
struct cairo_result result = {0};
|
||||
bm_pango_get_text_extents(cairo, paint, &result, "#");
|
||||
rect.width = result.x_advance * PANGO_SCALE;
|
||||
}
|
||||
|
||||
uint32_t cursor_width = rect.width / PANGO_SCALE;
|
||||
if (paint->cursor_width > 0) {
|
||||
cursor_width = paint->cursor_width;
|
||||
}
|
||||
uint32_t cursor_height = fmin(paint->cursor_height == 0 ? line_height : paint->cursor_height, line_height);
|
||||
cairo_set_source_rgba(cairo->cr, paint->cursor_fg.r, paint->cursor_fg.b, paint->cursor_fg.g, paint->cursor_fg.a);
|
||||
cairo_rectangle(cairo->cr,
|
||||
paint->pos.x + paint->box.lx + rect.x / PANGO_SCALE, paint->pos.y - paint->box.ty + ((line_height - cursor_height) / 2),
|
||||
cursor_width, cursor_height);
|
||||
cairo_fill(cairo->cr);
|
||||
|
||||
cairo_rectangle(cairo->cr,
|
||||
paint->pos.x + paint->box.lx + rect.x / PANGO_SCALE, paint->pos.y - paint->box.ty,
|
||||
cursor_width, line_height);
|
||||
cairo_clip(cairo->cr);
|
||||
|
||||
cairo_set_source_rgba(cairo->cr, paint->cursor_bg.r, paint->cursor_bg.b, paint->cursor_bg.g, paint->cursor_bg.a);
|
||||
cairo_move_to(cairo->cr, paint->box.lx + paint->pos.x, paint->pos.y - base + paint->baseline);
|
||||
pango_cairo_show_layout(cairo->cr, layout);
|
||||
cairo_reset_clip(cairo->cr);
|
||||
}
|
||||
|
||||
g_object_unref(layout);
|
||||
|
||||
result->x_advance = width + paint->box.rx;
|
||||
result->height = line_height;
|
||||
|
||||
cairo_identity_matrix(cairo->cr);
|
||||
return true;
|
||||
}
|
||||
|
||||
BM_LOG_ATTR(4, 5) static inline bool
|
||||
bm_cairo_draw_line(struct cairo *cairo, struct cairo_paint *paint, struct cairo_result *result, const char *fmt, ...)
|
||||
{
|
||||
assert(cairo && paint && result && fmt);
|
||||
memset(result, 0, sizeof(struct cairo_result));
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
bool ret = bm_vrprintf(&buffer, &blen, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
return bm_cairo_draw_line_str(cairo, paint, result, buffer);
|
||||
}
|
||||
|
||||
static inline void
|
||||
bm_cairo_color_from_menu_color(const struct bm_menu *menu, enum bm_color color, struct cairo_color *c)
|
||||
{
|
||||
assert(menu);
|
||||
c->r = (float)menu->colors[color].r / 255.0f;
|
||||
c->g = (float)menu->colors[color].g / 255.0f;
|
||||
c->b = (float)menu->colors[color].b / 255.0f;
|
||||
c->a = (float)menu->colors[color].a / 255.0f;
|
||||
}
|
||||
|
||||
static char *
|
||||
bm_cairo_entry_message(char *entry_text, bool highlighted, uint32_t event_feedback, uint32_t index, uint32_t count)
|
||||
{
|
||||
if (!highlighted || !event_feedback) {
|
||||
return entry_text ? entry_text : "";
|
||||
} else {
|
||||
if (event_feedback & TOUCH_WILL_CANCEL) {
|
||||
return "Cancel…";
|
||||
}
|
||||
if (event_feedback & TOUCH_WILL_SCROLL_FIRST) {
|
||||
if (index == 0) {
|
||||
return "Already on the first page…";
|
||||
} else {
|
||||
return "First page…";
|
||||
}
|
||||
}
|
||||
if (event_feedback & TOUCH_WILL_SCROLL_UP) {
|
||||
if (index == 0) {
|
||||
return "Already on the first page…";
|
||||
} else {
|
||||
return "Previous page…";
|
||||
}
|
||||
}
|
||||
if (event_feedback & TOUCH_WILL_SCROLL_DOWN) {
|
||||
if (index == count - 1) {
|
||||
return "Already on the last page…";
|
||||
} else {
|
||||
return "Next page…";
|
||||
}
|
||||
}
|
||||
if (event_feedback & TOUCH_WILL_SCROLL_LAST) {
|
||||
if (index == count - 1) {
|
||||
return "Already on the last page…";
|
||||
} else {
|
||||
return "Last page…";
|
||||
}
|
||||
}
|
||||
return "Not handled feedback…";
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t max_height, const struct bm_menu *menu, struct cairo_paint_result *out_result)
|
||||
{
|
||||
assert(cairo && menu && out_result);
|
||||
|
||||
max_height /= cairo->scale;
|
||||
|
||||
memset(out_result, 0, sizeof(struct cairo_paint_result));
|
||||
out_result->displayed = 1;
|
||||
|
||||
struct cairo_paint paint = {0};
|
||||
paint.font = menu->font.name;
|
||||
|
||||
struct cairo_result result = {0};
|
||||
int ascii_height;
|
||||
bm_pango_get_text_extents(cairo, &paint, &result, "!\"#$%%&'()*+,-./0123456789:;<=>?@ABCD"
|
||||
"EFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
|
||||
ascii_height = result.height;
|
||||
paint.baseline = result.baseline;
|
||||
|
||||
uint32_t border_size = menu->border_size;
|
||||
width -= border_size;
|
||||
uint32_t height = fmin(fmax(menu->line_height, ascii_height), max_height);
|
||||
uint32_t vpadding = (height - ascii_height)/2;
|
||||
|
||||
cairo_set_source_rgba(cairo->cr, 0, 0, 0, 0);
|
||||
cairo_rectangle(cairo->cr, 0, 0, width, height);
|
||||
|
||||
cairo_save(cairo->cr);
|
||||
cairo_set_operator(cairo->cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_paint(cairo->cr);
|
||||
cairo_restore(cairo->cr);
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
uint32_t title_x = 0;
|
||||
if (menu->title) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_TITLE_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_TITLE_BG, &paint.bg);
|
||||
paint.pos = (struct pos){ result.x_advance + border_size + 4, vpadding + border_size };
|
||||
paint.box = (struct box){ 4, 16, vpadding, -vpadding, 0, height };
|
||||
bm_cairo_draw_line(cairo, &paint, &result, "%s", menu->title);
|
||||
title_x = result.x_advance;
|
||||
}
|
||||
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_FILTER_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_FILTER_BG, &paint.bg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_CURSOR_FG, &paint.cursor_fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_CURSOR_BG, &paint.cursor_bg);
|
||||
paint.draw_cursor = true;
|
||||
paint.cursor = menu->cursor;
|
||||
paint.cursor_height = menu->cursor_height;
|
||||
paint.cursor_width = menu->cursor_width;
|
||||
paint.pos = (struct pos){ (menu->title ? 2 : 0) + result.x_advance + border_size, vpadding + border_size };
|
||||
paint.box = (struct box){ (menu->title ? 2 : 4), 0, vpadding, -vpadding, width - paint.pos.x, height };
|
||||
|
||||
const char *filter_text = (menu->filter ? menu->filter : "");
|
||||
if (menu->password) {
|
||||
bm_cairo_draw_line_str(cairo, &paint, &result, "");
|
||||
} else {
|
||||
bm_cairo_draw_line(cairo, &paint, &result, "%s", filter_text);
|
||||
}
|
||||
|
||||
paint.draw_cursor = false;
|
||||
const uint32_t titleh = result.height;
|
||||
out_result->height = titleh;
|
||||
|
||||
uint32_t count;
|
||||
struct bm_item **items = bm_menu_get_filtered_items(menu, &count);
|
||||
uint32_t lines = (menu->lines > 0 ? menu->lines : 1);
|
||||
uint32_t page_length = 0;
|
||||
|
||||
if (menu->lines > 0) {
|
||||
/* vertical mode */
|
||||
|
||||
const bool scrollbar = (menu->scrollbar > BM_SCROLLBAR_NONE && (menu->scrollbar != BM_SCROLLBAR_AUTOHIDE || count > lines) ? true : false);
|
||||
uint32_t spacing_x = menu->spacing ? title_x : 0, spacing_y = 0; // 0 == variable width spacing
|
||||
if (lines > max_height / titleh) {
|
||||
/* there is more lines than screen can fit, enter fixed spacing mode */
|
||||
lines = max_height / titleh - 1;
|
||||
spacing_y = titleh;
|
||||
}
|
||||
|
||||
uint32_t prefix_x = 0;
|
||||
if (menu->prefix) {
|
||||
bm_pango_get_text_extents(cairo, &paint, &result, "%s ", menu->prefix);
|
||||
prefix_x += result.x_advance;
|
||||
}
|
||||
|
||||
uint32_t scrollbar_w = 0;
|
||||
if (scrollbar) {
|
||||
bm_pango_get_text_extents(cairo, &paint, &result, "#");
|
||||
scrollbar_w = result.x_advance;
|
||||
spacing_x += (spacing_x < scrollbar_w ? scrollbar_w : 0);
|
||||
}
|
||||
|
||||
uint32_t posy = titleh;
|
||||
const uint32_t page = (menu->index / lines) * lines;
|
||||
for (uint32_t l = 0, i = page; l < lines && i < count && posy < max_height; ++i, ++l) {
|
||||
bool highlighted = (items[i] == bm_menu_get_highlighted_item(menu));
|
||||
|
||||
if (highlighted) {
|
||||
if (menu->event_feedback) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_FEEDBACK_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_FEEDBACK_BG, &paint.bg);
|
||||
} else {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_HIGHLIGHTED_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_HIGHLIGHTED_BG, &paint.bg);
|
||||
}
|
||||
} else if (bm_menu_item_is_selected(menu, items[i])) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_SELECTED_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_SELECTED_BG, &paint.bg);
|
||||
} else if (i % 2 == 1) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ALTERNATE_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ALTERNATE_BG, &paint.bg);
|
||||
} else {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ITEM_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ITEM_BG, &paint.bg);
|
||||
}
|
||||
|
||||
char *line_str = bm_cairo_entry_message(items[i]->text, highlighted, menu->event_feedback, i, count);
|
||||
if (menu->prefix && highlighted) {
|
||||
paint.pos = (struct pos){ spacing_x + border_size, posy+vpadding + border_size };
|
||||
paint.box = (struct box){ 4, 0, vpadding, -vpadding, width - paint.pos.x, height };
|
||||
bm_cairo_draw_line(cairo, &paint, &result, "%s %s", menu->prefix, line_str);
|
||||
} else {
|
||||
paint.pos = (struct pos){ spacing_x + border_size, posy+vpadding + border_size };
|
||||
paint.box = (struct box){ 4 + prefix_x, 0, vpadding, -vpadding, width - paint.pos.x, height };
|
||||
bm_cairo_draw_line(cairo, &paint, &result, "%s", line_str);
|
||||
}
|
||||
|
||||
posy += (spacing_y ? spacing_y : result.height);
|
||||
out_result->height = posy;
|
||||
out_result->displayed++;
|
||||
page_length += 1;
|
||||
}
|
||||
|
||||
if (spacing_x) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ITEM_BG, &paint.bg);
|
||||
const uint32_t sheight = out_result->height - titleh;
|
||||
cairo_set_source_rgba(cairo->cr, paint.bg.r, paint.bg.b, paint.bg.g, paint.bg.a);
|
||||
cairo_rectangle(cairo->cr, scrollbar_w + border_size, titleh + border_size, spacing_x - scrollbar_w, sheight);
|
||||
cairo_fill(cairo->cr);
|
||||
}
|
||||
|
||||
if (scrollbar && count > 0) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_SCROLLBAR_BG, &paint.bg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_SCROLLBAR_FG, &paint.fg);
|
||||
|
||||
const uint32_t sheight = out_result->height - titleh;
|
||||
cairo_set_source_rgba(cairo->cr, paint.bg.r, paint.bg.b, paint.bg.g, paint.bg.a);
|
||||
cairo_rectangle(cairo->cr, border_size, titleh + border_size, scrollbar_w, sheight);
|
||||
cairo_fill(cairo->cr);
|
||||
|
||||
const float percent = fmin(((float)page / (count - lines)), 1.0f);
|
||||
const float fraction = fmin((float)lines / count, 1.0f);
|
||||
const uint32_t size = fmax(sheight * fraction, 2.0f);
|
||||
const uint32_t posy = percent * (sheight - size);
|
||||
cairo_set_source_rgba(cairo->cr, paint.fg.r, paint.fg.b, paint.fg.g, paint.fg.a);
|
||||
cairo_rectangle(cairo->cr, border_size, titleh + posy + border_size, scrollbar_w, size);
|
||||
cairo_fill(cairo->cr);
|
||||
}
|
||||
} else {
|
||||
/* single-line mode */
|
||||
bm_pango_get_text_extents(cairo, &paint, &result, "lorem ipsum lorem ipsum lorem ipsum lorem");
|
||||
uint32_t cl = fmin(title_x + result.x_advance, width / 4);
|
||||
|
||||
if (count > 0) {
|
||||
paint.pos = (struct pos){ cl, vpadding + border_size };
|
||||
paint.box = (struct box){ 1, 2, vpadding, -vpadding, 0, height };
|
||||
bm_cairo_draw_line(cairo, &paint, &result, (count > 0 && (menu->wrap || menu->index > 0) ? "<" : " "));
|
||||
cl += result.x_advance + 1;
|
||||
}
|
||||
|
||||
for (uint32_t i = menu->index; i < count && cl < (width/cairo->scale); ++i) {
|
||||
bool highlighted = (items[i] == bm_menu_get_highlighted_item(menu));
|
||||
|
||||
if (highlighted) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_HIGHLIGHTED_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_HIGHLIGHTED_BG, &paint.bg);
|
||||
} else if (bm_menu_item_is_selected(menu, items[i])) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_SELECTED_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_SELECTED_BG, &paint.bg);
|
||||
} else if (i % 2 == 1) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ALTERNATE_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ALTERNATE_BG, &paint.bg);
|
||||
} else {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ITEM_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_ITEM_BG, &paint.bg);
|
||||
}
|
||||
|
||||
uint32_t hpadding = (menu->hpadding == 0 ? 2 : menu->hpadding);
|
||||
paint.pos = (struct pos){ cl + (hpadding/2), vpadding + border_size };
|
||||
paint.box = (struct box){ hpadding/2, 1.5 * hpadding, vpadding, -vpadding, 0, height };
|
||||
bm_cairo_draw_line(cairo, &paint, &result, "%s", (items[i]->text ? items[i]->text : ""));
|
||||
cl += result.x_advance + (0.5 * hpadding);
|
||||
out_result->displayed += (cl < width);
|
||||
out_result->height = fmax(out_result->height, result.height);
|
||||
}
|
||||
|
||||
if (menu->wrap || menu->index + 1 < count) {
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_FILTER_FG, &paint.fg);
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_FILTER_BG, &paint.bg);
|
||||
bm_pango_get_text_extents(cairo, &paint, &result, ">");
|
||||
paint.pos = (struct pos){ width/cairo->scale - result.x_advance - 2, vpadding + border_size };
|
||||
paint.box = (struct box){ 1, 2, vpadding, -vpadding, 0, height };
|
||||
bm_cairo_draw_line(cairo, &paint, &result, ">");
|
||||
}
|
||||
}
|
||||
|
||||
// Draw borders
|
||||
bm_cairo_color_from_menu_color(menu, BM_COLOR_BORDER, &paint.fg);
|
||||
cairo_set_source_rgba(cairo->cr, paint.fg.r, paint.fg.b, paint.fg.g, paint.fg.a);
|
||||
cairo_rectangle(cairo->cr, 0, 0, width + border_size, (height * (page_length + 1)) + (2 * border_size));
|
||||
cairo_set_line_width(cairo->cr, 2 * menu->border_size);
|
||||
cairo_stroke(cairo->cr);
|
||||
|
||||
out_result->height += 2 * border_size;
|
||||
out_result->height *= cairo->scale;
|
||||
}
|
||||
|
||||
#endif /* _BM_CAIRO_H */
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
448
.config/dwl/menu/lib/renderers/curses/curses.c
Normal file
448
.config/dwl/menu/lib/renderers/curses/curses.c
Normal file
|
@ -0,0 +1,448 @@
|
|||
#include "internal.h"
|
||||
#include <wchar.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
#include <dlfcn.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#define _XOPEN_SOURCE_EXTENDED
|
||||
#define NCURSES_WIDECHAR 1
|
||||
#include <curses.h>
|
||||
|
||||
#if _WIN32
|
||||
static const char *TTY = "CON";
|
||||
#else
|
||||
static const char *TTY = "/dev/tty";
|
||||
#endif
|
||||
|
||||
#if NCURSES_EXT_FUNCS < 20150808
|
||||
# define set_escdelay(x) ESCDELAY = (x)
|
||||
#endif
|
||||
|
||||
static struct curses {
|
||||
WINDOW *stdscreen;
|
||||
struct sigaction abrt_action;
|
||||
struct sigaction segv_action;
|
||||
struct sigaction winch_action;
|
||||
char *buffer;
|
||||
size_t blen;
|
||||
int old_stdin;
|
||||
int old_stdout;
|
||||
bool polled_once;
|
||||
bool should_terminate;
|
||||
} curses;
|
||||
|
||||
static inline void ignore_ret(int useless, ...) { (void)useless; }
|
||||
|
||||
static void
|
||||
reopen_stdin(void)
|
||||
{
|
||||
ignore_ret(0, freopen(TTY, "r", stdin));
|
||||
}
|
||||
|
||||
static void
|
||||
reopen_stdin_stdout(void)
|
||||
{
|
||||
reopen_stdin();
|
||||
ignore_ret(0, freopen(TTY, "w", stdout));
|
||||
}
|
||||
|
||||
static void
|
||||
store_stdin_stdout(void)
|
||||
{
|
||||
curses.old_stdin = dup(STDIN_FILENO);
|
||||
curses.old_stdout = dup(STDOUT_FILENO);
|
||||
}
|
||||
|
||||
static void
|
||||
restore_stdin(void)
|
||||
{
|
||||
if (curses.old_stdin != -1) {
|
||||
dup2(curses.old_stdin, STDIN_FILENO);
|
||||
close(curses.old_stdin);
|
||||
curses.old_stdin = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
restore_stdin_stdout(void)
|
||||
{
|
||||
restore_stdin();
|
||||
|
||||
if (curses.old_stdout != -1) {
|
||||
dup2(curses.old_stdout, STDOUT_FILENO);
|
||||
close(curses.old_stdout);
|
||||
curses.old_stdout = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
terminate(void)
|
||||
{
|
||||
if (curses.buffer) {
|
||||
free(curses.buffer);
|
||||
curses.buffer = NULL;
|
||||
curses.blen = 0;
|
||||
}
|
||||
|
||||
if (!curses.stdscreen)
|
||||
return;
|
||||
|
||||
reopen_stdin_stdout();
|
||||
refresh();
|
||||
endwin();
|
||||
restore_stdin_stdout();
|
||||
curses.stdscreen = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
crash_handler(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
terminate();
|
||||
}
|
||||
|
||||
static void
|
||||
resize_handler(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
if (!curses.stdscreen)
|
||||
return;
|
||||
|
||||
refresh();
|
||||
endwin();
|
||||
}
|
||||
|
||||
BM_LOG_ATTR(3, 4) static void
|
||||
draw_line(int32_t pair, int32_t y, const char *fmt, ...)
|
||||
{
|
||||
assert(fmt);
|
||||
|
||||
size_t ncols;
|
||||
if ((ncols = getmaxx(curses.stdscreen)) <= 0)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
bool ret = bm_vrprintf(&curses.buffer, &curses.blen, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
size_t nlen = strlen(curses.buffer);
|
||||
size_t dw = 0, i = 0;
|
||||
while (dw < ncols && i < nlen) {
|
||||
if (curses.buffer[i] == '\t') curses.buffer[i] = ' ';
|
||||
int32_t next = bm_utf8_rune_next(curses.buffer, i);
|
||||
dw += bm_utf8_rune_width(curses.buffer + i, next);
|
||||
i += (next ? next : 1);
|
||||
}
|
||||
|
||||
if (dw < ncols) {
|
||||
/* line is too short, widen it */
|
||||
size_t offset = i + (ncols - dw);
|
||||
if (curses.blen <= offset && !bm_resize_buffer(&curses.buffer, &curses.blen, offset + 1))
|
||||
return;
|
||||
|
||||
memset(curses.buffer + nlen, ' ', offset - nlen);
|
||||
curses.buffer[offset] = 0;
|
||||
} else if (i < curses.blen) {
|
||||
/* line is too long, shorten it */
|
||||
i -= bm_utf8_rune_prev(curses.buffer, i - (dw - ncols)) - 1;
|
||||
size_t cc = dw - (dw - ncols);
|
||||
|
||||
size_t offset = i - (dw - ncols) + (ncols - cc) + 1;
|
||||
if (curses.blen <= offset) {
|
||||
int32_t diff = offset - curses.blen + 1;
|
||||
if (!bm_resize_buffer(&curses.buffer, &curses.blen, curses.blen + diff))
|
||||
return;
|
||||
}
|
||||
|
||||
memset(curses.buffer + i - (dw - ncols), ' ', (ncols - cc) + 1);
|
||||
curses.buffer[offset] = 0;
|
||||
}
|
||||
|
||||
if (pair > 0)
|
||||
attron(COLOR_PAIR(pair));
|
||||
|
||||
mvprintw(y, 0, "%s", curses.buffer);
|
||||
|
||||
if (pair > 0)
|
||||
attroff(COLOR_PAIR(pair));
|
||||
}
|
||||
|
||||
static bool
|
||||
render(struct bm_menu *menu)
|
||||
{
|
||||
if (curses.should_terminate) {
|
||||
terminate();
|
||||
curses.should_terminate = false;
|
||||
}
|
||||
|
||||
if (!curses.stdscreen) {
|
||||
store_stdin_stdout();
|
||||
reopen_stdin_stdout();
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
if ((curses.stdscreen = initscr()) == NULL)
|
||||
return true;
|
||||
|
||||
set_escdelay(25);
|
||||
flushinp();
|
||||
keypad(curses.stdscreen, true);
|
||||
curs_set(1);
|
||||
noecho();
|
||||
raw();
|
||||
|
||||
start_color();
|
||||
use_default_colors();
|
||||
init_pair(1, COLOR_BLACK, COLOR_RED);
|
||||
init_pair(2, COLOR_RED, -1);
|
||||
}
|
||||
|
||||
erase();
|
||||
|
||||
uint32_t ncols = getmaxx(curses.stdscreen);
|
||||
uint32_t title_len = (menu->title ? strlen(menu->title) + 1 : 0);
|
||||
|
||||
if (title_len >= ncols)
|
||||
title_len = 0;
|
||||
|
||||
uint32_t ccols = ncols - title_len - 1;
|
||||
uint32_t dcols = 0, doffset = menu->cursor;
|
||||
|
||||
while (doffset > 0 && dcols < ccols) {
|
||||
int prev = bm_utf8_rune_prev(menu->filter, doffset);
|
||||
dcols += bm_utf8_rune_width(menu->filter + doffset - prev, prev);
|
||||
doffset -= (prev ? prev : 1);
|
||||
}
|
||||
|
||||
const char *filter_text = (menu->filter ? menu->filter + doffset : "");
|
||||
if (menu->password) {
|
||||
draw_line(0, 0, "%*s", title_len, "");
|
||||
} else {
|
||||
draw_line(0, 0, "%*s%s", title_len, "", filter_text);
|
||||
}
|
||||
|
||||
if (menu->title && title_len > 0) {
|
||||
attron(COLOR_PAIR(1));
|
||||
mvprintw(0, 0, "%s", menu->title);
|
||||
attroff(COLOR_PAIR(1));
|
||||
}
|
||||
|
||||
uint32_t count, cl = 0;
|
||||
const uint32_t lines = fmax(getmaxy(curses.stdscreen), 1) - 1;
|
||||
if (lines > 1) {
|
||||
uint32_t displayed = 0;
|
||||
struct bm_item **items = bm_menu_get_filtered_items(menu, &count);
|
||||
const bool scrollbar = (menu->scrollbar > BM_SCROLLBAR_NONE && (menu->scrollbar != BM_SCROLLBAR_AUTOHIDE || count > lines) ? true : false);
|
||||
const int32_t offset_x = title_len + (scrollbar && 2 > title_len ? 2 - title_len : 0);
|
||||
const int32_t prefix_x = (menu->prefix ? bm_utf8_string_screen_width(menu->prefix) : 0);
|
||||
|
||||
const uint32_t page = menu->index / lines * lines;
|
||||
for (uint32_t i = page; i < count && cl < lines; ++i) {
|
||||
bool highlighted = (items[i] == bm_menu_get_highlighted_item(menu));
|
||||
int32_t color = (highlighted ? 2 : (bm_menu_item_is_selected(menu, items[i]) ? 1 : 0));
|
||||
|
||||
if (menu->prefix && highlighted) {
|
||||
draw_line(color, 1 + cl++, "%*s%s %s", offset_x, "", menu->prefix, (items[i]->text ? items[i]->text : ""));
|
||||
} else {
|
||||
draw_line(color, 1 + cl++, "%*s%s%s", offset_x + prefix_x, "", (menu->prefix ? " " : ""), (items[i]->text ? items[i]->text : ""));
|
||||
}
|
||||
|
||||
++displayed;
|
||||
}
|
||||
|
||||
if (scrollbar) {
|
||||
attron(COLOR_PAIR(1));
|
||||
const float percent = fmin(((float)page / (count - lines)), 1.0f);
|
||||
const uint32_t size = fmax(lines * ((float)lines / count), 1.0f);
|
||||
const uint32_t posy = percent * (lines - size);
|
||||
for (uint32_t i = 0; i < size; ++i)
|
||||
mvprintw(1 + posy + i, 0, "▒");
|
||||
attroff(COLOR_PAIR(1));
|
||||
}
|
||||
}
|
||||
|
||||
move(0, title_len + (menu->curses_cursor < ccols ? menu->curses_cursor : ccols));
|
||||
refresh();
|
||||
|
||||
// Make it possible to read stdin even after rendering
|
||||
// Only make it impossible to read original stdin after poll_key is called once
|
||||
// This is mainly to make -f work even on curses backend
|
||||
if (!curses.polled_once) {
|
||||
reopen_stdin();
|
||||
restore_stdin();
|
||||
curses.should_terminate = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_displayed_count(const struct bm_menu *menu)
|
||||
{
|
||||
(void)menu;
|
||||
return (curses.stdscreen ? getmaxy(curses.stdscreen) : 0);
|
||||
}
|
||||
|
||||
static enum bm_key
|
||||
poll_key(const struct bm_menu *menu, uint32_t *unicode)
|
||||
{
|
||||
(void)menu;
|
||||
assert(unicode);
|
||||
*unicode = 0;
|
||||
curses.polled_once = true;
|
||||
|
||||
if (!curses.stdscreen || curses.should_terminate)
|
||||
return BM_KEY_NONE;
|
||||
|
||||
get_wch((wint_t*)unicode);
|
||||
|
||||
switch (*unicode) {
|
||||
#if KEY_RESIZE
|
||||
case KEY_RESIZE:
|
||||
return BM_KEY_NONE;
|
||||
#endif
|
||||
|
||||
case 16: /* C-p */
|
||||
case KEY_UP:
|
||||
return BM_KEY_UP;
|
||||
|
||||
case 14: /* C-n */
|
||||
case KEY_DOWN:
|
||||
return BM_KEY_DOWN;
|
||||
|
||||
case 2: /* C-b */
|
||||
case KEY_LEFT:
|
||||
return BM_KEY_LEFT;
|
||||
|
||||
case 6: /* C-f */
|
||||
case KEY_RIGHT:
|
||||
return BM_KEY_RIGHT;
|
||||
|
||||
case 1: /* C-a */
|
||||
case 391: /* S-Home */
|
||||
case KEY_HOME:
|
||||
return BM_KEY_HOME;
|
||||
|
||||
case 5: /* C-e */
|
||||
case 386: /* S-End */
|
||||
case KEY_END:
|
||||
return BM_KEY_END;
|
||||
|
||||
case KEY_PPAGE: /* Page up */
|
||||
return BM_KEY_PAGE_UP;
|
||||
|
||||
case 22: /* C-v */
|
||||
case KEY_NPAGE: /* Page down */
|
||||
return BM_KEY_PAGE_DOWN;
|
||||
|
||||
case 550: /* C-Page up */
|
||||
case 398: /* S-Page up */
|
||||
return BM_KEY_SHIFT_PAGE_UP;
|
||||
|
||||
case 545: /* C-Page down */
|
||||
case 396: /* S-Page down */
|
||||
return BM_KEY_SHIFT_PAGE_DOWN;
|
||||
|
||||
case 8: /* C-h */
|
||||
case 127: /* Delete */
|
||||
case KEY_BACKSPACE:
|
||||
return BM_KEY_BACKSPACE;
|
||||
|
||||
case 4: /* C-d */
|
||||
case KEY_DC:
|
||||
return BM_KEY_DELETE;
|
||||
|
||||
case 383: /* S-Del */
|
||||
case 21: /* C-u */
|
||||
return BM_KEY_LINE_DELETE_LEFT;
|
||||
|
||||
case 11: /* C-k */
|
||||
return BM_KEY_LINE_DELETE_RIGHT;
|
||||
|
||||
case 23: /* C-w */
|
||||
return BM_KEY_WORD_DELETE;
|
||||
|
||||
case 9: /* Tab */
|
||||
return BM_KEY_TAB;
|
||||
|
||||
case 353: /* S-Tab */
|
||||
return BM_KEY_SHIFT_TAB;
|
||||
|
||||
case 18: /* C-r */
|
||||
return BM_KEY_CONTROL_RETURN;
|
||||
|
||||
case 20: /* C-t */
|
||||
case 331: /* Insert */
|
||||
terminate();
|
||||
return BM_KEY_SHIFT_RETURN;
|
||||
|
||||
case 10: /* Return */
|
||||
case 13: /* C-m */
|
||||
terminate();
|
||||
return BM_KEY_RETURN;
|
||||
|
||||
case 7: /* C-g */
|
||||
case 27: /* Escape */
|
||||
terminate();
|
||||
return BM_KEY_ESCAPE;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return BM_KEY_UNICODE;
|
||||
}
|
||||
|
||||
static void
|
||||
destructor(struct bm_menu *menu)
|
||||
{
|
||||
(void)menu;
|
||||
terminate();
|
||||
sigaction(SIGABRT, &curses.abrt_action, NULL);
|
||||
sigaction(SIGSEGV, &curses.segv_action, NULL);
|
||||
sigaction(SIGWINCH, &curses.winch_action, NULL);
|
||||
memset(&curses, 0, sizeof(curses));
|
||||
}
|
||||
|
||||
static bool
|
||||
constructor(struct bm_menu *menu)
|
||||
{
|
||||
(void)menu;
|
||||
assert(!curses.stdscreen && "bemenu supports only one curses instance");
|
||||
|
||||
memset(&curses, 0, sizeof(curses));
|
||||
curses.old_stdin = -1;
|
||||
curses.old_stdout = -1;
|
||||
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(struct sigaction));
|
||||
action.sa_handler = crash_handler;
|
||||
sigaction(SIGABRT, &action, &curses.abrt_action);
|
||||
sigaction(SIGSEGV, &action, &curses.segv_action);
|
||||
|
||||
action.sa_handler = resize_handler;
|
||||
sigaction(SIGWINCH, &action, &curses.winch_action);
|
||||
return true;
|
||||
}
|
||||
|
||||
BM_PUBLIC extern const char*
|
||||
register_renderer(struct render_api *api)
|
||||
{
|
||||
api->constructor = constructor;
|
||||
api->destructor = destructor;
|
||||
api->get_displayed_count = get_displayed_count;
|
||||
api->poll_key = poll_key;
|
||||
api->render = render;
|
||||
api->priorty = BM_PRIO_TERMINAL;
|
||||
api->version = BM_PLUGIN_VERSION;
|
||||
return "curses";
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
701
.config/dwl/menu/lib/renderers/wayland/registry.c
Normal file
701
.config/dwl/menu/lib/renderers/wayland/registry.c
Normal file
|
@ -0,0 +1,701 @@
|
|||
#include "wayland.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *BM_XKB_MASK_NAMES[MASK_LAST] = {
|
||||
XKB_MOD_NAME_SHIFT,
|
||||
XKB_MOD_NAME_CAPS,
|
||||
XKB_MOD_NAME_CTRL,
|
||||
XKB_MOD_NAME_ALT,
|
||||
"Mod2",
|
||||
"Mod3",
|
||||
XKB_MOD_NAME_LOGO,
|
||||
"Mod5",
|
||||
};
|
||||
|
||||
const enum mod_bit BM_XKB_MODS[MASK_LAST] = {
|
||||
MOD_SHIFT,
|
||||
MOD_CAPS,
|
||||
MOD_CTRL,
|
||||
MOD_ALT,
|
||||
MOD_MOD2,
|
||||
MOD_MOD3,
|
||||
MOD_LOGO,
|
||||
MOD_MOD5
|
||||
};
|
||||
|
||||
static void
|
||||
shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
|
||||
{
|
||||
(void)wl_shm;
|
||||
struct wayland *wayland = data;
|
||||
wayland->formats |= (1 << format);
|
||||
}
|
||||
|
||||
struct wl_shm_listener shm_listener = {
|
||||
.format = shm_format
|
||||
};
|
||||
|
||||
static void
|
||||
keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size)
|
||||
{
|
||||
(void)keyboard;
|
||||
struct input *input = data;
|
||||
|
||||
if (!data) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
char *map_str;
|
||||
if ((map_str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
struct xkb_keymap *keymap = xkb_keymap_new_from_string(input->xkb.context, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
|
||||
munmap(map_str, size);
|
||||
close(fd);
|
||||
|
||||
if (!keymap) {
|
||||
fprintf(stderr, "failed to compile keymap\n");
|
||||
return;
|
||||
}
|
||||
|
||||
struct xkb_state *state;
|
||||
if (!(state = xkb_state_new(keymap))) {
|
||||
fprintf(stderr, "failed to create XKB state\n");
|
||||
xkb_keymap_unref(keymap);
|
||||
return;
|
||||
}
|
||||
|
||||
xkb_keymap_unref(input->xkb.keymap);
|
||||
xkb_state_unref(input->xkb.state);
|
||||
input->xkb.keymap = keymap;
|
||||
input->xkb.state = state;
|
||||
|
||||
for (uint32_t i = 0; i < MASK_LAST; ++i)
|
||||
input->xkb.masks[i] = 1 << xkb_keymap_mod_get_index(input->xkb.keymap, BM_XKB_MASK_NAMES[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
|
||||
{
|
||||
(void)data, (void)keyboard, (void)serial, (void)surface, (void)keys;
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
(void)keyboard, (void)serial, (void)surface;
|
||||
struct input *input = data;
|
||||
struct itimerspec its;
|
||||
its.it_interval.tv_sec = 0;
|
||||
its.it_interval.tv_nsec = 0;
|
||||
its.it_value.tv_sec = 0;
|
||||
its.it_value.tv_nsec = 0;
|
||||
timerfd_settime(*input->repeat_fd, 0, &its, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
press(struct input *input, xkb_keysym_t sym, uint32_t key, enum wl_keyboard_key_state state)
|
||||
{
|
||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
input->sym = sym;
|
||||
input->code = key + 8;
|
||||
input->key_pending = true;
|
||||
} else if (!input->key_pending) {
|
||||
input->sym = XKB_KEY_NoSymbol;
|
||||
input->code = 0;
|
||||
}
|
||||
|
||||
if (input->notify.key)
|
||||
input->notify.key(state, sym, key);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state_w)
|
||||
{
|
||||
(void)keyboard, (void)serial, (void)time;
|
||||
struct input *input = data;
|
||||
enum wl_keyboard_key_state state = state_w;
|
||||
|
||||
if (!input->xkb.state)
|
||||
return;
|
||||
|
||||
xkb_keysym_t sym = xkb_state_key_get_one_sym(input->xkb.state, key + 8);
|
||||
press(input, sym, key, state);
|
||||
|
||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED && xkb_keymap_key_repeats(input->xkb.keymap, input->code)) {
|
||||
struct itimerspec its;
|
||||
input->repeat_sym = sym;
|
||||
input->repeat_key = key;
|
||||
its.it_interval.tv_sec = input->repeat_rate_sec;
|
||||
its.it_interval.tv_nsec = input->repeat_rate_nsec;
|
||||
its.it_value.tv_sec = input->repeat_delay_sec;
|
||||
its.it_value.tv_nsec = input->repeat_delay_nsec;
|
||||
timerfd_settime(*input->repeat_fd, 0, &its, NULL);
|
||||
} else if (state == WL_KEYBOARD_KEY_STATE_RELEASED && key == input->repeat_key) {
|
||||
struct itimerspec its;
|
||||
its.it_interval.tv_sec = 0;
|
||||
its.it_interval.tv_nsec = 0;
|
||||
its.it_value.tv_sec = 0;
|
||||
its.it_value.tv_nsec = 0;
|
||||
timerfd_settime(*input->repeat_fd, 0, &its, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
|
||||
{
|
||||
(void)keyboard, (void)serial;
|
||||
struct input *input = data;
|
||||
|
||||
if (!input->xkb.keymap)
|
||||
return;
|
||||
|
||||
xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
|
||||
xkb_mod_mask_t mask = xkb_state_serialize_mods(input->xkb.state, XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
|
||||
|
||||
input->modifiers = 0;
|
||||
for (uint32_t i = 0; i < MASK_LAST; ++i) {
|
||||
if (mask & input->xkb.masks[i])
|
||||
input->modifiers |= BM_XKB_MODS[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_repeat_info(struct input *input, int32_t rate, int32_t delay)
|
||||
{
|
||||
assert(input);
|
||||
|
||||
input->repeat_rate_sec = input->repeat_rate_nsec = 0;
|
||||
input->repeat_delay_sec = input->repeat_delay_nsec = 0;
|
||||
|
||||
/* a rate of zero disables any repeating, regardless of the delay's value */
|
||||
if (rate == 0)
|
||||
return;
|
||||
|
||||
if (rate == 1)
|
||||
input->repeat_rate_sec = 1;
|
||||
else
|
||||
input->repeat_rate_nsec = 1000000000 / rate;
|
||||
|
||||
input->repeat_delay_sec = delay / 1000;
|
||||
delay -= (input->repeat_delay_sec * 1000);
|
||||
input->repeat_delay_nsec = delay * 1000 * 1000;
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_handle_repeat_info(void *data, struct wl_keyboard *keyboard, int32_t rate, int32_t delay)
|
||||
{
|
||||
(void)keyboard;
|
||||
set_repeat_info(data, rate, delay);
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||
{
|
||||
(void)wl_pointer, (void)surface;
|
||||
struct input *input = data;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_ENTER;
|
||||
input->pointer_event.serial = serial;
|
||||
input->pointer_event.surface_x = surface_x,
|
||||
input->pointer_event.surface_y = surface_y;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
(void)wl_pointer, (void)surface;
|
||||
struct input *input = data;
|
||||
input->pointer_event.serial = serial;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_LEAVE;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||
{
|
||||
(void)wl_pointer;
|
||||
struct input *input = data;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_MOTION;
|
||||
input->pointer_event.time = time;
|
||||
input->pointer_event.surface_x = surface_x,
|
||||
input->pointer_event.surface_y = surface_y;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
(void)wl_pointer;
|
||||
struct input *input = data;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_BUTTON;
|
||||
input->pointer_event.time = time;
|
||||
input->pointer_event.serial = serial;
|
||||
input->pointer_event.button = button,
|
||||
input->pointer_event.state |= state;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
uint32_t axis, wl_fixed_t value)
|
||||
{
|
||||
(void)wl_pointer;
|
||||
struct input *input = data;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_AXIS;
|
||||
input->pointer_event.time = time;
|
||||
input->pointer_event.axes[axis].valid = true;
|
||||
input->pointer_event.axes[axis].value = value;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t axis_source)
|
||||
{
|
||||
(void)wl_pointer;
|
||||
struct input *input = data;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_AXIS_SOURCE;
|
||||
input->pointer_event.axis_source = axis_source;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t time, uint32_t axis)
|
||||
{
|
||||
(void)wl_pointer;
|
||||
struct input *input = data;
|
||||
input->pointer_event.time = time;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_AXIS_STOP;
|
||||
input->pointer_event.axes[axis].valid = true;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t axis, int32_t discrete)
|
||||
{
|
||||
(void)wl_pointer;
|
||||
struct input *input = data;
|
||||
input->pointer_event.event_mask |= POINTER_EVENT_AXIS_DISCRETE;
|
||||
input->pointer_event.axes[axis].valid = true;
|
||||
input->pointer_event.axes[axis].discrete = discrete;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pointer_handle_frame(void *data, struct wl_pointer *wl_pointer)
|
||||
{
|
||||
(void) data, (void) wl_pointer;
|
||||
}
|
||||
|
||||
static struct touch_point *
|
||||
get_touch_point(struct input *input, int32_t id)
|
||||
{
|
||||
struct touch_event *touch = &input->touch_event;
|
||||
int invalid = -1;
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
if (touch->points[i].id == id) {
|
||||
invalid = i;
|
||||
}
|
||||
if (invalid == -1 && !touch->points[i].valid) {
|
||||
invalid = i;
|
||||
}
|
||||
}
|
||||
if (invalid == -1) {
|
||||
return NULL;
|
||||
}
|
||||
touch->points[invalid].id = id;
|
||||
return &touch->points[invalid];
|
||||
}
|
||||
|
||||
static void
|
||||
reset_all_start_position(struct input *input)
|
||||
{
|
||||
struct touch_event *event = &input->touch_event;
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
struct touch_point *point = &event->points[i];
|
||||
|
||||
if (!point->valid)
|
||||
continue;
|
||||
|
||||
point->surface_start_x = point->surface_x;
|
||||
point->surface_start_y = point->surface_y;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
revalidate_all_released(struct input *input)
|
||||
{
|
||||
struct touch_event *event = &input->touch_event;
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
struct touch_point *point = &event->points[i];
|
||||
|
||||
if (!point->valid && point->event_mask & TOUCH_EVENT_DOWN)
|
||||
point->valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, struct wl_surface *surface, int32_t id,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
(void) wl_touch, (void) surface;
|
||||
struct input *input = data;
|
||||
struct touch_point *point = get_touch_point(input, id);
|
||||
if (point == NULL) {
|
||||
return;
|
||||
}
|
||||
point->valid = true;
|
||||
point->event_mask = TOUCH_EVENT_DOWN;
|
||||
point->surface_x = x,
|
||||
point->surface_y = y;
|
||||
input->touch_event.time = time;
|
||||
input->touch_event.serial = serial;
|
||||
input->touch_event.active += 1;
|
||||
|
||||
revalidate_all_released(input);
|
||||
reset_all_start_position(input);
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, int32_t id)
|
||||
{
|
||||
(void) time, (void) wl_touch, (void) serial;
|
||||
struct input *input = data;
|
||||
struct touch_point *point = get_touch_point(input, id);
|
||||
if (point == NULL) {
|
||||
return;
|
||||
}
|
||||
point->event_mask |= TOUCH_EVENT_UP;
|
||||
input->touch_event.active -= 1;
|
||||
|
||||
reset_all_start_position(input);
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
(void) wl_touch;
|
||||
struct input *input = data;
|
||||
struct touch_point *point = get_touch_point(input, id);
|
||||
if (point == NULL) {
|
||||
return;
|
||||
}
|
||||
point->event_mask |= TOUCH_EVENT_MOTION;
|
||||
point->surface_x = x, point->surface_y = y;
|
||||
input->touch_event.time = time;
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_cancel(void *data, struct wl_touch *wl_touch)
|
||||
{
|
||||
(void) wl_touch, (void) data;
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_shape(void *data, struct wl_touch *wl_touch,
|
||||
int32_t id, wl_fixed_t major, wl_fixed_t minor)
|
||||
{
|
||||
(void) wl_touch;
|
||||
struct input *input = data;
|
||||
struct touch_point *point = get_touch_point(input, id);
|
||||
if (point == NULL) {
|
||||
return;
|
||||
}
|
||||
point->event_mask |= TOUCH_EVENT_SHAPE;
|
||||
point->major = major, point->minor = minor;
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_orientation(void *data, struct wl_touch *wl_touch,
|
||||
int32_t id, wl_fixed_t orientation)
|
||||
{
|
||||
(void) wl_touch;
|
||||
struct input *input = data;
|
||||
struct touch_point *point = get_touch_point(input, id);
|
||||
if (point == NULL) {
|
||||
return;
|
||||
}
|
||||
point->event_mask |= TOUCH_EVENT_ORIENTATION;
|
||||
point->orientation = orientation;
|
||||
}
|
||||
|
||||
static void
|
||||
touch_handle_frame(void *data, struct wl_touch *wl_touch)
|
||||
{
|
||||
(void) data, (void) wl_touch;
|
||||
}
|
||||
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
.enter = pointer_handle_enter,
|
||||
.leave = pointer_handle_leave,
|
||||
.motion = pointer_handle_motion,
|
||||
.button = pointer_handle_button,
|
||||
.axis = pointer_handle_axis,
|
||||
.frame = pointer_handle_frame,
|
||||
.axis_source = pointer_handle_axis_source,
|
||||
.axis_stop = pointer_handle_axis_stop,
|
||||
.axis_discrete = pointer_handle_axis_discrete,
|
||||
};
|
||||
|
||||
static const struct wl_keyboard_listener keyboard_listener = {
|
||||
.keymap = keyboard_handle_keymap,
|
||||
.enter = keyboard_handle_enter,
|
||||
.leave = keyboard_handle_leave,
|
||||
.key = keyboard_handle_key,
|
||||
.modifiers = keyboard_handle_modifiers,
|
||||
.repeat_info = keyboard_handle_repeat_info
|
||||
};
|
||||
|
||||
static const struct wl_touch_listener wl_touch_listener = {
|
||||
.down = touch_handle_down,
|
||||
.up = touch_handle_up,
|
||||
.motion = touch_handle_motion,
|
||||
.frame = touch_handle_frame,
|
||||
.cancel = touch_handle_cancel,
|
||||
.shape = touch_handle_shape,
|
||||
.orientation = touch_handle_orientation,
|
||||
};
|
||||
|
||||
static void
|
||||
seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
|
||||
{
|
||||
struct input *input = data;
|
||||
|
||||
if (!input->seat) {
|
||||
input->seat = seat;
|
||||
}
|
||||
|
||||
if (caps & WL_SEAT_CAPABILITY_KEYBOARD) {
|
||||
input->keyboard = wl_seat_get_keyboard(seat);
|
||||
wl_keyboard_add_listener(input->keyboard, &keyboard_listener, data);
|
||||
}
|
||||
|
||||
if (caps & WL_SEAT_CAPABILITY_POINTER) {
|
||||
input->pointer = wl_seat_get_pointer(seat);
|
||||
wl_pointer_add_listener(input->pointer, &pointer_listener, data);
|
||||
}
|
||||
|
||||
if (caps & WL_SEAT_CAPABILITY_TOUCH) {
|
||||
input->touch = wl_seat_get_touch(seat);
|
||||
wl_touch_add_listener(input->touch, &wl_touch_listener, data);
|
||||
}
|
||||
|
||||
if (seat == input->seat && !(caps & WL_SEAT_CAPABILITY_KEYBOARD) && !(caps & WL_SEAT_CAPABILITY_POINTER)) {
|
||||
wl_keyboard_destroy(input->keyboard);
|
||||
input->seat = NULL;
|
||||
input->keyboard = NULL;
|
||||
input->pointer = NULL;
|
||||
input->touch = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
seat_handle_name(void *data, struct wl_seat *seat, const char *name)
|
||||
{
|
||||
(void)data, (void)seat, (void)name;
|
||||
}
|
||||
|
||||
static const struct wl_seat_listener seat_listener = {
|
||||
.capabilities = seat_handle_capabilities,
|
||||
.name = seat_handle_name
|
||||
};
|
||||
|
||||
static void
|
||||
xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, int32_t x, int32_t y)
|
||||
{
|
||||
(void)data, (void)xdg_output, (void)x, (void)y;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height)
|
||||
{
|
||||
(void)data, (void)xdg_output, (void)width, (void)height;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
|
||||
{
|
||||
(void)data, (void)xdg_output;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name)
|
||||
{
|
||||
(void)xdg_output;
|
||||
struct output *output = data;
|
||||
output->name = bm_strdup(name);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, const char *description)
|
||||
{
|
||||
(void)data, (void)xdg_output, (void)description;
|
||||
}
|
||||
|
||||
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
||||
.logical_position = xdg_output_handle_logical_position,
|
||||
.logical_size = xdg_output_handle_logical_size,
|
||||
.done = xdg_output_handle_done,
|
||||
.name = xdg_output_handle_name,
|
||||
.description = xdg_output_handle_description,
|
||||
};
|
||||
|
||||
static void
|
||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, int physical_width, int physical_height, int subpixel, const char *make, const char *model, int transform)
|
||||
{
|
||||
(void)data, (void)wl_output, (void)x, (void)y, (void)physical_width, (void)physical_height, (void)subpixel, (void)make, (void)model, (void)transform;
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_done(void *data, struct wl_output *wl_output)
|
||||
{
|
||||
(void)data, (void)wl_output;
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale)
|
||||
{
|
||||
(void)wl_output;
|
||||
struct output *output = data;
|
||||
|
||||
assert(scale > 0);
|
||||
output->scale = scale;
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int width, int height, int refresh)
|
||||
{
|
||||
(void)wl_output, (void)refresh, (void)height, (void)width;
|
||||
struct output *output = data;
|
||||
|
||||
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
||||
output->height = height;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_output_listener output_listener = {
|
||||
.geometry = display_handle_geometry,
|
||||
.mode = display_handle_mode,
|
||||
.done = display_handle_done,
|
||||
.scale = display_handle_scale
|
||||
};
|
||||
|
||||
static void
|
||||
registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version)
|
||||
{
|
||||
(void)version;
|
||||
struct wayland *wayland = data;
|
||||
|
||||
if (strcmp(interface, "wl_compositor") == 0) {
|
||||
wayland->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 4);
|
||||
} else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
|
||||
wayland->layer_shell = wl_registry_bind(registry, id, &zwlr_layer_shell_v1_interface, 2);
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
wayland->seat = wl_registry_bind(registry, id, &wl_seat_interface, 7);
|
||||
wl_seat_add_listener(wayland->seat, &seat_listener, &wayland->input);
|
||||
} else if (strcmp(interface, "wl_shm") == 0) {
|
||||
wayland->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
||||
wl_shm_add_listener(wayland->shm, &shm_listener, data);
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
struct wl_output *wl_output = wl_registry_bind(registry, id, &wl_output_interface, 2);
|
||||
struct output *output = calloc(1, sizeof(struct output));
|
||||
output->output = wl_output;
|
||||
output->scale = 1;
|
||||
wl_list_insert(&wayland->outputs, &output->link);
|
||||
wl_output_add_listener(wl_output, &output_listener, output);
|
||||
} else if (!strcmp(interface, zxdg_output_manager_v1_interface.name)) {
|
||||
wayland->xdg_output_manager = wl_registry_bind(registry, id, &zxdg_output_manager_v1_interface, 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
|
||||
{
|
||||
(void)data, (void)registry, (void)name;
|
||||
}
|
||||
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
registry_handle_global,
|
||||
registry_handle_global_remove
|
||||
};
|
||||
|
||||
void
|
||||
bm_wl_repeat(struct wayland *wayland)
|
||||
{
|
||||
uint64_t exp;
|
||||
if (read(wayland->fds.repeat, &exp, sizeof(exp)) != sizeof(exp))
|
||||
return;
|
||||
|
||||
if (wayland->input.notify.key)
|
||||
wayland->input.notify.key(WL_KEYBOARD_KEY_STATE_PRESSED, wayland->input.repeat_sym, wayland->input.repeat_key + 8);
|
||||
|
||||
press(&wayland->input, wayland->input.repeat_sym, wayland->input.repeat_key, WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_registry_destroy(struct wayland *wayland)
|
||||
{
|
||||
assert(wayland);
|
||||
|
||||
if (wayland->shm)
|
||||
wl_shm_destroy(wayland->shm);
|
||||
|
||||
if (wayland->layer_shell)
|
||||
zwlr_layer_shell_v1_destroy(wayland->layer_shell);
|
||||
|
||||
if (wayland->compositor)
|
||||
wl_compositor_destroy(wayland->compositor);
|
||||
|
||||
if (wayland->registry)
|
||||
wl_registry_destroy(wayland->registry);
|
||||
|
||||
xkb_keymap_unref(wayland->input.xkb.keymap);
|
||||
xkb_state_unref(wayland->input.xkb.state);
|
||||
}
|
||||
|
||||
bool
|
||||
bm_wl_registry_register(struct wayland *wayland)
|
||||
{
|
||||
assert(wayland);
|
||||
|
||||
if (!(wayland->registry = wl_display_get_registry(wayland->display)))
|
||||
return false;
|
||||
|
||||
wl_registry_add_listener(wayland->registry, ®istry_listener, wayland);
|
||||
wl_display_roundtrip(wayland->display); // trip 1, registry globals
|
||||
if (!wayland->compositor || !wayland->seat || !wayland->shm || !wayland->layer_shell)
|
||||
return false;
|
||||
|
||||
struct output *output;
|
||||
wl_list_for_each(output, &wayland->outputs, link) {
|
||||
output->xdg_output = zxdg_output_manager_v1_get_xdg_output(
|
||||
wayland->xdg_output_manager, output->output);
|
||||
zxdg_output_v1_add_listener(
|
||||
output->xdg_output, &xdg_output_listener, output);
|
||||
}
|
||||
|
||||
wl_display_roundtrip(wayland->display); // trip 2, global listeners
|
||||
if (!wayland->input.keyboard || !(wayland->formats & (1 << WL_SHM_FORMAT_ARGB8888)))
|
||||
return false;
|
||||
|
||||
set_repeat_info(&wayland->input, 40, 400);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
609
.config/dwl/menu/lib/renderers/wayland/wayland.c
Normal file
609
.config/dwl/menu/lib/renderers/wayland/wayland.c
Normal file
|
@ -0,0 +1,609 @@
|
|||
#include "internal.h"
|
||||
#include "wayland.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
static int efd;
|
||||
|
||||
static void
|
||||
render_windows_if_pending(const struct bm_menu *menu, struct wayland *wayland) {
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
if (window->render_pending)
|
||||
bm_wl_window_render(window, wayland->display, menu);
|
||||
}
|
||||
wl_display_flush(wayland->display);
|
||||
}
|
||||
|
||||
static bool
|
||||
wait_for_events(struct wayland *wayland) {
|
||||
wl_display_dispatch_pending(wayland->display);
|
||||
|
||||
if (wl_display_flush(wayland->display) < 0 && errno != EAGAIN)
|
||||
return false;
|
||||
|
||||
struct epoll_event ep[16];
|
||||
uint32_t num = epoll_wait(efd, ep, 16, -1);
|
||||
for (uint32_t i = 0; i < num; ++i) {
|
||||
if (ep[i].data.ptr == &wayland->fds.display) {
|
||||
if (ep[i].events & EPOLLERR || ep[i].events & EPOLLHUP ||
|
||||
((ep[i].events & EPOLLIN) && wl_display_dispatch(wayland->display) < 0))
|
||||
return false;
|
||||
} else if (ep[i].data.ptr == &wayland->fds.repeat) {
|
||||
bm_wl_repeat(wayland);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
schedule_windows_render_if_dirty(struct bm_menu *menu, struct wayland *wayland) {
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
if (window->render_pending) {
|
||||
// This does not happen during normal execution, but only when the windows need to
|
||||
// be(re)created. We need to do the render ASAP (not schedule it) because otherwise,
|
||||
// since we lack a window, we may not receive further events and will get deadlocked
|
||||
render_windows_if_pending(menu, wayland);
|
||||
} else if (menu->dirty) {
|
||||
bm_wl_window_schedule_render(window);
|
||||
}
|
||||
}
|
||||
|
||||
menu->dirty = false;
|
||||
}
|
||||
|
||||
static bool
|
||||
render(struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
|
||||
schedule_windows_render_if_dirty(menu, wayland);
|
||||
if (!wait_for_events(wayland))
|
||||
return false;
|
||||
render_windows_if_pending(menu, wayland);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static enum bm_key
|
||||
poll_key(const struct bm_menu *menu, unsigned int *unicode)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland && unicode);
|
||||
*unicode = 0;
|
||||
|
||||
if (wayland->input.sym == XKB_KEY_NoSymbol)
|
||||
return BM_KEY_NONE;
|
||||
|
||||
xkb_keysym_t sym = wayland->input.sym;
|
||||
uint32_t mods = wayland->input.modifiers;
|
||||
*unicode = xkb_state_key_get_utf32(wayland->input.xkb.state, wayland->input.code);
|
||||
|
||||
if (!*unicode && wayland->input.code == 23 && (mods & MOD_SHIFT))
|
||||
return BM_KEY_SHIFT_TAB;
|
||||
|
||||
wayland->input.sym = XKB_KEY_NoSymbol;
|
||||
wayland->input.code = 0;
|
||||
|
||||
if (!wayland->input.key_pending)
|
||||
return BM_KEY_UNICODE;
|
||||
wayland->input.key_pending = false;
|
||||
|
||||
switch (sym) {
|
||||
case XKB_KEY_Up:
|
||||
return BM_KEY_UP;
|
||||
|
||||
case XKB_KEY_Down:
|
||||
return BM_KEY_DOWN;
|
||||
|
||||
case XKB_KEY_Left:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_UP : BM_KEY_LEFT);
|
||||
|
||||
case XKB_KEY_Right:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_DOWN : BM_KEY_RIGHT);
|
||||
|
||||
case XKB_KEY_Home:
|
||||
return BM_KEY_HOME;
|
||||
|
||||
case XKB_KEY_End:
|
||||
return BM_KEY_END;
|
||||
|
||||
case XKB_KEY_SunPageUp:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_SHIFT_PAGE_UP : BM_KEY_PAGE_UP);
|
||||
|
||||
case XKB_KEY_less:
|
||||
return (mods & MOD_ALT ? BM_KEY_SHIFT_PAGE_UP : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_SunPageDown:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_SHIFT_PAGE_DOWN : BM_KEY_PAGE_DOWN);
|
||||
|
||||
case XKB_KEY_greater:
|
||||
return (mods & MOD_ALT ? BM_KEY_SHIFT_PAGE_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_v:
|
||||
return (mods & MOD_CTRL ? BM_KEY_PAGE_DOWN : (mods & MOD_ALT ? BM_KEY_PAGE_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XKB_KEY_BackSpace:
|
||||
return BM_KEY_BACKSPACE;
|
||||
|
||||
case XKB_KEY_Delete:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_LINE_DELETE_LEFT : BM_KEY_DELETE);
|
||||
|
||||
case XKB_KEY_Tab:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_SHIFT_TAB : BM_KEY_TAB);
|
||||
|
||||
case XKB_KEY_Insert:
|
||||
return BM_KEY_SHIFT_RETURN;
|
||||
|
||||
case XKB_KEY_KP_Enter:
|
||||
case XKB_KEY_Return:
|
||||
return (mods & MOD_CTRL ? BM_KEY_CONTROL_RETURN : (mods & MOD_SHIFT ? BM_KEY_SHIFT_RETURN : BM_KEY_RETURN));
|
||||
|
||||
case XKB_KEY_g:
|
||||
if (!(mods & MOD_CTRL)) return BM_KEY_UNICODE;
|
||||
// fall through
|
||||
case XKB_KEY_c:
|
||||
if (!(mods & MOD_CTRL)) return BM_KEY_UNICODE;
|
||||
// fall through
|
||||
case XKB_KEY_bracketleft:
|
||||
if (!(mods & MOD_CTRL)) return BM_KEY_UNICODE;
|
||||
// fall through
|
||||
case XKB_KEY_Escape:
|
||||
return BM_KEY_ESCAPE;
|
||||
|
||||
case XKB_KEY_p:
|
||||
return (mods & MOD_CTRL ? BM_KEY_UP : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_n:
|
||||
return (mods & MOD_CTRL ? BM_KEY_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_l:
|
||||
return (mods & MOD_CTRL ? BM_KEY_LEFT : (mods & MOD_ALT ? BM_KEY_DOWN : BM_KEY_UNICODE));
|
||||
|
||||
case XKB_KEY_f:
|
||||
return (mods & MOD_CTRL ? BM_KEY_RIGHT : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_a:
|
||||
return (mods & MOD_CTRL ? BM_KEY_HOME : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_e:
|
||||
return (mods & MOD_CTRL ? BM_KEY_END : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_h:
|
||||
return (mods & MOD_CTRL ? BM_KEY_BACKSPACE : (mods & MOD_ALT ? BM_KEY_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XKB_KEY_u:
|
||||
return (mods & MOD_CTRL ? BM_KEY_LINE_DELETE_LEFT : (mods & MOD_ALT ? BM_KEY_PAGE_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XKB_KEY_k:
|
||||
return (mods & MOD_CTRL ? BM_KEY_LINE_DELETE_RIGHT : (mods & MOD_ALT ? BM_KEY_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XKB_KEY_w:
|
||||
return (mods & MOD_CTRL ? BM_KEY_WORD_DELETE : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_j:
|
||||
return (mods & MOD_ALT ? BM_KEY_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_d:
|
||||
return (mods & MOD_ALT ? BM_KEY_PAGE_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_m:
|
||||
return (mods & MOD_CTRL ? BM_KEY_RETURN : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_y:
|
||||
return (mods & MOD_CTRL ? BM_KEY_PASTE : BM_KEY_UNICODE);
|
||||
|
||||
case XKB_KEY_1:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_1;
|
||||
break;
|
||||
case XKB_KEY_2:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_2;
|
||||
break;
|
||||
case XKB_KEY_3:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_3;
|
||||
break;
|
||||
case XKB_KEY_4:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_4;
|
||||
break;
|
||||
case XKB_KEY_5:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_5;
|
||||
break;
|
||||
case XKB_KEY_6:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_6;
|
||||
break;
|
||||
case XKB_KEY_7:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_7;
|
||||
break;
|
||||
case XKB_KEY_8:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_8;
|
||||
break;
|
||||
case XKB_KEY_9:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_9;
|
||||
break;
|
||||
case XKB_KEY_0:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_10;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return BM_KEY_UNICODE;
|
||||
}
|
||||
|
||||
struct bm_pointer
|
||||
poll_pointer(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
struct input *input = &wayland->input;
|
||||
struct pointer_event *event = &input->pointer_event;
|
||||
assert(wayland && event);
|
||||
|
||||
struct bm_pointer bm_pointer = {0};
|
||||
|
||||
bm_pointer.event_mask = event->event_mask;
|
||||
bm_pointer.pos_x = wl_fixed_to_int(event->surface_x);
|
||||
bm_pointer.pos_y = wl_fixed_to_int(event->surface_y);
|
||||
bm_pointer.time = event->time;
|
||||
bm_pointer.axes[0].valid = event->axes[0].valid;
|
||||
bm_pointer.axes[0].value = event->axes[0].value;
|
||||
bm_pointer.axes[0].discrete = event->axes[0].discrete;
|
||||
bm_pointer.axes[1].valid = event->axes[1].valid;
|
||||
bm_pointer.axes[1].value = event->axes[1].value;
|
||||
bm_pointer.axes[1].discrete = event->axes[1].discrete;
|
||||
bm_pointer.axis_source = event->axis_source;
|
||||
|
||||
bm_pointer.button = BM_POINTER_KEY_NONE;
|
||||
switch (event->button) {
|
||||
case BTN_LEFT:
|
||||
bm_pointer.button = BM_POINTER_KEY_PRIMARY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (event->state & WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
bm_pointer.state = POINTER_STATE_PRESSED;
|
||||
}
|
||||
if (event->state & WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
bm_pointer.state = POINTER_STATE_RELEASED;
|
||||
}
|
||||
|
||||
memset(event, 0, sizeof(*event));
|
||||
return bm_pointer;
|
||||
}
|
||||
|
||||
struct bm_touch
|
||||
poll_touch(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
struct input *input = &wayland->input;
|
||||
struct touch_event *event = &input->touch_event;
|
||||
assert(wayland && event);
|
||||
|
||||
struct bm_touch bm_touch;
|
||||
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
struct touch_point *point = &event->points[i];
|
||||
|
||||
if (!point->valid) {
|
||||
bm_touch.points[i].event_mask = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
bm_touch.points[i].event_mask = point->event_mask;
|
||||
bm_touch.points[i].pos_x = wl_fixed_to_int(point->surface_x);
|
||||
bm_touch.points[i].pos_y = wl_fixed_to_int(point->surface_y);
|
||||
bm_touch.points[i].start_x = wl_fixed_to_int(point->surface_start_x);
|
||||
bm_touch.points[i].start_y = wl_fixed_to_int(point->surface_start_y);
|
||||
bm_touch.points[i].major = point->major;
|
||||
bm_touch.points[i].minor = point->minor;
|
||||
bm_touch.points[i].orientation = point->orientation;
|
||||
|
||||
if (point->event_mask & TOUCH_EVENT_UP) {
|
||||
point->valid = false;
|
||||
point->event_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return bm_touch;
|
||||
}
|
||||
|
||||
void
|
||||
release_touch(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
struct input *input = &wayland->input;
|
||||
struct touch_event *event = &input->touch_event;
|
||||
assert(wayland && event);
|
||||
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
struct touch_point *point = &event->points[i];
|
||||
point->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_displayed_count(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
uint32_t max = 0;
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
if (window->displayed > max)
|
||||
max = window->displayed;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_height(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
uint32_t max = 0;
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
if (window->displayed > max)
|
||||
max = window->height;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_width(const struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
uint32_t max = 0;
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
if (window->displayed > max)
|
||||
max = window->width;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
static void
|
||||
set_width(const struct bm_menu *menu, uint32_t margin, float factor)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
bm_wl_window_set_width(window, wayland->display, margin, factor);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_align(const struct bm_menu *menu, enum bm_align align)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
bm_wl_window_set_align(window, wayland->display, align);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
grab_keyboard(const struct bm_menu *menu, bool grab)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
bm_wl_window_grab_keyboard(window, wayland->display, grab);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_overlap(const struct bm_menu *menu, bool overlap)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
bm_wl_window_set_overlap(window, wayland->display, overlap);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_windows(struct wayland *wayland)
|
||||
{
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
bm_wl_window_destroy(window);
|
||||
}
|
||||
wl_list_init(&wayland->windows);
|
||||
}
|
||||
|
||||
static void
|
||||
recreate_windows(const struct bm_menu *menu, struct wayland *wayland)
|
||||
{
|
||||
destroy_windows(wayland);
|
||||
|
||||
int32_t monitors = 0;
|
||||
struct output *output;
|
||||
wl_list_for_each(output, &wayland->outputs, link)
|
||||
monitors++;
|
||||
|
||||
int32_t monitor = 0;
|
||||
wl_list_for_each(output, &wayland->outputs, link) {
|
||||
|
||||
if (!menu->monitor_name) {
|
||||
if (menu->monitor > -1) {
|
||||
if (menu->monitor < monitors && monitor != menu->monitor) {
|
||||
++monitor;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(menu->monitor_name, output->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
struct wl_surface *surface;
|
||||
if (!(surface = wl_compositor_create_surface(wayland->compositor)))
|
||||
goto fail;
|
||||
|
||||
wl_surface_set_buffer_scale(surface, output->scale);
|
||||
|
||||
struct window *window = calloc(1, sizeof(struct window));
|
||||
window->align = menu->align;
|
||||
window->hmargin_size = menu->hmargin_size;
|
||||
window->width_factor = menu->width_factor;
|
||||
|
||||
const char *scale = getenv("BEMENU_SCALE");
|
||||
if (scale) {
|
||||
window->scale = fmax(strtof(scale, NULL), 1.0f);
|
||||
} else {
|
||||
window->scale = output->scale;
|
||||
}
|
||||
|
||||
if (!bm_wl_window_create(window, wayland->display, wayland->shm, (menu->monitor == -1) ? NULL : output->output, wayland->layer_shell, surface))
|
||||
free(window);
|
||||
|
||||
window->notify.render = bm_cairo_paint;
|
||||
window->max_height = output->height;
|
||||
window->render_pending = true;
|
||||
wl_list_insert(&wayland->windows, &window->link);
|
||||
if (menu->monitor != -2) break;
|
||||
}
|
||||
|
||||
set_overlap(menu, menu->overlap);
|
||||
grab_keyboard(menu, menu->grabbed);
|
||||
return;
|
||||
|
||||
fail:
|
||||
// This is non handlable if fails on recreation
|
||||
fprintf(stderr, "wayland window creation failed :/\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
static void
|
||||
set_monitor(const struct bm_menu *menu, int32_t monitor)
|
||||
{
|
||||
(void)monitor;
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
recreate_windows(menu, wayland);
|
||||
}
|
||||
|
||||
static void
|
||||
set_monitor_name(const struct bm_menu *menu, char *monitor_name)
|
||||
{
|
||||
(void)monitor_name;
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
assert(wayland);
|
||||
recreate_windows(menu, wayland);
|
||||
}
|
||||
|
||||
static void
|
||||
destructor(struct bm_menu *menu)
|
||||
{
|
||||
struct wayland *wayland = menu->renderer->internal;
|
||||
|
||||
if (!wayland)
|
||||
return;
|
||||
|
||||
destroy_windows(wayland);
|
||||
bm_wl_registry_destroy(wayland);
|
||||
|
||||
xkb_context_unref(wayland->input.xkb.context);
|
||||
|
||||
if (wayland->display) {
|
||||
epoll_ctl(efd, EPOLL_CTL_DEL, wayland->fds.repeat, NULL);
|
||||
epoll_ctl(efd, EPOLL_CTL_DEL, wayland->fds.display, NULL);
|
||||
close(wayland->fds.repeat);
|
||||
wl_display_flush(wayland->display);
|
||||
wl_display_disconnect(wayland->display);
|
||||
}
|
||||
|
||||
free(wayland);
|
||||
menu->renderer->internal = NULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
constructor(struct bm_menu *menu)
|
||||
{
|
||||
if (!getenv("WAYLAND_DISPLAY") && !getenv("WAYLAND_SOCKET"))
|
||||
return false;
|
||||
|
||||
struct wayland *wayland;
|
||||
if (!(menu->renderer->internal = wayland = calloc(1, sizeof(struct wayland))))
|
||||
goto fail;
|
||||
|
||||
wl_list_init(&wayland->windows);
|
||||
wl_list_init(&wayland->outputs);
|
||||
|
||||
if (!(wayland->display = wl_display_connect(NULL)))
|
||||
goto fail;
|
||||
|
||||
if (!(wayland->input.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS)))
|
||||
goto fail;
|
||||
|
||||
if (!bm_wl_registry_register(wayland))
|
||||
goto fail;
|
||||
|
||||
wayland->fds.display = wl_display_get_fd(wayland->display);
|
||||
wayland->fds.repeat = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||
wayland->input.repeat_fd = &wayland->fds.repeat;
|
||||
wayland->input.key_pending = false;
|
||||
recreate_windows(menu, wayland);
|
||||
|
||||
if (!efd && (efd = epoll_create1(EPOLL_CLOEXEC)) < 0)
|
||||
goto fail;
|
||||
|
||||
struct epoll_event ep;
|
||||
ep.events = EPOLLIN | EPOLLERR | EPOLLHUP;
|
||||
ep.data.ptr = &wayland->fds.display;
|
||||
epoll_ctl(efd, EPOLL_CTL_ADD, wayland->fds.display, &ep);
|
||||
|
||||
struct epoll_event ep2;
|
||||
ep2.events = EPOLLIN;
|
||||
ep2.data.ptr = &wayland->fds.repeat;
|
||||
epoll_ctl(efd, EPOLL_CTL_ADD, wayland->fds.repeat, &ep2);
|
||||
return true;
|
||||
|
||||
fail:
|
||||
destructor(menu);
|
||||
return false;
|
||||
}
|
||||
|
||||
BM_PUBLIC extern const char*
|
||||
register_renderer(struct render_api *api)
|
||||
{
|
||||
api->constructor = constructor;
|
||||
api->destructor = destructor;
|
||||
api->get_displayed_count = get_displayed_count;
|
||||
api->get_height = get_height;
|
||||
api->get_width = get_width;
|
||||
api->poll_key = poll_key;
|
||||
api->poll_pointer = poll_pointer;
|
||||
api->poll_touch = poll_touch;
|
||||
api->release_touch = release_touch;
|
||||
api->render = render;
|
||||
api->set_align = set_align;
|
||||
api->set_width = set_width;
|
||||
api->grab_keyboard = grab_keyboard;
|
||||
api->set_overlap = set_overlap;
|
||||
api->set_monitor = set_monitor;
|
||||
api->set_monitor_name = set_monitor_name;
|
||||
api->priorty = BM_PRIO_GUI;
|
||||
api->version = BM_PLUGIN_VERSION;
|
||||
return "wayland";
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
180
.config/dwl/menu/lib/renderers/wayland/wayland.h
Normal file
180
.config/dwl/menu/lib/renderers/wayland/wayland.h
Normal file
|
@ -0,0 +1,180 @@
|
|||
#ifndef _BM_WAYLAND_H_
|
||||
#define _BM_WAYLAND_H_
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
|
||||
#include "wlr-layer-shell-unstable-v1.h"
|
||||
#include "xdg-output-unstable-v1.h"
|
||||
#include "renderers/cairo_renderer.h"
|
||||
|
||||
struct bm_menu;
|
||||
|
||||
enum mod_bit {
|
||||
MOD_SHIFT = 1<<0,
|
||||
MOD_CAPS = 1<<1,
|
||||
MOD_CTRL = 1<<2,
|
||||
MOD_ALT = 1<<3,
|
||||
MOD_MOD2 = 1<<4,
|
||||
MOD_MOD3 = 1<<5,
|
||||
MOD_LOGO = 1<<6,
|
||||
MOD_MOD5 = 1<<7,
|
||||
};
|
||||
|
||||
enum mask {
|
||||
MASK_SHIFT,
|
||||
MASK_CAPS,
|
||||
MASK_CTRL,
|
||||
MASK_ALT,
|
||||
MASK_MOD2,
|
||||
MASK_MOD3,
|
||||
MASK_LOGO,
|
||||
MASK_MOD5,
|
||||
MASK_LAST
|
||||
};
|
||||
|
||||
extern const char *BM_XKB_MASK_NAMES[MASK_LAST];
|
||||
extern const enum mod_bit BM_XKB_MODS[MASK_LAST];
|
||||
|
||||
struct xkb {
|
||||
struct xkb_state *state;
|
||||
struct xkb_context *context;
|
||||
struct xkb_keymap *keymap;
|
||||
xkb_mod_mask_t masks[MASK_LAST];
|
||||
};
|
||||
|
||||
struct pointer_event {
|
||||
uint32_t event_mask;
|
||||
wl_fixed_t surface_x, surface_y;
|
||||
uint32_t button, state;
|
||||
uint32_t time;
|
||||
uint32_t serial;
|
||||
struct {
|
||||
bool valid;
|
||||
wl_fixed_t value;
|
||||
int32_t discrete;
|
||||
} axes[2];
|
||||
uint32_t axis_source;
|
||||
};
|
||||
|
||||
struct touch_point {
|
||||
bool valid;
|
||||
int32_t id;
|
||||
uint32_t event_mask;
|
||||
wl_fixed_t surface_x, surface_y;
|
||||
wl_fixed_t surface_start_x, surface_start_y;
|
||||
wl_fixed_t major, minor;
|
||||
wl_fixed_t orientation;
|
||||
};
|
||||
|
||||
struct touch_event {
|
||||
uint32_t time;
|
||||
uint32_t serial;
|
||||
uint16_t active;
|
||||
struct touch_point points[2];
|
||||
};
|
||||
|
||||
struct input {
|
||||
int *repeat_fd;
|
||||
|
||||
struct wl_seat *seat;
|
||||
struct wl_keyboard *keyboard;
|
||||
struct wl_pointer *pointer;
|
||||
struct wl_touch *touch;
|
||||
struct pointer_event pointer_event;
|
||||
struct touch_event touch_event;
|
||||
struct xkb xkb;
|
||||
|
||||
xkb_keysym_t sym;
|
||||
uint32_t code;
|
||||
uint32_t modifiers;
|
||||
|
||||
xkb_keysym_t repeat_sym;
|
||||
uint32_t repeat_key;
|
||||
|
||||
int32_t repeat_rate_sec;
|
||||
int32_t repeat_rate_nsec;
|
||||
int32_t repeat_delay_sec;
|
||||
int32_t repeat_delay_nsec;
|
||||
|
||||
struct {
|
||||
void (*key)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code);
|
||||
} notify;
|
||||
|
||||
bool key_pending;
|
||||
};
|
||||
|
||||
struct buffer {
|
||||
struct cairo cairo;
|
||||
struct wl_buffer *buffer;
|
||||
uint32_t width, height;
|
||||
bool busy;
|
||||
};
|
||||
|
||||
struct window {
|
||||
struct wl_surface *surface;
|
||||
struct wl_callback *frame_cb;
|
||||
struct zwlr_layer_surface_v1 *layer_surface;
|
||||
struct wl_shm *shm;
|
||||
struct buffer buffers[2];
|
||||
uint32_t width, height, max_height;
|
||||
uint32_t hmargin_size;
|
||||
float width_factor;
|
||||
int32_t scale;
|
||||
uint32_t displayed;
|
||||
struct wl_list link;
|
||||
enum bm_align align;
|
||||
uint32_t align_anchor;
|
||||
bool render_pending;
|
||||
|
||||
struct {
|
||||
void (*render)(struct cairo *cairo, uint32_t width, uint32_t max_height, const struct bm_menu *menu, struct cairo_paint_result *result);
|
||||
} notify;
|
||||
};
|
||||
|
||||
struct output {
|
||||
struct wl_output *output;
|
||||
struct zxdg_output_v1 *xdg_output;
|
||||
struct wl_list link;
|
||||
int height;
|
||||
int scale;
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct wayland {
|
||||
struct {
|
||||
int32_t display;
|
||||
int32_t repeat;
|
||||
} fds;
|
||||
|
||||
struct wl_display *display;
|
||||
struct wl_registry *registry;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_list outputs;
|
||||
struct wl_seat *seat;
|
||||
struct zwlr_layer_shell_v1 *layer_shell;
|
||||
struct wl_shm *shm;
|
||||
struct input input;
|
||||
struct wl_list windows;
|
||||
struct zxdg_output_manager_v1 *xdg_output_manager;
|
||||
uint32_t formats;
|
||||
};
|
||||
|
||||
void bm_wl_repeat(struct wayland *wayland);
|
||||
bool bm_wl_registry_register(struct wayland *wayland);
|
||||
void bm_wl_registry_destroy(struct wayland *wayland);
|
||||
void bm_wl_window_schedule_render(struct window *window);
|
||||
void bm_wl_window_render(struct window *window, struct wl_display *display, const struct bm_menu *menu);
|
||||
void bm_wl_window_set_width(struct window *window, struct wl_display *display, uint32_t margin, float factor);
|
||||
void bm_wl_window_set_align(struct window *window, struct wl_display *display, enum bm_align align);
|
||||
void bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bool grab);
|
||||
void bm_wl_window_set_overlap(struct window *window, struct wl_display *display, bool overlap);
|
||||
bool bm_wl_window_create(struct window *window, struct wl_display *display, struct wl_shm *shm, struct wl_output *output, struct zwlr_layer_shell_v1 *layer_shell, struct wl_surface *surface);
|
||||
void bm_wl_window_destroy(struct window *window);
|
||||
|
||||
#endif /* _BM_WAYLAND_H_ */
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
395
.config/dwl/menu/lib/renderers/wayland/window.c
Normal file
395
.config/dwl/menu/lib/renderers/wayland/window.c
Normal file
|
@ -0,0 +1,395 @@
|
|||
#include "internal.h"
|
||||
#include "wayland.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
static int
|
||||
set_cloexec_or_close(int fd)
|
||||
{
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
long flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1)
|
||||
goto err;
|
||||
|
||||
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
|
||||
goto err;
|
||||
|
||||
return fd;
|
||||
|
||||
err:
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
create_tmpfile_cloexec(char *tmpname)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#ifdef HAVE_MKOSTEMP
|
||||
if ((fd = mkostemp(tmpname, O_CLOEXEC)) >= 0)
|
||||
unlink(tmpname);
|
||||
#else
|
||||
if ((fd = mkstemp(tmpname)) >= 0) {
|
||||
fd = set_cloexec_or_close(fd);
|
||||
unlink(tmpname);
|
||||
}
|
||||
#endif
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int
|
||||
os_create_anonymous_file(off_t size)
|
||||
{
|
||||
static const char template[] = "bemenu-shared-XXXXXX";
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
const char *path;
|
||||
if (!(path = getenv("XDG_RUNTIME_DIR")) || strlen(path) <= 0) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *name;
|
||||
int ts = (path[strlen(path) - 1] == '/');
|
||||
if (!(name = bm_dprintf("%s%s%s", path, (ts ? "" : "/"), template)))
|
||||
return -1;
|
||||
|
||||
fd = create_tmpfile_cloexec(name);
|
||||
free(name);
|
||||
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef HAVE_POSIX_FALLOCATE
|
||||
if ((ret = posix_fallocate(fd, 0, size)) != 0) {
|
||||
close(fd);
|
||||
errno = ret;
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if ((ret = ftruncate(fd, size)) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_release(void *data, struct wl_buffer *wl_buffer)
|
||||
{
|
||||
(void)wl_buffer;
|
||||
struct buffer *buffer = data;
|
||||
buffer->busy = false;
|
||||
}
|
||||
|
||||
static const struct wl_buffer_listener buffer_listener = {
|
||||
.release = buffer_release
|
||||
};
|
||||
|
||||
static void
|
||||
destroy_buffer(struct buffer *buffer)
|
||||
{
|
||||
if (buffer->buffer)
|
||||
wl_buffer_destroy(buffer->buffer);
|
||||
bm_cairo_destroy(&buffer->cairo);
|
||||
memset(buffer, 0, sizeof(struct buffer));
|
||||
}
|
||||
|
||||
static bool
|
||||
create_buffer(struct wl_shm *shm, struct buffer *buffer, int32_t width, int32_t height, uint32_t format, int32_t scale)
|
||||
{
|
||||
int fd = -1;
|
||||
struct wl_shm_pool *pool = NULL;
|
||||
uint32_t stride = width * 4;
|
||||
uint32_t size = stride * height;
|
||||
|
||||
if ((fd = os_create_anonymous_file(size)) < 0) {
|
||||
fprintf(stderr, "wayland: creating a buffer file for %d B failed\n", size);
|
||||
return false;
|
||||
}
|
||||
|
||||
void *data;
|
||||
if ((data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
|
||||
fprintf(stderr, "wayland: mmap failed\n");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(pool = wl_shm_create_pool(shm, fd, size))) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(buffer->buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, format)))
|
||||
goto fail;
|
||||
|
||||
wl_shm_pool_destroy(pool);
|
||||
pool = NULL;
|
||||
|
||||
close(fd);
|
||||
fd = -1;
|
||||
|
||||
wl_buffer_add_listener(buffer->buffer, &buffer_listener, buffer);
|
||||
|
||||
cairo_surface_t *surf;
|
||||
if (!(surf = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride)))
|
||||
goto fail;
|
||||
|
||||
buffer->cairo.scale = scale;
|
||||
|
||||
if (!bm_cairo_create_for_surface(&buffer->cairo, surf)) {
|
||||
cairo_surface_destroy(surf);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
buffer->width = width;
|
||||
buffer->height = height;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
if (fd > -1)
|
||||
close(fd);
|
||||
if (pool)
|
||||
wl_shm_pool_destroy(pool);
|
||||
destroy_buffer(buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct buffer*
|
||||
next_buffer(struct window *window)
|
||||
{
|
||||
assert(window);
|
||||
|
||||
struct buffer *buffer = NULL;
|
||||
for (int32_t i = 0; i < 2; ++i) {
|
||||
if (window->buffers[i].busy)
|
||||
continue;
|
||||
|
||||
buffer = &window->buffers[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
if (window->width * window->scale != buffer->width || window->height * window->scale != buffer->height)
|
||||
destroy_buffer(buffer);
|
||||
|
||||
if (!buffer->buffer && !create_buffer(window->shm, buffer, window->width * window->scale, window->height * window->scale, WL_SHM_FORMAT_ARGB8888, window->scale))
|
||||
return NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
|
||||
{
|
||||
(void)time;
|
||||
struct window *window = data;
|
||||
wl_callback_destroy(callback);
|
||||
window->frame_cb = NULL;
|
||||
window->render_pending = true;
|
||||
}
|
||||
|
||||
static const struct wl_callback_listener listener = {
|
||||
frame_callback
|
||||
};
|
||||
|
||||
static uint32_t
|
||||
get_align_anchor(enum bm_align align)
|
||||
{
|
||||
uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
|
||||
if(align == BM_ALIGN_TOP) {
|
||||
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
|
||||
} else if(align == BM_ALIGN_CENTER) {
|
||||
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
|
||||
} else {
|
||||
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
|
||||
}
|
||||
|
||||
return anchor;
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_window_schedule_render(struct window *window)
|
||||
{
|
||||
assert(window);
|
||||
if (window->frame_cb)
|
||||
return;
|
||||
|
||||
window->frame_cb = wl_surface_frame(window->surface);
|
||||
wl_callback_add_listener(window->frame_cb, &listener, window);
|
||||
wl_surface_commit(window->surface);
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_window_render(struct window *window, struct wl_display *display, const struct bm_menu *menu)
|
||||
{
|
||||
assert(window && menu);
|
||||
struct buffer *buffer;
|
||||
for (int tries = 0; tries < 2; ++tries) {
|
||||
if (!(buffer = next_buffer(window))) {
|
||||
fprintf(stderr, "could not get next buffer");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!window->notify.render)
|
||||
break;
|
||||
|
||||
struct cairo_paint_result result;
|
||||
window->notify.render(&buffer->cairo, buffer->width, window->max_height, menu, &result);
|
||||
window->displayed = result.displayed;
|
||||
|
||||
if (window->height == result.height / window->scale)
|
||||
break;
|
||||
|
||||
window->height = result.height / window->scale;
|
||||
zwlr_layer_surface_v1_set_size(window->layer_surface, window->width, window->height);
|
||||
wl_surface_commit(window->surface);
|
||||
wl_display_roundtrip(display);
|
||||
destroy_buffer(buffer);
|
||||
}
|
||||
|
||||
wl_surface_damage_buffer(window->surface, 0, 0, buffer->width, buffer->height);
|
||||
wl_surface_attach(window->surface, buffer->buffer, 0, 0);
|
||||
wl_surface_commit(window->surface);
|
||||
buffer->busy = true;
|
||||
window->render_pending = false;
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_window_destroy(struct window *window)
|
||||
{
|
||||
assert(window);
|
||||
|
||||
for (int32_t i = 0; i < 2; ++i)
|
||||
destroy_buffer(&window->buffers[i]);
|
||||
|
||||
if (window->layer_surface)
|
||||
zwlr_layer_surface_v1_destroy(window->layer_surface);
|
||||
|
||||
if (window->surface)
|
||||
wl_surface_destroy(window->surface);
|
||||
}
|
||||
|
||||
static void
|
||||
layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *layer_surface, uint32_t serial, uint32_t width, uint32_t height)
|
||||
{
|
||||
struct window *window = data;
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
zwlr_layer_surface_v1_ack_configure(layer_surface, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *layer_surface)
|
||||
{
|
||||
struct window *window = data;
|
||||
zwlr_layer_surface_v1_destroy(layer_surface);
|
||||
wl_surface_destroy(window->surface);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_window_width(struct window *window)
|
||||
{
|
||||
uint32_t width = window->width * ((window->width_factor != 0) ? window->width_factor : 1);
|
||||
|
||||
if(width > window->width - 2 * window->hmargin_size)
|
||||
width = window->width - 2 * window->hmargin_size;
|
||||
|
||||
if(width < WINDOW_MIN_WIDTH || 2 * window->hmargin_size > window->width)
|
||||
width = WINDOW_MIN_WIDTH;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
|
||||
.configure = layer_surface_configure,
|
||||
.closed = layer_surface_closed,
|
||||
};
|
||||
|
||||
void
|
||||
bm_wl_window_set_width(struct window *window, struct wl_display *display, uint32_t margin, float factor)
|
||||
{
|
||||
if(window->hmargin_size == margin && window->width_factor == factor)
|
||||
return;
|
||||
|
||||
window->hmargin_size = margin;
|
||||
window->width_factor = factor;
|
||||
|
||||
zwlr_layer_surface_v1_set_anchor(window->layer_surface, window->align_anchor);
|
||||
zwlr_layer_surface_v1_set_size(window->layer_surface, get_window_width(window), window->height);
|
||||
|
||||
wl_surface_commit(window->surface);
|
||||
wl_display_roundtrip(display);
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_window_set_align(struct window *window, struct wl_display *display, enum bm_align align)
|
||||
{
|
||||
if(window->align == align)
|
||||
return;
|
||||
|
||||
window->align = align;
|
||||
|
||||
window->align_anchor = get_align_anchor(window->align);
|
||||
|
||||
zwlr_layer_surface_v1_set_anchor(window->layer_surface, window->align_anchor);
|
||||
wl_surface_commit(window->surface);
|
||||
wl_display_roundtrip(display);
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bool grab)
|
||||
{
|
||||
zwlr_layer_surface_v1_set_keyboard_interactivity(window->layer_surface, grab);
|
||||
wl_surface_commit(window->surface);
|
||||
wl_display_roundtrip(display);
|
||||
}
|
||||
|
||||
void
|
||||
bm_wl_window_set_overlap(struct window *window, struct wl_display *display, bool overlap)
|
||||
{
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(window->layer_surface, overlap ? -1 : 0);
|
||||
wl_surface_commit(window->surface);
|
||||
wl_display_roundtrip(display);
|
||||
}
|
||||
|
||||
bool
|
||||
bm_wl_window_create(struct window *window, struct wl_display *display, struct wl_shm *shm, struct wl_output *output, struct zwlr_layer_shell_v1 *layer_shell, struct wl_surface *surface)
|
||||
{
|
||||
assert(window);
|
||||
|
||||
if (layer_shell && (window->layer_surface = zwlr_layer_shell_v1_get_layer_surface(layer_shell, surface, output, ZWLR_LAYER_SHELL_V1_LAYER_TOP, "menu"))) {
|
||||
zwlr_layer_surface_v1_add_listener(window->layer_surface, &layer_surface_listener, window);
|
||||
window->align_anchor = get_align_anchor(window->align);
|
||||
zwlr_layer_surface_v1_set_anchor(window->layer_surface, window->align_anchor);
|
||||
zwlr_layer_surface_v1_set_size(window->layer_surface, 0, 32);
|
||||
|
||||
wl_surface_commit(surface);
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
zwlr_layer_surface_v1_set_size(window->layer_surface, get_window_width(window), 32);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
window->shm = shm;
|
||||
window->surface = surface;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
|
@ -0,0 +1,390 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="wlr_layer_shell_unstable_v1">
|
||||
<copyright>
|
||||
Copyright © 2017 Drew DeVault
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of
|
||||
the copyright holders not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission. The copyright holders make no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied
|
||||
warranty.
|
||||
|
||||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="zwlr_layer_shell_v1" version="4">
|
||||
<description summary="create surfaces that are layers of the desktop">
|
||||
Clients can use this interface to assign the surface_layer role to
|
||||
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||
rendered with a defined z-depth respective to each other. They may also be
|
||||
anchored to the edges and corners of a screen and specify input handling
|
||||
semantics. This interface should be suitable for the implementation of
|
||||
many desktop shell components, and a broad number of other applications
|
||||
that interact with the desktop.
|
||||
</description>
|
||||
|
||||
<request name="get_layer_surface">
|
||||
<description summary="create a layer_surface from a surface">
|
||||
Create a layer surface for an existing surface. This assigns the role of
|
||||
layer_surface, or raises a protocol error if another role is already
|
||||
assigned.
|
||||
|
||||
Creating a layer surface from a wl_surface which has a buffer attached
|
||||
or committed is a client error, and any attempts by a client to attach
|
||||
or manipulate a buffer prior to the first layer_surface.configure call
|
||||
must also be treated as errors.
|
||||
|
||||
After creating a layer_surface object and setting it up, the client
|
||||
must perform an initial commit without any buffer attached.
|
||||
The compositor will reply with a layer_surface.configure event.
|
||||
The client must acknowledge it and is then allowed to attach a buffer
|
||||
to map the surface.
|
||||
|
||||
You may pass NULL for output to allow the compositor to decide which
|
||||
output to use. Generally this will be the one that the user most
|
||||
recently interacted with.
|
||||
|
||||
Clients can specify a namespace that defines the purpose of the layer
|
||||
surface.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwlr_layer_surface_v1"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
||||
<arg name="layer" type="uint" enum="layer" summary="layer to add this surface to"/>
|
||||
<arg name="namespace" type="string" summary="namespace for the layer surface"/>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="role" value="0" summary="wl_surface has another role"/>
|
||||
<entry name="invalid_layer" value="1" summary="layer value is invalid"/>
|
||||
<entry name="already_constructed" value="2" summary="wl_surface has a buffer attached or committed"/>
|
||||
</enum>
|
||||
|
||||
<enum name="layer">
|
||||
<description summary="available layers for surfaces">
|
||||
These values indicate which layers a surface can be rendered in. They
|
||||
are ordered by z depth, bottom-most first. Traditional shell surfaces
|
||||
will typically be rendered between the bottom and top layers.
|
||||
Fullscreen shell surfaces are typically rendered at the top layer.
|
||||
Multiple surfaces can share a single layer, and ordering within a
|
||||
single layer is undefined.
|
||||
</description>
|
||||
|
||||
<entry name="background" value="0"/>
|
||||
<entry name="bottom" value="1"/>
|
||||
<entry name="top" value="2"/>
|
||||
<entry name="overlay" value="3"/>
|
||||
</enum>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
|
||||
<request name="destroy" type="destructor" since="3">
|
||||
<description summary="destroy the layer_shell object">
|
||||
This request indicates that the client will not use the layer_shell
|
||||
object any more. Objects that have been created through this instance
|
||||
are not affected.
|
||||
</description>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_layer_surface_v1" version="4">
|
||||
<description summary="layer metadata interface">
|
||||
An interface that may be implemented by a wl_surface, for surfaces that
|
||||
are designed to be rendered as a layer of a stacked desktop-like
|
||||
environment.
|
||||
|
||||
Layer surface state (layer, size, anchor, exclusive zone,
|
||||
margin, interactivity) is double-buffered, and will be applied at the
|
||||
time wl_surface.commit of the corresponding wl_surface is called.
|
||||
|
||||
Attaching a null buffer to a layer surface unmaps it.
|
||||
|
||||
Unmapping a layer_surface means that the surface cannot be shown by the
|
||||
compositor until it is explicitly mapped again. The layer_surface
|
||||
returns to the state it had right after layer_shell.get_layer_surface.
|
||||
The client can re-map the surface by performing a commit without any
|
||||
buffer attached, waiting for a configure event and handling it as usual.
|
||||
</description>
|
||||
|
||||
<request name="set_size">
|
||||
<description summary="sets the size of the surface">
|
||||
Sets the size of the surface in surface-local coordinates. The
|
||||
compositor will display the surface centered with respect to its
|
||||
anchors.
|
||||
|
||||
If you pass 0 for either value, the compositor will assign it and
|
||||
inform you of the assignment in the configure event. You must set your
|
||||
anchor to opposite edges in the dimensions you omit; not doing so is a
|
||||
protocol error. Both values are 0 by default.
|
||||
|
||||
Size is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="width" type="uint"/>
|
||||
<arg name="height" type="uint"/>
|
||||
</request>
|
||||
|
||||
<request name="set_anchor">
|
||||
<description summary="configures the anchor point of the surface">
|
||||
Requests that the compositor anchor the surface to the specified edges
|
||||
and corners. If two orthogonal edges are specified (e.g. 'top' and
|
||||
'left'), then the anchor point will be the intersection of the edges
|
||||
(e.g. the top left corner of the output); otherwise the anchor point
|
||||
will be centered on that edge, or in the center if none is specified.
|
||||
|
||||
Anchor is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="anchor" type="uint" enum="anchor"/>
|
||||
</request>
|
||||
|
||||
<request name="set_exclusive_zone">
|
||||
<description summary="configures the exclusive geometry of this surface">
|
||||
Requests that the compositor avoids occluding an area with other
|
||||
surfaces. The compositor's use of this information is
|
||||
implementation-dependent - do not assume that this region will not
|
||||
actually be occluded.
|
||||
|
||||
A positive value is only meaningful if the surface is anchored to one
|
||||
edge or an edge and both perpendicular edges. If the surface is not
|
||||
anchored, anchored to only two perpendicular edges (a corner), anchored
|
||||
to only two parallel edges or anchored to all edges, a positive value
|
||||
will be treated the same as zero.
|
||||
|
||||
A positive zone is the distance from the edge in surface-local
|
||||
coordinates to consider exclusive.
|
||||
|
||||
Surfaces that do not wish to have an exclusive zone may instead specify
|
||||
how they should interact with surfaces that do. If set to zero, the
|
||||
surface indicates that it would like to be moved to avoid occluding
|
||||
surfaces with a positive exclusive zone. If set to -1, the surface
|
||||
indicates that it would not like to be moved to accommodate for other
|
||||
surfaces, and the compositor should extend it all the way to the edges
|
||||
it is anchored to.
|
||||
|
||||
For example, a panel might set its exclusive zone to 10, so that
|
||||
maximized shell surfaces are not shown on top of it. A notification
|
||||
might set its exclusive zone to 0, so that it is moved to avoid
|
||||
occluding the panel, but shell surfaces are shown underneath it. A
|
||||
wallpaper or lock screen might set their exclusive zone to -1, so that
|
||||
they stretch below or over the panel.
|
||||
|
||||
The default value is 0.
|
||||
|
||||
Exclusive zone is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="zone" type="int"/>
|
||||
</request>
|
||||
|
||||
<request name="set_margin">
|
||||
<description summary="sets a margin from the anchor point">
|
||||
Requests that the surface be placed some distance away from the anchor
|
||||
point on the output, in surface-local coordinates. Setting this value
|
||||
for edges you are not anchored to has no effect.
|
||||
|
||||
The exclusive zone includes the margin.
|
||||
|
||||
Margin is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="top" type="int"/>
|
||||
<arg name="right" type="int"/>
|
||||
<arg name="bottom" type="int"/>
|
||||
<arg name="left" type="int"/>
|
||||
</request>
|
||||
|
||||
<enum name="keyboard_interactivity">
|
||||
<description summary="types of keyboard interaction possible for a layer shell surface">
|
||||
Types of keyboard interaction possible for layer shell surfaces. The
|
||||
rationale for this is twofold: (1) some applications are not interested
|
||||
in keyboard events and not allowing them to be focused can improve the
|
||||
desktop experience; (2) some applications will want to take exclusive
|
||||
keyboard focus.
|
||||
</description>
|
||||
|
||||
<entry name="none" value="0">
|
||||
<description summary="no keyboard focus is possible">
|
||||
This value indicates that this surface is not interested in keyboard
|
||||
events and the compositor should never assign it the keyboard focus.
|
||||
|
||||
This is the default value, set for newly created layer shell surfaces.
|
||||
|
||||
This is useful for e.g. desktop widgets that display information or
|
||||
only have interaction with non-keyboard input devices.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="exclusive" value="1">
|
||||
<description summary="request exclusive keyboard focus">
|
||||
Request exclusive keyboard focus if this surface is above the shell surface layer.
|
||||
|
||||
For the top and overlay layers, the seat will always give
|
||||
exclusive keyboard focus to the top-most layer which has keyboard
|
||||
interactivity set to exclusive. If this layer contains multiple
|
||||
surfaces with keyboard interactivity set to exclusive, the compositor
|
||||
determines the one receiving keyboard events in an implementation-
|
||||
defined manner. In this case, no guarantee is made when this surface
|
||||
will receive keyboard focus (if ever).
|
||||
|
||||
For the bottom and background layers, the compositor is allowed to use
|
||||
normal focus semantics.
|
||||
|
||||
This setting is mainly intended for applications that need to ensure
|
||||
they receive all keyboard events, such as a lock screen or a password
|
||||
prompt.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="on_demand" value="2" since="4">
|
||||
<description summary="request regular keyboard focus semantics">
|
||||
This requests the compositor to allow this surface to be focused and
|
||||
unfocused by the user in an implementation-defined manner. The user
|
||||
should be able to unfocus this surface even regardless of the layer
|
||||
it is on.
|
||||
|
||||
Typically, the compositor will want to use its normal mechanism to
|
||||
manage keyboard focus between layer shell surfaces with this setting
|
||||
and regular toplevels on the desktop layer (e.g. click to focus).
|
||||
Nevertheless, it is possible for a compositor to require a special
|
||||
interaction to focus or unfocus layer shell surfaces (e.g. requiring
|
||||
a click even if focus follows the mouse normally, or providing a
|
||||
keybinding to switch focus between layers).
|
||||
|
||||
This setting is mainly intended for desktop shell components (e.g.
|
||||
panels) that allow keyboard interaction. Using this option can allow
|
||||
implementing a desktop shell that can be fully usable without the
|
||||
mouse.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<request name="set_keyboard_interactivity">
|
||||
<description summary="requests keyboard events">
|
||||
Set how keyboard events are delivered to this surface. By default,
|
||||
layer shell surfaces do not receive keyboard events; this request can
|
||||
be used to change this.
|
||||
|
||||
This setting is inherited by child surfaces set by the get_popup
|
||||
request.
|
||||
|
||||
Layer surfaces receive pointer, touch, and tablet events normally. If
|
||||
you do not want to receive them, set the input region on your surface
|
||||
to an empty region.
|
||||
|
||||
Keyboard interactivity is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
|
||||
</request>
|
||||
|
||||
<request name="get_popup">
|
||||
<description summary="assign this layer_surface as an xdg_popup parent">
|
||||
This assigns an xdg_popup's parent to this layer_surface. This popup
|
||||
should have been created via xdg_surface::get_popup with the parent set
|
||||
to NULL, and this request must be invoked before committing the popup's
|
||||
initial state.
|
||||
|
||||
See the documentation of xdg_popup for more details about what an
|
||||
xdg_popup is and how it is used.
|
||||
</description>
|
||||
<arg name="popup" type="object" interface="xdg_popup"/>
|
||||
</request>
|
||||
|
||||
<request name="ack_configure">
|
||||
<description summary="ack a configure event">
|
||||
When a configure event is received, if a client commits the
|
||||
surface in response to the configure event, then the client
|
||||
must make an ack_configure request sometime before the commit
|
||||
request, passing along the serial of the configure event.
|
||||
|
||||
If the client receives multiple configure events before it
|
||||
can respond to one, it only has to ack the last configure event.
|
||||
|
||||
A client is not required to commit immediately after sending
|
||||
an ack_configure request - it may even ack_configure several times
|
||||
before its next surface commit.
|
||||
|
||||
A client may send multiple ack_configure requests before committing, but
|
||||
only the last request sent before a commit indicates which configure
|
||||
event the client really is responding to.
|
||||
</description>
|
||||
<arg name="serial" type="uint" summary="the serial from the configure event"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the layer_surface">
|
||||
This request destroys the layer surface.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="configure">
|
||||
<description summary="suggest a surface change">
|
||||
The configure event asks the client to resize its surface.
|
||||
|
||||
Clients should arrange their surface for the new states, and then send
|
||||
an ack_configure request with the serial sent in this configure event at
|
||||
some point before committing the new surface.
|
||||
|
||||
The client is free to dismiss all but the last configure event it
|
||||
received.
|
||||
|
||||
The width and height arguments specify the size of the window in
|
||||
surface-local coordinates.
|
||||
|
||||
The size is a hint, in the sense that the client is free to ignore it if
|
||||
it doesn't resize, pick a smaller size (to satisfy aspect ratio or
|
||||
resize in steps of NxM pixels). If the client picks a smaller size and
|
||||
is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
|
||||
surface will be centered on this axis.
|
||||
|
||||
If the width or height arguments are zero, it means the client should
|
||||
decide its own window dimension.
|
||||
</description>
|
||||
<arg name="serial" type="uint"/>
|
||||
<arg name="width" type="uint"/>
|
||||
<arg name="height" type="uint"/>
|
||||
</event>
|
||||
|
||||
<event name="closed">
|
||||
<description summary="surface should be closed">
|
||||
The closed event is sent by the compositor when the surface will no
|
||||
longer be shown. The output may have been destroyed or the user may
|
||||
have asked for it to be removed. Further changes to the surface will be
|
||||
ignored. The client should destroy the resource after receiving this
|
||||
event, and create a new surface if they so choose.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
|
||||
<entry name="invalid_size" value="1" summary="size is invalid"/>
|
||||
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
|
||||
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
|
||||
</enum>
|
||||
|
||||
<enum name="anchor" bitfield="true">
|
||||
<entry name="top" value="1" summary="the top edge of the anchor rectangle"/>
|
||||
<entry name="bottom" value="2" summary="the bottom edge of the anchor rectangle"/>
|
||||
<entry name="left" value="4" summary="the left edge of the anchor rectangle"/>
|
||||
<entry name="right" value="8" summary="the right edge of the anchor rectangle"/>
|
||||
</enum>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<request name="set_layer" since="2">
|
||||
<description summary="change the layer of the surface">
|
||||
Change the layer that the surface is rendered on.
|
||||
|
||||
Layer is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
|
@ -0,0 +1,78 @@
|
|||
/* Generated by wayland-scanner 1.21.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2017 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface zxdg_output_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_output_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&zxdg_output_v1_interface,
|
||||
&wl_output_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_output_unstable_v1_types + 0 },
|
||||
{ "get_xdg_output", "no", xdg_output_unstable_v1_types + 2 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_output_manager_v1_interface = {
|
||||
"zxdg_output_manager_v1", 3,
|
||||
2, zxdg_output_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_v1_requests[] = {
|
||||
{ "destroy", "", xdg_output_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_v1_events[] = {
|
||||
{ "logical_position", "ii", xdg_output_unstable_v1_types + 0 },
|
||||
{ "logical_size", "ii", xdg_output_unstable_v1_types + 0 },
|
||||
{ "done", "", xdg_output_unstable_v1_types + 0 },
|
||||
{ "name", "2s", xdg_output_unstable_v1_types + 0 },
|
||||
{ "description", "2s", xdg_output_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_output_v1_interface = {
|
||||
"zxdg_output_v1", 3,
|
||||
1, zxdg_output_v1_requests,
|
||||
5, zxdg_output_v1_events,
|
||||
};
|
||||
|
411
.config/dwl/menu/lib/renderers/wayland/xdg-output-unstable-v1.h
Normal file
411
.config/dwl/menu/lib/renderers/wayland/xdg-output-unstable-v1.h
Normal file
|
@ -0,0 +1,411 @@
|
|||
/* Generated by wayland-scanner 1.21.0 */
|
||||
|
||||
#ifndef XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
#define XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_xdg_output_unstable_v1 The xdg_output_unstable_v1 protocol
|
||||
* Protocol to describe output regions
|
||||
*
|
||||
* @section page_desc_xdg_output_unstable_v1 Description
|
||||
*
|
||||
* This protocol aims at describing outputs in a way which is more in line
|
||||
* with the concept of an output on desktop oriented systems.
|
||||
*
|
||||
* Some information are more specific to the concept of an output for
|
||||
* a desktop oriented system and may not make sense in other applications,
|
||||
* such as IVI systems for example.
|
||||
*
|
||||
* Typically, the global compositor space on a desktop system is made of
|
||||
* a contiguous or overlapping set of rectangular regions.
|
||||
*
|
||||
* Some of the information provided in this protocol might be identical
|
||||
* to their counterparts already available from wl_output, in which case
|
||||
* the information provided by this protocol should be preferred to their
|
||||
* equivalent in wl_output. The goal is to move the desktop specific
|
||||
* concepts (such as output location within the global compositor space,
|
||||
* the connector name and types, etc.) out of the core wl_output protocol.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and
|
||||
* backward incompatible changes may be made. Backward compatible
|
||||
* changes may be added together with the corresponding interface
|
||||
* version bump.
|
||||
* Backward incompatible changes are done by bumping the version
|
||||
* number in the protocol and interface names and resetting the
|
||||
* interface version. Once the protocol is to be declared stable,
|
||||
* the 'z' prefix and the version number in the protocol and
|
||||
* interface names are removed and the interface version number is
|
||||
* reset.
|
||||
*
|
||||
* @section page_ifaces_xdg_output_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zxdg_output_manager_v1 - manage xdg_output objects
|
||||
* - @subpage page_iface_zxdg_output_v1 - compositor logical output region
|
||||
* @section page_copyright_xdg_output_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2017 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_output;
|
||||
struct zxdg_output_manager_v1;
|
||||
struct zxdg_output_v1;
|
||||
|
||||
#ifndef ZXDG_OUTPUT_MANAGER_V1_INTERFACE
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1
|
||||
* @section page_iface_zxdg_output_manager_v1_desc Description
|
||||
*
|
||||
* A global factory interface for xdg_output objects.
|
||||
* @section page_iface_zxdg_output_manager_v1_api API
|
||||
* See @ref iface_zxdg_output_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_output_manager_v1 The zxdg_output_manager_v1 interface
|
||||
*
|
||||
* A global factory interface for xdg_output objects.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_output_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZXDG_OUTPUT_V1_INTERFACE
|
||||
#define ZXDG_OUTPUT_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_output_v1 zxdg_output_v1
|
||||
* @section page_iface_zxdg_output_v1_desc Description
|
||||
*
|
||||
* An xdg_output describes part of the compositor geometry.
|
||||
*
|
||||
* This typically corresponds to a monitor that displays part of the
|
||||
* compositor space.
|
||||
*
|
||||
* For objects version 3 onwards, after all xdg_output properties have been
|
||||
* sent (when the object is created and when properties are updated), a
|
||||
* wl_output.done event is sent. This allows changes to the output
|
||||
* properties to be seen as atomic, even if they happen via multiple events.
|
||||
* @section page_iface_zxdg_output_v1_api API
|
||||
* See @ref iface_zxdg_output_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_output_v1 The zxdg_output_v1 interface
|
||||
*
|
||||
* An xdg_output describes part of the compositor geometry.
|
||||
*
|
||||
* This typically corresponds to a monitor that displays part of the
|
||||
* compositor space.
|
||||
*
|
||||
* For objects version 3 onwards, after all xdg_output properties have been
|
||||
* sent (when the object is created and when properties are updated), a
|
||||
* wl_output.done event is sent. This allows changes to the output
|
||||
* properties to be seen as atomic, even if they happen via multiple events.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_output_v1_interface;
|
||||
#endif
|
||||
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_DESTROY 0
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_output_manager_v1 */
|
||||
static inline void
|
||||
zxdg_output_manager_v1_set_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_output_manager_v1 */
|
||||
static inline void *
|
||||
zxdg_output_manager_v1_get_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_output_manager_v1_get_version(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*
|
||||
* Using this request a client can tell the server that it is not
|
||||
* going to use the xdg_output_manager object anymore.
|
||||
*
|
||||
* Any objects already created through this instance are not affected.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_output_manager_v1_destroy(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1,
|
||||
ZXDG_OUTPUT_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*
|
||||
* This creates a new xdg_output object for the given wl_output.
|
||||
*/
|
||||
static inline struct zxdg_output_v1 *
|
||||
zxdg_output_manager_v1_get_xdg_output(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, struct wl_output *output)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1,
|
||||
ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), 0, NULL, output);
|
||||
|
||||
return (struct zxdg_output_v1 *) id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
* @struct zxdg_output_v1_listener
|
||||
*/
|
||||
struct zxdg_output_v1_listener {
|
||||
/**
|
||||
* position of the output within the global compositor space
|
||||
*
|
||||
* The position event describes the location of the wl_output
|
||||
* within the global compositor space.
|
||||
*
|
||||
* The logical_position event is sent after creating an xdg_output
|
||||
* (see xdg_output_manager.get_xdg_output) and whenever the
|
||||
* location of the output changes within the global compositor
|
||||
* space.
|
||||
* @param x x position within the global compositor space
|
||||
* @param y y position within the global compositor space
|
||||
*/
|
||||
void (*logical_position)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
int32_t x,
|
||||
int32_t y);
|
||||
/**
|
||||
* size of the output in the global compositor space
|
||||
*
|
||||
* The logical_size event describes the size of the output in the
|
||||
* global compositor space.
|
||||
*
|
||||
* For example, a surface without any buffer scale, transformation
|
||||
* nor rotation set, with the size matching the logical_size will
|
||||
* have the same size as the corresponding output when displayed.
|
||||
*
|
||||
* Most regular Wayland clients should not pay attention to the
|
||||
* logical size and would rather rely on xdg_shell interfaces.
|
||||
*
|
||||
* Some clients such as Xwayland, however, need this to configure
|
||||
* their surfaces in the global compositor space as the compositor
|
||||
* may apply a different scale from what is advertised by the
|
||||
* output scaling property (to achieve fractional scaling, for
|
||||
* example).
|
||||
*
|
||||
* For example, for a wl_output mode 3840×2160 and a scale factor
|
||||
* 2:
|
||||
*
|
||||
* - A compositor not scaling the surface buffers will advertise a
|
||||
* logical size of 3840×2160,
|
||||
*
|
||||
* - A compositor automatically scaling the surface buffers will
|
||||
* advertise a logical size of 1920×1080,
|
||||
*
|
||||
* - A compositor using a fractional scale of 1.5 will advertise a
|
||||
* logical size to 2560×1620.
|
||||
*
|
||||
* For example, for a wl_output mode 1920×1080 and a 90 degree
|
||||
* rotation, the compositor will advertise a logical size of
|
||||
* 1080x1920.
|
||||
*
|
||||
* The logical_size event is sent after creating an xdg_output (see
|
||||
* xdg_output_manager.get_xdg_output) and whenever the logical size
|
||||
* of the output changes, either as a result of a change in the
|
||||
* applied scale or because of a change in the corresponding output
|
||||
* mode(see wl_output.mode) or transform (see wl_output.transform).
|
||||
* @param width width in global compositor space
|
||||
* @param height height in global compositor space
|
||||
*/
|
||||
void (*logical_size)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
int32_t width,
|
||||
int32_t height);
|
||||
/**
|
||||
* all information about the output have been sent
|
||||
*
|
||||
* This event is sent after all other properties of an xdg_output
|
||||
* have been sent.
|
||||
*
|
||||
* This allows changes to the xdg_output properties to be seen as
|
||||
* atomic, even if they happen via multiple events.
|
||||
*
|
||||
* For objects version 3 onwards, this event is deprecated.
|
||||
* Compositors are not required to send it anymore and must send
|
||||
* wl_output.done instead.
|
||||
*/
|
||||
void (*done)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1);
|
||||
/**
|
||||
* name of this output
|
||||
*
|
||||
* Many compositors will assign names to their outputs, show them
|
||||
* to the user, allow them to be configured by name, etc. The
|
||||
* client may wish to know this name as well to offer the user
|
||||
* similar behaviors.
|
||||
*
|
||||
* The naming convention is compositor defined, but limited to
|
||||
* alphanumeric characters and dashes (-). Each name is unique
|
||||
* among all wl_output globals, but if a wl_output global is
|
||||
* destroyed the same name may be reused later. The names will also
|
||||
* remain consistent across sessions with the same hardware and
|
||||
* software configuration.
|
||||
*
|
||||
* Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc.
|
||||
* However, do not assume that the name is a reflection of an
|
||||
* underlying DRM connector, X11 connection, etc.
|
||||
*
|
||||
* The name event is sent after creating an xdg_output (see
|
||||
* xdg_output_manager.get_xdg_output). This event is only sent once
|
||||
* per xdg_output, and the name does not change over the lifetime
|
||||
* of the wl_output global.
|
||||
* @param name output name
|
||||
* @since 2
|
||||
*/
|
||||
void (*name)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
const char *name);
|
||||
/**
|
||||
* human-readable description of this output
|
||||
*
|
||||
* Many compositors can produce human-readable descriptions of
|
||||
* their outputs. The client may wish to know this description as
|
||||
* well, to communicate the user for various purposes.
|
||||
*
|
||||
* The description is a UTF-8 string with no convention defined for
|
||||
* its contents. Examples might include 'Foocorp 11" Display' or
|
||||
* 'Virtual X11 output via :1'.
|
||||
*
|
||||
* The description event is sent after creating an xdg_output (see
|
||||
* xdg_output_manager.get_xdg_output) and whenever the description
|
||||
* changes. The description is optional, and may not be sent at
|
||||
* all.
|
||||
*
|
||||
* For objects of version 2 and lower, this event is only sent once
|
||||
* per xdg_output, and the description does not change over the
|
||||
* lifetime of the wl_output global.
|
||||
* @param description output description
|
||||
* @since 2
|
||||
*/
|
||||
void (*description)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
const char *description);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
static inline int
|
||||
zxdg_output_v1_add_listener(struct zxdg_output_v1 *zxdg_output_v1,
|
||||
const struct zxdg_output_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) zxdg_output_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define ZXDG_OUTPUT_V1_DESTROY 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_LOGICAL_POSITION_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_LOGICAL_SIZE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_DONE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_NAME_SINCE_VERSION 2
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_output_v1 */
|
||||
static inline void
|
||||
zxdg_output_v1_set_user_data(struct zxdg_output_v1 *zxdg_output_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_output_v1 */
|
||||
static inline void *
|
||||
zxdg_output_v1_get_user_data(struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_output_v1_get_version(struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*
|
||||
* Using this request a client can tell the server that it is not
|
||||
* going to use the xdg_output object anymore.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_output_v1_destroy(struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_v1,
|
||||
ZXDG_OUTPUT_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,220 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="xdg_output_unstable_v1">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2017 Red Hat Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="Protocol to describe output regions">
|
||||
This protocol aims at describing outputs in a way which is more in line
|
||||
with the concept of an output on desktop oriented systems.
|
||||
|
||||
Some information are more specific to the concept of an output for
|
||||
a desktop oriented system and may not make sense in other applications,
|
||||
such as IVI systems for example.
|
||||
|
||||
Typically, the global compositor space on a desktop system is made of
|
||||
a contiguous or overlapping set of rectangular regions.
|
||||
|
||||
Some of the information provided in this protocol might be identical
|
||||
to their counterparts already available from wl_output, in which case
|
||||
the information provided by this protocol should be preferred to their
|
||||
equivalent in wl_output. The goal is to move the desktop specific
|
||||
concepts (such as output location within the global compositor space,
|
||||
the connector name and types, etc.) out of the core wl_output protocol.
|
||||
|
||||
Warning! The protocol described in this file is experimental and
|
||||
backward incompatible changes may be made. Backward compatible
|
||||
changes may be added together with the corresponding interface
|
||||
version bump.
|
||||
Backward incompatible changes are done by bumping the version
|
||||
number in the protocol and interface names and resetting the
|
||||
interface version. Once the protocol is to be declared stable,
|
||||
the 'z' prefix and the version number in the protocol and
|
||||
interface names are removed and the interface version number is
|
||||
reset.
|
||||
</description>
|
||||
|
||||
<interface name="zxdg_output_manager_v1" version="3">
|
||||
<description summary="manage xdg_output objects">
|
||||
A global factory interface for xdg_output objects.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the xdg_output_manager object">
|
||||
Using this request a client can tell the server that it is not
|
||||
going to use the xdg_output_manager object anymore.
|
||||
|
||||
Any objects already created through this instance are not affected.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="get_xdg_output">
|
||||
<description summary="create an xdg output from a wl_output">
|
||||
This creates a new xdg_output object for the given wl_output.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zxdg_output_v1"/>
|
||||
<arg name="output" type="object" interface="wl_output"/>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zxdg_output_v1" version="3">
|
||||
<description summary="compositor logical output region">
|
||||
An xdg_output describes part of the compositor geometry.
|
||||
|
||||
This typically corresponds to a monitor that displays part of the
|
||||
compositor space.
|
||||
|
||||
For objects version 3 onwards, after all xdg_output properties have been
|
||||
sent (when the object is created and when properties are updated), a
|
||||
wl_output.done event is sent. This allows changes to the output
|
||||
properties to be seen as atomic, even if they happen via multiple events.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the xdg_output object">
|
||||
Using this request a client can tell the server that it is not
|
||||
going to use the xdg_output object anymore.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="logical_position">
|
||||
<description summary="position of the output within the global compositor space">
|
||||
The position event describes the location of the wl_output within
|
||||
the global compositor space.
|
||||
|
||||
The logical_position event is sent after creating an xdg_output
|
||||
(see xdg_output_manager.get_xdg_output) and whenever the location
|
||||
of the output changes within the global compositor space.
|
||||
</description>
|
||||
<arg name="x" type="int"
|
||||
summary="x position within the global compositor space"/>
|
||||
<arg name="y" type="int"
|
||||
summary="y position within the global compositor space"/>
|
||||
</event>
|
||||
|
||||
<event name="logical_size">
|
||||
<description summary="size of the output in the global compositor space">
|
||||
The logical_size event describes the size of the output in the
|
||||
global compositor space.
|
||||
|
||||
For example, a surface without any buffer scale, transformation
|
||||
nor rotation set, with the size matching the logical_size will
|
||||
have the same size as the corresponding output when displayed.
|
||||
|
||||
Most regular Wayland clients should not pay attention to the
|
||||
logical size and would rather rely on xdg_shell interfaces.
|
||||
|
||||
Some clients such as Xwayland, however, need this to configure
|
||||
their surfaces in the global compositor space as the compositor
|
||||
may apply a different scale from what is advertised by the output
|
||||
scaling property (to achieve fractional scaling, for example).
|
||||
|
||||
For example, for a wl_output mode 3840×2160 and a scale factor 2:
|
||||
|
||||
- A compositor not scaling the surface buffers will advertise a
|
||||
logical size of 3840×2160,
|
||||
|
||||
- A compositor automatically scaling the surface buffers will
|
||||
advertise a logical size of 1920×1080,
|
||||
|
||||
- A compositor using a fractional scale of 1.5 will advertise a
|
||||
logical size to 2560×1620.
|
||||
|
||||
For example, for a wl_output mode 1920×1080 and a 90 degree rotation,
|
||||
the compositor will advertise a logical size of 1080x1920.
|
||||
|
||||
The logical_size event is sent after creating an xdg_output
|
||||
(see xdg_output_manager.get_xdg_output) and whenever the logical
|
||||
size of the output changes, either as a result of a change in the
|
||||
applied scale or because of a change in the corresponding output
|
||||
mode(see wl_output.mode) or transform (see wl_output.transform).
|
||||
</description>
|
||||
<arg name="width" type="int"
|
||||
summary="width in global compositor space"/>
|
||||
<arg name="height" type="int"
|
||||
summary="height in global compositor space"/>
|
||||
</event>
|
||||
|
||||
<event name="done">
|
||||
<description summary="all information about the output have been sent">
|
||||
This event is sent after all other properties of an xdg_output
|
||||
have been sent.
|
||||
|
||||
This allows changes to the xdg_output properties to be seen as
|
||||
atomic, even if they happen via multiple events.
|
||||
|
||||
For objects version 3 onwards, this event is deprecated. Compositors
|
||||
are not required to send it anymore and must send wl_output.done
|
||||
instead.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<event name="name" since="2">
|
||||
<description summary="name of this output">
|
||||
Many compositors will assign names to their outputs, show them to the
|
||||
user, allow them to be configured by name, etc. The client may wish to
|
||||
know this name as well to offer the user similar behaviors.
|
||||
|
||||
The naming convention is compositor defined, but limited to
|
||||
alphanumeric characters and dashes (-). Each name is unique among all
|
||||
wl_output globals, but if a wl_output global is destroyed the same name
|
||||
may be reused later. The names will also remain consistent across
|
||||
sessions with the same hardware and software configuration.
|
||||
|
||||
Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do
|
||||
not assume that the name is a reflection of an underlying DRM
|
||||
connector, X11 connection, etc.
|
||||
|
||||
The name event is sent after creating an xdg_output (see
|
||||
xdg_output_manager.get_xdg_output). This event is only sent once per
|
||||
xdg_output, and the name does not change over the lifetime of the
|
||||
wl_output global.
|
||||
</description>
|
||||
<arg name="name" type="string" summary="output name"/>
|
||||
</event>
|
||||
|
||||
<event name="description" since="2">
|
||||
<description summary="human-readable description of this output">
|
||||
Many compositors can produce human-readable descriptions of their
|
||||
outputs. The client may wish to know this description as well, to
|
||||
communicate the user for various purposes.
|
||||
|
||||
The description is a UTF-8 string with no convention defined for its
|
||||
contents. Examples might include 'Foocorp 11" Display' or 'Virtual X11
|
||||
output via :1'.
|
||||
|
||||
The description event is sent after creating an xdg_output (see
|
||||
xdg_output_manager.get_xdg_output) and whenever the description
|
||||
changes. The description is optional, and may not be sent at all.
|
||||
|
||||
For objects of version 2 and lower, this event is only sent once per
|
||||
xdg_output, and the description does not change over the lifetime of
|
||||
the wl_output global.
|
||||
</description>
|
||||
<arg name="description" type="string" summary="output description"/>
|
||||
</event>
|
||||
|
||||
</interface>
|
||||
</protocol>
|
299
.config/dwl/menu/lib/renderers/x11/window.c
Normal file
299
.config/dwl/menu/lib/renderers/x11/window.c
Normal file
|
@ -0,0 +1,299 @@
|
|||
#include "internal.h"
|
||||
#include "x11.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cairo-xlib.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
static void
|
||||
destroy_buffer(struct buffer *buffer)
|
||||
{
|
||||
bm_cairo_destroy(&buffer->cairo);
|
||||
memset(buffer, 0, sizeof(struct buffer));
|
||||
}
|
||||
|
||||
static bool
|
||||
create_buffer(struct window *window, struct buffer *buffer, int32_t width, int32_t height)
|
||||
{
|
||||
cairo_surface_t *surf;
|
||||
if (!(surf = cairo_xlib_surface_create(window->display, window->drawable, window->visual, width, height)))
|
||||
goto fail;
|
||||
|
||||
cairo_xlib_surface_set_size(surf, width, height);
|
||||
|
||||
const char *scale = getenv("BEMENU_SCALE");
|
||||
if (scale) {
|
||||
buffer->cairo.scale = fmax(strtof(scale, NULL), 1.0f);
|
||||
} else {
|
||||
buffer->cairo.scale = 1;
|
||||
}
|
||||
|
||||
if (!bm_cairo_create_for_surface(&buffer->cairo, surf)) {
|
||||
cairo_surface_destroy(surf);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
buffer->width = width;
|
||||
buffer->height = height;
|
||||
buffer->created = true;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
destroy_buffer(buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct buffer*
|
||||
next_buffer(struct window *window)
|
||||
{
|
||||
assert(window);
|
||||
|
||||
struct buffer *buffer = &window->buffer;
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
if (window->width != buffer->width || window->height != buffer->height)
|
||||
destroy_buffer(buffer);
|
||||
|
||||
if (!buffer->created && !create_buffer(window, buffer, window->width, window->height))
|
||||
return NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_window_width(struct window *window)
|
||||
{
|
||||
uint32_t width = window->width * ((window->width_factor != 0) ? window->width_factor : 1);
|
||||
|
||||
if(width > window->width - 2 * window->hmargin_size)
|
||||
width = window->width - 2 * window->hmargin_size;
|
||||
|
||||
if(width < WINDOW_MIN_WIDTH || 2 * window->hmargin_size > window->width)
|
||||
width = WINDOW_MIN_WIDTH;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
void
|
||||
bm_x11_window_render(struct window *window, const struct bm_menu *menu)
|
||||
{
|
||||
assert(window && menu);
|
||||
uint32_t oldw = window->width, oldh = window->height;
|
||||
|
||||
struct buffer *buffer;
|
||||
for (int32_t tries = 0; tries < 2; ++tries) {
|
||||
if (!(buffer = next_buffer(window))) {
|
||||
fprintf(stderr, "could not get next buffer");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!window->notify.render)
|
||||
break;
|
||||
|
||||
cairo_push_group(buffer->cairo.cr);
|
||||
struct cairo_paint_result result;
|
||||
window->notify.render(&buffer->cairo, buffer->width, window->max_height, menu, &result);
|
||||
window->displayed = result.displayed;
|
||||
cairo_pop_group_to_source(buffer->cairo.cr);
|
||||
|
||||
if (window->height == result.height)
|
||||
break;
|
||||
|
||||
window->height = result.height;
|
||||
destroy_buffer(buffer);
|
||||
}
|
||||
|
||||
if (oldw != window->width || oldh != window->height) {
|
||||
uint32_t win_y = 0;
|
||||
|
||||
if(window->align == BM_ALIGN_CENTER) {
|
||||
win_y = (window->max_height - window->height) / 2;
|
||||
} else if(window->align == BM_ALIGN_BOTTOM) {
|
||||
win_y = window->max_height - window->height;
|
||||
}
|
||||
|
||||
XMoveResizeWindow(window->display, window->drawable, window->x, win_y, window->width, window->height);
|
||||
}
|
||||
|
||||
if (buffer->created) {
|
||||
cairo_save(buffer->cairo.cr);
|
||||
cairo_set_operator(buffer->cairo.cr, CAIRO_OPERATOR_SOURCE);
|
||||
cairo_paint(buffer->cairo.cr);
|
||||
cairo_surface_flush(buffer->cairo.surface);
|
||||
cairo_restore(buffer->cairo.cr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bm_x11_window_key_press(struct window *window, XKeyEvent *ev)
|
||||
{
|
||||
KeySym keysym = NoSymbol;
|
||||
XmbLookupString(window->xic, ev, NULL, 0, &keysym, NULL);
|
||||
window->mods = 0;
|
||||
if (ev->state & ControlMask) window->mods |= MOD_CTRL;
|
||||
if (ev->state & ShiftMask) window->mods |= MOD_SHIFT;
|
||||
if (ev->state & Mod1Mask) window->mods |= MOD_ALT;
|
||||
window->keysym = keysym;
|
||||
}
|
||||
|
||||
void
|
||||
bm_x11_window_destroy(struct window *window)
|
||||
{
|
||||
assert(window);
|
||||
destroy_buffer(&window->buffer);
|
||||
|
||||
if (window->display && window->drawable)
|
||||
XDestroyWindow(window->display, window->drawable);
|
||||
}
|
||||
|
||||
void
|
||||
bm_x11_window_set_monitor(struct window *window, int32_t monitor)
|
||||
{
|
||||
if (window->monitor == monitor)
|
||||
return;
|
||||
|
||||
Window root = DefaultRootWindow(window->display);
|
||||
|
||||
{
|
||||
/* xinerama logic straight from dmenu */
|
||||
#define INTERSECT(x,y,w,h,r) (fmax(0, fmin((x)+(w),(r).x_org+(r).width) - fmax((x),(r).x_org)) * fmax(0, fmin((y)+(h),(r).y_org+(r).height) - fmax((y),(r).y_org)))
|
||||
|
||||
int32_t n;
|
||||
XineramaScreenInfo *info;
|
||||
if ((info = XineramaQueryScreens(window->display, &n))) {
|
||||
int32_t x, y, a, j, di, i = 0, area = 0;
|
||||
uint32_t du;
|
||||
Window w, pw, dw, *dws;
|
||||
XWindowAttributes wa;
|
||||
|
||||
XGetInputFocus(window->display, &w, &di);
|
||||
if (monitor >= 0 && monitor < n)
|
||||
i = monitor;
|
||||
else if (w != root && w != PointerRoot && w != None) {
|
||||
/* find top-level window containing current input focus */
|
||||
do {
|
||||
if (XQueryTree(window->display, (pw = w), &dw, &w, &dws, &du) && dws)
|
||||
XFree(dws);
|
||||
} while(w != root && w != pw);
|
||||
|
||||
/* find xinerama screen with which the window intersects most */
|
||||
if (XGetWindowAttributes(window->display, pw, &wa)) {
|
||||
for (j = 0; j < n; j++)
|
||||
if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
|
||||
area = a;
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no focused window is on screen, so use pointer location instead */
|
||||
if (monitor < 0 && !area && XQueryPointer(window->display, root, &dw, &dw, &x, &y, &di, &di, &du)) {
|
||||
for (i = 0; i < n; i++) {
|
||||
if (INTERSECT(x, y, 1, 1, info[i]) > 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window->x = info[i].x_org;
|
||||
window->y = info[i].y_org;
|
||||
if(window->align == BM_ALIGN_CENTER) {
|
||||
window->y += (info[i].height - window->height) / 2;
|
||||
} else if(window->align == BM_ALIGN_BOTTOM) {
|
||||
window->y += info[i].height - window->height;
|
||||
}
|
||||
|
||||
window->width = info[i].width;
|
||||
window->max_height = info[i].height;
|
||||
XFree(info);
|
||||
} else {
|
||||
window->max_height = DisplayHeight(window->display, window->screen);
|
||||
window->x = 0;
|
||||
if(window->align == BM_ALIGN_CENTER) {
|
||||
window->y = (window->max_height - window->height) / 2;
|
||||
} else if(window->align == BM_ALIGN_BOTTOM) {
|
||||
window->y = window->max_height - window->height;
|
||||
} else {
|
||||
window->y = 0;
|
||||
}
|
||||
window->width = DisplayWidth(window->display, window->screen);
|
||||
}
|
||||
|
||||
window->orig_width = window->width;
|
||||
window->orig_x = window->x;
|
||||
window->width = get_window_width(window);
|
||||
window->x += (window->orig_width - window->width) / 2;
|
||||
|
||||
#undef INTERSECT
|
||||
}
|
||||
|
||||
window->monitor = monitor;
|
||||
XMoveResizeWindow(window->display, window->drawable, window->x, window->y, window->width, window->height);
|
||||
XFlush(window->display);
|
||||
}
|
||||
|
||||
void
|
||||
bm_x11_window_set_align(struct window *window, enum bm_align align)
|
||||
{
|
||||
if(window->align == align)
|
||||
return;
|
||||
|
||||
window->align = align;
|
||||
bm_x11_window_set_monitor(window, window->monitor);
|
||||
}
|
||||
|
||||
void
|
||||
bm_x11_window_set_width(struct window *window, uint32_t margin, float factor)
|
||||
{
|
||||
if(window->hmargin_size == margin && window->width_factor == factor)
|
||||
return;
|
||||
|
||||
window->hmargin_size = margin;
|
||||
window->width_factor = factor;
|
||||
window->width = window->orig_width;
|
||||
window->x = window->orig_x;
|
||||
window->width = get_window_width(window);
|
||||
window->x += (window->orig_width - window->width) / 2;
|
||||
bm_x11_window_set_monitor(window, window->monitor);
|
||||
}
|
||||
|
||||
bool
|
||||
bm_x11_window_create(struct window *window, Display *display)
|
||||
{
|
||||
assert(window);
|
||||
|
||||
window->display = display;
|
||||
window->screen = DefaultScreen(display);
|
||||
window->width = window->height = 1;
|
||||
window->monitor = -1;
|
||||
window->visual = DefaultVisual(display, window->screen);
|
||||
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask
|
||||
};
|
||||
|
||||
XVisualInfo vinfo;
|
||||
int depth = DefaultDepth(display, window->screen);
|
||||
unsigned long valuemask = CWOverrideRedirect | CWEventMask | CWBackPixel;
|
||||
|
||||
if (XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo)) {
|
||||
depth = vinfo.depth;
|
||||
window->visual = vinfo.visual;
|
||||
wa.background_pixmap = None;
|
||||
wa.border_pixel = 0;
|
||||
wa.colormap = XCreateColormap(display, DefaultRootWindow(display), window->visual, AllocNone);
|
||||
valuemask = CWOverrideRedirect | CWEventMask | CWBackPixmap | CWColormap | CWBorderPixel;
|
||||
}
|
||||
|
||||
window->drawable = XCreateWindow(display, DefaultRootWindow(display), 0, 0, window->width, window->height, 0, depth, CopyFromParent, window->visual, valuemask, &wa);
|
||||
XSelectInput(display, window->drawable, ButtonPressMask | KeyPressMask);
|
||||
XMapRaised(display, window->drawable);
|
||||
window->xim = XOpenIM(display, NULL, NULL, NULL);
|
||||
window->xic = XCreateIC(window->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, window->drawable, XNFocusWindow, window->drawable, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
312
.config/dwl/menu/lib/renderers/x11/x11.c
Normal file
312
.config/dwl/menu/lib/renderers/x11/x11.c
Normal file
|
@ -0,0 +1,312 @@
|
|||
#include "internal.h"
|
||||
#include "x11.h"
|
||||
#include "xkb_unicode.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
static bool
|
||||
render(struct bm_menu *menu)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
|
||||
bm_x11_window_render(&x11->window, menu);
|
||||
XFlush(x11->display);
|
||||
|
||||
XEvent ev;
|
||||
if (XNextEvent(x11->display, &ev) || XFilterEvent(&ev, x11->window.drawable))
|
||||
return true;
|
||||
|
||||
switch (ev.type) {
|
||||
case KeyPress:
|
||||
bm_x11_window_key_press(&x11->window, &ev.xkey);
|
||||
break;
|
||||
case SelectionNotify:
|
||||
// paste here
|
||||
break;
|
||||
case VisibilityNotify:
|
||||
if (ev.xvisibility.state != VisibilityUnobscured) {
|
||||
XRaiseWindow(x11->display, x11->window.drawable);
|
||||
XFlush(x11->display);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static enum bm_key
|
||||
poll_key(const struct bm_menu *menu, unsigned int *unicode)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
assert(x11 && unicode);
|
||||
|
||||
if (x11->window.keysym == NoSymbol)
|
||||
return BM_KEY_UNICODE;
|
||||
|
||||
KeySym sym = x11->window.keysym;
|
||||
uint32_t mods = x11->window.mods;
|
||||
*unicode = bm_x11_key_sym2unicode(sym);
|
||||
|
||||
x11->window.keysym = NoSymbol;
|
||||
|
||||
switch (sym) {
|
||||
case XK_Up:
|
||||
return BM_KEY_UP;
|
||||
|
||||
case XK_Down:
|
||||
return BM_KEY_DOWN;
|
||||
|
||||
case XK_Left:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_UP : BM_KEY_LEFT);
|
||||
|
||||
case XK_Right:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_DOWN : BM_KEY_RIGHT);
|
||||
|
||||
case XK_Home:
|
||||
return BM_KEY_HOME;
|
||||
|
||||
case XK_End:
|
||||
return BM_KEY_END;
|
||||
|
||||
case XK_Page_Up:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_SHIFT_PAGE_UP : BM_KEY_PAGE_UP);
|
||||
|
||||
case XK_less:
|
||||
return (mods & MOD_ALT ? BM_KEY_SHIFT_PAGE_UP : BM_KEY_UNICODE);
|
||||
|
||||
case XK_Page_Down:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_SHIFT_PAGE_DOWN : BM_KEY_PAGE_DOWN);
|
||||
|
||||
case XK_greater:
|
||||
return (mods & MOD_ALT ? BM_KEY_SHIFT_PAGE_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XK_v:
|
||||
return (mods & MOD_CTRL ? BM_KEY_PAGE_DOWN : (mods & MOD_ALT ? BM_KEY_PAGE_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XK_BackSpace:
|
||||
return BM_KEY_BACKSPACE;
|
||||
|
||||
case XK_Delete:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_LINE_DELETE_LEFT : BM_KEY_DELETE);
|
||||
|
||||
case XK_Tab:
|
||||
return (mods & MOD_SHIFT ? BM_KEY_SHIFT_TAB : BM_KEY_TAB);
|
||||
|
||||
case XK_ISO_Left_Tab:
|
||||
return BM_KEY_SHIFT_TAB;
|
||||
|
||||
case XK_Insert:
|
||||
return BM_KEY_SHIFT_RETURN;
|
||||
|
||||
case XK_KP_Enter:
|
||||
case XK_Return:
|
||||
return (mods & MOD_CTRL ? BM_KEY_CONTROL_RETURN : (mods & MOD_SHIFT ? BM_KEY_SHIFT_RETURN : BM_KEY_RETURN));
|
||||
|
||||
case XK_g:
|
||||
if (!(mods & MOD_CTRL)) return BM_KEY_UNICODE;
|
||||
// fall through
|
||||
case XK_c:
|
||||
if (!(mods & MOD_CTRL)) return BM_KEY_UNICODE;
|
||||
// fall through
|
||||
case XK_bracketleft:
|
||||
if (!(mods & MOD_CTRL)) return BM_KEY_UNICODE;
|
||||
// fall through
|
||||
case XK_Escape:
|
||||
return BM_KEY_ESCAPE;
|
||||
|
||||
case XK_p:
|
||||
return (mods & MOD_CTRL ? BM_KEY_UP : BM_KEY_UNICODE);
|
||||
|
||||
case XK_n:
|
||||
return (mods & MOD_CTRL ? BM_KEY_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XK_l:
|
||||
return (mods & MOD_CTRL ? BM_KEY_LEFT : (mods & MOD_ALT ? BM_KEY_DOWN : BM_KEY_UNICODE));
|
||||
|
||||
case XK_f:
|
||||
return (mods & MOD_CTRL ? BM_KEY_RIGHT : BM_KEY_UNICODE);
|
||||
|
||||
case XK_a:
|
||||
return (mods & MOD_CTRL ? BM_KEY_HOME : BM_KEY_UNICODE);
|
||||
|
||||
case XK_e:
|
||||
return (mods & MOD_CTRL ? BM_KEY_END : BM_KEY_UNICODE);
|
||||
|
||||
case XK_h:
|
||||
return (mods & MOD_CTRL ? BM_KEY_BACKSPACE : (mods & MOD_ALT ? BM_KEY_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XK_u:
|
||||
return (mods & MOD_CTRL ? BM_KEY_LINE_DELETE_LEFT : (mods & MOD_ALT ? BM_KEY_PAGE_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XK_k:
|
||||
return (mods & MOD_CTRL ? BM_KEY_LINE_DELETE_RIGHT : (mods & MOD_ALT ? BM_KEY_UP : BM_KEY_UNICODE));
|
||||
|
||||
case XK_w:
|
||||
return (mods & MOD_CTRL ? BM_KEY_WORD_DELETE : BM_KEY_UNICODE);
|
||||
|
||||
case XK_y:
|
||||
return (mods & MOD_CTRL ? BM_KEY_PASTE : BM_KEY_UNICODE);
|
||||
|
||||
case XK_j:
|
||||
return (mods & MOD_ALT ? BM_KEY_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XK_d:
|
||||
return (mods & MOD_ALT ? BM_KEY_PAGE_DOWN : BM_KEY_UNICODE);
|
||||
|
||||
case XK_m:
|
||||
return (mods & MOD_CTRL ? BM_KEY_RETURN : BM_KEY_UNICODE);
|
||||
|
||||
case XK_1:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_1;
|
||||
break;
|
||||
case XK_2:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_2;
|
||||
break;
|
||||
case XK_3:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_3;
|
||||
break;
|
||||
case XK_4:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_4;
|
||||
break;
|
||||
case XK_5:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_5;
|
||||
break;
|
||||
case XK_6:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_6;
|
||||
break;
|
||||
case XK_7:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_7;
|
||||
break;
|
||||
case XK_8:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_8;
|
||||
break;
|
||||
case XK_9:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_9;
|
||||
break;
|
||||
case XK_0:
|
||||
if ((mods & MOD_ALT)) return BM_KEY_CUSTOM_10;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return BM_KEY_UNICODE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_displayed_count(const struct bm_menu *menu)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
assert(x11);
|
||||
return x11->window.displayed;
|
||||
}
|
||||
|
||||
static void
|
||||
set_align(const struct bm_menu *menu, enum bm_align align)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
assert(x11);
|
||||
bm_x11_window_set_align(&x11->window, align);
|
||||
}
|
||||
|
||||
static void
|
||||
set_width(const struct bm_menu *menu, uint32_t margin, float factor)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
assert(x11);
|
||||
bm_x11_window_set_width(&x11->window, margin, factor);
|
||||
}
|
||||
|
||||
static void
|
||||
set_monitor(const struct bm_menu *menu, int32_t monitor)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
assert(x11);
|
||||
bm_x11_window_set_monitor(&x11->window, monitor);
|
||||
}
|
||||
|
||||
static void
|
||||
grab_keyboard(const struct bm_menu *menu, bool grab)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
assert(x11);
|
||||
|
||||
if (grab) {
|
||||
for (uint32_t i = 0; i < 1000; ++i) {
|
||||
if (XGrabKeyboard(x11->display, DefaultRootWindow(x11->display), True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||
return;
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
fprintf(stderr, "x11: cannot grab keyboard\n");
|
||||
} else {
|
||||
XUngrabKeyboard(x11->display, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
destructor(struct bm_menu *menu)
|
||||
{
|
||||
struct x11 *x11 = menu->renderer->internal;
|
||||
|
||||
if (!x11)
|
||||
return;
|
||||
|
||||
bm_x11_window_destroy(&x11->window);
|
||||
|
||||
if (x11->display)
|
||||
XCloseDisplay(x11->display);
|
||||
|
||||
free(x11);
|
||||
menu->renderer->internal = NULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
constructor(struct bm_menu *menu)
|
||||
{
|
||||
if (getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET"))
|
||||
return false;
|
||||
|
||||
struct x11 *x11;
|
||||
if (!(menu->renderer->internal = x11 = calloc(1, sizeof(struct x11))))
|
||||
goto fail;
|
||||
|
||||
if (!(x11->display = XOpenDisplay(NULL)))
|
||||
goto fail;
|
||||
|
||||
if (!bm_x11_window_create(&x11->window, x11->display))
|
||||
goto fail;
|
||||
|
||||
XSetClassHint(x11->window.display, x11->window.drawable, (XClassHint[]){{.res_name = (menu->title ? menu->title : "bemenu"), .res_class = "bemenu"}});
|
||||
|
||||
x11->window.align = menu->align;
|
||||
bm_x11_window_set_monitor(&x11->window, menu->monitor);
|
||||
|
||||
x11->window.notify.render = bm_cairo_paint;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
destructor(menu);
|
||||
return false;
|
||||
}
|
||||
|
||||
BM_PUBLIC extern const char*
|
||||
register_renderer(struct render_api *api)
|
||||
{
|
||||
api->constructor = constructor;
|
||||
api->destructor = destructor;
|
||||
api->get_displayed_count = get_displayed_count;
|
||||
api->poll_key = poll_key;
|
||||
api->render = render;
|
||||
api->set_align = set_align;
|
||||
api->set_width = set_width;
|
||||
api->set_monitor = set_monitor;
|
||||
api->grab_keyboard = grab_keyboard;
|
||||
api->priorty = BM_PRIO_GUI;
|
||||
api->version = BM_PLUGIN_VERSION;
|
||||
return "x11";
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
64
.config/dwl/menu/lib/renderers/x11/x11.h
Normal file
64
.config/dwl/menu/lib/renderers/x11/x11.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
#ifndef _BM_X11_H_
|
||||
#define _BM_X11_H_
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#include "renderers/cairo_renderer.h"
|
||||
|
||||
enum mod_bit {
|
||||
MOD_SHIFT = 1<<0,
|
||||
MOD_CTRL = 1<<1,
|
||||
MOD_ALT = 1<<2,
|
||||
};
|
||||
|
||||
struct buffer {
|
||||
struct cairo cairo;
|
||||
uint32_t width, height;
|
||||
bool created;
|
||||
};
|
||||
|
||||
struct window {
|
||||
Display *display;
|
||||
int32_t screen;
|
||||
Drawable drawable;
|
||||
XIM xim;
|
||||
XIC xic;
|
||||
Visual *visual;
|
||||
|
||||
KeySym keysym;
|
||||
uint32_t mods;
|
||||
|
||||
struct buffer buffer;
|
||||
uint32_t x, y, width, height, max_height;
|
||||
uint32_t orig_width, orig_x;
|
||||
uint32_t hmargin_size;
|
||||
float width_factor;
|
||||
uint32_t displayed;
|
||||
|
||||
int32_t monitor;
|
||||
enum bm_align align;
|
||||
|
||||
struct {
|
||||
void (*render)(struct cairo *cairo, uint32_t width, uint32_t max_height, const struct bm_menu *menu, struct cairo_paint_result *result);
|
||||
} notify;
|
||||
};
|
||||
|
||||
struct x11 {
|
||||
Display *display;
|
||||
struct window window;
|
||||
};
|
||||
|
||||
void bm_x11_window_render(struct window *window, const struct bm_menu *menu);
|
||||
void bm_x11_window_key_press(struct window *window, XKeyEvent *ev);
|
||||
void bm_x11_window_set_monitor(struct window *window, int32_t monitor);
|
||||
void bm_x11_window_set_align(struct window *window, enum bm_align align);
|
||||
void bm_x11_window_set_width(struct window *window, uint32_t margin, float factor);
|
||||
bool bm_x11_window_create(struct window *window, Display *display);
|
||||
void bm_x11_window_destroy(struct window *window);
|
||||
|
||||
#endif /* _BM_WAYLAND_H_ */
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
857
.config/dwl/menu/lib/renderers/x11/xkb_unicode.c
Normal file
857
.config/dwl/menu/lib/renderers/x11/xkb_unicode.c
Normal file
|
@ -0,0 +1,857 @@
|
|||
/**
|
||||
* From GLFW
|
||||
*/
|
||||
|
||||
/*
|
||||
* Marcus: This code was originally written by Markus G. Kuhn.
|
||||
* I have made some slight changes (trimmed it down a bit from >60 KB to
|
||||
* 20 KB), but the functionality is the same.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This module converts keysym values into the corresponding ISO 10646
|
||||
* (UCS, Unicode) values.
|
||||
*
|
||||
* The array keysymtab[] contains pairs of X11 keysym values for graphical
|
||||
* characters and the corresponding Unicode value. The function
|
||||
* _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary
|
||||
* search, therefore keysymtab[] must remain SORTED by keysym value.
|
||||
*
|
||||
* We allow to represent any UCS character in the range U-00000000 to
|
||||
* U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
|
||||
* This admittedly does not cover the entire 31-bit space of UCS, but
|
||||
* it does cover all of the characters up to U-10FFFF, which can be
|
||||
* represented by UTF-16, and more, and it is very unlikely that higher
|
||||
* UCS codes will ever be assigned by ISO. So to get Unicode character
|
||||
* U+ABCD you can directly use keysym 0x0100abcd.
|
||||
*
|
||||
* Original author: Markus G. Kuhn <mkuhn@acm.org>, University of
|
||||
* Cambridge, April 2001
|
||||
*
|
||||
* Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
|
||||
* an initial draft of the mapping table.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** KeySym to Unicode mapping table ****
|
||||
//************************************************************************
|
||||
|
||||
#include "xkb_unicode.h"
|
||||
#include "x11.h"
|
||||
|
||||
static const struct codepair {
|
||||
unsigned short keysym;
|
||||
unsigned short ucs;
|
||||
} keysymtab[] = {
|
||||
{ 0x01a1, 0x0104 },
|
||||
{ 0x01a2, 0x02d8 },
|
||||
{ 0x01a3, 0x0141 },
|
||||
{ 0x01a5, 0x013d },
|
||||
{ 0x01a6, 0x015a },
|
||||
{ 0x01a9, 0x0160 },
|
||||
{ 0x01aa, 0x015e },
|
||||
{ 0x01ab, 0x0164 },
|
||||
{ 0x01ac, 0x0179 },
|
||||
{ 0x01ae, 0x017d },
|
||||
{ 0x01af, 0x017b },
|
||||
{ 0x01b1, 0x0105 },
|
||||
{ 0x01b2, 0x02db },
|
||||
{ 0x01b3, 0x0142 },
|
||||
{ 0x01b5, 0x013e },
|
||||
{ 0x01b6, 0x015b },
|
||||
{ 0x01b7, 0x02c7 },
|
||||
{ 0x01b9, 0x0161 },
|
||||
{ 0x01ba, 0x015f },
|
||||
{ 0x01bb, 0x0165 },
|
||||
{ 0x01bc, 0x017a },
|
||||
{ 0x01bd, 0x02dd },
|
||||
{ 0x01be, 0x017e },
|
||||
{ 0x01bf, 0x017c },
|
||||
{ 0x01c0, 0x0154 },
|
||||
{ 0x01c3, 0x0102 },
|
||||
{ 0x01c5, 0x0139 },
|
||||
{ 0x01c6, 0x0106 },
|
||||
{ 0x01c8, 0x010c },
|
||||
{ 0x01ca, 0x0118 },
|
||||
{ 0x01cc, 0x011a },
|
||||
{ 0x01cf, 0x010e },
|
||||
{ 0x01d0, 0x0110 },
|
||||
{ 0x01d1, 0x0143 },
|
||||
{ 0x01d2, 0x0147 },
|
||||
{ 0x01d5, 0x0150 },
|
||||
{ 0x01d8, 0x0158 },
|
||||
{ 0x01d9, 0x016e },
|
||||
{ 0x01db, 0x0170 },
|
||||
{ 0x01de, 0x0162 },
|
||||
{ 0x01e0, 0x0155 },
|
||||
{ 0x01e3, 0x0103 },
|
||||
{ 0x01e5, 0x013a },
|
||||
{ 0x01e6, 0x0107 },
|
||||
{ 0x01e8, 0x010d },
|
||||
{ 0x01ea, 0x0119 },
|
||||
{ 0x01ec, 0x011b },
|
||||
{ 0x01ef, 0x010f },
|
||||
{ 0x01f0, 0x0111 },
|
||||
{ 0x01f1, 0x0144 },
|
||||
{ 0x01f2, 0x0148 },
|
||||
{ 0x01f5, 0x0151 },
|
||||
{ 0x01f8, 0x0159 },
|
||||
{ 0x01f9, 0x016f },
|
||||
{ 0x01fb, 0x0171 },
|
||||
{ 0x01fe, 0x0163 },
|
||||
{ 0x01ff, 0x02d9 },
|
||||
{ 0x02a1, 0x0126 },
|
||||
{ 0x02a6, 0x0124 },
|
||||
{ 0x02a9, 0x0130 },
|
||||
{ 0x02ab, 0x011e },
|
||||
{ 0x02ac, 0x0134 },
|
||||
{ 0x02b1, 0x0127 },
|
||||
{ 0x02b6, 0x0125 },
|
||||
{ 0x02b9, 0x0131 },
|
||||
{ 0x02bb, 0x011f },
|
||||
{ 0x02bc, 0x0135 },
|
||||
{ 0x02c5, 0x010a },
|
||||
{ 0x02c6, 0x0108 },
|
||||
{ 0x02d5, 0x0120 },
|
||||
{ 0x02d8, 0x011c },
|
||||
{ 0x02dd, 0x016c },
|
||||
{ 0x02de, 0x015c },
|
||||
{ 0x02e5, 0x010b },
|
||||
{ 0x02e6, 0x0109 },
|
||||
{ 0x02f5, 0x0121 },
|
||||
{ 0x02f8, 0x011d },
|
||||
{ 0x02fd, 0x016d },
|
||||
{ 0x02fe, 0x015d },
|
||||
{ 0x03a2, 0x0138 },
|
||||
{ 0x03a3, 0x0156 },
|
||||
{ 0x03a5, 0x0128 },
|
||||
{ 0x03a6, 0x013b },
|
||||
{ 0x03aa, 0x0112 },
|
||||
{ 0x03ab, 0x0122 },
|
||||
{ 0x03ac, 0x0166 },
|
||||
{ 0x03b3, 0x0157 },
|
||||
{ 0x03b5, 0x0129 },
|
||||
{ 0x03b6, 0x013c },
|
||||
{ 0x03ba, 0x0113 },
|
||||
{ 0x03bb, 0x0123 },
|
||||
{ 0x03bc, 0x0167 },
|
||||
{ 0x03bd, 0x014a },
|
||||
{ 0x03bf, 0x014b },
|
||||
{ 0x03c0, 0x0100 },
|
||||
{ 0x03c7, 0x012e },
|
||||
{ 0x03cc, 0x0116 },
|
||||
{ 0x03cf, 0x012a },
|
||||
{ 0x03d1, 0x0145 },
|
||||
{ 0x03d2, 0x014c },
|
||||
{ 0x03d3, 0x0136 },
|
||||
{ 0x03d9, 0x0172 },
|
||||
{ 0x03dd, 0x0168 },
|
||||
{ 0x03de, 0x016a },
|
||||
{ 0x03e0, 0x0101 },
|
||||
{ 0x03e7, 0x012f },
|
||||
{ 0x03ec, 0x0117 },
|
||||
{ 0x03ef, 0x012b },
|
||||
{ 0x03f1, 0x0146 },
|
||||
{ 0x03f2, 0x014d },
|
||||
{ 0x03f3, 0x0137 },
|
||||
{ 0x03f9, 0x0173 },
|
||||
{ 0x03fd, 0x0169 },
|
||||
{ 0x03fe, 0x016b },
|
||||
{ 0x047e, 0x203e },
|
||||
{ 0x04a1, 0x3002 },
|
||||
{ 0x04a2, 0x300c },
|
||||
{ 0x04a3, 0x300d },
|
||||
{ 0x04a4, 0x3001 },
|
||||
{ 0x04a5, 0x30fb },
|
||||
{ 0x04a6, 0x30f2 },
|
||||
{ 0x04a7, 0x30a1 },
|
||||
{ 0x04a8, 0x30a3 },
|
||||
{ 0x04a9, 0x30a5 },
|
||||
{ 0x04aa, 0x30a7 },
|
||||
{ 0x04ab, 0x30a9 },
|
||||
{ 0x04ac, 0x30e3 },
|
||||
{ 0x04ad, 0x30e5 },
|
||||
{ 0x04ae, 0x30e7 },
|
||||
{ 0x04af, 0x30c3 },
|
||||
{ 0x04b0, 0x30fc },
|
||||
{ 0x04b1, 0x30a2 },
|
||||
{ 0x04b2, 0x30a4 },
|
||||
{ 0x04b3, 0x30a6 },
|
||||
{ 0x04b4, 0x30a8 },
|
||||
{ 0x04b5, 0x30aa },
|
||||
{ 0x04b6, 0x30ab },
|
||||
{ 0x04b7, 0x30ad },
|
||||
{ 0x04b8, 0x30af },
|
||||
{ 0x04b9, 0x30b1 },
|
||||
{ 0x04ba, 0x30b3 },
|
||||
{ 0x04bb, 0x30b5 },
|
||||
{ 0x04bc, 0x30b7 },
|
||||
{ 0x04bd, 0x30b9 },
|
||||
{ 0x04be, 0x30bb },
|
||||
{ 0x04bf, 0x30bd },
|
||||
{ 0x04c0, 0x30bf },
|
||||
{ 0x04c1, 0x30c1 },
|
||||
{ 0x04c2, 0x30c4 },
|
||||
{ 0x04c3, 0x30c6 },
|
||||
{ 0x04c4, 0x30c8 },
|
||||
{ 0x04c5, 0x30ca },
|
||||
{ 0x04c6, 0x30cb },
|
||||
{ 0x04c7, 0x30cc },
|
||||
{ 0x04c8, 0x30cd },
|
||||
{ 0x04c9, 0x30ce },
|
||||
{ 0x04ca, 0x30cf },
|
||||
{ 0x04cb, 0x30d2 },
|
||||
{ 0x04cc, 0x30d5 },
|
||||
{ 0x04cd, 0x30d8 },
|
||||
{ 0x04ce, 0x30db },
|
||||
{ 0x04cf, 0x30de },
|
||||
{ 0x04d0, 0x30df },
|
||||
{ 0x04d1, 0x30e0 },
|
||||
{ 0x04d2, 0x30e1 },
|
||||
{ 0x04d3, 0x30e2 },
|
||||
{ 0x04d4, 0x30e4 },
|
||||
{ 0x04d5, 0x30e6 },
|
||||
{ 0x04d6, 0x30e8 },
|
||||
{ 0x04d7, 0x30e9 },
|
||||
{ 0x04d8, 0x30ea },
|
||||
{ 0x04d9, 0x30eb },
|
||||
{ 0x04da, 0x30ec },
|
||||
{ 0x04db, 0x30ed },
|
||||
{ 0x04dc, 0x30ef },
|
||||
{ 0x04dd, 0x30f3 },
|
||||
{ 0x04de, 0x309b },
|
||||
{ 0x04df, 0x309c },
|
||||
{ 0x05ac, 0x060c },
|
||||
{ 0x05bb, 0x061b },
|
||||
{ 0x05bf, 0x061f },
|
||||
{ 0x05c1, 0x0621 },
|
||||
{ 0x05c2, 0x0622 },
|
||||
{ 0x05c3, 0x0623 },
|
||||
{ 0x05c4, 0x0624 },
|
||||
{ 0x05c5, 0x0625 },
|
||||
{ 0x05c6, 0x0626 },
|
||||
{ 0x05c7, 0x0627 },
|
||||
{ 0x05c8, 0x0628 },
|
||||
{ 0x05c9, 0x0629 },
|
||||
{ 0x05ca, 0x062a },
|
||||
{ 0x05cb, 0x062b },
|
||||
{ 0x05cc, 0x062c },
|
||||
{ 0x05cd, 0x062d },
|
||||
{ 0x05ce, 0x062e },
|
||||
{ 0x05cf, 0x062f },
|
||||
{ 0x05d0, 0x0630 },
|
||||
{ 0x05d1, 0x0631 },
|
||||
{ 0x05d2, 0x0632 },
|
||||
{ 0x05d3, 0x0633 },
|
||||
{ 0x05d4, 0x0634 },
|
||||
{ 0x05d5, 0x0635 },
|
||||
{ 0x05d6, 0x0636 },
|
||||
{ 0x05d7, 0x0637 },
|
||||
{ 0x05d8, 0x0638 },
|
||||
{ 0x05d9, 0x0639 },
|
||||
{ 0x05da, 0x063a },
|
||||
{ 0x05e0, 0x0640 },
|
||||
{ 0x05e1, 0x0641 },
|
||||
{ 0x05e2, 0x0642 },
|
||||
{ 0x05e3, 0x0643 },
|
||||
{ 0x05e4, 0x0644 },
|
||||
{ 0x05e5, 0x0645 },
|
||||
{ 0x05e6, 0x0646 },
|
||||
{ 0x05e7, 0x0647 },
|
||||
{ 0x05e8, 0x0648 },
|
||||
{ 0x05e9, 0x0649 },
|
||||
{ 0x05ea, 0x064a },
|
||||
{ 0x05eb, 0x064b },
|
||||
{ 0x05ec, 0x064c },
|
||||
{ 0x05ed, 0x064d },
|
||||
{ 0x05ee, 0x064e },
|
||||
{ 0x05ef, 0x064f },
|
||||
{ 0x05f0, 0x0650 },
|
||||
{ 0x05f1, 0x0651 },
|
||||
{ 0x05f2, 0x0652 },
|
||||
{ 0x06a1, 0x0452 },
|
||||
{ 0x06a2, 0x0453 },
|
||||
{ 0x06a3, 0x0451 },
|
||||
{ 0x06a4, 0x0454 },
|
||||
{ 0x06a5, 0x0455 },
|
||||
{ 0x06a6, 0x0456 },
|
||||
{ 0x06a7, 0x0457 },
|
||||
{ 0x06a8, 0x0458 },
|
||||
{ 0x06a9, 0x0459 },
|
||||
{ 0x06aa, 0x045a },
|
||||
{ 0x06ab, 0x045b },
|
||||
{ 0x06ac, 0x045c },
|
||||
{ 0x06ae, 0x045e },
|
||||
{ 0x06af, 0x045f },
|
||||
{ 0x06b0, 0x2116 },
|
||||
{ 0x06b1, 0x0402 },
|
||||
{ 0x06b2, 0x0403 },
|
||||
{ 0x06b3, 0x0401 },
|
||||
{ 0x06b4, 0x0404 },
|
||||
{ 0x06b5, 0x0405 },
|
||||
{ 0x06b6, 0x0406 },
|
||||
{ 0x06b7, 0x0407 },
|
||||
{ 0x06b8, 0x0408 },
|
||||
{ 0x06b9, 0x0409 },
|
||||
{ 0x06ba, 0x040a },
|
||||
{ 0x06bb, 0x040b },
|
||||
{ 0x06bc, 0x040c },
|
||||
{ 0x06be, 0x040e },
|
||||
{ 0x06bf, 0x040f },
|
||||
{ 0x06c0, 0x044e },
|
||||
{ 0x06c1, 0x0430 },
|
||||
{ 0x06c2, 0x0431 },
|
||||
{ 0x06c3, 0x0446 },
|
||||
{ 0x06c4, 0x0434 },
|
||||
{ 0x06c5, 0x0435 },
|
||||
{ 0x06c6, 0x0444 },
|
||||
{ 0x06c7, 0x0433 },
|
||||
{ 0x06c8, 0x0445 },
|
||||
{ 0x06c9, 0x0438 },
|
||||
{ 0x06ca, 0x0439 },
|
||||
{ 0x06cb, 0x043a },
|
||||
{ 0x06cc, 0x043b },
|
||||
{ 0x06cd, 0x043c },
|
||||
{ 0x06ce, 0x043d },
|
||||
{ 0x06cf, 0x043e },
|
||||
{ 0x06d0, 0x043f },
|
||||
{ 0x06d1, 0x044f },
|
||||
{ 0x06d2, 0x0440 },
|
||||
{ 0x06d3, 0x0441 },
|
||||
{ 0x06d4, 0x0442 },
|
||||
{ 0x06d5, 0x0443 },
|
||||
{ 0x06d6, 0x0436 },
|
||||
{ 0x06d7, 0x0432 },
|
||||
{ 0x06d8, 0x044c },
|
||||
{ 0x06d9, 0x044b },
|
||||
{ 0x06da, 0x0437 },
|
||||
{ 0x06db, 0x0448 },
|
||||
{ 0x06dc, 0x044d },
|
||||
{ 0x06dd, 0x0449 },
|
||||
{ 0x06de, 0x0447 },
|
||||
{ 0x06df, 0x044a },
|
||||
{ 0x06e0, 0x042e },
|
||||
{ 0x06e1, 0x0410 },
|
||||
{ 0x06e2, 0x0411 },
|
||||
{ 0x06e3, 0x0426 },
|
||||
{ 0x06e4, 0x0414 },
|
||||
{ 0x06e5, 0x0415 },
|
||||
{ 0x06e6, 0x0424 },
|
||||
{ 0x06e7, 0x0413 },
|
||||
{ 0x06e8, 0x0425 },
|
||||
{ 0x06e9, 0x0418 },
|
||||
{ 0x06ea, 0x0419 },
|
||||
{ 0x06eb, 0x041a },
|
||||
{ 0x06ec, 0x041b },
|
||||
{ 0x06ed, 0x041c },
|
||||
{ 0x06ee, 0x041d },
|
||||
{ 0x06ef, 0x041e },
|
||||
{ 0x06f0, 0x041f },
|
||||
{ 0x06f1, 0x042f },
|
||||
{ 0x06f2, 0x0420 },
|
||||
{ 0x06f3, 0x0421 },
|
||||
{ 0x06f4, 0x0422 },
|
||||
{ 0x06f5, 0x0423 },
|
||||
{ 0x06f6, 0x0416 },
|
||||
{ 0x06f7, 0x0412 },
|
||||
{ 0x06f8, 0x042c },
|
||||
{ 0x06f9, 0x042b },
|
||||
{ 0x06fa, 0x0417 },
|
||||
{ 0x06fb, 0x0428 },
|
||||
{ 0x06fc, 0x042d },
|
||||
{ 0x06fd, 0x0429 },
|
||||
{ 0x06fe, 0x0427 },
|
||||
{ 0x06ff, 0x042a },
|
||||
{ 0x07a1, 0x0386 },
|
||||
{ 0x07a2, 0x0388 },
|
||||
{ 0x07a3, 0x0389 },
|
||||
{ 0x07a4, 0x038a },
|
||||
{ 0x07a5, 0x03aa },
|
||||
{ 0x07a7, 0x038c },
|
||||
{ 0x07a8, 0x038e },
|
||||
{ 0x07a9, 0x03ab },
|
||||
{ 0x07ab, 0x038f },
|
||||
{ 0x07ae, 0x0385 },
|
||||
{ 0x07af, 0x2015 },
|
||||
{ 0x07b1, 0x03ac },
|
||||
{ 0x07b2, 0x03ad },
|
||||
{ 0x07b3, 0x03ae },
|
||||
{ 0x07b4, 0x03af },
|
||||
{ 0x07b5, 0x03ca },
|
||||
{ 0x07b6, 0x0390 },
|
||||
{ 0x07b7, 0x03cc },
|
||||
{ 0x07b8, 0x03cd },
|
||||
{ 0x07b9, 0x03cb },
|
||||
{ 0x07ba, 0x03b0 },
|
||||
{ 0x07bb, 0x03ce },
|
||||
{ 0x07c1, 0x0391 },
|
||||
{ 0x07c2, 0x0392 },
|
||||
{ 0x07c3, 0x0393 },
|
||||
{ 0x07c4, 0x0394 },
|
||||
{ 0x07c5, 0x0395 },
|
||||
{ 0x07c6, 0x0396 },
|
||||
{ 0x07c7, 0x0397 },
|
||||
{ 0x07c8, 0x0398 },
|
||||
{ 0x07c9, 0x0399 },
|
||||
{ 0x07ca, 0x039a },
|
||||
{ 0x07cb, 0x039b },
|
||||
{ 0x07cc, 0x039c },
|
||||
{ 0x07cd, 0x039d },
|
||||
{ 0x07ce, 0x039e },
|
||||
{ 0x07cf, 0x039f },
|
||||
{ 0x07d0, 0x03a0 },
|
||||
{ 0x07d1, 0x03a1 },
|
||||
{ 0x07d2, 0x03a3 },
|
||||
{ 0x07d4, 0x03a4 },
|
||||
{ 0x07d5, 0x03a5 },
|
||||
{ 0x07d6, 0x03a6 },
|
||||
{ 0x07d7, 0x03a7 },
|
||||
{ 0x07d8, 0x03a8 },
|
||||
{ 0x07d9, 0x03a9 },
|
||||
{ 0x07e1, 0x03b1 },
|
||||
{ 0x07e2, 0x03b2 },
|
||||
{ 0x07e3, 0x03b3 },
|
||||
{ 0x07e4, 0x03b4 },
|
||||
{ 0x07e5, 0x03b5 },
|
||||
{ 0x07e6, 0x03b6 },
|
||||
{ 0x07e7, 0x03b7 },
|
||||
{ 0x07e8, 0x03b8 },
|
||||
{ 0x07e9, 0x03b9 },
|
||||
{ 0x07ea, 0x03ba },
|
||||
{ 0x07eb, 0x03bb },
|
||||
{ 0x07ec, 0x03bc },
|
||||
{ 0x07ed, 0x03bd },
|
||||
{ 0x07ee, 0x03be },
|
||||
{ 0x07ef, 0x03bf },
|
||||
{ 0x07f0, 0x03c0 },
|
||||
{ 0x07f1, 0x03c1 },
|
||||
{ 0x07f2, 0x03c3 },
|
||||
{ 0x07f3, 0x03c2 },
|
||||
{ 0x07f4, 0x03c4 },
|
||||
{ 0x07f5, 0x03c5 },
|
||||
{ 0x07f6, 0x03c6 },
|
||||
{ 0x07f7, 0x03c7 },
|
||||
{ 0x07f8, 0x03c8 },
|
||||
{ 0x07f9, 0x03c9 },
|
||||
{ 0x08a1, 0x23b7 },
|
||||
{ 0x08a2, 0x250c },
|
||||
{ 0x08a3, 0x2500 },
|
||||
{ 0x08a4, 0x2320 },
|
||||
{ 0x08a5, 0x2321 },
|
||||
{ 0x08a6, 0x2502 },
|
||||
{ 0x08a7, 0x23a1 },
|
||||
{ 0x08a8, 0x23a3 },
|
||||
{ 0x08a9, 0x23a4 },
|
||||
{ 0x08aa, 0x23a6 },
|
||||
{ 0x08ab, 0x239b },
|
||||
{ 0x08ac, 0x239d },
|
||||
{ 0x08ad, 0x239e },
|
||||
{ 0x08ae, 0x23a0 },
|
||||
{ 0x08af, 0x23a8 },
|
||||
{ 0x08b0, 0x23ac },
|
||||
{ 0x08bc, 0x2264 },
|
||||
{ 0x08bd, 0x2260 },
|
||||
{ 0x08be, 0x2265 },
|
||||
{ 0x08bf, 0x222b },
|
||||
{ 0x08c0, 0x2234 },
|
||||
{ 0x08c1, 0x221d },
|
||||
{ 0x08c2, 0x221e },
|
||||
{ 0x08c5, 0x2207 },
|
||||
{ 0x08c8, 0x223c },
|
||||
{ 0x08c9, 0x2243 },
|
||||
{ 0x08cd, 0x21d4 },
|
||||
{ 0x08ce, 0x21d2 },
|
||||
{ 0x08cf, 0x2261 },
|
||||
{ 0x08d6, 0x221a },
|
||||
{ 0x08da, 0x2282 },
|
||||
{ 0x08db, 0x2283 },
|
||||
{ 0x08dc, 0x2229 },
|
||||
{ 0x08dd, 0x222a },
|
||||
{ 0x08de, 0x2227 },
|
||||
{ 0x08df, 0x2228 },
|
||||
{ 0x08ef, 0x2202 },
|
||||
{ 0x08f6, 0x0192 },
|
||||
{ 0x08fb, 0x2190 },
|
||||
{ 0x08fc, 0x2191 },
|
||||
{ 0x08fd, 0x2192 },
|
||||
{ 0x08fe, 0x2193 },
|
||||
{ 0x09e0, 0x25c6 },
|
||||
{ 0x09e1, 0x2592 },
|
||||
{ 0x09e2, 0x2409 },
|
||||
{ 0x09e3, 0x240c },
|
||||
{ 0x09e4, 0x240d },
|
||||
{ 0x09e5, 0x240a },
|
||||
{ 0x09e8, 0x2424 },
|
||||
{ 0x09e9, 0x240b },
|
||||
{ 0x09ea, 0x2518 },
|
||||
{ 0x09eb, 0x2510 },
|
||||
{ 0x09ec, 0x250c },
|
||||
{ 0x09ed, 0x2514 },
|
||||
{ 0x09ee, 0x253c },
|
||||
{ 0x09ef, 0x23ba },
|
||||
{ 0x09f0, 0x23bb },
|
||||
{ 0x09f1, 0x2500 },
|
||||
{ 0x09f2, 0x23bc },
|
||||
{ 0x09f3, 0x23bd },
|
||||
{ 0x09f4, 0x251c },
|
||||
{ 0x09f5, 0x2524 },
|
||||
{ 0x09f6, 0x2534 },
|
||||
{ 0x09f7, 0x252c },
|
||||
{ 0x09f8, 0x2502 },
|
||||
{ 0x0aa1, 0x2003 },
|
||||
{ 0x0aa2, 0x2002 },
|
||||
{ 0x0aa3, 0x2004 },
|
||||
{ 0x0aa4, 0x2005 },
|
||||
{ 0x0aa5, 0x2007 },
|
||||
{ 0x0aa6, 0x2008 },
|
||||
{ 0x0aa7, 0x2009 },
|
||||
{ 0x0aa8, 0x200a },
|
||||
{ 0x0aa9, 0x2014 },
|
||||
{ 0x0aaa, 0x2013 },
|
||||
{ 0x0aae, 0x2026 },
|
||||
{ 0x0aaf, 0x2025 },
|
||||
{ 0x0ab0, 0x2153 },
|
||||
{ 0x0ab1, 0x2154 },
|
||||
{ 0x0ab2, 0x2155 },
|
||||
{ 0x0ab3, 0x2156 },
|
||||
{ 0x0ab4, 0x2157 },
|
||||
{ 0x0ab5, 0x2158 },
|
||||
{ 0x0ab6, 0x2159 },
|
||||
{ 0x0ab7, 0x215a },
|
||||
{ 0x0ab8, 0x2105 },
|
||||
{ 0x0abb, 0x2012 },
|
||||
{ 0x0abc, 0x2329 },
|
||||
{ 0x0abe, 0x232a },
|
||||
{ 0x0ac3, 0x215b },
|
||||
{ 0x0ac4, 0x215c },
|
||||
{ 0x0ac5, 0x215d },
|
||||
{ 0x0ac6, 0x215e },
|
||||
{ 0x0ac9, 0x2122 },
|
||||
{ 0x0aca, 0x2613 },
|
||||
{ 0x0acc, 0x25c1 },
|
||||
{ 0x0acd, 0x25b7 },
|
||||
{ 0x0ace, 0x25cb },
|
||||
{ 0x0acf, 0x25af },
|
||||
{ 0x0ad0, 0x2018 },
|
||||
{ 0x0ad1, 0x2019 },
|
||||
{ 0x0ad2, 0x201c },
|
||||
{ 0x0ad3, 0x201d },
|
||||
{ 0x0ad4, 0x211e },
|
||||
{ 0x0ad6, 0x2032 },
|
||||
{ 0x0ad7, 0x2033 },
|
||||
{ 0x0ad9, 0x271d },
|
||||
{ 0x0adb, 0x25ac },
|
||||
{ 0x0adc, 0x25c0 },
|
||||
{ 0x0add, 0x25b6 },
|
||||
{ 0x0ade, 0x25cf },
|
||||
{ 0x0adf, 0x25ae },
|
||||
{ 0x0ae0, 0x25e6 },
|
||||
{ 0x0ae1, 0x25ab },
|
||||
{ 0x0ae2, 0x25ad },
|
||||
{ 0x0ae3, 0x25b3 },
|
||||
{ 0x0ae4, 0x25bd },
|
||||
{ 0x0ae5, 0x2606 },
|
||||
{ 0x0ae6, 0x2022 },
|
||||
{ 0x0ae7, 0x25aa },
|
||||
{ 0x0ae8, 0x25b2 },
|
||||
{ 0x0ae9, 0x25bc },
|
||||
{ 0x0aea, 0x261c },
|
||||
{ 0x0aeb, 0x261e },
|
||||
{ 0x0aec, 0x2663 },
|
||||
{ 0x0aed, 0x2666 },
|
||||
{ 0x0aee, 0x2665 },
|
||||
{ 0x0af0, 0x2720 },
|
||||
{ 0x0af1, 0x2020 },
|
||||
{ 0x0af2, 0x2021 },
|
||||
{ 0x0af3, 0x2713 },
|
||||
{ 0x0af4, 0x2717 },
|
||||
{ 0x0af5, 0x266f },
|
||||
{ 0x0af6, 0x266d },
|
||||
{ 0x0af7, 0x2642 },
|
||||
{ 0x0af8, 0x2640 },
|
||||
{ 0x0af9, 0x260e },
|
||||
{ 0x0afa, 0x2315 },
|
||||
{ 0x0afb, 0x2117 },
|
||||
{ 0x0afc, 0x2038 },
|
||||
{ 0x0afd, 0x201a },
|
||||
{ 0x0afe, 0x201e },
|
||||
{ 0x0ba3, 0x003c },
|
||||
{ 0x0ba6, 0x003e },
|
||||
{ 0x0ba8, 0x2228 },
|
||||
{ 0x0ba9, 0x2227 },
|
||||
{ 0x0bc0, 0x00af },
|
||||
{ 0x0bc2, 0x22a5 },
|
||||
{ 0x0bc3, 0x2229 },
|
||||
{ 0x0bc4, 0x230a },
|
||||
{ 0x0bc6, 0x005f },
|
||||
{ 0x0bca, 0x2218 },
|
||||
{ 0x0bcc, 0x2395 },
|
||||
{ 0x0bce, 0x22a4 },
|
||||
{ 0x0bcf, 0x25cb },
|
||||
{ 0x0bd3, 0x2308 },
|
||||
{ 0x0bd6, 0x222a },
|
||||
{ 0x0bd8, 0x2283 },
|
||||
{ 0x0bda, 0x2282 },
|
||||
{ 0x0bdc, 0x22a2 },
|
||||
{ 0x0bfc, 0x22a3 },
|
||||
{ 0x0cdf, 0x2017 },
|
||||
{ 0x0ce0, 0x05d0 },
|
||||
{ 0x0ce1, 0x05d1 },
|
||||
{ 0x0ce2, 0x05d2 },
|
||||
{ 0x0ce3, 0x05d3 },
|
||||
{ 0x0ce4, 0x05d4 },
|
||||
{ 0x0ce5, 0x05d5 },
|
||||
{ 0x0ce6, 0x05d6 },
|
||||
{ 0x0ce7, 0x05d7 },
|
||||
{ 0x0ce8, 0x05d8 },
|
||||
{ 0x0ce9, 0x05d9 },
|
||||
{ 0x0cea, 0x05da },
|
||||
{ 0x0ceb, 0x05db },
|
||||
{ 0x0cec, 0x05dc },
|
||||
{ 0x0ced, 0x05dd },
|
||||
{ 0x0cee, 0x05de },
|
||||
{ 0x0cef, 0x05df },
|
||||
{ 0x0cf0, 0x05e0 },
|
||||
{ 0x0cf1, 0x05e1 },
|
||||
{ 0x0cf2, 0x05e2 },
|
||||
{ 0x0cf3, 0x05e3 },
|
||||
{ 0x0cf4, 0x05e4 },
|
||||
{ 0x0cf5, 0x05e5 },
|
||||
{ 0x0cf6, 0x05e6 },
|
||||
{ 0x0cf7, 0x05e7 },
|
||||
{ 0x0cf8, 0x05e8 },
|
||||
{ 0x0cf9, 0x05e9 },
|
||||
{ 0x0cfa, 0x05ea },
|
||||
{ 0x0da1, 0x0e01 },
|
||||
{ 0x0da2, 0x0e02 },
|
||||
{ 0x0da3, 0x0e03 },
|
||||
{ 0x0da4, 0x0e04 },
|
||||
{ 0x0da5, 0x0e05 },
|
||||
{ 0x0da6, 0x0e06 },
|
||||
{ 0x0da7, 0x0e07 },
|
||||
{ 0x0da8, 0x0e08 },
|
||||
{ 0x0da9, 0x0e09 },
|
||||
{ 0x0daa, 0x0e0a },
|
||||
{ 0x0dab, 0x0e0b },
|
||||
{ 0x0dac, 0x0e0c },
|
||||
{ 0x0dad, 0x0e0d },
|
||||
{ 0x0dae, 0x0e0e },
|
||||
{ 0x0daf, 0x0e0f },
|
||||
{ 0x0db0, 0x0e10 },
|
||||
{ 0x0db1, 0x0e11 },
|
||||
{ 0x0db2, 0x0e12 },
|
||||
{ 0x0db3, 0x0e13 },
|
||||
{ 0x0db4, 0x0e14 },
|
||||
{ 0x0db5, 0x0e15 },
|
||||
{ 0x0db6, 0x0e16 },
|
||||
{ 0x0db7, 0x0e17 },
|
||||
{ 0x0db8, 0x0e18 },
|
||||
{ 0x0db9, 0x0e19 },
|
||||
{ 0x0dba, 0x0e1a },
|
||||
{ 0x0dbb, 0x0e1b },
|
||||
{ 0x0dbc, 0x0e1c },
|
||||
{ 0x0dbd, 0x0e1d },
|
||||
{ 0x0dbe, 0x0e1e },
|
||||
{ 0x0dbf, 0x0e1f },
|
||||
{ 0x0dc0, 0x0e20 },
|
||||
{ 0x0dc1, 0x0e21 },
|
||||
{ 0x0dc2, 0x0e22 },
|
||||
{ 0x0dc3, 0x0e23 },
|
||||
{ 0x0dc4, 0x0e24 },
|
||||
{ 0x0dc5, 0x0e25 },
|
||||
{ 0x0dc6, 0x0e26 },
|
||||
{ 0x0dc7, 0x0e27 },
|
||||
{ 0x0dc8, 0x0e28 },
|
||||
{ 0x0dc9, 0x0e29 },
|
||||
{ 0x0dca, 0x0e2a },
|
||||
{ 0x0dcb, 0x0e2b },
|
||||
{ 0x0dcc, 0x0e2c },
|
||||
{ 0x0dcd, 0x0e2d },
|
||||
{ 0x0dce, 0x0e2e },
|
||||
{ 0x0dcf, 0x0e2f },
|
||||
{ 0x0dd0, 0x0e30 },
|
||||
{ 0x0dd1, 0x0e31 },
|
||||
{ 0x0dd2, 0x0e32 },
|
||||
{ 0x0dd3, 0x0e33 },
|
||||
{ 0x0dd4, 0x0e34 },
|
||||
{ 0x0dd5, 0x0e35 },
|
||||
{ 0x0dd6, 0x0e36 },
|
||||
{ 0x0dd7, 0x0e37 },
|
||||
{ 0x0dd8, 0x0e38 },
|
||||
{ 0x0dd9, 0x0e39 },
|
||||
{ 0x0dda, 0x0e3a },
|
||||
{ 0x0ddf, 0x0e3f },
|
||||
{ 0x0de0, 0x0e40 },
|
||||
{ 0x0de1, 0x0e41 },
|
||||
{ 0x0de2, 0x0e42 },
|
||||
{ 0x0de3, 0x0e43 },
|
||||
{ 0x0de4, 0x0e44 },
|
||||
{ 0x0de5, 0x0e45 },
|
||||
{ 0x0de6, 0x0e46 },
|
||||
{ 0x0de7, 0x0e47 },
|
||||
{ 0x0de8, 0x0e48 },
|
||||
{ 0x0de9, 0x0e49 },
|
||||
{ 0x0dea, 0x0e4a },
|
||||
{ 0x0deb, 0x0e4b },
|
||||
{ 0x0dec, 0x0e4c },
|
||||
{ 0x0ded, 0x0e4d },
|
||||
{ 0x0df0, 0x0e50 },
|
||||
{ 0x0df1, 0x0e51 },
|
||||
{ 0x0df2, 0x0e52 },
|
||||
{ 0x0df3, 0x0e53 },
|
||||
{ 0x0df4, 0x0e54 },
|
||||
{ 0x0df5, 0x0e55 },
|
||||
{ 0x0df6, 0x0e56 },
|
||||
{ 0x0df7, 0x0e57 },
|
||||
{ 0x0df8, 0x0e58 },
|
||||
{ 0x0df9, 0x0e59 },
|
||||
{ 0x0ea1, 0x3131 },
|
||||
{ 0x0ea2, 0x3132 },
|
||||
{ 0x0ea3, 0x3133 },
|
||||
{ 0x0ea4, 0x3134 },
|
||||
{ 0x0ea5, 0x3135 },
|
||||
{ 0x0ea6, 0x3136 },
|
||||
{ 0x0ea7, 0x3137 },
|
||||
{ 0x0ea8, 0x3138 },
|
||||
{ 0x0ea9, 0x3139 },
|
||||
{ 0x0eaa, 0x313a },
|
||||
{ 0x0eab, 0x313b },
|
||||
{ 0x0eac, 0x313c },
|
||||
{ 0x0ead, 0x313d },
|
||||
{ 0x0eae, 0x313e },
|
||||
{ 0x0eaf, 0x313f },
|
||||
{ 0x0eb0, 0x3140 },
|
||||
{ 0x0eb1, 0x3141 },
|
||||
{ 0x0eb2, 0x3142 },
|
||||
{ 0x0eb3, 0x3143 },
|
||||
{ 0x0eb4, 0x3144 },
|
||||
{ 0x0eb5, 0x3145 },
|
||||
{ 0x0eb6, 0x3146 },
|
||||
{ 0x0eb7, 0x3147 },
|
||||
{ 0x0eb8, 0x3148 },
|
||||
{ 0x0eb9, 0x3149 },
|
||||
{ 0x0eba, 0x314a },
|
||||
{ 0x0ebb, 0x314b },
|
||||
{ 0x0ebc, 0x314c },
|
||||
{ 0x0ebd, 0x314d },
|
||||
{ 0x0ebe, 0x314e },
|
||||
{ 0x0ebf, 0x314f },
|
||||
{ 0x0ec0, 0x3150 },
|
||||
{ 0x0ec1, 0x3151 },
|
||||
{ 0x0ec2, 0x3152 },
|
||||
{ 0x0ec3, 0x3153 },
|
||||
{ 0x0ec4, 0x3154 },
|
||||
{ 0x0ec5, 0x3155 },
|
||||
{ 0x0ec6, 0x3156 },
|
||||
{ 0x0ec7, 0x3157 },
|
||||
{ 0x0ec8, 0x3158 },
|
||||
{ 0x0ec9, 0x3159 },
|
||||
{ 0x0eca, 0x315a },
|
||||
{ 0x0ecb, 0x315b },
|
||||
{ 0x0ecc, 0x315c },
|
||||
{ 0x0ecd, 0x315d },
|
||||
{ 0x0ece, 0x315e },
|
||||
{ 0x0ecf, 0x315f },
|
||||
{ 0x0ed0, 0x3160 },
|
||||
{ 0x0ed1, 0x3161 },
|
||||
{ 0x0ed2, 0x3162 },
|
||||
{ 0x0ed3, 0x3163 },
|
||||
{ 0x0ed4, 0x11a8 },
|
||||
{ 0x0ed5, 0x11a9 },
|
||||
{ 0x0ed6, 0x11aa },
|
||||
{ 0x0ed7, 0x11ab },
|
||||
{ 0x0ed8, 0x11ac },
|
||||
{ 0x0ed9, 0x11ad },
|
||||
{ 0x0eda, 0x11ae },
|
||||
{ 0x0edb, 0x11af },
|
||||
{ 0x0edc, 0x11b0 },
|
||||
{ 0x0edd, 0x11b1 },
|
||||
{ 0x0ede, 0x11b2 },
|
||||
{ 0x0edf, 0x11b3 },
|
||||
{ 0x0ee0, 0x11b4 },
|
||||
{ 0x0ee1, 0x11b5 },
|
||||
{ 0x0ee2, 0x11b6 },
|
||||
{ 0x0ee3, 0x11b7 },
|
||||
{ 0x0ee4, 0x11b8 },
|
||||
{ 0x0ee5, 0x11b9 },
|
||||
{ 0x0ee6, 0x11ba },
|
||||
{ 0x0ee7, 0x11bb },
|
||||
{ 0x0ee8, 0x11bc },
|
||||
{ 0x0ee9, 0x11bd },
|
||||
{ 0x0eea, 0x11be },
|
||||
{ 0x0eeb, 0x11bf },
|
||||
{ 0x0eec, 0x11c0 },
|
||||
{ 0x0eed, 0x11c1 },
|
||||
{ 0x0eee, 0x11c2 },
|
||||
{ 0x0eef, 0x316d },
|
||||
{ 0x0ef0, 0x3171 },
|
||||
{ 0x0ef1, 0x3178 },
|
||||
{ 0x0ef2, 0x317f },
|
||||
{ 0x0ef3, 0x3181 },
|
||||
{ 0x0ef4, 0x3184 },
|
||||
{ 0x0ef5, 0x3186 },
|
||||
{ 0x0ef6, 0x318d },
|
||||
{ 0x0ef7, 0x318e },
|
||||
{ 0x0ef8, 0x11eb },
|
||||
{ 0x0ef9, 0x11f0 },
|
||||
{ 0x0efa, 0x11f9 },
|
||||
{ 0x0eff, 0x20a9 },
|
||||
{ 0x13a4, 0x20ac },
|
||||
{ 0x13bc, 0x0152 },
|
||||
{ 0x13bd, 0x0153 },
|
||||
{ 0x13be, 0x0178 },
|
||||
{ 0x20ac, 0x20ac },
|
||||
// Numeric keypad with numlock on
|
||||
{ XK_KP_Space, ' ' },
|
||||
{ XK_KP_Equal, '=' },
|
||||
{ XK_KP_Multiply, '*' },
|
||||
{ XK_KP_Add, '+' },
|
||||
{ XK_KP_Separator, ',' },
|
||||
{ XK_KP_Subtract, '-' },
|
||||
{ XK_KP_Decimal, '.' },
|
||||
{ XK_KP_Divide, '/' },
|
||||
{ XK_KP_0, 0x0030 },
|
||||
{ XK_KP_1, 0x0031 },
|
||||
{ XK_KP_2, 0x0032 },
|
||||
{ XK_KP_3, 0x0033 },
|
||||
{ XK_KP_4, 0x0034 },
|
||||
{ XK_KP_5, 0x0035 },
|
||||
{ XK_KP_6, 0x0036 },
|
||||
{ XK_KP_7, 0x0037 },
|
||||
{ XK_KP_8, 0x0038 },
|
||||
{ XK_KP_9, 0x0039 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Convert X11 KeySym to Unicode
|
||||
*/
|
||||
uint32_t
|
||||
bm_x11_key_sym2unicode(uint32_t keysym)
|
||||
{
|
||||
uint32_t min = 0, max = sizeof(keysymtab) / sizeof(struct codepair) - 1, mid;
|
||||
|
||||
// First check for Latin-1 characters (1:1 mapping)
|
||||
if ((keysym >= 0x0020 && keysym <= 0x007e) || (keysym >= 0x00a0 && keysym <= 0x00ff))
|
||||
return keysym;
|
||||
|
||||
// Also check for directly encoded 24-bit UCS characters
|
||||
if ((keysym & 0xff000000) == 0x01000000)
|
||||
return keysym & 0x00ffffff;
|
||||
|
||||
// Binary search in table
|
||||
while (max >= min) {
|
||||
mid = (min + max) / 2;
|
||||
if (keysymtab[mid].keysym < keysym)
|
||||
min = mid + 1;
|
||||
else if (keysymtab[mid].keysym > keysym)
|
||||
max = mid - 1;
|
||||
else
|
||||
return keysymtab[mid].ucs;
|
||||
}
|
||||
|
||||
// No matching Unicode value found
|
||||
return 0;
|
||||
}
|
8
.config/dwl/menu/lib/renderers/x11/xkb_unicode.h
Normal file
8
.config/dwl/menu/lib/renderers/x11/xkb_unicode.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef _BM_XKB_UNICODE_H_
|
||||
#define _BM_XKB_UNICODE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t bm_x11_key_sym2unicode(uint32_t keysym);
|
||||
|
||||
#endif // _BM_XKB_UNICODE_H_
|
415
.config/dwl/menu/lib/util.c
Normal file
415
.config/dwl/menu/lib/util.c
Normal file
|
@ -0,0 +1,415 @@
|
|||
#define _XOPEN_SOURCE
|
||||
#include <wchar.h> /* wcswidth */
|
||||
#undef _XOPEN_SOURCE
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
/**
|
||||
* Portable strdup.
|
||||
*
|
||||
* @param string C "string" to copy.
|
||||
* @return Copy of the given C "string".
|
||||
*/
|
||||
char*
|
||||
bm_strdup(const char *string)
|
||||
{
|
||||
assert(string);
|
||||
|
||||
size_t len = strlen(string);
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
|
||||
void *copy = calloc(1, len + 1);
|
||||
if (copy == NULL)
|
||||
return NULL;
|
||||
|
||||
return (char *)memcpy(copy, string, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Small wrapper around realloc.
|
||||
* Resizes the buffer.
|
||||
*
|
||||
* @param in_out_buffer Reference to the input buffer that will be modified on succesful resize.
|
||||
* @param in_out_size Current buffer size, will be modified with new size on succesful resize.
|
||||
* @param nsize New size to resize the buffer to.
|
||||
* @return true for succesful resize, false for failure.
|
||||
*/
|
||||
bool
|
||||
bm_resize_buffer(char **in_out_buffer, size_t *in_out_size, size_t nsize)
|
||||
{
|
||||
assert(in_out_buffer && in_out_size);
|
||||
|
||||
if (nsize == 0 || nsize <= *in_out_size)
|
||||
return false;
|
||||
|
||||
void *tmp;
|
||||
if (!(tmp = realloc(*in_out_buffer, nsize)))
|
||||
return false;
|
||||
|
||||
*in_out_buffer = tmp;
|
||||
*in_out_size = nsize;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatted printf that returns allocated char array.
|
||||
*
|
||||
* @param fmt Format as C "string".
|
||||
* @return Copy of the formatted C "string".
|
||||
*/
|
||||
char*
|
||||
bm_dprintf(const char *fmt, ...)
|
||||
{
|
||||
assert(fmt);
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
size_t len = vsnprintf(NULL, 0, fmt, args) + 1;
|
||||
va_end(args);
|
||||
|
||||
char *buffer;
|
||||
if (!(buffer = calloc(1, len)))
|
||||
return NULL;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buffer, len, fmt, args);
|
||||
va_end(args);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatted printf that reuses and grows buffer when neccessary.
|
||||
*
|
||||
* @param in_out_buffer Reference to buffer that holds the new formatted text.
|
||||
* @param in_out_len Reference to the length of current buffer and outs as resized length.
|
||||
* @param fmt Format as C "string".
|
||||
* @param va_list Argument list.
|
||||
* @return true if successful, false if failure.
|
||||
*/
|
||||
bool
|
||||
bm_vrprintf(char **in_out_buffer, size_t *in_out_len, const char *fmt, va_list args)
|
||||
{
|
||||
assert(in_out_buffer && in_out_len && fmt);
|
||||
|
||||
va_list copy;
|
||||
va_copy(copy, args);
|
||||
|
||||
size_t len = vsnprintf(NULL, 0, fmt, args) + 1;
|
||||
|
||||
if ((!*in_out_buffer || *in_out_len < len) && !bm_resize_buffer(in_out_buffer, in_out_len, len))
|
||||
return false;
|
||||
|
||||
vsnprintf(*in_out_buffer, len, fmt, copy);
|
||||
va_end(copy);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces next token in string with '\0' and returns position for the replaced token.
|
||||
*
|
||||
* @param string C "string" where token will be replaced.
|
||||
* @param out_next Reference to position of next delimiter, or 0 if none.
|
||||
* @return Position of the replaced token.
|
||||
*/
|
||||
size_t
|
||||
bm_strip_token(char *string, const char *token, size_t *out_next)
|
||||
{
|
||||
size_t len = strcspn(string, token);
|
||||
|
||||
if (out_next)
|
||||
*out_next = len + (string[len] != 0);
|
||||
|
||||
string[len] = 0;
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portable case-insensitive strcmp.
|
||||
*
|
||||
* @param hay C "string" to match against.
|
||||
* @param needle C "string" to match.
|
||||
* @return Less than, equal to or greater than zero if hay is lexicographically less than, equal to or greater than needle.
|
||||
*/
|
||||
int
|
||||
bm_strupcmp(const char *hay, const char *needle)
|
||||
{
|
||||
return bm_strnupcmp(hay, needle, strlen(hay));
|
||||
}
|
||||
|
||||
/**
|
||||
* Portable case-insensitive strncmp.
|
||||
*
|
||||
* @param hay C "string" to match against.
|
||||
* @param needle C "string" to match.
|
||||
* @return Less than, equal to or greater than zero if hay is lexicographically less than, equal to or greater than needle.
|
||||
*/
|
||||
int
|
||||
bm_strnupcmp(const char *hay, const char *needle, size_t len)
|
||||
{
|
||||
const unsigned char *p1 = (const unsigned char*)hay;
|
||||
const unsigned char *p2 = (const unsigned char*)needle;
|
||||
|
||||
unsigned char a = 0, b = 0;
|
||||
for (size_t i = 0; len > 0; --len, ++i)
|
||||
if ((a = toupper(*p1++)) != (b = toupper(*p2++)))
|
||||
return a - b;
|
||||
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portable case-insensitive strstr.
|
||||
*
|
||||
* @param hay C "string" to substring against.
|
||||
* @param needle C "string" to substring.
|
||||
*/
|
||||
char*
|
||||
bm_strupstr(const char *hay, const char *needle)
|
||||
{
|
||||
size_t r = 0, p = 0, len, len2;
|
||||
|
||||
if ((len = strlen(hay)) < (len2 = strlen(needle)))
|
||||
return NULL;
|
||||
|
||||
if (!bm_strnupcmp(hay, needle, len2))
|
||||
return (char*)hay;
|
||||
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (p == len2)
|
||||
return (char*)hay + r;
|
||||
|
||||
if (toupper(hay[i]) == toupper(needle[p++])) {
|
||||
if (!r)
|
||||
r = i;
|
||||
} else {
|
||||
if (r)
|
||||
i = r;
|
||||
r = p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (p == len2 ? (char*)hay + r : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determite columns needed to display UTF8 string.
|
||||
*
|
||||
* @param string C "string" to determite.
|
||||
* @return Number of columns, or -1 on failure.
|
||||
*/
|
||||
int32_t
|
||||
bm_utf8_string_screen_width(const char *string)
|
||||
{
|
||||
assert(string);
|
||||
|
||||
char *mstr;
|
||||
if (!(mstr = bm_strdup(string)))
|
||||
return strlen(string);
|
||||
|
||||
char *s;
|
||||
for (s = mstr; *s; ++s) if (*s == '\t') *s = ' ';
|
||||
|
||||
int num_char = mbstowcs(NULL, mstr, 0) + 1;
|
||||
wchar_t *wstring = malloc((num_char + 1) * sizeof (wstring[0]));
|
||||
|
||||
if (mbstowcs(wstring, mstr, num_char) == (size_t)(-1)) {
|
||||
free(wstring);
|
||||
int len = strlen(mstr);
|
||||
free(mstr);
|
||||
return len;
|
||||
}
|
||||
|
||||
int32_t length = wcswidth(wstring, num_char);
|
||||
free(wstring);
|
||||
free(mstr);
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out how many bytes to shift to next UTF8 rune.
|
||||
*
|
||||
* @param string C "string" which contains the runes.
|
||||
* @param start Offset where to figure out next rune. (cursor)
|
||||
* @return Number of bytes to next UTF8 rune.
|
||||
*/
|
||||
size_t
|
||||
bm_utf8_rune_next(const char *string, size_t start)
|
||||
{
|
||||
assert(string);
|
||||
|
||||
size_t len = strlen(string), i = start;
|
||||
if (len == 0 || len <= i || !*string)
|
||||
return 0;
|
||||
|
||||
while (++i < len && (string[i] & 0xc0) == 0x80);
|
||||
return i - start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out how many bytes to shift to previous UTF8 rune.
|
||||
*
|
||||
* @param string C "string" which contains the runes.
|
||||
* @param start Offset where to figure out previous rune. (cursor)
|
||||
* @return Number of bytes to previous UTF8 rune.
|
||||
*/
|
||||
size_t
|
||||
bm_utf8_rune_prev(const char *string, size_t start)
|
||||
{
|
||||
assert(string);
|
||||
|
||||
size_t len = strlen(string), i = start;
|
||||
if (i == 0 || len < start || !*string)
|
||||
return 0;
|
||||
|
||||
while (--i > 0 && (string[i] & 0xc0) == 0x80);
|
||||
return start - i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out how many columns are needed to display UTF8 rune.
|
||||
*
|
||||
* @param rune Buffer which contains the rune.
|
||||
* @param u8len Byte length of the rune.
|
||||
* @return Number of columns, or -1 on failure.
|
||||
*/
|
||||
size_t
|
||||
bm_utf8_rune_width(const char *rune, uint32_t u8len)
|
||||
{
|
||||
assert(rune);
|
||||
char mb[5] = { 0, 0, 0, 0, 0 };
|
||||
memcpy(mb, rune, (u8len > 4 ? 4 : u8len));
|
||||
return bm_utf8_string_screen_width(mb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove previous UTF8 rune from buffer.
|
||||
*
|
||||
* @param string Null terminated C "string".
|
||||
* @param start Start offset where to delete from. (cursor)
|
||||
* @param out_rune_width Reference to size_t, return number of columns for removed rune, or -1 on failure.
|
||||
* @return Number of bytes removed from buffer.
|
||||
*/
|
||||
size_t
|
||||
bm_utf8_rune_remove(char *string, size_t start, size_t *out_rune_width)
|
||||
{
|
||||
assert(string);
|
||||
|
||||
if (out_rune_width)
|
||||
*out_rune_width = 0;
|
||||
|
||||
size_t len = strlen(string), oldStart = start;
|
||||
if (len == 0 || len < start || !*string)
|
||||
return 0;
|
||||
|
||||
start -= bm_utf8_rune_prev(string, start);
|
||||
|
||||
if (out_rune_width)
|
||||
*out_rune_width = bm_utf8_rune_width(string + start, oldStart - start);
|
||||
|
||||
memmove(string + start, string + oldStart, len - oldStart);
|
||||
string[len - (oldStart - start)] = 0;
|
||||
return (oldStart - start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert UTF8 rune to buffer.
|
||||
*
|
||||
* @param in_out_string Reference to buffer.
|
||||
* @param in_out_buf_size Reference to size of the buffer.
|
||||
* @param start Start offset where to insert to. (cursor)
|
||||
* @param rune Buffer to insert to string.
|
||||
* @param u8len Byte length of the rune.
|
||||
* @param out_rune_width Reference to size_t, return number of columns for inserted rune, or -1 on failure.
|
||||
* @return Number of bytes inserted to buffer.
|
||||
*/
|
||||
size_t
|
||||
bm_utf8_rune_insert(char **in_out_string, size_t *in_out_buf_size, size_t start, const char *rune, uint32_t u8len, size_t *out_rune_width)
|
||||
{
|
||||
assert(in_out_string);
|
||||
assert(in_out_buf_size);
|
||||
|
||||
if (out_rune_width)
|
||||
*out_rune_width = 0;
|
||||
|
||||
if (u8len == 1 && !isprint(*rune))
|
||||
return 0;
|
||||
|
||||
size_t len = (*in_out_string ? strlen(*in_out_string) : 0);
|
||||
if (!*in_out_string && !(*in_out_string = calloc(1, (*in_out_buf_size = u8len + 1))))
|
||||
return 0;
|
||||
|
||||
if (len + u8len >= *in_out_buf_size) {
|
||||
void *tmp;
|
||||
if (!(tmp = realloc(*in_out_string, (*in_out_buf_size * 2)))) {
|
||||
if (!(tmp = malloc((*in_out_buf_size * 2))))
|
||||
return 0;
|
||||
|
||||
memcpy(tmp, *in_out_string, *in_out_buf_size);
|
||||
free(*in_out_string);
|
||||
}
|
||||
|
||||
memset((char*)tmp + *in_out_buf_size, 0, *in_out_buf_size);
|
||||
*in_out_string = tmp;
|
||||
*in_out_buf_size *= 2;
|
||||
}
|
||||
|
||||
char *str = *in_out_string + start;
|
||||
memmove(str + u8len, str, len - start);
|
||||
memcpy(str, rune, u8len);
|
||||
(*in_out_string)[len + u8len] = 0;
|
||||
|
||||
if (out_rune_width)
|
||||
*out_rune_width = bm_utf8_rune_width(rune, u8len);
|
||||
return u8len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert unicode character to UTF8 buffer.
|
||||
*
|
||||
* @param in_out_string Reference to buffer.
|
||||
* @param in_out_buf_size Reference to size of the buffer.
|
||||
* @param start Start offset where to insert to. (cursor)
|
||||
* @param unicode Unicode character to insert.
|
||||
* @param out_rune_width Reference to size_t, return number of columns for inserted rune, or -1 on failure.
|
||||
* @return Number of bytes inserted to buffer.
|
||||
*/
|
||||
size_t
|
||||
bm_unicode_insert(char **in_out_string, size_t *in_out_buf_size, size_t start, uint32_t unicode, size_t *out_rune_width)
|
||||
{
|
||||
assert(in_out_string && in_out_buf_size);
|
||||
|
||||
uint8_t u8len = ((unicode < 0x80) ? 1 : ((unicode < 0x800) ? 2 : ((unicode < 0x10000) ? 3 : 4)));
|
||||
char mb[5] = { 0, 0, 0, 0 };
|
||||
|
||||
if (u8len == 1) {
|
||||
mb[0] = unicode;
|
||||
} else {
|
||||
size_t j;
|
||||
for (j = u8len; j > 1; --j) mb[j - 1] = 0x80 | (0x3F & (unicode >> ((u8len - j) * 6)));
|
||||
mb[0] = (uint8_t)(~0) << (8 - u8len);
|
||||
mb[0] |= (unicode >> (u8len * 6 - 6));
|
||||
}
|
||||
|
||||
return bm_utf8_rune_insert(in_out_string, in_out_buf_size, start, mb, u8len, out_rune_width);
|
||||
}
|
||||
|
||||
bool
|
||||
bm_menu_item_is_selected(const struct bm_menu *menu, const struct bm_item *item)
|
||||
{
|
||||
assert(menu);
|
||||
assert(item);
|
||||
|
||||
uint32_t i, count;
|
||||
struct bm_item **items = bm_menu_get_selected_items(menu, &count);
|
||||
for (i = 0; i < count && items[i] != item; ++i);
|
||||
return (i < count);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sw=4 tw=0 :*/
|
368
.config/dwl/menu/lib/vim.c
Normal file
368
.config/dwl/menu/lib/vim.c
Normal file
|
@ -0,0 +1,368 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "vim.h"
|
||||
|
||||
|
||||
static enum bm_vim_code vim_on_first_key(struct bm_menu *menu, uint32_t unicode, uint32_t item_count, uint32_t items_displayed);
|
||||
static enum bm_vim_code vim_on_second_key(struct bm_menu *menu, uint32_t unicode, uint32_t item_count, uint32_t items_displayed);
|
||||
|
||||
|
||||
static void move_left(struct bm_menu *menu){
|
||||
if(menu->filter && menu->cursor > 0){
|
||||
uint32_t old_cursor = menu->cursor;
|
||||
menu->cursor -= bm_utf8_rune_prev(menu->filter, menu->cursor);
|
||||
menu->curses_cursor -= bm_utf8_rune_width(menu->filter + menu->cursor, old_cursor - menu->cursor);
|
||||
}
|
||||
}
|
||||
|
||||
static void move_right(struct bm_menu *menu, size_t filter_length){
|
||||
if(menu->cursor < filter_length){
|
||||
uint32_t old_cursor = menu->cursor;
|
||||
menu->cursor += bm_utf8_rune_next(menu->filter, menu->cursor);
|
||||
menu->curses_cursor += bm_utf8_rune_width(menu->filter + old_cursor, menu->cursor - old_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
static void move_line_start(struct bm_menu *menu){
|
||||
menu->cursor = 0;
|
||||
menu->curses_cursor = 0;
|
||||
}
|
||||
|
||||
static void move_line_end(struct bm_menu *menu){
|
||||
menu->cursor = (menu->filter ? strlen(menu->filter) : 0);
|
||||
menu->curses_cursor = (menu->filter ? bm_utf8_string_screen_width(menu->filter) : 0);
|
||||
}
|
||||
|
||||
static void menu_next(struct bm_menu *menu, uint32_t count, bool wrap){
|
||||
if (menu->index < count - 1) {
|
||||
bm_menu_set_highlighted_index(menu, menu->index + 1);
|
||||
} else if (wrap) {
|
||||
bm_menu_set_highlighted_index(menu, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_prev(struct bm_menu *menu, uint32_t count, bool wrap){
|
||||
if (menu->index > 0) {
|
||||
bm_menu_set_highlighted_index(menu, menu->index - 1);
|
||||
} else if (wrap) {
|
||||
bm_menu_set_highlighted_index(menu, count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_first(struct bm_menu *menu, uint32_t count){
|
||||
if(count > 0){
|
||||
bm_menu_set_highlighted_index(menu, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_last(struct bm_menu *menu, uint32_t count){
|
||||
if(count > 0){
|
||||
bm_menu_set_highlighted_index(menu, count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_view_high(struct bm_menu *menu, uint32_t count){
|
||||
if(count > 0){
|
||||
uint32_t nth_view_item = menu->index % menu->lines;
|
||||
bm_menu_set_highlighted_index(menu, menu->index - nth_view_item);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_view_mid(struct bm_menu *menu, uint32_t count, uint32_t displayed){
|
||||
if(count > 0){
|
||||
uint32_t nth_view_item = menu->index % menu->lines;
|
||||
uint32_t half_view_height = (displayed - 1) / 2;
|
||||
bm_menu_set_highlighted_index(menu, menu->index - nth_view_item + half_view_height);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_view_low(struct bm_menu *menu, uint32_t count, uint32_t displayed){
|
||||
if(count > 0){
|
||||
uint32_t nth_view_item = menu->index % menu->lines;
|
||||
uint32_t view_bottom_offset = (displayed - 2) - nth_view_item;
|
||||
bm_menu_set_highlighted_index(menu, menu->index + view_bottom_offset);
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_page_down(struct bm_menu *menu, uint32_t count, uint32_t displayed){
|
||||
bm_menu_set_highlighted_index(menu, (menu->index + displayed >= count ? count - 1 : menu->index + (displayed - 1)));
|
||||
}
|
||||
|
||||
static void menu_page_up(struct bm_menu *menu, uint32_t displayed){
|
||||
bm_menu_set_highlighted_index(menu, (menu->index < displayed ? 0 : menu->index - (displayed - 1)));
|
||||
}
|
||||
|
||||
static void move_word(struct bm_menu *menu){
|
||||
if(!menu->filter) return;
|
||||
|
||||
size_t filter_length = strlen(menu->filter);
|
||||
while (menu->cursor < filter_length && !isspace(menu->filter[menu->cursor])) move_right(menu, filter_length);
|
||||
while (menu->cursor < filter_length && isspace(menu->filter[menu->cursor])) move_right(menu, filter_length);
|
||||
}
|
||||
|
||||
static void move_word_back(struct bm_menu *menu){
|
||||
while (menu->cursor > 0 && isspace(menu->filter[menu->cursor - 1])) move_left(menu);
|
||||
while (menu->cursor > 0 && !isspace(menu->filter[menu->cursor - 1])) move_left(menu);
|
||||
}
|
||||
|
||||
static void move_word_end(struct bm_menu *menu){
|
||||
if(!menu->filter) return;
|
||||
|
||||
size_t filter_length = strlen(menu->filter);
|
||||
size_t old_cursor = menu->cursor;
|
||||
size_t old_curses_cursor = menu->curses_cursor;
|
||||
|
||||
while (menu->cursor < filter_length && isspace(menu->filter[menu->cursor + 1])) move_right(menu, filter_length);
|
||||
while (menu->cursor < filter_length && !isspace(menu->filter[menu->cursor + 1])) move_right(menu, filter_length);
|
||||
|
||||
if(menu->cursor == filter_length){
|
||||
menu->cursor = old_cursor;
|
||||
menu->curses_cursor = old_curses_cursor;
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_char(struct bm_menu *menu){
|
||||
if(menu->filter){
|
||||
if(menu->cursor < strlen(menu->filter)){
|
||||
size_t width;
|
||||
bm_utf8_rune_remove(menu->filter, menu->cursor + 1, &width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_char_back(struct bm_menu *menu){
|
||||
if(menu->filter){
|
||||
if(menu->cursor > 0){
|
||||
size_t width;
|
||||
bm_utf8_rune_remove(menu->filter, menu->cursor, &width);
|
||||
move_left(menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_word(struct bm_menu *menu){
|
||||
if(!menu->filter) return;
|
||||
|
||||
size_t filter_length = strlen(menu->filter);
|
||||
while (menu->cursor < filter_length && !isspace(menu->filter[menu->cursor])) delete_char(menu);
|
||||
while (menu->cursor < filter_length && isspace(menu->filter[menu->cursor])) delete_char(menu);
|
||||
}
|
||||
|
||||
static void delete_word_back(struct bm_menu *menu){
|
||||
while (menu->cursor > 0 && isspace(menu->filter[menu->cursor - 1])){
|
||||
move_left(menu);
|
||||
delete_char(menu);
|
||||
}
|
||||
|
||||
while (menu->cursor > 0 && !isspace(menu->filter[menu->cursor - 1])){
|
||||
move_left(menu);
|
||||
delete_char(menu);
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_line(struct bm_menu *menu){
|
||||
if(menu->filter){
|
||||
menu->filter[0] = 0;
|
||||
menu->cursor = 0;
|
||||
menu->curses_cursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_to_line_end(struct bm_menu *menu){
|
||||
if(menu->filter){
|
||||
menu->filter[menu->cursor] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void delete_to_line_start(struct bm_menu *menu){
|
||||
if(menu->filter){
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wrestrict"
|
||||
strcpy(menu->filter, menu->filter + menu->cursor);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
menu->cursor = 0;
|
||||
menu->curses_cursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void toggle_item_selection(struct bm_menu *menu){
|
||||
struct bm_item *highlighted = bm_menu_get_highlighted_item(menu);
|
||||
if (highlighted){
|
||||
if(!bm_menu_item_is_selected(menu, highlighted)){
|
||||
list_add_item(&menu->selection, highlighted);
|
||||
} else {
|
||||
list_remove_item(&menu->selection, highlighted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum bm_vim_code bm_vim_key_press(struct bm_menu *menu, enum bm_key key, uint32_t unicode, uint32_t item_count, uint32_t items_displayed){
|
||||
if(key == BM_KEY_ESCAPE && unicode == 99) return BM_VIM_EXIT;
|
||||
|
||||
if(menu->vim_mode == 'n'){
|
||||
if(key == BM_KEY_ESCAPE) return BM_VIM_CONSUME;
|
||||
if(unicode == 0 || unicode > 128) return BM_VIM_IGNORE;
|
||||
|
||||
if(menu->vim_last_key == 0) return vim_on_first_key(menu, unicode, item_count, items_displayed);
|
||||
else return vim_on_second_key(menu, unicode, item_count, items_displayed);
|
||||
} else if(menu->vim_mode == 'i'){
|
||||
if(key == BM_KEY_ESCAPE && unicode == 0){
|
||||
menu->vim_mode = 'n';
|
||||
return BM_VIM_CONSUME;
|
||||
}
|
||||
}
|
||||
|
||||
return BM_VIM_IGNORE;
|
||||
}
|
||||
|
||||
static enum bm_vim_code vim_on_first_key(struct bm_menu *menu, uint32_t unicode, uint32_t item_count, uint32_t items_displayed){
|
||||
size_t filter_length = 0;
|
||||
|
||||
switch(unicode){
|
||||
case 'q':
|
||||
return BM_VIM_EXIT;
|
||||
case 'v':
|
||||
toggle_item_selection(menu);
|
||||
goto action_executed;
|
||||
case 'i':
|
||||
goto insert_action_executed;
|
||||
case 'I':
|
||||
move_line_start(menu);
|
||||
goto insert_action_executed;
|
||||
case 'a':
|
||||
if(menu->filter) filter_length = strlen(menu->filter);
|
||||
move_right(menu, filter_length);
|
||||
goto insert_action_executed;
|
||||
case 'A':
|
||||
move_line_end(menu);
|
||||
goto insert_action_executed;
|
||||
case 'h':
|
||||
move_left(menu);
|
||||
goto action_executed;
|
||||
case 'n':
|
||||
case 'j':
|
||||
menu_next(menu, item_count, menu->wrap);
|
||||
goto action_executed;
|
||||
case 'p':
|
||||
case 'k':
|
||||
menu_prev(menu, item_count, menu->wrap);
|
||||
goto action_executed;
|
||||
case 'l':
|
||||
if(menu->filter) filter_length = strlen(menu->filter);
|
||||
move_right(menu, filter_length);
|
||||
goto action_executed;
|
||||
case 'w':
|
||||
move_word(menu);
|
||||
goto action_executed;
|
||||
case 'b':
|
||||
move_word_back(menu);
|
||||
goto action_executed;
|
||||
case 'e':
|
||||
move_word_end(menu);
|
||||
goto action_executed;
|
||||
case 'x':
|
||||
delete_char(menu);
|
||||
goto action_executed;
|
||||
case 'X':
|
||||
delete_char_back(menu);
|
||||
goto action_executed;
|
||||
case '0':
|
||||
move_line_start(menu);
|
||||
goto action_executed;
|
||||
case '$':
|
||||
move_line_end(menu);
|
||||
goto action_executed;
|
||||
case 'G':
|
||||
menu_last(menu, item_count);
|
||||
goto action_executed;
|
||||
case 'H':
|
||||
menu_view_high(menu, item_count);
|
||||
goto action_executed;
|
||||
case 'M':
|
||||
menu_view_mid(menu, item_count, items_displayed);
|
||||
goto action_executed;
|
||||
case 'L':
|
||||
menu_view_low(menu, item_count, items_displayed);
|
||||
goto action_executed;
|
||||
case 'F':
|
||||
menu_page_down(menu, item_count, items_displayed);
|
||||
goto action_executed;
|
||||
case 'B':
|
||||
menu_page_up(menu, items_displayed);
|
||||
goto action_executed;
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'g':
|
||||
menu->vim_last_key = unicode;
|
||||
return BM_VIM_CONSUME;
|
||||
default:
|
||||
menu->vim_last_key = 0;
|
||||
return BM_VIM_CONSUME;
|
||||
}
|
||||
|
||||
insert_action_executed:
|
||||
menu->vim_mode = 'i';
|
||||
action_executed:
|
||||
menu->vim_last_key = 0;
|
||||
return BM_VIM_CONSUME;
|
||||
}
|
||||
|
||||
static enum bm_vim_code vim_on_second_key(struct bm_menu *menu, uint32_t unicode, uint32_t item_count, uint32_t items_displayed){
|
||||
if(menu->vim_last_key == 'd'){
|
||||
switch(unicode){
|
||||
case 'd':
|
||||
delete_line(menu);
|
||||
goto action_executed;
|
||||
case 'w':
|
||||
delete_word(menu);
|
||||
goto action_executed;
|
||||
case 'b':
|
||||
delete_word_back(menu);
|
||||
goto action_executed;
|
||||
case '$':
|
||||
delete_to_line_end(menu);
|
||||
goto action_executed;
|
||||
case '0':
|
||||
delete_to_line_start(menu);
|
||||
goto action_executed;
|
||||
}
|
||||
} else if(menu->vim_last_key == 'c'){
|
||||
switch(unicode){
|
||||
case 'c':
|
||||
delete_line(menu);
|
||||
goto insert_action_executed;
|
||||
case 'w':
|
||||
delete_word(menu);
|
||||
goto insert_action_executed;
|
||||
case 'b':
|
||||
delete_word_back(menu);
|
||||
goto insert_action_executed;
|
||||
case '$':
|
||||
delete_to_line_end(menu);
|
||||
goto insert_action_executed;
|
||||
case '0':
|
||||
delete_to_line_start(menu);
|
||||
goto insert_action_executed;
|
||||
}
|
||||
} else if(menu->vim_last_key == 'g'){
|
||||
switch(unicode){
|
||||
case 'g':
|
||||
menu_first(menu, item_count);
|
||||
goto action_executed;
|
||||
}
|
||||
}
|
||||
|
||||
return vim_on_first_key(menu, unicode, item_count, items_displayed);
|
||||
|
||||
insert_action_executed:
|
||||
menu->vim_mode = 'i';
|
||||
action_executed:
|
||||
menu->vim_last_key = 0;
|
||||
return BM_VIM_CONSUME;
|
||||
}
|
14
.config/dwl/menu/lib/vim.h
Normal file
14
.config/dwl/menu/lib/vim.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef _VIM_H_
|
||||
#define _VIM_H_
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
enum bm_vim_code {
|
||||
BM_VIM_CONSUME,
|
||||
BM_VIM_IGNORE,
|
||||
BM_VIM_EXIT
|
||||
};
|
||||
|
||||
enum bm_vim_code bm_vim_key_press(struct bm_menu *menu, enum bm_key key, uint32_t unicode, uint32_t item_count, uint32_t items_displayed);
|
||||
|
||||
#endif
|
283
.config/dwl/menu/man/bemenu.1.scd.in
Normal file
283
.config/dwl/menu/man/bemenu.1.scd.in
Normal file
|
@ -0,0 +1,283 @@
|
|||
bemenu(1)
|
||||
|
||||
# NAME
|
||||
|
||||
*bemenu* - dynamic menu inspired by *dmenu*(1)
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
*bemenu* [*-hivwx*] [*-I* <_index_>] [*-l* <_lines_>] [*-P* _prefix_]
|
||||
\[*-p* <_prompt_>] [*--ifne*] [*--scrollbar* _none_|_always_|_autohide_]
|
||||
\[_backend_options_]
|
||||
|
||||
*bemenu-run* [*-hivwx*] [*-I* <_index_>] [*-l* <_lines_>] [*-P* <_prefix_>]
|
||||
\[*-p* <_prompt_>] [*--ifne*] [*--scrollbar* _none_|_always_|_autohide_]
|
||||
\[*--fork*] [*--no-exec*] [_backend-options_]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
*bemenu* is a dynamic menu for *tty*(4) (using *ncurses*(3)), X11 and Wayland,
|
||||
inspired by *dmenu*(1).
|
||||
|
||||
It reads a list of newline-separated items from standard input and then presents
|
||||
them as a list, where the user can select one or more of them. When pressing
|
||||
*<carriage-return>*, the selected items are printed to standard output (one per
|
||||
line) and *bemenu* exits.
|
||||
|
||||
Entering text will filter the items to those that match the input. If the number
|
||||
of items exceeds the size of the list, the items will be paginated.
|
||||
|
||||
*bemenu-run* is a special-case invocation of *bemenu*, where the input is the
|
||||
list of executables under PATH and the selected items are executed.
|
||||
|
||||
# OPTIONS
|
||||
|
||||
*-h, --help*
|
||||
Print a help message to standard output and exit.
|
||||
|
||||
*-I, --index* <_index_>
|
||||
Highlight the item at _index_ at the start. Indices start at 0. By
|
||||
default, the first item is highlighted.
|
||||
|
||||
*-i, --ignorecase*
|
||||
Filter items case-insensitively.
|
||||
|
||||
*-l, --list* <_number_>
|
||||
List items vertically with the given _number_ of lines.
|
||||
|
||||
*-P, --prefix* <_prefix_>
|
||||
Display _prefix_ before the highlighted item in a vertical list.
|
||||
|
||||
*-p, --prompt* <_prompt_>
|
||||
Defines the _prompt_ text to be displayed to the left of the input
|
||||
field. Defaults to ‘bemenu’.
|
||||
|
||||
*-v, --version*
|
||||
Print the *bemenu* version number to standard output and exit.
|
||||
|
||||
*-w, --wrap*
|
||||
Advancing past the end of the list returns you to the start.
|
||||
|
||||
*-x, --password*
|
||||
Hide filter text.
|
||||
|
||||
*--fork*
|
||||
Always *fork*(2) before executing the selections. Disabled by default
|
||||
when using the terminal backend.
|
||||
|
||||
*--no-exec*
|
||||
Print the selected items to standard output instead of executing them.
|
||||
|
||||
*--scrollbar* _none_|_always_|_autohide_
|
||||
Specify when to show a scrollbar for vertical lists:
|
||||
[[ *none*
|
||||
:< Never display a scrollbar (the default).
|
||||
| *always*
|
||||
: Always display a scrollbar.
|
||||
| *autohide*
|
||||
: Only display a scrollbar when the number of items exceeds the number
|
||||
of lines.
|
||||
|
||||
## Backend options
|
||||
|
||||
These options are only available on backends specified in the parentheses:
|
||||
|
||||
*-b, --bottom* (Wayland, X11)
|
||||
The list will appear at the bottom of the screen.
|
||||
|
||||
*-f, --grab* (Wayland, X11)
|
||||
Show the *bemenu* window whilst reading the items.
|
||||
|
||||
*-H, --line-height* <_height_> (Wayland, X11)
|
||||
Specify the _height_ in point size to make each entry.
|
||||
|
||||
*-m, --monitor* <_index_> (Wayland, X11)
|
||||
Specify the monitor _index_ where the list should appear. Monitor
|
||||
indices start at zero. The interpretation of the given argument depends
|
||||
on the utilized backend. With X11 and Wayland, a value of ‘-1’ or
|
||||
*focused* indicates that the current monitor should be used (the
|
||||
default). With Wayland, the _index_ should be a string specifying a
|
||||
specific monitor name. The value ‘-2’ or *all* indicates that the list
|
||||
should appear on all monitors.
|
||||
|
||||
*-n, --no-overlap* (Wayland)
|
||||
Set the *bemenu* window to be on top of any other panels.
|
||||
|
||||
*-M, --margin* <_margin_> (Wayland, X11)
|
||||
Specify the _margin_ (empty space) in pixels to leave between menu and
|
||||
vertical view borders. *bemenu* will reduce it's size to fit in space
|
||||
between gaps.
|
||||
|
||||
*-W, --width-factor* <_factor_> (Wayland, X11)
|
||||
Specify the relative width factor as a floating point number. It makes
|
||||
sense to set it between 0 and 1 to define how much of the screen width
|
||||
*bemenu* will use. However, *bemenu* will still respect _margin_, so if
|
||||
resulting size is greater than space between gaps, *bemenu* will ignore
|
||||
_factor_ and use available space instead.
|
||||
|
||||
*--fn* <_name_ [_size_]> (Wayland, X11)
|
||||
Specify the font family _name_ and _size_ to be used. For more options,
|
||||
consult the _Pango Reference Manual_ for
|
||||
*pango_font_description_from_string*().
|
||||
|
||||
The following options control the colours for various parts of the list
|
||||
for the Wayland and X11 backends. Each takes an argument in the form of:
|
||||
|
||||
*#*_RGB_[_A_]
|
||||
|
||||
where _R_, _G_, _B_ and _A_ are hexadecimal integers from 00–FF that
|
||||
control the red, green, blue and alpha-transparency channels.
|
||||
|
||||
*--tb* <_color_> Title background.
|
||||
|
||||
*--tf* <_color_> Title foreground.
|
||||
|
||||
*--fb* <_color_> Filter background.
|
||||
|
||||
*--ff* <_color_> Filter foreground
|
||||
|
||||
*--cb* <_color_> Cursor background.
|
||||
|
||||
*--cf* <_color_> Cursor foreground
|
||||
|
||||
*--nb* <_color_> Normal background.
|
||||
|
||||
*--nf* <_color_> Normal foreground.
|
||||
|
||||
*--hb* <_color_> Highlighted background.
|
||||
|
||||
*--hf* <_color_> Highlighted foreground.
|
||||
|
||||
*--fbb* <_color_> Feedback background.
|
||||
|
||||
*--fbf* <_color_> Feedback foreground.
|
||||
|
||||
*--sb* <_color_> Selected background.
|
||||
|
||||
*--sf* <_color_> Selected foreground.
|
||||
|
||||
*--ab* <_color_> Alternating background color.
|
||||
|
||||
*--af* <_color_> Alternating foreground color.
|
||||
|
||||
*--scb* <_color_> Scrollbar background.
|
||||
|
||||
*--scf* <_color_> Scrollbar foreground.
|
||||
|
||||
# KEYBOARD COMMANDS
|
||||
|
||||
*bemenu* supports keyboard commands to move around the list and edit the filter.
|
||||
In the following examples, *C-x* means *<control-x>*, *M-x* means *<alt-x>* and
|
||||
*S-x* means *<shift-x>*:
|
||||
|
||||
*<cursor-up>, S-<cursor-left>, C-p, M-j, M-l*
|
||||
Highlight the previous item.
|
||||
|
||||
*<cursor-down>, <tab>, C-n, M-h, M-k*
|
||||
Highlight the next item.
|
||||
|
||||
*PageUp, M-v, M-u*
|
||||
Show the previous page of items, preserving the offset of the currently
|
||||
highlighted item, if possible.
|
||||
|
||||
*PageDown, C-v, M-d*
|
||||
Show the next page of items, preserving the offset of the currently
|
||||
highlighted item, if possible.
|
||||
|
||||
*S-M-<, S-PageUp*
|
||||
Highlight the first item in the list.
|
||||
|
||||
*S-M->, S-PageDown*
|
||||
Highlight the last item in the list.
|
||||
|
||||
*S-<tab>*
|
||||
Copy the highlighted item to the filter.
|
||||
|
||||
*<escape>, C-g*
|
||||
Terminate *bemenu* without printing items.
|
||||
|
||||
*C-<carriage-return>, C-m*
|
||||
Print selected items and the currently highlighted one, and exit. Items
|
||||
are printed in the order they were selected, with the currently
|
||||
highlighted item printed last.
|
||||
|
||||
*S-<carriage-return>, Insert*
|
||||
Print the filter text to standard output and exit.
|
||||
|
||||
*C-l, <cursor-left>*
|
||||
Move cursor left.
|
||||
|
||||
*C-f, <cursor-right>*
|
||||
Move cursor right.
|
||||
|
||||
*C-a, Home*
|
||||
Move cursor to the start.
|
||||
|
||||
*C-e, End*
|
||||
Move cursor to the end.
|
||||
|
||||
*<backspace> C-h*
|
||||
Remove character before the cursor.
|
||||
|
||||
*<delete>*
|
||||
Remove character at the cursor.
|
||||
|
||||
*C-u, S-<delete>*
|
||||
Remove all characters before the cursor.
|
||||
|
||||
*C-k*
|
||||
Remove all characters after the cursor.
|
||||
|
||||
*C-w*
|
||||
Clear the filter.
|
||||
|
||||
*C-y*
|
||||
Paste the clipboard.
|
||||
|
||||
*M-[1-9]*
|
||||
Print selected items and exit with a custom error code 10 (*M-1*)
|
||||
through 18 (*M-9*), see _EXIT STATUS_.
|
||||
|
||||
*M-0*
|
||||
Print selected items and exit with the custom error code 19, see _EXIT
|
||||
STATUS_.
|
||||
|
||||
# ENVIRONMENT
|
||||
|
||||
[[ *BEMENU_OPTS*
|
||||
:< An alternative way to pass command line arguments to *bemenu*.
|
||||
| *BEMENU_BACKEND*
|
||||
: Force a backend to be used. If empty, one of the GUI backends (Wayland, X11)
|
||||
will be selected automatically. The accepted values are *curses*, *wayland*
|
||||
and *x11*.
|
||||
| *BEMENU_RENDERER*
|
||||
: Force a backend by loading its shared object from the set value.
|
||||
| *BEMENU_RENDERERS*
|
||||
: Override the backend search path to the set value. Defaults to
|
||||
_@LIBDIR@/bemenu_.
|
||||
| *BEMENU_SCALE*
|
||||
: Override the rendering scale factor for the GUI backends.
|
||||
|
||||
# EXIT STATUS
|
||||
|
||||
*0*
|
||||
bemenu ran successfully.
|
||||
|
||||
*1*
|
||||
The user exited without selecting, or bemenu encountered an error.
|
||||
|
||||
*10-19*
|
||||
The user specified a custom exit code with *M-[0-9]*, see _KEYBOARD
|
||||
COMMANDS_.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
*dmenu*(1), *fork*(2), *ncurses*(3), *tty*(4)
|
||||
|
||||
_Pango Reference Manual_, https://developer.gnome.org/pango/1.46/, August 20,
|
||||
2020, Fonts — pango_font_description_from_string().
|
||||
|
||||
# AUTHORS
|
||||
|
||||
*bemenu* is written and maintained by Jari Vetoniemi <_mailroxas@gmail.com_>
|
||||
with the help of various contributors.
|
20
.config/dwl/menu/pw.cloudef.bemenu-run.yml
Normal file
20
.config/dwl/menu/pw.cloudef.bemenu-run.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
app-id: pw.cloudef.bemenu-run
|
||||
runtime: org.freedesktop.Platform
|
||||
runtime-version: '20.08'
|
||||
sdk: org.freedesktop.Sdk
|
||||
command: bemenu-run
|
||||
modules:
|
||||
- name: bemenu-run
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- make bemenu-run x11 wayland curses PREFIX=/app
|
||||
- make install-base install-renderers PREFIX=/app
|
||||
sources:
|
||||
- type: git
|
||||
url: https://github.com/Cloudef/bemenu.git
|
||||
branch: master
|
||||
finish-args:
|
||||
- --share=ipc
|
||||
- --socket=x11
|
||||
- --socket=wayland
|
||||
- --filesystem=host:ro
|
19
.config/dwl/menu/pw.cloudef.bemenu.yml
Normal file
19
.config/dwl/menu/pw.cloudef.bemenu.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
app-id: pw.cloudef.bemenu
|
||||
runtime: org.freedesktop.Platform
|
||||
runtime-version: '20.08'
|
||||
sdk: org.freedesktop.Sdk
|
||||
command: bemenu
|
||||
modules:
|
||||
- name: bemenu
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- make bemenu x11 wayland curses PREFIX=/app
|
||||
- make install-base install-renderers PREFIX=/app
|
||||
sources:
|
||||
- type: git
|
||||
url: https://github.com/Cloudef/bemenu.git
|
||||
branch: master
|
||||
finish-args:
|
||||
- --share=ipc
|
||||
- --socket=x11
|
||||
- --socket=wayland
|
9
.config/dwl/menu/scripts/bemenu
Executable file
9
.config/dwl/menu/scripts/bemenu
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Load Backend
|
||||
export BEMENU_BACKEND=wayland
|
||||
#export BEMENU_BACKEND=x11
|
||||
#export BEMENU_BACKEND=curses
|
||||
|
||||
# Run bemenu
|
||||
LD_LIBRARY_PATH=/usr/lib/ BEMENU_RENDERERS=/usr/lib/bemenu /usr/bin/bemenu-renderer "$@"
|
91
.config/dwl/menu/scripts/bemenu_close
Executable file
91
.config/dwl/menu/scripts/bemenu_close
Executable file
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
|
||||
#######################################################################
|
||||
# bemenu_close - bemenu script for poweroff/reboot/suspend and logout #
|
||||
# #
|
||||
# Author: q3aql <q3aql@duck.com> #
|
||||
# Last update: 03-12-2022 #
|
||||
#######################################################################
|
||||
|
||||
# Configuration variables
|
||||
load_theme_path="${HOME}/.bemenu"
|
||||
load_themes="${load_theme_path}/themes"
|
||||
load_theme_file="${load_theme_path}/load_theme"
|
||||
|
||||
function load_theme() {
|
||||
if [ -f "${load_theme_file}" ] ; then
|
||||
source "${load_theme_file}"
|
||||
else
|
||||
mkdir -p "${load_theme_path}"
|
||||
mkdir -p "${load_themes}"
|
||||
echo "#!/bin/bash" > ${load_theme_file}
|
||||
echo "" >> ${load_theme_file}
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
||||
source "${load_theme_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
function load_session_options() {
|
||||
echo " Restart"
|
||||
echo " Shutdown"
|
||||
echo " Suspend"
|
||||
dwm_session=$(ps -ef | grep " dwm" | grep -v "grep")
|
||||
spectrwm_session=$(ps -ef | grep " spectrwm" | grep -v "grep")
|
||||
qtile_session=$(ps -ef | grep " qtile" | grep -v "grep")
|
||||
sway_session=$(ps -ef | grep " sway" | grep -v "grep")
|
||||
i3_session=$(ps -ef | grep " i3" | grep -v "grep")
|
||||
sessions_check="${dwm_session}${spectrwm_session}${qtile_session}${sway_session}${i3_session}"
|
||||
if [ ! -z "${sessions_check}" ] ; then
|
||||
echo " Logout"
|
||||
fi
|
||||
#generate_spaces 75
|
||||
}
|
||||
|
||||
function close_session() {
|
||||
killall dwm
|
||||
killall spectrwm
|
||||
killall sway
|
||||
killall i3
|
||||
qtile_pid=$(ps -ef | grep " qtile" | grep -v "grep" | tr -s " " | cut -d " " -f 2 | head -1)
|
||||
if [ ! -z ${qtile_pid} ] ; then
|
||||
kill ${qtile_pid}
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_spaces() {
|
||||
num_spaces=${1}
|
||||
count_spaces=1
|
||||
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
||||
echo -n " "
|
||||
count_spaces=$(expr ${count_spaces} + 1)
|
||||
done
|
||||
}
|
||||
|
||||
function run_action() {
|
||||
load_theme
|
||||
systemctl --version &> /dev/null
|
||||
systemd_error=$?
|
||||
if [ ${systemd_error} -eq 0 ] ; then
|
||||
systemctl ${1}
|
||||
else
|
||||
echo > /dev/null | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " You need SystemD for ${1} $(generate_spaces 60)"
|
||||
fi
|
||||
}
|
||||
|
||||
load_theme
|
||||
list_output=$(load_session_options | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " Session:")
|
||||
run_output=$(echo ${list_output} | cut -c 5-999)
|
||||
if [ ! -z "${run_output}" ] ; then
|
||||
if [ "${run_output}" == "Restart" ] ; then
|
||||
run_action "reboot"
|
||||
elif [ "${run_output}" == "Shutdown" ] ; then
|
||||
run_action "poweroff"
|
||||
elif [ "${run_output}" == "Suspend" ] ; then
|
||||
run_action "suspend"
|
||||
elif [ "${run_output}" == "Logout" ] ; then
|
||||
close_session
|
||||
fi
|
||||
fi
|
44
.config/dwl/menu/scripts/bemenu_cmd
Executable file
44
.config/dwl/menu/scripts/bemenu_cmd
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
##############################################################
|
||||
# bemenu_cmd - bemenu script that simulates 'rofi -show run' #
|
||||
# only insert command #
|
||||
# #
|
||||
# Author: q3aql <q3aql@duck.com> #
|
||||
# Last update: 03-12-2022 #
|
||||
##############################################################
|
||||
|
||||
# Configuration variables
|
||||
load_theme_path="${HOME}/.bemenu"
|
||||
load_themes="${load_theme_path}/themes"
|
||||
load_theme_file="${load_theme_path}/load_theme"
|
||||
|
||||
function load_theme() {
|
||||
if [ -f "${load_theme_file}" ] ; then
|
||||
source "${load_theme_file}"
|
||||
else
|
||||
mkdir -p "${load_theme_path}"
|
||||
mkdir -p "${load_themes}"
|
||||
echo "#!/bin/bash" > ${load_theme_file}
|
||||
echo "" >> ${load_theme_file}
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
||||
source "${load_theme_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_spaces() {
|
||||
num_spaces=${1}
|
||||
count_spaces=1
|
||||
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
||||
echo -n " "
|
||||
count_spaces=$(expr ${count_spaces} + 1)
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
load_theme
|
||||
command_run=$(echo > /dev/null | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " command:")
|
||||
${command_run}
|
117
.config/dwl/menu/scripts/bemenu_drun
Executable file
117
.config/dwl/menu/scripts/bemenu_drun
Executable file
|
@ -0,0 +1,117 @@
|
|||
#!/bin/bash
|
||||
|
||||
################################################################
|
||||
# bemenu_drun - bemenu script that simulates 'rofi -show drun' #
|
||||
# #
|
||||
# Author: q3aql <q3aql@duck.com> #
|
||||
# Last update: 03-12-2022 #
|
||||
################################################################
|
||||
|
||||
# Configuration variables
|
||||
load_theme_path="${HOME}/.bemenu"
|
||||
load_themes="${load_theme_path}/themes"
|
||||
load_theme_file="${load_theme_path}/load_theme"
|
||||
load_desktop_files="${HOME}/.bemenu/desktop"
|
||||
desktop_files="/usr/share/applications"
|
||||
desktop_files_home="${HOME}/.local/share/applications"
|
||||
|
||||
function load_theme() {
|
||||
if [ -f "${load_theme_file}" ] ; then
|
||||
source "${load_theme_file}"
|
||||
else
|
||||
mkdir -p "${load_theme_path}"
|
||||
mkdir -p "${load_themes}"
|
||||
echo "#!/bin/bash" > ${load_theme_file}
|
||||
echo "" >> ${load_theme_file}
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
||||
source "${load_theme_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_spaces() {
|
||||
num_spaces=${1}
|
||||
count_spaces=1
|
||||
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
||||
echo -n " "
|
||||
count_spaces=$(expr ${count_spaces} + 1)
|
||||
done
|
||||
}
|
||||
|
||||
function list_desktop_files() {
|
||||
if [ -d "${desktop_files}" ] ; then
|
||||
ls -1 "${desktop_files}/" | grep ".desktop"
|
||||
fi
|
||||
if [ -d "${desktop_files_home}" ] ; then
|
||||
ls -1 "${desktop_files_home}/" | grep ".desktop"
|
||||
fi
|
||||
}
|
||||
|
||||
function list_desktop_icons() {
|
||||
echo " Scan New Desktop Files"
|
||||
ls -1 "${load_desktop_files}/" | while read current_desktop ; do
|
||||
echo " ${current_desktop}"
|
||||
done
|
||||
#generate_spaces 75
|
||||
}
|
||||
|
||||
rundesk () {
|
||||
if [ -z ${1} ] ; then
|
||||
echo "No file entry"
|
||||
else
|
||||
if [ -f "${1}" ] ; then
|
||||
eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1" | head -1)"
|
||||
else
|
||||
echo "File does not exist"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function create_list_files() {
|
||||
mkdir -p ${load_desktop_files}
|
||||
if [ ! -f ${HOME}/.bemenu/read_list ] ; then
|
||||
echo "0" > ${HOME}/.bemenu/read_list
|
||||
fi
|
||||
exec_list=$(cat ${HOME}/.bemenu/read_list)
|
||||
if [ ${exec_list} -eq 0 ] ; then
|
||||
rm -rf ${load_desktop_files}/*
|
||||
list_desktop_files | while read current_file ; do
|
||||
if [ -f "${desktop_files}/${current_file}" ] ; then
|
||||
name_show=$(cat "${desktop_files}/${current_file}" | grep "Name=" | head -1 | cut -d "=" -f 2 | sed 's/\//|/g')
|
||||
if [ ! -z "${name_show}" ] ; then
|
||||
echo "${desktop_files}/${current_file}" > "${load_desktop_files}/${name_show}"
|
||||
fi
|
||||
fi
|
||||
if [ -f "${desktop_files_home}/${current_file}" ] ; then
|
||||
name_show=$(cat "${desktop_files_home}/${current_file}" | grep "Name=" | head -1 | cut -d "=" -f 2 | sed 's/\//|/g')
|
||||
if [ ! -z "${name_show}" ] ; then
|
||||
echo "${desktop_files_home}/${current_file}" > "${load_desktop_files}/${name_show}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "1" > ${HOME}/.bemenu/read_list
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f /usr/bin/dex ] ; then
|
||||
runDesktop="dex"
|
||||
else
|
||||
runDesktop="rundesk"
|
||||
fi
|
||||
|
||||
load_theme
|
||||
create_list_files
|
||||
list_output=$(list_desktop_icons | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " drun:")
|
||||
run_output=$(echo ${list_output} | cut -c 5-999)
|
||||
if [ ! -z "${run_output}" ] ; then
|
||||
if [ "${run_output}" == "Scan New Desktop Files" ] ; then
|
||||
echo "0" > ${HOME}/.bemenu/read_list
|
||||
create_list_files
|
||||
$0
|
||||
else
|
||||
run_desktop_file=$(cat "${load_desktop_files}/${run_output}")
|
||||
${runDesktop} "${run_desktop_file}"
|
||||
fi
|
||||
fi
|
93
.config/dwl/menu/scripts/bemenu_fbrun
Executable file
93
.config/dwl/menu/scripts/bemenu_fbrun
Executable file
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash
|
||||
|
||||
########################################################################
|
||||
# bemenu_fbrun - bemenu script that simulates 'rofi -show filebrowser' #
|
||||
# #
|
||||
# Author: q3aql <q3aql@duck.com> #
|
||||
# Last update: 03-12-2022 #
|
||||
########################################################################
|
||||
|
||||
# Configuration variables
|
||||
load_theme_path="${HOME}/.bemenu"
|
||||
load_themes="${load_theme_path}/themes"
|
||||
load_theme_file="${load_theme_path}/load_theme"
|
||||
|
||||
function load_theme() {
|
||||
if [ -f "${load_theme_file}" ] ; then
|
||||
source "${load_theme_file}"
|
||||
else
|
||||
mkdir -p "${load_theme_path}"
|
||||
mkdir -p "${load_themes}"
|
||||
echo "#!/bin/bash" > ${load_theme_file}
|
||||
echo "" >> ${load_theme_file}
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
||||
source "${load_theme_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_spaces() {
|
||||
num_spaces=${1}
|
||||
count_spaces=1
|
||||
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
||||
echo -n " "
|
||||
count_spaces=$(expr ${count_spaces} + 1)
|
||||
done
|
||||
}
|
||||
|
||||
function show_icon_tree() {
|
||||
ls -1 | while read current ; do
|
||||
if [ -f "${current}" ] ; then
|
||||
echo " ${current}"
|
||||
elif [ -d "${current}" ] ; then
|
||||
echo " ${current}"
|
||||
else
|
||||
echo " ${current}"
|
||||
fi
|
||||
done
|
||||
#generate_spaces 75
|
||||
}
|
||||
|
||||
function remove_icon() {
|
||||
entry="${@}"
|
||||
remove_icon_space=0
|
||||
read_entry=$(echo "${entry}" | grep " ")
|
||||
if ! [ -z "${read_entry}" ] ; then
|
||||
remove_icon_space=1
|
||||
fi
|
||||
read_entry=$(echo "${entry}" | grep " ")
|
||||
if ! [ -z "${read_entry}" ] ; then
|
||||
remove_icon_space=1
|
||||
fi
|
||||
read_entry=$(echo "${entry}" | grep " ")
|
||||
if ! [ -z "${read_entry}" ] ; then
|
||||
remove_icon_space=1
|
||||
fi
|
||||
if [ ${remove_icon_space} -eq 1 ] ; then
|
||||
show_output=$(echo "${entry}" | cut -c4-999 | tr -s " " | cut -c2-999)
|
||||
echo "${show_output}"
|
||||
else
|
||||
echo "${entry}"
|
||||
fi
|
||||
}
|
||||
|
||||
load_theme
|
||||
file=1
|
||||
while [ "${file}" ]; do
|
||||
file_icon=$(show_icon_tree | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " filebrowser: $(basename $(pwd))")
|
||||
file=$(remove_icon "${file_icon}")
|
||||
echo "# ${file} #"
|
||||
if [ -e "${file}" ]; then
|
||||
owd=$(pwd)
|
||||
if [ -d "${file}" ]; then
|
||||
cd "${file}"
|
||||
else [ -f "${file}" ]
|
||||
if which xdg-open &> /dev/null; then
|
||||
exec xdg-open "${owd}/${file}" &
|
||||
unset file
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
71
.config/dwl/menu/scripts/bemenu_run
Executable file
71
.config/dwl/menu/scripts/bemenu_run
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash
|
||||
|
||||
##############################################################
|
||||
# bemenu_run - bemenu script that simulates 'rofi -show run' #
|
||||
# #
|
||||
# Author: q3aql <q3aql@duck.com> #
|
||||
# Last update: 03-12-2022 #
|
||||
##############################################################
|
||||
|
||||
# Configuration variables
|
||||
load_theme_path="${HOME}/.bemenu"
|
||||
load_themes="${load_theme_path}/themes"
|
||||
load_theme_file="${load_theme_path}/load_theme"
|
||||
|
||||
function load_theme() {
|
||||
if [ -f "${load_theme_file}" ] ; then
|
||||
source "${load_theme_file}"
|
||||
else
|
||||
mkdir -p "${load_theme_path}"
|
||||
mkdir -p "${load_themes}"
|
||||
echo "#!/bin/bash" > ${load_theme_file}
|
||||
echo "" >> ${load_theme_file}
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
||||
source "${load_theme_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_spaces() {
|
||||
num_spaces=${1}
|
||||
count_spaces=1
|
||||
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
||||
echo -n " "
|
||||
count_spaces=$(expr ${count_spaces} + 1)
|
||||
done
|
||||
}
|
||||
|
||||
function list_binaries() {
|
||||
binaries=0
|
||||
path_binaries=${PATH}
|
||||
count_path=1
|
||||
while [ ${binaries} -eq 0 ] ; do
|
||||
current_path=$(echo ${path_binaries} | cut -d ":" -f ${count_path})
|
||||
if [ -z "${current_path}" ] ; then
|
||||
binaries=1
|
||||
else
|
||||
# Extra code / When /bin is the same that /usr/bin/
|
||||
bin_same=$(ls -la ${current_path} | grep "> usr/bin")
|
||||
if [ -z "${bin_same}" ] ; then
|
||||
ls -1 ${current_path}/
|
||||
count_path=$(expr ${count_path} + 1)
|
||||
else
|
||||
count_path=$(expr ${count_path} + 1)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function list_binaries_icons() {
|
||||
list_binaries | while read current_binary ; do
|
||||
echo " ${current_binary}"
|
||||
done
|
||||
#generate_spaces 75
|
||||
}
|
||||
|
||||
load_theme
|
||||
list_output=$(list_binaries_icons | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " run:")
|
||||
run_output=$(echo "${list_output}" | cut -c4-999)
|
||||
${run_output}
|
220
.config/dwl/menu/scripts/bemenu_themes
Executable file
220
.config/dwl/menu/scripts/bemenu_themes
Executable file
|
@ -0,0 +1,220 @@
|
|||
#!/bin/bash
|
||||
|
||||
######################################################################
|
||||
# bemenu_themes - bemenu script that simulates 'rofi-theme-selector' #
|
||||
# #
|
||||
# Author: q3aql <q3aql@duck.com> #
|
||||
# Last update: 03-12-2022 #
|
||||
######################################################################
|
||||
|
||||
# Configuration variables
|
||||
load_theme_path="${HOME}/.bemenu"
|
||||
load_themes="${load_theme_path}/themes"
|
||||
load_theme_file="${load_theme_path}/load_theme"
|
||||
|
||||
function load_theme() {
|
||||
if [ -f "${load_theme_file}" ] ; then
|
||||
source "${load_theme_file}"
|
||||
else
|
||||
mkdir -p "${load_theme_path}"
|
||||
mkdir -p "${load_themes}"
|
||||
echo "#!/bin/bash" > ${load_theme_file}
|
||||
echo "" >> ${load_theme_file}
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
||||
source "${load_theme_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
function load_themes_files() {
|
||||
count_themes=$(ls -1 "${load_themes}/" | wc -l)
|
||||
if [ ${count_themes} -lt 18 ] ; then
|
||||
# Default Purple
|
||||
echo "#!/bin/bash" > ${load_themes}/default-purple
|
||||
echo "" >> ${load_themes}/default-purple
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/default-purple
|
||||
echo "NBCOLOR=\"#1f1f35\"" >> ${load_themes}/default-purple
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/default-purple
|
||||
echo "SBCOLOR=\"#664477\"" >> ${load_themes}/default-purple
|
||||
# Cool Green
|
||||
echo "#!/bin/bash" > ${load_themes}/cool-green
|
||||
echo "" >> ${load_themes}/cool-green
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/cool-green
|
||||
echo "NBCOLOR=\"#253829\"" >> ${load_themes}/cool-green
|
||||
echo "SFCOLOR=\"#202118\"" >> ${load_themes}/cool-green
|
||||
echo "SBCOLOR=\"#98c379\"" >> ${load_themes}/cool-green
|
||||
# Dark Grey
|
||||
echo "#!/bin/bash" > ${load_themes}/dark-grey
|
||||
echo "" >> ${load_themes}/dark-grey
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/dark-grey
|
||||
echo "NBCOLOR=\"#0f101a\"" >> ${load_themes}/dark-grey
|
||||
echo "SFCOLOR=\"#0f101a\"" >> ${load_themes}/dark-grey
|
||||
echo "SBCOLOR=\"#f1ffff\"" >> ${load_themes}/dark-grey
|
||||
# Dracula
|
||||
echo "#!/bin/bash" > ${load_themes}/dracula
|
||||
echo "" >> ${load_themes}/dracula
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/dracula
|
||||
echo "NBCOLOR=\"#292d3e\"" >> ${load_themes}/dracula
|
||||
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/dracula
|
||||
echo "SBCOLOR=\"#a77ac4\"" >> ${load_themes}/dracula
|
||||
# Material Darker
|
||||
echo "#!/bin/bash" > ${load_themes}/material-darker
|
||||
echo "" >> ${load_themes}/material-darker
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/material-darker
|
||||
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/material-darker
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/material-darker
|
||||
echo "SBCOLOR=\"#a151d3\"" >> ${load_themes}/material-darker
|
||||
# Material Darker
|
||||
echo "#!/bin/bash" > ${load_themes}/material-darker
|
||||
echo "" >> ${load_themes}/material-darker
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/material-darker
|
||||
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/material-darker
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/material-darker
|
||||
echo "SBCOLOR=\"#a151d3\"" >> ${load_themes}/material-darker
|
||||
# Monokai
|
||||
echo "#!/bin/bash" > ${load_themes}/monokai
|
||||
echo "" >> ${load_themes}/monokai
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/monokai
|
||||
echo "NBCOLOR=\"#1e1e2e\"" >> ${load_themes}/monokai
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/monokai
|
||||
echo "SBCOLOR=\"#a32852\"" >> ${load_themes}/monokai
|
||||
# Monokai Pro
|
||||
echo "#!/bin/bash" > ${load_themes}/monokai-pro
|
||||
echo "" >> ${load_themes}/monokai-pro
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/monokai-pro
|
||||
echo "NBCOLOR=\"#2d2a2e\"" >> ${load_themes}/monokai-pro
|
||||
echo "SFCOLOR=\"#2d2a2e\"" >> ${load_themes}/monokai-pro
|
||||
echo "SBCOLOR=\"#a9dc76\"" >> ${load_themes}/monokai-pro
|
||||
# Nice Blue
|
||||
echo "#!/bin/bash" > ${load_themes}/nice-blue
|
||||
echo "" >> ${load_themes}/nice-blue
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/nice-blue
|
||||
echo "NBCOLOR=\"#1b214a\"" >> ${load_themes}/nice-blue
|
||||
echo "SFCOLOR=\"#eeeeee\"" >> ${load_themes}/nice-blue
|
||||
echo "SBCOLOR=\"#3e4474\"" >> ${load_themes}/nice-blue
|
||||
# Nord
|
||||
echo "#!/bin/bash" > ${load_themes}/nord
|
||||
echo "" >> ${load_themes}/nord
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/nord
|
||||
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/nord
|
||||
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/nord
|
||||
echo "SBCOLOR=\"#81a1c1\"" >> ${load_themes}/nord
|
||||
# Nord Wave
|
||||
echo "#!/bin/bash" > ${load_themes}/nord-wave
|
||||
echo "" >> ${load_themes}/nord-wave
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/nord-wave
|
||||
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/nord-wave
|
||||
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/nord-wave
|
||||
echo "SBCOLOR=\"#ebcb8b\"" >> ${load_themes}/nord-wave
|
||||
# Onedark
|
||||
echo "#!/bin/bash" > ${load_themes}/onedark
|
||||
echo "" >> ${load_themes}/onedark
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/onedark
|
||||
echo "NBCOLOR=\"#1e2127\"" >> ${load_themes}/onedark
|
||||
echo "SFCOLOR=\"#202118\"" >> ${load_themes}/onedark
|
||||
echo "SBCOLOR=\"#98c379\"" >> ${load_themes}/onedark
|
||||
# Orange
|
||||
echo "#!/bin/bash" > ${load_themes}/orange
|
||||
echo "" >> ${load_themes}/orange
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/orange
|
||||
echo "NBCOLOR=\"#22222c\"" >> ${load_themes}/orange
|
||||
echo "SFCOLOR=\"#22222c\"" >> ${load_themes}/orange
|
||||
echo "SBCOLOR=\"#d05a1f\"" >> ${load_themes}/orange
|
||||
# Psychedelic
|
||||
echo "#!/bin/bash" > ${load_themes}/psychedelic
|
||||
echo "" >> ${load_themes}/psychedelic
|
||||
echo "NFCOLOR=\"#98c379\"" >> ${load_themes}/psychedelic
|
||||
echo "NBCOLOR=\"#212121\"" >> ${load_themes}/psychedelic
|
||||
echo "SFCOLOR=\"#ef3a03\"" >> ${load_themes}/psychedelic
|
||||
echo "SBCOLOR=\"#5457a9\"" >> ${load_themes}/psychedelic
|
||||
# Red Sea
|
||||
echo "#!/bin/bash" > ${load_themes}/red-sea
|
||||
echo "" >> ${load_themes}/red-sea
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/red-sea
|
||||
echo "NBCOLOR=\"#941835\"" >> ${load_themes}/red-sea
|
||||
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/red-sea
|
||||
echo "SBCOLOR=\"#c62570\"" >> ${load_themes}/red-sea
|
||||
# Rosepine
|
||||
echo "#!/bin/bash" > ${load_themes}/rosepine
|
||||
echo "" >> ${load_themes}/rosepine
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/rosepine
|
||||
echo "NBCOLOR=\"#1f1d29\"" >> ${load_themes}/rosepine
|
||||
echo "SFCOLOR=\"#292d3e\"" >> ${load_themes}/rosepine
|
||||
echo "SBCOLOR=\"#eabbb9\"" >> ${load_themes}/rosepine
|
||||
# Sunset
|
||||
echo "#!/bin/bash" > ${load_themes}/sunset
|
||||
echo "" >> ${load_themes}/sunset
|
||||
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_themes}/sunset
|
||||
echo "NBCOLOR=\"#9b3800\"" >> ${load_themes}/sunset
|
||||
echo "SFCOLOR=\"#22222c\"" >> ${load_themes}/sunset
|
||||
echo "SBCOLOR=\"#c59a4d\"" >> ${load_themes}/sunset
|
||||
# White Heaven
|
||||
echo "#!/bin/bash" > ${load_themes}/white-heaven
|
||||
echo "" >> ${load_themes}/white-heaven
|
||||
echo "NFCOLOR=\"#2d2d37\"" >> ${load_themes}/white-heaven
|
||||
echo "NBCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-heaven
|
||||
echo "SFCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-heaven
|
||||
echo "SBCOLOR=\"#2d2d37\"" >> ${load_themes}/white-heaven
|
||||
# White Wine
|
||||
echo "#!/bin/bash" > ${load_themes}/white-wine
|
||||
echo "" >> ${load_themes}/white-wine
|
||||
echo "NFCOLOR=\"#861616\"" >> ${load_themes}/white-wine
|
||||
echo "NBCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-wine
|
||||
echo "SFCOLOR=\"#a9a8a7\"" >> ${load_themes}/white-wine
|
||||
echo "SBCOLOR=\"#861616\"" >> ${load_themes}/white-wine
|
||||
fi
|
||||
}
|
||||
|
||||
function generate_spaces() {
|
||||
num_spaces=${1}
|
||||
count_spaces=1
|
||||
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
||||
echo -n " "
|
||||
count_spaces=$(expr ${count_spaces} + 1)
|
||||
done
|
||||
}
|
||||
|
||||
function show_icon_tree() {
|
||||
ls -1 ${load_themes} | while read current ; do
|
||||
if [ -f "${load_themes}/${current}" ] ; then
|
||||
echo " ${current}"
|
||||
else
|
||||
echo " ${current}"
|
||||
fi
|
||||
done
|
||||
#generate_spaces 75
|
||||
}
|
||||
|
||||
function remove_icon() {
|
||||
entry="${@}"
|
||||
remove_icon_space=0
|
||||
read_entry=$(echo "${entry}" | grep " ")
|
||||
if ! [ -z "${read_entry}" ] ; then
|
||||
remove_icon_space=1
|
||||
fi
|
||||
if [ ${remove_icon_space} -eq 1 ] ; then
|
||||
show_output=$(echo "${entry}" | cut -c4-999 | tr -s " " | cut -c2-999)
|
||||
echo "${show_output}"
|
||||
else
|
||||
echo "${entry}"
|
||||
fi
|
||||
}
|
||||
|
||||
function load_theme_selector() {
|
||||
file_icon=$(show_icon_tree | bemenu -c -i -W 0.5 --fn 'UbuntuMono Nerd Font 14' --tb "${SBCOLOR}" --tf "${SFCOLOR}" --fb "${NBCOLOR}" --ff "${NFCOLOR}" --nb "${NBCOLOR}" --ab "${NBCOLOR}" --nf "${NFCOLOR}" --af "${NFCOLOR}" --sb "${SBCOLOR}" --sf "${SFCOLOR}" --hb "${SBCOLOR}" --hf "${SFCOLOR}" -l 18 -p " Theme:")
|
||||
file=$(remove_icon "${file_icon}")
|
||||
if [ -z "${file}" ] ; then
|
||||
echo "# Theme selector canceled"
|
||||
else
|
||||
cp -rf ${load_themes}/${file} ${load_theme_file}
|
||||
load_theme
|
||||
load_theme_selector
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function for load theme
|
||||
load_theme
|
||||
load_themes_files
|
||||
load_theme_selector
|
42
.config/dwl/menu/scripts/check-symbols.sh
Normal file
42
.config/dwl/menu/scripts/check-symbols.sh
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
# Check that no internal symbols are being leaked from the library
|
||||
# $1: path to the .so
|
||||
# $2: path to the lib/bemenu.h
|
||||
|
||||
hash grep nm sort awk comm printf cat touch
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
grep '^BM_PUBLIC' "$2" | grep -o '[a-z_]*(' | grep -o '[a-z_]*' | awk 'NF' | sort > "$tmp/hdr.txt"
|
||||
|
||||
nm --extern-only "$1" |\
|
||||
awk '/T/{if (substr($3,1,1) == "_") print substr($3, 2); else print $3}' |\
|
||||
grep -o '[a-z_]*' | awk 'NF' | sort > "$tmp/lib.txt"
|
||||
|
||||
comm -13 "$tmp/hdr.txt" "$tmp/lib.txt" > "$tmp/leaks.txt"
|
||||
comm -23 "$tmp/hdr.txt" "$tmp/lib.txt" > "$tmp/missing.txt"
|
||||
|
||||
if [ -s "$tmp/leaks.txt" ]; then
|
||||
printf 'SYMBOL LEAKAGE: following symbols should not be marked BM_PUBLIC:\n'
|
||||
cat "$tmp/leaks.txt" | awk '$0="> "$0'
|
||||
touch "$tmp/failure"
|
||||
fi
|
||||
|
||||
if [ -s "$tmp/missing.txt" ]; then
|
||||
printf 'SYMBOL MISSING: following BM_PUBLIC symbols were not found from the binary:\n'
|
||||
cat "$tmp/missing.txt" | awk '$0="> "$0'
|
||||
touch "$tmp/failure"
|
||||
fi
|
||||
|
||||
shift 2
|
||||
for renderer in "$@"; do
|
||||
nm --extern-only "$renderer" | awk '/T/{print $3}' | grep -v register_renderer | awk 'NF' > "$tmp/${renderer}_leaks.txt"
|
||||
if [ -s "$tmp/${renderer}_leaks.txt" ]; then
|
||||
printf 'SYMBOL LEAKAGE: %s should only have a register_renderer symbol visible\n' "$renderer"
|
||||
cat "$tmp/${renderer}_leaks.txt" | awk '$0="> "$0'
|
||||
touch "$tmp/failure"
|
||||
fi
|
||||
done
|
||||
|
||||
test -f "$tmp/failure" && exit 1 || exit 0
|
51
.config/dwl/scripts/dwlbar.sh
Executable file
51
.config/dwl/scripts/dwlbar.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
echo '| 1!| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |'
|
||||
fname="/tmp/dwltags-$WAYLAND_DISPLAY";
|
||||
while true
|
||||
do
|
||||
#make sure the file exists
|
||||
while [ ! -f $fname ]
|
||||
do
|
||||
inotifywait -qqe create `dirname $fname`
|
||||
done;
|
||||
|
||||
#wait for dwl to close it after writing
|
||||
inotifywait -qqe close_write $fname
|
||||
|
||||
titleline=$1
|
||||
tagline=$((titleline+1))
|
||||
|
||||
title=`sed "$titleline!d" $fname`
|
||||
taginfo=`sed "$tagline!d" $fname`
|
||||
|
||||
isactive=`echo "$taginfo" | cut -d ' ' -f 1`
|
||||
|
||||
ctags=`echo "$taginfo" | cut -d ' ' -f 2`
|
||||
|
||||
mtags=`echo "$taginfo" | cut -d ' ' -f 3`
|
||||
|
||||
layout=`echo "$taginfo" | cut -d ' ' -f 4-`
|
||||
|
||||
for i in {0..8};
|
||||
do
|
||||
|
||||
mask=$((1<<i))
|
||||
if (( "$ctags" & $mask ));
|
||||
then
|
||||
n="*$((i+1))"
|
||||
else
|
||||
n=" $((i+1))"
|
||||
fi
|
||||
if (( "$mtags" & $mask ));
|
||||
then
|
||||
echo -n "|$n!"
|
||||
else
|
||||
echo -n "|$n "
|
||||
fi
|
||||
done
|
||||
echo "| $layout $title"
|
||||
|
||||
|
||||
done
|
72
.config/dwl/scripts/wayland-screenshot
Executable file
72
.config/dwl/scripts/wayland-screenshot
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
|
||||
FILEDIR=~/Downloads
|
||||
OPTION=()
|
||||
|
||||
values=$(zenity \
|
||||
--title=wayland-screenshot \
|
||||
--text="Option" \
|
||||
--forms \
|
||||
--add-combo="Mode" \
|
||||
--combo-values="All screen|Specific window|Specific area" \
|
||||
--add-combo="Include cursor[default: no]" \
|
||||
--combo-values="no|yes" \
|
||||
--add-entry="time to wait[default: 0s]" \
|
||||
--add-combo="Copy to clipboard[default: yes]" \
|
||||
--combo-values="yes|no" \
|
||||
)
|
||||
|
||||
result=$?
|
||||
|
||||
mode=$(echo $values | cut -d '|' -f 1)
|
||||
cursor=$(echo $values | cut -d '|' -f 2)
|
||||
wait=$(echo $values | cut -d '|' -f 3)
|
||||
clipboard=$(echo $values | cut -d '|' -f 4)
|
||||
|
||||
if [ "$result" -eq 1 ];then # select cancel
|
||||
echo "canceling"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -z "$cursor" ] && [ "$cursor" == yes ];then
|
||||
OPTION+="-c"
|
||||
fi
|
||||
|
||||
if [ -z "$mode" ] ;then # select nothing
|
||||
echo "mode is null"
|
||||
zenity \
|
||||
--title=wayland-screenshot \
|
||||
--width=200 \
|
||||
--warning \
|
||||
--text="Mode empty"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -z "$wait" ];then
|
||||
sleep $wait
|
||||
fi
|
||||
|
||||
if [ "$mode" == "All screen" ];then # select All screen
|
||||
true
|
||||
elif [ "$mode" == "Specific window" ];then # select specify window
|
||||
GEO="$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)"
|
||||
elif [ "$mode" == "Specific area" ];then # select specfy area
|
||||
GEO="$(slurp)"
|
||||
else # error
|
||||
echo $mode
|
||||
fi
|
||||
|
||||
if [ -z "$clipboard" ] || [ "$clipboard" == yes ];then
|
||||
if [ -z "$GEO" ]; then
|
||||
grim $OPTION - | wl-copy;
|
||||
else
|
||||
grim $OPTION -g "$GEO" - | wl-copy;
|
||||
fi
|
||||
else
|
||||
if [ -z "$GEO" ]; then
|
||||
grim $OPTION $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png
|
||||
else
|
||||
grim $OPTION -g "$GEO" $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user