Removing dbe and introducing umlauts to titles.

Thanks Alexander Sedov <alex0player@gmail.com> for the title patch!
This commit is contained in:
Christoph Lohmann 2013-02-23 21:44:06 +01:00
parent efaf1c2a94
commit e40d8da194

92
st.c
View file

@ -25,7 +25,6 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/extensions/Xdbe.h>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include <fontconfig/fontconfig.h> #include <fontconfig/fontconfig.h>
@ -351,6 +350,7 @@ static void xloadcols(void);
static int xsetcolorname(int, const char *); static int xsetcolorname(int, const char *);
static int xloadfont(Font *, FcPattern *); static int xloadfont(Font *, FcPattern *);
static void xloadfonts(char *, int); static void xloadfonts(char *, int);
static void xsettitle(char *);
static void xresettitle(void); static void xresettitle(void);
static void xseturgency(int); static void xseturgency(int);
static void xsetsel(char*); static void xsetsel(char*);
@ -423,8 +423,6 @@ static char *opt_embed = NULL;
static char *opt_class = NULL; static char *opt_class = NULL;
static char *opt_font = NULL; static char *opt_font = NULL;
bool usedbe = False;
static char *usedfont = NULL; static char *usedfont = NULL;
static int usedfontsize = 0; static int usedfontsize = 0;
@ -1862,7 +1860,6 @@ void
strhandle(void) { strhandle(void) {
char *p = NULL; char *p = NULL;
int i, j, narg; int i, j, narg;
XTextProperty prop;
strparse(); strparse();
narg = strescseq.narg; narg = strescseq.narg;
@ -1873,12 +1870,8 @@ strhandle(void) {
case 0: case 0:
case 1: case 1:
case 2: case 2:
if(narg > 1) { if(narg > 1)
p += 2; xsettitle(strescseq.args[1]);
Xutf8TextListToTextProperty(xw.dpy, &p, 1,
XUTF8StringStyle, &prop);
XSetWMName(xw.dpy, xw.win, &prop);
}
break; break;
case 4: /* color set */ case 4: /* color set */
if(narg < 3) if(narg < 3)
@ -1890,7 +1883,11 @@ strhandle(void) {
if (!xsetcolorname(j, p)) { if (!xsetcolorname(j, p)) {
fprintf(stderr, "erresc: invalid color %s\n", p); fprintf(stderr, "erresc: invalid color %s\n", p);
} else { } else {
redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ /*
* TODO if defaultbg color is changed, borders
* are dirty
*/
redraw(0);
} }
break; break;
default: default:
@ -1900,10 +1897,7 @@ strhandle(void) {
} }
break; break;
case 'k': /* old title set compatibility */ case 'k': /* old title set compatibility */
p += 1; xsettitle(strescseq.args[0]);
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop);
XSetWMName(xw.dpy, xw.win, &prop);
break; break;
case 'P': /* DSC -- Device Control String */ case 'P': /* DSC -- Device Control String */
case '_': /* APC -- Application Program Command */ case '_': /* APC -- Application Program Command */
@ -2338,13 +2332,11 @@ xresize(int col, int row) {
xw.tw = MAX(1, col * xw.cw); xw.tw = MAX(1, col * xw.cw);
xw.th = MAX(1, row * xw.ch); xw.th = MAX(1, row * xw.ch);
if(!usedbe) { XFreePixmap(xw.dpy, xw.buf);
XFreePixmap(xw.dpy, xw.buf); xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, DefaultDepth(xw.dpy, xw.scr));
DefaultDepth(xw.dpy, xw.scr)); XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel);
XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
}
XftDrawChange(xw.draw, xw.buf); XftDrawChange(xw.draw, xw.buf);
} }
@ -2606,7 +2598,7 @@ xinit(void) {
XGCValues gcvalues; XGCValues gcvalues;
Cursor cursor; Cursor cursor;
Window parent; Window parent;
int sw, sh, major, minor; int sw, sh;
if(!(xw.dpy = XOpenDisplay(NULL))) if(!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n"); die("Can't open display\n");
@ -2661,26 +2653,14 @@ xinit(void) {
| CWColormap, | CWColormap,
&attrs); &attrs);
/* double buffering */ memset(&gcvalues, 0, sizeof(gcvalues));
/* gcvalues.graphics_exposures = False;
if(XdbeQueryExtension(xw.dpy, &major, &minor)) { dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, &gcvalues);
XdbeBackground); xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
usedbe = True; DefaultDepth(xw.dpy, xw.scr));
} else { XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
*/ XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
memset(&gcvalues, 0, sizeof(gcvalues));
gcvalues.graphics_exposures = False;
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
&gcvalues);
xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
DefaultDepth(xw.dpy, xw.scr));
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
//xw.buf = xw.win;
/*
}
*/
/* Xft rendering context */ /* Xft rendering context */
xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
@ -2971,9 +2951,19 @@ xdrawcursor(void) {
} }
} }
void
xsettitle(char *p) {
XTextProperty prop;
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop);
XSetWMName(xw.dpy, xw.win, &prop);
}
void void
xresettitle(void) { xresettitle(void) {
XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st"); xsettitle(opt_title ? opt_title : "st");
} }
void void
@ -2991,16 +2981,12 @@ redraw(int timeout) {
void void
draw(void) { draw(void) {
XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}};
drawregion(0, 0, term.col, term.row); drawregion(0, 0, term.col, term.row);
if(usedbe) { XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w,
XdbeSwapBuffers(xw.dpy, swpinfo, 1); xw.h, 0, 0);
} else { XSetForeground(xw.dpy, dc.gc,
XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w, dc.col[IS_SET(MODE_REVERSE)?
xw.h, 0, 0); defaultfg : defaultbg].pixel);
XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel);
}
} }
void void