Emmanuele Bassi wrote: > if you provide a patch for the clutter-perl bindings to expose those > methods (under the Clutter::X11 namespace, for instance) and you verify > that they work, then I'll consider pushing it upstream. > > [...] > > what you need to do is create a small C library that implements a > subclass of ClutterStage and calls clutter_x11_stage_set_foreign() > inside the realize() virtual function -- after you chained up to the > parent implementation. > > then write the Perl bindings using the perl-Glib machinery that > clutter-perl uses, and use the custom class inside your Perl code.
Thanks for your quick answer!
Since my C/glib knowledge is very limited (subclassing gobject's is
beyond my scope), I tried quick and dirty binding
clutter_x11_set_stage_foreign() in ClutterStage.xs to see if this is
basically working (using Clutter 0.820 from CPAN).
This is the xsub I added:
--snip--
gboolean
clutter_stage_set_foreign_x11_window(ClutterStage *stage, int xwindow)
CODE:
RETVAL = clutter_x11_set_stage_foreign(stage, (Window) xwindow);
OUTPUT:
RETVAL
--snip--
And used this small script to test:
--snip--
#!/usr/bin/perl
use strict;
use Gtk2 '-init';
use Clutter '-init';
use Glib qw(TRUE FALSE);
main: {
my $window = Gtk2::Window->new('toplevel');
$window->set_default_size(800, 400);
$window->set_decorated(0);
$window->signal_connect('delete_event', sub { Gtk2->main_quit; });
my $colormap = $window->get_screen->get_rgba_colormap;
$window->set_colormap($colormap) if $colormap;
$window->show_all;
my $xid = $window->window->get_xid;
print "xid=$xid\n";
my $stage = Clutter::Stage->get_default();
$stage->set_foreign_x11_window($xid);
$stage->set_color(Clutter::Color->parse('DarkBlue'));
$stage->set_opacity(128);
Gtk2->main;
}
--snip--
That gives me a warning:
(./osd-test-foreign.pl:20579): ClutterX11-WARNING **: Unable to retrieve the
new window geometry
and of course no active clutter stage at all ;)
The warning is issued by clutter-stage-x11.c on the check whether all
conditions of the target X11 window are met:
if (clutter_x11_untrap_x_errors () ||
!status ||
width == 0 || height == 0 ||
depth != stage_x11->xvisinfo->depth)
{
g_warning ("Unable to retrieve the new window geometry");
return FALSE;
}
I added some debugging output and found out that the depth condition is
the problem:
depth == 32
stage_x11->xvisinfo->depth == 24
So my X11 window has an alpha channel while the clutter stage has not.
Is this due to my "quick and dirty" approach or did I hit another
problem?
Thanks,
Jörn
--
sub i($){print$_[0]}*j=*ENV;sub w($){sleep$_[0]}sub _($){i"$p:$c> ",w+01
,$_=$_[0],tr;i-za-h,;a-hi-z ;,i$_,w+01,i"\n"}$|=1;$f='HO';($c=$j{PWD})=~
s+$j{$f."ME"}+~+;$p.="$j{USER}\@".`hostname`;chop$p;_"kl",$c='~',_"zu,".
"-zn,*",_"#,epg,lw,gwc,mfmkcbm,cvsvwev,uiqt,kwvbmvb?",i"$p:$c> ";w+1<<07
pgpOXBI0f1HIj.pgp
Description: PGP signature
