Add draw.h, basic draw function (text)

This commit is contained in:
Martin Duquesnoy 2011-08-25 21:57:52 +02:00
parent 05aafde11a
commit 4fc5f0a9c2
4 changed files with 39 additions and 4 deletions

34
wmfs2/src/draw.h Executable file
View File

@ -0,0 +1,34 @@
/*
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
* For license, see COPYING.
*/
#ifndef DRAW_H
#define DRAW_H
#include <string.h>
#include <X11/Xlib.h>
#include "wmfs.h"
#define TEXTY(w) ((W->font.height - W->font.de) + ((w - W->font.height) >> 1))
static inline void
draw_text(Drawable d, int x, int y, Color fg, const char *str)
{
XSetForeground(W->dpy, W->gc, fg);
XmbDrawString(W->dpy, d, W->font.fontset, W->gc, x, y, str, strlen(str));
}
static inline unsigned short
draw_textw(const char *str)
{
XRectangle r;
XmbTextExtents(W->font.fontset, str, strlen(str), NULL, &r);
return r.width;
}
#endif /* DRAW_H */

View File

@ -4,6 +4,7 @@
*/ */
#include "event.h" #include "event.h"
#include "ewmh.h"
#include "util.h" #include "util.h"
#include "wmfs.h" #include "wmfs.h"
#include "client.h" #include "client.h"
@ -149,7 +150,7 @@ event_propertynotify(XEvent *e)
*/ */
break; break;
default: default:
if(ev->atom == XA_WM_NAME /* || ev->atom == _NET_WM_NAME */) if(ev->atom == XA_WM_NAME || ev->atom == W->net_atom[net_wm_name])
client_get_name(c); client_get_name(c);
break; break;
} }

View File

@ -4,6 +4,7 @@
*/ */
#include "wmfs.h" #include "wmfs.h"
#include "draw.h"
#include "infobar.h" #include "infobar.h"
#include "barwin.h" #include "barwin.h"
#include "util.h" #include "util.h"
@ -49,6 +50,8 @@ infobar_init(void)
void void
infobar_refresh(Infobar *i) infobar_refresh(Infobar *i)
{ {
draw_text(i->bar->dr, 1, TEXTY(INFOBAR_DEF_W), 0x005500, "WMFS2");
barwin_refresh(i->bar); barwin_refresh(i->bar);
} }

View File

@ -73,9 +73,6 @@ screen_init(void)
s = screen_new(&g, 0); s = screen_new(&g, 0);
tag_screen(s, tag_new(s, "tag")); tag_screen(s, tag_new(s, "tag"));
} }
SLIST_FOREACH(s, &W->h.screen, next)
printf("%d: %d %d %d %d\n", s->id, s->geo.x, s->geo.y, s->geo.w, s->geo.h);
} }
void void