[Perl] Move foo near bar

Hi !

I’d like to move a window, when it’s added, close to another window.
In my perl module I catch the M_ADDWINDOW event and I wrote an handler to do some actions.

I need to find the position x/y of the window I want to be close, let’s call it bar :slight_smile:. So the only thing I know is the name of the window i want to be close to , and the window added, called foo.

To be clear When a window foo is created I want to move it close to the window bar.

All ideas are very welcome !!

Have a look into FvwmMaximize.

xprop could help.

– Thomas –

Btw. Have moved your post to "Other languages’ because it’s not FvwmScript.

I wouldn’t bother with FvwmMaximize.

If you want to use perllib for this, look at the WindowTracker module to get information about other windows, and do the calculation that way.

Alternatively, you could just do something like:

Style application_i_want_near_to_another_one InitialMapCommand SomeFunc

DestroyFunc SomeFunc
AddToFunc   SomeFunc
+ I Next (TheOtherApplication) PipeRead ` .... `

– Thomas Adam

Hi again

WindowTracker is doing good job thanks a lot for your support !!!

I did it with Perl because I’m moving java Transient windows and i can’t manage it with fvwm config but maybe i did it wrong with config file.


Almost certainly you are doing it wrong. What had you tried doing before?

– Thomas Adam


I used Manual placement style for * and those windows wasn’t affected by this policy placement. So i conclude that transient windows wasn’t handled the same way…


So your window placement isn’t as expected. You might add this to your config, and then look at ~/.xsession-errors for details about window placement.

BugOpts ExplainWindowPlacement on

This won’t help for transient windows.

Put your config somewhere for me to see, please.

– Thomas Adam

Sorry I can’t,

here’s what i did :

#! /usr/bin/perl -w
use strict;

use lib ‘//’;
use FVWM::Module;

my $module = FVWM::Module->new(
Debug => 1,

$module->showMessage("$0 starting up");
my $tracker=$module->track(“WindowList”);
sub m_track_window_move
my $mod = shift; # FVWM::Module object
my $event = shift; # FVWM::Event object

get the actual window added

    my $windowid = $event->{arg_values}[0];
    if (  defined $tracker->data("$windowid") ){
            my $addedWindow = $tracker->data("$windowid")->{visible_name} ;
            if ( $addedWindow =~ /^foo/ ){
                    $mod->send( 'move $[pointer.x]p $[pointer.y]p', $windowid );

$module->addHandler( M_ADD_WINDOW , &m_foo_window_move );
$module->event_loop or die “Module $0 is dead”;