r56855 - in /branches/upstream/libopengl-xscreensaver-perl: ./ current/ current/inc/ current/inc/Devel/ current/lib/ current/lib/OpenGL/ current/t/
mxey-guest at users.alioth.debian.org
mxey-guest at users.alioth.debian.org
Sun Apr 25 13:03:05 UTC 2010
Author: mxey-guest
Date: Sun Apr 25 12:59:18 2010
New Revision: 56855
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56855
Log:
[svn-inject] Installing original source of libopengl-xscreensaver-perl
Added:
branches/upstream/libopengl-xscreensaver-perl/
branches/upstream/libopengl-xscreensaver-perl/current/
branches/upstream/libopengl-xscreensaver-perl/current/Changes
branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST
branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST.SKIP
branches/upstream/libopengl-xscreensaver-perl/current/META.yml
branches/upstream/libopengl-xscreensaver-perl/current/Makefile.PL
branches/upstream/libopengl-xscreensaver-perl/current/XScreenSaver.xs
branches/upstream/libopengl-xscreensaver-perl/current/inc/
branches/upstream/libopengl-xscreensaver-perl/current/inc/Devel/
branches/upstream/libopengl-xscreensaver-perl/current/inc/Devel/CheckLib.pm
branches/upstream/libopengl-xscreensaver-perl/current/lib/
branches/upstream/libopengl-xscreensaver-perl/current/lib/OpenGL/
branches/upstream/libopengl-xscreensaver-perl/current/lib/OpenGL/XScreenSaver.pm
branches/upstream/libopengl-xscreensaver-perl/current/t/
branches/upstream/libopengl-xscreensaver-perl/current/t/00_useok.t (with props)
branches/upstream/libopengl-xscreensaver-perl/current/t/01_window_id.t (with props)
Added: branches/upstream/libopengl-xscreensaver-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/Changes?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/Changes (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/Changes Sun Apr 25 12:59:18 2010
@@ -1,0 +1,23 @@
+OpenGL-XScreenSaver 0.04 - Sat Feb 20 03:30:04 2010 +0100
+
+ * add dimensions() function to query window dimensions
+
+OpenGL-XScreenSaver 0.03 - Wed Jan 6 20:17:27 2010 +0100
+
+ * the window is now displayed in standalone mode
+ * do not assume that the root window has ID 0x10f, but ask the
+ server
+ * add 11 tests
+
+OpenGL-XScreenSaver 0.02 - Wed Jan 6 15:44:22 2010 +0100
+
+ * check for GL and X11 libraries in Makefile.PL so that unmet dependencies
+ do not generate FAILed test reports
+
+OpenGL-XScreenSaver 0.01 - Wed Jan 6 12:49:20 2010 +0100
+
+ * initial code import from dizzy
+ * bind GL context to a window with some ID
+ * find out correct window ID to draw to
+ * parse and remove XScreenSaver specific command line arguments
+
Added: branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST Sun Apr 25 12:59:18 2010
@@ -1,0 +1,10 @@
+Changes
+inc/Devel/CheckLib.pm
+lib/OpenGL/XScreenSaver.pm
+Makefile.PL
+MANIFEST This list of files
+MANIFEST.SKIP
+t/00_useok.t
+t/01_window_id.t
+XScreenSaver.xs
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST.SKIP?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/MANIFEST.SKIP Sun Apr 25 12:59:18 2010
@@ -1,0 +1,7 @@
+^\.git
+^Makefile$
+^blib/
+^pm_to_blib$
+^MANIFEST\.bak$
+.*\.(bs|c|o|tar\.gz)$
+
Added: branches/upstream/libopengl-xscreensaver-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/META.yml?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/META.yml (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/META.yml Sun Apr 25 12:59:18 2010
@@ -1,0 +1,20 @@
+--- #YAML:1.0
+name: OpenGL-XScreenSaver
+version: 0.04
+abstract: prepare environment for writing OpenGL-based XScreenSaver hacks
+author: []
+license: perl
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
+requires: {}
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.55_02
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Added: branches/upstream/libopengl-xscreensaver-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/Makefile.PL?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/Makefile.PL (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/Makefile.PL Sun Apr 25 12:59:18 2010
@@ -1,0 +1,15 @@
+#!/usr/bin/env perl
+use ExtUtils::MakeMaker;
+
+use lib 'inc';
+use Devel::CheckLib;
+
+check_lib_or_exit(lib => ['X11', 'GL']);
+
+WriteMakefile(
+ NAME => 'OpenGL::XScreenSaver',
+ VERSION_FROM => 'lib/OpenGL/XScreenSaver.pm',
+ ABSTRACT_FROM => 'lib/OpenGL/XScreenSaver.pm',
+ LIBS => '-lGL -lX11',
+ LICENSE => 'perl',
+);
Added: branches/upstream/libopengl-xscreensaver-perl/current/XScreenSaver.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/XScreenSaver.xs?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/XScreenSaver.xs (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/XScreenSaver.xs Sun Apr 25 12:59:18 2010
@@ -1,0 +1,74 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include <X11/Xlib.h>
+#include <GL/glx.h>
+
+static Display *dpy = 0;
+static Window win;
+static XVisualInfo *vi;
+static GLXContext cx;
+
+MODULE = OpenGL::XScreenSaver PACKAGE = OpenGL::XScreenSaver
+
+PROTOTYPES: DISABLE
+
+int
+xss_connect()
+ CODE:
+ if (!dpy)
+ dpy = XOpenDisplay(0);
+
+ if (!dpy) {
+ XSRETURN_NO;
+ } else {
+ XSRETURN_YES;
+ }
+
+int
+xss_init_gl(wid)
+ int wid
+ CODE:
+ win = wid;
+
+ vi = glXChooseVisual(dpy, DefaultScreen(dpy), (int[]){ GLX_RGBA, GLX_DOUBLEBUFFER, None });
+ cx = glXCreateContext(dpy, vi, 0, GL_TRUE);
+
+ if (!win) {
+ win = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 640, 480, 0, 0, 0);
+ XMapWindow(dpy, win);
+ }
+
+ glXMakeCurrent(dpy, win, cx);
+
+ XSRETURN_YES;
+
+void
+xss_update_frame()
+ CODE:
+ glXSwapBuffers(dpy, win);
+
+void
+xss_update_viewport()
+ CODE:
+ XWindowAttributes xwa;
+ XGetWindowAttributes(dpy, win, &xwa);
+ glXMakeCurrent(dpy, win, cx);
+ glViewport(0, 0, xwa.width, xwa.height);
+
+int
+xss_root_window()
+ CODE:
+ RETVAL = DefaultRootWindow(dpy);
+ OUTPUT:
+ RETVAL
+
+void
+xss_viewport_dimensions()
+ PPCODE:
+ XWindowAttributes xwa;
+ XGetWindowAttributes(dpy, win, &xwa);
+ XPUSHs(sv_2mortal(newSVnv(xwa.width)));
+ XPUSHs(sv_2mortal(newSVnv(xwa.height)));
+
Added: branches/upstream/libopengl-xscreensaver-perl/current/inc/Devel/CheckLib.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/inc/Devel/CheckLib.pm?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/inc/Devel/CheckLib.pm (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/inc/Devel/CheckLib.pm Sun Apr 25 12:59:18 2010
@@ -1,0 +1,377 @@
+# $Id: CheckLib.pm,v 1.25 2008/10/27 12:16:23 drhyde Exp $
+
+package #
+Devel::CheckLib;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT);
+$VERSION = '0.6';
+use Config;
+
+use File::Spec;
+use File::Temp;
+
+require Exporter;
+ at ISA = qw(Exporter);
+ at EXPORT = qw(assert_lib check_lib_or_exit);
+
+# localising prevents the warningness leaking out of this module
+local $^W = 1; # use warnings is a 5.6-ism
+
+_findcc(); # bomb out early if there's no compiler
+
+=head1 NAME
+
+Devel::CheckLib - check that a library is available
+
+=head1 DESCRIPTION
+
+Devel::CheckLib is a perl module that checks whether a particular C
+library and its headers are available.
+
+=head1 SYNOPSIS
+
+ use Devel::CheckLib;
+
+ check_lib_or_exit( lib => 'jpeg', header => 'jpeglib.h' );
+ check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] );
+
+ # or prompt for path to library and then do this:
+ check_lib_or_exit( lib => 'jpeg', libpath => $additional_path );
+
+=head1 USING IT IN Makefile.PL or Build.PL
+
+If you want to use this from Makefile.PL or Build.PL, do
+not simply copy the module into your distribution as this may cause
+problems when PAUSE and search.cpan.org index the distro. Instead, use
+the use-devel-checklib script.
+
+=head1 HOW IT WORKS
+
+You pass named parameters to a function, describing to it how to build
+and link to the libraries.
+
+It works by trying to compile this:
+
+ int main(void) { return 0; }
+
+and linking it to the specified libraries. If something pops out the end
+which looks executable, then we know that it worked. That tiny program is
+built once for each library that you specify, and (without linking) once
+for each header file.
+
+=head1 FUNCTIONS
+
+All of these take the same named parameters and are exported by default.
+To avoid exporting them, C<use Devel::CheckLib ()>.
+
+=head2 assert_lib
+
+This takes several named parameters, all of which are optional, and dies
+with an error message if any of the libraries listed can
+not be found. B<Note>: dying in a Makefile.PL or Build.PL may provoke
+a 'FAIL' report from CPAN Testers' automated smoke testers. Use
+C<check_lib_or_exit> instead.
+
+The named parameters are:
+
+=over
+
+=item lib
+
+Must be either a string with the name of a single
+library or a reference to an array of strings of library names. Depending
+on the compiler found, library names will be fed to the compiler either as
+C<-l> arguments or as C<.lib> file names. (E.g. C<-ljpeg> or C<jpeg.lib>)
+
+=item libpath
+
+a string or an array of strings
+representing additional paths to search for libraries.
+
+=item LIBS
+
+a C<ExtUtils::MakeMaker>-style space-seperated list of
+libraries (each preceded by '-l') and directories (preceded by '-L').
+
+This can also be supplied on the command-line.
+
+=back
+
+And libraries are no use without header files, so ...
+
+=over
+
+=item header
+
+Must be either a string with the name of a single
+header file or a reference to an array of strings of header file names.
+
+=item incpath
+
+a string or an array of strings
+representing additional paths to search for headers.
+
+=item INC
+
+a C<ExtUtils::MakeMaker>-style space-seperated list of
+incpaths, each preceded by '-I'.
+
+This can also be supplied on the command-line.
+
+=back
+
+=head2 check_lib_or_exit
+
+This behaves exactly the same as C<assert_lib()> except that instead of
+dieing, it warns (with exactly the same error message) and exits.
+This is intended for use in Makefile.PL / Build.PL
+when you might want to prompt the user for various paths and
+things before checking that what they've told you is sane.
+
+If any library or header is missing, it exits with an exit value of 0 to avoid
+causing a CPAN Testers 'FAIL' report. CPAN Testers should ignore this
+result -- which is what you want if an external library dependency is not
+available.
+
+=cut
+
+sub check_lib_or_exit {
+ eval 'assert_lib(@_)';
+ if($@) {
+ warn $@;
+ exit;
+ }
+}
+
+sub assert_lib {
+ my %args = @_;
+ my (@libs, @libpaths, @headers, @incpaths);
+
+ # FIXME: these four just SCREAM "refactor" at me
+ @libs = (ref($args{lib}) ? @{$args{lib}} : $args{lib})
+ if $args{lib};
+ @libpaths = (ref($args{libpath}) ? @{$args{libpath}} : $args{libpath})
+ if $args{libpath};
+ @headers = (ref($args{header}) ? @{$args{header}} : $args{header})
+ if $args{header};
+ @incpaths = (ref($args{incpath}) ? @{$args{incpath}} : $args{incpath})
+ if $args{incpath};
+
+ # work-a-like for Makefile.PL's LIBS and INC arguments
+ # if given as command-line argument, append to %args
+ for my $arg (@ARGV) {
+ for my $mm_attr_key qw(LIBS INC) {
+ if (my ($mm_attr_value) = $arg =~ /\A $mm_attr_key = (.*)/x) {
+ # it is tempting to put some \s* into the expression, but the
+ # MM command-line parser only accepts LIBS etc. followed by =,
+ # so we should not be any more lenient with whitespace than that
+ $args{$mm_attr_key} .= " $mm_attr_value";
+ }
+ }
+ }
+
+ # using special form of split to trim whitespace
+ if(defined($args{LIBS})) {
+ foreach my $arg (split(' ', $args{LIBS})) {
+ die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-l/i);
+ push @{$arg =~ /^-l/ ? \@libs : \@libpaths}, substr($arg, 2);
+ }
+ }
+ if(defined($args{INC})) {
+ foreach my $arg (split(' ', $args{INC})) {
+ die("INC argument badly-formed: $arg\n") unless($arg =~ /^-I/);
+ push @incpaths, substr($arg, 2);
+ }
+ }
+
+ my @cc = _findcc();
+ my @missing;
+
+ # first figure out which headers we can't find ...
+ for my $header (@headers) {
+ my($ch, $cfile) = File::Temp::tempfile(
+ 'assertlibXXXXXXXX', SUFFIX => '.c'
+ );
+ print $ch qq{#include <$header>\nint main(void) { return 0; }\n};
+ close($ch);
+ my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe};
+ my @sys_cmd;
+ # FIXME: re-factor - almost identical code later when linking
+ if ( $Config{cc} eq 'cl' ) { # Microsoft compiler
+ require Win32;
+ @sys_cmd = (@cc, $cfile, "/Fe$exefile", (map { '/I'.Win32::GetShortPathName($_) } @incpaths));
+ } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland
+ @sys_cmd = (@cc, (map { "-I$_" } @incpaths), "-o$exefile", $cfile);
+ } else { # Unix-ish
+ # gcc, Sun, AIX (gcc, cc)
+ @sys_cmd = (@cc, $cfile, (map { "-I$_" } @incpaths), "-o", "$exefile");
+ }
+ warn "# @sys_cmd\n" if $args{debug};
+ my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd);
+ push @missing, $header if $rv != 0 || ! -x $exefile;
+ _cleanup_exe($exefile);
+ unlink $cfile;
+ }
+
+ # now do each library in turn with no headers
+ my($ch, $cfile) = File::Temp::tempfile(
+ 'assertlibXXXXXXXX', SUFFIX => '.c'
+ );
+ print $ch "int main(void) { return 0; }\n";
+ close($ch);
+ for my $lib ( @libs ) {
+ my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe};
+ my @sys_cmd;
+ if ( $Config{cc} eq 'cl' ) { # Microsoft compiler
+ require Win32;
+ my @libpath = map {
+ q{/libpath:} . Win32::GetShortPathName($_)
+ } @libpaths;
+ @sys_cmd = (@cc, $cfile, "${lib}.lib", "/Fe$exefile",
+ "/link", @libpath
+ );
+ } elsif($Config{cc} eq 'CC/DECC') { # VMS
+ } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland
+ my @libpath = map { "-L$_" } @libpaths;
+ @sys_cmd = (@cc, "-o$exefile", "-l$lib", @libpath, $cfile);
+ } else { # Unix-ish
+ # gcc, Sun, AIX (gcc, cc)
+ my @libpath = map { "-L$_" } @libpaths;
+ @sys_cmd = (@cc, $cfile, "-o", "$exefile", "-l$lib", @libpath);
+ }
+ warn "# @sys_cmd\n" if $args{debug};
+ my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd);
+ push @missing, $lib if $rv != 0 || ! -x $exefile;
+ _cleanup_exe($exefile);
+ }
+ unlink $cfile;
+
+ my $miss_string = join( q{, }, map { qq{'$_'} } @missing );
+ die("Can't link/include $miss_string\n") if @missing;
+}
+
+sub _cleanup_exe {
+ my ($exefile) = @_;
+ my $ofile = $exefile;
+ $ofile =~ s/$Config{_exe}$/$Config{_o}/;
+ unlink $exefile if -f $exefile;
+ unlink $ofile if -f $ofile;
+ unlink "$exefile\.manifest" if -f "$exefile\.manifest";
+ return
+}
+
+sub _findcc {
+ my @paths = split(/$Config{path_sep}/, $ENV{PATH});
+ my @cc = split(/\s+/, $Config{cc});
+ return @cc if -x $cc[0];
+ foreach my $path (@paths) {
+ my $compiler = File::Spec->catfile($path, $cc[0]) . $Config{_exe};
+ return ($compiler, @cc[1 .. $#cc]) if -x $compiler;
+ }
+ die("Couldn't find your C compiler\n");
+}
+
+# code substantially borrowed from IPC::Run3
+sub _quiet_system {
+ my (@cmd) = @_;
+
+ # save handles
+ local *STDOUT_SAVE;
+ local *STDERR_SAVE;
+ open STDOUT_SAVE, ">&STDOUT" or die "CheckLib: $! saving STDOUT";
+ open STDERR_SAVE, ">&STDERR" or die "CheckLib: $! saving STDERR";
+
+ # redirect to nowhere
+ local *DEV_NULL;
+ open DEV_NULL, ">" . File::Spec->devnull
+ or die "CheckLib: $! opening handle to null device";
+ open STDOUT, ">&" . fileno DEV_NULL
+ or die "CheckLib: $! redirecting STDOUT to null handle";
+ open STDERR, ">&" . fileno DEV_NULL
+ or die "CheckLib: $! redirecting STDERR to null handle";
+
+ # run system command
+ my $rv = system(@cmd);
+
+ # restore handles
+ open STDOUT, ">&" . fileno STDOUT_SAVE
+ or die "CheckLib: $! restoring STDOUT handle";
+ open STDERR, ">&" . fileno STDERR_SAVE
+ or die "CheckLib: $! restoring STDERR handle";
+
+ return $rv;
+}
+
+=head1 PLATFORMS SUPPORTED
+
+You must have a C compiler installed. We check for C<$Config{cc}>,
+both literally as it is in Config.pm and also in the $PATH.
+
+It has been tested with varying degrees on rigourousness on:
+
+=over
+
+=item gcc (on Linux, *BSD, Mac OS X, Solaris, Cygwin)
+
+=item Sun's compiler tools on Solaris
+
+=item IBM's tools on AIX
+
+=item SGI's tools on Irix 6.5
+
+=item Microsoft's tools on Windows
+
+=item MinGW on Windows (with Strawberry Perl)
+
+=item Borland's tools on Windows
+
+=item QNX
+
+=back
+
+=head1 WARNINGS, BUGS and FEEDBACK
+
+This is a very early release intended primarily for feedback from
+people who have discussed it. The interface may change and it has
+not been adequately tested.
+
+Feedback is most welcome, including constructive criticism.
+Bug reports should be made using L<http://rt.cpan.org/> or by email.
+
+When submitting a bug report, please include the output from running:
+
+ perl -V
+ perl -MDevel::CheckLib -e0
+
+=head1 SEE ALSO
+
+L<Devel::CheckOS>
+
+L<Probe::Perl>
+
+=head1 AUTHORS
+
+David Cantrell E<lt>david at cantrell.org.ukE<gt>
+
+David Golden E<lt>dagolden at cpan.orgE<gt>
+
+Thanks to the cpan-testers-discuss mailing list for prompting us to write it
+in the first place;
+
+to Chris Williams for help with Borland support.
+
+=head1 COPYRIGHT and LICENCE
+
+Copyright 2007 David Cantrell. Portions copyright 2007 David Golden.
+
+This module is free-as-in-speech software, and may be used, distributed,
+and modified under the same conditions as perl itself.
+
+=head1 CONSPIRACY
+
+This module is also free-as-in-mason software.
+
+=cut
+
+1;
Added: branches/upstream/libopengl-xscreensaver-perl/current/lib/OpenGL/XScreenSaver.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/lib/OpenGL/XScreenSaver.pm?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/lib/OpenGL/XScreenSaver.pm (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/lib/OpenGL/XScreenSaver.pm Sun Apr 25 12:59:18 2010
@@ -1,0 +1,150 @@
+package OpenGL::XScreenSaver;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.04';
+
+require XSLoader;
+XSLoader::load('OpenGL::XScreenSaver', $VERSION);
+
+my $window_id = 0;
+
+# for tests
+sub _window_id { return $window_id; }
+sub _reset_wid { $window_id = 0; }
+
+sub init {
+ # parse and remove XScreenSaver specific arguments.
+ # stop at the first unknown argument (XScreenSaver will pass its own always
+ # first)
+ while (@ARGV) {
+ if ($ARGV[0] eq "-window-id") {
+ $window_id = $ARGV[1];
+ $window_id = oct($window_id) if ($window_id =~ /^0/);
+ splice(@ARGV, 0, 2);
+ } elsif ($ARGV[0] eq "-root") {
+ $window_id = "ROOT";
+ shift(@ARGV);
+ } elsif ($ARGV[0] eq "-mono" or $ARGV[0] eq "-install") {
+ shift(@ARGV);
+ } elsif ($ARGV[0] eq "-visual") {
+ splice(@ARGV, 0, 2);
+ } else {
+ last;
+ }
+ }
+
+ # if no window ID has been found yet, check out the environment.
+ # XScreenSaver sometimes dumps the window ID there
+ if (!$window_id and $ENV{XSCREENSAVER_WINDOW}) {
+ $window_id = $ENV{XSCREENSAVER_WINDOW};
+ $window_id = oct($window_id) if ($window_id =~ /^0/);
+ }
+
+ # if still no window then it seems we have to create one ourselves.
+ # leave the window ID set to 0, start() will detect this and create its
+ # own window.
+ # return the information to the caller because the user might decide she
+ # wants it to work in XScreenSaver only, not standalone.
+ return ! ! $window_id;
+}
+
+sub start {
+ xss_connect();
+ if ($window_id eq "ROOT") {
+ $window_id = xss_root_window();
+ }
+ xss_init_gl($window_id);
+}
+
+sub update {
+ xss_update_frame();
+ xss_update_viewport();
+}
+
+sub dimensions {
+ xss_viewport_dimensions();
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+OpenGL::XScreenSaver - prepare environment for writing OpenGL-based XScreenSaver hacks
+
+=head1 SYNOPSIS
+
+ use OpenGL qw(:all);
+ use OpenGL::XScreenSaver;
+
+ OpenGL::XScreenSaver::init();
+ # GetOptions(...); # parse your own options, if any
+
+ OpenGL::XScreenSaver::start();
+
+ while (1) {
+ glClear(...);
+ # draw your scene here
+ OpenGL::XScreenSaver::update();
+ }
+
+=head1 DESCRIPTION
+
+This module allows you to write OpenGL XScreenSaver hacks in Perl. It prepares
+the GL to be used with XScreenSaver.
+
+Read the synopsis for how your program might look.
+
+=head2 Description of functions
+
+The B<init()> function will return a true value if a window to draw on has been
+found, and a false value if a window will have to be created. This value can
+be ignored unless you want to make sure that your screenhack cannot be
+executed outside XScreenSaver (e.g. if your standalone version comes as an
+extra binary with keyboard control, which would be useless in a screensaver).
+
+The B<start()> function will open the connection to the X server and bind to
+the window ID or create a new window to draw on (depends on if it was called
+standalone or from XScreenSaver).
+
+The B<update()> function should be called when you finished rendering the
+frame. It will flush output and swap the buffers. In the future it might also
+handle a minimal set of X events when run in standalone mode (like window
+deletion requests by the window manager).
+
+The B<dimensions()> function returns a list with the width and the height of
+the currently used window.
+
+=head2 About screenhacks
+
+What follows is a short description of how it works and what XScreenSaver
+expects a screenhack to do.
+
+XScreenSaver tells the hack on startup what window ID the hack shall draw to.
+This is either a small window mapping to the screen in the preview dialog, or
+a fullscreen window. The window ID is passed either via the B<-window-id>
+option or via the B<XSCREENSAVER_WINDOW> environment variable. B<init()> of
+this module checks both of these.
+
+XScreenSaver handles all user input including exiting and pausing the
+screensaver. The process is sent a SIGSTOP when the unlock screen is displayed,
+obviously a SIGCONT when it is dismissed, and when the pointing device is
+moved or the screen gets unlocked XScreenSaver sends a SIGTERM. This means
+that no event handling is required by your screenhack whatsoever. This again
+keeps the design of a screenhack dead simple.
+
+=head1 SEE ALSO
+
+L<OpenGL>
+
+=head1 AUTHORS & COPYRIGHTS
+
+Made 2010 by Lars Stoltenow.
+OpenGL::XScreenSaver is free software; you may redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
Added: branches/upstream/libopengl-xscreensaver-perl/current/t/00_useok.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/t/00_useok.t?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/t/00_useok.t (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/t/00_useok.t Sun Apr 25 12:59:18 2010
@@ -1,0 +1,8 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+use_ok("OpenGL::XScreenSaver");
+
Propchange: branches/upstream/libopengl-xscreensaver-perl/current/t/00_useok.t
------------------------------------------------------------------------------
svn:executable =
Added: branches/upstream/libopengl-xscreensaver-perl/current/t/01_window_id.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libopengl-xscreensaver-perl/current/t/01_window_id.t?rev=56855&op=file
==============================================================================
--- branches/upstream/libopengl-xscreensaver-perl/current/t/01_window_id.t (added)
+++ branches/upstream/libopengl-xscreensaver-perl/current/t/01_window_id.t Sun Apr 25 12:59:18 2010
@@ -1,0 +1,48 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More tests => 10;
+
+use OpenGL::XScreenSaver;
+
+*_init = \&OpenGL::XScreenSaver::init;
+*_window_id = \&OpenGL::XScreenSaver::_window_id;
+
+sub reset_env {
+ delete($ENV{XSCREENSAVER_WINDOW});
+ @ARGV = ();
+ OpenGL::XScreenSaver::_reset_wid();
+}
+
+my $ret;
+
+# test 1: default should require creation of new window
+reset_env();
+$ret = _init();
+ok(! $ret , "no window id leads to creation of new window (init() return value)");
+is(_window_id() , 0 , "no window id leads to creation of new window (saved window id)");
+
+# test 2: -root option draws on the root window and won't create a new window
+reset_env();
+ at ARGV = qw(-root);
+$ret = _init();
+ok($ret , "-root option will not create a new window");
+is(_window_id() , "ROOT" , "-root option will draw on the root window");
+
+# test 3: resetting the environment actually works (should now create no window again)
+reset_env(); $ret = _init();
+ok(! $ret , "resetting test environment actually works (return value)");
+is(_window_id() , 0 , "resetting test environment actually works (saved window id)");
+
+# test 4: defining window ids will make it draw to them
+reset_env(); @ARGV = qw(-window-id 23); _init();
+is(_window_id() , 23 , "-window-id works with base-10 numbers");
+reset_env(); @ARGV = qw(-window-id 0x42); _init();
+is(_window_id() , 0x42 , "-window-id works with base-16 numbers");
+reset_env(); @ARGV = qw(-window-id 010); _init();
+is(_window_id() , 8 , "-window-id works with base-8 numbers");
+
+# test 5: defining only the envvar will make it draw to that window
+reset_env(); $ENV{XSCREENSAVER_WINDOW} = "0x2342"; _init();
+is(_window_id() , 0x2342 , "can read window ID from environment");
Propchange: branches/upstream/libopengl-xscreensaver-perl/current/t/01_window_id.t
------------------------------------------------------------------------------
svn:executable =
More information about the Pkg-perl-cvs-commits
mailing list