mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
don't sync more than 60 times per sec on resize and move; idea from scrotwm.
ok oga@ sometime ago
This commit is contained in:
parent
ea96e92ac8
commit
cc68490fe1
26
mousefunc.c
26
mousefunc.c
@ -88,6 +88,7 @@ void
|
|||||||
mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
Time time = 0;
|
||||||
struct screen_ctx *sc = CCTOSC(cc);
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
int x = cc->geom.x, y = cc->geom.y;
|
int x = cc->geom.x, y = cc->geom.y;
|
||||||
@ -116,9 +117,19 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
|||||||
ev.xmotion.x, ev.xmotion.y))
|
ev.xmotion.x, ev.xmotion.y))
|
||||||
/* Recompute window output */
|
/* Recompute window output */
|
||||||
_mousefunc_sweep_draw(cc, dx, dy);
|
_mousefunc_sweep_draw(cc, dx, dy);
|
||||||
client_resize(cc);
|
|
||||||
|
/* don't sync more than 60 times / second */
|
||||||
|
if ((ev.xmotion.time - time) > (1000 / 60) ) {
|
||||||
|
time = ev.xmotion.time;
|
||||||
|
XSync(X_Dpy, False);
|
||||||
|
client_resize(cc);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
if (time) {
|
||||||
|
XSync(X_Dpy, False);
|
||||||
|
client_resize(cc);
|
||||||
|
}
|
||||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||||
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
|
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||||
xu_ptr_ungrab();
|
xu_ptr_ungrab();
|
||||||
@ -140,6 +151,7 @@ void
|
|||||||
mousefunc_window_move(struct client_ctx *cc, void *arg)
|
mousefunc_window_move(struct client_ctx *cc, void *arg)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
Time time = 0;
|
||||||
struct screen_ctx *sc = CCTOSC(cc);
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
int mx, my;
|
int mx, my;
|
||||||
int x = cc->geom.x, y = cc->geom.y;
|
int x = cc->geom.x, y = cc->geom.y;
|
||||||
@ -161,9 +173,19 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
|
|||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
cc->geom.x = x + (ev.xmotion.x - mx);
|
cc->geom.x = x + (ev.xmotion.x - mx);
|
||||||
cc->geom.y = y + (ev.xmotion.y - my);
|
cc->geom.y = y + (ev.xmotion.y - my);
|
||||||
client_move(cc);
|
|
||||||
|
/* don't sync more than 60 times / second */
|
||||||
|
if ((ev.xmotion.time - time) > (1000 / 60) ) {
|
||||||
|
time = ev.xmotion.time;
|
||||||
|
XSync(X_Dpy, False);
|
||||||
|
client_move(cc);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
if (time) {
|
||||||
|
XSync(X_Dpy, False);
|
||||||
|
client_move(cc);
|
||||||
|
}
|
||||||
xu_ptr_ungrab();
|
xu_ptr_ungrab();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user