Tapio Luukkanen
2014-09-14 14:00:21 UTC
Hello all,
Question 1: I probably should have asked publicly before starting to
experiment with the approach outlined here -- is there any cleaner,
already existing way to achieve these "goals"?
So ... I was experimenting with the PipeRead command to create a
"smart" scroll-wheel-based non-interactive window resizing mechanism
that would choose the edge where the resize occurs based on where the
window midpoint is located on the screen (eventually using maybe other
criteria as well).
The initial goal of this "smartness" was this: if the window midpoint is
in the "left half" of screen, its left edge should stay in place. If in the
"right half", then the right edge, and similarly for "top half" and top
edge, "bottom half" and bottom edge.
To achieve this, wrote a shell script ("fvwm-resizer-tool") that is passed
some fvwm state, and the script then emits commands for PipeRead:
## Resize using default increments in 'fvwm-resizer-tool'
Mouse 4 WT CS ResizerFunc y_minus
Mouse 5 WT CS ResizerFunc y_plus
Mouse 4 WT C4 ResizerFunc x_minus
Mouse 5 WT C4 ResizerFunc x_plus
## Resize with explicit size changes
Mouse 4 WT CSM ResizerFunc y_minus w-20c
Mouse 5 WT CSM ResizerFunc y_plus w+20c
Mouse 4 WT C4M ResizerFunc x_minus w-20c
Mouse 5 WT C4M ResizerFunc x_plus w+20c
DestroyFunc ResizerFunc
AddToFunc ResizerFunc
+ I ThisWindow PipeRead "fvwm-resizer-tool \
desk $[desk.n] \
deskpages $[desk.pagesx] $[desk.pagesy] \
deskwidhei $[desk.width] $[desk.height] \
page $[page.nx] $[page.ny] \
pages $[page.pagesx] $[page.pagesy] \
ewmh-wa $[wa.x] $[wa.y] $[wa.width] $[wa.height] \
ewmh-dwa $[dwa.x] $[dwa.y] $[dwa.width] $[dwa.height] \
win $[w.id] \
win-xy $[w.x] $[w.y] win-widhei $[w.width] $[w.height] \
cw-xy $[cw.x] $[cw.y] cw-widhei $[cw.width] $[cw.height] \
pointer-xy $[pointer.x] $[pointer.y] \
pointer-wxy $[pointer.wx] $[pointer.wy] pointer-cxy
$[pointer.cx] $[pointer.cy] \
vp-xy $[vp.x] $[vp.y] vp-widhei $[vp.width] $[vp.height] \
-resize $[*] "
The shell script parses these arguments and eventually emits commands
like these:
ResizeMove KeepRight w-20c keep ## reduce width, keep right edge
in place
ResizeMove KeepBottom keep w+25c ## increase height, keep bottom in
place
Resize keep w+25c ## increase height normally
Resize w-20c keep ## decrease width normally
To implement these new options KeepBottom and KeepRight for
"ResizeMove" move_resize.c and geometry.c needed to be patched
slightly (please contact if interested).
Question 1 restated: can anyone suggest better approaches?
Question 2:
Another (somewhat unrelated) thing to note (from the ResizerFunc call
above) is that I can't seem to find a way to pass the variables
$[page.nx] and $[page.ny] to the script as anything else than "0 0" --
they are maybe expanded at the time when the .fvwm2rc script is being
evaluated?
So, is there a way to ensure $[page.nx] and $[page.ny] are evaluated
"lazily" at
function call time, to have their correct values for example when I am
"viewing page 1 7"?
--Tapio
Question 1: I probably should have asked publicly before starting to
experiment with the approach outlined here -- is there any cleaner,
already existing way to achieve these "goals"?
So ... I was experimenting with the PipeRead command to create a
"smart" scroll-wheel-based non-interactive window resizing mechanism
that would choose the edge where the resize occurs based on where the
window midpoint is located on the screen (eventually using maybe other
criteria as well).
The initial goal of this "smartness" was this: if the window midpoint is
in the "left half" of screen, its left edge should stay in place. If in the
"right half", then the right edge, and similarly for "top half" and top
edge, "bottom half" and bottom edge.
To achieve this, wrote a shell script ("fvwm-resizer-tool") that is passed
some fvwm state, and the script then emits commands for PipeRead:
## Resize using default increments in 'fvwm-resizer-tool'
Mouse 4 WT CS ResizerFunc y_minus
Mouse 5 WT CS ResizerFunc y_plus
Mouse 4 WT C4 ResizerFunc x_minus
Mouse 5 WT C4 ResizerFunc x_plus
## Resize with explicit size changes
Mouse 4 WT CSM ResizerFunc y_minus w-20c
Mouse 5 WT CSM ResizerFunc y_plus w+20c
Mouse 4 WT C4M ResizerFunc x_minus w-20c
Mouse 5 WT C4M ResizerFunc x_plus w+20c
DestroyFunc ResizerFunc
AddToFunc ResizerFunc
+ I ThisWindow PipeRead "fvwm-resizer-tool \
desk $[desk.n] \
deskpages $[desk.pagesx] $[desk.pagesy] \
deskwidhei $[desk.width] $[desk.height] \
page $[page.nx] $[page.ny] \
pages $[page.pagesx] $[page.pagesy] \
ewmh-wa $[wa.x] $[wa.y] $[wa.width] $[wa.height] \
ewmh-dwa $[dwa.x] $[dwa.y] $[dwa.width] $[dwa.height] \
win $[w.id] \
win-xy $[w.x] $[w.y] win-widhei $[w.width] $[w.height] \
cw-xy $[cw.x] $[cw.y] cw-widhei $[cw.width] $[cw.height] \
pointer-xy $[pointer.x] $[pointer.y] \
pointer-wxy $[pointer.wx] $[pointer.wy] pointer-cxy
$[pointer.cx] $[pointer.cy] \
vp-xy $[vp.x] $[vp.y] vp-widhei $[vp.width] $[vp.height] \
-resize $[*] "
The shell script parses these arguments and eventually emits commands
like these:
ResizeMove KeepRight w-20c keep ## reduce width, keep right edge
in place
ResizeMove KeepBottom keep w+25c ## increase height, keep bottom in
place
Resize keep w+25c ## increase height normally
Resize w-20c keep ## decrease width normally
To implement these new options KeepBottom and KeepRight for
"ResizeMove" move_resize.c and geometry.c needed to be patched
slightly (please contact if interested).
Question 1 restated: can anyone suggest better approaches?
Question 2:
Another (somewhat unrelated) thing to note (from the ResizerFunc call
above) is that I can't seem to find a way to pass the variables
$[page.nx] and $[page.ny] to the script as anything else than "0 0" --
they are maybe expanded at the time when the .fvwm2rc script is being
evaluated?
So, is there a way to ensure $[page.nx] and $[page.ny] are evaluated
"lazily" at
function call time, to have their correct values for example when I am
"viewing page 1 7"?
--Tapio