Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 204105 Details for
Bug 284350
x11-wm/scrotwm (new package)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Patch #3 for scrotwm-0.9.6
03-scrotwm-0.9.6-use-xft.diff (text/plain), 4.00 KB, created by
Massimo Gengarelli
on 2009-09-14 17:36:10 UTC
(
hide
)
Description:
Patch #3 for scrotwm-0.9.6
Filename:
MIME Type:
Creator:
Massimo Gengarelli
Created:
2009-09-14 17:36:10 UTC
Size:
4.00 KB
patch
obsolete
>--- scrotwm-0.9.6/scrotwm.c 2009-09-14 19:09:15.000000000 +0200 >+++ scrotwm-0.9.6.devl/scrotwm.c 2009-09-14 18:59:38.000000000 +0200 >@@ -83,6 +83,7 @@ > #include <X11/Xproto.h> > #include <X11/Xutil.h> > #include <X11/extensions/Xrandr.h> >+#include <X11/Xft/Xft.h> > > #if RANDR_MAJOR < 1 > # error XRandR versions less than 1.0 are not supported >@@ -194,6 +195,9 @@ > int bar_fidx = 0; > XFontStruct *bar_fs; > char *bar_fonts[] = { NULL, NULL, NULL }; /* XXX Make fully dynamic */ >+XftDraw *xftdraw; >+XftFont *bar_xft_fs; >+int xft_loaded = 0; > char *spawn_term[] = { NULL, NULL }; /* XXX Make fully dynamic */ > > #define SWM_MENU_FN (2) >@@ -534,10 +538,32 @@ > void > bar_print(struct swm_region *r, char *s) > { >+ int scr, len; >+ XGlyphInfo ext; >+ XftColor col; >+ > XClearWindow(display, r->bar_window); > XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color); >- XDrawString(display, r->bar_window, bar_gc, 4, bar_fs->ascent, s, >- strlen(s)); >+ if (xft_loaded) { >+ scr = DefaultScreen(display); >+ XftColorAllocName(display, >+ DefaultVisual(display, scr), >+ DefaultColormap(display, scr), >+ r->s->c[SWM_S_COLOR_BAR_FONT].name, >+ &col); >+ xftdraw = XftDrawCreate(display, >+ r->bar_window, >+ DefaultVisual(display, scr), >+ DefaultColormap(display, scr)); >+ XftTextExtents8 (display, >+ bar_xft_fs, s, strlen(s), &ext); >+ XftDrawString8(xftdraw, &col, bar_xft_fs, 4, bar_xft_fs->ascent, s, >+ strlen(s)); >+ } >+ else { >+ XDrawString(display, r->bar_window, bar_gc, 4, bar_fs->ascent, s, >+ strlen(s)); >+ } > } > > void >@@ -707,32 +733,82 @@ > bar_update(); > } > >+/* Help function for bar_setup. >+ * It takes a string which defines a font in input and: >+ * if the string is an xft_font, then sets the second char pointer to >+ * the stripped string, else it just returns 0 >+ * it accepts 2 kind of strings: >+ * "xft:xftfontname" >+ * "-*-*-etcetc" >+ */ >+int >+isxft(char *font, char *xft_result) >+{ >+ int i,j; >+ char* c; >+ >+ if (font[0] != 'x') { >+ DNPRINTF(SWM_D_MISC, "non xft-font: %s\n", font); >+ return 0; >+ } >+ else { >+ for (i=0,j=4; font[j]!='\0'; i++,j++) { >+ xft_result[i] = font[j]; >+ } >+ } >+ DNPRINTF(SWM_D_MISC, "xft-font loaded: %s\n", xft_result); >+ return 1; >+} >+ >+/* This is a bit tricky: first of all we try to load an Xft font, >+ * if for any reason (wrong font-name, or something else) the font >+ * cannot be loaded, then it tries to load the same fonts array but >+ * using the X Core Fonts method >+ */ > void > bar_setup(struct swm_region *r) > { > int i; >+ int scr = DefaultScreen(display); >+ char xftfont[64]; > > for (i = 0; bar_fonts[i] != NULL; i++) { >- bar_fs = XLoadQueryFont(display, bar_fonts[i]); >- if (bar_fs) { >+ if (isxft(bar_fonts[i], xftfont)) { >+ bar_xft_fs = XftFontOpenName(display, >+ scr, xftfont); >+ xft_loaded = 1; >+ } >+ else { >+ bar_fs = XLoadQueryFont(display, bar_fonts[i]); >+ xft_loaded = 0; >+ } >+ if (bar_fs || bar_xft_fs) { > bar_fidx = i; > break; > } > } > if (bar_fonts[i] == NULL) > errx(1, "couldn't load font"); >- bar_height = bar_fs->ascent + bar_fs->descent + 3; >+ DNPRINTF(SWM_D_MISC, "Font Loaded: %d %s\n", xft_loaded, bar_fonts[i]); >+ if (!xft_loaded) >+ bar_height = bar_fs->ascent + bar_fs->descent + 3; >+ else >+ bar_height = bar_xft_fs->ascent + bar_xft_fs->descent + 3; > > r->bar_window = XCreateSimpleWindow(display, > r->s->root, X(r), Y(r), WIDTH(r) - 2, bar_height - 2, > 1, r->s->c[SWM_S_COLOR_BAR_BORDER].color, > r->s->c[SWM_S_COLOR_BAR].color); > bar_gc = XCreateGC(display, r->bar_window, 0, &bar_gcv); >- XSetFont(display, bar_gc, bar_fs->fid); >+ if (!xft_loaded) >+ XSetFont(display, bar_gc, bar_fs->fid); > XSelectInput(display, r->bar_window, VisibilityChangeMask); > if (bar_enabled) > XMapRaised(display, r->bar_window); >- DNPRINTF(SWM_D_MISC, "bar_setup: bar_window %lu\n", r->bar_window); >+ if (xft_loaded) >+ xftdraw = XftDrawCreate(display, >+ r->bar_window, DefaultVisual(display, scr), >+ DefaultColormap(display, scr)); > > if (signal(SIGALRM, bar_signal) == SIG_ERR) > err(1, "could not install bar_signal");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 284350
:
203634
|
203636
|
203637
|
203639
|
203640
|
203947
|
203948
|
203950
|
203952
|
204100
|
204102
|
204103
|
204105
|
204107
|
206282
|
206283
|
206319
|
206408
|
206410
|
206518
|
206520
|
206731
|
206967
|
206969
|
206970
|
206974
|
207019
|
210444
|
224619
|
224639
|
224641
|
224651
|
224655
|
253387