From f707d98ca8050202ae2cd4b6c5fe5455ec6e6cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Mon, 26 Feb 2024 12:48:31 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A6=81=E3=82=89=E3=81=AA=E3=81=84=E7=89=A9?= =?UTF-8?q?=E3=81=AE=E5=89=8A=E9=99=A4=E3=80=81FreeBSD=E3=81=AE=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.h | 10 +--------- config.mk | 40 +++++++++++++++++++++------------------- dwm.c | 18 +++++++----------- 3 files changed, 29 insertions(+), 39 deletions(-) diff --git a/config.h b/config.h index a21308a..7272094 100644 --- a/config.h +++ b/config.h @@ -6,15 +6,7 @@ #define TERMINAL "st" #define TERMCLASS "St" -#if MYOS == ARTIX -#define BROWSER "iceweasel" -#elif MYOS == VOID || MYOS == OPENBSD || MYOS == FREEBSD -#define BROWSER "netsurf" -#elif MYOS == CRUX -#define BROWSER "librewolf" -#elif MYOS == POSTMARKETOS -#define BROWSER == "firefox-esr" -#endif +#define BROWSER "firefox-esr" static const char wallpaper[] = "/home/suwako/.local/share/wallpapers/8ffe33a4a3459c39bcd0a11a528a3785-"; static const char ext[] = ".jpg"; diff --git a/config.mk b/config.mk index d898530..c5ac6b2 100644 --- a/config.mk +++ b/config.mk @@ -4,49 +4,51 @@ OS := $(shell uname -s) VERSION = 6.4 # paths -ifeq ($(OS),FreeBSD) -PREFIX = /usr/local -MANPREFIX = ${PREFIX}/share/man -else ifeq ($(OS),OpenBSD) -PREFIX = /usr/local -MANPREFIX = $(PREFIX)/man -else PREFIX = /usr MANPREFIX = ${PREFIX}/share/man +ifeq ($(OS),FreeBSD) + PREFIX = /usr/local +else ifeq ($(OS),OpenBSD) + PREFIX = /usr/local + MANPREFIX = $(PREFIX)/man endif X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib +ifeq ($(OS),FreeBSD) + X11INC = /usr/local/include + X11LIB = /usr/local/lib +endif XINERAMALIBS = -lXinerama XINERAMAFLAGS = -DXINERAMA # freetype FREETYPELIBS = -lfontconfig -lXft -ifeq ($(OS),OpenBSD) -FREETYPEINC = ${X11INC}/freetype2 -else FREETYPEINC = ${PREFIX}/include/freetype2 +ifeq ($(OS),OpenBSD) + FREETYPEINC = ${X11INC}/freetype2 endif # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lXext -lImlib2 -lm +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lXext -lImlib2 -lm -lXrandr ifeq ($(OS),FreeBSD) -LIBS += -lutil + LIBS += -lutil endif # flags +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} + ifeq ($(OS),Linux) -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -endif -ifeq ($(OS),OpenBSD) -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -endif -ifneq ($(OS),FreeBSD) -CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} + CPPFLAGS += -D_XOPEN_SOURCE=700L +else ifeq ($(OS),OpenBSD) + CPPFLAGS += -D_POSIX_C_SOURCE=200809L +else ifneq ($(OS),FreeBSD) + CPPFLAGS += -D_XOPEN_SOURCE=700L endif LDFLAGS = ${LIBS} +CFLAGS = ${INCS} # compiler and linker CC = cc diff --git a/dwm.c b/dwm.c index 3e112ca..dbfd3e5 100644 --- a/dwm.c +++ b/dwm.c @@ -438,7 +438,7 @@ void setrootbg() { Window wc; int screen; Imlib_Image image; - int screen_width, screen_height, image_width, image_height; + int screen_width, screen_height, screen_depth, image_width, image_height; float scale; display = XOpenDisplay(NULL); @@ -452,13 +452,8 @@ void setrootbg() { screen = DefaultScreen(display); screen_width = DisplayWidth(display, screen); screen_height = DisplayHeight(display, screen); - pixmap = XCreatePixmap( - display, - wc, - DisplayWidth(display, screen), - DisplayHeight(display, screen), - DefaultDepth(display, screen) - ); + screen_depth = DefaultDepth(display, screen); + pixmap = XCreatePixmap(display, wc, screen_width, screen_height, screen_depth); // 画像を読み込む imlib_context_set_display(display); @@ -476,6 +471,7 @@ void setrootbg() { image_width = imlib_image_get_width(); image_height = imlib_image_get_height(); + // https://gitlin.moe/himdel/hsetroot/blob/master/hsetroot.c switch (bgmode) { case MODE_CENTER: imlib_render_image_on_drawable((screen_width - image_width) / 2, (screen_height - image_height) / 2); @@ -2558,9 +2554,9 @@ updatestatus(void) Monitor* m; if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext))) { #if defined(__FreeBSD__) || defined(__OpenBSD__) - strlcpy(stext, "dwm-"VERSION, sizeof(stext)); + strlcpy(stext, "dwm-6.4", sizeof(stext)); #else - strncpy(stext, "dwm-"VERSION, sizeof(stext) - 1); + strncpy(stext, "dwm-6.4", sizeof(stext) - 1); stext[sizeof(stext) - 1] = '\0'; #endif } else { @@ -2887,7 +2883,7 @@ int main(int argc, char *argv[]) { if (argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION); + die("dwm-6.4"); else if (argc != 1) die("usage: dwm [-v]"); if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())