This file is indexed.

/usr/lib/perl5/OpenGL/XScreenSaver.pm is in libopengl-xscreensaver-perl 0.05-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package OpenGL::XScreenSaver;

use strict;
use warnings;

our $VERSION = '0.05';

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