| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | # The XC-MISC Extension | ||
| 4 | package X11::Protocol::Ext::XC_MISC; | ||
| 5 | |||
| 6 | # This module was originally written in 1998 by Jay Kominek. As of | ||
| 7 | # February 10th, 2003, he has placed it in the public domain. | ||
| 8 | |||
| 9 | use X11::Protocol qw(pad padding padded make_num_hash); | ||
| 10 | use Carp; | ||
| 11 | |||
| 12 | use strict; | ||
| 13 | use vars '$VERSION'; | ||
| 14 | |||
| 15 | $VERSION = 0.01; | ||
| 16 | |||
| 17 | sub new | ||
| 18 | { | ||
| 19 | my($pkg, $x, $request_num, $event_num, $error_num) = @_; | ||
| 20 | my($self) = {}; | ||
| 21 | |||
| 22 | # Constants | ||
| 23 | |||
| 24 | # Events | ||
| 25 | |||
| 26 | # Requests | ||
| 27 | $x->{'ext_request'}{$request_num} = | ||
| 28 | [ | ||
| 29 | ["XCMiscGetVersion", sub { | ||
| 30 | my($self) = shift; | ||
| 31 | my($major, $minor) = @_; | ||
| 32 | return pack("SS", $major, $minor); | ||
| 33 | }, sub { | ||
| 34 | my($self) = shift; | ||
| 35 | my($data) = @_; | ||
| 36 | my($major,$minor) | ||
| 37 | = unpack("xxxxxxxxSSxxxxxxxxxxxxxxxxxxxx",$data); | ||
| 38 | return($major,$minor); | ||
| 39 | }], | ||
| 40 | ["XCMiscGetXIDRange", sub { | ||
| 41 | my($self) = shift; | ||
| 42 | return ""; | ||
| 43 | }, sub { | ||
| 44 | my($self) = shift; | ||
| 45 | my($data) = @_; | ||
| 46 | my($start_id,$count) = unpack("xxxxxxxxLLxxxxxxxxxxxxxxxx",$data); | ||
| 47 | return($start_id,$count); | ||
| 48 | }], | ||
| 49 | ["XCMiscGetXIDList", sub { | ||
| 50 | my($self) = shift; | ||
| 51 | return pack("L",shift); | ||
| 52 | }, sub { | ||
| 53 | my($self) = shift; | ||
| 54 | my($data) = @_; | ||
| 55 | my($count,@ids) = unpack("xxxxxxxxLxxxxxxxxxxxxxxxxxxxxL*",$data); | ||
| 56 | return($count,@ids); | ||
| 57 | }] | ||
| 58 | ]; | ||
| 59 | my($i); | ||
| 60 | for $i (0 .. $#{$x->{'ext_request'}{$request_num}}) { | ||
| 61 | $x->{'ext_request_num'}{$x->{'ext_request'}{$request_num}[$i][0]} = | ||
| 62 | [$request_num, $i]; | ||
| 63 | } | ||
| 64 | ($self->{'major'},$self->{'minor'}) = $x->req('XCMiscGetVersion', 1, 1); | ||
| 65 | if ($self->{'major'} != 1) { | ||
| 66 | carp "Wrong XC-MISC version ($self->{'major'} != 1)"; | ||
| 67 | return undef; | ||
| 68 | } | ||
| 69 | return bless $self, $pkg; | ||
| 70 | } | ||
| 71 | |||
| 72 | 1; | ||
| 73 | __END__ |