From 2741bb71de1a1bc75d243234ccce80121df5fe98 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Wed, 22 Apr 2009 03:04:41 +0200 Subject: [PATCH] Wmfs: Replace statustext[] -> *statustext and improve clientmessageevent(). --- src/event.c | 26 ++++++++------------------ src/infobar.c | 2 +- src/wmfs.h | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/event.c b/src/event.c index 95d1274..44582b7 100644 --- a/src/event.c +++ b/src/event.c @@ -146,6 +146,9 @@ clientmessageevent(XClientMessageEvent *ev) Atom rt; int rf; ulong ir, il; + uchar *ret = NULL; + uchar *ret_cmd = NULL; + void (*func)(uicb_t); if(ev->format != 32) return; @@ -192,15 +195,10 @@ clientmessageevent(XClientMessageEvent *ev) /* Manage _WMFS_STATUSTEXT */ if(mess_t == wmfs_statustext && ev->data.l[4] == True) { - uchar *ret; - if(XGetWindowProperty(dpy, ROOT, net_atom[wmfs_statustext], 0, 4096, False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret) == Success) { - for(i = 0; i < LEN(statustext); ++i) - statustext[i] = 0; - - strcpy(statustext, (char*)ret); + statustext = _strdup((char*)ret); for(i = 0; i < screen_count(); ++i) infobar_draw(i); @@ -213,25 +211,17 @@ clientmessageevent(XClientMessageEvent *ev) if((mess_t == wmfs_function && ev->data.l[4] == True) || (mess_t == wmfs_cmd && ev->data.l[4] == True)) { - uchar *ret_func = NULL; - uchar *ret_cmd = NULL; - XGetWindowProperty(dpy, ROOT, net_atom[wmfs_function], 0, 4096, - False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret_func); + False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret); XGetWindowProperty(dpy, ROOT, net_atom[wmfs_cmd], 0, 4096, False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret_cmd); - void (*func)(uicb_t) = name_to_func((char*)ret_func, func_list); - - if(func) + if((func = name_to_func((char*)ret, func_list))) func((uicb_t)ret_cmd); - if(ret_cmd) - XFree(ret_cmd); - - if(ret_func) - XFree(ret_func); + XFree(ret_cmd); + XFree(ret); } diff --git a/src/infobar.c b/src/infobar.c index f783959..3f0398c 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -96,7 +96,7 @@ infobar_init(void) barwin_refresh(infobar[sc].bar); /* Default statustext is set here */ - strcpy(statustext, "WMFS-" WMFS_VERSION); + statustext = _strdup("WMFS-" WMFS_VERSION); infobar_draw(sc); } diff --git a/src/wmfs.h b/src/wmfs.h index 9daa018..6785ec8 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -313,7 +313,7 @@ int selscreen; Conf conf; Key *keys; Bool exiting; -char statustext[1024]; +char *statustext; XRectangle *sgeo; XRectangle *spgeo; Cursor cursor[CurLast];