Subject: Yet another unclutter problem

From: Lorenz Minder <[email-masked]>
Date: Thu, 28 Jun 2001 16:57:53 +0200

I don't actually think this is release critical, but I think it should
probably not be me to decide that, therefore I figured it would be
better to mention that anyway.

I have another problem with unclutter. Here's a minimal config:

Style   *       SloppyFocus
Key     Tab     A       M       Next [*] Focus

Reproduce:

1) Open two xterms.
2) Move the mouse on the title bar or border of one of these xterms.
3) Switch windows with Alt-Tab (but leave the mouse pointer where it is)
4) Wait --- When unclutter hides the mouse pointer, focus is switched
5) Even more annoyingly, you can't switch back with Alt-Tab, it will
   immediately switch back again.

This appears on fvwm-snap-20010603.

I tried to track it down, but didn't succeed yet. And, unfortunately I
have no time to devote right now. When I was inserting fprintf's in the
source, etc. I could no longer reliably reproduce part (5); maybe it has
to do with timing. So I don't know if (5) can be reproduced on faster
machines, for instance. (This here is a Pentium-133).

Greetings,
--Lorenz
--
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: "Paul D. Smith" <[email-masked]>
Date: 28 Jun 2001 12:38:57 -0400

There was an unclutter problem I reported back about then, that was
fixed almost immediately.

You say you are using a snap from early June; the very first thing to do
when you find a problem, well before bothering to spend any time
debugging it yourself, is to try the latest code.

If it still happens there, please file a bug.

Thanks!

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>    HASMAT--HA Software Methods & Tools
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
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: Lorenz Minder <[email-masked]>
Date: Thu, 28 Jun 2001 19:35:53 +0200

> fixed almost immediately.

No, your problem was in May, not June, according to my archive. (That's
BTW why I entitled it `Yet another ...'.) Moreover the bug descriptions
don't match.

> debugging it yourself, is to try the latest code.

There are no suspicious changelog entries. While early June might seem
very old, let's not forget that fvwm-wise the time stood still for
several weeks between now and then. (I'm actually preety sure it's still
there.)

Anyway, in principle you're right; if I come around to, I'll try. (But
as I said, I have no time, so don't count on me doing that quickly.
Sorry.)

Greetings,
--Lorenz

---

From: Dan Espen <[email-masked]>
Date: Thu, 28 Jun 2001 14:21:05 -0400

> > If it still happens there, please file a bug.

I can confirm that the problem exists with CVS from a couple of days
ago.

I just observed another problem that was fixed a while back and
appears to have come back.  As long as a menu is posted, fvwm
is causing X activity.

-- 
Dan Espen
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854                     Phone: (732) 699-5570
--
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: Fri, 29 Jun 2001 06:13:39 +0200

> appears to have come back.  As long as a menu is posted, fvwm

I don't see any X activity, but this may depend on the menu styles
you use.  Can you please post the relevant lines?

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: Dominik Vogt <[email-masked]>
Date: Fri, 29 Jun 2001 05:53:22 +0200

>    immediately switch back again.

The problem is this:

When unclutter hides the pointer, it creates an invisible
subwindow to the window that currently contains the pointer.
Since the pointer generates an EnterNofity on the new window and
unclutter sends a synthetic EnterNotify on its parent so that the
application thinks it still has the cursor.

Now, while the cursor is hidden, unclutter waits for any
interesting event including FocusOut on the parent window.  If it
gets one, it destroys its subwindow, creates a new one and sends
another EnterNotify.

With SloppyFocus and MouseFocus this new EnterNotify moves the
focus right back to the old window.  There is not much we can do
about this in fvwm, it has to be fixed in unclutter.  fvwm
responds correctly to the events it gets.

Bye

Dominik ^_^  ^_^

---

From: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 08:32:06 -0400

> you use.  Can you please post the relevant lines?

It happens for me with no .fvwm2rc file at all,
just using the built in menu.

I've only got one computer at home, this is difficult to debug without
2 machines.

---

From: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 08:39:09 -0400

> responds correctly to the events it gets.

It seems to me that if you are using SloppyFocus or MouseFocus,
you want the focus to follow the mouse pointer.
Thats what it does.

The "Next [*] Focus" command violates that rule, but unclutter fixes
it up.  If you want to focus on a new window with either of these
focus models, warptowindow should be used.

I don't think theres a problem.

---

From: "Paul D. Smith" <[email-masked]>
Date: 29 Jun 2001 09:40:39 -0400

%% Dan Espen <[email-masked]> writes:

  de> I've only got one computer at home, this is difficult to debug
  de> without 2 machines.

Can you get it to happen using Xnest?

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 29 Jun 2001 15:56:19 +0200

> I've only got one computer at home, this is difficult to debug without

You can either start a second X server and fvwm in an XNest
window:

  $ exec Xnest -full -sync -name "Xnest :3" :3
  $ fvwm2 -d :3 -cmd "FvwmCpp $HOME/.fvwm/.fvwm2rc"

Or start a second X server:

  $ exec xinit /bin/sleep 100000 -- :1
  $ fvwm2 -d :1 -cmd "FvwmCpp $HOME/.fvwm/.fvwm2rc"

Running fvwm in xnest is often easier to debug since you don't
need to switch screens, but moving the pointer out of the window
may generate unwanted events.

Bye

Dominik ^_^  ^_^

--
Dominik Vogt, email: [email-masked]
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
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: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 10:18:36 -0400

> may generate unwanted events.

I'm at home.
I'm stuck with Exceed and W98.
Actually, I see that I can use a telnet window at the same time I have
a menu posted.

I'll see if I can figure out whats going on.

---

From: Charles Hines <[email-masked]>
Date: Fri, 29 Jun 2001 10:23:48 -0400

>>>>> "Dominik" == Dominik Vogt <[email-masked]> writes:

Dominik> On Fri, Jun 29, 2001 at 08:32:06AM -0400, Dan Espen wrote:
...
>> I've only got one computer at home, this is difficult to debug without

Dominik> You can either start a second X server and fvwm in an XNest
Dominik> window:

Dominik>   $ exec Xnest -full -sync -name "Xnest :3" :3
Dominik>   $ fvwm2 -d :3 -cmd "FvwmCpp $HOME/.fvwm/.fvwm2rc"

Dominik> Or start a second X server:

Dominik>   $ exec xinit /bin/sleep 100000 -- :1
Dominik>   $ fvwm2 -d :1 -cmd "FvwmCpp $HOME/.fvwm/.fvwm2rc"

Dominik> Running fvwm in xnest is often easier to debug since you don't
Dominik> need to switch screens, but moving the pointer out of the window
Dominik> may generate unwanted events.

VNC is another good choice.  It's what I used to use occasionally for
debugging fvwm, along with XMX (which also worked fairly well although
sometimes that had bugs of it's own which interfered) and Xnest (and
occasionally in conjunction with xmon/xscope, of course).  It shouldn't have
any problems with the pointer leaving the window since the vncviewer window is
totally separate from the actual Xvnc X11 session.

I felt that using the virtual terminals (under Linux or AIX 3.x) for debugging
fvwm was rather difficult...

Chuck

-- 
Charles K. Hines   <[email-masked]>   <[email-masked]>
Principal Scientist at ReQuest Technologies Inc   (http://www.ReQuestTech.com/)
Martial Arts Instructor [Modern Arnis and Balintawak Escrima]

         "Go back to sleep, Chuck.  You're just havin' a nightmare
             -- of course, we ARE still in Hell." (Gary Larson)

---

From: Lorenz Minder <[email-masked]>
Date: Fri, 29 Jun 2001 16:39:35 +0200

Dominik Vogt wrote:
> > [...]

Thanks a lot for this description, now I see why it doesn't work.

I have implemented a new Style, NoMouseFocusWithoutMotion which causes
windows not to get focus because of the mouse pointer, if it hasn't moved
before.

Obvioulsy this doesn't only change the behaviour of unclutter but also,
e.g. of newly created windows: They no longer automatically receive
Focus just because they were placed below the mouse cursor. Another
effect is that focus of windows, which are moved by keyboard commands,
doesn't accidentially change.

Personally, I prefer this to the default behaviour.

I'll post a patch as soon as I've properly tested, cleaned up and documented 
that new style.

Greetings,
--Lorenz

---

From: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 10:36:02 -0400

> I'll see if I can figure out whats going on.

Ok, heres a trace:

---

From: "Paul D. Smith" <[email-masked]>
Date: 29 Jun 2001 12:08:41 -0400

%% Lorenz Minder <[email-masked]> writes:

  lm> I have implemented a new Style, NoMouseFocusWithoutMotion which
  lm> causes windows not to get focus because of the mouse pointer, if
  lm> it hasn't moved before.

Without commenting one way or another on whether this is a good style or
not, you might consider changing the name to avoid the double negative.

Maybe just "FocusRequiresMotion"?

(*shrug*)

---

From: Danek Duvall <[email-masked]>
Date: Fri, 29 Jun 2001 08:57:43 -0700

On Fri, Jun 29, 2001 at 08:39:09AM -0400, Dan Espen wrote:

> The "Next [*] Focus" command violates that rule, but unclutter fixes it
> up.  If you want to focus on a new window with either of these focus
> models, warptowindow should be used.

One inconvenient thing about warptowindow is that there's no programmatic
way to get back to the original window.  So if you want a command to
temporarily get you to a different window and then put you back as if
nothing had happened, warping the pointer doesn't work so well.

Specifically, I like to bring up FvwmConsole with a single keystroke.  I
get focus in the new window immediately, type whatever I need in it, and
when I hit ^D to get out of it, my focus returns to the window I was in
before (because the mouse hasn't moved).

Is there a better way of doing this?

Danek

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 29 Jun 2001 19:45:05 +0200

> > I'll see if I can figure out whats going on.

I'm not quite sure what I should see in this trace.  To me, it
looks like a random piece of code recorded in a log file.  Is this
meant to demonstrate one of the busy wait cycles?  If it is, it
contains neither the start nor the end of the cycle.

Bye

Dominik ^_^  ^_^

---

From: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 14:05:54 -0400

> contains neither the start nor the end of the cycle.

It is meant to demonstrate the cycle.

I thought when it went from XQueryPointer at line 371 in menus.c
back to the same location I had the whole cycle.

---

From: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 14:27:38 -0400

> back to the same location I had the whole cycle.

In the sample I sent, it seems to fake a MotionNotify event
(line 1539, menus.c) and then start querying the pointer, I think
its looking for a release event.

If it still looks bad to you, I'll redo it.
I might have inadvertantly moved the mouse while trying to get gdb
to operate.

I'm also using a fairly new trackball mouse.

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 29 Jun 2001 21:51:36 +0200

> I might have inadvertantly moved the mouse while trying to get gdb

Probably.  A cycly should start at the beginning of the loop in
MenuInteraction().

Bye

Dominik ^_^  ^_^

---

From: Dan Espen <[email-masked]>
Date: Fri, 29 Jun 2001 18:38:24 -0400

> Probably.  A cycly should start at the beginning of the loop in

Attached is a new trace.

The while loop in menus.c starts with:

flags.do_popdown_now = False;

thats line 1427 in this trace.

You will see that twice in the attached trace.  Actually, I see it
4 times, in pairs like this:

1427	    flags.do_popdown_now = False;
1425	    flags.do_popup_and_warp = False;
1426	    flags.do_popup_now = False;
1427	    flags.do_popdown_now = False;

I believe thats just the optimizer rearranging code.

To produce this  trace, I telneted into the  machine running fvwm from
the PC.  Then  I attached gdb to  the  running fvwm and  typed "cont".
Then I  brought  up  a  menu using the    keyboard.  The pointer   was
positioned on the first  item in the menu (below  the title).  Looking
at my cable modem, I could see packets flying back and forth.

I then hit Ctrl-Alt-Tab to select the telnet window.
This leaves the
pointer on the menu item but I can type commands into the telnet window.

I then hit ctrl-C to gain  control and single  stepped thru the loop a
few times.

In the attached trace, I took out the "(gdb)" prompts to make it
easier to read.

---

From: Dominik Vogt <[email-masked]>
Date: Sat, 30 Jun 2001 08:04:33 +0200

On Fri, Jun 29, 2001 at 06:38:24PM -0400, Dan Espen wrote:
> You will see that twice in the attached trace.

What you noticed is that fvwm periodically bumps out of the loop
where it waits for events (Each time the PopupDelay is over) and
checks if something has to be popped up.  In the process,
XQueryPointer is called three times.  This happens every 150
milliseconds, so this should hardly be noticeable.  I'll rewrite
a bit of code so that it only needs to call XQueryPointer once.

Bye

Dominik ^_^  ^_^

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 30 Jun 2001 13:33:44 +0000

> Is there a better way of doing this?

If I correctly understand the question, here is how to achieve this:

  Style * StickyFocus
  Style FvwmConsole GrabFocus
  Key F12 A M FvwmConsole

The second way, which also achieves this (in 2.2.x it works differently):

  AddToFunc StartFvwmConsole
  + I FvwmConsole
  + I Wait FvwmConsole
  + I Next (FvwmConsole) Focus  # Focus NoWarp if 2 non-sticky FvwmConsole

I only post tested examples.

Regards,
Mikhael.