aboutsummaryrefslogtreecommitdiffstats
path: root/menu.c
diff options
context:
space:
mode:
authorokan2016-09-30 15:12:19 +0000
committerokan2016-09-30 15:12:19 +0000
commit6683b9c99889c3bbc28f721777801aef4ba84bf9 (patch)
tree7a98784f1ec4f4fb8c51e38d1158900be138664c /menu.c
parent91a18250def9bac118f6198caf2b551ee606ce4d (diff)
downloadcwm-6683b9c99889c3bbc28f721777801aef4ba84bf9.tar.gz
Replace mousefunc_sweep_draw() with a generic menu_windraw() using va
lists; use it appropriately for both window dimension and position in the respective mousefunc calls. ok bryent@
Diffstat (limited to '')
-rw-r--r--menu.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index 94eb399..57d32d0 100644
--- a/menu.c
+++ b/menu.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: menu.c,v 1.94 2016/09/29 00:21:55 okan Exp $
+ * $OpenBSD: menu.c,v 1.95 2016/09/30 15:12:19 okan Exp $
*/
#include <sys/types.h>
@@ -638,3 +638,35 @@ menuq_clear(struct menu_q *mq)
free(mi);
}
}
+
+void
+menu_windraw(struct screen_ctx *sc, Window win, const char *fmt, ...)
+{
+ va_list ap;
+ int i;
+ char *text;
+ XGlyphInfo extents;
+
+ va_start(ap, fmt);
+ i = vasprintf(&text, fmt, ap);
+ va_end(ap);
+
+ if (i < 0 || text == NULL)
+ err(1, "vasprintf");
+
+ XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)text,
+ strlen(text), &extents);
+
+ XReparentWindow(X_Dpy, sc->menu.win, win, 0, 0);
+ XMoveResizeWindow(X_Dpy, sc->menu.win, 0, 0,
+ extents.xOff, sc->xftfont->height);
+ XMapWindow(X_Dpy, sc->menu.win);
+ XClearWindow(X_Dpy, sc->menu.win);
+
+ XftDrawStringUtf8(sc->menu.xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT],
+ sc->xftfont, 0, sc->xftfont->ascent + 1,
+ (const FcChar8*)text, strlen(text));
+
+ free(text);
+}
+