Subject: AutoHide in fvwm core

From: Dominik Vogt <[email-masked]>
Date: Thu, 31 Jan 2002 03:31:19 +0100

With my latest changes, it's possible to implement autohiding
using FvwmEvent with the enter_window/leave_window events, the
Schedule command and the State command.  This example uses
WindowShade to hide two windows called "FvwmButtons" and
"XMessages" automatically.  If title button 8 is pressed (sorry,
no visual feedback yet), the window is locked in unhidden state.
This should work with any focus policy.

What I like especially about this it that it was trivial to
implement (the C code, not the complex functions).

Any comments?

BTW, Tim, I changed the behaviour of "Schedule 0 <cmd>".  The
command is now executed before any event handling is done, the
next time fvwm enters the My_XNextEvent() function.

------------------------- snip -----------------------
#
# AutoHide in fvwm
#

### configure FvwmEvent

*FvwmEvent: PassId
*FvwmEvent: enter_window "autohide_window"
*FvwmEvent: leave_window "autohide_window"

AddToFunc StartFunction
+ I Module FvwmEvent

### some helper functions

AddToFunc show_window
+ I Deschedule $0
+ I WindowShade off

AddToFunc hide_window
+ I All (FvwmButtons) WindowShade on

AddToFunc check_hide
+ I None (CirculateHit,HasPointer,$0) Schedule $1 $2 All ($0,!state 0) WindowShade on
+ I PointerWindow ($0) show_window $2

### the main autohide function
# Add more windows as needed.
#
# $0 = window name (*must* be unique)
# $1 = delay in ms
# $2 = job group id used in the Schedule command.  Should be unique for each
#      window.

AddToFunc autohide_window
+ I check_hide FvwmButtons 200 100
+ I check_hide XMessages 200 101

### use state 0 on button 8 to lock window in unhidden state
# would be nice to invert the title button depending on the state
mouse 1 8 n state 0
------------------------- snip -----------------------

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: Olivier Chapuis <[email-masked]>
Date: Thu, 31 Jan 2002 13:58:40 +0100

> implement (the C code, not the complex functions).

I begun to try this. Your example work fine here.
So, I try to modify it for my need.
I get a core dump with:

DestroyModuleConfig FvwmEvent-Auto: *
*FvwmEvent-Auto: PassId
*FvwmEvent-Auto: enter_window "autohide_window"
*FvwmEvent-Auto: leave_window "autohide_window"

DestroyFunc show_window
AddToFunc show_window
+ I Deschedule $0
+ I WindowId $1 Raise

DestroyFunc check_raise
AddToFunc check_raise
+ I PointerWindow ($0) Schedule $1 $2 show_window $2 $3

DestroyFunc autohide_window
AddToFunc autohide_window
+ I check_raise FvwmButtons 500 101 $0

If I remove "+ I Deschedule $0" I've no more a core dump
(I am not sure that this deschedule is useful) but
the things does not work fine. I've added an Echo $1
in show_window and it seems that PointerWindow($0)
does not respect the $0 condition and also FvwmEvent
send strange window id sometimes.

here the core dump:

[olivier@snoopy olivier]$ gdb fvwm2 core
GNU gdb 4.18
Core was generated by `fvwm2 -f themes-rc'.
Program terminated with signal 11, Erreur de segmentation.
Reading symbols from /opt/X11R6/lib/libXpm.so.4...done.
Reading symbols from /usr/local/lib/libstroke.so.0...done.
Reading symbols from /opt/X11R6/lib/libSM.so.6...done.
Reading symbols from /opt/X11R6/lib/libICE.so.6...done.
Reading symbols from /opt/X11R6/lib/libXext.so.6...done.
Reading symbols from /opt/X11R6/lib/libX11.so.6...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from /opt/X11R6/lib/X11/locale/common/xlcDef.so.2...done.
Reading symbols from /usr/lib/gconv/ISO8859-1.so...done.
Reading symbols from /opt/X11R6/lib/X11/locale/common/xomGeneric.so.2...done.
#0  0x401975af in free () from /lib/libc.so.6
(gdb) where
#0  0x401975af in free () from /lib/libc.so.6
#1  0x80966cb in execute_obj_func (object=0x8182738, args=0xbffff368)
    at schedule.c:186
#2  0x809f8a6 in fqueue_remove_or_operate_all (fq=0x80ab20c, 
    operate_func=0x80965f0 <execute_obj_func>, operate_args=0xbffff368)
    at queue.c:253
#3  0x8096738 in squeue_execute () at schedule.c:206
#4  0x806ca26 in My_XNextEvent (dpy=0x80b5d58, event=0x80acc60)
    at events.c:2917
#5  0x806cc87 in HandleEvents () at events.c:3051
#6  0x808dc5d in main (argc=3, argv=0xbffff944) at fvwm.c:715

---

From: Olivier Chapuis <[email-masked]>
Date: Thu, 31 Jan 2002 14:05:39 +0100

DestroyFunc show_window
AddToFunc show_window
+ I Deschedule $0
+ I WindowId $1 Raise

DestroyFunc check_raise
AddToFunc check_raise

here the core dump:

---

From: Dominik Vogt <[email-masked]>
Date: Thu, 31 Jan 2002 16:28:21 +0100

> So, I try to modify it for my need.

Ill look into this later.

[snip]

> (I am not sure that this deschedule is useful)

But it is!  Without that, you can get a race condition between the
scheduled hiding and immediate unhiding.

Bye

Dominik ^_^  ^_^

---

From: Dominik Vogt <[email-masked]>
Date: Thu, 31 Jan 2002 22:31:37 +0100

> So, I try to modify it for my need.

Fixed.  I didn't plan for commands that deschedule themselves :-)

Bye

Dominik ^_^  ^_^