New Expo Function (+ binding problem)

Hi,

I’ve just written Expo function and here is a code I you want to try it.

[code]DestroyFunc Expose
AddToFunc Expose

  • I All (CurrentPage, !Iconic, !Sticky, !Shaded) PipeRead
    ‘echo “$[w.id] $[w.width] $[w.height] $[w.x] $[w.y]” >> $[FVWM_USERDIR]/.expose_temp’
  • I TestRc (Match) PipeRead ‘$[FVWM_USERDIR]/scripts/expose.py expose $[FVWM_USERDIR]/.expose_temp’
  • I NoWindow Pick DeExpose $[w.id]

DestroyFunc DeExpose
AddToFunc DeExpose

  • I PipeRead ‘$[FVWM_USERDIR]/scripts/expose.py dexpose $[FVWM_USERDIR]/.expose_temp $0’
  • I Test (F $[FVWM_USERDIR]/.expose_temp) Exec exec rm -f $[FVWM_USERDIR]/.expose_temp[/code]

And Python’s script for this:

[code]#!/use/bin/env python

author: Bartosz SKOWRON hack at bartskowron dot com

licence: GPL2

####################################

XXX set you screen resolution here

SCREEN_X = 1400
SCREEN_Y = 1050
WIDTH = 300
HEIGHT = 220
SPACE_X = 10
SPACE_Y = 20
START_X = SPACE_X
START_Y = 100
####################################

import sys

if len(sys.argv) < 3:
sys.stderr.write(‘Wrong arguments!\n’)
sys.exit(-1)

parsing file

fh = open(sys.argv[2])
win = {}
for line in fh.readlines():
line = line.split()
win[line[0]] = [ int(i) for i in line[1:] ]
fh.close()

if sys.argv[1] == ‘expose’:
x = START_X
y = START_Y
for w in win:
# resizing
print “WindowId %s Resize %dp %dp” % (w, WIDTH, HEIGHT)
# moving
if x + WIDTH + SPACE_X > SCREEN_X:
x = START_X
y += HEIGHT + SPACE_Y
print “WindowId %s Move %dp %dp” % (w, x, y)
x += WIDTH + SPACE_X
elif sys.argv[1] == ‘dexpose’:
for w in win:
print “WindowId %s ResizeMove %dp %dp %dp %dp” % (w, win[w][0], win[w][1], win[w][2], win[w][3])

print "WindowId %s Raise" % sys.argv[3]
print "WindowId %s Focus" % sys.argv[3][/code]

Ok, so this function works very well [1]. If you would like to have animation, use AnimatedMove istead Move.

It works, if I call it from FvwmConsole.
I bound this in this way:

Key E       A       4   Expose

And it doesn’t work from my shortcut.
After pressing Win+E all lines in tempory file are reference only to focused window (number of entries in the file is number of windows on current page) and I get “picking pointer”. What is wrong? Why it works from FvwmConsole?

Another question is about removing temp file. I remove it in DeExpose function but better solution is to remove it at the beginning of Expose func.

+ I Test (F $[FVWM_USERDIR]/.expose_temp) Exec exec rm -f $[FVWM_USERDIR]/.expose_temp

I tried this, and it seems like it works parallely with next function.
So I tried something like:

PipeRead ' if [ -f $FVWM_USERDIR/.expose_temp ]; then rm -f $FVWM_USERDIR/.expose_temp; fi

But after this I should write && and next function…but next function is treating to All windows so I can’t do that and it’s confusing me.

[1] There should be some improvement if it goes about how to fit all windows on the screen. If there will be too many windows there is a problem. There should be checking of how many window we have to resize and then fix width and height of resizing windows. I don’t need it, cause I don’t use more than 4-5 windows per Page. If anyone need is, let me know, I will add 2-3 lines for this issue.

Because of the referenced window. You need to try:

Key E       A       4   NoWindow Expose

– Thomas Adam

Damn! I read email with the same issue yesterday, how could i forget about it?
It works!

How about removing temp file problem?

Ahem. I need to clarify this.

Your problem is Key now is an operator as well. Hence:

DestroyFunc Expose
AddToFunc Expose
+ I All (CurrentPage, !Iconic, !Sticky, !Shaded) PipeRead \
'echo "$$$$[w.id] $$$$[w.width] $$$$[w.height] $$$$[w.x] $$$$[w.y]" >> $[FVWM_USERDIR]/.expose_temp'
+ I TestRc (Match) PipeRead '$[FVWM_USERDIR]/scripts/expose.py expose $[FVWM_USERDIR]/.expose_temp'
+ I NoWindow Pick DeExpose $[w.id]

Note the $$$$ to allow for correct expansion.

– Thomas Adam

See my last post.

– Thomas Adam

OK, I use $$$$ instead of NoWindow Expose while binding. But both solutions work!

And I don’t see connection between $$$$ and how to remove temp file at the beginning of Expose function (or I’m so dump).

I found a little bug:

$[w.width] $[w.height] $[w.x] $[w.y]

before expose:
[FVWM][Echo]: 1138 847 185 137

after expose:
[FVWM][Echo]: 1142 871 185 137

Why windows are bigger than they should?

Of course. It’s good that I can sit here and just dispense all this crap, but can you tell me why they work, and what’s happening? [1]

See [1]. Ultimately you’ve answered your own question:

+ I Test (F $[FVWM_USERDIR]/.expose_temp) Exec exec rm -f $[FVWM_USERDIR]/.expose_temp

What is it that’s not working with this?

– Thomas Adam

[1] If not, just ask. I’ll be pointing you to the other three threads on these forums detailing it.

Gee. I wonder if it’s to do with your moving and resizing windows in your python script?

– Thomas Adam

NoWindow Expose - removes window contexts before calling Expose func
$$$$ - expands variables in correct way for All

2 different ways for the same problem.
But, sure, you can point me to 3 threads, I really like to read good articles.

I misunderstand you.

Go ahead! I really like to read :slight_smile:

What is wrong there?

I store w.width, w.height, w.x, w.y of the window
and after exposing trying to restory by this function:

ResizeMove widthp heightp xp yp

and i don’t change values of stored window’s params. something wrong with ResizeMove?

What is it you’re doing now which makes you think those files aren’t being removed?

You’re answering your own question here. I’m not sure how else I can phrase my answer.

– Thomas Adam

It removes that file. The problem is, that the next function starts work before removing is finished.

Example of 5 windows:

line 1
line 2
line 3
removing file
line 1
line 2

so, 3 lines miss

Just say me, what is wrong with my ResizeMove function. Do I use it in wrong way? Or better, how to restore geometry of window exactly the same before moving/resizing?

Yes - a race condition.

Use PipeRead.

PipeRead `[ -f somefile ] && rm somefile && echo SomeFvwmFunctionToRun`

Don’t bother. Use ResizeMoveMaximize and Unmaximize the window to put it back in its place. Much easier than storing a whole load of data about where a window was, when unmaximizing a window puts it back in its place.

– Thomas Adam

Oh :slight_smile: Why didn’t you say about this function earlier? :slight_smile:

So, it works very nice and I’m try to rewrite this to use just PipeRead

[code]DestroyFunc Expose
AddToFunc Expose

  • I SetEnv SCREEN_X 1400
  • I SetEnv SCREEN_Y 1050
  • I SetEnv WIDTH 300
  • I SetEnv HEIGHT 220
  • I SetEnv SPACE_X 10
  • I SetEnv SPACE_Y 30
  • I SetEnv START_X 10
  • I SetEnv x $[START_X]
  • I SetEnv y 100
  • I All (CurrentPage, !Iconic, !Sticky, !Shaded) PipeRead
    ‘if [ $[x]+$[WIDTH]+$[SPACE_X] > $[SCREEN_X] ]; then echo “SetEnv x $[START_X]”;
    echo “SetEnv y $(($[y] + $[HEIGHT] + $[SPACE_Y]))”;
    fi && echo “ResizeMoveMaximize $[WIDTH]p $[HEIGHT]p $[x]p $[y]p”
    ; echo “SetEnv x $(($[x] + $[WIDTH] + $[SPACE_X]))”’
  • I NoWindow Pick DeEx $[w.id][/code]

and it seems like piperead works parallely for all windows, so that changes of $[x] and $[y] don’t impact on other windows (all of them use default x=10, y=100)

What’s with all the SetEnv stuff? Not only are you hard-coding values which you can ascertain directly from within FVWM such as what’s stored in SCREEN_X and SCREEN_Y in your example (c.f. the values of $[vp.x] and $[vp.y]), but you never seem to UnSetEnv these variables at the end of the function.

viewtopic.php?f=40&t=1505

– Thomas Adam

I have UnSetEnv too, I didn’t paste whole code.

The meaning of my SCREEN_X and SCREEN_Y is to set a box on screen where you want to fit whole windows (personally I like whole screen).

So, how to hack this PipeRead to get sequence of windows (to keep $[x] and $[y] dependent from window to window)?
I use temp file to have it, but if it’s better idea, let me know!

It seems like fvwm sucks for critical section. Or there isn’t critical section at all.

Your English fails you here – can you please rephrase this?

– Thomas Adam

Your English fails you here – can you please rephrase this?

– Thomas Adam

+ I All (CurrentPage, !Iconic, !Sticky, !Shaded) PipeRead \ 'if [ $[x]+$[WIDTH]+$[SPACE_X] > $[SCREEN_X] ]; then echo "SetEnv x $[START_X]"; \ echo "SetEnv y $(($[y] + $[HEIGHT] + $[SPACE_Y]))"; \ fi && echo "ResizeMoveMaximize $[WIDTH]p $[HEIGHT]p $[x]p $[y]p" \ ; echo "SetEnv x $(($[x] + $[WIDTH] + $[SPACE_X]))"'

I wish to run this is function in serial mode.
win1 -> win2 -> … -> winN
because, there are $[x] and $[y], and they should be calculate for every window (values of them depend on values from previous window).

now, it works like this functin runs for all windows in the same time, so for every windows there are they same value of $[x] and $[y].

so it’s look like it works in concurrently mode. and it’s ok. but there isn’t critical section[1], so there is problem with synchronisation…

[1] i’m not sure if this is english term, i translated it directly from polish. but i mean about semaphores, mutexes and stuff like that. you’re smart - you know what i’m talking about :slight_smile: