# An incomplete module for adding MIT-SCREEN-SAVER extension to Perl's X11::Protocol
# Copyright (C) 2008 Matthieu Weber <mweber()mit.jyu.fi>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

package X11::Protocol::Ext::MIT_SCREEN_SAVER;

use X11::Protocol qw(pad padding padded make_num_hash);

sub new {
  my($pkg, $x, $request_num, $event_num, $error_num) = @_;
  my($self) = {};

	$x->{'ext_request'}{$request_num} =
	  [
		  ["ScreenSaverQueryVersion", sub {
			  my($self) = shift;
				return pack("xxS", 1, 0);
		   }, sub {
			   my($self) = shift;
				 my($data) = @_;
				 my($major, $minor) = unpack("xxxxxxxxSSxxxxxxxxxxxxxxxxxxxx", $data);
				 return ($major, $minor);
			 }
     ],
		 ["ScreenSaverQueryInfo", sub {
			  my($self) = shift;
        my ($drawable) = @_;
				return pack("L", $drawable);
		   }, sub {
			   my($self) = shift;
				 my($data) = @_;
				 my($window, $tilOrSince, $idle, $eventMask, $kind) = unpack("xxxxxxxxLLLLCxxxxxxx", $data);
				 return ($window, $tilOrSince, $idle, $eventMask, $kind);
			 }
     ]

   ];
  my($i);
  for $i (0 .. $#{$x->{'ext_request'}{$request_num}}) {
    $x->{'ext_request_num'}{$x->{'ext_request'}{$request_num}[$i][0]} = [$request_num, $i];
  }
  return bless $self, $pkg;
}

1;
