[Perl] Move foo near bar

Mickae
Kitten
Kitten
Posts: 4
Joined: Thu Jun 02, 2016 2:45 pm

[Perl] Move foo near bar

Postby Mickae » Thu Jun 02, 2016 3:05 pm

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 :). 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 !!

User avatar
TF
Moderator
Moderator
Posts: 245
Joined: Sat Sep 10, 2005 12:30 am
Location: Germany
Contact:

Re: [Perl] Move foo near bar

Postby TF » Thu Jun 02, 2016 3:50 pm

Mickae wrote:I need to find the position x/y of the window I want to be close, let's call it bar :). 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.
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe." -- Albert Einstein
Fvwm version: 2.6.5
Fvwm config: Fvwm-Nightshade

thomasadam
Administrator
Administrator
Posts: 3037
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: [Perl] Move foo near bar

Postby thomasadam » Thu Jun 02, 2016 4:02 pm

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:

Code: Select all

Style application_i_want_near_to_another_one InitialMapCommand SomeFunc

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


-- Thomas Adam

Mickae
Kitten
Kitten
Posts: 4
Joined: Thu Jun 02, 2016 2:45 pm

Re: [Perl] Move foo near bar

Postby Mickae » Thu Jun 02, 2016 5:40 pm

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.

Michael

thomasadam
Administrator
Administrator
Posts: 3037
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: [Perl] Move foo near bar

Postby thomasadam » Thu Jun 02, 2016 5:56 pm

Mickae wrote: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.

Michael


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

-- Thomas Adam

Mickae
Kitten
Kitten
Posts: 4
Joined: Thu Jun 02, 2016 2:45 pm

Re: [Perl] Move foo near bar

Postby Mickae » Fri Jun 03, 2016 3:57 pm

Hi,

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...

Michael

phleagol
Cat in the hat
Cat in the hat
Posts: 39
Joined: Sun Nov 24, 2013 1:19 pm
Location: New Zealand

Re: [Perl] Move foo near bar

Postby phleagol » Tue Jun 07, 2016 8:11 am

Mickae wrote:I used Manual placement style for * and those windows wasn't affected by this policy placement.

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.

Code: Select all

BugOpts ExplainWindowPlacement on

thomasadam
Administrator
Administrator
Posts: 3037
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: [Perl] Move foo near bar

Postby thomasadam » Tue Jun 07, 2016 2:07 pm

phleagol wrote:
Mickae wrote:I used Manual placement style for * and those windows wasn't affected by this policy placement.

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.

Code: Select all

BugOpts ExplainWindowPlacement on


This won't help for transient windows.

thomasadam
Administrator
Administrator
Posts: 3037
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: [Perl] Move foo near bar

Postby thomasadam » Tue Jun 07, 2016 2:07 pm

Mickae wrote:Hi,

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...

Michael


Put your config somewhere for me to see, please.

-- Thomas Adam

Mickae
Kitten
Kitten
Posts: 4
Joined: Thu Jun 02, 2016 2:45 pm

Re: [Perl] Move foo near bar

Postby Mickae » Mon Aug 08, 2016 4:56 pm

Sorry I can't,

here's what i did :

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

use lib '/<to your perl libs>/';
use FVWM::Module;

my $module = FVWM::Module->new(
Debug => 1,
);
#
$module->showMessage("$0 starting up");
my $tracker=$module->track("WindowList");
$tracker->stop;
sub m_track_window_move
{
my $mod = shift; # FVWM::Module object
my $event = shift; # FVWM::Event object
#
# get the actual window added
#
$tracker->start;
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 );
}
}
$tracker->stop;
}
$module->addHandler( M_ADD_WINDOW , \&m_foo_window_move );
$module->event_loop or die "Module $0 is dead";


Return to “Other languages”

Who is online

Users browsing this forum: No registered users and 1 guest