cvsimport

This commit is contained in:
Christian Neukirchen
2013-05-29 22:37:37 +02:00
14 changed files with 486 additions and 516 deletions

View File

@@ -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: