xft text, time
parent
f656e7712d
commit
c2cc5b34cf
9
slock.c
9
slock.c
|
|
@ -106,7 +106,6 @@ writemessage(Display *dpy, struct lock *lock)
|
|||
time_t currenttime;
|
||||
struct tm *ltime;
|
||||
int screen = lock->screen;
|
||||
Window win = lock->win;
|
||||
|
||||
char str[256] = {0};
|
||||
|
||||
|
|
@ -114,8 +113,6 @@ writemessage(Display *dpy, struct lock *lock)
|
|||
* Time text
|
||||
*/
|
||||
|
||||
XftDraw* draw = XftDrawCreate(dpy, win, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
|
||||
|
||||
time(¤ttime);
|
||||
ltime = localtime(¤ttime);
|
||||
snprintf(str, sizeof(str), "%02d:%02d", ltime->tm_hour, ltime->tm_min);
|
||||
|
|
@ -126,7 +123,7 @@ writemessage(Display *dpy, struct lock *lock)
|
|||
timex = (DisplayWidth(dpy, screen) - ext.width) / 2;
|
||||
timey = (DisplayHeight(dpy, screen) - ext.height) / 2;
|
||||
|
||||
XftDrawString8(draw, &lock->font_colors[TIME], lock->fonts[TIME], timex, timey, (XftChar8*)str, timelen);
|
||||
XftDrawString8(lock->draw, &lock->font_colors[TIME], lock->fonts[TIME], timex, timey, (XftChar8*)str, timelen);
|
||||
|
||||
/*
|
||||
* Message text
|
||||
|
|
@ -138,7 +135,7 @@ writemessage(Display *dpy, struct lock *lock)
|
|||
x = (DisplayWidth(dpy, screen) - ext.width) / 2;
|
||||
y = (DisplayHeight(dpy, screen) - ext.height) / 8 * 7;
|
||||
|
||||
XftDrawString8(draw, &lock->font_colors[TEXT], lock->fonts[TEXT], x, y, (XftChar8*)message, len);
|
||||
XftDrawString8(lock->draw, &lock->font_colors[TEXT], lock->fonts[TEXT], x, y, (XftChar8*)message, len);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -337,6 +334,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
|||
XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), text_color, &lock->font_colors[TEXT]);
|
||||
XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), time_color, &lock->font_colors[TIME]);
|
||||
|
||||
lock->draw = XftDrawCreate(dpy, lock->win, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
|
||||
|
||||
/* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */
|
||||
for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) {
|
||||
if (ptgrab != GrabSuccess) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue