Subject: BusyCursor Patch

From: Olivier Chapuis <[email-masked]>
Date: Fri, 29 Oct 1999 19:21:01 +0200

Hello,
Attached to this message a "busy cursor" patch. This patch is big
(and one may found it is dangerous). It will be probably preferable 
to send 3 patches but since every things is linked  I send
only one. However, if you like only some parts of this patch, say me
and I will send an other one.
I found the results quite pretty espesially with dynamic menus used
with the various "browse menus" scriptes.

1. Busy Cursor Stuff

The man page between the two --- lines:

-----------------------
.B "BusyCursor" "[\fIOption\fP \fIbool\fP\fP], ..."
This command controls the cursor during the execution of certain
command. \fIOption\fP can be "DynamicMenu", "ModuleSynchronous", "Read", 
"Recapture", "Wait". An option must be followed by a boolean argument 
\fIbool\fP. You can use commas to separate individual options. If you 
set an option to True, then when the corresponding  command is run, fvwm 
display the cursor of the WAIT context of the \fICursorStyle\fP command. 
False forces to not display the cursor. The Default is: DynamicMenu False, 
ModuleSynchronous False, Read False, Recapture True, Wait False.

The Read option also concerns the \fIPipeRead\fP command.
 
DynamicMenu concerns the \fIDynamicPopupAction\fP and 
\fIMissingSubmenuFunc\fP commands. If this option is set to False, then
the busy cursor is not displayed during a dynamic menu command even if this
command is a \fI(Pipe)Read\fP command and the Read option is set to true. 

Wait concerns only the root cursor. During the wait pause the root cursor
is replaced by the busy cursor and fvwm is still fully functional (you can 
escape from the pause, see the \fIEscapeFunc\fP command). If you want to 
use this option and if you do not use the default root cursor, you must 
set your root cursor with the \fICursorStyle\fP command.
---------------------------

Comments:
If the corresponding action to an option set to True is execuded, then
the cursor is grabed using the GrabEm function (things are different for
Wait, see below) and ungrabed when the execution is finished with the 
UngrabeEm function. The main technical problems is "multi grabing", for
avoiding problems I have add a new external int variable GrabPointerState 
and modify GrabEm and UngrabEm which now have a new parameters
"(un)grab_context". This new external variable is controled by GrabEm, 
UngrabEm and menus.c (and also by StartupStuff of fvwm.c for the "busy 
cursor at startup" stuff). Grabing the cursor when it is allready Grabed
is not a problem, however, we need to 
i. never forget to ungrab the cursor;
ii. not ungrab the cursor if it is not necessary (to avoid the disparition
of the busy cursor if a command that grab the cursor is executed during
a BusyCursor command).
iii. Do not forget to regrab the cursor after that a command which grab/ungrab
the cursor occure when the cursor is grabed: case of menus.c with dynamic
menus.
If one forget i and iii then we can freeze fvwm. Note that we can freeze
the *current* cvs by using principe iii: use a dynamicpopuaction that build
a menu but also execute a command that grab the cursor as Recapture or Move,
then popup this menu and click on the root window: "freeze". The patch solves
this :o). An other good news: the "busy cursor at startup" is alive for a
more long time.
The reason for this (is may be a bad news) is that I have commented some
not usefull IMHO UngrabEm in do_execute_module and SendStrToModule.
An other good news: the Wait stuff does not use grabbing, its only
redefine the root cursor (since fvwm is still functional during a
wait pause), here the bad news is that the user can't any more use xsetroot
to set the root cursor (if (s)he sets the Wait option to True and use
the Wait command). But, (s)he can use CursorStyle.

Ok, the above comments are quite not clear ... if you are interested
just read the patch :o)

2. Some cursor utilities

I have add the ROOT context to the CursorStyle command. Moreover, one
can now use X11 cursor name in this command (and not only number). 
I do *not* used the Xmu library.
I do that because of the Wait option of the BusyCursor command. So that
it is more easy to users to change the xsetroot command to a CursorStyle
one for setting the root cursor.  

3. EscapeFunc

I have documented the Ctl-Alt-Escape key sequence for the Wait and
ModuleSynchronous command. Moreover, since it seems that this key
sequence can be captured by some X server I have added the EscapeFunc 
function. Here the man page:

.B "EscapeFunc"
By default the key sequence Ctl-Alt-Escape allows to escape from
a \fIWait\fP pause and from a locked \fIModuleSynchronous\fP command.
The \fIEscapeFunc\fP command used with the \fIKey\fP command allows
to configure this key sequence. An example:
.EX
Key Escape A MC -
Key Escape A S EscapeFunc
.EE
replace Ctl-Alt-Escape by Shift-Escape for aboring \fIWait\fP pause
and \fIModuleSynchronous\fP command. \fIEscapeFunc\fP used without the 
\fIKey\fP command does nothing.

I think that here we do not need more comments.

ChangeLog

* NEWS: BusyCursor, EscapeFunc and CursorStyle.
* fvwm/ConfigFvwmDefaults: add the binding Key Escape A MC EscapeFunc
* fvwm/builtins.c (wait_func, recapture): Busy cursor stuff
* fvwm/cursor.{c,h} (cursor_type, default_cursors, CursorStyle, setBusyCursor,
   myCusorNameToIndex): Add CRS_ROOT and ROOT context for CursorStyle. 
   We can use X11 cursor name in  the CursorStyle command. Busy cursor stuff.
* fvwm/focus.c (FocusOn): update GrabEm and GrabEm.
* fvwm/function.{c,h} (func_config, execute_complex_function, DeferExecution):
  New functions BusyCursor and EscapeFunc. Busy cursor stuff.
* fvwm/fvwm.{c,h} (StartupStuff, InitVariables): Some Busy cursor stuff, the
  new external int GrabPointerState.
* fvwm/fvwm2.1: BusyCursor and EscapeFunc documentation. Update CursorStyle
  documentation.
* fvwm/menus.c (MenuInteraction, pop_menu_up): Busy cursor stuff.
* fvwm/misc.{c,h} (GrabEm, UngrabEm): Busy cursor stuff. Grab context bits for 
  GrabPointerState.
* fvwm/module_interface.c (ExecuteModuleSync): Busy cursor stuff and some
  logic fixes.
* fvwm/move_resize.c (InteractiveMove, resize_window): update GrabEm and
  UngrabEm.
* fvwm/module_interface.c (do_execute_module,SendStrToModule,ExecuteModuleSync):
  Comments some not useful (IMHO) UngarbEm for the Busy cursor stuff. And ...
  Busy cursor stuff !
* fvwm/placement.c (PlaceWindow): update GrabEm and UngrabEm.
* fvwm/read.c (cursor_control, ReadFile, PipeRead): Busy cursor stuff.
* fvwm/screen.h (ScreenInfo): BusyCursor

modules/ChangLog

* modules/FvwmForm/FvwmRootCursor.:
* modules/FvwmForm/FvwmRootCursor.pl:
  Replace xsetroot by CursorStyle ROOT  

Olivier

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 30 Oct 1999 03:09:01 +0200

> with the various "browse menus" scriptes.

Nice work, Olivier!
Some notes after several minutes of playing with this new stuff.

You forgot to enclose the second parameter to CheckBinding() in
#ifdef HAVE_STROKE. No need to repost a patch.

Now with this patch all xsetroot or similar calls in initialization
functions are ignored. I don't know whether this is ok.

It is not a problem to replace:
	Exec xsetroot -cursor_name left_ptr -fg red -bg white
with:
	CursorStyle Root left_ptr red white

But probably some users can be confused. The note about the initial
xsetroot should be in the man page or/and NEWS.

I think that the default Root cursor must be changed from ugly X_cursor to
left_ptr or similar. Does anyone love this X_cursor?

I see no problems with incorporating this patch into the current CVS.
But I didn't take a look at it in depth yet and I prefer to test it first.

Also I think Olivier can get write access to apply his patches himself.

What others think?

Regards,
Mikhael.
--
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: Ben Winslow <[email-masked]>
Date: Fri, 29 Oct 1999 23:55:21 -0400

Mikhael Goikhman wrote:
[snip]
>         CursorStyle Root left_ptr red white
I'd definately prefer a 'Root' cursorstyle instead of running xsetroot
in the InitFunction.  One note is that CursorStyle requires the cursor
number, and can't accept names--  support for names would be nicer, and
wouldn't it be preferable to have name support anyway, since the numbers
could *theoretically* change?

> left_ptr or similar. Does anyone love this X_cursor?
I hate the default X cursor.  Most window managers set the default to
left_ptr...

-- 
Ben Winslow ([email-masked])    / |Rain| @ IRC / freshmeat news
squad
freshmeat: http://www.freshmeat.net / anynet: irc.anynet.org
--
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: Sat, 30 Oct 1999 07:25:12 +0200

> > with the various "browse menus" scriptes.

Thanks Mikhael ! It was not easy for me to implement this busy cursor
stuff and I'm happy that you like the result.
 
> #ifdef HAVE_STROKE. No need to repost a patch.

Arghhhhhh ... and shame on me since at present time I work on 
understanding the STROKE patch to allows modifier to work.
 
> xsetroot should be in the man page or/and NEWS.

Yep, with the first versions of my patch this happen only if you use
BusyCursor Wait True. I think I can do so that this is the case with
the version I send (and so the doc is ok).
 
> left_ptr or similar. Does anyone love this X_cursor?

I don't, I use hand1 yellow black :o). For the default I think that the
better one is right_ptr (it is more different that the cursor which appear 
with TitleBar, menu, modules, ...).
 
> Also I think Olivier can get write access to apply his patches himself.

Maybe I am a little young with programming and with fvwm code (even if
I learned quite fast this last two months). On the other hand my job
is *theoretical* computer science and if I have write access I will
be very careful (at present time I know that Dominik, Tim, Mikhael or an
other "guru"  will take a look to my patch) I do not want that
a fvwm core dump be my fault !
Any way, the fact that I have not write access is a minor problem for
building patch and may be I have to learn more to have this access.

Yours, Olivier

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 30 Oct 1999 12:30:24 +0200

> could *theoretically* change?

But with this patch it is already possible to use names instead of
numbers, so my example is valid. :)

Regards,
Mikhael.

---

From: Bob Woodside <[email-masked]>
Date: Sat, 30 Oct 1999 10:58:00 -0400

Olivier Chapuis wrote:
> I learned quite fast this last two months).

	We've all made mistakes and committed things that were broken. We just
expect someone to demonstrate reasonable competence and to be reasonably
conscientious. I think you've done both. If you have a particularly
complex piece of work, you can *still* ask for opinions or make a patch
for others to review before committing it. Even the "old-timers" do that
occasionally. Remember that one advantage of being able to commit things
yourself is that, if something goes in that is broken, you can fix it
much more quickly.

	Olivier has my vote whenever he feels ready to request access from
Jason.

Cheers,
Bob

---

From: Bob Woodside <[email-masked]>
Date: Sat, 30 Oct 1999 10:58:22 -0400

> the version I send (and so the doc is ok).

	I hope so. I don't like the idea of adding too many "you can't do this
during init functions" restrictions.

> > left_ptr or similar. Does anyone love this X_cursor?

	I doubt it.

> with TitleBar, menu, modules, ...).

	The default X *is* really ugly. There isn't another choice that quite
satisfies me, though. The standard collection of X cursors could stand
some sprucing up. I wouldn't recommend the righr_ptr because of the
Motif habit of switching to that cursor when it expects you to do
something. This could be confusing or annoying to some users. The
disadvantage of the left pointer (otherwise probably the best choice) is
that I really like to see the cursor change when you enter a window or a
menu, and left_ptr is commonly used in this case. Most of the others are
either commonly used for specific purposes (like the watch) or are are a
bit quirky (i.e., very much subject to individual taste).

	Does anyone else have a favorite they'd like to recommend as the new
default?

Cheers,
Bob

---

From: Ben Winslow <[email-masked]>
Date: Sat, 30 Oct 1999 11:27:14 -0400 (EDT)

Around 10:58am on Oct 30, 1999, Bob Woodside spoke unto me:

[snip]
BW# > 
BW# > I don't, I use hand1 yellow black :o). For the default I think that the
BW# > better one is right_ptr (it is more different that the cursor which appear
BW# > with TitleBar, menu, modules, ...).
BW# 
BW# 	The default X *is* really ugly. There isn't another choice that quite
BW# satisfies me, though. The standard collection of X cursors could stand
BW# some sprucing up. I wouldn't recommend the righr_ptr because of the
BW# Motif habit of switching to that cursor when it expects you to do
BW# something. This could be confusing or annoying to some users. The
BW# disadvantage of the left pointer (otherwise probably the best choice) is
BW# that I really like to see the cursor change when you enter a window or a
BW# menu, and left_ptr is commonly used in this case. Most of the others are
BW# either commonly used for specific purposes (like the watch) or are are a
BW# bit quirky (i.e., very much subject to individual taste).
BW# 
BW# 	Does anyone else have a favorite they'd like to recommend as the new
BW# default?
I'd recommend left_ptr, although you do have a valid point.  Perhaps the
best bet is to use a custom xpm as the default cursor (although this may
cause even more disagreement than the default X cursors ;)

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

-- 
Ben Winslow ([email-masked])    / |Rain| @ IRC / freshmeat news squad
freshmeat: http://www.freshmeat.net / anynet: irc.anynet.org