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