forked from mirror/dwl
Compare commits
50 commits
Author | SHA1 | Date | |
---|---|---|---|
|
30f5063474 | ||
|
1d08ade132 | ||
|
84245764e2 | ||
|
6ca87210d4 | ||
|
002c7d2204 | ||
|
8206cc8889 | ||
|
54f207839f | ||
|
9c05b9622c | ||
|
d34be5d545 | ||
|
c49312f084 | ||
|
f899060965 | ||
|
cc72df11d6 | ||
|
0312720ae8 | ||
|
6de87121e2 | ||
|
bbc00d88a4 | ||
|
54b546121b | ||
|
43016bdad8 | ||
|
b616476c85 | ||
|
d4ad37354e | ||
|
5db05e82bd | ||
|
8ec5e52e06 | ||
|
c5275ca571 | ||
|
2c0b889f86 | ||
|
554754c9a2 | ||
|
0caa658276 | ||
|
07aeef1f7e | ||
|
e454f7ae81 | ||
|
334bbe6f0f | ||
|
1b805ddd38 | ||
|
94f4ead7da | ||
|
bb21ecda30 | ||
|
b25717c939 | ||
|
a4fa954616 | ||
|
35951a8d7e | ||
|
a634e3f527 | ||
|
d136dadf45 | ||
|
672b4c405d | ||
|
b5abbc37d8 | ||
|
986beef5be | ||
|
487abc28ba | ||
|
cd216908a7 | ||
|
f2c5023a3a | ||
|
4bbbb4907e | ||
|
ea6a450121 | ||
|
ad30ca910b | ||
|
452a314faa | ||
|
da6de7c4d7 | ||
|
2553111aa3 | ||
|
51881da27b | ||
|
7328e5691c |
15 changed files with 212 additions and 2159 deletions
2
.mailmap
2
.mailmap
|
@ -1 +1,3 @@
|
|||
Lennart Jablonka <humm@ljabl.com> <hummsmith42@gmail.com>
|
||||
Leonardo Hernández Hernández <leohdz172@proton.me> <leohdz172@outlook.com>
|
||||
Leonardo Hernández Hernández <leohdz172@proton.me> <leohdz172@protonmail.com>
|
||||
|
|
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -8,6 +8,15 @@
|
|||
|
||||
## Unreleased
|
||||
### Added
|
||||
|
||||
* Support for the linux-drm-syncobj-v1 protocol ([wlroots!4715][wlroots!4715], [#685][685])
|
||||
* Allow the use of non-system wlroots library ([#646][646])
|
||||
|
||||
[wlroots!4715]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4715
|
||||
[685]: https://codeberg.org/dwl/dwl/pulls/685
|
||||
[646]: https://codeberg.org/dwl/dwl/pulls/646
|
||||
|
||||
|
||||
### Changed
|
||||
### Deprecated
|
||||
### Removed
|
||||
|
@ -21,7 +30,7 @@
|
|||
|
||||
## 0.7
|
||||
|
||||
See also [0.6](#0.6) release notes. 0.7 builds against wlroots 0.18.x.
|
||||
This version is just 0.6 with wlroots 0.18 compatibility.
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -32,15 +41,9 @@ See also [0.6](#0.6) release notes. 0.7 builds against wlroots 0.18.x.
|
|||
[601]: https://codeberg.org/dwl/dwl/issues/601
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
* Crash when re-mapping unmapped clients.
|
||||
|
||||
|
||||
### Contributors
|
||||
|
||||
Guido Cella
|
||||
Lennart Jablonka
|
||||
|
||||
|
||||
## 0.6
|
||||
|
|
10
Makefile
10
Makefile
|
@ -6,15 +6,15 @@ include config.mk
|
|||
# flags for compiling
|
||||
DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
|
||||
-DVERSION=\"$(VERSION)\" $(XWAYLAND)
|
||||
DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
|
||||
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
|
||||
-Wfloat-conversion
|
||||
|
||||
# CFLAGS / LDFLAGS
|
||||
PKGS = wlroots-0.18 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
|
||||
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
||||
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
|
||||
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
|
||||
|
@ -50,7 +50,6 @@ config.h:
|
|||
cp config.def.h $@
|
||||
clean:
|
||||
rm -f dwl *.o *-protocol.h
|
||||
rm -f result result-man
|
||||
|
||||
dist: clean
|
||||
mkdir -p dwl-$(VERSION)
|
||||
|
@ -62,6 +61,7 @@ dist: clean
|
|||
|
||||
install: dwl
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/dwl
|
||||
cp -f dwl $(DESTDIR)$(PREFIX)/bin
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dwl
|
||||
mkdir -p $(DESTDIR)$(MANDIR)/man1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# dwl - dwm for Wayland
|
||||
|
||||
Join us on our IRC channel: [#dwl on Libera Chat]
|
||||
Or on our [Discord server].
|
||||
Or on the community-maintained [Discord server].
|
||||
|
||||
dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is
|
||||
intended to fill the same space in the Wayland world that dwm does in X11,
|
||||
|
@ -14,8 +14,6 @@ philosophy. Like dwm, dwl is:
|
|||
|
||||
## Getting Started:
|
||||
|
||||
### **dwl branch 0.7 and releases based upon 0.7 build against [wlroots] 0.18**
|
||||
|
||||
### Latest semi-stable [release]
|
||||
This is probably where you want to start. This builds against the dependent
|
||||
packages' versions currently shipping in major distributions. If your
|
||||
|
|
43
client.h
43
client.h
|
@ -126,15 +126,14 @@ client_get_appid(Client *c)
|
|||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->class;
|
||||
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->app_id;
|
||||
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken";
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_get_clip(Client *c, struct wlr_box *clip)
|
||||
{
|
||||
struct wlr_box xdg_geom = {0};
|
||||
*clip = (struct wlr_box){
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
|
@ -147,9 +146,8 @@ client_get_clip(Client *c, struct wlr_box *clip)
|
|||
return;
|
||||
#endif
|
||||
|
||||
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
|
||||
clip->x = xdg_geom.x;
|
||||
clip->y = xdg_geom.y;
|
||||
clip->x = c->surface.xdg->geometry.x;
|
||||
clip->y = c->surface.xdg->geometry.y;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -164,7 +162,7 @@ client_get_geometry(Client *c, struct wlr_box *geom)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
|
||||
*geom = c->surface.xdg->geometry;
|
||||
}
|
||||
|
||||
static inline Client *
|
||||
|
@ -200,9 +198,9 @@ client_get_title(Client *c)
|
|||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->title;
|
||||
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->title;
|
||||
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title : "broken";
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
@ -301,17 +299,6 @@ client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
|
|||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_restack_surface(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
|
||||
XCB_STACK_MODE_ABOVE);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_send_close(Client *c)
|
||||
{
|
||||
|
@ -344,6 +331,13 @@ client_set_fullscreen(Client *c, int fullscreen)
|
|||
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_set_scale(struct wlr_surface *s, float scale)
|
||||
{
|
||||
wlr_fractional_scale_v1_notify_scale(s, scale);
|
||||
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
{
|
||||
|
@ -364,8 +358,11 @@ static inline void
|
|||
client_set_tiled(Client *c, uint32_t edges)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
||||
edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
||||
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
|
@ -391,8 +388,8 @@ client_wants_focus(Client *c)
|
|||
{
|
||||
#ifdef XWAYLAND
|
||||
return client_is_unmanaged(c)
|
||||
&& wlr_xwayland_or_surface_wants_focus(c->surface.xwayland)
|
||||
&& wlr_xwayland_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
&& wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland)
|
||||
&& wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[]
|
39
config.def.h
39
config.def.h
|
@ -7,21 +7,15 @@
|
|||
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 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 const float rootcolor[] = COLOR(0x222222ff);
|
||||
static const float bordercolor[] = COLOR(0x444444ff);
|
||||
static const float focuscolor[] = COLOR(0x005577ff);
|
||||
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 */
|
||||
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 */
|
||||
static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
#define TAGCOUNT (9)
|
||||
|
||||
/* logging */
|
||||
static int log_level = WLR_ERROR;
|
||||
|
@ -31,7 +25,7 @@ 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 */
|
||||
{ "discord", NULL, 1 << 1, 0, 1 }, /* Start on ONLY tag "9" */
|
||||
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
|
@ -53,8 +47,6 @@ static const MonitorRule monrules[] = {
|
|||
/* example of a HiDPI laptop monitor:
|
||||
{ "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
*/
|
||||
{ "HDMI-A-1", 0.5f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0 },
|
||||
{ "DP-1", 0.5f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 1920, 0 },
|
||||
/* defaults */
|
||||
{ NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
};
|
||||
|
@ -115,7 +107,7 @@ 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_LOGO
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
#define TAGKEYS(KEY,SKEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
|
@ -127,7 +119,7 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
|||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static const char *termcmd[] = { "kitty", NULL };
|
||||
static const char *termcmd[] = { "foot", NULL };
|
||||
static const char *menucmd[] = { "wmenu-run", NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
|
@ -135,7 +127,6 @@ 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} },
|
||||
|
@ -179,15 +170,7 @@ static const Key keys[] = {
|
|||
};
|
||||
|
||||
static const Button buttons[] = {
|
||||
{ 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} },
|
||||
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
||||
};
|
||||
|
|
23
config.mk
23
config.mk
|
@ -1,4 +1,4 @@
|
|||
_VERSION = 0.7
|
||||
_VERSION = 0.8-dev
|
||||
VERSION = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)`
|
||||
|
||||
PKG_CONFIG = pkg-config
|
||||
|
@ -8,10 +8,29 @@ PREFIX = /usr/local
|
|||
MANDIR = $(PREFIX)/share/man
|
||||
DATADIR = $(PREFIX)/share
|
||||
|
||||
WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19`
|
||||
WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19`
|
||||
|
||||
# Allow using an alternative wlroots installations
|
||||
# This has to have all the includes required by wlroots, e.g:
|
||||
# Assuming wlroots git repo is "${PWD}/wlroots" and you only ran "meson setup build && ninja -C build"
|
||||
#WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
|
||||
# -I$(PWD)/wlroots/include
|
||||
# Set -rpath to avoid using the wrong library.
|
||||
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.19
|
||||
|
||||
# Assuming you ran "meson setup --prefix ${PWD}/0.19 build && ninja -C build install"
|
||||
#WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
|
||||
# -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
|
||||
|
||||
CC = gcc
|
||||
# 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
|
||||
# gmake default 'CC=c99', we use cc.
|
||||
CC = cc
|
||||
|
|
311
drwl.h
311
drwl.h
|
@ -1,311 +0,0 @@
|
|||
/*
|
||||
* drwl - https://codeberg.org/sewn/drwl
|
||||
*
|
||||
* Copyright (c) 2023-2024 sewn <sewn@disroot.org>
|
||||
* Copyright (c) 2024 notchoc <notchoc@disroot.org>
|
||||
*
|
||||
* 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 <bjoern@hoehrmann.de>
|
||||
* See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fcft/fcft.h>
|
||||
#include <pixman-1/pixman.h>
|
||||
|
||||
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)
|
||||
{
|
||||
fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3);
|
||||
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();
|
||||
}
|
58
flake.lock
58
flake.lock
|
@ -1,58 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733312601,
|
||||
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1733759999,
|
||||
"narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1733096140,
|
||||
"narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
28
flake.nix
28
flake.nix
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
description = "dwm for Wayland (requires dwl 0.7)";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
};
|
||||
|
||||
outputs = inputs@{ flake-parts, nixpkgs, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [
|
||||
flake-parts.flakeModules.easyOverlay
|
||||
];
|
||||
systems = nixpkgs.lib.platforms.unix;
|
||||
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||
overlayAttrs = {
|
||||
zdwl = config.packages.default;
|
||||
};
|
||||
packages.default = pkgs.dwl.overrideAttrs (old: {
|
||||
buildInputs = old.buildInputs ++ (with pkgs; [
|
||||
fcft
|
||||
libdrm.dev
|
||||
]);
|
||||
src = ./.;
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,2 +0,0 @@
|
|||
nix-shell -p bear --command fish
|
||||
nix develop nixpkgs#dwl --command fish
|
Loading…
Reference in a new issue