背景を追加
このコミットが含まれているのは:
コミット
d5410a3826
76
config.h
76
config.h
|
@ -34,18 +34,28 @@ static const char resolution[] = "1050";
|
||||||
static const char resolution[] = "1280";
|
static const char resolution[] = "1280";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MODE_CENTER,
|
||||||
|
MODE_COVER,
|
||||||
|
MODE_TILE,
|
||||||
|
MODE_FULL,
|
||||||
|
/* MODE_EXTEND, */
|
||||||
|
MODE_FILL
|
||||||
|
} BGMode;
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static unsigned int borderpx = 3; /* border pixel of windows */
|
static unsigned int borderpx = 3; /* border pixel of windows */
|
||||||
static unsigned int snap = 32; /* snap pixel */
|
static unsigned int snap = 32; /* snap pixel */
|
||||||
static unsigned int gappih = 5; /* horiz inner gap between windows */
|
static unsigned int gappih = 5; /* horiz inner gap between windows */
|
||||||
static unsigned int gappiv = 5; /* vert 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 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 gappov = 5; /* vert outer gap between windows and screen edge */
|
||||||
static unsigned int dpms = -1; /* 分間。DPMSを無効にする場合:-1 */
|
static unsigned int dpms = -1; /* 秒間。DPMSを無効にする場合:-1 */
|
||||||
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
static BGMode bgmode = MODE_FILL; /* 背景モード */
|
||||||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
static int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||||
static int showbar = 1; /* 0 means no bar */
|
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||||
static int topbar = 1; /* 0 means bottom bar */
|
static int showbar = 1; /* 0 means no bar */
|
||||||
|
static int topbar = 1; /* 0 means bottom bar */
|
||||||
#if MYPC == DESKTOP || MYPC == T43
|
#if MYPC == DESKTOP || MYPC == T43
|
||||||
static char *fonts[] = { "monospace:size=10", "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" };
|
static char *fonts[] = { "monospace:size=10", "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" };
|
||||||
#else
|
#else
|
||||||
|
@ -76,7 +86,11 @@ static Sp scratchpads[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const autostart[] = {
|
static const char *const autostart[] = {
|
||||||
"hsetroot", "-center", bgimg, NULL,
|
#if MYOS == OPENBSD
|
||||||
|
"uim", NULL,
|
||||||
|
#else
|
||||||
|
"fcitx5", NULL,
|
||||||
|
#endif
|
||||||
NULL /* terminate */
|
NULL /* terminate */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -158,25 +172,25 @@ static const char *termcmd[] = { TERMINAL, NULL };
|
||||||
* Xresources preferences to load at startup
|
* Xresources preferences to load at startup
|
||||||
*/
|
*/
|
||||||
ResourcePref resources[] = {
|
ResourcePref resources[] = {
|
||||||
{ "color0", STRING, &normbordercolor },
|
{ "color0", STRING, &normbordercolor },
|
||||||
{ "color8", STRING, &selbordercolor },
|
{ "color8", STRING, &selbordercolor },
|
||||||
{ "color0", STRING, &normbgcolor },
|
{ "color0", STRING, &normbgcolor },
|
||||||
{ "color4", STRING, &normfgcolor },
|
{ "color4", STRING, &normfgcolor },
|
||||||
{ "color0", STRING, &selfgcolor },
|
{ "color0", STRING, &selfgcolor },
|
||||||
{ "color4", STRING, &selbgcolor },
|
{ "color4", STRING, &selbgcolor },
|
||||||
{ "borderpx", INTEGER, &borderpx },
|
{ "borderpx", INTEGER, &borderpx },
|
||||||
{ "snap", INTEGER, &snap },
|
{ "snap", INTEGER, &snap },
|
||||||
{ "showbar", INTEGER, &showbar },
|
{ "showbar", INTEGER, &showbar },
|
||||||
{ "topbar", INTEGER, &topbar },
|
{ "topbar", INTEGER, &topbar },
|
||||||
{ "nmaster", INTEGER, &nmaster },
|
{ "nmaster", INTEGER, &nmaster },
|
||||||
{ "resizehints", INTEGER, &resizehints },
|
{ "resizehints", INTEGER, &resizehints },
|
||||||
{ "mfact", FLOAT, &mfact },
|
{ "mfact", FLOAT, &mfact },
|
||||||
{ "gappih", INTEGER, &gappih },
|
{ "gappih", INTEGER, &gappih },
|
||||||
{ "gappiv", INTEGER, &gappiv },
|
{ "gappiv", INTEGER, &gappiv },
|
||||||
{ "gappoh", INTEGER, &gappoh },
|
{ "gappoh", INTEGER, &gappoh },
|
||||||
{ "gappov", INTEGER, &gappov },
|
{ "gappov", INTEGER, &gappov },
|
||||||
{ "swallowfloating", INTEGER, &swallowfloating },
|
{ "swallowfloating", INTEGER, &swallowfloating },
|
||||||
{ "smartgaps", INTEGER, &smartgaps },
|
{ "smartgaps", INTEGER, &smartgaps },
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <X11/XF86keysym.h>
|
#include <X11/XF86keysym.h>
|
||||||
|
|
|
@ -31,7 +31,7 @@ endif
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
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)
|
ifeq ($(OS),FreeBSD)
|
||||||
LIBS += -lutil
|
LIBS += -lutil
|
||||||
endif
|
endif
|
||||||
|
|
89
dwm.c
89
dwm.c
|
@ -28,6 +28,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <Imlib2.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
@ -200,6 +202,7 @@ typedef struct {
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
static void setdpms();
|
static void setdpms();
|
||||||
static void setupbackgrounds();
|
static void setupbackgrounds();
|
||||||
|
static void setrootbg();
|
||||||
static void applyrules(Client *c);
|
static void applyrules(Client *c);
|
||||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||||
static void arrange(Monitor *m);
|
static void arrange(Monitor *m);
|
||||||
|
@ -395,9 +398,6 @@ autostart_exec() {
|
||||||
static pid_t *autostart_pids;
|
static pid_t *autostart_pids;
|
||||||
static size_t autostart_len;
|
static size_t autostart_len;
|
||||||
|
|
||||||
/* 背景を設定 */
|
|
||||||
char bgimg[100];
|
|
||||||
|
|
||||||
void setdpms() {
|
void setdpms() {
|
||||||
Display *display;
|
Display *display;
|
||||||
int dummy;
|
int dummy;
|
||||||
|
@ -423,12 +423,94 @@ void setdpms() {
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 背景を設定 */
|
||||||
|
char bgimg[100];
|
||||||
|
|
||||||
void setupbackgrounds() {
|
void setupbackgrounds() {
|
||||||
strcpy(bgimg, wallpaper);
|
strcpy(bgimg, wallpaper);
|
||||||
strcat(bgimg, resolution);
|
strcat(bgimg, resolution);
|
||||||
strcat(bgimg, ext);
|
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 */
|
/* function implementations */
|
||||||
void
|
void
|
||||||
applyrules(Client *c)
|
applyrules(Client *c)
|
||||||
|
@ -2817,6 +2899,7 @@ main(int argc, char *argv[])
|
||||||
checkotherwm();
|
checkotherwm();
|
||||||
setdpms();
|
setdpms();
|
||||||
setupbackgrounds();
|
setupbackgrounds();
|
||||||
|
setrootbg();
|
||||||
autostart_exec();
|
autostart_exec();
|
||||||
XrmInitialize();
|
XrmInitialize();
|
||||||
load_xresources();
|
load_xresources();
|
||||||
|
|
読み込み中…
新しいイシューから参照