summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2009-04-15 14:10:08 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2009-04-15 14:10:08 +0000
commitdcc4482f9341efbc92848cadee0d5437afcdb472 (patch)
tree91bd7909ba3e7e2bbf72746c60b0ec0391a145d3 /app/cwm
parent2850366d21e546e21590af9e37ef3407eef47f59 (diff)
don't sync more than 60 times per sec on resize and move; idea from scrotwm.
ok oga@ sometime ago
Diffstat (limited to 'app/cwm')
-rw-r--r--app/cwm/mousefunc.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c
index 86cef8a20..8dcc66000 100644
--- a/app/cwm/mousefunc.c
+++ b/app/cwm/mousefunc.c
@@ -16,7 +16,7 @@
* 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.7 2009/01/22 19:01:56 okan Exp $
+ * $Id: mousefunc.c,v 1.8 2009/04/15 14:10:07 okan Exp $
*/
#include "headers.h"
@@ -88,6 +88,7 @@ void
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;
@@ -116,9 +117,19 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
ev.xmotion.x, ev.xmotion.y))
/* Recompute window output */
_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;
case ButtonRelease:
+ if (time) {
+ XSync(X_Dpy, False);
+ client_resize(cc);
+ }
XUnmapWindow(X_Dpy, sc->menuwin);
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
xu_ptr_ungrab();
@@ -140,6 +151,7 @@ void
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;
@@ -161,9 +173,19 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
case MotionNotify:
cc->geom.x = x + (ev.xmotion.x - mx);
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;
case ButtonRelease:
+ if (time) {
+ XSync(X_Dpy, False);
+ client_move(cc);
+ }
xu_ptr_ungrab();
return;
}