Subject: rxvt selection problem pinned down

From: Dominik Vogt <[email-masked]>
Date: Tue, 11 Apr 2000 18:18:15 +0200

Finally I have pinned down the rxvt selection problem to
a single commit.

[The problem is that if you drag a window (you have to do it
fast over a rxvt window, some text in the rxvt is often
selected - depending on the load of the X server.  Try to
run 'while;true; do ls; done' in a shell on the screen to
keep the X server busy if necessary.]

The problem is not present in the code I get with

  cvs checkout -D 10/29/1999 -P -d fvwm

and starts with

  cvs checkout -D 10/31/1999 -P -d fvwm

The difference in the ChangeLog is the BUSY_CURSOR patch:

  1999-10-30  Olivier Chapuis  [email-masked]

          * NEWS: BusyCursor, EscapeFunc and CursorStyle.
          * fvwm/ConfigFvwmDefaults: add the binding Key Escape A MC EscapeFunc
          ...
  
  1999-10-25  Hippo

Olivier, can you please help debugging this?  I'm fairly sure
that it has something to do with 'grabbing', but I have no idea
what exactly could cause it.  The configure option disabling the
BUSYCURSOR patch doesn't fix the problem, so probably you missed
something with that option.  Possibly it would even happen with
2.3.16 if the BUSYCURSOR patch was completely removed.  So it is
probably best to take the cvs from 31st or October, and remove
the diffs to cvs from 29th of October until the problem goes away.
Then we can see if the same changes to current cvs fix the problem
too.

Bye

Dominik ^_^

-- 
Dominik Vogt, Agilent Technologies, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/464-4596, fax: 07031/464-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: Dominik Vogt <[email-masked]>
Date: Tue, 11 Apr 2000 22:43:59 +0200

> Then we can see if the same changes to current cvs fix the problem

Finally, the problem is solved.  It was indeed introduced by the
BUSYCURSOR patch.  In execute_complex_function() (functions.c),
A UngrabEm() call was moved to a delicate place:

This code around line 1439 (current CVS)
  while(fi != NULL)
    {
      /* make lower case */
      c = fi->condition;
      ...
        ExecuteFunction(taction,tmp_win,ev,context,-2,expand_cmd);
      ...
    }
  WaitForButtonsUp(False);
  UngrabEm();                 <-----

was changed to this:

  UngrabEm(GRAB_NORMAL);      <-----
  while(fi != NULL)
    {
      /* make lower case */
      c = fi->condition;
      ...
        ExecuteFunction(taction,tmp_win,ev,context,-2,expand_cmd);
      ...
    }
  WaitForButtonsUp(False);

I.e. before the BUSYCURSOR patch, the pointer was grabbed throughout
a complex function until the button was release.  After the patch
the pointer was not grabbed anymore.  Now this explains nicely why
the selection problem happened:

 1) Press button on window title.
 2) The pointer is grabbed automatically in the selected window.
 3) The complex function is executed.
 4) Before the 'Move' command is called, above code releases the
    automatic grab on the pointer!
 5) Move the pointer fast over another window.  Sometimes when the
    X server is too busy, the mouse is ahead of the window.
 6) Now, the crucial point is that the pointer is not grabbed
    anymore.  Thus, 'MotionNotify' events are reported to the rxvt
    because rxvt has selected them spcifically.
 7) rxvt interprets the MotionNotify events with a button held as
    user input and selects text in its window until the moving
    window catches up with the pointer!!!

So, the fix is to move the UngrabEm() call back down after
WaitForButtonsUp().  The big question is: why was it moved up
in the first place?  Probably because you can't grab the BUSYCURSOR
if the pointer is already grabbed.  Well, Olivier, you have to
think of a different way to achieve this.  The pointer must not
be ungrabbed for a single CPU cycle or otherwise the problem might
come back again.

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: Bob Woodside <[email-masked]>
Date: Tue, 11 Apr 2000 21:19:10 -0400

Dominik Vogt wrote:
> 
> Finally, the problem is solved.

	Congratulations, Dominik! This is a most impressive piece of detective
work.

	[ deep sigh of relief that we don't have to go back to the drawing
          boards on the decor_w vs. frame button-grabbing business ]

	I'm sorry I wasn't able to offer any help on this one...my schedule has
been so tight that I haven't even had time to do an update in a couple
of months (though I think I'll have to try to find time in a day or so,
just to see this problem disappear!), but I do try to follow the list
activity as best I can, even if only in read-only mode. :-(

Cheers,
Bob

---

From: Olivier Chapuis <[email-masked]>
Date: Wed, 12 Apr 2000 12:29:08 +0200

Dominik Vogt wrote:
> in the first place?
 
I think that when I do the  BUSYCURSOR ifdef commit I send to you, Dominik,
a private message to say that I've do this UngrabEm() move in complex
functions when I do the busy cursor patch. At this time we conclude 
that this move was a good move. I do not remember why we do such
conclusion. I'm far from the machine I used to send to you this
message, but you may take a look to your mail archive and this
may answer the question. 
 
> Probably because you can't grab the BUSYCURSOR

I need to check again, but I think that your commit is consistent
with the busy cursor patch.
Olivier
--
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: Wed, 12 Apr 2000 13:33:34 +0200

On Wed, Apr 12, 2000 at 12:29:08PM +0200, Olivier Chapuis wrote:

[snip]

> message, but you may take a look to your mail archive and this

Yes, I can remember this very vaguely, but whatever our
reasoning was - we were wrong.

> with the busy cursor patch.

Okay.  If we don't have to change anything - excellent.

Bye

Dominik ^_^