X11/Protocol/Ext/Composite.pm

filter: Statementstmt 44.0% 22 / 50 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 6 / 15 Podpod 0.0% 0 / 1 totaltotal 38.3% 28 / 73 CC 4 SCAR 13.3
CC
4
Cov
40%
_num_none
12.0
_ext_requests_install
6.0
__ANON__
2.0
CRAP 3.8
« X11/Protocol/Ext/DOUBLE_BUFFER.pm ↑ Summary X11/Protocol/Ext/XINERAMA.pm »
1 # Copyright 2011, 2012, 2013, 2014, 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-composite-dev/compositeproto.txt.gz
20 # http://cgit.freedesktop.org/xorg/proto/compositeproto/plain/compositeproto.txt
21 #
22 # /usr/include/X11/extensions/Xcomposite.h Xlib
23 # /usr/include/X11/extensions/composite.h constants
24 # /usr/include/X11/extensions/compositeproto.h structs
25 #
26 # http://ktown.kde.org/~fredrik/composite_howto.html
27 #
28 # server side source:
29 # http://cgit.freedesktop.org/xorg/xserver/tree/composite/compext.c
30 #
31  
32  
33 1 ▶BEGIN { require 5 }
Subroutine BEGIN: called CC=1 SCAR=0.0
34 package X11::Protocol::Ext::Composite;
35 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use X11::Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 1 ▶use vars '$VERSION', '@CARP_NOT';
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 $VERSION = 31;
40 1 @CARP_NOT = ('X11::Protocol');
41  
42 # uncomment this to run the ### lines
43 #use Smart::Comments;
44  
45  
46 # these not documented yet ...
47 1 ▶use constant CLIENT_MAJOR_VERSION => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use constant CLIENT_MINOR_VERSION => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 my $reqs =
51 [
52 ['CompositeQueryVersion', # 0
53 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 my ($X, $major, $minor) = @_;
55 ### CompositeQueryVersion request
56 0 return pack 'LL', $major, $minor;
57 },
58 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 my ($X, $data) = @_;
60 ### CompositeQueryVersion reply
61 0 return unpack 'x8LL', $data;
62  
63 # Any interest in holding onto the version?
64 # my ($server_major, $server_minor) = unpack 'x8LL', $data;
65 # ### $server_major
66 # ### $server_minor
67 # my $self;
68 # if ($self = $self->{'ext'}{'Composite'}->[3]) {
69 # $self->{'major'} = $server_major;
70 # $self->{'minor'} = $server_minor;
71 # }
72 # return ($server_major, $server_minor);
73 }],
74  
75 ['CompositeRedirectWindow', # 1
76 \&_request_window_and_update ],
77  
78 ['CompositeRedirectSubwindows', # 2
79 \&_request_window_and_update ],
80  
81 ['CompositeUnredirectWindow', # 3
82 \&_request_window_and_update ],
83  
84 ['CompositeUnredirectSubwindows', # 4
85 \&_request_window_and_update ],
86  
87 ['CompositeCreateRegionFromBorderClip', # 5
88 \&_request_xids ], # ($X, $region, $window)
89  
90 #----------------------------------------------
91 # version 0.2
92  
93 ['CompositeNameWindowPixmap', # 6
94 \&_request_xids ], # ($X, $window, $pixmap)
95  
96 #----------------------------------------------
97 # version 0.3
98  
99 ['CompositeGetOverlayWindow', # 7
100 \&_request_xids, # ($X, $window)
101 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 my ($X, $data) = @_;
103 ### CompositeGetOverlayWindow reply
104 0 return unpack 'x8L', $data;
105 1 }],
106  
107 ['CompositeReleaseOverlayWindow', # 8
108 \&_request_xids ], # ($X, $window)
109  
110 #----------------------------------------------
111 # version 0.4
112  
113 # these untested, probably not working
114  
115 # ['CompositeRedirectCoordinate', # 9
116 # sub {
117 # my ($X, $window, $bool) = @_;
118 # ### CompositeRedirectCoordinate request
119 # return pack 'LL', $major, $minor;
120 # },
121 # ['CompositeTransformCoordinate', # 10
122 # sub {
123 # my $X = shift;
124 # my $serial = shift;
125 # my $x = shift;
126 # my $y = shift;
127 # # FIXME: padding ?
128 # return pack('Lss', $serial, $x, $y) . join ('', map {pack 'Lss', @$_});
129 # },
130  
131 ];
132  
133 0 ▶sub _request_window_and_update {
Subroutine _request_window_and_update: not called CC=1 SCAR=6.9
134 0 my ($X, $window, $update) = @_;
135 ### _request_window_and_update()
136 0 return pack ('LCxxx',
137 $window,
138 $X->num('CompositeUpdate',$update));
139 }
140  
141 1 my $CompositeUpdate_array = [ 'Automatic', 'Manual' ];
142 1 my $CompositeUpdate_hash =
143 { X11::Protocol::make_num_hash($CompositeUpdate_array) };
144  
145 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
146 0 my ($class, $X, $request_num, $event_num, $error_num) = @_;
147 ### Composite new()
148  
149 # Constants
150 0 $X->{'ext_const'}->{'CompositeUpdate'} = $CompositeUpdate_array;
151 0 $X->{'ext_const_num'}->{'CompositeUpdate'} = $CompositeUpdate_hash;
152  
153 # Requests
154 0 _ext_requests_install ($X, $request_num, $reqs);
155  
156 # Events
157 # untested, probably not working
158 #
159 # $X->{'ext_const'}{'Events'}[$event_num] = 'CompositeTransformCoordinate';
160 # $X->{'ext_events'}[$event_num] =
161 # [ sub {
162 # my $X = shift;
163 # my $data = shift;
164 # ### CompositeTransformCoordinate unpack: @_[1..$#_]
165 # my ($window, $serial, $x, $y) = unpack 'xxxxLLss', $data;
166 #
167 # return (@_,
168 # name => 'CompositeTransformCoordinate',
169 # serial => $serial,
170 # window => $window,
171 # x => $x,
172 # y => $y,
173 # coordinates => [ map {unpack 'Lss', substr($data,$_*8,8)} 4 .. length($data)/8 ],
174 # );
175 # }, sub {
176 # my ($X, %h) = @_;
177 # return (pack('x4LLss',
178 # $h{'window'},
179 # $h{'serial'},
180 # $h{'x'},
181 # $h{'y'})
182 # . join('',map{pack 'Lss', @$_} $h{'coordinates'}),
183 # 1); # "do_seq" put in sequence number
184 # } ];
185  
186 # Any need to negotiate the version before using?
187 # my ($major, $minor) = $X->req('CompositeQueryVersion',
188 # CLIENT_MAJOR_VERSION,
189 # CLIENT_MINOR_VERSION);
190 # if ($major != 1) {
191 # carp "Unrecognised Composite major version, got $major want 1";
192 # return 0;
193 # }
194 0 return bless {
195 # major => $major,
196 # minor => $minor,
197 }, $class;
198 }
199  
200 0 ▶sub _ext_requests_install {
Subroutine _ext_requests_install: not called CC=2 SCAR=17.9
201 0 my ($X, $request_num, $reqs) = @_;
202  
203 0 $X->{'ext_request'}->{$request_num} = $reqs;
204 0 my $href = $X->{'ext_request_num'};
205 0 my $i;
206 0 foreach $i (0 .. $#$reqs) {
207 0 $href->{$reqs->[$i]->[0]} = [$request_num, $i];
208 }
209 }
210  
211 0 ▶sub _request_xids {
Subroutine _request_xids: not called CC=1 SCAR=6.9
212 0 my $X = shift;
213 ### _request_xids(): @_
214 0 return _request_card32s ($X, map {_num_none($_)} @_);
215 }
216 0 ▶sub _request_card32s {
Subroutine _request_card32s: not called CC=1 SCAR=6.9
217 0 shift;
218 ### _request_card32s(): @_
219 0 return pack 'L*', @_;
220 }
221 0 ▶sub _num_none {
Subroutine _num_none: not called CC=3 SCAR=24.8
222 0 my ($xid) = @_;
223 0 ▶ if (defined $xid && $xid eq 'None') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xid and $xid eq 'None') { } 0 0 0
Condition0%0/3
defined $xid and $xid eq "None"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $xid and $xid eq "None"
defined $xid $xid eq "None"
Truth table0%0/3
A and B
A= defined $xidB= $xid eq "None"
ABresult
0X0
100
111
224 0 return 0;
225 } else {
226 0 return $xid;
227 }
228 }
229  
230 1 1;
231 __END__
« X11/Protocol/Ext/DOUBLE_BUFFER.pm ↑ Summary X11/Protocol/Ext/XINERAMA.pm »