| 1 | # Copyright 2011, 2012, 2013, 2014, 2016, 2017 Kevin Ryde | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # This file is part of X11-Protocol-Other. | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # X11-Protocol-Other is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 6 | # modify it under the terms of the GNU General Public License as published | ||||||||||||||||||||||||||||
| 7 | # by the Free Software Foundation; either version 3, or (at your option) any | ||||||||||||||||||||||||||||
| 8 | # later version. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # X11-Protocol-Other is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||||||||||||||||||||||||||||
| 13 | # Public License for more details. | ||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||
| 16 | # with X11-Protocol-Other. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # /usr/share/doc/x11proto-scrnsaver-dev/saver.txt.gz | ||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||
| 21 | # /usr/include/X11/extensions/saver.h | ||||||||||||||||||||||||||||
| 22 | # /usr/include/X11/extensions/saverproto.h | ||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||
| 24 | # /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | BEGIN { require 5 } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | package X11::Protocol::Ext::MIT_SCREEN_SAVER; | ||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use X11::Protocol; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use vars '$VERSION', '@CARP_NOT'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 1 | $VERSION = 31; | |||||||||||||||||||||||||||
| 34 | 1 | @CARP_NOT = ('X11::Protocol'); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # uncomment this to run the ### lines | ||||||||||||||||||||||||||||
| 37 | #use Smart::Comments; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # these not documented yet ... and not used as such | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | use constant CLIENT_MAJOR_VERSION => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use constant CLIENT_MINOR_VERSION => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | my $reqs = | ||||||||||||||||||||||||||||
| 47 | [ | ||||||||||||||||||||||||||||
| 48 | [ 'MitScreenSaverQueryVersion', # 0 | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 50 | 0 | my ($X, $client_major, $client_minor) = @_; | |||||||||||||||||||||||||||
| 51 | ### MitScreenSaverQueryVersion request | ||||||||||||||||||||||||||||
| 52 | 0 | return pack 'CCxx', $client_major, $client_minor; | |||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 55 | 0 | my ($X, $data) = @_; | |||||||||||||||||||||||||||
| 56 | 0 | return unpack 'x8SS', $data; | |||||||||||||||||||||||||||
| 57 | }], | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | [ 'MitScreenSaverQueryInfo', # 1 | ||||||||||||||||||||||||||||
| 60 | \&_request_card32s, | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 62 | 0 | my ($X, $data) = @_; | |||||||||||||||||||||||||||
| 63 | 0 | my ($state, $window, $til_or_since, $idle, $event_mask, $kind) | |||||||||||||||||||||||||||
| 64 | = unpack 'xCx6LLLLC', $data; | ||||||||||||||||||||||||||||
| 65 | 0 | return ($X->interp('MitScreenSaverState',$state), | |||||||||||||||||||||||||||
| 66 | _interp_none($X,$window), | ||||||||||||||||||||||||||||
| 67 | $til_or_since, | ||||||||||||||||||||||||||||
| 68 | $idle, | ||||||||||||||||||||||||||||
| 69 | $event_mask, | ||||||||||||||||||||||||||||
| 70 | $X->interp('MitScreenSaverKind',$kind)); | ||||||||||||||||||||||||||||
| 71 | } ], | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | [ 'MitScreenSaverSelectInput', # 2 | ||||||||||||||||||||||||||||
| 74 | \&_request_card32s ], # ($X, $drawable, $event_mask) | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | [ 'MitScreenSaverSetAttributes', # 3 | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 78 | ### MitScreenSaverSetAttributes request | ||||||||||||||||||||||||||||
| 79 | # same args as $X->CreateWindow(), but pack format a bit different | ||||||||||||||||||||||||||||
| 80 | 0 | my ($X, $drawable, | |||||||||||||||||||||||||||
| 81 | $class, $depth, $visual, | ||||||||||||||||||||||||||||
| 82 | $x, $y, $width, $height, | ||||||||||||||||||||||||||||
| 83 | $border_width, | ||||||||||||||||||||||||||||
| 84 | @values) = @_; | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # ChangeWindow | ||||||||||||||||||||||||||||
| 87 | 0 | my ($data) = &{$X->{'requests'}->[2]->[1]} ($X, $drawable, @values); | |||||||||||||||||||||||||||
| 88 | ### $data | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | return (pack ('LssSSSCCL', | |||||||||||||||||||||||||||
| 91 | $drawable, | ||||||||||||||||||||||||||||
| 92 | $x, $y, | ||||||||||||||||||||||||||||
| 93 | $width, $height, | ||||||||||||||||||||||||||||
| 94 | $border_width, | ||||||||||||||||||||||||||||
| 95 | $X->num('Class',$class), | ||||||||||||||||||||||||||||
| 96 | $depth, | ||||||||||||||||||||||||||||
| 97 | _num_visual($visual)) | ||||||||||||||||||||||||||||
| 98 | . substr ($data, 4)); | ||||||||||||||||||||||||||||
| 99 | 1 | } ], | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | [ 'MitScreenSaverUnsetAttributes', # 4 | ||||||||||||||||||||||||||||
| 102 | \&_request_card32s ], # ($X, $drawable) | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | ]; | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub _num_visual { | ||||||||||||||||||||||||||
|
Subroutine
_num_visual: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 107 | 0 | my ($visual) = @_; | |||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($visual eq 'CopyFromParent') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | return 0; | |||||||||||||||||||||||||||
| 110 | } else { | ||||||||||||||||||||||||||||
| 111 | 0 | return $visual; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 1 | my $MitScreenSaverNotify_event | |||||||||||||||||||||||||||
| 118 | = [ 'xCxxLLLCC', | ||||||||||||||||||||||||||||
| 119 | ['state','MitScreenSaverState'], | ||||||||||||||||||||||||||||
| 120 | 'time', | ||||||||||||||||||||||||||||
| 121 | 'root', | ||||||||||||||||||||||||||||
| 122 | 'window', | ||||||||||||||||||||||||||||
| 123 | ['kind','MitScreenSaverKind'], | ||||||||||||||||||||||||||||
| 124 | 'forced' ]; | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 1 | my %const_arrays | |||||||||||||||||||||||||||
| 129 | = ( | ||||||||||||||||||||||||||||
| 130 | MitScreenSaverKind => ['Blanked', 'Internal', 'External'], | ||||||||||||||||||||||||||||
| 131 | MitScreenSaverState => ['Off', 'On', 'Cycle', 'Disabled'], | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | # not sure about this one yet | ||||||||||||||||||||||||||||
| 134 | # MitScreenSaverEventMask => ['Notify', 'Cycle'], | ||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||
| 136 | my %const_hashes | ||||||||||||||||||||||||||||
| 137 | 1 | = (map { $_ => { X11::Protocol::make_num_hash($const_arrays{$_}) } } | |||||||||||||||||||||||||||
| 138 | keys %const_arrays); | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | 0 | my ($class, $X, $request_num, $event_num, $error_num) = @_; | |||||||||||||||||||||||||||
| 144 | ### MIT_SCREEN_SAVER new() | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | # Constants | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | %{$X->{'ext_const'}} = (%{$X->{'ext_const'} ||= {}}, %const_arrays); | ||||||||||||||||||||||||||
|
Condition0%0/2
$X->{"ext_const"} ||= {}
MC/DC0%0/1
$X->{"ext_const"} ||= {}
$X->{"ext_const"}
Truth table0%0/2
A
A= $X->{"ext_const"}
| |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | %{$X->{'ext_const_num'}} = (%{$X->{'ext_const_num'} ||= {}}, %const_hashes); | ||||||||||||||||||||||||||
|
Condition0%0/2
$X->{"ext_const_num"} ||= {}
MC/DC0%0/1
$X->{"ext_const_num"} ||= {}
$X->{"ext_const_num"}
Truth table0%0/2
A
A= $X->{"ext_const_num"}
| |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | # Events | ||||||||||||||||||||||||||||
| 151 | 0 | $X->{'ext_const'}{'Events'}[$event_num] = 'MitScreenSaverNotify'; | |||||||||||||||||||||||||||
| 152 | 0 | $X->{'ext_events'}[$event_num] = $MitScreenSaverNotify_event; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | _ext_requests_install ($X, $request_num, $reqs); | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | # my ($server_major, $server_minor) = $X->req ('MitScreenSaverQueryVersion', | ||||||||||||||||||||||||||||
| 157 | # CLIENT_MAJOR_VERSION, | ||||||||||||||||||||||||||||
| 158 | # CLIENT_MINOR_VERSION); | ||||||||||||||||||||||||||||
| 159 | # ### $server_major | ||||||||||||||||||||||||||||
| 160 | # ### $server_minor | ||||||||||||||||||||||||||||
| 161 | 0 | return bless { | |||||||||||||||||||||||||||
| 162 | # major => $server_major, | ||||||||||||||||||||||||||||
| 163 | # minor => $server_minor, | ||||||||||||||||||||||||||||
| 164 | }, $class; | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub _ext_requests_install { | ||||||||||||||||||||||||||
|
Subroutine
_ext_requests_install: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 168 | 0 | my ($X, $request_num, $reqs) = @_; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | $X->{'ext_request'}->{$request_num} = $reqs; | |||||||||||||||||||||||||||
| 171 | 0 | my $href = $X->{'ext_request_num'}; | |||||||||||||||||||||||||||
| 172 | 0 | my $i; | |||||||||||||||||||||||||||
| 173 | 0 | foreach $i (0 .. $#$reqs) { | |||||||||||||||||||||||||||
| 174 | 0 | $href->{$reqs->[$i]->[0]} = [$request_num, $i]; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub _request_card32s { | ||||||||||||||||||||||||||
|
Subroutine
_request_card32s: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 179 | 0 | shift; | |||||||||||||||||||||||||||
| 180 | ### _request_card32s(): @_ | ||||||||||||||||||||||||||||
| 181 | 0 | return pack 'L*', @_; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub _interp_none { | ||||||||||||||||||||||||||
|
Subroutine
_interp_none: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 185 | 0 | my ($X, $xid) = @_; | |||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ($X->{'do_interp'} && $xid == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$X->{"do_interp"} and $xid == 0
MC/DC0%0/2
$X->{"do_interp"} and $xid == 0
$X->{"do_interp"}
$xid == 0
Truth table0%0/3
A and B
A= $X->{"do_interp"}B= $xid == 0
| |||||||||||||||||||||||||||||
| 187 | 0 | return 'None'; | |||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||
| 189 | 0 | return $xid; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # Similar to Xlib XScreenSaverSaverRegister() maybe. | ||||||||||||||||||||||||||||
| 194 | # Or plain funcs X11::Protocol::Ext::MIT_SCREEN_SAVER::register() | ||||||||||||||||||||||||||||
| 195 | # set_screen_saver_id() | ||||||||||||||||||||||||||||
| 196 | # get_screen_saver_id() | ||||||||||||||||||||||||||||
| 197 | # | ||||||||||||||||||||||||||||
| 198 | # { | ||||||||||||||||||||||||||||
| 199 | # package X11::Protocol; | ||||||||||||||||||||||||||||
| 200 | # | ||||||||||||||||||||||||||||
| 201 | # sub MitScreenSaverRegister { | ||||||||||||||||||||||||||||
| 202 | # my ($X, $screen, $type, $xid) = @_; | ||||||||||||||||||||||||||||
| 203 | # $X->ChangeProperty ($X->{'screen'}->[$screen]->{'root'}, | ||||||||||||||||||||||||||||
| 204 | # $X->atom('_SCREEN_SAVER_ID'), # property | ||||||||||||||||||||||||||||
| 205 | # $type, | ||||||||||||||||||||||||||||
| 206 | # 32, # format | ||||||||||||||||||||||||||||
| 207 | # 'Replace', | ||||||||||||||||||||||||||||
| 208 | # $xid); | ||||||||||||||||||||||||||||
| 209 | # } | ||||||||||||||||||||||||||||
| 210 | # sub MitScreenSaverUnregister { | ||||||||||||||||||||||||||||
| 211 | # my ($X, $screen) = @_; | ||||||||||||||||||||||||||||
| 212 | # $X->DeleteProperty ($X->{'screen'}->[$screen]->{'root'}, | ||||||||||||||||||||||||||||
| 213 | # $X->atom('_SCREEN_SAVER_ID')); | ||||||||||||||||||||||||||||
| 214 | # } | ||||||||||||||||||||||||||||
| 215 | # sub MitScreenSaverGetRegistered { | ||||||||||||||||||||||||||||
| 216 | # my ($X, $screen, $type, $xid) = @_; | ||||||||||||||||||||||||||||
| 217 | # my ($value, $got_type, $format, $bytes_after) | ||||||||||||||||||||||||||||
| 218 | # = $X->GetProperty ($X->{'screen'}->[$screen]->{'root'}, | ||||||||||||||||||||||||||||
| 219 | # $X->atom('_SCREEN_SAVER_ID'), # property | ||||||||||||||||||||||||||||
| 220 | # $type, | ||||||||||||||||||||||||||||
| 221 | # 0, # offset | ||||||||||||||||||||||||||||
| 222 | # 1, # length | ||||||||||||||||||||||||||||
| 223 | # 0); # delete; | ||||||||||||||||||||||||||||
| 224 | # if ($format == 32) { | ||||||||||||||||||||||||||||
| 225 | # return unpack 'L', $value; | ||||||||||||||||||||||||||||
| 226 | # } else { | ||||||||||||||||||||||||||||
| 227 | # return undef; | ||||||||||||||||||||||||||||
| 228 | # } | ||||||||||||||||||||||||||||
| 229 | # } | ||||||||||||||||||||||||||||
| 230 | # } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 1 | 1; | |||||||||||||||||||||||||||
| 233 | __END__ | ||||||||||||||||||||||||||||