summaryrefslogtreecommitdiff
path: root/dmenu
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu')
-rw-r--r--dmenu/config.def.h8
-rw-r--r--dmenu/dmenu.c50
2 files changed, 40 insertions, 18 deletions
diff --git a/dmenu/config.def.h b/dmenu/config.def.h
index 1edb647..bc17068 100644
--- a/dmenu/config.def.h
+++ b/dmenu/config.def.h
@@ -8,10 +8,10 @@ static const char *fonts[] = {
};
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {
- /* fg bg */
- [SchemeNorm] = { "#bbbbbb", "#222222" },
- [SchemeSel] = { "#eeeeee", "#005577" },
- [SchemeOut] = { "#000000", "#00ffff" },
+ /* fg bg */
+ [SchemeNorm] = { "#dddddd", "#000000" },
+ [SchemeSel] = { "#ffffff", "#66ccff" },
+ [SchemeOut] = { "#000000", "#66ccff" },
};
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
static unsigned int lines = 0;
diff --git a/dmenu/dmenu.c b/dmenu/dmenu.c
index 40153dc..066d20f 100644
--- a/dmenu/dmenu.c
+++ b/dmenu/dmenu.c
@@ -64,9 +64,12 @@ char color[8];
} ColorShm;
static ColorShm *accentshm;
static char accentcol[8] = "#005577";
+static const double opacity = 0.85;
static void initaccent(void);
static void updateaccent(void);
+static int openaccent(void);
+static void setopacity(Window w, double opacity);
#include "config.h"
@@ -127,13 +130,30 @@ cleanup(void)
XCloseDisplay(dpy);
}
+static int
+openaccent(void)
+{
+ int fd;
+ if (accentshm)
+ return 1;
+ if ((fd = shm_open(SHMNAME, O_RDONLY, 0)) < 0)
+ return 0;
+ accentshm = mmap(NULL, sizeof(ColorShm), PROT_READ, MAP_SHARED, fd, 0);
+ close(fd);
+ if (accentshm == MAP_FAILED) {
+ accentshm = NULL;
+ return 0;
+ }
+ return 1;
+}
+
static void
updateaccent(void)
{
uint32_t s1, s2;
char tmp[8];
- if (!accentshm)
+ if (!accentshm && !openaccent())
return;
do {
s1 = accentshm->seq;
@@ -149,15 +169,7 @@ updateaccent(void)
static void
initaccent(void)
{
-int fd = shm_open(SHMNAME, O_RDONLY, 0);
-if (fd >= 0) {
-accentshm = mmap(NULL, sizeof(ColorShm), PROT_READ,
- MAP_SHARED, fd, 0);
-if (accentshm == MAP_FAILED)
-accentshm = NULL;
-close(fd);
-}
-updateaccent();
+ updateaccent();
}
static char *
cistrstr(const char *h, const char *n)
@@ -240,6 +252,15 @@ drawmenu(void)
}
static void
+setopacity(Window w, double op)
+{
+ unsigned long val = op * 0xffffffff;
+ XChangeProperty(dpy, w, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *)&val, 1);
+}
+
+static void
grabfocus(void)
{
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
@@ -758,10 +779,11 @@ setup(void)
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, win, XNFocusWindow, win, NULL);
- XMapRaised(dpy, win);
- if (embed) {
- XReparentWindow(dpy, win, parentwin, x, y);
- XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
+ XMapRaised(dpy, win);
+ setopacity(win, opacity);
+ if (embed) {
+ XReparentWindow(dpy, win, parentwin, x, y);
+ XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
for (i = 0; i < du && dws[i] != win; ++i)
XSelectInput(dpy, dws[i], FocusChangeMask);