J
JiggaHertz
I'm trying to use the ptk_steal script that I found on the
comp.lang.perl.tk group and I'm getting 2 individual windows instead of
an xterm inside of a tk frame. Here's the output of xwininfo for those
windows:
# xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x1c0000d "WindowToSteal"
Absolute upper-left X: 270
Absolute upper-left Y: 270
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 499
Height: 316
Depth: 8
Visual Class: PseudoColor
Border width: 0
Class: InputOutput
Colormap: 0x34 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +270+270 -831+270 -831-614 +270-614
-geometry 80x24+264+240
# xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x1b80004 "Ptk_steal"
Absolute upper-left X: 16
Absolute upper-left Y: 40
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 96
Height: 21
Depth: 8
Visual Class: PseudoColor
Border width: 0
Class: InputOutput
Colormap: 0x34 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +16+40 -1488+40 -1488-1139 +16-1139
-geometry 96x21+10+10
I've verified that the window id from the xterm "WindowToSteal" is
correct. I included the ptk_steal.pl script as reference. Any help
would be greatly appreciated.
Thanks,
JH
==================================================================
#!/usr/bin/perl
# $Id: ptk_steal.pl,v 1.1 1999/07/01 19:56:31 eserte Exp $
# Author: Slaven Rezic
# Copyright (C) 1999 Slaven Rezic. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
# Mail: (e-mail address removed)-berlin.de
# WWW: http://user.cs.tu-berlin.de/~eserte/#
use Tk;
use X11:rotocol;
$x = X11:rotocol->new();
$top = MainWindow->new;
system("xterm -name WindowToSteal &");
$check = $top->repeat(
50,
sub {
$wid = get_window_by_name("WindowToSteal");
}
);
while ( !defined $wid ) {
$top->waitVariable( \$wid );
}
$check->cancel;
warn sprintf("Window id: %x\n", $wid);
$top->geometry("+10+10");
$top->Label( -text => "A xterm:" )->pack;
if ( $Tk::VERSION >= 800 ) {
$f = $top->Frame( '-container' => 1 )->pack;
}
else {
$f = $top->Frame( -width => 500, -height => 400 )->pack;
}
warn sprintf("Resized main frame\n");
$f->update;
warn sprintf("Updated main frame\n");
$test = $x->ReparentWindow( $wid, oct( $f->id ), 0, 0 );
$x->MapWindow($wid);
warn sprintf("Reparent Window done\n");
warn sprintf("test = $test\n");
sub get_window_by_name {
_get_window_by_name( $x->{'root'}, $_[0] );
}
sub _get_window_by_name {
my ( $root, $searchname ) = @_;
my ( $dummy, $dummy2, @new_kids ) = $x->QueryTree($root);
foreach my $k (@new_kids) {
my $atomnr;
#warn sprintf("%x\n", $k);
foreach my $atom ( $x->ListProperties($k) ) {
if ( $x->GetAtomName($atom) eq "WM_CLASS" ) {
$atomnr = $atom;
last;
}
}
if ( defined $atomnr ) {
my ($classprop) =
$x->GetProperty( $k, $atomnr, "AnyPropertyType", 0, 256, 0
);
my ( $class, $name ) = split( /\0/, $classprop );
if ( $class eq $searchname ) {
return $k;
}
}
my $ret = _get_window_by_name( $k, $searchname );
if ( defined $ret ) {
return $ret;
}
}
undef;
}
MainLoop;
__END__
comp.lang.perl.tk group and I'm getting 2 individual windows instead of
an xterm inside of a tk frame. Here's the output of xwininfo for those
windows:
# xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x1c0000d "WindowToSteal"
Absolute upper-left X: 270
Absolute upper-left Y: 270
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 499
Height: 316
Depth: 8
Visual Class: PseudoColor
Border width: 0
Class: InputOutput
Colormap: 0x34 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +270+270 -831+270 -831-614 +270-614
-geometry 80x24+264+240
# xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x1b80004 "Ptk_steal"
Absolute upper-left X: 16
Absolute upper-left Y: 40
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 96
Height: 21
Depth: 8
Visual Class: PseudoColor
Border width: 0
Class: InputOutput
Colormap: 0x34 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +16+40 -1488+40 -1488-1139 +16-1139
-geometry 96x21+10+10
I've verified that the window id from the xterm "WindowToSteal" is
correct. I included the ptk_steal.pl script as reference. Any help
would be greatly appreciated.
Thanks,
JH
==================================================================
#!/usr/bin/perl
# $Id: ptk_steal.pl,v 1.1 1999/07/01 19:56:31 eserte Exp $
# Author: Slaven Rezic
# Copyright (C) 1999 Slaven Rezic. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
# Mail: (e-mail address removed)-berlin.de
# WWW: http://user.cs.tu-berlin.de/~eserte/#
use Tk;
use X11:rotocol;
$x = X11:rotocol->new();
$top = MainWindow->new;
system("xterm -name WindowToSteal &");
$check = $top->repeat(
50,
sub {
$wid = get_window_by_name("WindowToSteal");
}
);
while ( !defined $wid ) {
$top->waitVariable( \$wid );
}
$check->cancel;
warn sprintf("Window id: %x\n", $wid);
$top->geometry("+10+10");
$top->Label( -text => "A xterm:" )->pack;
if ( $Tk::VERSION >= 800 ) {
$f = $top->Frame( '-container' => 1 )->pack;
}
else {
$f = $top->Frame( -width => 500, -height => 400 )->pack;
}
warn sprintf("Resized main frame\n");
$f->update;
warn sprintf("Updated main frame\n");
$test = $x->ReparentWindow( $wid, oct( $f->id ), 0, 0 );
$x->MapWindow($wid);
warn sprintf("Reparent Window done\n");
warn sprintf("test = $test\n");
sub get_window_by_name {
_get_window_by_name( $x->{'root'}, $_[0] );
}
sub _get_window_by_name {
my ( $root, $searchname ) = @_;
my ( $dummy, $dummy2, @new_kids ) = $x->QueryTree($root);
foreach my $k (@new_kids) {
my $atomnr;
#warn sprintf("%x\n", $k);
foreach my $atom ( $x->ListProperties($k) ) {
if ( $x->GetAtomName($atom) eq "WM_CLASS" ) {
$atomnr = $atom;
last;
}
}
if ( defined $atomnr ) {
my ($classprop) =
$x->GetProperty( $k, $atomnr, "AnyPropertyType", 0, 256, 0
);
my ( $class, $name ) = split( /\0/, $classprop );
if ( $class eq $searchname ) {
return $k;
}
}
my $ret = _get_window_by_name( $k, $searchname );
if ( defined $ret ) {
return $ret;
}
}
undef;
}
MainLoop;
__END__