Module Synchronisation (in Expose like function)

Hi!

I’m trying to do a quick hack for an Exposé-like function using FvwmRearrange. I know Exposé has been discussed in the forums before, but I do not want to use some CPU-consuming take-screenshot-of-all-windows programs and besides the issue here generalizes to other functions. What I have up to now:

DestroyFunc Expose
AddToFunc Expose
+ I SetEnv FVWMCountWindows 0
+ I All (CurrentPage, !Iconic, CirculateHit, !Sticky) PipeRead 'echo SetEnv FVWMCountWindows $((FVWMCountWindows + 1))'
+ I PipeRead 'echo ModuleSynchronous FvwmRearrange -tile -maximize -m -mn `echo -e "sqrt\($FVWMCountWindows\)+1" | bc`'
+ I Pick DeExpose $[w.id]

DestroyFunc DeExpose
AddToFunc DeExpose
+ I All (CurrentPage, !Iconic, CirculateHit, !Sticky) Maximize Off
+ I WindowId $0 WarpToWindow 50 50

The first funtion arranges the windows in a matrix and then should prompt the user to select a window. When this happens the windows return to their normal position and size (here is a problem with already maximized windows, I know, but it’s only a first try). My problem is that when I call the Expose function, I inmediately get the window selection cursor and only afterwards the windows get rearranged. I tried with the ModuleSynchronous command and with Schedule, but it doesn’t seem to work (at least reliably). Any ideas?

You will need to be much clearer in describing what it is that’s wrong, and what it is you’re after achieving. I can’t work out from your current description what it is you’re trying to do.

– Thomas Adam

Yes, perhaps it was not a clear description. I want to tile all the windows in the current page (!Iconic, etc.). Next, select a window (with the mouse). Then all the windows go back to their initial positions and sizes and the window I selected is raised and has focus.

This is what I implemented: The Expose function tiles the windows via FvwmRearrange. I do the window counting in order to tile the windows as a matrix, not all horizontally or vertically. I set the maximize flag on all windows (option in FvwmRearrange) in order to be able to go back to the initial positions and sizes[1].This works.

The function DeExpose unmaximizes all the windows (i.e. they go back to the initial sizes and positions) and warps to selected window. This works.

What doesn’t work right is the last line of the Expose function, i.e.

+ I Pick DeExpose $[w.id] 

It seems it gets executed before FvwmRearrange. That means, when I call Expose, I get the cursor for selecting a window (because of the Pick command, I expect). I select a window and then the windows get rearranged. The DeExpose function also gets executed (I inserted an Echo to see this), but also before FvwmRearrange, so that it doesn’t have any effect.

Footnotes:
[1] I know, there will be a problem here with already maximized windows, I will handle it when I get the rest working.

Hi ! This is my first post !!

First I want to say that the forum always gave me the answers I searched (thanks for all), but this time, I have the question but not its answer, so I decided not to create a new topic because I didn’t want to split the same question in 2 topics.

Anyway, I’ll try to explain it with my words.

I have 2 functions with shortcuts :

[code]Key F3 A M ExposeFunc
Key F5 A M NoWindow Pick DeExpose

DestroyFunc Expose
AddToFunc Expose

  • I PipeRead ‘echo ModuleSynchronous FvwmRearrange -tile -maximize -mn 2 -m $[EWMH-BS-Panel-Left]p 75p expr $[vp.width] - $[fvwm_icon_size]p expr $[vp.height] - 30p’

DestroyFunc DeExpose
AddToFunc DeExpose

  • I All (CurrentPage, !Iconic, CirculateHit, !Sticky) Maximize Off
  • I Pick Raise[/code]

I removed a lot from the davvil’s code but it still works :
Alt + F3 moves the windows in 2 columns
Alt + F5 change the cursor to make me focus the window I want and move back other windows

Ok, this works, but I wanted to do it with just 1 shortcut, so I did (or in fact took from davvil) this :

[code]Key F3 A M ExposeFunc

DestroyFunc ExposeFunc
AddToFunc ExposeFunc

  • I All (CurrentPage, !Iconic, CirculateHit, !Sticky) Expose
  • I NoWindow Pick DeExpose $[w.id][/code]

Now Alt + F3 does :

  • change the cursor to make me focus the window I want and move back other windows
  • moves the windows in 2 columns

So in fact, DeExpose is executed before Expose.
I tried some sleep or wait commands between the Expose and DeExpose but it doesn’t work.

Now, you guess my question (which is the same as the davvil’s one) :
How to make the Epose before the DeExpose ?

Here it is, my first post is a huge question, but I hope that you have a good answer.
thank you :slight_smile:

I’m really guessing here, but I believe the whole function is exec’d asynch, so put a piperead for all which need synch.
I don’t really understand why you’d need to Pick anything if mimicing Exposé (as opposed to DeExposé).

@Danou: If I understood you correctly, you really don’t need any complex functions with what you’re trying to do, plain Key F3 A M FvwmRearrange -tile should suffice for your needs. man FvwmRearrange will tell you more options.

Hmm, I had forgotten about this topic. Actually this is a bug/feature of FvwmRearrange. In order to get it working you have to modify the source code of FvwmRearrange by moving one line. I posted this here.

You do not need to install the whole fvwm from source, you can just compile it and copy the corresponding module, in case you want to use your distribution’s fvwm version.

morbusg : You didn’t understand. In fact I want DeExpose to work after Expose by itself. I don’t want to have 2 shortcuts, because Expose and DeExpose are supposed to be the same function.

davvil : ok, thanks. I’ll try to move the

SendFinishedStartupNotification(fd);

like you suggested.

I’ll also try to see SetSyncMask();

Maybe i’ll do it if I manage to understand SetSyncMask() (but i’m lazy -and still don’t have the level to do it- so I’ll just do your modification)

Thank you !

That is the way to go, really. I tried to make that clear in that older aforementioned post.

– Thomas Adam

It seems so.

I tried to move the function just before “return 0” and after, the function works…
But, roughly 1 time out of 5, the function makes FVWM block (only the cursor keeps working, but ctrl + alt + backspace is needed).
So I just took the Debian package and I forgot this function… But I hope I’ll try to understand SetSyncMask();

Thank you all :slight_smile:

I doubt that. Look at EscapeFunc.

– Thomas Adam

Ok, so I surely made a mistake or something like that…

Probably. Hard to say without seeing anything you’ve written.

– Thomas Adam

Here’s a stumper for you guys:

I modified the FvwmRearrange module like was posted, and the Expose function works great! There is one problem, though. It only works when I invoke it with the cursor over the root window.

According to the man page,

So when I invoke Expose to look for a window behind a maximized window, it just ends up re-raising the maximized window, defeating the whole purpose.

Is there any way of forcing pick to give me the targeting cursor? I tried using CursorMove to get the cursor to the screen edge before calling pick, but it doesn’t work for some reason. Am I going to have to modify the source? If so, which file is it in? I think I looked in conditional.h, and I didn’t find anything promising.

Thanks.

I can’t reproduce this, which doesn’t surprise me.

conditional.h is nowhere near accurate, and you’re woefully misunderstanding what’s happening. You certainly don’t need to modify anything.

The reason you’re being asked to select a window is due the whacking “NoWindow” command to always force context which Pick then works on, (Overkill, actually, but I never wrote it.)

You’re going to have to be more specific if you want help.

– Thomas Adam

Oh, sorry. Sure enough I had forgotten that I changed a few things. Here is the modified code I’m using:

[code]DestroyFunc Expose
AddToFunc Expose

  • I SetEnv FVWMCountWindows 0
  • I All (CurrentPage, !Iconic, CirculateHit, !Sticky) PipeRead ‘echo SetEnv FVWMCountWindows $((FVWMCountWindows + 1))’
  • I PipeRead ‘echo ModuleSynchronous FvwmRearrange -tile -maximize -m -mn echo -e "sqrt\($FVWMCountWindows\)+1" | bc; echo “Pick DeExpose \$[w.id]”’

DestroyFunc DeExpose
AddToFunc DeExpose

  • I All (CurrentPage, !Iconic, CirculateHit, !Sticky) Maximize Off
  • I WindowId $0 WarpToWindow 50 50[/code]

If I understand correctly, the trick to getting the crosshairs to show up after the windows are tiled is to make the pick command execute after the FvwmRearrange command by putting both in a PipeRead. This is because PipeRead is forcing the commands to be run sequentially. (Correct me if I’m wrong!) The hard part was remembering to double-escape the dollar sign. 8)

The problem, however, is this:

I call the Expose command with F3.

Key F3 A N Expose

When I press F3 with my mouse over root, the command works as expected. The windows tile themselves, I get some nice crosshairs, I select a window, and all the windows restore themselves, except for the selected window, which appears on top. It’s lovely.

However, when I press F3 with my mouse over a window, it fails. The windows tile themselves and then immediately restore themselves, except the the window that was under the mouse when I pressed F3 gets sent to the top. This is useless to me.

You mentioned “NoWindow”. Unfortunately, it was in a sentence that was impossible for my non-British brain to parse. (Is whacking being used as a verb or an expletive?) I tried inserting NoWindow at various points in the function, but I’m pretty sure it is negating the result of the Pick and …

Ok, nevermind, I got it working as I was writing this post. The trick was to put NoWindow in the Key command.

Key F3 A N NoWindow Expose

Thanks for your help. :smiley:

See – psychic I am not.

You’re not wrong, but that sentence doesn’t explain it in any great detail. Do search these forums for further information though if you’re interested – I won’t repeat it here since I am sick of repeating the same information.

Because in your modified version of the Expose function, you’re running everything in the PipeRead at once in an already established window context. This is why you’re seeing the results you do with the mouse pointer being over a window. Because All wants a non-root window context to work, if it doesn’t find one, it will ask you for one.

This assumption leads me to believe you’re not using sloppyfocus, but someething like mousefocus or clicktofocus instead.

I mentioned NoWindow because it explain what you were seeing in the original function, not the butchered one you have only revealed until now. :wink:

And yes, again, using:

NoWindow somefunction

Will always force context. It’s a corner-case, but this is why it’s useful.

– Thomas Adam

Hey !

This seems cool krispyfi !
I tried it but… It doesn’t work… because I think I don’t have your version of the module (I actually run the fvwm’s Debian package fvwm 2.5.25 compiled on Mar 19 2008). How Do I get it ?
Will this version be in the official version one day ?

Thank you :slight_smile:

The solution isn’t correct, so I hope it won’t make it into FvwmRearrange anytime soon.

As for how you can mangle it for yourself, just follow the instructions.

– Thomas Adam