Subject: waht happens with motion events?

From: Dominik Vogt <[email-masked]>
Date: Sat, 10 Jul 1999 01:54:28 +0200

I tried to fix some quirks with window movement when you are too
fast. But after spending hours debugging I am utterly confused.
My XServer: XFree 3.3.3.1 on Linuk 2.2.5.

What I do is this:

 1) Set a high ClickTime (not necessary, but helps in reproducing
    the problem).
 2) Press a button on a window title (the function bound to the title
    will raise the window and then start a move).
 3) Move the pointer a good distance to the right fast (*very* fast).
 4) Release the button.
 5) Move the pointer a good distance down as fast as in 3.

All this must be done extremely fast. 

What I would expect is that the window moves to the place where I
release the button. But quite often it ends up where the pointer
is after 5.

I digged into the code and logged all events. What I would have
expected is this:

  ButtonPress
  MotionNotify with button held (Event.xbutton.state != 0)
  ...
  ButtonRelease
  MotionNotify with button released (Event.xbutton.state == 0)
  ...

But what I get is this:

  ButtonPress
  MotionNotify with button held (Event.xbutton.state != 0)
  ...
  MotionNotify with button released (Event.xbutton.state == 0)
  ...
  ButtonRelease
 
I.e. I get the ButtonRelease only after I have stopped moving
the pointer completely. It looks as if the XServer didn't
generate ButtonRelease events while the pointer is grabbed.

This happens much more often when I try to move the window over
the top border of the screen in step 3, i.e. when I move
the mouse up and right.

Another thing that helps is to put a 'XFush(dpy);sleep(1)'
after the call to BroadcastRestack() in stack.c, function
RaiseOrLowerWindow().

Can someone shed a light on this mystery? Could someone with
a different XServer try this? I wonder if this is a XFree
problem.

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Brad Giaccio <[email-masked]>
Date: Mon, 12 Jul 1999 07:48:25 -0400

> My XServer: XFree 3.3.3.1 on Linuk 2.2.5.

I can confirm this on my Xsun servers (that is the openwin X server under 
solaris 2.5.1 2.6 and 2.7)

I realize this is a hack, but how does this sound, keep a static lastx
and lasty for the function and on every mousemotion update lastx and
lasty, then in the button release use the lastx and lasty instead of the
button release coordinates.  Now I beleive this is happening because
we are spending to much time in the switch, between checking snap
attraction, drawing the window and firing a notify event to windows,
we are just spending to much time.  So while the last motion event is
still being processes a button release gets registered and for some
reason when we actually ask for the button release it has the wrong
coordinates.

Index: move_resize.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/move_resize.c,v
retrieving revision 1.29
diff -u -B -b -r1.29 move_resize.c
--- move_resize.c       1999/07/09 17:44:26     1.29
+++ move_resize.c       1999/07/12 11:48:25
@@ -673,6 +673,7 @@
   FvwmWindow tmp_win_copy;
   int dx = Scr.EdgeScrollX ? Scr.EdgeScrollX : Scr.MyDisplayWidth;
   int dy = Scr.EdgeScrollY ? Scr.EdgeScrollY : Scr.MyDisplayHeight;
+  static int lastx,lasty;
 
   /* make a copy of the tmp_win structure for sending to the pager */
   memcpy(&tmp_win_copy, tmp_win, sizeof(FvwmWindow));
@@ -798,11 +799,17 @@
              break;
            }
        case ButtonRelease:
-fprintf(stderr,"br: x=%d, y=%d\n", Event.xbutton.x_root, Event.xbutton.y_root);
+fprintf(stderr,"br: x=%d, y=%d  %d %d\n", Event.xbutton.x_root, Event.xbutton.y_root, lastx,lasty);
          if(!opaque_move)
            MoveOutline(Scr.Root, 0, 0, 0, 0);
-         xl2 = Event.xbutton.x_root + XOffset;
-         yt2 = Event.xbutton.y_root + YOffset;
+         if(lastx == -1 && lasty == -1)+         {
+           lastx = Event.xbutton.x_root;
+           lasty = Event.xbutton.y_root;
+         }
+         xl2 = lastx + XOffset;
+         yt2 = lasty + YOffset;
+         lastx = lasty = -1;
          /* ignore the position of the button release if it was on a
           * different page. */
          if (!((xl < 0 && xl2 >= 0) || (xl >= 0 && xl2 < 0) ||
@@ -834,7 +841,9 @@
          break;
 
        case MotionNotify:
-fprintf(stderr,"mn: x=%d, y=%d\n", Event.xbutton.x_root, Event.xbutton.y_root);
+fprintf(stderr,"mn: x=%d, y=%d\n", Event.xmotion.x_root, Event.xmotion.y_root);
+         lastx = Event.xmotion.x_root;
+         lasty = Event.xmotion.y_root;
          xl = Event.xmotion.x_root + XOffset;
          yt = Event.xmotion.y_root + YOffset;

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 12 Jul 1999 19:12:45 +0200

On Mon, Jul 12, 1999 at 07:48:25AM -0400, [email-masked] wrote:
> button release coordinates.

I'll try your patch, but I think that will not really help since the
X server can generate many events in the meantime, not just one. I
have tried terminating the move when the first MotionNotify without
buttons down arrives, but this is too hard to determine because you
must not stop moving if no button was pressed initially (which you
can't find out reliably with fvwm's internal structure (faking
events and such)).

> Now I beleive this is happening because

But isn't keeping track of the right coordinates and order of events
the task of the X server? I can't think of anything else than a bug
in the X server or X itself.

Bye

Dominik ^_^

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Brad Giaccio <[email-masked]>
Date: Mon, 12 Jul 1999 13:30:26 -0400

> in the X server or X itself.

It is the job of the X server your right, but keep in mnid we are
getting what we have paid for here.  So my guess is yes it is a bug, or
is it a feature, with X.

Now I did try my patch and it seemed to correct, or at the very least
make it less noticble.  BTW what mouse acceleration do you normally use,
that it really makes it that notcible?  With my patch I couldn't produce
the problem with a setting of xset s 2 10 and if I went much higher I
really couldn't control my mouse well anyway. 

-- 
--- There are two kinds of knowledge, you either know the answer or
			you know where to find it
		      -Kane, Johnson, and anonymous
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Tue, 13 Jul 1999 11:40:49 +0200

> the problem with a setting of xset s 2 10 and if I went much higher I
                                ^^^^^^^^^^^

I assume you mean 'xset m 2 10'. 's' is the screen saver acceleration :-)

> really couldn't control my mouse well anyway. 

xset m 4 2

I don't have a mouse anyway but one of these fancy trackballs.

Bye

Dominik ^_^