|
@@ -25,6 +25,9 @@
|
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
|
|
|
|
|
|
|
+/* define opaqueness */
|
|
|
|
+#define OPAQUE 0xFFU
|
|
|
|
+
|
|
/* enums */
|
|
/* enums */
|
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
|
|
|
|
|
@@ -51,6 +54,10 @@ static Window root, parentwin, win;
|
|
static XIC xic;
|
|
static XIC xic;
|
|
|
|
|
|
static Drw *drw;
|
|
static Drw *drw;
|
|
|
|
+static int usergb = 0;
|
|
|
|
+static Visual *visual;
|
|
|
|
+static int depth;
|
|
|
|
+static Colormap cmap;
|
|
static Clr *scheme[SchemeLast];
|
|
static Clr *scheme[SchemeLast];
|
|
|
|
|
|
#include "config.h"
|
|
#include "config.h"
|
|
@@ -58,6 +65,46 @@ static Clr *scheme[SchemeLast];
|
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
|
|
|
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+xinitvisual()
|
|
|
|
+{
|
|
|
|
+ XVisualInfo *infos;
|
|
|
|
+ XRenderPictFormat *fmt;
|
|
|
|
+ int nitems;
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ XVisualInfo tpl = {
|
|
|
|
+ .screen = screen,
|
|
|
|
+ .depth = 32,
|
|
|
|
+ .class = TrueColor
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
|
|
|
|
+
|
|
|
|
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
|
|
|
|
+ visual = NULL;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < nitems; i++){
|
|
|
|
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
|
|
|
|
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
|
|
|
|
+ visual = infos[i].visual;
|
|
|
|
+ depth = infos[i].depth;
|
|
|
|
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
|
|
|
|
+ usergb = 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ XFree(infos);
|
|
|
|
+
|
|
|
|
+ if (! visual) {
|
|
|
|
+ visual = DefaultVisual(dpy, screen);
|
|
|
|
+ depth = DefaultDepth(dpy, screen);
|
|
|
|
+ cmap = DefaultColormap(dpy, screen);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
static void
|
|
static void
|
|
appenditem(struct item *item, struct item **list, struct item **last)
|
|
appenditem(struct item *item, struct item **list, struct item **last)
|
|
{
|
|
{
|
|
@@ -597,7 +644,7 @@ setup(void)
|
|
#endif
|
|
#endif
|
|
/* init appearance */
|
|
/* init appearance */
|
|
for (j = 0; j < SchemeLast; j++)
|
|
for (j = 0; j < SchemeLast; j++)
|
|
- scheme[j] = drw_scm_create(drw, colors[j], 2);
|
|
|
|
|
|
+ scheme[j] = drw_scm_create(drw, colors[j], alphas[j], 2);
|
|
|
|
|
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
|
@@ -653,10 +700,12 @@ setup(void)
|
|
/* create menu window */
|
|
/* create menu window */
|
|
swa.override_redirect = True;
|
|
swa.override_redirect = True;
|
|
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
|
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
|
|
|
+ swa.border_pixel = 0;
|
|
|
|
+ swa.colormap = cmap;
|
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
|
- CopyFromParent, CopyFromParent, CopyFromParent,
|
|
|
|
- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
|
|
|
|
|
+ depth, InputOutput, visual,
|
|
|
|
+ CWOverrideRedirect | CWBackPixel | CWColormap | CWEventMask | CWBorderPixel, &swa);
|
|
XSetClassHint(dpy, win, &ch);
|
|
XSetClassHint(dpy, win, &ch);
|
|
|
|
|
|
/* open input methods */
|
|
/* open input methods */
|
|
@@ -742,7 +791,8 @@ main(int argc, char *argv[])
|
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
|
die("could not get embedding window attributes: 0x%lx",
|
|
die("could not get embedding window attributes: 0x%lx",
|
|
parentwin);
|
|
parentwin);
|
|
- drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
|
|
|
|
|
+ xinitvisual();
|
|
|
|
+ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
|
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
|
die("no fonts could be loaded.");
|
|
die("no fonts could be loaded.");
|
|
lrpad = drw->fonts->h;
|
|
lrpad = drw->fonts->h;
|