From e60b30011219665e9f4dafb49b6d728f2be09797 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 28 Dec 2007 17:37:41 +0100 Subject: [PATCH] optimize mwfact resizing with mouse --- mouse.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mouse.c b/mouse.c index 2f0cb2b9..9bb8df00 100644 --- a/mouse.c +++ b/mouse.c @@ -19,6 +19,8 @@ * */ +#include + #include "mouse.h" #include "screen.h" #include "layout.h" @@ -40,7 +42,7 @@ extern AwesomeConf globalconf; void uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) { - int x1, y1, ocx, ocy, di, nx, ny; + int x1, y, ocx, ocy, di, nx, ny; unsigned int dui; Window dummy; XEvent ev; @@ -72,7 +74,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) return; XQueryPointer(globalconf.display, RootWindow(globalconf.display, c->phys_screen), - &dummy, &dummy, &x1, &y1, &di, &di, &dui); + &dummy, &dummy, &x1, &y, &di, &di, &dui); c->ismax = False; statusbar_draw(c->screen); for(;;) @@ -94,7 +96,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) break; case MotionNotify: nx = ocx + (ev.xmotion.x - x1); - ny = ocy + (ev.xmotion.y - y1); + ny = ocy + (ev.xmotion.y - y); if(abs(nx) < globalconf.screens[screen].snap + area.x && nx > area.x) nx = area.x; else if(abs((area.x + area.width) - (nx + c->w + 2 * c->border)) < globalconf.screens[screen].snap) @@ -200,8 +202,13 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) mwfact = 1 - (double) (ev.xmotion.x - area.x) / area.width; if(mwfact < 0.1) mwfact = 0.1; else if(mwfact > 0.9) mwfact = 0.9; - curtags[0]->mwfact = mwfact; - arrange(screen); + if(fabs(curtags[0]->mwfact - mwfact) >= 0.05) + { + curtags[0]->mwfact = mwfact; + arrange(screen); + /* drop possibly arrived events while we where arrange()ing */ + while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev)); + } } break;