Lines 83-88
static const char *cvstag = "$scrotwm: s
Link Here
|
83 |
#include <X11/Xproto.h> |
83 |
#include <X11/Xproto.h> |
84 |
#include <X11/Xutil.h> |
84 |
#include <X11/Xutil.h> |
85 |
#include <X11/extensions/Xrandr.h> |
85 |
#include <X11/extensions/Xrandr.h> |
|
|
86 |
#include <X11/Xft/Xft.h> |
86 |
|
87 |
|
87 |
#if RANDR_MAJOR < 1 |
88 |
#if RANDR_MAJOR < 1 |
88 |
# error XRandR versions less than 1.0 are not supported |
89 |
# error XRandR versions less than 1.0 are not supported |
Lines 201-206
XGCValues bar_gcv;
Link Here
|
201 |
int bar_fidx = 0; |
202 |
int bar_fidx = 0; |
202 |
XFontStruct *bar_fs; |
203 |
XFontStruct *bar_fs; |
203 |
char *bar_fonts[] = { NULL, NULL, NULL, NULL };/* XXX Make fully dynamic */ |
204 |
char *bar_fonts[] = { NULL, NULL, NULL, NULL };/* XXX Make fully dynamic */ |
|
|
205 |
XftDraw *xft_draw; |
206 |
XftFont *bar_xft_fs; |
207 |
XftColor xft_color; |
208 |
int xft_loaded = 0; |
204 |
char *spawn_term[] = { NULL, NULL }; /* XXX Make fully dynamic */ |
209 |
char *spawn_term[] = { NULL, NULL }; /* XXX Make fully dynamic */ |
205 |
|
210 |
|
206 |
#define SWM_MENU_FN (2) |
211 |
#define SWM_MENU_FN (2) |
Lines 707-714
bar_print(struct swm_region *r, char *s)
Link Here
|
707 |
{ |
712 |
{ |
708 |
XClearWindow(display, r->bar_window); |
713 |
XClearWindow(display, r->bar_window); |
709 |
XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color); |
714 |
XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color); |
710 |
XDrawString(display, r->bar_window, bar_gc, 4, bar_fs->ascent, s, |
715 |
if (xft_loaded) { |
711 |
strlen(s)); |
716 |
xft_draw = XftDrawCreate(display, |
|
|
717 |
r->bar_window, |
718 |
DefaultVisual(display, DefaultScreen(display)), |
719 |
DefaultColormap(display, DefaultScreen(display))); |
720 |
XftDrawString8(xft_draw, &xft_color, bar_xft_fs, 4, |
721 |
bar_xft_fs->ascent, s, strlen(s)); |
722 |
} |
723 |
else |
724 |
XDrawString(display, r->bar_window, bar_gc, 4, bar_fs->ascent, s, |
725 |
strlen(s)); |
712 |
} |
726 |
} |
713 |
|
727 |
|
714 |
void |
728 |
void |
Lines 893-920
bar_refresh(void)
Link Here
|
893 |
bar_update(); |
907 |
bar_update(); |
894 |
} |
908 |
} |
895 |
|
909 |
|
|
|
910 |
int |
911 |
is_xft(char *font, char *xft_result) |
912 |
{ |
913 |
int i, j; |
914 |
|
915 |
if (font == NULL) |
916 |
return (0); |
917 |
|
918 |
if (strncmp("xft:", font, 4) == 0) |
919 |
for (i = 0, j = 4; font[j] != '\0'; i++, j++) |
920 |
xft_result[i] = font[j]; |
921 |
else |
922 |
return (0); |
923 |
|
924 |
return (1); |
925 |
} |
926 |
|
896 |
void |
927 |
void |
897 |
bar_setup(struct swm_region *r) |
928 |
bar_setup(struct swm_region *r) |
898 |
{ |
929 |
{ |
899 |
int i; |
930 |
int i; |
|
|
931 |
char xftfont[64]; |
900 |
|
932 |
|
901 |
for (i = 0; bar_fonts[i] != NULL; i++) { |
933 |
for (i = 0; bar_fonts[i] != NULL; i++) { |
902 |
bar_fs = XLoadQueryFont(display, bar_fonts[i]); |
934 |
if (is_xft(bar_fonts[i], xftfont)) { |
903 |
if (bar_fs) { |
935 |
bar_xft_fs = XftFontOpenName(display, |
|
|
936 |
DefaultScreen(display), xftfont); |
937 |
XftColorAllocName(display, |
938 |
DefaultVisual(display, DefaultScreen(display)), |
939 |
DefaultColormap(display, DefaultScreen(display)), |
940 |
r->s->c[SWM_S_COLOR_BAR_FONT].name, |
941 |
&xft_color); |
942 |
xft_loaded = 1; |
943 |
} |
944 |
else { |
945 |
bar_fs = XLoadQueryFont(display, bar_fonts[i]); |
946 |
xft_loaded = 0; |
947 |
} |
948 |
|
949 |
if (bar_fs || bar_xft_fs) { |
904 |
bar_fidx = i; |
950 |
bar_fidx = i; |
905 |
break; |
951 |
break; |
906 |
} |
952 |
} |
907 |
} |
953 |
} |
908 |
if (bar_fonts[i] == NULL) |
954 |
if (bar_fonts[i] == NULL) |
909 |
errx(1, "couldn't load font"); |
955 |
errx(1, "couldn't load font"); |
910 |
bar_height = bar_fs->ascent + bar_fs->descent + 3; |
956 |
if (!xft_loaded) |
911 |
|
957 |
bar_height = bar_fs->ascent + bar_fs->descent + 3; |
|
|
958 |
else |
959 |
bar_height = bar_xft_fs->ascent + bar_xft_fs->descent + 3; |
960 |
|
912 |
r->bar_window = XCreateSimpleWindow(display, |
961 |
r->bar_window = XCreateSimpleWindow(display, |
913 |
r->s->root, X(r), Y(r), WIDTH(r) - 2, bar_height - 2, |
962 |
r->s->root, X(r), Y(r), WIDTH(r) - 2, bar_height - 2, |
914 |
1, r->s->c[SWM_S_COLOR_BAR_BORDER].color, |
963 |
1, r->s->c[SWM_S_COLOR_BAR_BORDER].color, |
915 |
r->s->c[SWM_S_COLOR_BAR].color); |
964 |
r->s->c[SWM_S_COLOR_BAR].color); |
916 |
bar_gc = XCreateGC(display, r->bar_window, 0, &bar_gcv); |
965 |
bar_gc = XCreateGC(display, r->bar_window, 0, &bar_gcv); |
917 |
XSetFont(display, bar_gc, bar_fs->fid); |
966 |
if (!xft_loaded) |
|
|
967 |
XSetFont(display, bar_gc, bar_fs->fid); |
918 |
XSelectInput(display, r->bar_window, VisibilityChangeMask); |
968 |
XSelectInput(display, r->bar_window, VisibilityChangeMask); |
919 |
if (bar_enabled) |
969 |
if (bar_enabled) |
920 |
XMapRaised(display, r->bar_window); |
970 |
XMapRaised(display, r->bar_window); |