背景を追加
このコミットが含まれているのは:
コミット
d5410a3826
76
config.h
76
config.h
|
@ -34,18 +34,28 @@ static const char resolution[] = "1050";
|
|||
static const char resolution[] = "1280";
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MODE_CENTER,
|
||||
MODE_COVER,
|
||||
MODE_TILE,
|
||||
MODE_FULL,
|
||||
/* MODE_EXTEND, */
|
||||
MODE_FILL
|
||||
} BGMode;
|
||||
|
||||
/* appearance */
|
||||
static unsigned int borderpx = 3; /* border pixel of windows */
|
||||
static unsigned int snap = 32; /* snap pixel */
|
||||
static unsigned int gappih = 5; /* horiz inner gap between windows */
|
||||
static unsigned int gappiv = 5; /* vert inner gap between windows */
|
||||
static unsigned int gappoh = 5; /* horiz outer gap between windows and screen edge */
|
||||
static unsigned int gappov = 5; /* vert outer gap between windows and screen edge */
|
||||
static unsigned int dpms = -1; /* 分間。DPMSを無効にする場合:-1 */
|
||||
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||
static int showbar = 1; /* 0 means no bar */
|
||||
static int topbar = 1; /* 0 means bottom bar */
|
||||
static unsigned int borderpx = 3; /* border pixel of windows */
|
||||
static unsigned int snap = 32; /* snap pixel */
|
||||
static unsigned int gappih = 5; /* horiz inner gap between windows */
|
||||
static unsigned int gappiv = 5; /* vert inner gap between windows */
|
||||
static unsigned int gappoh = 5; /* horiz outer gap between windows and screen edge */
|
||||
static unsigned int gappov = 5; /* vert outer gap between windows and screen edge */
|
||||
static unsigned int dpms = -1; /* 秒間。DPMSを無効にする場合:-1 */
|
||||
static BGMode bgmode = MODE_FILL; /* 背景モード */
|
||||
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||
static int showbar = 1; /* 0 means no bar */
|
||||
static int topbar = 1; /* 0 means bottom bar */
|
||||
#if MYPC == DESKTOP || MYPC == T43
|
||||
static char *fonts[] = { "monospace:size=10", "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" };
|
||||
#else
|
||||
|
@ -76,7 +86,11 @@ static Sp scratchpads[] = {
|
|||
};
|
||||
|
||||
static const char *const autostart[] = {
|
||||
"hsetroot", "-center", bgimg, NULL,
|
||||
#if MYOS == OPENBSD
|
||||
"uim", NULL,
|
||||
#else
|
||||
"fcitx5", NULL,
|
||||
#endif
|
||||
NULL /* terminate */
|
||||
};
|
||||
|
||||
|
@ -158,25 +172,25 @@ static const char *termcmd[] = { TERMINAL, NULL };
|
|||
* Xresources preferences to load at startup
|
||||
*/
|
||||
ResourcePref resources[] = {
|
||||
{ "color0", STRING, &normbordercolor },
|
||||
{ "color8", STRING, &selbordercolor },
|
||||
{ "color0", STRING, &normbgcolor },
|
||||
{ "color4", STRING, &normfgcolor },
|
||||
{ "color0", STRING, &selfgcolor },
|
||||
{ "color4", STRING, &selbgcolor },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
{ "snap", INTEGER, &snap },
|
||||
{ "showbar", INTEGER, &showbar },
|
||||
{ "topbar", INTEGER, &topbar },
|
||||
{ "nmaster", INTEGER, &nmaster },
|
||||
{ "resizehints", INTEGER, &resizehints },
|
||||
{ "mfact", FLOAT, &mfact },
|
||||
{ "gappih", INTEGER, &gappih },
|
||||
{ "gappiv", INTEGER, &gappiv },
|
||||
{ "gappoh", INTEGER, &gappoh },
|
||||
{ "gappov", INTEGER, &gappov },
|
||||
{ "swallowfloating", INTEGER, &swallowfloating },
|
||||
{ "smartgaps", INTEGER, &smartgaps },
|
||||
{ "color0", STRING, &normbordercolor },
|
||||
{ "color8", STRING, &selbordercolor },
|
||||
{ "color0", STRING, &normbgcolor },
|
||||
{ "color4", STRING, &normfgcolor },
|
||||
{ "color0", STRING, &selfgcolor },
|
||||
{ "color4", STRING, &selbgcolor },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
{ "snap", INTEGER, &snap },
|
||||
{ "showbar", INTEGER, &showbar },
|
||||
{ "topbar", INTEGER, &topbar },
|
||||
{ "nmaster", INTEGER, &nmaster },
|
||||
{ "resizehints", INTEGER, &resizehints },
|
||||
{ "mfact", FLOAT, &mfact },
|
||||
{ "gappih", INTEGER, &gappih },
|
||||
{ "gappiv", INTEGER, &gappiv },
|
||||
{ "gappoh", INTEGER, &gappoh },
|
||||
{ "gappov", INTEGER, &gappov },
|
||||
{ "swallowfloating", INTEGER, &swallowfloating },
|
||||
{ "smartgaps", INTEGER, &smartgaps },
|
||||
};
|
||||
|
||||
#include <X11/XF86keysym.h>
|
||||
|
|
|
@ -31,7 +31,7 @@ endif
|
|||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lXext
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lXext -lImlib2 -lm
|
||||
ifeq ($(OS),FreeBSD)
|
||||
LIBS += -lutil
|
||||
endif
|
||||
|
|
89
dwm.c
89
dwm.c
|
@ -28,6 +28,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#if defined(__FreeBSD__)
|
||||
|
@ -39,6 +40,7 @@
|
|||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <Imlib2.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
@ -200,6 +202,7 @@ typedef struct {
|
|||
/* function declarations */
|
||||
static void setdpms();
|
||||
static void setupbackgrounds();
|
||||
static void setrootbg();
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
static void arrange(Monitor *m);
|
||||
|
@ -395,9 +398,6 @@ autostart_exec() {
|
|||
static pid_t *autostart_pids;
|
||||
static size_t autostart_len;
|
||||
|
||||
/* 背景を設定 */
|
||||
char bgimg[100];
|
||||
|
||||
void setdpms() {
|
||||
Display *display;
|
||||
int dummy;
|
||||
|
@ -423,12 +423,94 @@ void setdpms() {
|
|||
XCloseDisplay(display);
|
||||
}
|
||||
|
||||
/* 背景を設定 */
|
||||
char bgimg[100];
|
||||
|
||||
void setupbackgrounds() {
|
||||
strcpy(bgimg, wallpaper);
|
||||
strcat(bgimg, resolution);
|
||||
strcat(bgimg, ext);
|
||||
}
|
||||
|
||||
void setrootbg() {
|
||||
Pixmap pixmap;
|
||||
Display *display;
|
||||
Window wc;
|
||||
int screen;
|
||||
Imlib_Image image;
|
||||
int screen_width, screen_height, image_width, image_height;
|
||||
float scale;
|
||||
|
||||
display = XOpenDisplay(NULL);
|
||||
if (!display) {
|
||||
fprintf(stderr, "エラー: ディスプレイに接続できません。\n");
|
||||
return;
|
||||
}
|
||||
|
||||
wc = DefaultRootWindow(display);
|
||||
|
||||
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)
|
||||
);
|
||||
|
||||
// 画像を読み込む
|
||||
imlib_context_set_display(display);
|
||||
imlib_context_set_visual(DefaultVisual(display, screen));
|
||||
imlib_context_set_colormap(DefaultColormap(display, screen));
|
||||
imlib_context_set_drawable(pixmap);
|
||||
|
||||
image = imlib_load_image(bgimg);
|
||||
if (!image) {
|
||||
fprintf(stderr, "画像の読み込みに失敗:%s\n", bgimg);
|
||||
return;
|
||||
}
|
||||
|
||||
imlib_context_set_image(image);
|
||||
image_width = imlib_image_get_width();
|
||||
image_height = imlib_image_get_height();
|
||||
|
||||
switch (bgmode) {
|
||||
case MODE_CENTER:
|
||||
imlib_render_image_on_drawable((screen_width - image_width) / 2, (screen_height - image_height) / 2);
|
||||
break;
|
||||
case MODE_COVER:
|
||||
scale = fmax((float)screen_width / image_width, (float)screen_height / image_height);
|
||||
imlib_render_image_on_drawable_at_size((screen_width - (int)(image_width * scale)) / 2, (screen_height - (int)(image_height * scale)) / 2, (int)(image_width * scale), (int)(image_height * scale));
|
||||
break;
|
||||
case MODE_TILE:
|
||||
for (int x = 0; x < screen_width; x += image_width) {
|
||||
for (int y = 0; y < screen_height; y += image_height) {
|
||||
imlib_render_image_on_drawable(x, y);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODE_FULL:
|
||||
imlib_render_image_on_drawable_at_size(0, 0, screen_width, screen_height);
|
||||
break;
|
||||
/* case MODE_EXTEND: */
|
||||
/* // 現在は未対応 */
|
||||
/* break; */
|
||||
case MODE_FILL:
|
||||
scale = fmax((float)screen_width / image_width, (float)screen_height / image_height);
|
||||
imlib_render_image_on_drawable_at_size(0, 0, (int)(image_width * scale), (int)(image_height * scale));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
imlib_free_image();
|
||||
XSetWindowBackgroundPixmap(display, wc, pixmap);
|
||||
XFreePixmap(display, pixmap);
|
||||
XClearWindow(display, wc);
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
applyrules(Client *c)
|
||||
|
@ -2817,6 +2899,7 @@ main(int argc, char *argv[])
|
|||
checkotherwm();
|
||||
setdpms();
|
||||
setupbackgrounds();
|
||||
setrootbg();
|
||||
autostart_exec();
|
||||
XrmInitialize();
|
||||
load_xresources();
|
||||
|
|
読み込み中…
新しいイシューから参照