diff options
| author | Christoph Lohmann <20h@r-36.net> | 2013-02-23 21:44:06 +0100 |
|---|---|---|
| committer | Christoph Lohmann <20h@r-36.net> | 2013-02-23 21:44:06 +0100 |
| commit | e40d8da194cb02b400b09d2c8642f701c5c16821 (patch) | |
| tree | 135f19a2c0cb35b25d275dfc6e50b69d82d73d5b | |
| parent | efaf1c2a94ed9193c04c3a67f374d31f988b0e9a (diff) | |
| download | st-e40d8da194cb02b400b09d2c8642f701c5c16821.tar.gz st-e40d8da194cb02b400b09d2c8642f701c5c16821.zip | |
Removing dbe and introducing umlauts to titles.
Thanks Alexander Sedov <alex0player@gmail.com> for the title patch!
| -rw-r--r-- | st.c | 92 |
1 files changed, 39 insertions, 53 deletions
| @@ -25,7 +25,6 @@ | |||
| 25 | #include <X11/Xutil.h> | 25 | #include <X11/Xutil.h> |
| 26 | #include <X11/cursorfont.h> | 26 | #include <X11/cursorfont.h> |
| 27 | #include <X11/keysym.h> | 27 | #include <X11/keysym.h> |
| 28 | #include <X11/extensions/Xdbe.h> | ||
| 29 | #include <X11/Xft/Xft.h> | 28 | #include <X11/Xft/Xft.h> |
| 30 | #include <fontconfig/fontconfig.h> | 29 | #include <fontconfig/fontconfig.h> |
| 31 | 30 | ||
| @@ -351,6 +350,7 @@ static void xloadcols(void); | |||
| 351 | static int xsetcolorname(int, const char *); | 350 | static int xsetcolorname(int, const char *); |
| 352 | static int xloadfont(Font *, FcPattern *); | 351 | static int xloadfont(Font *, FcPattern *); |
| 353 | static void xloadfonts(char *, int); | 352 | static void xloadfonts(char *, int); |
| 353 | static void xsettitle(char *); | ||
| 354 | static void xresettitle(void); | 354 | static void xresettitle(void); |
| 355 | static void xseturgency(int); | 355 | static void xseturgency(int); |
| 356 | static void xsetsel(char*); | 356 | static void xsetsel(char*); |
| @@ -423,8 +423,6 @@ static char *opt_embed = NULL; | |||
| 423 | static char *opt_class = NULL; | 423 | static char *opt_class = NULL; |
| 424 | static char *opt_font = NULL; | 424 | static char *opt_font = NULL; |
| 425 | 425 | ||
| 426 | bool usedbe = False; | ||
| 427 | |||
| 428 | static char *usedfont = NULL; | 426 | static char *usedfont = NULL; |
| 429 | static int usedfontsize = 0; | 427 | static int usedfontsize = 0; |
| 430 | 428 | ||
| @@ -1862,7 +1860,6 @@ void | |||
| 1862 | strhandle(void) { | 1860 | strhandle(void) { |
| 1863 | char *p = NULL; | 1861 | char *p = NULL; |
| 1864 | int i, j, narg; | 1862 | int i, j, narg; |
| 1865 | XTextProperty prop; | ||
| 1866 | 1863 | ||
| 1867 | strparse(); | 1864 | strparse(); |
| 1868 | narg = strescseq.narg; | 1865 | narg = strescseq.narg; |
| @@ -1873,12 +1870,8 @@ strhandle(void) { | |||
| 1873 | case 0: | 1870 | case 0: |
| 1874 | case 1: | 1871 | case 1: |
| 1875 | case 2: | 1872 | case 2: |
| 1876 | if(narg > 1) { | 1873 | if(narg > 1) |
| 1877 | p += 2; | 1874 | xsettitle(strescseq.args[1]); |
| 1878 | Xutf8TextListToTextProperty(xw.dpy, &p, 1, | ||
| 1879 | XUTF8StringStyle, &prop); | ||
| 1880 | XSetWMName(xw.dpy, xw.win, &prop); | ||
| 1881 | } | ||
| 1882 | break; | 1875 | break; |
| 1883 | case 4: /* color set */ | 1876 | case 4: /* color set */ |
| 1884 | if(narg < 3) | 1877 | if(narg < 3) |
| @@ -1890,7 +1883,11 @@ strhandle(void) { | |||
| 1890 | if (!xsetcolorname(j, p)) { | 1883 | if (!xsetcolorname(j, p)) { |
| 1891 | fprintf(stderr, "erresc: invalid color %s\n", p); | 1884 | fprintf(stderr, "erresc: invalid color %s\n", p); |
| 1892 | } else { | 1885 | } else { |
| 1893 | redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ | 1886 | /* |
| 1887 | * TODO if defaultbg color is changed, borders | ||
| 1888 | * are dirty | ||
| 1889 | */ | ||
| 1890 | redraw(0); | ||
| 1894 | } | 1891 | } |
| 1895 | break; | 1892 | break; |
| 1896 | default: | 1893 | default: |
| @@ -1900,10 +1897,7 @@ strhandle(void) { | |||
| 1900 | } | 1897 | } |
| 1901 | break; | 1898 | break; |
| 1902 | case 'k': /* old title set compatibility */ | 1899 | case 'k': /* old title set compatibility */ |
| 1903 | p += 1; | 1900 | xsettitle(strescseq.args[0]); |
| 1904 | Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, | ||
| 1905 | &prop); | ||
| 1906 | XSetWMName(xw.dpy, xw.win, &prop); | ||
| 1907 | break; | 1901 | break; |
| 1908 | case 'P': /* DSC -- Device Control String */ | 1902 | case 'P': /* DSC -- Device Control String */ |
| 1909 | case '_': /* APC -- Application Program Command */ | 1903 | case '_': /* APC -- Application Program Command */ |
| @@ -2338,13 +2332,11 @@ xresize(int col, int row) { | |||
| 2338 | xw.tw = MAX(1, col * xw.cw); | 2332 | xw.tw = MAX(1, col * xw.cw); |
| 2339 | xw.th = MAX(1, row * xw.ch); | 2333 | xw.th = MAX(1, row * xw.ch); |
| 2340 | 2334 | ||
| 2341 | if(!usedbe) { | 2335 | XFreePixmap(xw.dpy, xw.buf); |
| 2342 | XFreePixmap(xw.dpy, xw.buf); | 2336 | xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, |
| 2343 | xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, | 2337 | DefaultDepth(xw.dpy, xw.scr)); |
| 2344 | DefaultDepth(xw.dpy, xw.scr)); | 2338 | XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); |
| 2345 | XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); | 2339 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); |
| 2346 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); | ||
| 2347 | } | ||
| 2348 | 2340 | ||
| 2349 | XftDrawChange(xw.draw, xw.buf); | 2341 | XftDrawChange(xw.draw, xw.buf); |
| 2350 | } | 2342 | } |
| @@ -2606,7 +2598,7 @@ xinit(void) { | |||
| 2606 | XGCValues gcvalues; | 2598 | XGCValues gcvalues; |
| 2607 | Cursor cursor; | 2599 | Cursor cursor; |
| 2608 | Window parent; | 2600 | Window parent; |
| 2609 | int sw, sh, major, minor; | 2601 | int sw, sh; |
| 2610 | 2602 | ||
| 2611 | if(!(xw.dpy = XOpenDisplay(NULL))) | 2603 | if(!(xw.dpy = XOpenDisplay(NULL))) |
| 2612 | die("Can't open display\n"); | 2604 | die("Can't open display\n"); |
| @@ -2661,26 +2653,14 @@ xinit(void) { | |||
| 2661 | | CWColormap, | 2653 | | CWColormap, |
| 2662 | &attrs); | 2654 | &attrs); |
| 2663 | 2655 | ||
| 2664 | /* double buffering */ | 2656 | memset(&gcvalues, 0, sizeof(gcvalues)); |
| 2665 | /* | 2657 | gcvalues.graphics_exposures = False; |
| 2666 | if(XdbeQueryExtension(xw.dpy, &major, &minor)) { | 2658 | dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, |
| 2667 | xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, | 2659 | &gcvalues); |
| 2668 | XdbeBackground); | 2660 | xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, |
| 2669 | usedbe = True; | 2661 | DefaultDepth(xw.dpy, xw.scr)); |
| 2670 | } else { | 2662 | XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); |
| 2671 | */ | 2663 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); |
| 2672 | memset(&gcvalues, 0, sizeof(gcvalues)); | ||
| 2673 | gcvalues.graphics_exposures = False; | ||
| 2674 | dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, | ||
| 2675 | &gcvalues); | ||
| 2676 | xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, | ||
| 2677 | DefaultDepth(xw.dpy, xw.scr)); | ||
| 2678 | XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); | ||
| 2679 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); | ||
| 2680 | //xw.buf = xw.win; | ||
| 2681 | /* | ||
| 2682 | } | ||
| 2683 | */ | ||
| 2684 | 2664 | ||
| 2685 | /* Xft rendering context */ | 2665 | /* Xft rendering context */ |
| 2686 | xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); | 2666 | xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); |
| @@ -2971,9 +2951,19 @@ xdrawcursor(void) { | |||
| 2971 | } | 2951 | } |
| 2972 | } | 2952 | } |
| 2973 | 2953 | ||
| 2954 | |||
| 2955 | void | ||
| 2956 | xsettitle(char *p) { | ||
| 2957 | XTextProperty prop; | ||
| 2958 | |||
| 2959 | Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, | ||
| 2960 | &prop); | ||
| 2961 | XSetWMName(xw.dpy, xw.win, &prop); | ||
| 2962 | } | ||
| 2963 | |||
| 2974 | void | 2964 | void |
| 2975 | xresettitle(void) { | 2965 | xresettitle(void) { |
| 2976 | XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st"); | 2966 | xsettitle(opt_title ? opt_title : "st"); |
| 2977 | } | 2967 | } |
| 2978 | 2968 | ||
| 2979 | void | 2969 | void |
| @@ -2991,16 +2981,12 @@ redraw(int timeout) { | |||
| 2991 | 2981 | ||
| 2992 | void | 2982 | void |
| 2993 | draw(void) { | 2983 | draw(void) { |
| 2994 | XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}}; | ||
| 2995 | |||
| 2996 | drawregion(0, 0, term.col, term.row); | 2984 | drawregion(0, 0, term.col, term.row); |
| 2997 | if(usedbe) { | 2985 | XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w, |
| 2998 | XdbeSwapBuffers(xw.dpy, swpinfo, 1); | 2986 | xw.h, 0, 0); |
| 2999 | } else { | 2987 | XSetForeground(xw.dpy, dc.gc, |
| 3000 | XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w, | 2988 | dc.col[IS_SET(MODE_REVERSE)? |
| 3001 | xw.h, 0, 0); | 2989 | defaultfg : defaultbg].pixel); |
| 3002 | XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); | ||
| 3003 | } | ||
| 3004 | } | 2990 | } |
| 3005 | 2991 | ||
| 3006 | void | 2992 | void |
