diff --git a/.gitignore b/.gitignore index 5c28541..0dde90e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dwl *-protocol.c *-protocol.h .ccls-cache +config.h diff --git a/Makefile b/Makefile index 974a852..578194f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -1.POSIX: +.POSIX: .SUFFIXES: include config.mk @@ -12,19 +12,17 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \ -Wfloat-conversion # CFLAGS / LDFLAGS -PKGS = wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS) +PKGS = wayland-server xkbcommon libinput $(XLIBS) DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS) all: dwl -dwl: dwl.o util.o dwl-ipc-unstable-v2-protocol.o - $(CC) dwl.o util.o dwl-ipc-unstable-v2-protocol.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ +dwl: dwl.o util.o + $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \ pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \ - wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \ - dwl-ipc-unstable-v2-protocol.h + wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h util.o: util.c util.h -dwl-ipc-unstable-v2-protocol.o: dwl-ipc-unstable-v2-protocol.c dwl-ipc-unstable-v2-protocol.h # wayland-scanner is a tool which generates C headers and rigging for Wayland # protocols, which are specified in XML. wlroots requires you to rig these up @@ -47,12 +45,6 @@ wlr-output-power-management-unstable-v1-protocol.h: xdg-shell-protocol.h: $(WAYLAND_SCANNER) server-header \ $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ -dwl-ipc-unstable-v2-protocol.h: - $(WAYLAND_SCANNER) server-header \ - protocols/dwl-ipc-unstable-v2.xml $@ -dwl-ipc-unstable-v2-protocol.c: - $(WAYLAND_SCANNER) private-code \ - protocols/dwl-ipc-unstable-v2.xml $@ config.h: cp config.def.h $@ diff --git a/README.md b/README.md index 38211c4..390788d 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,5 @@ # dwl - dwm for Wayland -2025-08-16: -dwl IS CURRENTLY UN-MAINTAINED. -AT THE PRESENT TIME, I (@fauxmight) DO NOT HAVE -THE TIME OR CAPACITY TO KEEP UP WITH [wlroots] CHANGES. -IF YOU ARE INTERESTED IN TAKING ON LEAD DEVELOPER RESPONSIBILITIES, -SEE ISSUE [#1166](https://codeberg.org/dwl/dwl/issues/1166). ---- - Join us on our IRC channel: [#dwl on Libera Chat] Or on the community-maintained [Discord server]. diff --git a/client.h b/client.h index 7a7792d..d9f90bb 100644 --- a/client.h +++ b/client.h @@ -318,12 +318,6 @@ client_set_border_color(Client *c, const float color[static 4]) wlr_scene_rect_set_color(c->border[i], color); } -static inline void -client_set_dimmer_state(Client *c, const int dim) -{ - wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim); -} - static inline void client_set_fullscreen(Client *c, int fullscreen) { diff --git a/config.def.h b/config.def.h index c745b6b..95c2afa 100644 --- a/config.def.h +++ b/config.def.h @@ -10,20 +10,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const float rootcolor[] = COLOR(0x222222ff); static const float bordercolor[] = COLOR(0x444444ff); static const float focuscolor[] = COLOR(0x005577ff); -static const float unfocuseddim[] = COLOR(0x00000088); static const float urgentcolor[] = COLOR(0xff0000ff); -static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = {"monospace:size=10"}; -static const float rootcolor[] = COLOR(0x000000ff); - -static uint32_t colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff }, - [SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff }, - [SchemeUrg] = { 0, 0, 0x770000ff }, -}; - /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ @@ -35,14 +22,10 @@ static int log_level = WLR_ERROR; /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ static const Rule rules[] = { - /* app_id title tags mask isfloating neverdim monitor */ - /* examples: - { "Gimp_example", NULL, 0, 1, 0, -1 }, - */ - { "firefox-developer-edition", NULL, 1 << 8, 0, 1, -1 }, - { "idea", NULL, 1 << 0, 0, 1, -1}, - { "vesktop", NULL, 1 << 1, 0, 1, -1 }, - { "thunderbird", NULL, 1 << 2, 0, 1, -1 } + /* app_id title tags mask isfloating monitor */ + /* examples: */ + { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */ + { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */ }; /* layout(s) */ @@ -61,11 +44,11 @@ static const Layout layouts[] = { /* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */ static const MonitorRule monrules[] = { /* name mfact nmaster scale layout rotate/reflect x y */ - // example of a HiDPI laptop monitor: - { "HDMI-A-1", 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, - // + /* example of a HiDPI laptop monitor: + { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, + */ /* defaults */ - { NULL, 0.55f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, + { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, }; /* keyboard */ @@ -74,12 +57,11 @@ static const struct xkb_rule_names xkb_rules = { /* example: .options = "ctrl:nocaps", */ - .layout = "us,gr", - .options = "grp:win_space_toggle", + .options = NULL, }; -static const int repeat_rate = 50; -static const int repeat_delay = 250; +static const int repeat_rate = 25; +static const int repeat_delay = 600; /* Trackpad */ static const int tap_to_click = 1; @@ -115,7 +97,7 @@ static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE */ -static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; +static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; static const double accel_speed = 0.0; /* You can choose between: @@ -131,60 +113,20 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }, \ - { WLR_MODIFIER_ALT, KEY, focusnthmon, {.ui = TAG} }, \ - { WLR_MODIFIER_ALT|WLR_MODIFIER_SHIFT, SKEY, tagnthmon, {.ui = TAG} } - + { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} } /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ -static const char *termcmd[] = { "foot", - "-f", "BlexMono Nerd Font:size=16", - "fish", - NULL -}; -static const char *menucmd[] = { - "wmenu-run", - "-f", "BlexMono Nerd Font Normal 16", - "-b", - "-S", "026873", - "-N", "181926", - NULL -}; -static const char *lockcmd[] = { "swaylock", NULL }; -static const char *fmcmd[] = { "pcmanfm", NULL }; -static const char *screencmd[] = {"screenshot.sh", NULL }; -static const char *screenfilecmd[] = {"screenshot-file.sh", NULL }; -static const char *zellijcmd[] = { - "foot", - "-f", "BlexMono Nerd Font:size=16", - "zellij", - NULL -}; -static const char *volcmdup[] = { - "vol.sh", - "up", - NULL -}; -static const char *volcmddown[] = { - "vol.sh", - "down", - NULL -}; -static const char *volcmdzero[] = { - "vol.sh", - "mute", - NULL -}; +static const char *termcmd[] = { "foot", NULL }; +static const char *menucmd[] = { "wmenu-run", NULL }; + 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|WLR_MODIFIER_SHIFT, XKB_KEY_Z, spawn, {.v = zellijcmd} }, - { MODKEY, XKB_KEY_w, spawn, {.v = fmcmd} }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, @@ -192,21 +134,14 @@ static const Key keys[] = { { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} }, { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, { 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_L, spawn, {.v = lockcmd} }, - { 0, XKB_KEY_Print, spawn, {.v = screencmd} }, - { MODKEY, XKB_KEY_Print, spawn, {.v = screenfilecmd} }, + { MODKEY, XKB_KEY_Tab, view, {0} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} }, { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, - { 0, XKB_KEY_XF86AudioLowerVolume, spawn, {.v = volcmddown} }, - { 0, XKB_KEY_XF86AudioRaiseVolume, spawn, {.v = volcmdup} }, - { 0, XKB_KEY_XF86AudioMute, spawn, {.v = volcmdzero} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, - { MODKEY, XKB_KEY_apostrophe, toggledimming, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, - { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, + { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, @@ -237,6 +172,5 @@ static const Key keys[] = { static const Button buttons[] = { { MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, { MODKEY, BTN_MIDDLE, togglefloating, {0} }, - { MODKEY|WLR_MODIFIER_SHIFT, BTN_MIDDLE, toggledimmingclient, {0} }, { MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, }; diff --git a/config.h b/config.h deleted file mode 100644 index 8dd33b6..0000000 --- a/config.h +++ /dev/null @@ -1,248 +0,0 @@ -/* Taken from https://github.com/djpohly/dwl/issues/466 */ -#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \ - ((hex >> 16) & 0xFF) / 255.0f, \ - ((hex >> 8) & 0xFF) / 255.0f, \ - (hex & 0xFF) / 255.0f } -/* appearance */ -static const int sloppyfocus = 1; /* focus follows mouse */ -static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const float rootcolor[] = COLOR(0x222222ff); -static const float bordercolor[] = COLOR(0x444444ff); -static const float focuscolor[] = COLOR(0x005577ff); -static const float unfocuseddim[] = COLOR(0x00000088); -static const float urgentcolor[] = COLOR(0xff0000ff); -static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = {"monospace:size=10"}; -static uint32_t colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff }, - [SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff }, - [SchemeUrg] = { 0, 0, 0x770000ff }, -}; -/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ -static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ - -/* tagging - TAGCOUNT must be no greater than 31 */ -static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; - -/* logging */ -static int log_level = WLR_ERROR; - -/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ -static const Rule rules[] = { - /* app_id title tags mask isfloating neverdim monitor */ - /* examples: - { "Gimp_example", NULL, 0, 1, 0, -1 }, - */ - { "firefox-developer-edition", NULL, 1 << 8, 0, 1, -1 }, - { "idea", NULL, 1 << 0, 0, 1, -1}, - { "vesktop", NULL, 1 << 1, 0, 1, -1 }, - { "thunderbird", NULL, 1 << 2, 0, 1, -1 } -}; - -/* layout(s) */ -static const Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, -}; - -/* monitors */ -/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator - * WARNING: negative values other than (-1, -1) cause problems with Xwayland clients - * https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 -*/ -/* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */ -static const MonitorRule monrules[] = { - /* name mfact nmaster scale layout rotate/reflect x y */ - // example of a HiDPI laptop monitor: - { "HDMI-A-1", 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, - // - /* defaults */ - { NULL, 0.55f, 1, 1.33, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, -}; - -/* keyboard */ -static const struct xkb_rule_names xkb_rules = { - /* can specify fields: rules, model, layout, variant, options */ - /* example: - .options = "ctrl:nocaps", - */ - .layout = "us,gr", - .options = "grp:win_space_toggle", -}; - -static const int repeat_rate = 50; -static const int repeat_delay = 250; - -/* Trackpad */ -static const int tap_to_click = 1; -static const int tap_and_drag = 1; -static const int drag_lock = 1; -static const int natural_scrolling = 0; -static const int disable_while_typing = 1; -static const int left_handed = 0; -static const int middle_button_emulation = 0; -/* You can choose between: -LIBINPUT_CONFIG_SCROLL_NO_SCROLL -LIBINPUT_CONFIG_SCROLL_2FG -LIBINPUT_CONFIG_SCROLL_EDGE -LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN -*/ -static const enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG; - -/* You can choose between: -LIBINPUT_CONFIG_CLICK_METHOD_NONE -LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS -LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER -*/ -static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; - -/* You can choose between: -LIBINPUT_CONFIG_SEND_EVENTS_ENABLED -LIBINPUT_CONFIG_SEND_EVENTS_DISABLED -LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE -*/ -static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; - -/* You can choose between: -LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT -LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE -*/ -static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; -static const double accel_speed = 0.0; - -/* You can choose between: -LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle -LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right -*/ -static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM; - -/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */ -#define MODKEY WLR_MODIFIER_ALT - -#define TAGKEYS(KEY,SKEY,TAG) \ - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }, \ - { WLR_MODIFIER_ALT, KEY, focusnthmon, {.ui = TAG} }, \ - { WLR_MODIFIER_ALT|WLR_MODIFIER_SHIFT, SKEY, tagnthmon, {.ui = TAG} } - - -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } - -/* commands */ -static const char *termcmd[] = { "foot", - "-f", "BlexMono Nerd Font:size=16", - "fish", - NULL -}; -static const char *menucmd[] = { - "wmenu-run", - "-b", - NULL -}; -static const char *lockcmd[] = { "swaylock", NULL }; -static const char *fmcmd[] = { "pcmanfm", NULL }; -static const char *screencmd[] = {"screenshot.sh", NULL }; -static const char *screenfilecmd[] = {"screenshot-file.sh", NULL }; -static const char *zellijcmd[] = { - "foot", - "-f", "BlexMono Nerd Font:size=16", - "zellij", - NULL -}; -static const char *volcmdup[] = { - "vol.sh", - "up", - NULL -}; -static const char *volcmddown[] = { - "vol.sh", - "down", - NULL -}; -static const char *volcmdzero[] = { - "vol.sh", - "mute", - NULL -}; -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, XKB_KEY_b, togglebar, {0} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Z, spawn, {.v = zellijcmd} }, - { MODKEY, XKB_KEY_w, spawn, {.v = fmcmd} }, - { 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, XKB_KEY_h, setmfact, {.f = -0.05f} }, - { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, - { 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_L, spawn, {.v = lockcmd} }, - { 0, XKB_KEY_Print, spawn, {.v = screencmd} }, - { MODKEY, XKB_KEY_Print, spawn, {.v = screenfilecmd} }, - { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, - { 0, XKB_KEY_XF86AudioLowerVolume, spawn, {.v = volcmddown} }, - { 0, XKB_KEY_XF86AudioRaiseVolume, spawn, {.v = volcmdup} }, - { 0, XKB_KEY_XF86AudioMute, spawn, {.v = volcmdzero} }, - { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XKB_KEY_space, setlayout, {0} }, - { MODKEY, XKB_KEY_apostrophe, toggledimming, {0} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, - { MODKEY, XKB_KEY_e, 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} }, - TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), - TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), - TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), - TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3), - TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4), - TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5), - 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} }, - - /* 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} }, - /* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is - * do not remove them. - */ -#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} } - CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6), - CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12), -}; - -static const Button buttons[] = { - // { MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, - // { MODKEY, BTN_MIDDLE, togglefloating, {0} }, - // { MODKEY|WLR_MODIFIER_SHIFT, BTN_MIDDLE, toggledimmingclient, {0} }, - // { MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, - { ClkLtSymbol, 0, BTN_LEFT, setlayout, {.v = &layouts[0]} }, - { ClkLtSymbol, 0, BTN_RIGHT, setlayout, {.v = &layouts[2]} }, - { ClkTitle, 0, BTN_MIDDLE, zoom, {0} }, - { ClkStatus, 0, BTN_MIDDLE, spawn, {.v = termcmd} }, - { ClkClient, MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, - { ClkClient, MODKEY, BTN_MIDDLE, togglefloating, {0} }, - { ClkClient, MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, - { ClkTagBar, 0, BTN_LEFT, view, {0} }, - { ClkTagBar, 0, BTN_RIGHT, toggleview, {0} }, - { ClkTagBar, MODKEY, BTN_LEFT, tag, {0} }, - { ClkTagBar, MODKEY, BTN_RIGHT, toggletag, {0} }, -}; diff --git a/config.mk b/config.mk index 2065142..eb08a05 100644 --- a/config.mk +++ b/config.mk @@ -24,9 +24,11 @@ WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19` # -I$(PWD)/wlroots/0.19/include/wlroots-0.19 #WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.19/lib64 -L$(PWD)/wlroots/0.19/lib64 -lwlroots-0.19 +XWAYLAND = +XLIBS = # Uncomment to build XWayland support -XWAYLAND = -DXWAYLAND -XLIBS = xcb xcb-icccm +#XWAYLAND = -DXWAYLAND +#XLIBS = xcb xcb-icccm # dwl itself only uses C99 features, but wlroots' headers use anonymous unions (C11). # To avoid warnings about them, we do not use -std=c99 and instead of using the diff --git a/drwl.h b/drwl.h deleted file mode 100644 index 21afd21..0000000 --- a/drwl.h +++ /dev/null @@ -1,310 +0,0 @@ -/* - * drwl - https://codeberg.org/sewn/drwl - * - * Copyright (c) 2023-2025 sewn - * Copyright (c) 2024 notchoc - * - * 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 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. - * - * The UTF-8 Decoder included is from Bjoern Hoehrmann: - * Copyright (c) 2008-2010 Bjoern Hoehrmann - * See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. - */ -#pragma once - -#include -#include -#include - -enum { ColFg, ColBg, ColBorder }; /* colorscheme index */ - -typedef struct fcft_font Fnt; -typedef pixman_image_t Img; - -typedef struct { - Img *image; - Fnt *font; - uint32_t *scheme; -} Drwl; - -#define UTF8_ACCEPT 0 -#define UTF8_REJECT 12 -#define UTF8_INVALID 0xFFFD - -static const uint8_t utf8d[] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, - - 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, - 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, - 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, - 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, - 12,36,12,12,12,12,12,12,12,12,12,12, -}; - -static inline uint32_t -utf8decode(uint32_t *state, uint32_t *codep, uint8_t byte) -{ - uint32_t type = utf8d[byte]; - - *codep = (*state != UTF8_ACCEPT) ? - (byte & 0x3fu) | (*codep << 6) : - (0xff >> type) & (byte); - - *state = utf8d[256 + *state + type]; - return *state; -} - -static int -drwl_init(void) -{ - return fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR); -} - -static Drwl * -drwl_create(void) -{ - Drwl *drwl; - - if (!(drwl = calloc(1, sizeof(Drwl)))) - return NULL; - - return drwl; -} - -static void -drwl_setfont(Drwl *drwl, Fnt *font) -{ - if (drwl) - drwl->font = font; -} - -static void -drwl_setimage(Drwl *drwl, Img *image) -{ - if (drwl) - drwl->image = image; -} - -static Fnt * -drwl_font_create(Drwl *drwl, size_t count, - const char *names[static count], const char *attributes) -{ - Fnt *font = fcft_from_name(count, names, attributes); - if (drwl) - drwl_setfont(drwl, font); - return font; -} - -static void -drwl_font_destroy(Fnt *font) -{ - fcft_destroy(font); -} - -static inline pixman_color_t -convert_color(uint32_t clr) -{ - return (pixman_color_t){ - ((clr >> 24) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF, - ((clr >> 16) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF, - ((clr >> 8) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF, - (clr & 0xFF) * 0x101 - }; -} - -static void -drwl_setscheme(Drwl *drwl, uint32_t *scm) -{ - if (drwl) - drwl->scheme = scm; -} - -static Img * -drwl_image_create(Drwl *drwl, unsigned int w, unsigned int h, uint32_t *bits) -{ - Img *image; - pixman_region32_t clip; - - image = pixman_image_create_bits_no_clear( - PIXMAN_a8r8g8b8, w, h, bits, w * 4); - if (!image) - return NULL; - pixman_region32_init_rect(&clip, 0, 0, w, h); - pixman_image_set_clip_region32(image, &clip); - pixman_region32_fini(&clip); - - if (drwl) - drwl_setimage(drwl, image); - return image; -} - -static void -drwl_rect(Drwl *drwl, - int x, int y, unsigned int w, unsigned int h, - int filled, int invert) -{ - pixman_color_t clr; - if (!drwl || !drwl->scheme || !drwl->image) - return; - - clr = convert_color(drwl->scheme[invert ? ColBg : ColFg]); - if (filled) - pixman_image_fill_rectangles(PIXMAN_OP_SRC, drwl->image, &clr, 1, - &(pixman_rectangle16_t){x, y, w, h}); - else - pixman_image_fill_rectangles(PIXMAN_OP_SRC, drwl->image, &clr, 4, - (pixman_rectangle16_t[4]){ - { x, y, w, 1 }, - { x, y + h - 1, w, 1 }, - { x, y, 1, h }, - { x + w - 1, y, 1, h }}); -} - -static int -drwl_text(Drwl *drwl, - int x, int y, unsigned int w, unsigned int h, - unsigned int lpad, const char *text, int invert) -{ - int ty; - int render = x || y || w || h; - long x_kern; - uint32_t cp = 0, last_cp = 0, state; - pixman_color_t clr; - pixman_image_t *fg_pix = NULL; - int noellipsis = 0; - const struct fcft_glyph *glyph, *eg = NULL; - int fcft_subpixel_mode = FCFT_SUBPIXEL_DEFAULT; - - if (!drwl || (render && (!drwl->scheme || !w || !drwl->image)) || !text || !drwl->font) - return 0; - - if (!render) { - w = invert ? invert : ~invert; - } else { - clr = convert_color(drwl->scheme[invert ? ColBg : ColFg]); - fg_pix = pixman_image_create_solid_fill(&clr); - - drwl_rect(drwl, x, y, w, h, 1, !invert); - - x += lpad; - w -= lpad; - } - - if (render && (drwl->scheme[ColBg] & 0xFF) != 0xFF) - fcft_subpixel_mode = FCFT_SUBPIXEL_NONE; - - if (render) - eg = fcft_rasterize_char_utf32(drwl->font, 0x2026 /* … */, fcft_subpixel_mode); - - for (const char *p = text, *pp; pp = p, *p; p++) { - for (state = UTF8_ACCEPT; *p && - utf8decode(&state, &cp, *p) > UTF8_REJECT; p++) - ; - if (!*p || state == UTF8_REJECT) { - cp = UTF8_INVALID; - if (p > pp) - p--; - } - - glyph = fcft_rasterize_char_utf32(drwl->font, cp, fcft_subpixel_mode); - if (!glyph) - continue; - - x_kern = 0; - if (last_cp) - fcft_kerning(drwl->font, last_cp, cp, &x_kern, NULL); - last_cp = cp; - - ty = y + (h - drwl->font->height) / 2 + drwl->font->ascent; - - if (render && !noellipsis && x_kern + glyph->advance.x + eg->advance.x > w && - *(p + 1) != '\0') { - /* cannot fit ellipsis after current codepoint */ - if (drwl_text(drwl, 0, 0, 0, 0, 0, pp, 0) + x_kern <= w) { - noellipsis = 1; - } else { - w -= eg->advance.x; - pixman_image_composite32( - PIXMAN_OP_OVER, fg_pix, eg->pix, drwl->image, 0, 0, 0, 0, - x + eg->x, ty - eg->y, eg->width, eg->height); - } - } - - if ((x_kern + glyph->advance.x) > w) - break; - - x += x_kern; - - if (render && pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8) - /* pre-rendered glyphs (eg. emoji) */ - pixman_image_composite32( - PIXMAN_OP_OVER, glyph->pix, NULL, drwl->image, 0, 0, 0, 0, - x + glyph->x, ty - glyph->y, glyph->width, glyph->height); - else if (render) - pixman_image_composite32( - PIXMAN_OP_OVER, fg_pix, glyph->pix, drwl->image, 0, 0, 0, 0, - x + glyph->x, ty - glyph->y, glyph->width, glyph->height); - - x += glyph->advance.x; - w -= glyph->advance.x; - } - - if (render) - pixman_image_unref(fg_pix); - - return x + (render ? w : 0); -} - -static unsigned int -drwl_font_getwidth(Drwl *drwl, const char *text) -{ - if (!drwl || !drwl->font || !text) - return 0; - return drwl_text(drwl, 0, 0, 0, 0, 0, text, 0); -} - -static void -drwl_image_destroy(Img *image) -{ - pixman_image_unref(image); -} - -static void -drwl_destroy(Drwl *drwl) -{ - if (drwl->font) - drwl_font_destroy(drwl->font); - if (drwl->image) - drwl_image_destroy(drwl->image); - free(drwl); -} - -static void -drwl_fini(void) -{ - fcft_fini(); -} diff --git a/dwl.c b/dwl.c index 3c524a5..12f441e 100644 --- a/dwl.c +++ b/dwl.c @@ -1,12 +1,10 @@ /* * See LICENSE file for copyright and license details. */ -#include #include #include #include #include -#include #include #include #include @@ -14,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -72,9 +68,7 @@ #include #endif -#include "dwl-ipc-unstable-v2-protocol.h" #include "util.h" -#include "drwl.h" /* macros */ #define MAX(A, B) ((A) > (B) ? (A) : (B)) @@ -83,17 +77,14 @@ #define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) #define END(A) ((A) + LENGTH(A)) -#define TAGMASK ((1u << LENGTH(tags)) - 1) +#define TAGMASK ((1u << TAGCOUNT) - 1) #define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L))) #define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0) -#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad) /* enums */ -enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */ enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ enum { XDGShell, LayerShell, X11 }; /* client types */ enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */ -enum { ClkTagBar, ClkLtSymbol, ClkStatus, ClkTitle, ClkClient, ClkRoot }; /* clicks */ typedef union { int i; @@ -103,7 +94,6 @@ typedef union { } Arg; typedef struct { - unsigned int click; unsigned int mod; unsigned int button; void (*func)(const Arg *); @@ -118,7 +108,6 @@ typedef struct { Monitor *mon; struct wlr_scene_tree *scene; struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ - struct wlr_scene_rect *dimmer; struct wlr_scene_tree *scene_surface; struct wl_list link; struct wl_list flink; @@ -148,16 +137,10 @@ typedef struct { #endif unsigned int bw; uint32_t tags; - int isfloating, isurgent, isfullscreen, neverdim; + int isfloating, isurgent, isfullscreen; uint32_t resize; /* configure serial of a pending resize */ } Client; -typedef struct { - struct wl_list link; - struct wl_resource *resource; - Monitor *mon; -} DwlIpcOutput; - typedef struct { uint32_t mod; xkb_keysym_t keysym; @@ -200,20 +183,10 @@ typedef struct { void (*arrange)(Monitor *); } Layout; -typedef struct { - struct wlr_buffer base; - struct wl_listener release; - bool busy; - Img *image; - uint32_t data[]; -} Buffer; - struct Monitor { struct wl_list link; - struct wl_list dwl_ipc_outputs; struct wlr_output *wlr_output; struct wlr_scene_output *scene_output; - struct wlr_scene_buffer *scene_buffer; /* bar buffer */ struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */ struct wl_listener frame; struct wl_listener destroy; @@ -221,11 +194,6 @@ struct Monitor { struct wl_listener destroy_lock_surface; struct wlr_session_lock_surface_v1 *lock_surface; struct wlr_box m; /* monitor area, layout-relative */ - struct { - int width, height; - int real_width, real_height; /* non-scaled */ - float scale; - } b; /* bar area */ struct wlr_box w; /* window area, layout-relative */ struct wl_list layers[4]; /* LayerSurface.link */ const Layout *lt[2]; @@ -237,9 +205,6 @@ struct Monitor { int nmaster; char ltsymbol[16]; int asleep; - Drwl *drw; - Buffer *pool[2]; - int lrpad; }; typedef struct { @@ -262,7 +227,6 @@ typedef struct { const char *title; uint32_t tags; int isfloating; - int neverdim; int monitor; } Rule; @@ -283,13 +247,6 @@ static void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive); static void arrangelayers(Monitor *m); static void axisnotify(struct wl_listener *listener, void *data); -static bool baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy); -static void bufdestroy(struct wlr_buffer *buffer); -static bool bufdatabegin(struct wlr_buffer *buffer, uint32_t flags, - void **data, uint32_t *format, size_t *stride); -static void bufdataend(struct wlr_buffer *buffer); -static Buffer *bufmon(Monitor *m); -static void bufrelease(struct wl_listener *listener, void *data); static void buttonpress(struct wl_listener *listener, void *data); static void chvt(const Arg *arg); static void checkidleinhibitor(struct wlr_surface *exclude); @@ -325,23 +282,8 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data); static void destroykeyboardgroup(struct wl_listener *listener, void *data); static Monitor *dirtomon(enum wlr_direction dir); -static Monitor *numtomon(int num); -static void dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id); -static void dwl_ipc_manager_destroy(struct wl_resource *resource); -static void dwl_ipc_manager_get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output); -static void dwl_ipc_manager_release(struct wl_client *client, struct wl_resource *resource); -static void dwl_ipc_output_destroy(struct wl_resource *resource); -static void dwl_ipc_output_printstatus(Monitor *monitor); -static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output); -static void dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *resource, uint32_t and_tags, uint32_t xor_tags); -static void dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index); -static void dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset); -static void dwl_ipc_output_release(struct wl_client *client, struct wl_resource *resource); -static void drawbar(Monitor *m); -static void drawbars(void); static void focusclient(Client *c, int lift); static void focusmon(const Arg *arg); -static void focusnthmon(const Arg *arg); static void focusstack(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); @@ -389,14 +331,9 @@ static void setsel(struct wl_listener *listener, void *data); static void setup(void); static void spawn(const Arg *arg); static void startdrag(struct wl_listener *listener, void *data); -static int statusin(int fd, unsigned int mask, void *data); static void tag(const Arg *arg); static void tagmon(const Arg *arg); -static void tagnthmon(const Arg *arg); static void tile(Monitor *m); -static void togglebar(const Arg *arg); -static void toggledimming(const Arg *arg); -static void toggledimmingclient(const Arg *arg); static void togglefloating(const Arg *arg); static void togglefullscreen(const Arg *arg); static void toggletag(const Arg *arg); @@ -405,13 +342,11 @@ static void unlocksession(struct wl_listener *listener, void *data); static void unmaplayersurfacenotify(struct wl_listener *listener, void *data); static void unmapnotify(struct wl_listener *listener, void *data); static void updatemons(struct wl_listener *listener, void *data); -static void updatebar(Monitor *m); static void updatetitle(struct wl_listener *listener, void *data); static void urgent(struct wl_listener *listener, void *data); static void view(const Arg *arg); static void virtualkeyboard(struct wl_listener *listener, void *data); static void virtualpointer(struct wl_listener *listener, void *data); -static void warpcursor(const Client *c); static Monitor *xytomon(double x, double y); static void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl, double *nx, double *ny); @@ -470,16 +405,6 @@ static struct wlr_output_layout *output_layout; static struct wlr_box sgeom; static struct wl_list mons; static Monitor *selmon; -static int DIMOPT = 1; - -static char stext[256]; -static struct wl_event_source *status_event_source; - -static const struct wlr_buffer_impl buffer_impl = { - .destroy = bufdestroy, - .begin_data_ptr_access = bufdatabegin, - .end_data_ptr_access = bufdataend, -}; /* global event handlers */ static struct wl_listener cursor_axis = {.notify = axisnotify}; @@ -510,8 +435,7 @@ static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape}; static struct wl_listener request_start_drag = {.notify = requeststartdrag}; static struct wl_listener start_drag = {.notify = startdrag}; static struct wl_listener new_session_lock = {.notify = locksession}; -static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output}; -static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags}; + #ifdef XWAYLAND static void activatex11(struct wl_listener *listener, void *data); static void associatex11(struct wl_listener *listener, void *data); @@ -566,7 +490,6 @@ applyrules(Client *c) if ((!r->title || strstr(title, r->title)) && (!r->id || strstr(appid, r->id))) { c->isfloating = r->isfloating; - c->neverdim = r-> neverdim; newtags |= r->tags; i = 0; wl_list_for_each(m, &mons, link) { @@ -598,7 +521,7 @@ arrange(Monitor *m) wlr_scene_node_set_enabled(&m->fullscreen_bg->node, (c = focustop(m)) && c->isfullscreen); - strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol)); + strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); /* We move all clients (except fullscreen and unmanaged) to LyrTile while * in floating layout to avoid "real" floating clients be always on top */ @@ -618,7 +541,6 @@ arrange(Monitor *m) m->lt[m->sellt]->arrange(m); motionnotify(0, NULL, 0, 0, 0, 0); checkidleinhibitor(NULL); - warpcursor(focustop(selmon)); } void @@ -654,11 +576,6 @@ arrangelayers(Monitor *m) if (!m->wlr_output->enabled) return; - if (m->scene_buffer->node.enabled) { - usable_area.height -= m->b.real_height; - usable_area.y += topbar ? m->b.real_height : 0; - } - /* Arrange exclusive surfaces from top->bottom */ for (i = 3; i >= 0; i--) arrangelayer(m, &m->layers[i], &usable_area, 1); @@ -701,102 +618,17 @@ axisnotify(struct wl_listener *listener, void *data) event->delta_discrete, event->source, event->relative_direction); } -bool -baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy) -{ - return true; -} - -void -bufdestroy(struct wlr_buffer *wlr_buffer) -{ - Buffer *buf = wl_container_of(wlr_buffer, buf, base); - if (buf->busy) - wl_list_remove(&buf->release.link); - drwl_image_destroy(buf->image); - free(buf); -} - -bool -bufdatabegin(struct wlr_buffer *wlr_buffer, uint32_t flags, - void **data, uint32_t *format, size_t *stride) -{ - Buffer *buf = wl_container_of(wlr_buffer, buf, base); - - if (flags & WLR_BUFFER_DATA_PTR_ACCESS_WRITE) return false; - - *data = buf->data; - *stride = wlr_buffer->width * 4; - *format = DRM_FORMAT_ARGB8888; - - return true; -} - -void -bufdataend(struct wlr_buffer *wlr_buffer) -{ -} - -Buffer * -bufmon(Monitor *m) -{ - size_t i; - Buffer *buf = NULL; - - for (i = 0; i < LENGTH(m->pool); i++) { - if (m->pool[i]) { - if (m->pool[i]->busy) - continue; - buf = m->pool[i]; - break; - } - - buf = ecalloc(1, sizeof(Buffer) + (m->b.width * 4 * m->b.height)); - buf->image = drwl_image_create(NULL, m->b.width, m->b.height, buf->data); - wlr_buffer_init(&buf->base, &buffer_impl, m->b.width, m->b.height); - m->pool[i] = buf; - break; - } - if (!buf) - return NULL; - - buf->busy = true; - LISTEN(&buf->base.events.release, &buf->release, bufrelease); - wlr_buffer_lock(&buf->base); - drwl_setimage(m->drw, buf->image); - return buf; -} - -void -bufrelease(struct wl_listener *listener, void *data) -{ - Buffer *buf = wl_container_of(listener, buf, release); - buf->busy = false; - wl_list_remove(&buf->release.link); -} - void buttonpress(struct wl_listener *listener, void *data) { - unsigned int i = 0, x = 0; - double cx; - unsigned int click; struct wlr_pointer_button_event *event = data; struct wlr_keyboard *keyboard; - struct wlr_scene_node *node; - struct wlr_scene_buffer *buffer; uint32_t mods; - Arg arg = {0}; Client *c; const Button *b; wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); - click = ClkRoot; - xytonode(cursor->x, cursor->y, NULL, &c, NULL, NULL, NULL); - if (c) - click = ClkClient; - switch (event->state) { case WL_POINTER_BUTTON_STATE_PRESSED: cursor_mode = CurPressed; @@ -804,34 +636,17 @@ buttonpress(struct wl_listener *listener, void *data) if (locked) break; - if (!c && !exclusive_focus && - (node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) && - (buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) { - cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale; - do - x += TEXTW(selmon, tags[i]); - while (cx >= x && ++i < LENGTH(tags)); - if (i < LENGTH(tags)) { - click = ClkTagBar; - arg.ui = 1 << i; - } else if (cx < x + TEXTW(selmon, selmon->ltsymbol)) - click = ClkLtSymbol; - else if (cx > selmon->b.width - (TEXTW(selmon, stext) - selmon->lrpad + 2)) { - click = ClkStatus; - } else - click = ClkTitle; - } - /* Change focus if the button was _pressed_ over a client */ xytonode(cursor->x, cursor->y, NULL, &c, NULL, NULL, NULL); - if (click == ClkClient && (!client_is_unmanaged(c) || client_wants_focus(c))) + if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) focusclient(c, 1); keyboard = wlr_seat_get_keyboard(seat); mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; for (b = buttons; b < END(buttons); b++) { - if (CLEANMASK(mods) == CLEANMASK(b->mod) && event->button == b->button && click == b->click && b->func) { - b->func(click == ClkTagBar && b->arg.i == 0 ? &arg : &b->arg); + if (CLEANMASK(mods) == CLEANMASK(b->mod) && + event->button == b->button && b->func) { + b->func(&b->arg); return; } } @@ -906,8 +721,6 @@ cleanup(void) /* Destroy after the wayland display (when the monitors are already destroyed) to avoid destroying them with an invalid scene output. */ wlr_scene_node_destroy(&scene->tree.node); - - drwl_fini(); } void @@ -917,22 +730,12 @@ cleanupmon(struct wl_listener *listener, void *data) LayerSurface *l, *tmp; size_t i; - DwlIpcOutput *ipc_output, *ipc_output_tmp; - wl_list_for_each_safe(ipc_output, ipc_output_tmp, &m->dwl_ipc_outputs, link) - wl_resource_destroy(ipc_output->resource); - /* m->layers[i] are intentionally not unlinked */ for (i = 0; i < LENGTH(m->layers); i++) { wl_list_for_each_safe(l, tmp, &m->layers[i], link) wlr_layer_surface_v1_destroy(l->layer_surface); } - for (i = 0; i < LENGTH(m->pool); i++) - wlr_buffer_drop(&m->pool[i]->base); - - drwl_setimage(m->drw, NULL); - drwl_destroy(m->drw); - wl_list_remove(&m->destroy.link); wl_list_remove(&m->frame.link); wl_list_remove(&m->link); @@ -945,7 +748,6 @@ cleanupmon(struct wl_listener *listener, void *data) closemon(m); wlr_scene_node_destroy(&m->fullscreen_bg->node); - wlr_scene_node_destroy(&m->scene_buffer->node); free(m); } @@ -1012,7 +814,7 @@ closemon(Monitor *m) setmon(c, selmon, c->tags); } focusclient(focustop(selmon), 1); - drawbars(); + printstatus(); } void @@ -1250,8 +1052,6 @@ createmon(struct wl_listener *listener, void *data) m = wlr_output->data = ecalloc(1, sizeof(*m)); m->wlr_output = wlr_output; - wl_list_init(&m->dwl_ipc_outputs); - for (i = 0; i < LENGTH(m->layers); i++) wl_list_init(&m->layers[i]); @@ -1266,7 +1066,7 @@ createmon(struct wl_listener *listener, void *data) m->nmaster = r->nmaster; m->lt[0] = r->lt; m->lt[1] = &layouts[LENGTH(layouts) > 1 && r->lt != &layouts[1]]; - strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol)); + strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); wlr_output_state_set_scale(&state, r->scale); wlr_output_state_set_transform(&state, r->rr); break; @@ -1288,15 +1088,8 @@ createmon(struct wl_listener *listener, void *data) wlr_output_commit_state(wlr_output, &state); wlr_output_state_finish(&state); - if (!(m->drw = drwl_create())) - die("failed to create drwl context"); - - m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL); - m->scene_buffer->point_accepts_input = baracceptsinput; - updatebar(m); - wl_list_insert(&mons, &m->link); - drawbars(); + printstatus(); /* The xdg-protocol specifies: * @@ -1606,285 +1399,6 @@ dirtomon(enum wlr_direction dir) return selmon; } -Monitor * -numtomon(int num) -{ - Monitor *m = NULL; - int found = 0; - int i = 0; - - wl_list_for_each(m, &mons, link) { - if (!m->wlr_output->enabled) - i--; - else if (i == num) { - found = true; - break; - } - i++; - } - return found ? m : NULL; -} - -void -dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - struct wl_resource *manager_resource = wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id); - if (!manager_resource) { - wl_client_post_no_memory(client); - return; - } - wl_resource_set_implementation(manager_resource, &dwl_manager_implementation, NULL, dwl_ipc_manager_destroy); - - zdwl_ipc_manager_v2_send_tags(manager_resource, LENGTH(tags)); - - for (unsigned int i = 0; i < LENGTH(layouts); i++) - zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol); -} - -void -dwl_ipc_manager_destroy(struct wl_resource *resource) -{ - /* No state to destroy */ -} - -void -dwl_ipc_manager_get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output) -{ - DwlIpcOutput *ipc_output; - Monitor *monitor = wlr_output_from_resource(output)->data; - struct wl_resource *output_resource = wl_resource_create(client, &zdwl_ipc_output_v2_interface, wl_resource_get_version(resource), id); - if (!output_resource) - return; - - ipc_output = ecalloc(1, sizeof(*ipc_output)); - ipc_output->resource = output_resource; - ipc_output->mon = monitor; - wl_resource_set_implementation(output_resource, &dwl_output_implementation, ipc_output, dwl_ipc_output_destroy); - wl_list_insert(&monitor->dwl_ipc_outputs, &ipc_output->link); - dwl_ipc_output_printstatus_to(ipc_output); -} - -void -dwl_ipc_manager_release(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void -dwl_ipc_output_destroy(struct wl_resource *resource) -{ - DwlIpcOutput *ipc_output = wl_resource_get_user_data(resource); - wl_list_remove(&ipc_output->link); - free(ipc_output); -} - -void -dwl_ipc_output_printstatus(Monitor *monitor) -{ - DwlIpcOutput *ipc_output; - wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link) - dwl_ipc_output_printstatus_to(ipc_output); -} - -void -dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) -{ - Monitor *monitor = ipc_output->mon; - Client *c, *focused; - int tagmask, state, numclients, focused_client, tag; - const char *title, *appid; - focused = focustop(monitor); - zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon); - - for (tag = 0 ; tag < LENGTH(tags); tag++) { - numclients = state = focused_client = 0; - tagmask = 1 << tag; - if ((tagmask & monitor->tagset[monitor->seltags]) != 0) - state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE; - - wl_list_for_each(c, &clients, link) { - if (c->mon != monitor) - continue; - if (!(c->tags & tagmask)) - continue; - if (c == focused) - focused_client = 1; - if (c->isurgent) - state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT; - - numclients++; - } - zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients, focused_client); - } - title = focused ? client_get_title(focused) : ""; - appid = focused ? client_get_appid(focused) : ""; - - zdwl_ipc_output_v2_send_layout(ipc_output->resource, monitor->lt[monitor->sellt] - layouts); - zdwl_ipc_output_v2_send_title(ipc_output->resource, title); - zdwl_ipc_output_v2_send_appid(ipc_output->resource, appid); - zdwl_ipc_output_v2_send_layout_symbol(ipc_output->resource, monitor->ltsymbol); - if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) { - zdwl_ipc_output_v2_send_fullscreen(ipc_output->resource, focused ? focused->isfullscreen : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) { - zdwl_ipc_output_v2_send_floating(ipc_output->resource, focused ? focused->isfloating : 0); - } - zdwl_ipc_output_v2_send_frame(ipc_output->resource); -} - -void -dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *resource, uint32_t and_tags, uint32_t xor_tags) -{ - DwlIpcOutput *ipc_output; - Monitor *monitor; - Client *selected_client; - unsigned int newtags = 0; - - ipc_output = wl_resource_get_user_data(resource); - if (!ipc_output) - return; - - monitor = ipc_output->mon; - selected_client = focustop(monitor); - if (!selected_client) - return; - - newtags = (selected_client->tags & and_tags) ^ xor_tags; - if (!newtags) - return; - - selected_client->tags = newtags; - if (selmon == monitor) - focusclient(focustop(monitor), 1); - arrange(selmon); - printstatus(); -} - -void -dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index) -{ - DwlIpcOutput *ipc_output; - Monitor *monitor; - - ipc_output = wl_resource_get_user_data(resource); - if (!ipc_output) - return; - - monitor = ipc_output->mon; - if (index >= LENGTH(layouts)) - return; - if (index != monitor->lt[monitor->sellt] - layouts) - monitor->sellt ^= 1; - - monitor->lt[monitor->sellt] = &layouts[index]; - arrange(monitor); - printstatus(); -} - -void -dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset) -{ - DwlIpcOutput *ipc_output; - Monitor *monitor; - unsigned int newtags = tagmask & TAGMASK; - - ipc_output = wl_resource_get_user_data(resource); - if (!ipc_output) - return; - monitor = ipc_output->mon; - - if (!newtags || newtags == monitor->tagset[monitor->seltags]) - return; - if (toggle_tagset) - monitor->seltags ^= 1; - - monitor->tagset[monitor->seltags] = newtags; - if (selmon == monitor) - focusclient(focustop(monitor), 1); - arrange(monitor); - printstatus(); -} - -void -dwl_ipc_output_release(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -void -drawbar(Monitor *m) -{ - int x, w, tw = 0; - int boxs = m->drw->font->height / 9; - int boxw = m->drw->font->height / 6 + 2; - uint32_t i, occ = 0, urg = 0; - Client *c; - Buffer *buf; - - if (!m->scene_buffer->node.enabled) - return; - if (!(buf = bufmon(m))) - return; - - /* draw status first so it can be overdrawn by tags later */ - if (m == selmon) { /* status is only drawn on selected monitor */ - drwl_setscheme(m->drw, colors[SchemeNorm]); - tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */ - drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0); - } - - wl_list_for_each(c, &clients, link) { - if (c->mon != m) - continue; - occ |= c->tags; - if (c->isurgent) - urg |= c->tags; - } - x = 0; - c = focustop(m); - for (i = 0; i < LENGTH(tags); i++) { - w = TEXTW(m, tags[i]); - drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); - drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i); - if (occ & 1 << i) - drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, - m == selmon && c && c->tags & 1 << i, - urg & 1 << i); - x += w; - } - w = TEXTW(m, m->ltsymbol); - drwl_setscheme(m->drw, colors[SchemeNorm]); - x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0); - - if ((w = m->b.width - tw - x) > m->b.height) { - if (c) { - drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]); - drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0); - if (c && c->isfloating) - drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0); - } else { - drwl_setscheme(m->drw, colors[SchemeNorm]); - drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1); - } - } - - wlr_scene_buffer_set_dest_size(m->scene_buffer, - m->b.real_width, m->b.real_height); - wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x, - m->m.y + (topbar ? 0 : m->m.height - m->b.real_height)); - wlr_scene_buffer_set_buffer(m->scene_buffer, &buf->base); - wlr_buffer_unlock(&buf->base); -} - -void -drawbars(void) -{ - Monitor *m = NULL; - - wl_list_for_each(m, &mons, link) - drawbar(m); -} - void focusclient(Client *c, int lift) { @@ -1896,10 +1410,6 @@ focusclient(Client *c, int lift) if (locked) return; - /* Warp cursor to center of client if it is outside */ - if (lift) - warpcursor(c); - /* Raise client in stacking order if requested */ if (c && lift) wlr_scene_node_raise_to_top(&c->scene->node); @@ -1922,16 +1432,14 @@ focusclient(Client *c, int lift) /* Don't change border color if there is an exclusive focus or we are * handling a drag operation */ - if (!exclusive_focus && !seat->drag) { - client_set_border_color(c, (float[])COLOR(colors[SchemeSel][ColBorder])); - client_set_dimmer_state(c, 0); - } + if (!exclusive_focus && !seat->drag) + client_set_border_color(c, focuscolor); } /* Deactivate old client if focus is changing */ if (old && (!c || client_surface(c) != old)) { /* If an overlay is focused, don't focus or activate the client, - * but only update its position in fstack to render its border with its color + * but only update its position in fstack to render its border with focuscolor * and focus it after the overlay is closed. */ if (old_client_type == LayerShell && wlr_scene_node_coords( &old_l->scene->node, &unused_lx, &unused_ly) @@ -1942,12 +1450,12 @@ focusclient(Client *c, int lift) /* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg * and probably other clients */ } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { - client_set_border_color(old_c, (float[])COLOR(colors[SchemeNorm][ColBorder])); - client_set_dimmer_state(old_c, 1); + client_set_border_color(old_c, bordercolor); + client_activate_surface(old, 0); } } - drawbars(); + printstatus(); if (!c) { /* With no client, all we have left is to clear focus */ @@ -1977,16 +1485,6 @@ focusmon(const Arg *arg) focusclient(focustop(selmon), 1); } -void -focusnthmon(const Arg *arg) -{ - Monitor *m = numtomon(arg->i); - if (!m || m == selmon) - return; - selmon = m; - focusclient(focustop(selmon), 1); -} - void focusstack(const Arg *arg) { @@ -2118,8 +1616,7 @@ keybinding(uint32_t mods, xkb_keysym_t sym) const Key *k; for (k = keys; k < END(keys); k++) { if (CLEANMASK(mods) == CLEANMASK(k->mod) - && xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym) - && k->func) { + && sym == k->keysym && k->func) { k->func(&k->arg); return 1; } @@ -2240,7 +1737,8 @@ void mapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is mapped, or ready to display on-screen. */ - Client *p, *w, *d, *c = wl_container_of(listener, c, map); + Client *p = NULL; + Client *w, *c = wl_container_of(listener, c, map); Monitor *m; int i; @@ -2270,14 +1768,10 @@ mapnotify(struct wl_listener *listener, void *data) for (i = 0; i < 4; i++) { c->border[i] = wlr_scene_rect_create(c->scene, 0, 0, - (float[])COLOR(colors[c->isurgent ? SchemeUrg : SchemeNorm][ColBorder])); + c->isurgent ? urgentcolor : bordercolor); c->border[i]->node.data = c; } - c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim); - c->dimmer->node.data = c; - client_set_dimmer_state(c, 1); - /* Initialize client geometry with room for border */ client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); c->geom.width += 2 * c->bw; @@ -2296,12 +1790,8 @@ mapnotify(struct wl_listener *listener, void *data) setmon(c, p->mon, p->tags); } else { applyrules(c); - d = focustop(selmon); - if (d) { - client_set_dimmer_state(d, 0); - } } - drawbars(); + printstatus(); unset_fullscreen: m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y); @@ -2594,13 +2084,42 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, wlr_seat_pointer_notify_motion(seat, time, sx, sy); } -static void +void printstatus(void) { Monitor *m = NULL; + Client *c; + uint32_t occ, urg, sel; - wl_list_for_each(m, &mons, link) - dwl_ipc_output_printstatus(m); + wl_list_for_each(m, &mons, link) { + occ = urg = 0; + wl_list_for_each(c, &clients, link) { + if (c->mon != m) + continue; + occ |= c->tags; + if (c->isurgent) + urg |= c->tags; + } + if ((c = focustop(m))) { + printf("%s title %s\n", m->wlr_output->name, client_get_title(c)); + printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c)); + printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen); + printf("%s floating %d\n", m->wlr_output->name, c->isfloating); + sel = c->tags; + } else { + printf("%s title \n", m->wlr_output->name); + printf("%s appid \n", m->wlr_output->name); + printf("%s fullscreen \n", m->wlr_output->name); + printf("%s floating \n", m->wlr_output->name); + sel = 0; + } + + printf("%s selmon %u\n", m->wlr_output->name, m == selmon); + printf("%s tags %"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"\n", + m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg); + printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol); + } + fflush(stdout); } void @@ -2697,7 +2216,7 @@ resize(Client *c, struct wlr_box geo, int interact) c->geom = geo; applybounds(c, bbox); - /* Update scene-graph, including borders and dimmer*/ + /* Update scene-graph, including borders */ wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw); @@ -2707,8 +2226,6 @@ resize(Client *c, struct wlr_box geo, int interact) wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw); wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw); wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw); - wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw); - wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw); /* this is a no-op if size hasn't changed */ c->resize = client_set_size(c, c->geom.width - 2 * c->bw, @@ -2733,14 +2250,22 @@ run(char *startup_cmd) /* Now that the socket exists and the backend is started, run the startup command */ if (startup_cmd) { + int piperw[2]; + if (pipe(piperw) < 0) + die("startup: pipe:"); if ((child_pid = fork()) < 0) die("startup: fork:"); if (child_pid == 0) { - close(STDIN_FILENO); setsid(); + dup2(piperw[0], STDIN_FILENO); + close(piperw[0]); + close(piperw[1]); execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL); die("startup: execl:"); } + dup2(piperw[1], STDOUT_FILENO); + close(piperw[1]); + close(piperw[0]); } /* Mark stdout as non-blocking to avoid the startup script @@ -2750,7 +2275,7 @@ run(char *startup_cmd) if (fd_set_nonblock(STDOUT_FILENO) < 0) close(STDOUT_FILENO); - drawbars(); + printstatus(); /* At this point the outputs are initialized, choose initial selmon based on * cursor position, and set default cursor image */ @@ -2816,7 +2341,7 @@ setfloating(Client *c, int floating) (p && p->isfullscreen) ? LyrFS : c->isfloating ? LyrFloat : LyrTile]); arrange(c->mon); - drawbars(); + printstatus(); } void @@ -2839,7 +2364,7 @@ setfullscreen(Client *c, int fullscreen) resize(c, c->prev, 0); } arrange(c->mon); - drawbars(); + printstatus(); } void @@ -2851,9 +2376,9 @@ setlayout(const Arg *arg) selmon->sellt ^= 1; if (arg && arg->v) selmon->lt[selmon->sellt] = (Layout *)arg->v; - strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof(selmon->ltsymbol)); + strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol)); arrange(selmon); - drawbar(selmon); + printstatus(); } /* arg > 1.0 will set mfact absolutely */ @@ -2926,7 +2451,6 @@ setup(void) for (i = 0; i < (int)LENGTH(sig); i++) sigaction(sig[i], &sa, NULL); - wlr_log_init(log_level, NULL); /* The Wayland display is managed by libwayland. It handles accepting @@ -3121,12 +2645,6 @@ setup(void) wl_signal_add(&output_mgr->events.apply, &output_mgr_apply); wl_signal_add(&output_mgr->events.test, &output_mgr_test); - wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, dwl_ipc_manager_bind); - drwl_init(); - - status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy), - STDIN_FILENO, WL_EVENT_READABLE, statusin, NULL); - /* Make sure XWayland clients don't connect to the parent X server, * e.g when running in the x11 backend or the wayland backend and the * compositor has Xwayland support */ @@ -3151,8 +2669,6 @@ void spawn(const Arg *arg) { if (fork() == 0) { - close(STDIN_FILENO); - open("/dev/null", O_RDWR); dup2(STDERR_FILENO, STDOUT_FILENO); setsid(); execvp(((char **)arg->v)[0], (char **)arg->v); @@ -3171,30 +2687,6 @@ startdrag(struct wl_listener *listener, void *data) LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon); } -int -statusin(int fd, unsigned int mask, void *data) -{ - char status[256]; - ssize_t n; - - if (mask & WL_EVENT_ERROR) - die("status in event error"); - if (mask & WL_EVENT_HANGUP) - wl_event_source_remove(status_event_source); - - n = read(fd, status, sizeof(status) - 1); - if (n < 0 && errno != EWOULDBLOCK) - die("read:"); - - status[n] = '\0'; - status[strcspn(status, "\n")] = '\0'; - - strncpy(stext, status, sizeof(stext)); - drawbars(); - - return 0; -} - void tag(const Arg *arg) { @@ -3205,7 +2697,7 @@ tag(const Arg *arg) sel->tags = arg->ui & TAGMASK; focusclient(focustop(selmon), 1); arrange(selmon); - drawbars(); + printstatus(); } void @@ -3216,19 +2708,6 @@ tagmon(const Arg *arg) setmon(sel, dirtomon(arg->i), 0); } -void -tagnthmon(const Arg *arg) -{ - Client *sel = focustop(selmon); - Monitor *m = numtomon(arg->i); - if (!m || !sel) - return; - setmon(sel, m, 0); - - arrange(selmon); - arrange(m); -} - void tile(Monitor *m) { @@ -3263,39 +2742,6 @@ tile(Monitor *m) } } -void toggledimming(const Arg *arg) -{ - Client *c; - DIMOPT ^= 1; - wl_list_for_each(c, &clients, link) - { - client_set_dimmer_state(c, 1); - } - c = focustop(selmon); - if (c) - client_set_dimmer_state(c, 0); -} - -void -toggledimmingclient(const Arg *arg) -{ - Client *sel = focustop(selmon); - if (sel) - sel -> neverdim ^= 1; -} -void -togglebar(const Arg *arg) -{ - DwlIpcOutput *ipc_output; - wl_list_for_each(ipc_output, &selmon->dwl_ipc_outputs, link) - zdwl_ipc_output_v2_send_toggle_visibility(ipc_output->resource); - - wlr_scene_node_set_enabled(&selmon->scene_buffer->node, - !selmon->scene_buffer->node.enabled); - arrangelayers(selmon); - drawbars(); -} - void togglefloating(const Arg *arg) { @@ -3324,7 +2770,7 @@ toggletag(const Arg *arg) sel->tags = newtags; focusclient(focustop(selmon), 1); arrange(selmon); - drawbars(); + printstatus(); } void @@ -3337,7 +2783,7 @@ toggleview(const Arg *arg) selmon->tagset[selmon->seltags] = newtagset; focusclient(focustop(selmon), 1); arrange(selmon); - drawbars(); + printstatus(); } void @@ -3385,7 +2831,7 @@ unmapnotify(struct wl_listener *listener, void *data) } wlr_scene_node_destroy(&c->scene->node); - drawbars(); + printstatus(); motionnotify(0, NULL, 0, 0, 0, 0); } @@ -3485,13 +2931,6 @@ updatemons(struct wl_listener *listener, void *data) } } - if (stext[0] == '\0') - strncpy(stext, "dwl-"VERSION, sizeof(stext)); - wl_list_for_each(m, &mons, link) { - updatebar(m); - drawbar(m); - } - /* FIXME: figure out why the cursor image is at 0,0 after turning all * the monitors on. * Move the cursor image where it used to be. It does not generate a @@ -3502,45 +2941,12 @@ updatemons(struct wl_listener *listener, void *data) wlr_output_manager_v1_set_configuration(output_mgr, config); } -void -updatebar(Monitor *m) -{ - size_t i; - int rw, rh; - char fontattrs[12]; - - wlr_output_transformed_resolution(m->wlr_output, &rw, &rh); - m->b.width = rw; - m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale); - - wlr_scene_node_set_enabled(&m->scene_buffer->node, m->wlr_output->enabled ? showbar : 0); - - for (i = 0; i < LENGTH(m->pool); i++) - if (m->pool[i]) { - wlr_buffer_drop(&m->pool[i]->base); - m->pool[i] = NULL; - } - - if (m->b.scale == m->wlr_output->scale && m->drw) - return; - - drwl_font_destroy(m->drw->font); - snprintf(fontattrs, sizeof(fontattrs), "dpi=%.2f", 96. * m->wlr_output->scale); - if (!(drwl_font_create(m->drw, LENGTH(fonts), fonts, fontattrs))) - die("Could not load font"); - - m->b.scale = m->wlr_output->scale; - m->lrpad = m->drw->font->height; - m->b.height = m->drw->font->height + 2; - m->b.real_height = (int)((float)m->b.height / m->wlr_output->scale); -} - void updatetitle(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, set_title); if (c == focustop(c->mon)) - drawbars(); + printstatus(); } void @@ -3553,10 +2959,10 @@ urgent(struct wl_listener *listener, void *data) return; c->isurgent = 1; - drawbars(); + printstatus(); if (client_surface(c)->mapped) - client_set_border_color(c, (float[])COLOR(colors[SchemeUrg][ColBorder])); + client_set_border_color(c, urgentcolor); } void @@ -3569,7 +2975,7 @@ view(const Arg *arg) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; focusclient(focustop(selmon), 1); arrange(selmon); - drawbars(); + printstatus(); } void @@ -3597,27 +3003,6 @@ virtualpointer(struct wl_listener *listener, void *data) wlr_cursor_map_input_to_output(cursor, device, event->suggested_output); } -void -warpcursor(const Client *c) { - if (cursor_mode != CurNormal) { - return; - } - if (!c && selmon) { - wlr_cursor_warp_closest(cursor, - NULL, - selmon->w.x + selmon->w.width / 2.0 , - selmon->w.y + selmon->w.height / 2.0); - } - else if ( c && (cursor->x < c->geom.x || - cursor->x > c->geom.x + c->geom.width || - cursor->y < c->geom.y || - cursor->y > c->geom.y + c->geom.height)) - wlr_cursor_warp_closest(cursor, - NULL, - c->geom.x + c->geom.width / 2.0, - c->geom.y + c->geom.height / 2.0); -} - Monitor * xytomon(double x, double y) { @@ -3631,7 +3016,6 @@ xytonode(double x, double y, struct wlr_surface **psurface, { struct wlr_scene_node *node, *pnode; struct wlr_surface *surface = NULL; - struct wlr_scene_surface *scene_surface = NULL; Client *c = NULL; LayerSurface *l = NULL; int layer; @@ -3640,12 +3024,9 @@ xytonode(double x, double y, struct wlr_surface **psurface, if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny))) continue; - if (node->type == WLR_SCENE_NODE_BUFFER) { - scene_surface = wlr_scene_surface_try_from_buffer( - wlr_scene_buffer_from_node(node)); - if (!scene_surface) continue; - surface = scene_surface->surface; - } + if (node->type == WLR_SCENE_NODE_BUFFER) + surface = wlr_scene_surface_try_from_buffer( + wlr_scene_buffer_from_node(node))->surface; /* Walk the tree to find a node that knows the client */ for (pnode = node; pnode && !c; pnode = &pnode->parent->node) c = pnode->data; @@ -3778,10 +3159,10 @@ sethints(struct wl_listener *listener, void *data) return; c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints); - drawbars(); + printstatus(); if (c->isurgent && surface && surface->mapped) - client_set_border_color(c, (float[])COLOR(colors[SchemeUrg][ColBorder])); + client_set_border_color(c, urgentcolor); } void diff --git a/dwl.desktop b/dwl.desktop index 9e56b6b..e1380f7 100644 --- a/dwl.desktop +++ b/dwl.desktop @@ -1,5 +1,5 @@ [Desktop Entry] Name=dwl Comment=dwm for Wayland -Exec=/usr/local/bin/startup.sh +Exec=dwl Type=Application diff --git a/patches/accessnthmon.patch b/patches/accessnthmon.patch deleted file mode 100644 index f69f57d..0000000 --- a/patches/accessnthmon.patch +++ /dev/null @@ -1,122 +0,0 @@ -From 5f531bfb1387ded7b8817faf7df760d3b998742b Mon Sep 17 00:00:00 2001 -From: Rutherther -Date: Sat, 27 Apr 2024 21:25:16 +0200 -Subject: [PATCH] feat: access nth monitor - ---- - config.def.h | 4 +++- - dwl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 49 insertions(+), 1 deletion(-) - -diff --git a/config.def.h b/config.def.h -index 8847e58..4709c5d 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -108,7 +108,9 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \ -- { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} } -+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }, \ -+ { WLR_MODIFIER_ALT, KEY, focusnthmon, {.ui = TAG} }, \ -+ { WLR_MODIFIER_ALT|WLR_MODIFIER_SHIFT, SKEY, tagnthmon, {.ui = TAG} } - - /* helper for spawning shell commands in the pre dwm-5.0 fashion */ - #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } -diff --git a/dwl.c b/dwl.c -index bf763df..1d42caf 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -11,6 +11,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -278,8 +279,10 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data); - static void destroysessionlock(struct wl_listener *listener, void *data); - static void destroysessionmgr(struct wl_listener *listener, void *data); - static Monitor *dirtomon(enum wlr_direction dir); -+static Monitor *numtomon(int num); - static void focusclient(Client *c, int lift); - static void focusmon(const Arg *arg); -+static void focusnthmon(const Arg *arg); - static void focusstack(const Arg *arg); - static Client *focustop(Monitor *m); - static void fullscreennotify(struct wl_listener *listener, void *data); -@@ -329,6 +332,7 @@ static void spawn(const Arg *arg); - static void startdrag(struct wl_listener *listener, void *data); - static void tag(const Arg *arg); - static void tagmon(const Arg *arg); -+static void tagnthmon(const Arg *arg); - static void tile(Monitor *m); - static void togglefloating(const Arg *arg); - static void togglefullscreen(const Arg *arg); -@@ -1233,6 +1237,25 @@ dirtomon(enum wlr_direction dir) - return selmon; - } - -+Monitor * -+numtomon(int num) -+{ -+ Monitor *m = NULL; -+ int found = 0; -+ int i = 0; -+ -+ wl_list_for_each(m, &mons, link) { -+ if (!m->wlr_output->enabled) -+ i--; -+ else if (i == num) { -+ found = true; -+ break; -+ } -+ i++; -+ } -+ return found ? m : NULL; -+} -+ - void - focusclient(Client *c, int lift) - { -@@ -1320,6 +1343,16 @@ focusmon(const Arg *arg) - focusclient(focustop(selmon), 1); - } - -+void -+focusnthmon(const Arg *arg) -+{ -+ Monitor *m = numtomon(arg->i); -+ if (!m || m == selmon) -+ return; -+ selmon = m; -+ focusclient(focustop(selmon), 1); -+} -+ - void - focusstack(const Arg *arg) - { -@@ -2569,6 +2602,19 @@ tagmon(const Arg *arg) - setmon(sel, dirtomon(arg->i), 0); - } - -+void -+tagnthmon(const Arg *arg) -+{ -+ Client *sel = focustop(selmon); -+ Monitor *m = numtomon(arg->i); -+ if (!m || !sel) -+ return; -+ setmon(sel, m, 0); -+ -+ arrange(selmon); -+ arrange(m); -+} -+ - void - tile(Monitor *m) - { --- -2.44.0 - diff --git a/patches/bar.patch b/patches/bar.patch deleted file mode 100644 index e098118..0000000 --- a/patches/bar.patch +++ /dev/null @@ -1,1271 +0,0 @@ -From d6a2c4e7f0d3108c7a8a1ad6e76a62e854b2f8e1 Mon Sep 17 00:00:00 2001 -From: sewn -Date: Mon, 5 Jan 2026 16:51:14 +0300 -Subject: [PATCH] Implement dwm bar clone - ---- - Makefile | 2 +- - config.def.h | 33 ++-- - drwl.h | 310 +++++++++++++++++++++++++++++++++++ - dwl.c | 444 +++++++++++++++++++++++++++++++++++++++++---------- - 4 files changed, 697 insertions(+), 92 deletions(-) - create mode 100644 drwl.h - -diff --git a/Makefile b/Makefile -index 578194f..279b1c0 100644 ---- a/Makefile -+++ b/Makefile -@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \ - -Wfloat-conversion - - # CFLAGS / LDFLAGS --PKGS = wayland-server xkbcommon libinput $(XLIBS) -+PKGS = wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS) - DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) - LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS) - -diff --git a/config.def.h b/config.def.h -index 8a6eda0..7da50d2 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -7,15 +7,21 @@ - static const int sloppyfocus = 1; /* focus follows mouse */ - static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ - static const unsigned int borderpx = 1; /* border pixel of windows */ --static const float rootcolor[] = COLOR(0x222222ff); --static const float bordercolor[] = COLOR(0x444444ff); --static const float focuscolor[] = COLOR(0x005577ff); --static const float urgentcolor[] = COLOR(0xff0000ff); -+static const int showbar = 1; /* 0 means no bar */ -+static const int topbar = 1; /* 0 means bottom bar */ -+static const char *fonts[] = {"monospace:size=10"}; -+static const float rootcolor[] = COLOR(0x000000ff); - /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ - static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ -+static uint32_t colors[][3] = { -+ /* fg bg border */ -+ [SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff }, -+ [SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff }, -+ [SchemeUrg] = { 0, 0, 0x770000ff }, -+}; - --/* tagging - TAGCOUNT must be no greater than 31 */ --#define TAGCOUNT (9) -+/* tagging */ -+static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; - - /* logging */ - static int log_level = WLR_ERROR; -@@ -123,6 +129,7 @@ static const Key keys[] = { - /* modifier key function argument */ - { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, -+ { MODKEY, XKB_KEY_b, togglebar, {0} }, - { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, - { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, - { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, -@@ -166,7 +173,15 @@ static const Key keys[] = { - }; - - static const Button buttons[] = { -- { MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, -- { MODKEY, BTN_MIDDLE, togglefloating, {0} }, -- { MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, -+ { ClkLtSymbol, 0, BTN_LEFT, setlayout, {.v = &layouts[0]} }, -+ { ClkLtSymbol, 0, BTN_RIGHT, setlayout, {.v = &layouts[2]} }, -+ { ClkTitle, 0, BTN_MIDDLE, zoom, {0} }, -+ { ClkStatus, 0, BTN_MIDDLE, spawn, {.v = termcmd} }, -+ { ClkClient, MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, -+ { ClkClient, MODKEY, BTN_MIDDLE, togglefloating, {0} }, -+ { ClkClient, MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, -+ { ClkTagBar, 0, BTN_LEFT, view, {0} }, -+ { ClkTagBar, 0, BTN_RIGHT, toggleview, {0} }, -+ { ClkTagBar, MODKEY, BTN_LEFT, tag, {0} }, -+ { ClkTagBar, MODKEY, BTN_RIGHT, toggletag, {0} }, - }; -diff --git a/drwl.h b/drwl.h -new file mode 100644 -index 0000000..21afd21 ---- /dev/null -+++ b/drwl.h -@@ -0,0 +1,310 @@ -+/* -+ * drwl - https://codeberg.org/sewn/drwl -+ * -+ * Copyright (c) 2023-2025 sewn -+ * Copyright (c) 2024 notchoc -+ * -+ * 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 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. -+ * -+ * The UTF-8 Decoder included is from Bjoern Hoehrmann: -+ * Copyright (c) 2008-2010 Bjoern Hoehrmann -+ * See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. -+ */ -+#pragma once -+ -+#include -+#include -+#include -+ -+enum { ColFg, ColBg, ColBorder }; /* colorscheme index */ -+ -+typedef struct fcft_font Fnt; -+typedef pixman_image_t Img; -+ -+typedef struct { -+ Img *image; -+ Fnt *font; -+ uint32_t *scheme; -+} Drwl; -+ -+#define UTF8_ACCEPT 0 -+#define UTF8_REJECT 12 -+#define UTF8_INVALID 0xFFFD -+ -+static const uint8_t utf8d[] = { -+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, -+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, -+ 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, -+ 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, -+ -+ 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, -+ 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, -+ 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, -+ 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, -+ 12,36,12,12,12,12,12,12,12,12,12,12, -+}; -+ -+static inline uint32_t -+utf8decode(uint32_t *state, uint32_t *codep, uint8_t byte) -+{ -+ uint32_t type = utf8d[byte]; -+ -+ *codep = (*state != UTF8_ACCEPT) ? -+ (byte & 0x3fu) | (*codep << 6) : -+ (0xff >> type) & (byte); -+ -+ *state = utf8d[256 + *state + type]; -+ return *state; -+} -+ -+static int -+drwl_init(void) -+{ -+ return fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR); -+} -+ -+static Drwl * -+drwl_create(void) -+{ -+ Drwl *drwl; -+ -+ if (!(drwl = calloc(1, sizeof(Drwl)))) -+ return NULL; -+ -+ return drwl; -+} -+ -+static void -+drwl_setfont(Drwl *drwl, Fnt *font) -+{ -+ if (drwl) -+ drwl->font = font; -+} -+ -+static void -+drwl_setimage(Drwl *drwl, Img *image) -+{ -+ if (drwl) -+ drwl->image = image; -+} -+ -+static Fnt * -+drwl_font_create(Drwl *drwl, size_t count, -+ const char *names[static count], const char *attributes) -+{ -+ Fnt *font = fcft_from_name(count, names, attributes); -+ if (drwl) -+ drwl_setfont(drwl, font); -+ return font; -+} -+ -+static void -+drwl_font_destroy(Fnt *font) -+{ -+ fcft_destroy(font); -+} -+ -+static inline pixman_color_t -+convert_color(uint32_t clr) -+{ -+ return (pixman_color_t){ -+ ((clr >> 24) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF, -+ ((clr >> 16) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF, -+ ((clr >> 8) & 0xFF) * 0x101 * (clr & 0xFF) / 0xFF, -+ (clr & 0xFF) * 0x101 -+ }; -+} -+ -+static void -+drwl_setscheme(Drwl *drwl, uint32_t *scm) -+{ -+ if (drwl) -+ drwl->scheme = scm; -+} -+ -+static Img * -+drwl_image_create(Drwl *drwl, unsigned int w, unsigned int h, uint32_t *bits) -+{ -+ Img *image; -+ pixman_region32_t clip; -+ -+ image = pixman_image_create_bits_no_clear( -+ PIXMAN_a8r8g8b8, w, h, bits, w * 4); -+ if (!image) -+ return NULL; -+ pixman_region32_init_rect(&clip, 0, 0, w, h); -+ pixman_image_set_clip_region32(image, &clip); -+ pixman_region32_fini(&clip); -+ -+ if (drwl) -+ drwl_setimage(drwl, image); -+ return image; -+} -+ -+static void -+drwl_rect(Drwl *drwl, -+ int x, int y, unsigned int w, unsigned int h, -+ int filled, int invert) -+{ -+ pixman_color_t clr; -+ if (!drwl || !drwl->scheme || !drwl->image) -+ return; -+ -+ clr = convert_color(drwl->scheme[invert ? ColBg : ColFg]); -+ if (filled) -+ pixman_image_fill_rectangles(PIXMAN_OP_SRC, drwl->image, &clr, 1, -+ &(pixman_rectangle16_t){x, y, w, h}); -+ else -+ pixman_image_fill_rectangles(PIXMAN_OP_SRC, drwl->image, &clr, 4, -+ (pixman_rectangle16_t[4]){ -+ { x, y, w, 1 }, -+ { x, y + h - 1, w, 1 }, -+ { x, y, 1, h }, -+ { x + w - 1, y, 1, h }}); -+} -+ -+static int -+drwl_text(Drwl *drwl, -+ int x, int y, unsigned int w, unsigned int h, -+ unsigned int lpad, const char *text, int invert) -+{ -+ int ty; -+ int render = x || y || w || h; -+ long x_kern; -+ uint32_t cp = 0, last_cp = 0, state; -+ pixman_color_t clr; -+ pixman_image_t *fg_pix = NULL; -+ int noellipsis = 0; -+ const struct fcft_glyph *glyph, *eg = NULL; -+ int fcft_subpixel_mode = FCFT_SUBPIXEL_DEFAULT; -+ -+ if (!drwl || (render && (!drwl->scheme || !w || !drwl->image)) || !text || !drwl->font) -+ return 0; -+ -+ if (!render) { -+ w = invert ? invert : ~invert; -+ } else { -+ clr = convert_color(drwl->scheme[invert ? ColBg : ColFg]); -+ fg_pix = pixman_image_create_solid_fill(&clr); -+ -+ drwl_rect(drwl, x, y, w, h, 1, !invert); -+ -+ x += lpad; -+ w -= lpad; -+ } -+ -+ if (render && (drwl->scheme[ColBg] & 0xFF) != 0xFF) -+ fcft_subpixel_mode = FCFT_SUBPIXEL_NONE; -+ -+ if (render) -+ eg = fcft_rasterize_char_utf32(drwl->font, 0x2026 /* … */, fcft_subpixel_mode); -+ -+ for (const char *p = text, *pp; pp = p, *p; p++) { -+ for (state = UTF8_ACCEPT; *p && -+ utf8decode(&state, &cp, *p) > UTF8_REJECT; p++) -+ ; -+ if (!*p || state == UTF8_REJECT) { -+ cp = UTF8_INVALID; -+ if (p > pp) -+ p--; -+ } -+ -+ glyph = fcft_rasterize_char_utf32(drwl->font, cp, fcft_subpixel_mode); -+ if (!glyph) -+ continue; -+ -+ x_kern = 0; -+ if (last_cp) -+ fcft_kerning(drwl->font, last_cp, cp, &x_kern, NULL); -+ last_cp = cp; -+ -+ ty = y + (h - drwl->font->height) / 2 + drwl->font->ascent; -+ -+ if (render && !noellipsis && x_kern + glyph->advance.x + eg->advance.x > w && -+ *(p + 1) != '\0') { -+ /* cannot fit ellipsis after current codepoint */ -+ if (drwl_text(drwl, 0, 0, 0, 0, 0, pp, 0) + x_kern <= w) { -+ noellipsis = 1; -+ } else { -+ w -= eg->advance.x; -+ pixman_image_composite32( -+ PIXMAN_OP_OVER, fg_pix, eg->pix, drwl->image, 0, 0, 0, 0, -+ x + eg->x, ty - eg->y, eg->width, eg->height); -+ } -+ } -+ -+ if ((x_kern + glyph->advance.x) > w) -+ break; -+ -+ x += x_kern; -+ -+ if (render && pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8) -+ /* pre-rendered glyphs (eg. emoji) */ -+ pixman_image_composite32( -+ PIXMAN_OP_OVER, glyph->pix, NULL, drwl->image, 0, 0, 0, 0, -+ x + glyph->x, ty - glyph->y, glyph->width, glyph->height); -+ else if (render) -+ pixman_image_composite32( -+ PIXMAN_OP_OVER, fg_pix, glyph->pix, drwl->image, 0, 0, 0, 0, -+ x + glyph->x, ty - glyph->y, glyph->width, glyph->height); -+ -+ x += glyph->advance.x; -+ w -= glyph->advance.x; -+ } -+ -+ if (render) -+ pixman_image_unref(fg_pix); -+ -+ return x + (render ? w : 0); -+} -+ -+static unsigned int -+drwl_font_getwidth(Drwl *drwl, const char *text) -+{ -+ if (!drwl || !drwl->font || !text) -+ return 0; -+ return drwl_text(drwl, 0, 0, 0, 0, 0, text, 0); -+} -+ -+static void -+drwl_image_destroy(Img *image) -+{ -+ pixman_image_unref(image); -+} -+ -+static void -+drwl_destroy(Drwl *drwl) -+{ -+ if (drwl->font) -+ drwl_font_destroy(drwl->font); -+ if (drwl->image) -+ drwl_image_destroy(drwl->image); -+ free(drwl); -+} -+ -+static void -+drwl_fini(void) -+{ -+ fcft_fini(); -+} -diff --git a/dwl.c b/dwl.c -index 44f3ad9..7b2abf5 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -1,10 +1,12 @@ - /* - * See LICENSE file for copyright and license details. - */ -+#include - #include - #include - #include - #include -+#include - #include - #include - #include -@@ -59,6 +61,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -69,6 +72,7 @@ - #endif - - #include "util.h" -+#include "drwl.h" - - /* macros */ - #define MAX(A, B) ((A) > (B) ? (A) : (B)) -@@ -77,14 +81,17 @@ - #define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) - #define LENGTH(X) (sizeof X / sizeof X[0]) - #define END(A) ((A) + LENGTH(A)) --#define TAGMASK ((1u << TAGCOUNT) - 1) -+#define TAGMASK ((1u << LENGTH(tags)) - 1) - #define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L))) - #define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0) -+#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad) - - /* enums */ -+enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */ - enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ - enum { XDGShell, LayerShell, X11 }; /* client types */ - enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */ -+enum { ClkTagBar, ClkLtSymbol, ClkStatus, ClkTitle, ClkClient, ClkRoot }; /* clicks */ - - typedef union { - int i; -@@ -94,6 +101,7 @@ typedef union { - } Arg; - - typedef struct { -+ unsigned int click; - unsigned int mod; - unsigned int button; - void (*func)(const Arg *); -@@ -183,10 +191,19 @@ typedef struct { - void (*arrange)(Monitor *); - } Layout; - -+typedef struct { -+ struct wlr_buffer base; -+ struct wl_listener release; -+ bool busy; -+ Img *image; -+ uint32_t data[]; -+} Buffer; -+ - struct Monitor { - struct wl_list link; - struct wlr_output *wlr_output; - struct wlr_scene_output *scene_output; -+ struct wlr_scene_buffer *scene_buffer; /* bar buffer */ - struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */ - struct wl_listener frame; - struct wl_listener destroy; -@@ -194,6 +211,11 @@ struct Monitor { - struct wl_listener destroy_lock_surface; - struct wlr_session_lock_surface_v1 *lock_surface; - struct wlr_box m; /* monitor area, layout-relative */ -+ struct { -+ int width, height; -+ int real_width, real_height; /* non-scaled */ -+ float scale; -+ } b; /* bar area */ - struct wlr_box w; /* window area, layout-relative */ - struct wl_list layers[4]; /* LayerSurface.link */ - const Layout *lt[2]; -@@ -205,6 +227,9 @@ struct Monitor { - int nmaster; - char ltsymbol[16]; - int asleep; -+ Drwl *drw; -+ Buffer *pool[2]; -+ int lrpad; - }; - - typedef struct { -@@ -247,6 +272,13 @@ static void arrangelayer(Monitor *m, struct wl_list *list, - struct wlr_box *usable_area, int exclusive); - static void arrangelayers(Monitor *m); - static void axisnotify(struct wl_listener *listener, void *data); -+static bool baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy); -+static void bufdestroy(struct wlr_buffer *buffer); -+static bool bufdatabegin(struct wlr_buffer *buffer, uint32_t flags, -+ void **data, uint32_t *format, size_t *stride); -+static void bufdataend(struct wlr_buffer *buffer); -+static Buffer *bufmon(Monitor *m); -+static void bufrelease(struct wl_listener *listener, void *data); - static void buttonpress(struct wl_listener *listener, void *data); - static void chvt(const Arg *arg); - static void checkidleinhibitor(struct wlr_surface *exclude); -@@ -282,6 +314,8 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data); - static void destroysessionlock(struct wl_listener *listener, void *data); - static void destroykeyboardgroup(struct wl_listener *listener, void *data); - static Monitor *dirtomon(enum wlr_direction dir); -+static void drawbar(Monitor *m); -+static void drawbars(void); - static void focusclient(Client *c, int lift); - static void focusmon(const Arg *arg); - static void focusstack(const Arg *arg); -@@ -310,7 +344,6 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int - static void outputmgrtest(struct wl_listener *listener, void *data); - static void pointerfocus(Client *c, struct wlr_surface *surface, - double sx, double sy, uint32_t time); --static void printstatus(void); - static void powermgrsetmode(struct wl_listener *listener, void *data); - static void quit(const Arg *arg); - static void rendermon(struct wl_listener *listener, void *data); -@@ -331,9 +364,11 @@ static void setsel(struct wl_listener *listener, void *data); - static void setup(void); - static void spawn(const Arg *arg); - static void startdrag(struct wl_listener *listener, void *data); -+static int statusin(int fd, unsigned int mask, void *data); - static void tag(const Arg *arg); - static void tagmon(const Arg *arg); - static void tile(Monitor *m); -+static void togglebar(const Arg *arg); - static void togglefloating(const Arg *arg); - static void togglefullscreen(const Arg *arg); - static void toggletag(const Arg *arg); -@@ -342,6 +377,7 @@ static void unlocksession(struct wl_listener *listener, void *data); - static void unmaplayersurfacenotify(struct wl_listener *listener, void *data); - static void unmapnotify(struct wl_listener *listener, void *data); - static void updatemons(struct wl_listener *listener, void *data); -+static void updatebar(Monitor *m); - static void updatetitle(struct wl_listener *listener, void *data); - static void urgent(struct wl_listener *listener, void *data); - static void view(const Arg *arg); -@@ -406,6 +442,15 @@ static struct wlr_box sgeom; - static struct wl_list mons; - static Monitor *selmon; - -+static char stext[256]; -+static struct wl_event_source *status_event_source; -+ -+static const struct wlr_buffer_impl buffer_impl = { -+ .destroy = bufdestroy, -+ .begin_data_ptr_access = bufdatabegin, -+ .end_data_ptr_access = bufdataend, -+}; -+ - /* global event handlers */ - static struct wl_listener cursor_axis = {.notify = axisnotify}; - static struct wl_listener cursor_button = {.notify = buttonpress}; -@@ -521,7 +566,7 @@ arrange(Monitor *m) - wlr_scene_node_set_enabled(&m->fullscreen_bg->node, - (c = focustop(m)) && c->isfullscreen); - -- strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); -+ strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol)); - - /* We move all clients (except fullscreen and unmanaged) to LyrTile while - * in floating layout to avoid "real" floating clients be always on top */ -@@ -576,6 +621,11 @@ arrangelayers(Monitor *m) - if (!m->wlr_output->enabled) - return; - -+ if (m->scene_buffer->node.enabled) { -+ usable_area.height -= m->b.real_height; -+ usable_area.y += topbar ? m->b.real_height : 0; -+ } -+ - /* Arrange exclusive surfaces from top->bottom */ - for (i = 3; i >= 0; i--) - arrangelayer(m, &m->layers[i], &usable_area, 1); -@@ -618,17 +668,102 @@ axisnotify(struct wl_listener *listener, void *data) - event->delta_discrete, event->source, event->relative_direction); - } - -+bool -+baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy) -+{ -+ return true; -+} -+ -+void -+bufdestroy(struct wlr_buffer *wlr_buffer) -+{ -+ Buffer *buf = wl_container_of(wlr_buffer, buf, base); -+ if (buf->busy) -+ wl_list_remove(&buf->release.link); -+ drwl_image_destroy(buf->image); -+ free(buf); -+} -+ -+bool -+bufdatabegin(struct wlr_buffer *wlr_buffer, uint32_t flags, -+ void **data, uint32_t *format, size_t *stride) -+{ -+ Buffer *buf = wl_container_of(wlr_buffer, buf, base); -+ -+ if (flags & WLR_BUFFER_DATA_PTR_ACCESS_WRITE) return false; -+ -+ *data = buf->data; -+ *stride = wlr_buffer->width * 4; -+ *format = DRM_FORMAT_ARGB8888; -+ -+ return true; -+} -+ -+void -+bufdataend(struct wlr_buffer *wlr_buffer) -+{ -+} -+ -+Buffer * -+bufmon(Monitor *m) -+{ -+ size_t i; -+ Buffer *buf = NULL; -+ -+ for (i = 0; i < LENGTH(m->pool); i++) { -+ if (m->pool[i]) { -+ if (m->pool[i]->busy) -+ continue; -+ buf = m->pool[i]; -+ break; -+ } -+ -+ buf = ecalloc(1, sizeof(Buffer) + (m->b.width * 4 * m->b.height)); -+ buf->image = drwl_image_create(NULL, m->b.width, m->b.height, buf->data); -+ wlr_buffer_init(&buf->base, &buffer_impl, m->b.width, m->b.height); -+ m->pool[i] = buf; -+ break; -+ } -+ if (!buf) -+ return NULL; -+ -+ buf->busy = true; -+ LISTEN(&buf->base.events.release, &buf->release, bufrelease); -+ wlr_buffer_lock(&buf->base); -+ drwl_setimage(m->drw, buf->image); -+ return buf; -+} -+ -+void -+bufrelease(struct wl_listener *listener, void *data) -+{ -+ Buffer *buf = wl_container_of(listener, buf, release); -+ buf->busy = false; -+ wl_list_remove(&buf->release.link); -+} -+ - void - buttonpress(struct wl_listener *listener, void *data) - { -+ unsigned int i = 0, x = 0; -+ double cx; -+ unsigned int click; - struct wlr_pointer_button_event *event = data; - struct wlr_keyboard *keyboard; -+ struct wlr_scene_node *node; -+ struct wlr_scene_buffer *buffer; - uint32_t mods; -+ Arg arg = {0}; - Client *c; - const Button *b; - - wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); - -+ click = ClkRoot; -+ xytonode(cursor->x, cursor->y, NULL, &c, NULL, NULL, NULL); -+ if (c) -+ click = ClkClient; -+ - switch (event->state) { - case WL_POINTER_BUTTON_STATE_PRESSED: - cursor_mode = CurPressed; -@@ -636,17 +771,34 @@ buttonpress(struct wl_listener *listener, void *data) - if (locked) - break; - -+ if (!c && !exclusive_focus && -+ (node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) && -+ (buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) { -+ cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale; -+ do -+ x += TEXTW(selmon, tags[i]); -+ while (cx >= x && ++i < LENGTH(tags)); -+ if (i < LENGTH(tags)) { -+ click = ClkTagBar; -+ arg.ui = 1 << i; -+ } else if (cx < x + TEXTW(selmon, selmon->ltsymbol)) -+ click = ClkLtSymbol; -+ else if (cx > selmon->b.width - (TEXTW(selmon, stext) - selmon->lrpad + 2)) { -+ click = ClkStatus; -+ } else -+ click = ClkTitle; -+ } -+ - /* Change focus if the button was _pressed_ over a client */ - xytonode(cursor->x, cursor->y, NULL, &c, NULL, NULL, NULL); -- if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) -+ if (click == ClkClient && (!client_is_unmanaged(c) || client_wants_focus(c))) - focusclient(c, 1); - - keyboard = wlr_seat_get_keyboard(seat); - mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; - for (b = buttons; b < END(buttons); b++) { -- if (CLEANMASK(mods) == CLEANMASK(b->mod) && -- event->button == b->button && b->func) { -- b->func(&b->arg); -+ if (CLEANMASK(mods) == CLEANMASK(b->mod) && event->button == b->button && click == b->click && b->func) { -+ b->func(click == ClkTagBar && b->arg.i == 0 ? &arg : &b->arg); - return; - } - } -@@ -721,6 +873,8 @@ cleanup(void) - /* Destroy after the wayland display (when the monitors are already destroyed) - to avoid destroying them with an invalid scene output. */ - wlr_scene_node_destroy(&scene->tree.node); -+ -+ drwl_fini(); - } - - void -@@ -736,6 +890,12 @@ cleanupmon(struct wl_listener *listener, void *data) - wlr_layer_surface_v1_destroy(l->layer_surface); - } - -+ for (i = 0; i < LENGTH(m->pool); i++) -+ wlr_buffer_drop(&m->pool[i]->base); -+ -+ drwl_setimage(m->drw, NULL); -+ drwl_destroy(m->drw); -+ - wl_list_remove(&m->destroy.link); - wl_list_remove(&m->frame.link); - wl_list_remove(&m->link); -@@ -748,6 +908,7 @@ cleanupmon(struct wl_listener *listener, void *data) - - closemon(m); - wlr_scene_node_destroy(&m->fullscreen_bg->node); -+ wlr_scene_node_destroy(&m->scene_buffer->node); - free(m); - } - -@@ -814,7 +975,7 @@ closemon(Monitor *m) - setmon(c, selmon, c->tags); - } - focusclient(focustop(selmon), 1); -- printstatus(); -+ drawbars(); - } - - void -@@ -1066,7 +1227,7 @@ createmon(struct wl_listener *listener, void *data) - m->nmaster = r->nmaster; - m->lt[0] = r->lt; - m->lt[1] = &layouts[LENGTH(layouts) > 1 && r->lt != &layouts[1]]; -- strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); -+ strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol)); - wlr_output_state_set_scale(&state, r->scale); - wlr_output_state_set_transform(&state, r->rr); - break; -@@ -1088,8 +1249,15 @@ createmon(struct wl_listener *listener, void *data) - wlr_output_commit_state(wlr_output, &state); - wlr_output_state_finish(&state); - -+ if (!(m->drw = drwl_create())) -+ die("failed to create drwl context"); -+ -+ m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL); -+ m->scene_buffer->point_accepts_input = baracceptsinput; -+ updatebar(m); -+ - wl_list_insert(&mons, &m->link); -- printstatus(); -+ drawbars(); - - /* The xdg-protocol specifies: - * -@@ -1399,6 +1567,80 @@ dirtomon(enum wlr_direction dir) - return selmon; - } - -+void -+drawbar(Monitor *m) -+{ -+ int x, w, tw = 0; -+ int boxs = m->drw->font->height / 9; -+ int boxw = m->drw->font->height / 6 + 2; -+ uint32_t i, occ = 0, urg = 0; -+ Client *c; -+ Buffer *buf; -+ -+ if (!m->scene_buffer->node.enabled) -+ return; -+ if (!(buf = bufmon(m))) -+ return; -+ -+ /* draw status first so it can be overdrawn by tags later */ -+ if (m == selmon) { /* status is only drawn on selected monitor */ -+ drwl_setscheme(m->drw, colors[SchemeNorm]); -+ tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */ -+ drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0); -+ } -+ -+ wl_list_for_each(c, &clients, link) { -+ if (c->mon != m) -+ continue; -+ occ |= c->tags; -+ if (c->isurgent) -+ urg |= c->tags; -+ } -+ x = 0; -+ c = focustop(m); -+ for (i = 0; i < LENGTH(tags); i++) { -+ w = TEXTW(m, tags[i]); -+ drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); -+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i); -+ if (occ & 1 << i) -+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, -+ m == selmon && c && c->tags & 1 << i, -+ urg & 1 << i); -+ x += w; -+ } -+ w = TEXTW(m, m->ltsymbol); -+ drwl_setscheme(m->drw, colors[SchemeNorm]); -+ x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0); -+ -+ if ((w = m->b.width - tw - x) > m->b.height) { -+ if (c) { -+ drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]); -+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0); -+ if (c && c->isfloating) -+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0); -+ } else { -+ drwl_setscheme(m->drw, colors[SchemeNorm]); -+ drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1); -+ } -+ } -+ -+ wlr_scene_buffer_set_dest_size(m->scene_buffer, -+ m->b.real_width, m->b.real_height); -+ wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x, -+ m->m.y + (topbar ? 0 : m->m.height - m->b.real_height)); -+ wlr_scene_buffer_set_buffer(m->scene_buffer, &buf->base); -+ wlr_buffer_unlock(&buf->base); -+} -+ -+void -+drawbars(void) -+{ -+ Monitor *m = NULL; -+ -+ wl_list_for_each(m, &mons, link) -+ drawbar(m); -+} -+ - void - focusclient(Client *c, int lift) - { -@@ -1433,13 +1675,13 @@ focusclient(Client *c, int lift) - /* Don't change border color if there is an exclusive focus or we are - * handling a drag operation */ - if (!exclusive_focus && !seat->drag) -- client_set_border_color(c, focuscolor); -+ client_set_border_color(c, (float[])COLOR(colors[SchemeSel][ColBorder])); - } - - /* Deactivate old client if focus is changing */ - if (old && (!c || client_surface(c) != old)) { - /* If an overlay is focused, don't focus or activate the client, -- * but only update its position in fstack to render its border with focuscolor -+ * but only update its position in fstack to render its border with its color - * and focus it after the overlay is closed. */ - if (old_client_type == LayerShell && wlr_scene_node_coords( - &old_l->scene->node, &unused_lx, &unused_ly) -@@ -1450,12 +1692,11 @@ focusclient(Client *c, int lift) - /* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg - * and probably other clients */ - } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { -- client_set_border_color(old_c, bordercolor); -- -+ client_set_border_color(old_c, (float[])COLOR(colors[SchemeNorm][ColBorder])); - client_activate_surface(old, 0); - } - } -- printstatus(); -+ drawbars(); - - if (!c) { - /* With no client, all we have left is to clear focus */ -@@ -1769,7 +2010,7 @@ mapnotify(struct wl_listener *listener, void *data) - - for (i = 0; i < 4; i++) { - c->border[i] = wlr_scene_rect_create(c->scene, 0, 0, -- c->isurgent ? urgentcolor : bordercolor); -+ (float[])COLOR(colors[c->isurgent ? SchemeUrg : SchemeNorm][ColBorder])); - c->border[i]->node.data = c; - } - -@@ -1792,7 +2033,7 @@ mapnotify(struct wl_listener *listener, void *data) - } else { - applyrules(c); - } -- printstatus(); -+ drawbars(); - - unset_fullscreen: - m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y); -@@ -2085,44 +2326,6 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, - wlr_seat_pointer_notify_motion(seat, time, sx, sy); - } - --void --printstatus(void) --{ -- Monitor *m = NULL; -- Client *c; -- uint32_t occ, urg, sel; -- -- wl_list_for_each(m, &mons, link) { -- occ = urg = 0; -- wl_list_for_each(c, &clients, link) { -- if (c->mon != m) -- continue; -- occ |= c->tags; -- if (c->isurgent) -- urg |= c->tags; -- } -- if ((c = focustop(m))) { -- printf("%s title %s\n", m->wlr_output->name, client_get_title(c)); -- printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c)); -- printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen); -- printf("%s floating %d\n", m->wlr_output->name, c->isfloating); -- sel = c->tags; -- } else { -- printf("%s title \n", m->wlr_output->name); -- printf("%s appid \n", m->wlr_output->name); -- printf("%s fullscreen \n", m->wlr_output->name); -- printf("%s floating \n", m->wlr_output->name); -- sel = 0; -- } -- -- printf("%s selmon %u\n", m->wlr_output->name, m == selmon); -- printf("%s tags %"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"\n", -- m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg); -- printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol); -- } -- fflush(stdout); --} -- - void - powermgrsetmode(struct wl_listener *listener, void *data) - { -@@ -2251,22 +2454,14 @@ run(char *startup_cmd) - - /* Now that the socket exists and the backend is started, run the startup command */ - if (startup_cmd) { -- int piperw[2]; -- if (pipe(piperw) < 0) -- die("startup: pipe:"); - if ((child_pid = fork()) < 0) - die("startup: fork:"); - if (child_pid == 0) { -+ close(STDIN_FILENO); - setsid(); -- dup2(piperw[0], STDIN_FILENO); -- close(piperw[0]); -- close(piperw[1]); - execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL); - die("startup: execl:"); - } -- dup2(piperw[1], STDOUT_FILENO); -- close(piperw[1]); -- close(piperw[0]); - } - - /* Mark stdout as non-blocking to avoid the startup script -@@ -2276,7 +2471,7 @@ run(char *startup_cmd) - if (fd_set_nonblock(STDOUT_FILENO) < 0) - close(STDOUT_FILENO); - -- printstatus(); -+ drawbars(); - - /* At this point the outputs are initialized, choose initial selmon based on - * cursor position, and set default cursor image */ -@@ -2342,7 +2537,7 @@ setfloating(Client *c, int floating) - (p && p->isfullscreen) ? LyrFS - : c->isfloating ? LyrFloat : LyrTile]); - arrange(c->mon); -- printstatus(); -+ drawbars(); - } - - void -@@ -2365,7 +2560,7 @@ setfullscreen(Client *c, int fullscreen) - resize(c, c->prev, 0); - } - arrange(c->mon); -- printstatus(); -+ drawbars(); - } - - void -@@ -2377,9 +2572,9 @@ setlayout(const Arg *arg) - selmon->sellt ^= 1; - if (arg && arg->v) - selmon->lt[selmon->sellt] = (Layout *)arg->v; -- strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol)); -+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof(selmon->ltsymbol)); - arrange(selmon); -- printstatus(); -+ drawbar(selmon); - } - - /* arg > 1.0 will set mfact absolutely */ -@@ -2452,6 +2647,7 @@ setup(void) - for (i = 0; i < (int)LENGTH(sig); i++) - sigaction(sig[i], &sa, NULL); - -+ - wlr_log_init(log_level, NULL); - - /* The Wayland display is managed by libwayland. It handles accepting -@@ -2646,6 +2842,11 @@ setup(void) - wl_signal_add(&output_mgr->events.apply, &output_mgr_apply); - wl_signal_add(&output_mgr->events.test, &output_mgr_test); - -+ drwl_init(); -+ -+ status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy), -+ STDIN_FILENO, WL_EVENT_READABLE, statusin, NULL); -+ - /* Make sure XWayland clients don't connect to the parent X server, - * e.g when running in the x11 backend or the wayland backend and the - * compositor has Xwayland support */ -@@ -2670,6 +2871,8 @@ void - spawn(const Arg *arg) - { - if (fork() == 0) { -+ close(STDIN_FILENO); -+ open("/dev/null", O_RDWR); - dup2(STDERR_FILENO, STDOUT_FILENO); - setsid(); - execvp(((char **)arg->v)[0], (char **)arg->v); -@@ -2688,6 +2891,30 @@ startdrag(struct wl_listener *listener, void *data) - LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon); - } - -+int -+statusin(int fd, unsigned int mask, void *data) -+{ -+ char status[256]; -+ ssize_t n; -+ -+ if (mask & WL_EVENT_ERROR) -+ die("status in event error"); -+ if (mask & WL_EVENT_HANGUP) -+ wl_event_source_remove(status_event_source); -+ -+ n = read(fd, status, sizeof(status) - 1); -+ if (n < 0 && errno != EWOULDBLOCK) -+ die("read:"); -+ -+ status[n] = '\0'; -+ status[strcspn(status, "\n")] = '\0'; -+ -+ strncpy(stext, status, sizeof(stext)); -+ drawbars(); -+ -+ return 0; -+} -+ - void - tag(const Arg *arg) - { -@@ -2698,7 +2925,7 @@ tag(const Arg *arg) - sel->tags = arg->ui & TAGMASK; - focusclient(focustop(selmon), 1); - arrange(selmon); -- printstatus(); -+ drawbars(); - } - - void -@@ -2743,6 +2970,15 @@ tile(Monitor *m) - } - } - -+void -+togglebar(const Arg *arg) -+{ -+ wlr_scene_node_set_enabled(&selmon->scene_buffer->node, -+ !selmon->scene_buffer->node.enabled); -+ arrangelayers(selmon); -+ drawbars(); -+} -+ - void - togglefloating(const Arg *arg) - { -@@ -2771,7 +3007,7 @@ toggletag(const Arg *arg) - sel->tags = newtags; - focusclient(focustop(selmon), 1); - arrange(selmon); -- printstatus(); -+ drawbars(); - } - - void -@@ -2784,7 +3020,7 @@ toggleview(const Arg *arg) - selmon->tagset[selmon->seltags] = newtagset; - focusclient(focustop(selmon), 1); - arrange(selmon); -- printstatus(); -+ drawbars(); - } - - void -@@ -2832,7 +3068,7 @@ unmapnotify(struct wl_listener *listener, void *data) - } - - wlr_scene_node_destroy(&c->scene->node); -- printstatus(); -+ drawbars(); - motionnotify(0, NULL, 0, 0, 0, 0); - } - -@@ -2932,6 +3168,13 @@ updatemons(struct wl_listener *listener, void *data) - } - } - -+ if (stext[0] == '\0') -+ strncpy(stext, "dwl-"VERSION, sizeof(stext)); -+ wl_list_for_each(m, &mons, link) { -+ updatebar(m); -+ drawbar(m); -+ } -+ - /* FIXME: figure out why the cursor image is at 0,0 after turning all - * the monitors on. - * Move the cursor image where it used to be. It does not generate a -@@ -2942,12 +3185,45 @@ updatemons(struct wl_listener *listener, void *data) - wlr_output_manager_v1_set_configuration(output_mgr, config); - } - -+void -+updatebar(Monitor *m) -+{ -+ size_t i; -+ int rw, rh; -+ char fontattrs[12]; -+ -+ wlr_output_transformed_resolution(m->wlr_output, &rw, &rh); -+ m->b.width = rw; -+ m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale); -+ -+ wlr_scene_node_set_enabled(&m->scene_buffer->node, m->wlr_output->enabled ? showbar : 0); -+ -+ for (i = 0; i < LENGTH(m->pool); i++) -+ if (m->pool[i]) { -+ wlr_buffer_drop(&m->pool[i]->base); -+ m->pool[i] = NULL; -+ } -+ -+ if (m->b.scale == m->wlr_output->scale && m->drw) -+ return; -+ -+ drwl_font_destroy(m->drw->font); -+ snprintf(fontattrs, sizeof(fontattrs), "dpi=%.2f", 96. * m->wlr_output->scale); -+ if (!(drwl_font_create(m->drw, LENGTH(fonts), fonts, fontattrs))) -+ die("Could not load font"); -+ -+ m->b.scale = m->wlr_output->scale; -+ m->lrpad = m->drw->font->height; -+ m->b.height = m->drw->font->height + 2; -+ m->b.real_height = (int)((float)m->b.height / m->wlr_output->scale); -+} -+ - void - updatetitle(struct wl_listener *listener, void *data) - { - Client *c = wl_container_of(listener, c, set_title); - if (c == focustop(c->mon)) -- printstatus(); -+ drawbars(); - } - - void -@@ -2960,10 +3236,10 @@ urgent(struct wl_listener *listener, void *data) - return; - - c->isurgent = 1; -- printstatus(); -+ drawbars(); - - if (client_surface(c)->mapped) -- client_set_border_color(c, urgentcolor); -+ client_set_border_color(c, (float[])COLOR(colors[SchemeUrg][ColBorder])); - } - - void -@@ -2976,7 +3252,7 @@ view(const Arg *arg) - selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; - focusclient(focustop(selmon), 1); - arrange(selmon); -- printstatus(); -+ drawbars(); - } - - void -@@ -3017,6 +3293,7 @@ xytonode(double x, double y, struct wlr_surface **psurface, - { - struct wlr_scene_node *node, *pnode; - struct wlr_surface *surface = NULL; -+ struct wlr_scene_surface *scene_surface = NULL; - Client *c = NULL; - LayerSurface *l = NULL; - int layer; -@@ -3025,9 +3302,12 @@ xytonode(double x, double y, struct wlr_surface **psurface, - if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny))) - continue; - -- if (node->type == WLR_SCENE_NODE_BUFFER) -- surface = wlr_scene_surface_try_from_buffer( -- wlr_scene_buffer_from_node(node))->surface; -+ if (node->type == WLR_SCENE_NODE_BUFFER) { -+ scene_surface = wlr_scene_surface_try_from_buffer( -+ wlr_scene_buffer_from_node(node)); -+ if (!scene_surface) continue; -+ surface = scene_surface->surface; -+ } - /* Walk the tree to find a node that knows the client */ - for (pnode = node; pnode && !c; pnode = &pnode->parent->node) - c = pnode->data; -@@ -3160,10 +3440,10 @@ sethints(struct wl_listener *listener, void *data) - return; - - c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints); -- printstatus(); -+ drawbars(); - - if (c->isurgent && surface && surface->mapped) -- client_set_border_color(c, urgentcolor); -+ client_set_border_color(c, (float[])COLOR(colors[SchemeUrg][ColBorder])); - } - - void --- -2.52.0 - diff --git a/patches/dim-unfocused.patch b/patches/dim-unfocused.patch deleted file mode 100644 index baf410b..0000000 --- a/patches/dim-unfocused.patch +++ /dev/null @@ -1,216 +0,0 @@ -diff --git a/client.h b/client.h -index dabea35..3a31c25 100644 ---- a/client.h -+++ b/client.h -@@ -319,6 +319,12 @@ client_set_border_color(Client *c, const float color[static 4]) - wlr_scene_rect_set_color(c->border[i], color); - } - -+static inline void -+client_set_dimmer_state(Client *c, const int dim) -+{ -+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim); -+} -+ - static inline void - client_set_fullscreen(Client *c, int fullscreen) - { -diff --git a/config.def.h b/config.def.h -index 22d2171..4ca21c9 100644 ---- a/config.h -+++ b/config.h -@@ -10,6 +10,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ - static const float rootcolor[] = COLOR(0x222222ff); - static const float bordercolor[] = COLOR(0x444444ff); - static const float focuscolor[] = COLOR(0x005577ff); -+static const float unfocuseddim[] = COLOR(0x00000088); - static const float urgentcolor[] = COLOR(0xff0000ff); - /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ - static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ -@@ -22,10 +23,11 @@ static int log_level = WLR_ERROR; - - /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ - static const Rule rules[] = { -- /* app_id title tags mask isfloating monitor */ -- /* examples: */ -- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */ -- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */ -+ /* app_id title tags mask isfloating neverdim monitor */ -+ /* examples: -+ { "Gimp_example", NULL, 0, 1, 0, -1 }, -+ */ -+ { "firefox_example", NULL, 1 << 8, 0, 1, -1 }, - }; - - /* layout(s) */ -@@ -140,8 +142,9 @@ static const Key keys[] = { - { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XKB_KEY_space, setlayout, {0} }, -+ { MODKEY, XKB_KEY_apostrophe, toggledimming, {0} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, -- { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, -+ { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, - { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, - { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, -@@ -172,5 +175,6 @@ static const Key keys[] = { - static const Button buttons[] = { - { MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} }, - { MODKEY, BTN_MIDDLE, togglefloating, {0} }, -+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} }, - { MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, - }; -diff --git a/dwl.c b/dwl.c -index dc0c861..dcc3ece 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -112,6 +112,7 @@ typedef struct { - Monitor *mon; - struct wlr_scene_tree *scene; - struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ -+ struct wlr_scene_rect *dimmer; - struct wlr_scene_tree *scene_surface; - struct wl_list link; - struct wl_list flink; -@@ -141,7 +142,7 @@ typedef struct { - #endif - unsigned int bw; - uint32_t tags; -- int isfloating, isurgent, isfullscreen; -+ int isfloating, isurgent, isfullscreen, neverdim; - uint32_t resize; /* configure serial of a pending resize */ - } Client; - -@@ -231,6 +232,7 @@ typedef struct { - const char *title; - uint32_t tags; - int isfloating; -+ int neverdim; - int monitor; - } Rule; - -@@ -338,6 +340,8 @@ static void startdrag(struct wl_listener *listener, void *data); - static void tag(const Arg *arg); - static void tagmon(const Arg *arg); - static void tile(Monitor *m); -+static void toggledimming(const Arg *arg); -+static void toggledimmingclient(const Arg *arg); - static void togglefloating(const Arg *arg); - static void togglefullscreen(const Arg *arg); - static void toggletag(const Arg *arg); -@@ -410,6 +414,7 @@ static struct wlr_output_layout *output_layout; - static struct wlr_box sgeom; - static struct wl_list mons; - static Monitor *selmon; -+static int DIMOPT = 1; - - #ifdef XWAYLAND - static void activatex11(struct wl_listener *listener, void *data); -@@ -466,6 +471,7 @@ applyrules(Client *c) - if ((!r->title || strstr(title, r->title)) - && (!r->id || strstr(appid, r->id))) { - c->isfloating = r->isfloating; -+ c->neverdim = r-> neverdim; - newtags |= r->tags; - i = 0; - wl_list_for_each(m, &mons, link) { -@@ -1365,8 +1371,10 @@ focusclient(Client *c, int lift) - - /* Don't change border color if there is an exclusive focus or we are - * handling a drag operation */ -- if (!exclusive_focus && !seat->drag) -+ if (!exclusive_focus && !seat->drag) { - client_set_border_color(c, focuscolor); -+ client_set_dimmer_state(c, 0); -+ } - } - - /* Deactivate old client if focus is changing */ -@@ -1384,7 +1392,7 @@ focusclient(Client *c, int lift) - * and probably other clients */ - } else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) { - client_set_border_color(old_c, bordercolor); -- -+ client_set_dimmer_state(old_c, 1); - client_activate_surface(old, 0); - } - } -@@ -1681,8 +1689,7 @@ void - mapnotify(struct wl_listener *listener, void *data) - { - /* Called when the surface is mapped, or ready to display on-screen. */ -- Client *p = NULL; -- Client *w, *c = wl_container_of(listener, c, map); -+ Client *p, *w, *d, *c = wl_container_of(listener, c, map); - Monitor *m; - int i; - -@@ -1716,6 +1723,10 @@ mapnotify(struct wl_listener *listener, void *data) - c->border[i]->node.data = c; - } - -+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim); -+ c->dimmer->node.data = c; -+ client_set_dimmer_state(c, 1); -+ - /* Initialize client geometry with room for border */ - client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); - c->geom.width += 2 * c->bw; -@@ -1734,6 +1745,10 @@ mapnotify(struct wl_listener *listener, void *data) - setmon(c, p->mon, p->tags); - } else { - applyrules(c); -+ d = focustop(selmon); -+ if (d) { -+ client_set_dimmer_state(d, 0); -+ } - } - printstatus(); - -@@ -2160,7 +2175,7 @@ resize(Client *c, struct wlr_box geo, int interact) - c->geom = geo; - applybounds(c, bbox); - -- /* Update scene-graph, including borders */ -+ /* Update scene-graph, including borders and dimmer*/ - wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); - wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); - wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw); -@@ -2170,6 +2185,8 @@ resize(Client *c, struct wlr_box geo, int interact) - wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw); - wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw); - wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw); -+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw); -+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw); - - /* this is a no-op if size hasn't changed */ - c->resize = client_set_size(c, c->geom.width - 2 * c->bw, -@@ -2681,6 +2698,27 @@ tile(Monitor *m) - } - } - -+void toggledimming(const Arg *arg) -+{ -+ Client *c; -+ DIMOPT ^= 1; -+ wl_list_for_each(c, &clients, link) -+ { -+ client_set_dimmer_state(c, 1); -+ } -+ c = focustop(selmon); -+ if (c) -+ client_set_dimmer_state(c, 0); -+} -+ -+void -+toggledimmingclient(const Arg *arg) -+{ -+ Client *sel = focustop(selmon); -+ if (sel) -+ sel -> neverdim ^= 1; -+} -+ - void - togglefloating(const Arg *arg) - { diff --git a/patches/ipc.patch b/patches/ipc.patch deleted file mode 100644 index 9f989e7..0000000 --- a/patches/ipc.patch +++ /dev/null @@ -1,597 +0,0 @@ -From 6c6d655b68770ce82a24fde9b58c4d97b672553a Mon Sep 17 00:00:00 2001 -From: choc -Date: Mon, 23 Oct 2023 10:35:17 +0800 -Subject: [PATCH] implement dwl-ipc-unstable-v2 - https://codeberg.org/dwl/dwl-patches/wiki/ipc - ---- - Makefile | 14 +- - config.def.h | 1 + - dwl.c | 257 ++++++++++++++++++++++++++---- - protocols/dwl-ipc-unstable-v2.xml | 181 +++++++++++++++++++++ - 4 files changed, 419 insertions(+), 34 deletions(-) - create mode 100644 protocols/dwl-ipc-unstable-v2.xml - -diff --git a/Makefile b/Makefile -index 8db7409..a79a080 100644 ---- a/Makefile -+++ b/Makefile -@@ -17,12 +17,14 @@ DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEV - LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS) - - all: dwl --dwl: dwl.o util.o -- $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ -+dwl: dwl.o util.o dwl-ipc-unstable-v2-protocol.o -+ $(CC) dwl.o util.o dwl-ipc-unstable-v2-protocol.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ - dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \ - pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \ -- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h -+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \ -+ dwl-ipc-unstable-v2-protocol.h - util.o: util.c util.h -+dwl-ipc-unstable-v2-protocol.o: dwl-ipc-unstable-v2-protocol.c dwl-ipc-unstable-v2-protocol.h - - # wayland-scanner is a tool which generates C headers and rigging for Wayland - # protocols, which are specified in XML. wlroots requires you to rig these up -@@ -45,6 +47,12 @@ wlr-output-power-management-unstable-v1-protocol.h: - xdg-shell-protocol.h: - $(WAYLAND_SCANNER) server-header \ - $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ -+dwl-ipc-unstable-v2-protocol.h: -+ $(WAYLAND_SCANNER) server-header \ -+ protocols/dwl-ipc-unstable-v2.xml $@ -+dwl-ipc-unstable-v2-protocol.c: -+ $(WAYLAND_SCANNER) private-code \ -+ protocols/dwl-ipc-unstable-v2.xml $@ - - config.h: - cp config.def.h $@ -diff --git a/config.def.h b/config.def.h -index 22d2171..1593033 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -127,6 +127,7 @@ static const Key keys[] = { - /* modifier key function argument */ - { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, -+ { MODKEY, XKB_KEY_b, togglebar, {0} }, - { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, - { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, - { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, -diff --git a/dwl.c b/dwl.c -index 8a587d1..7a4949b 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -68,6 +68,7 @@ - #include - #endif - -+#include "dwl-ipc-unstable-v2-protocol.h" - #include "util.h" - - /* macros */ -@@ -144,6 +145,12 @@ typedef struct { - uint32_t resize; /* configure serial of a pending resize */ - } Client; - -+typedef struct { -+ struct wl_list link; -+ struct wl_resource *resource; -+ Monitor *mon; -+} DwlIpcOutput; -+ - typedef struct { - uint32_t mod; - xkb_keysym_t keysym; -@@ -189,6 +196,7 @@ typedef struct { - - struct Monitor { - struct wl_list link; -+ struct wl_list dwl_ipc_outputs; - struct wlr_output *wlr_output; - struct wlr_scene_output *scene_output; - struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */ -@@ -286,6 +294,17 @@ static void destroysessionlock(struct wl_listener *listener, void *data); - static void destroysessionmgr(struct wl_listener *listener, void *data); - static void destroykeyboardgroup(struct wl_listener *listener, void *data); - static Monitor *dirtomon(enum wlr_direction dir); -+static void dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id); -+static void dwl_ipc_manager_destroy(struct wl_resource *resource); -+static void dwl_ipc_manager_get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output); -+static void dwl_ipc_manager_release(struct wl_client *client, struct wl_resource *resource); -+static void dwl_ipc_output_destroy(struct wl_resource *resource); -+static void dwl_ipc_output_printstatus(Monitor *monitor); -+static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output); -+static void dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *resource, uint32_t and_tags, uint32_t xor_tags); -+static void dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index); -+static void dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset); -+static void dwl_ipc_output_release(struct wl_client *client, struct wl_resource *resource); - static void focusclient(Client *c, int lift); - static void focusmon(const Arg *arg); - static void focusstack(const Arg *arg); -@@ -338,6 +357,7 @@ static void startdrag(struct wl_listener *listener, void *data); - static void tag(const Arg *arg); - static void tagmon(const Arg *arg); - static void tile(Monitor *m); -+static void togglebar(const Arg *arg); - static void togglefloating(const Arg *arg); - static void togglefullscreen(const Arg *arg); - static void toggletag(const Arg *arg); -@@ -411,6 +431,9 @@ static struct wlr_box sgeom; - static struct wl_list mons; - static Monitor *selmon; - -+static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output}; -+static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags}; -+ - #ifdef XWAYLAND - static void activatex11(struct wl_listener *listener, void *data); - static void associatex11(struct wl_listener *listener, void *data); -@@ -703,6 +726,10 @@ cleanupmon(struct wl_listener *listener, void *data) - LayerSurface *l, *tmp; - size_t i; - -+ DwlIpcOutput *ipc_output, *ipc_output_tmp; -+ wl_list_for_each_safe(ipc_output, ipc_output_tmp, &m->dwl_ipc_outputs, link) -+ wl_resource_destroy(ipc_output->resource); -+ - /* m->layers[i] are intentionally not unlinked */ - for (i = 0; i < LENGTH(m->layers); i++) { - wl_list_for_each_safe(l, tmp, &m->layers[i], link) -@@ -983,6 +1010,8 @@ createmon(struct wl_listener *listener, void *data) - m = wlr_output->data = ecalloc(1, sizeof(*m)); - m->wlr_output = wlr_output; - -+ wl_list_init(&m->dwl_ipc_outputs); -+ - for (i = 0; i < LENGTH(m->layers); i++) - wl_list_init(&m->layers[i]); - -@@ -1334,6 +1363,192 @@ dirtomon(enum wlr_direction dir) - return selmon; - } - -+void -+dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) -+{ -+ struct wl_resource *manager_resource = wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id); -+ if (!manager_resource) { -+ wl_client_post_no_memory(client); -+ return; -+ } -+ wl_resource_set_implementation(manager_resource, &dwl_manager_implementation, NULL, dwl_ipc_manager_destroy); -+ -+ zdwl_ipc_manager_v2_send_tags(manager_resource, TAGCOUNT); -+ -+ for (unsigned int i = 0; i < LENGTH(layouts); i++) -+ zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol); -+} -+ -+void -+dwl_ipc_manager_destroy(struct wl_resource *resource) -+{ -+ /* No state to destroy */ -+} -+ -+void -+dwl_ipc_manager_get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output) -+{ -+ DwlIpcOutput *ipc_output; -+ Monitor *monitor = wlr_output_from_resource(output)->data; -+ struct wl_resource *output_resource = wl_resource_create(client, &zdwl_ipc_output_v2_interface, wl_resource_get_version(resource), id); -+ if (!output_resource) -+ return; -+ -+ ipc_output = ecalloc(1, sizeof(*ipc_output)); -+ ipc_output->resource = output_resource; -+ ipc_output->mon = monitor; -+ wl_resource_set_implementation(output_resource, &dwl_output_implementation, ipc_output, dwl_ipc_output_destroy); -+ wl_list_insert(&monitor->dwl_ipc_outputs, &ipc_output->link); -+ dwl_ipc_output_printstatus_to(ipc_output); -+} -+ -+void -+dwl_ipc_manager_release(struct wl_client *client, struct wl_resource *resource) -+{ -+ wl_resource_destroy(resource); -+} -+ -+static void -+dwl_ipc_output_destroy(struct wl_resource *resource) -+{ -+ DwlIpcOutput *ipc_output = wl_resource_get_user_data(resource); -+ wl_list_remove(&ipc_output->link); -+ free(ipc_output); -+} -+ -+void -+dwl_ipc_output_printstatus(Monitor *monitor) -+{ -+ DwlIpcOutput *ipc_output; -+ wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link) -+ dwl_ipc_output_printstatus_to(ipc_output); -+} -+ -+void -+dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) -+{ -+ Monitor *monitor = ipc_output->mon; -+ Client *c, *focused; -+ int tagmask, state, numclients, focused_client, tag; -+ const char *title, *appid; -+ focused = focustop(monitor); -+ zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon); -+ -+ for (tag = 0 ; tag < TAGCOUNT; tag++) { -+ numclients = state = focused_client = 0; -+ tagmask = 1 << tag; -+ if ((tagmask & monitor->tagset[monitor->seltags]) != 0) -+ state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE; -+ -+ wl_list_for_each(c, &clients, link) { -+ if (c->mon != monitor) -+ continue; -+ if (!(c->tags & tagmask)) -+ continue; -+ if (c == focused) -+ focused_client = 1; -+ if (c->isurgent) -+ state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT; -+ -+ numclients++; -+ } -+ zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients, focused_client); -+ } -+ title = focused ? client_get_title(focused) : ""; -+ appid = focused ? client_get_appid(focused) : ""; -+ -+ zdwl_ipc_output_v2_send_layout(ipc_output->resource, monitor->lt[monitor->sellt] - layouts); -+ zdwl_ipc_output_v2_send_title(ipc_output->resource, title); -+ zdwl_ipc_output_v2_send_appid(ipc_output->resource, appid); -+ zdwl_ipc_output_v2_send_layout_symbol(ipc_output->resource, monitor->ltsymbol); -+ if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) { -+ zdwl_ipc_output_v2_send_fullscreen(ipc_output->resource, focused ? focused->isfullscreen : 0); -+ } -+ if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) { -+ zdwl_ipc_output_v2_send_floating(ipc_output->resource, focused ? focused->isfloating : 0); -+ } -+ zdwl_ipc_output_v2_send_frame(ipc_output->resource); -+} -+ -+void -+dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *resource, uint32_t and_tags, uint32_t xor_tags) -+{ -+ DwlIpcOutput *ipc_output; -+ Monitor *monitor; -+ Client *selected_client; -+ unsigned int newtags = 0; -+ -+ ipc_output = wl_resource_get_user_data(resource); -+ if (!ipc_output) -+ return; -+ -+ monitor = ipc_output->mon; -+ selected_client = focustop(monitor); -+ if (!selected_client) -+ return; -+ -+ newtags = (selected_client->tags & and_tags) ^ xor_tags; -+ if (!newtags) -+ return; -+ -+ selected_client->tags = newtags; -+ if (selmon == monitor) -+ focusclient(focustop(monitor), 1); -+ arrange(selmon); -+ printstatus(); -+} -+ -+void -+dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index) -+{ -+ DwlIpcOutput *ipc_output; -+ Monitor *monitor; -+ -+ ipc_output = wl_resource_get_user_data(resource); -+ if (!ipc_output) -+ return; -+ -+ monitor = ipc_output->mon; -+ if (index >= LENGTH(layouts)) -+ return; -+ if (index != monitor->lt[monitor->sellt] - layouts) -+ monitor->sellt ^= 1; -+ -+ monitor->lt[monitor->sellt] = &layouts[index]; -+ arrange(monitor); -+ printstatus(); -+} -+ -+void -+dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource, uint32_t tagmask, uint32_t toggle_tagset) -+{ -+ DwlIpcOutput *ipc_output; -+ Monitor *monitor; -+ unsigned int newtags = tagmask & TAGMASK; -+ -+ ipc_output = wl_resource_get_user_data(resource); -+ if (!ipc_output) -+ return; -+ monitor = ipc_output->mon; -+ -+ if (!newtags || newtags == monitor->tagset[monitor->seltags]) -+ return; -+ if (toggle_tagset) -+ monitor->seltags ^= 1; -+ -+ monitor->tagset[monitor->seltags] = newtags; -+ if (selmon == monitor) -+ focusclient(focustop(monitor), 1); -+ arrange(monitor); -+ printstatus(); -+} -+ -+void -+dwl_ipc_output_release(struct wl_client *client, struct wl_resource *resource) -+{ -+ wl_resource_destroy(resource); -+} -+ - void - focusclient(Client *c, int lift) - { -@@ -2033,38 +2248,9 @@ void - printstatus(void) - { - Monitor *m = NULL; -- Client *c; -- uint32_t occ, urg, sel; - -- wl_list_for_each(m, &mons, link) { -- occ = urg = 0; -- wl_list_for_each(c, &clients, link) { -- if (c->mon != m) -- continue; -- occ |= c->tags; -- if (c->isurgent) -- urg |= c->tags; -- } -- if ((c = focustop(m))) { -- printf("%s title %s\n", m->wlr_output->name, client_get_title(c)); -- printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c)); -- printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen); -- printf("%s floating %d\n", m->wlr_output->name, c->isfloating); -- sel = c->tags; -- } else { -- printf("%s title \n", m->wlr_output->name); -- printf("%s appid \n", m->wlr_output->name); -- printf("%s fullscreen \n", m->wlr_output->name); -- printf("%s floating \n", m->wlr_output->name); -- sel = 0; -- } -- -- printf("%s selmon %u\n", m->wlr_output->name, m == selmon); -- printf("%s tags %"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"\n", -- m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg); -- printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol); -- } -- fflush(stdout); -+ wl_list_for_each(m, &mons, link) -+ dwl_ipc_output_printstatus(m); - } - - void -@@ -2584,6 +2770,8 @@ setup(void) - LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply); - LISTEN_STATIC(&output_mgr->events.test, outputmgrtest); - -+ wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, dwl_ipc_manager_bind); -+ - /* Make sure XWayland clients don't connect to the parent X server, - * e.g when running in the x11 backend or the wayland backend and the - * compositor has Xwayland support */ -@@ -2681,6 +2869,13 @@ tile(Monitor *m) - } - } - -+void -+togglebar(const Arg *arg) { -+ DwlIpcOutput *ipc_output; -+ wl_list_for_each(ipc_output, &selmon->dwl_ipc_outputs, link) -+ zdwl_ipc_output_v2_send_toggle_visibility(ipc_output->resource); -+} -+ - void - togglefloating(const Arg *arg) - { -diff --git a/protocols/dwl-ipc-unstable-v2.xml b/protocols/dwl-ipc-unstable-v2.xml -new file mode 100644 -index 0000000..0a6e7e5 ---- /dev/null -+++ b/protocols/dwl-ipc-unstable-v2.xml -@@ -0,0 +1,181 @@ -+ -+ -+ -+ -+ This protocol allows clients to update and get updates from dwl. -+ -+ 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. -+ -+ -+ -+ -+ This interface is exposed as a global in wl_registry. -+ -+ Clients can use this interface to get a dwl_ipc_output. -+ After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events. -+ The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client. -+ -+ -+ -+ -+ Indicates that the client will not the dwl_ipc_manager object anymore. -+ Objects created through this instance are not affected. -+ -+ -+ -+ -+ -+ Get a dwl_ipc_outout for the specified wl_output. -+ -+ -+ -+ -+ -+ -+ -+ This event is sent after binding. -+ A roundtrip after binding guarantees the client recieved all tags. -+ -+ -+ -+ -+ -+ -+ This event is sent after binding. -+ A roundtrip after binding guarantees the client recieved all layouts. -+ -+ -+ -+ -+ -+ -+ -+ Observe and control a dwl output. -+ -+ Events are double-buffered: -+ Clients should cache events and redraw when a dwl_ipc_output.frame event is sent. -+ -+ Request are not double-buffered: -+ The compositor will update immediately upon request. -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Indicates to that the client no longer needs this dwl_ipc_output. -+ -+ -+ -+ -+ -+ Indicates the client should hide or show themselves. -+ If the client is visible then hide, if hidden then show. -+ -+ -+ -+ -+ -+ Indicates if the output is active. Zero is invalid, nonzero is valid. -+ -+ -+ -+ -+ -+ -+ Indicates that a tag has been updated. -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Indicates a new layout is selected. -+ -+ -+ -+ -+ -+ -+ Indicates the title has changed. -+ -+ -+ -+ -+ -+ -+ Indicates the appid has changed. -+ -+ -+ -+ -+ -+ -+ Indicates the layout has changed. Since layout symbols are dynamic. -+ As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying. -+ You can ignore the zdwl_ipc_output.layout event. -+ -+ -+ -+ -+ -+ -+ Indicates that a sequence of status updates have finished and the client should redraw. -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ The tags are updated as follows: -+ new_tags = (current_tags AND and_tags) XOR xor_tags -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Indicates if the selected client on this output is fullscreen. -+ -+ -+ -+ -+ -+ -+ Indicates if the selected client on this output is floating. -+ -+ -+ -+ -+ --- -2.43.0 - diff --git a/patches/warpcursor.patch b/patches/warpcursor.patch deleted file mode 100644 index 6ac0329..0000000 --- a/patches/warpcursor.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 4951ccc89dac2b557994b2f6c3aacb2398e2d1b1 Mon Sep 17 00:00:00 2001 -From: Ben Collerson -Date: Thu, 4 Jan 2024 20:30:01 +1000 -Subject: [PATCH] warpcursor - ---- - dwl.c | 27 +++++++++++++++++++++++++++ - 1 file changed, 27 insertions(+) - -diff --git a/dwl.c b/dwl.c -index 145fd018..f7ad6c13 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -347,6 +347,7 @@ static void urgent(struct wl_listener *listener, void *data); - static void view(const Arg *arg); - static void virtualkeyboard(struct wl_listener *listener, void *data); - static void virtualpointer(struct wl_listener *listener, void *data); -+static void warpcursor(const Client *c); - static Monitor *xytomon(double x, double y); - static void xytonode(double x, double y, struct wlr_surface **psurface, - Client **pc, LayerSurface **pl, double *nx, double *ny); -@@ -514,6 +515,7 @@ arrange(Monitor *m) - m->lt[m->sellt]->arrange(m); - motionnotify(0, NULL, 0, 0, 0, 0); - checkidleinhibitor(NULL); -+ warpcursor(focustop(selmon)); - } - - void -@@ -1323,6 +1325,10 @@ focusclient(Client *c, int lift) - if (locked) - return; - -+ /* Warp cursor to center of client if it is outside */ -+ if (lift) -+ warpcursor(c); -+ - /* Raise client in stacking order if requested */ - if (c && lift) - wlr_scene_node_raise_to_top(&c->scene->node); -@@ -2927,6 +2933,27 @@ virtualpointer(struct wl_listener *listener, void *data) - wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output); - } - -+void -+warpcursor(const Client *c) { -+ if (cursor_mode != CurNormal) { -+ return; -+ } -+ if (!c && selmon) { -+ wlr_cursor_warp_closest(cursor, -+ NULL, -+ selmon->w.x + selmon->w.width / 2.0 , -+ selmon->w.y + selmon->w.height / 2.0); -+ } -+ else if ( c && (cursor->x < c->geom.x || -+ cursor->x > c->geom.x + c->geom.width || -+ cursor->y < c->geom.y || -+ cursor->y > c->geom.y + c->geom.height)) -+ wlr_cursor_warp_closest(cursor, -+ NULL, -+ c->geom.x + c->geom.width / 2.0, -+ c->geom.y + c->geom.height / 2.0); -+} -+ - Monitor * - xytomon(double x, double y) - { --- -2.45.2 - diff --git a/protocols/dwl-ipc-unstable-v2.xml b/protocols/dwl-ipc-unstable-v2.xml deleted file mode 100644 index 0a6e7e5..0000000 --- a/protocols/dwl-ipc-unstable-v2.xml +++ /dev/null @@ -1,181 +0,0 @@ - - - - - This protocol allows clients to update and get updates from dwl. - - 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. - - - - - This interface is exposed as a global in wl_registry. - - Clients can use this interface to get a dwl_ipc_output. - After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events. - The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client. - - - - - Indicates that the client will not the dwl_ipc_manager object anymore. - Objects created through this instance are not affected. - - - - - - Get a dwl_ipc_outout for the specified wl_output. - - - - - - - - This event is sent after binding. - A roundtrip after binding guarantees the client recieved all tags. - - - - - - - This event is sent after binding. - A roundtrip after binding guarantees the client recieved all layouts. - - - - - - - - Observe and control a dwl output. - - Events are double-buffered: - Clients should cache events and redraw when a dwl_ipc_output.frame event is sent. - - Request are not double-buffered: - The compositor will update immediately upon request. - - - - - - - - - - - Indicates to that the client no longer needs this dwl_ipc_output. - - - - - - Indicates the client should hide or show themselves. - If the client is visible then hide, if hidden then show. - - - - - - Indicates if the output is active. Zero is invalid, nonzero is valid. - - - - - - - Indicates that a tag has been updated. - - - - - - - - - - Indicates a new layout is selected. - - - - - - - Indicates the title has changed. - - - - - - - Indicates the appid has changed. - - - - - - - Indicates the layout has changed. Since layout symbols are dynamic. - As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying. - You can ignore the zdwl_ipc_output.layout event. - - - - - - - Indicates that a sequence of status updates have finished and the client should redraw. - - - - - - - - - - - - The tags are updated as follows: - new_tags = (current_tags AND and_tags) XOR xor_tags - - - - - - - - - - - - - - Indicates if the selected client on this output is fullscreen. - - - - - - - Indicates if the selected client on this output is floating. - - - - -