Application focus and control

Hi all:

I have found that FVWM is AMAZING – does everything that I want… so far.

So, far all you guru’s, here’s something that just came to mind (and something that I need FVWM to do):

Is it possible, in the .fvwm2rc, to specify that when application X on Desk Y is active/started/whatever, that no tabbing, switching, anything is possible as long as that application is active?

I have been scouring the fvwm man page, and I can’t find anything.

I sincerely do not want to have to change anything in events.c or session.c, etc. stating that if the window root is Desk Y with application X active, dont’ allow anything else to gain focus as long as that window has focus

If anyone out there knows a way that something like this could possibly gtake place – PLEASE drop me a reply

thanks,
Skender

It is, yes. Let’s assume that you have application “X”. You can use FvwmEvent to monitor all windows as they are started up. That’s the first step. We’ll call the FvwmEvent instance “FE-notab”:

DestroyModuleConfig FE-notab: *
*FE-notab: Cmd Function
*FE-notab: add_window SomeFunc

# Start the module next time fvwm reloads.
AddToFunc StartFunction I Module FvwmEvent FE-notab

So everytime a window is mapped to the Xserver, the function “SomeFunc” will get run. Now, all we have to do is test for this application X and “disable” scrolling:

DestroyFunc SomeFunc
AddToFunc SomeFunc
+ I All (CurrentDesk) ThisWindow ("X") DisableScroll

Which means that if the window called “X” exists, then the “DisableScroll” function will get called. In that, we can then do something like:

DestroyFunc DisableScroll
AddToFunc DisableScroll
+ I EdgeResistance 10000 10000
+ I EdgeScroll 0 0
+ I DestroyFunc foo

That’ll stop you from flipping pages with the mouse (if the mouse hits the edge of the screen.) The “DestroyFunc foo” part is for destroying those functions you might have that are bound to key-bindings that flip pages. You can’t completely disable the effect of flipping pages/desks, so the next best thing is to disable the means to do so – which means removing the ability to do so via key-bindings, etc.

Of course, what happens, when you then do kill the application that was stopping you from flipping pages. You’d then have allow it, hence you’ll need to add to the “FE-notab” configuration, to watch for an event on close/destroy window:

*FE-notab: destroy_window RestoreFlipping

Then the function:

DestroyFunc RestoreFlipping
AddToFunc RestoreFlipping
+ I EdgeScroll 100 100
+ I EdgeResistance ...
....

etc, etc. But that might be long-winded. The other possible action I can see instead of that, is to listen for “new_desk” events instead, and effectively “disallow” them. Note that what follows is to be used instead of the method suggested above, but not as well as:

DestroyModuleConfig FE-noswicthdesk: *
*FE-noswicthdesk: Cmd Function
*FE-noswicthdesk: new_desk GoBackDeskPage desk
*FE-noswitchpage: new_page GobackDeskPage page

Then the function:

DestroyFunc GoBackDeskPage
AddToFunc GoBackDeskPage
+ I PipeRead `[ $0 = "desk" ] && echo 'GotoDesk prev' || echo 'GotoPage prev'`

Which simply switches the viewport back to the original page and/or desk you were at before the application “X” was started.

I’ve presented a few options for you to try.

– Thomas Adam

About keeping the focus to one window, I have written this

[code]DestroyFunc GrabFocus
AddToFunc GrabFocus

  • I Style * NeverFocus,!FPFocusByFunction,!FPFocusByProgram
  • I WindowStyle SloppyFocus

DestroyFunc UngrabFocus
AddToFunc UngrabFocus

  • I Style * SloppyFocus,FPFocusByProgram,FPFocusByFunction[/code]

I use this when I need to type a password, to prevent it to be typed in another window which would “splash”…

I’d be just that bit cautious about naming your function “GrabFocus”, especially as there is a style option of the same name.

Don’t forget about “UpdateStyles”.

– Thomas Adam.

Hello Zonk,
I am novice to this domain. I am having the exactly same requirement but I am not sure how to do this changes in my system.

Do I have to create this function in my fvwm configuration. but how these function will be called when our login window lunched and closed?

This doesn’t answer your question, but I am utterly delighted to see that Fvwm has been going so long that one can have a forum discussion where a reply is dated “17 years later”.