line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 . |
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
|
|
|
1
|
|
573
|
BEGIN { require 5 } |
28
|
|
|
|
|
|
|
package X11::Protocol::Ext::MIT_SCREEN_SAVER; |
29
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
30
|
1
|
|
|
1
|
|
857
|
use X11::Protocol; |
|
1
|
|
|
|
|
14602
|
|
|
1
|
|
|
|
|
62
|
|
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
8
|
use vars '$VERSION', '@CARP_NOT'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
70
|
|
33
|
|
|
|
|
|
|
$VERSION = 30; |
34
|
|
|
|
|
|
|
@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
|
|
|
1
|
|
4
|
use constant CLIENT_MAJOR_VERSION => 1; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
75
|
|
42
|
1
|
|
|
1
|
|
3
|
use constant CLIENT_MINOR_VERSION => 0; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
530
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $reqs = |
47
|
|
|
|
|
|
|
[ |
48
|
|
|
|
|
|
|
[ 'MitScreenSaverQueryVersion', # 0 |
49
|
|
|
|
|
|
|
sub { |
50
|
|
|
|
|
|
|
my ($X, $client_major, $client_minor) = @_; |
51
|
|
|
|
|
|
|
### MitScreenSaverQueryVersion request |
52
|
|
|
|
|
|
|
return pack 'CCxx', $client_major, $client_minor; |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
sub { |
55
|
|
|
|
|
|
|
my ($X, $data) = @_; |
56
|
|
|
|
|
|
|
return unpack 'x8SS', $data; |
57
|
|
|
|
|
|
|
}], |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
[ 'MitScreenSaverQueryInfo', # 1 |
60
|
|
|
|
|
|
|
\&_request_card32s, |
61
|
|
|
|
|
|
|
sub { |
62
|
|
|
|
|
|
|
my ($X, $data) = @_; |
63
|
|
|
|
|
|
|
my ($state, $window, $til_or_since, $idle, $event_mask, $kind) |
64
|
|
|
|
|
|
|
= unpack 'xCx6LLLLC', $data; |
65
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub { |
78
|
|
|
|
|
|
|
### MitScreenSaverSetAttributes request |
79
|
|
|
|
|
|
|
# same args as $X->CreateWindow(), but pack format a bit different |
80
|
|
|
|
|
|
|
my ($X, $drawable, |
81
|
|
|
|
|
|
|
$class, $depth, $visual, |
82
|
|
|
|
|
|
|
$x, $y, $width, $height, |
83
|
|
|
|
|
|
|
$border_width, |
84
|
|
|
|
|
|
|
@values) = @_; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# ChangeWindow |
87
|
|
|
|
|
|
|
my ($data) = &{$X->{'requests'}->[2]->[1]} ($X, $drawable, @values); |
88
|
|
|
|
|
|
|
### $data |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
} ], |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
[ 'MitScreenSaverUnsetAttributes', # 4 |
102
|
|
|
|
|
|
|
\&_request_card32s ], # ($X, $drawable) |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
]; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _num_visual { |
107
|
0
|
|
|
0
|
|
|
my ($visual) = @_; |
108
|
0
|
0
|
|
|
|
|
if ($visual eq 'CopyFromParent') { |
109
|
0
|
|
|
|
|
|
return 0; |
110
|
|
|
|
|
|
|
} else { |
111
|
0
|
|
|
|
|
|
return $visual; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $MitScreenSaverNotify_event |
118
|
|
|
|
|
|
|
= [ 'xCxxLLLCC', |
119
|
|
|
|
|
|
|
['state','MitScreenSaverState'], |
120
|
|
|
|
|
|
|
'time', |
121
|
|
|
|
|
|
|
'root', |
122
|
|
|
|
|
|
|
'window', |
123
|
|
|
|
|
|
|
['kind','MitScreenSaverKind'], |
124
|
|
|
|
|
|
|
'forced' ]; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
= (map { $_ => { X11::Protocol::make_num_hash($const_arrays{$_}) } } |
138
|
|
|
|
|
|
|
keys %const_arrays); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub new { |
143
|
0
|
|
|
0
|
0
|
|
my ($class, $X, $request_num, $event_num, $error_num) = @_; |
144
|
|
|
|
|
|
|
### MIT_SCREEN_SAVER new() |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Constants |
147
|
0
|
|
0
|
|
|
|
%{$X->{'ext_const'}} = (%{$X->{'ext_const'} ||= {}}, %const_arrays); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
148
|
0
|
|
0
|
|
|
|
%{$X->{'ext_const_num'}} = (%{$X->{'ext_const_num'} ||= {}}, %const_hashes); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub _ext_requests_install { |
168
|
0
|
|
|
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
|
|
|
|
|
|
|
sub _request_card32s { |
179
|
0
|
|
|
0
|
|
|
shift; |
180
|
|
|
|
|
|
|
### _request_card32s(): @_ |
181
|
0
|
|
|
|
|
|
return pack 'L*', @_; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub _interp_none { |
185
|
0
|
|
|
0
|
|
|
my ($X, $xid) = @_; |
186
|
0
|
0
|
0
|
|
|
|
if ($X->{'do_interp'} && $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; |
233
|
|
|
|
|
|
|
__END__ |