aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client.c7
-rw-r--r--mousefunc.c55
2 files changed, 26 insertions, 36 deletions
diff --git a/client.c b/client.c
index f7ed30f..1c80e1c 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: client.c,v 1.51 2009/05/30 00:30:17 okan Exp $
+ * $Id: client.c,v 1.52 2009/06/17 12:45:01 okan Exp $
*/
#include "headers.h"
@@ -66,11 +66,6 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
cc->size = XAllocSizeHints();
XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
- if (cc->size->width_inc == 0)
- cc->size->width_inc = 1;
- if (cc->size->height_inc == 0)
- cc->size->height_inc = 1;
-
if (cc->size->flags & PBaseSize) {
cc->geom.min_dx = cc->size->base_width;
cc->geom.min_dy = cc->size->base_height;
diff --git a/mousefunc.c b/mousefunc.c
index 2f0a3dd..7653769 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -16,17 +16,14 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: mousefunc.c,v 1.9 2009/05/18 00:23:35 okan Exp $
+ * $Id: mousefunc.c,v 1.10 2009/06/17 12:45:01 okan Exp $
*/
#include "headers.h"
#include "calmwm.h"
static int mousefunc_sweep_calc(struct client_ctx *, int, int, int, int);
-static void mousefunc_sweep_draw(struct client_ctx *, int, int);
-
-#define ADJUST_HEIGHT(cc, dy) ((cc->geom.height - cc->geom.min_dy) / dy)
-#define ADJUST_WIDTH(cc, dx) ((cc->geom.width - cc->geom.min_dx) / dx)
+static void mousefunc_sweep_draw(struct client_ctx *);
static int
mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
@@ -60,28 +57,29 @@ mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
}
static void
-mousefunc_sweep_draw(struct client_ctx *cc, int dx, int dy)
+mousefunc_sweep_draw(struct client_ctx *cc)
{
struct screen_ctx *sc = CCTOSC(cc);
char asize[10]; /* fits "nnnnxnnnn\0" */
- int wide, height, wide_size, wide_name;
- int x = cc->geom.x, y = cc->geom.y;
+ int width, height, width_size, width_name;
snprintf(asize, sizeof(asize), "%dx%d",
- ADJUST_WIDTH(cc, dx), ADJUST_HEIGHT(cc, dy));
- wide_size = font_width(asize, strlen(asize)) + 4;
- wide_name = font_width(cc->name, strlen(cc->name)) + 4;
- wide = MAX(wide_size, wide_name);
+ (cc->geom.width - cc->geom.min_dx) / cc->size->width_inc,
+ (cc->geom.height - cc->geom.min_dy) / cc->size->height_inc);
+ width_size = font_width(asize, strlen(asize)) + 4;
+ width_name = font_width(cc->name, strlen(cc->name)) + 4;
+ width = MAX(width_size, width_name);
height = font_ascent() + font_descent() + 1;
- XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, wide, height * 2);
+ XMoveResizeWindow(X_Dpy, sc->menuwin, cc->geom.x, cc->geom.y,
+ width, height * 2);
XMapWindow(X_Dpy, sc->menuwin);
XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
XClearWindow(X_Dpy, sc->menuwin);
font_draw(sc, cc->name, strlen(cc->name), sc->menuwin,
2, font_ascent() + 1);
font_draw(sc, asize, strlen(asize), sc->menuwin,
- wide / 2 - wide_size / 2, height + font_ascent() + 1);
+ width / 2 - width_size / 2, height + font_ascent() + 1);
}
void
@@ -90,20 +88,19 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
XEvent ev;
Time time = 0;
struct screen_ctx *sc = CCTOSC(cc);
- int dx, dy;
int x = cc->geom.x, y = cc->geom.y;
- dx = MAX(1, cc->size->width_inc);
- dy = MAX(1, cc->size->height_inc);
+ cc->size->width_inc = MAX(1, cc->size->width_inc);
+ cc->size->height_inc = MAX(1, cc->size->height_inc);
client_raise(cc);
client_ptrsave(cc);
- if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0)
+ if (xu_ptr_grab(cc->win, MouseMask, Cursor_resize) < 0)
return;
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
- mousefunc_sweep_draw(cc, dx, dy);
+ mousefunc_sweep_draw(cc);
for (;;) {
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
@@ -114,12 +111,12 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
break;
case MotionNotify:
if (mousefunc_sweep_calc(cc, x, y,
- ev.xmotion.x, ev.xmotion.y))
+ ev.xmotion.x_root, ev.xmotion.y_root))
/* Recompute window output */
- mousefunc_sweep_draw(cc, dx, dy);
+ mousefunc_sweep_draw(cc);
/* don't sync more than 60 times / second */
- if ((ev.xmotion.time - time) > (1000 / 60) ) {
+ if ((ev.xmotion.time - time) > (1000 / 60)) {
time = ev.xmotion.time;
XSync(X_Dpy, False);
client_resize(cc);
@@ -152,16 +149,14 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
{
XEvent ev;
Time time = 0;
- struct screen_ctx *sc = CCTOSC(cc);
- int mx, my;
- int x = cc->geom.x, y = cc->geom.y;
+ int px, py;
client_raise(cc);
- if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0)
+ if (xu_ptr_grab(cc->win, MouseMask, Cursor_move) < 0)
return;
- xu_ptr_getpos(sc->rootwin, &mx, &my);
+ xu_ptr_getpos(cc->win, &px, &py);
for (;;) {
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
@@ -171,11 +166,11 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
client_draw_border(cc);
break;
case MotionNotify:
- cc->geom.x = x + (ev.xmotion.x - mx);
- cc->geom.y = y + (ev.xmotion.y - my);
+ cc->geom.x = ev.xmotion.x_root - px;
+ cc->geom.y = ev.xmotion.y_root - py;
/* don't sync more than 60 times / second */
- if ((ev.xmotion.time - time) > (1000 / 60) ) {
+ if ((ev.xmotion.time - time) > (1000 / 60)) {
time = ev.xmotion.time;
XSync(X_Dpy, False);
client_move(cc);