optimize mwfact resizing with mouse
This commit is contained in:
parent
6dde3eaf16
commit
e60b300112
13
mouse.c
13
mouse.c
|
@ -19,6 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
@ -40,7 +42,7 @@ extern AwesomeConf globalconf;
|
||||||
void
|
void
|
||||||
uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
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;
|
unsigned int dui;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
@ -72,7 +74,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
return;
|
return;
|
||||||
XQueryPointer(globalconf.display,
|
XQueryPointer(globalconf.display,
|
||||||
RootWindow(globalconf.display, c->phys_screen),
|
RootWindow(globalconf.display, c->phys_screen),
|
||||||
&dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
&dummy, &dummy, &x1, &y, &di, &di, &dui);
|
||||||
c->ismax = False;
|
c->ismax = False;
|
||||||
statusbar_draw(c->screen);
|
statusbar_draw(c->screen);
|
||||||
for(;;)
|
for(;;)
|
||||||
|
@ -94,7 +96,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
nx = ocx + (ev.xmotion.x - x1);
|
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)
|
if(abs(nx) < globalconf.screens[screen].snap + area.x && nx > 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)
|
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;
|
mwfact = 1 - (double) (ev.xmotion.x - area.x) / area.width;
|
||||||
if(mwfact < 0.1) mwfact = 0.1;
|
if(mwfact < 0.1) mwfact = 0.1;
|
||||||
else if(mwfact > 0.9) mwfact = 0.9;
|
else if(mwfact > 0.9) mwfact = 0.9;
|
||||||
|
if(fabs(curtags[0]->mwfact - mwfact) >= 0.05)
|
||||||
|
{
|
||||||
curtags[0]->mwfact = mwfact;
|
curtags[0]->mwfact = mwfact;
|
||||||
arrange(screen);
|
arrange(screen);
|
||||||
|
/* drop possibly arrived events while we where arrange()ing */
|
||||||
|
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue