Xinqi Bao's Git
1341c3b8615096db084de0f68f92c09855e34c39
1 /* See LICENSE file for copyright and license details. */
13 #include <X11/Xatom.h>
14 #include <X11/Xproto.h>
15 #include <X11/Xutil.h>
17 #include <X11/extensions/Xinerama.h>
19 #include <X11/Xft/Xft.h>
25 #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
26 * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
27 #define LENGTH(X) (sizeof X / sizeof X[0])
28 #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
33 enum { SchemeNorm
, SchemeSel
, SchemeOut
, SchemeLast
}; /* color schemes */
37 struct item
*left
, *right
;
42 static char text
[BUFSIZ
] = "";
44 static int bh
, mw
, mh
;
45 static int inputw
= 0, promptw
;
46 static int lrpad
; /* sum of left and right padding */
48 static struct item
*items
= NULL
;
49 static struct item
*matches
, *matchend
;
50 static struct item
*prev
, *curr
, *next
, *sel
;
51 static int mon
= -1, screen
;
53 static Atom clip
, utf8
;
55 static Window root
, parentwin
, win
;
59 static Clr
*scheme
[SchemeLast
];
61 static int useargb
= 0;
62 static Visual
*visual
;
68 static int (*fstrncmp
)(const char *, const char *, size_t) = strncmp
;
69 static char *(*fstrstr
)(const char *, const char *) = strstr
;
70 static void xinitvisual();
73 textw_clamp(const char *str
, unsigned int n
)
75 unsigned int w
= drw_fontset_getwidth_clamp(drw
, str
, n
) + lrpad
;
80 appenditem(struct item
*item
, struct item
**list
, struct item
**last
)
83 (*last
)->right
= item
;
100 n
= mw
- (promptw
+ inputw
+ TEXTW("<") + TEXTW(">"));
101 /* calculate which items will begin the next page and previous page */
102 for (i
= 0, next
= curr
; next
; next
= next
->right
)
103 if ((i
+= (lines
> 0) ? bh
: textw_clamp(next
->text
, n
)) > n
)
105 for (i
= 0, prev
= curr
; prev
&& prev
->left
; prev
= prev
->left
)
106 if ((i
+= (lines
> 0) ? bh
: textw_clamp(prev
->left
->text
, n
)) > n
)
114 for (struct item
*item
= items
; item
&& item
->text
; item
++)
115 len
= MAX(TEXTW(item
->text
), len
);
124 XUngrabKey(dpy
, AnyKey
, AnyModifier
, root
);
125 for (i
= 0; i
< SchemeLast
; i
++)
127 for (i
= 0; items
&& items
[i
].text
; ++i
)
136 cistrstr(const char *h
, const char *n
)
144 for (i
= 0; n
[i
] && tolower((unsigned char)n
[i
]) ==
145 tolower((unsigned char)h
[i
]); ++i
)
154 drawitem(struct item
*item
, int x
, int y
, int w
)
157 drw_setscheme(drw
, scheme
[SchemeSel
]);
159 drw_setscheme(drw
, scheme
[SchemeOut
]);
161 drw_setscheme(drw
, scheme
[SchemeNorm
]);
163 return drw_text(drw
, x
, y
, w
, bh
, lrpad
/ 2, item
->text
, 0);
173 drw_setscheme(drw
, scheme
[SchemeNorm
]);
174 drw_rect(drw
, 0, 0, mw
, mh
, 1, 1);
176 if (prompt
&& *prompt
) {
177 drw_setscheme(drw
, scheme
[SchemeSel
]);
178 x
= drw_text(drw
, x
, 0, promptw
, bh
, lrpad
/ 2, prompt
, 0);
180 /* draw input field */
181 w
= (lines
> 0 || !matches
) ? mw
- x
: inputw
;
182 drw_setscheme(drw
, scheme
[SchemeNorm
]);
183 drw_text(drw
, x
, 0, w
, bh
, lrpad
/ 2, text
, 0);
185 curpos
= TEXTW(text
) - TEXTW(&text
[cursor
]);
186 if ((curpos
+= lrpad
/ 2 - 1) < w
) {
187 drw_setscheme(drw
, scheme
[SchemeNorm
]);
188 drw_rect(drw
, x
+ curpos
, 2, 2, bh
- 4, 1, 0);
192 /* draw vertical list */
193 for (item
= curr
; item
!= next
; item
= item
->right
)
194 drawitem(item
, x
, y
+= bh
, mw
- x
);
195 } else if (matches
) {
196 /* draw horizontal list */
200 drw_setscheme(drw
, scheme
[SchemeNorm
]);
201 drw_text(drw
, x
, 0, w
, bh
, lrpad
/ 2, "<", 0);
204 for (item
= curr
; item
!= next
; item
= item
->right
)
205 x
= drawitem(item
, x
, 0, textw_clamp(item
->text
, mw
- x
- TEXTW(">")));
208 drw_setscheme(drw
, scheme
[SchemeNorm
]);
209 drw_text(drw
, mw
- w
, 0, w
, bh
, lrpad
/ 2, ">", 0);
212 drw_map(drw
, win
, 0, 0, mw
, mh
);
218 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 10000000 };
222 for (i
= 0; i
< 100; ++i
) {
223 XGetInputFocus(dpy
, &focuswin
, &revertwin
);
226 XSetInputFocus(dpy
, win
, RevertToParent
, CurrentTime
);
227 nanosleep(&ts
, NULL
);
229 die("cannot grab focus");
235 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 1000000 };
240 /* try to grab keyboard, we may have to wait for another process to ungrab */
241 for (i
= 0; i
< 1000; i
++) {
242 if (XGrabKeyboard(dpy
, DefaultRootWindow(dpy
), True
, GrabModeAsync
,
243 GrabModeAsync
, CurrentTime
) == GrabSuccess
)
245 nanosleep(&ts
, NULL
);
247 die("cannot grab keyboard");
251 compare_distance(const void *a
, const void *b
)
253 struct item
*da
= *(struct item
**) a
;
254 struct item
*db
= *(struct item
**) b
;
261 return da
->distance
== db
->distance
? 0 : da
->distance
< db
->distance
? -1 : 1;
267 /* bang - we have so much memory */
269 struct item
**fuzzymatches
= NULL
;
271 int number_of_matches
= 0, i
, pidx
, sidx
, eidx
;
272 int text_len
= strlen(text
), itext_len
;
274 matches
= matchend
= NULL
;
276 /* walk through all items */
277 for (it
= items
; it
&& it
->text
; it
++) {
279 itext_len
= strlen(it
->text
);
280 pidx
= 0; /* pointer */
281 sidx
= eidx
= -1; /* start of match, end of match */
282 /* walk through item text */
283 for (i
= 0; i
< itext_len
&& (c
= it
->text
[i
]); i
++) {
284 /* fuzzy match pattern */
285 if (!fstrncmp(&text
[pidx
], &c
, 1)) {
289 if (pidx
== text_len
) {
295 /* build list of matches */
297 /* compute distance */
298 /* add penalty if match starts late (log(sidx+2))
299 * add penalty for long a match without many matching characters */
300 it
->distance
= log(sidx
+ 2) + (double)(eidx
- sidx
- text_len
);
301 /* fprintf(stderr, "distance %s %f\n", it->text, it->distance); */
302 appenditem(it
, &matches
, &matchend
);
306 appenditem(it
, &matches
, &matchend
);
310 if (number_of_matches
) {
311 /* initialize array with matches */
312 if (!(fuzzymatches
= realloc(fuzzymatches
, number_of_matches
* sizeof(struct item
*))))
313 die("cannot realloc %u bytes:", number_of_matches
* sizeof(struct item
*));
314 for (i
= 0, it
= matches
; it
&& i
< number_of_matches
; i
++, it
= it
->right
) {
315 fuzzymatches
[i
] = it
;
317 /* sort matches according to distance */
318 qsort(fuzzymatches
, number_of_matches
, sizeof(struct item
*), compare_distance
);
319 /* rebuild list of matches */
320 matches
= matchend
= NULL
;
321 for (i
= 0, it
= fuzzymatches
[i
]; i
< number_of_matches
&& it
&& \
322 it
->text
; i
++, it
= fuzzymatches
[i
]) {
323 appenditem(it
, &matches
, &matchend
);
327 curr
= sel
= matches
;
338 static char **tokv
= NULL
;
341 char buf
[sizeof text
], *s
;
343 size_t len
, textsize
;
344 struct item
*item
, *lprefix
, *lsubstr
, *prefixend
, *substrend
;
347 /* separate input text into tokens to be matched individually */
348 for (s
= strtok(buf
, " "); s
; tokv
[tokc
- 1] = s
, s
= strtok(NULL
, " "))
349 if (++tokc
> tokn
&& !(tokv
= realloc(tokv
, ++tokn
* sizeof *tokv
)))
350 die("cannot realloc %zu bytes:", tokn
* sizeof *tokv
);
351 len
= tokc
? strlen(tokv
[0]) : 0;
353 matches
= lprefix
= lsubstr
= matchend
= prefixend
= substrend
= NULL
;
354 textsize
= strlen(text
) + 1;
355 for (item
= items
; item
&& item
->text
; item
++) {
356 for (i
= 0; i
< tokc
; i
++)
357 if (!fstrstr(item
->text
, tokv
[i
]))
359 if (i
!= tokc
) /* not all tokens match */
361 /* exact matches go first, then prefixes, then substrings */
362 if (!tokc
|| !fstrncmp(text
, item
->text
, textsize
))
363 appenditem(item
, &matches
, &matchend
);
364 else if (!fstrncmp(tokv
[0], item
->text
, len
))
365 appenditem(item
, &lprefix
, &prefixend
);
367 appenditem(item
, &lsubstr
, &substrend
);
371 matchend
->right
= lprefix
;
372 lprefix
->left
= matchend
;
375 matchend
= prefixend
;
379 matchend
->right
= lsubstr
;
380 lsubstr
->left
= matchend
;
383 matchend
= substrend
;
385 curr
= sel
= matches
;
390 insert(const char *str
, ssize_t n
)
392 if (strlen(text
) + n
> sizeof text
- 1)
394 /* move existing text out of the way, insert new text, and update cursor */
395 memmove(&text
[cursor
+ n
], &text
[cursor
], sizeof text
- cursor
- MAX(n
, 0));
397 memcpy(&text
[cursor
], str
, n
);
407 /* return location of next utf8 rune in the given direction (+1 or -1) */
408 for (n
= cursor
+ inc
; n
+ inc
>= 0 && (text
[n
] & 0xc0) == 0x80; n
+= inc
)
414 movewordedge(int dir
)
416 if (dir
< 0) { /* move cursor to the start of the word*/
417 while (cursor
> 0 && strchr(worddelimiters
, text
[nextrune(-1)]))
418 cursor
= nextrune(-1);
419 while (cursor
> 0 && !strchr(worddelimiters
, text
[nextrune(-1)]))
420 cursor
= nextrune(-1);
421 } else { /* move cursor to the end of the word */
422 while (text
[cursor
] && strchr(worddelimiters
, text
[cursor
]))
423 cursor
= nextrune(+1);
424 while (text
[cursor
] && !strchr(worddelimiters
, text
[cursor
]))
425 cursor
= nextrune(+1);
430 keypress(XKeyEvent
*ev
)
437 len
= XmbLookupString(xic
, ev
, buf
, sizeof buf
, &ksym
, &status
);
439 default: /* XLookupNone, XBufferOverflow */
448 if (ev
->state
& ControlMask
) {
450 case XK_a
: ksym
= XK_Home
; break;
451 case XK_b
: ksym
= XK_Left
; break;
452 case XK_c
: ksym
= XK_Escape
; break;
453 case XK_d
: ksym
= XK_Delete
; break;
454 case XK_e
: ksym
= XK_End
; break;
455 case XK_f
: ksym
= XK_Right
; break;
456 case XK_g
: ksym
= XK_Escape
; break;
457 case XK_h
: ksym
= XK_BackSpace
; break;
458 case XK_i
: ksym
= XK_Tab
; break;
459 case XK_j
: /* fallthrough */
460 case XK_J
: /* fallthrough */
461 case XK_m
: /* fallthrough */
462 case XK_M
: ksym
= XK_Return
; ev
->state
&= ~ControlMask
; break;
463 case XK_n
: ksym
= XK_Down
; break;
464 case XK_p
: ksym
= XK_Up
; break;
466 case XK_k
: /* delete right */
470 case XK_u
: /* delete left */
471 insert(NULL
, 0 - cursor
);
473 case XK_w
: /* delete word */
474 while (cursor
> 0 && strchr(worddelimiters
, text
[nextrune(-1)]))
475 insert(NULL
, nextrune(-1) - cursor
);
476 while (cursor
> 0 && !strchr(worddelimiters
, text
[nextrune(-1)]))
477 insert(NULL
, nextrune(-1) - cursor
);
479 case XK_y
: /* paste selection */
481 XConvertSelection(dpy
, (ev
->state
& ShiftMask
) ? clip
: XA_PRIMARY
,
482 utf8
, utf8
, win
, CurrentTime
);
501 } else if (ev
->state
& Mod1Mask
) {
509 case XK_g
: ksym
= XK_Home
; break;
510 case XK_G
: ksym
= XK_End
; break;
511 case XK_h
: ksym
= XK_Up
; break;
512 case XK_j
: ksym
= XK_Next
; break;
513 case XK_k
: ksym
= XK_Prior
; break;
514 case XK_l
: ksym
= XK_Down
; break;
523 if (!iscntrl((unsigned char)*buf
))
528 if (text
[cursor
] == '\0')
530 cursor
= nextrune(+1);
535 insert(NULL
, nextrune(-1) - cursor
);
539 if (text
[cursor
] != '\0') {
540 cursor
= strlen(text
);
544 /* jump to end of list and position items in reverse */
549 while (next
&& (curr
= curr
->right
))
559 if (sel
== matches
) {
563 sel
= curr
= matches
;
568 if (cursor
> 0 && (!sel
|| !sel
->left
|| lines
> 0)) {
569 cursor
= nextrune(-1);
577 if (sel
&& sel
->left
&& (sel
= sel
->left
)->right
== curr
) {
598 puts((sel
&& !(ev
->state
& ShiftMask
)) ? sel
->text
: text
);
599 if (!(ev
->state
& ControlMask
)) {
608 if (text
[cursor
] != '\0') {
609 cursor
= nextrune(+1);
617 if (sel
&& sel
->right
&& (sel
= sel
->right
) == next
) {
625 strncpy(text
, sel
->text
, sizeof text
- 1);
626 text
[sizeof text
- 1] = '\0';
627 cursor
= strlen(text
);
644 /* we have been given the current selection, now insert it into input */
645 if (XGetWindowProperty(dpy
, win
, utf8
, 0, (sizeof text
/ 4) + 1, False
,
646 utf8
, &da
, &di
, &dl
, &dl
, (unsigned char **)&p
)
648 insert(p
, (q
= strchr(p
, '\n')) ? q
- p
: (ssize_t
)strlen(p
));
657 char buf
[sizeof text
], *p
;
660 /* read each line from stdin and add it to the item list */
661 for (i
= 0; fgets(buf
, sizeof buf
, stdin
); i
++) {
662 if (i
+ 1 >= size
/ sizeof *items
)
663 if (!(items
= realloc(items
, (size
+= BUFSIZ
))))
664 die("cannot realloc %zu bytes:", size
);
665 if ((p
= strchr(buf
, '\n')))
667 if (!(items
[i
].text
= strdup(buf
)))
668 die("cannot strdup %zu bytes:", strlen(buf
) + 1);
672 items
[i
].text
= NULL
;
673 lines
= MIN(lines
, i
);
681 while (!XNextEvent(dpy
, &ev
)) {
682 if (XFilterEvent(&ev
, win
))
686 if (ev
.xdestroywindow
.window
!= win
)
691 if (ev
.xexpose
.count
== 0)
692 drw_map(drw
, win
, 0, 0, mw
, mh
);
695 /* regrab focus from parent window */
696 if (ev
.xfocus
.window
!= win
)
702 case SelectionNotify
:
703 if (ev
.xselection
.property
== utf8
)
706 case VisibilityNotify
:
707 if (ev
.xvisibility
.state
!= VisibilityUnobscured
)
708 XRaiseWindow(dpy
, win
);
718 unsigned int du
, tmp
;
719 XSetWindowAttributes swa
;
722 XWindowAttributes wa
;
723 XClassHint ch
= {"dmenu", "dmenu"};
726 XineramaScreenInfo
*info
;
728 int a
, di
, n
, area
= 0;
730 /* init appearance */
731 for (j
= 0; j
< SchemeLast
; j
++)
732 scheme
[j
] = drw_scm_create(drw
, colors
[j
], alphas
[j
], 2);
734 clip
= XInternAtom(dpy
, "CLIPBOARD", False
);
735 utf8
= XInternAtom(dpy
, "UTF8_STRING", False
);
737 /* calculate menu geometry */
738 bh
= drw
->fonts
->h
+ 2;
739 lines
= MAX(lines
, 0);
740 mh
= (lines
+ 1) * bh
;
741 promptw
= (prompt
&& *prompt
) ? TEXTW(prompt
) - lrpad
/ 4 : 0;
744 if (parentwin
== root
&& (info
= XineramaQueryScreens(dpy
, &n
))) {
745 XGetInputFocus(dpy
, &w
, &di
);
746 if (mon
>= 0 && mon
< n
)
748 else if (w
!= root
&& w
!= PointerRoot
&& w
!= None
) {
749 /* find top-level window containing current input focus */
751 if (XQueryTree(dpy
, (pw
= w
), &dw
, &w
, &dws
, &du
) && dws
)
753 } while (w
!= root
&& w
!= pw
);
754 /* find xinerama screen with which the window intersects most */
755 if (XGetWindowAttributes(dpy
, pw
, &wa
))
756 for (j
= 0; j
< n
; j
++)
757 if ((a
= INTERSECT(wa
.x
, wa
.y
, wa
.width
, wa
.height
, info
[j
])) > area
) {
762 /* no focused window is on screen, so use pointer location instead */
763 if (mon
< 0 && !area
&& XQueryPointer(dpy
, root
, &dw
, &dw
, &x
, &y
, &di
, &di
, &du
))
764 for (i
= 0; i
< n
; i
++)
765 if (INTERSECT(x
, y
, 1, 1, info
[i
]) != 0)
769 mw
= MIN(MAX(max_textw() + promptw
, min_width
), info
[i
].width
);
770 x
= info
[i
].x_org
+ ((info
[i
].width
- mw
) / 2);
771 y
= info
[i
].y_org
+ ((info
[i
].height
- mh
) / 2);
774 y
= info
[i
].y_org
+ (topbar
? 0 : info
[i
].height
- mh
);
782 if (!XGetWindowAttributes(dpy
, parentwin
, &wa
))
783 die("could not get embedding window attributes: 0x%lx",
787 mw
= MIN(MAX(max_textw() + promptw
, min_width
), wa
.width
);
788 x
= (wa
.width
- mw
) / 2;
789 y
= (wa
.height
- mh
) / 2;
792 y
= topbar
? 0 : wa
.height
- mh
;
796 for (item
= items
; item
&& item
->text
; ++item
) {
797 if ((tmp
= textw_clamp(item
->text
, mw
/3)) > inputw
) {
798 if ((inputw
= tmp
) == mw
/3)
804 /* create menu window */
805 swa
.override_redirect
= True
;
806 swa
.background_pixel
= 0;
807 swa
.border_pixel
= 0;
809 swa
.event_mask
= ExposureMask
| KeyPressMask
| VisibilityChangeMask
;
810 win
= XCreateWindow(dpy
, parentwin
, x
, y
, mw
, mh
, 0,
811 depth
, CopyFromParent
, visual
,
812 CWOverrideRedirect
| CWBackPixel
| CWBorderPixel
| CWColormap
| CWEventMask
, &swa
);
813 XSetClassHint(dpy
, win
, &ch
);
817 if ((xim
= XOpenIM(dpy
, NULL
, NULL
, NULL
)) == NULL
)
818 die("XOpenIM failed: could not open input device");
820 xic
= XCreateIC(xim
, XNInputStyle
, XIMPreeditNothing
| XIMStatusNothing
,
821 XNClientWindow
, win
, XNFocusWindow
, win
, NULL
);
823 XMapRaised(dpy
, win
);
825 XSelectInput(dpy
, parentwin
, FocusChangeMask
| SubstructureNotifyMask
);
826 if (XQueryTree(dpy
, parentwin
, &dw
, &w
, &dws
, &du
) && dws
) {
827 for (i
= 0; i
< du
&& dws
[i
] != win
; ++i
)
828 XSelectInput(dpy
, dws
[i
], FocusChangeMask
);
833 drw_resize(drw
, mw
, mh
);
840 fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
841 " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr
);
846 main(int argc
, char *argv
[])
848 XWindowAttributes wa
;
851 for (i
= 1; i
< argc
; i
++)
852 /* these options take no arguments */
853 if (!strcmp(argv
[i
], "-v")) { /* prints version information */
854 puts("dmenu-"VERSION
);
856 } else if (!strcmp(argv
[i
], "-b")) /* appears at the bottom of the screen */
858 else if (!strcmp(argv
[i
], "-f")) /* grabs keyboard before reading stdin */
860 else if (!strcmp(argv
[i
], "-F")) /* grabs keyboard before reading stdin */
861 /* always fuzzy */; // fuzzy = 0;
862 else if (!strcmp(argv
[i
], "-c")) /* centers dmenu on screen */
864 else if (!strcmp(argv
[i
], "-i")) { /* case-insensitive item matching */
865 fstrncmp
= strncasecmp
;
867 } else if (i
+ 1 == argc
)
869 /* these options take one argument */
870 else if (!strcmp(argv
[i
], "-l")) /* number of lines in vertical list */
871 lines
= atoi(argv
[++i
]);
872 else if (!strcmp(argv
[i
], "-m"))
873 mon
= atoi(argv
[++i
]);
874 else if (!strcmp(argv
[i
], "-p")) /* adds prompt to left of input field */
876 else if (!strcmp(argv
[i
], "-fn")) /* font or font set */
877 fonts
[0] = argv
[++i
];
878 else if (!strcmp(argv
[i
], "-nb")) /* normal background color */
879 colors
[SchemeNorm
][ColBg
] = argv
[++i
];
880 else if (!strcmp(argv
[i
], "-nf")) /* normal foreground color */
881 colors
[SchemeNorm
][ColFg
] = argv
[++i
];
882 else if (!strcmp(argv
[i
], "-sb")) /* selected background color */
883 colors
[SchemeSel
][ColBg
] = argv
[++i
];
884 else if (!strcmp(argv
[i
], "-sf")) /* selected foreground color */
885 colors
[SchemeSel
][ColFg
] = argv
[++i
];
886 else if (!strcmp(argv
[i
], "-w")) /* embedding window id */
891 if (!setlocale(LC_CTYPE
, "") || !XSupportsLocale())
892 fputs("warning: no locale support\n", stderr
);
893 if (!(dpy
= XOpenDisplay(NULL
)))
894 die("cannot open display");
895 screen
= DefaultScreen(dpy
);
896 root
= RootWindow(dpy
, screen
);
897 if (!embed
|| !(parentwin
= strtol(embed
, NULL
, 0)))
899 if (!XGetWindowAttributes(dpy
, parentwin
, &wa
))
900 die("could not get embedding window attributes: 0x%lx",
903 drw
= drw_create(dpy
, screen
, root
, wa
.width
, wa
.height
, visual
, depth
, cmap
);
904 if (!drw_fontset_create(drw
, fonts
, LENGTH(fonts
)))
905 die("no fonts could be loaded.");
906 lrpad
= drw
->fonts
->h
;
909 if (pledge("stdio rpath", NULL
) == -1)
913 if (fast
&& !isatty(0)) {
923 return 1; /* unreachable */
930 XRenderPictFormat
*fmt
;
939 long masks
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
941 infos
= XGetVisualInfo(dpy
, masks
, &tpl
, &nitems
);
943 for(i
= 0; i
< nitems
; i
++) {
944 fmt
= XRenderFindVisualFormat(dpy
, infos
[i
].visual
);
945 if (fmt
->type
== PictTypeDirect
&& fmt
->direct
.alphaMask
) {
946 visual
= infos
[i
].visual
;
947 depth
= infos
[i
].depth
;
948 cmap
= XCreateColormap(dpy
, root
, visual
, AllocNone
);
957 visual
= DefaultVisual(dpy
, screen
);
958 depth
= DefaultDepth(dpy
, screen
);
959 cmap
= DefaultColormap(dpy
, screen
);