about summary refs log tree commit diff
path: root/mousefunc.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2013-05-29 22:37:37 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2013-05-29 22:41:51 +0200
commit5515a365ba77cec3e7bf9797c3a4cc5e6c5c91ae (patch)
tree437f902828ef965474a0bcf9402f30bf937135cb /mousefunc.c
parent843f18aaee1550344b8521d95d952502e064c5f0 (diff)
parent692d341dfc6b059db570356e9dfadba92dc93f19 (diff)
downloadcwm-5515a365ba77cec3e7bf9797c3a4cc5e6c5c91ae.tar.gz
cwm-5515a365ba77cec3e7bf9797c3a4cc5e6c5c91ae.tar.xz
cwm-5515a365ba77cec3e7bf9797c3a4cc5e6c5c91ae.zip
cvsimport
Diffstat (limited to 'mousefunc.c')
-rw-r--r--mousefunc.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/mousefunc.c b/mousefunc.c
index dcf1073..9305633 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -31,14 +31,12 @@
 
 #include "calmwm.h"
 
-static int	mousefunc_sweep_calc(struct client_ctx *, int, int, int, int);
+static void	mousefunc_sweep_calc(struct client_ctx *, int, int, int, int);
 static void	mousefunc_sweep_draw(struct client_ctx *);
 
-static int
+static void
 mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
 {
-	int	 width = cc->geom.w, height = cc->geom.h;
-
 	cc->geom.w = abs(x - mx) - cc->bwidth;
 	cc->geom.h = abs(y - my) - cc->bwidth;
 
@@ -46,32 +44,27 @@ mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
 
 	cc->geom.x = x <= mx ? x : x - cc->geom.w;
 	cc->geom.y = y <= my ? y : y - cc->geom.h;
-
-	return (width != cc->geom.w || height != cc->geom.h);
 }
 
 static void
 mousefunc_sweep_draw(struct client_ctx *cc)
 {
 	struct screen_ctx	*sc = cc->sc;
-	char			 asize[10]; /* fits "nnnnxnnnn\0" */
-	int			 width, width_size, width_name;
+	char			 asize[14]; /* fits " nnnn x nnnn \0" */
 
-	(void)snprintf(asize, sizeof(asize), "%dx%d",
+	(void)snprintf(asize, sizeof(asize), " %4d x %-4d ",
 	    (cc->geom.w - cc->hint.basew) / cc->hint.incw,
 	    (cc->geom.h - cc->hint.baseh) / cc->hint.inch);
-	width_size = font_width(sc, asize, strlen(asize)) + 4;
-	width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
-	width = MAX(width_size, width_name);
 
 	XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
-	XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, width, font_height(sc) * 2);
+	XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0,
+	    xu_xft_width(sc->xftfont, asize, strlen(asize)),
+	    sc->xftfont->height);
 	XMapWindow(X_Dpy, sc->menuwin);
 	XClearWindow(X_Dpy, sc->menuwin);
-	font_draw(sc, cc->name, strlen(cc->name), sc->menuwin, 0,
-	    2, font_ascent(sc) + 1);
-	font_draw(sc, asize, strlen(asize), sc->menuwin, 0,
-	    width / 2 - width_size / 2, font_height(sc) + font_ascent(sc) + 1);
+
+	xu_xft_draw(sc, asize, CWM_COLOR_MENU_FONT,
+	    0, sc->xftfont->ascent + 1);
 }
 
 void
@@ -102,15 +95,14 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
 			client_draw_border(cc);
 			break;
 		case MotionNotify:
-			if (mousefunc_sweep_calc(cc, x, y,
-			    ev.xmotion.x_root, ev.xmotion.y_root))
-				/* Recompute window output */
-				mousefunc_sweep_draw(cc);
+			mousefunc_sweep_calc(cc, x, y,
+			    ev.xmotion.x_root, ev.xmotion.y_root);
 
 			/* don't resize more than 60 times / second */
 			if ((ev.xmotion.time - ltime) > (1000 / 60)) {
 				ltime = ev.xmotion.time;
 				client_resize(cc, 1);
+				mousefunc_sweep_draw(cc);
 			}
 			break;
 		case ButtonRelease: