From 4fc5f0a9c23e9d342cd7f9828fa0d0d02b850ef3 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Thu, 25 Aug 2011 21:57:52 +0200 Subject: [PATCH] Add draw.h, basic draw function (text) --- wmfs2/src/draw.h | 34 ++++++++++++++++++++++++++++++++++ wmfs2/src/event.c | 3 ++- wmfs2/src/infobar.c | 3 +++ wmfs2/src/screen.c | 3 --- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 wmfs2/src/draw.h diff --git a/wmfs2/src/draw.h b/wmfs2/src/draw.h new file mode 100755 index 0000000..2258dd5 --- /dev/null +++ b/wmfs2/src/draw.h @@ -0,0 +1,34 @@ +/* + * wmfs2 by Martin Duquesnoy { for(i = 2011; i < 2111; ++i) ©(i); } + * For license, see COPYING. + */ + + +#ifndef DRAW_H +#define DRAW_H + +#include +#include + +#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 */ diff --git a/wmfs2/src/event.c b/wmfs2/src/event.c index 5fa5196..4820724 100755 --- a/wmfs2/src/event.c +++ b/wmfs2/src/event.c @@ -4,6 +4,7 @@ */ #include "event.h" +#include "ewmh.h" #include "util.h" #include "wmfs.h" #include "client.h" @@ -149,7 +150,7 @@ event_propertynotify(XEvent *e) */ break; 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); break; } diff --git a/wmfs2/src/infobar.c b/wmfs2/src/infobar.c index 2695f2d..30616ca 100755 --- a/wmfs2/src/infobar.c +++ b/wmfs2/src/infobar.c @@ -4,6 +4,7 @@ */ #include "wmfs.h" +#include "draw.h" #include "infobar.h" #include "barwin.h" #include "util.h" @@ -49,6 +50,8 @@ infobar_init(void) void infobar_refresh(Infobar *i) { + draw_text(i->bar->dr, 1, TEXTY(INFOBAR_DEF_W), 0x005500, "WMFS2"); + barwin_refresh(i->bar); } diff --git a/wmfs2/src/screen.c b/wmfs2/src/screen.c index 82f5c95..58e81e4 100755 --- a/wmfs2/src/screen.c +++ b/wmfs2/src/screen.c @@ -73,9 +73,6 @@ screen_init(void) s = screen_new(&g, 0); 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