strredwolf has asked for the wisdom of the Perl Monks concerning the following question:


I'm building a Perl script that follows the mouse in one screen, snapshots the area, and puts it into a window on a separate screen. I got 99% of it written using Gtk2 and tested; it's working great except for one thing.

In X11, the mouse cursor doesn't get grabbed.

Is there any way to grab the mouse cursor? Anyone try calling the XFIXES extension of X11 from Perl? If I can grab the data I can glue it into the screen and smack it to the destination window.

EDIT: Here's my code for ''. It grabs from the current screen. If you give it an argument (like, exactly like the DISPLAY env variable), it'll display it on that screen you gave. I have it going from my Linux box to my Mac running

#!/usr/bin/perl $|=1; use strict; use Gtk2 -init; use Glib qw/TRUE FALSE/; my $s = Gtk2::Gdk::Screen->get_default; my $iw = $s->get_root_window; my $isw = $s->get_width; my $ish = $s->get_height; my $ddisp; if($ARGV[0]=~/:/) { my $dest=$ARGV[0]; $ddisp=Gtk2::Gdk::Display->open($dest); } else { $ddisp=Gtk2::Gdk::Display->get_default; } my $scr = $ddisp->get_default_screen; my $win = Gtk2::Window->new('toplevel'); $win->set_screen($scr); $win->resize(640,480); $win->set_resizable(FALSE); my $img = Gtk2::Image->new(); $win->add($img); $win->show_all; Glib::Timeout->add(50,\&track); Gtk2->main; sub track { my ($sn,$x,$y,$m) = $iw->get_pointer; # print "$x, $y -->> "; $x=($x > 320 ? $x-320:0); $x=($x>$isw-640 ? $isw-640:$x); $y=($y > 240 ? $y-240:0); $y=($y>$ish-480 ? $ish-480:$y); # print "$x, $y\n"; my $p = Gtk2::Gdk::Pixbuf->get_from_drawable($iw,undef,$x,$y,0,0,6 +40,480); $img->set_from_pixbuf($p); return TRUE; }
Information doesn't want to be free. It wants to be feline.