1#!/usr/local/bin/perl -w 2use Tk; 3use Tk::Xlib; 4use Tk::HList; 5 6my $win_image; 7 8sub AddChildren 9{ 10 my ($hl,$path,$id) = @_; 11 my $w; 12# foreach $w ($hl->property(list => $$id)) 13# { 14# $hl->add("$path.$w", -itemtype => 'text', -text => $w, -data => $w); 15# } 16 foreach $w ($hl->Display->XQueryTree($id)) 17 { 18 my $name = sprintf("#%X",$$w); 19 my $text = ($hl->property('exists' => 'WM_NAME',$$w)) 20 ? $hl->property(get => 'WM_NAME',$$w) 21 : $name; 22 23 $hl->add("$path.$name", -itemtype => 'imagetext', -image => $win_image, -text => $text, -data => $w); 24 AddChildren($hl,"$path.$name",$w); 25 } 26} 27 28sub More 29{ 30 my ($w,$item) = @_; 31 my $data = $w->entrycget($item,'-data'); 32 if (ref($data)) 33 { 34 AddChildren($w,$item,$data); 35 } 36 else 37 { 38 my $prop = $data; 39 my $parent = $w->info('parent',$item); 40 $data = $w->entrycget($parent,'-data'); 41 my @info = $w->property('get',$prop,$$data); 42 print join(' ',$prop,@info),"\n"; 43 } 44} 45 46 47my $mw = MainWindow->new; 48$mw->MakeWindowExist; 49my $root; 50$mw->Display->XQueryTree($mw->WindowId,$root); 51 52if (defined $root) 53 { 54 $win_image = $mw->Bitmap(-file => Tk->findINC('win.xbm')); 55 my $hl = $mw->Scrolled('HList',-separator => '.',-drawbranch => 1); 56 $hl->configure(-command => [\&More,$hl]); 57 my $name = sprintf("%X",$$root); 58 $hl->add($name, -itemtype => 'imagetext', -image => $win_image, -text => $name, -data => $root); 59 AddChildren($hl,$name,$root); 60 $hl->pack(-expand=> 1, -fill => 'both'); 61 } 62 63MainLoop; 64