On Wed, 02 Jul 2008 20:23:32 +0200
Mario Kemper <[EMAIL PROTECTED]> wrote:

>Hello folks, 
>
>i am trying to get the native window ids of my running x-session and
>handle them in my perl code using Gtk2::Gdk::Window->foreign_new but
>this is misleading into an error:
>Gdk-CRITICAL **: gdk_window_foreign_new_for_display: assertion
>`GDK_IS_DISPLAY (display)'
>
>Here is my code snippet:

>I think a am doing something totally wrong here, but i can't figure it
>out.
>I've already had that code running, but i do not know what changed :-(

>Thanks in advance
>Mario

This rings a little bell, reminding me of when I tried grabbing screenshots
thru wininfo ids.  And since you said it was working, but now it dosn't, may be 
a clue
that you have the same glitch.  The glitch was you needed to run the capture 
script from the
same virtual desktop as the window to-be-captured.  Now Gnome2::Wnck
does have the ability to switch you to the virtual desktop, I was using 
X11::WMCtrl

This was my hacking script when I did it

#!/usr/bin/perl
use warnings;
use strict;
use Image::Magick;
use X11::WMCtrl;
use Data::Dumper;

my $wmctrl = X11::WMCtrl->new;

printf("window manager is %s\n", $wmctrl->get_window_manager->{name});

my @windows = $wmctrl->get_windows;

my $wid;  # x window id
my $host; # virtual desktop

foreach my $app(@windows){
         my $title = $app->{title};
          if( $title =~ /Mozilla/i){
          print "$title\n";
          print Dumper(\$app),"\n\n";
          
          $wid = $app->{id};
          $host = $app->{host};

         }
   }

$wmctrl->switch($host);
#must be on same virtual desktop as the browser

#works
my $blob = `import -window $wid jpg:`;   

#my $blob = `import -`;  #postscript produced
#print "$blob\n";
# now $blob is in memory and you can do what you
# want with it.

my $output = Image::Magick->new(magick=>'jpg');
$output->BlobToImage( $blob );
$output->Resize(geometry=>'160x120');
$output->Write( $0.'.jpg');

exit;
# png works too


__END__

zentara


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/CandyGram_for_Mongo.html 
_______________________________________________
gtk-perl-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to