cvsimport
[fvwm.git] / modules / FvwmCommand / scripts / ex-grpmv.pl
bloba6eb9b4a9ba4d74f971c41c7c84fb25434963567
1 #! xPERLx
2 # FvwmCommand example - move a group of windows
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ask();
22 open( FCM, "FvwmCommand -m -i3 |" ) || die "$! FvwmCommand";
23 open( FCC, ">$ENV{'HOME'}/.FvwmCommandC" ) || die "FCC";
24 select( FCC ); $| = 1;
25 select( STDOUT ); $| = 1;
27 while( <FCM> ) {
28 if( /^0x(\S+) frame +x (\d+), y (\d+)/ ) {
29 # check if a member window is moved
30 ($id,$x,$y) = ($1,$2,$3);
32 if( defined $Config{$id} ) {
33 foreach $w (keys %Config) {
34 $newx = $x + $Config{$w}{'x'}-$Config{$id}{'x'};
35 $newy = $y + $Config{$w}{'y'}-$Config{$id}{'y'};
36 if( $newx < 0 ) {
37 $newx = 0;
39 if( $newy < 0 ) {
40 $newy = 0;
42 print FCC "windowid 0x$w move ${newx}p ${newy}p\n";
44 # ignore - pixel info is the last info for move
45 while(<FCM>) {
46 last if /^0x$w pixel/;
48 select(undef,undef,undef,0.1);
56 sub ask {
57 my($k,$c,$w, $mark);
59 # list up windows
60 open( FCM, "FvwmCommand -i2 send_windowlist |" ) || die "$! FvwmCommand";
61 while( <FCM> ) {
62 if( /^0x(\S+) (id|window) +(.*)/ ) {
63 $Config{$1}{$2} = $3;
64 }elsif( /^0x(\S+) frame +x (\d+), y (\d+)/ ) {
65 $Config{$1}{'x'} = $2;
66 $Config{$1}{'y'} = $3;
69 close( FCM );
71 $k = 'a';
72 foreach $w (keys %Config) {
73 $win{$k++} = $w;
74 $Config{$w}{'grp'} = 0;
76 while(1) {
77 print "\nWhich windwow to group (* for all, ENTER to Start)?\n";
78 foreach $k (keys %win) {
79 $mark = $Config{$win{$k}}{'grp'} ? 'X':' ';
80 print "($k) ($mark) $Config{$win{$k}}{'window'}\n";
83 system "stty -icanon min 1 time 0";
84 $c = getc();
85 system "stty icanon";
87 if( $c eq '*' ) {
88 foreach(keys %win) {
89 $Config{$_}{'grp'} = 1;
91 }elsif( $c eq "\n" ) {
92 last;
93 }elsif( !grep( /$c/,keys %win) ) {
94 print "\aUndefine process\n";
95 }else{
96 $Config{$win{$c}}{'grp'} = ! $Config{$win{$c}}{'grp'};
100 print "Group move on effect\n";
101 foreach $w (keys %Config) {
102 delete $Config{$w} if $Config{$w}{'grp'}!=1;