Window management: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Add a Perl 6 example)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 709: Line 709:
}
}
</lang>
</lang>



=={{header|Julia}}==
=={{header|Julia}}==
Line 1,108: Line 1,107:


Doubtless some more modern Tk binding (such as Tkx, or perhaps Tcl::Tk) would handle that better.
Doubtless some more modern Tk binding (such as Tkx, or perhaps Tcl::Tk) would handle that better.

=={{header|Perl 6}}==
{{works with|Rakudo|2018.12}}
This are generic window handling routines. They work for any window managed by the X11 display server, not just windows created by the program.

<lang perl6>use X11::libxdo;

my $xdo = Xdo.new;

say 'Visible windows:';
printf "Class: %-21s ID#: %10d pid: %5d Name: %s\n", $_<class ID pid name>
for $xdo.get-windows.sort(+*.key)».value;
sleep 2;

my $id = $xdo.get-active-window;

my ($w, $h ) = $xdo.get-window-size( $id );
my ($wx, $wy) = $xdo.get-window-location( $id );
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 );

$xdo.move-window( $id, 150, 150 );

$xdo.set-window-size( $id, 350, 350, 0 );

sleep .25;

for flat 1 .. $dw - 350, $dw - 350, {$_ - 1} … 1 -> $mx { #
my $my = (($mx / $dw * τ).sin * 500).abs.Int;
$xdo.move-window( $id, $mx, $my );
$xdo.activate-window($id);
}

sleep .25;

$xdo.move-window( $id, 150, 150 );

my $dx = $dw - 300;
my $dy = $dh - 300;

$xdo.set-window-size( $id, $dx, $dy, 0 );

sleep .25;

my $s = -1;

loop {
$dx += $s * ($dw / 200).ceiling;
$dy += $s * ($dh / 200).ceiling;
$xdo.set-window-size( $id, $dx, $dy, 0 );
$xdo.activate-window($id);
sleep .005;
$s *= -1 if $dy < 200;
last if $dx >= $dw;
}

sleep .25;

$xdo.set-window-size( $id, $w, $h, 0 );
$xdo.move-window( $id, $wx, $wy );
$xdo.activate-window($id);

sleep .25;

$xdo.minimize($id);
$xdo.activate-window($id);
sleep 1;
$xdo.raise-window($id);
sleep .25;
</lang>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,419: Line 1,349:
</lang>
</lang>


=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2018.12}}
This are generic window handling routines. They work for any window managed by the X11 display server, not just windows created by the program.


<lang perl6>use X11::libxdo;

my $xdo = Xdo.new;

say 'Visible windows:';
printf "Class: %-21s ID#: %10d pid: %5d Name: %s\n", $_<class ID pid name>
for $xdo.get-windows.sort(+*.key)».value;
sleep 2;

my $id = $xdo.get-active-window;

my ($w, $h ) = $xdo.get-window-size( $id );
my ($wx, $wy) = $xdo.get-window-location( $id );
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 );

$xdo.move-window( $id, 150, 150 );

$xdo.set-window-size( $id, 350, 350, 0 );

sleep .25;

for flat 1 .. $dw - 350, $dw - 350, {$_ - 1} … 1 -> $mx { #
my $my = (($mx / $dw * τ).sin * 500).abs.Int;
$xdo.move-window( $id, $mx, $my );
$xdo.activate-window($id);
}

sleep .25;

$xdo.move-window( $id, 150, 150 );

my $dx = $dw - 300;
my $dy = $dh - 300;

$xdo.set-window-size( $id, $dx, $dy, 0 );

sleep .25;

my $s = -1;

loop {
$dx += $s * ($dw / 200).ceiling;
$dy += $s * ($dh / 200).ceiling;
$xdo.set-window-size( $id, $dx, $dy, 0 );
$xdo.activate-window($id);
sleep .005;
$s *= -1 if $dy < 200;
last if $dx >= $dw;
}

sleep .25;

$xdo.set-window-size( $id, $w, $h, 0 );
$xdo.move-window( $id, $wx, $wy );
$xdo.activate-window($id);

sleep .25;

$xdo.minimize($id);
$xdo.activate-window($id);
sleep 1;
$xdo.raise-window($id);
sleep .25;
</lang>


=={{header|Ring}}==
=={{header|Ring}}==
Line 1,578: Line 1,576:


</lang>
</lang>



=={{header|Tcl}}==
=={{header|Tcl}}==