Protocol.pm

filter: Statementstmt 4.0% 57 / 1394 Branchbran 2.8% 11 / 382 Conditioncond 3.7% 3 / 81 MC/DCmcdc 1.9% 1 / 52 Subroutinesub 1.7% 5 / 291 Podpod 71.0% 27 / 38 totaltotal 4.6% 104 / 2238 CC 250 SCAR 39.1
CC
250
Cov
4%
new
420.3
pack_event
342.0
unpack_event
240.0
CRAP 50.1
« Protocol/Ext/RENDER.pm ↑ Summary Auth.pm »
1 #!/usr/bin/perl
2  
3 package X11::Protocol;
4  
5 # Copyright (C) 1997-2000, 2003-2006 Stephen McCamant. All rights
6 # reserved. This program is free software; you can redistribute and/or
7 # modify it under the same terms as Perl itself.
8  
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use vars qw($VERSION $AUTOLOAD @ISA @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 require Exporter;
13  
14 1 @ISA = ('Exporter');
15  
16 1 @EXPORT_OK = qw(pad padding padded hexi make_num_hash default_error_handler);
17  
18 1 $VERSION = "0.56";
19  
20 0 ▶sub padding ($) {
Subroutine padding: not called CC=1 SCAR=6.9
Pod documented
21 0 my($x) = @_;
22 0 -$x & 3;
23 }
24  
25 0 ▶sub pad ($) {
Subroutine pad: not called CC=1 SCAR=6.9
Pod documented
26 0 my($x) = @_;
27 0 padding(length($x));
28 }
29  
30 0 ▶sub padded ($) {
Subroutine padded: not called CC=1 SCAR=6.9
Pod documented
31 0 my $l = length($_[0]);
32 0 "a" . $l . "x" x (-$l & 3);
33 }
34  
35 0 ▶sub hexi ($) {
Subroutine hexi: not called CC=1 SCAR=6.9
Pod documented
36 0 "0x" . sprintf("%x", $_[0]);
37 }
38  
39  
40 1 length(pack("L", 0)) == 4 or croak "can't happen";
41  
42 1 my($Byte_Order, $Card16, $Int16, $Card8, $Int8);
43  
44 1 if (pack("L", 1) eq "\0\0\0\1") {
45 $Byte_Order = 'B';
46 $Int8 = "xxxc";
47 $Card8 = "xxxC";
48 $Int16 = "xxs";
49 $Card16 = "xxS";
50 } elsif (pack("L", 1) eq "\1\0\0\0") {
51 1 $Byte_Order = 'l';
52 1 $Int8 = "cxxx";
53 1 $Card8 = "Cxxx";
54 1 $Int16 = "sxx";
55 1 $Card16 = "Sxx";
56 } else {
57 croak "Can't determine byte order!\n";
58 }
59  
60 1 my($Default_Display);
61  
62 1 ▶if ($^O eq "MSWin32") {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 1 1
63 0 $Default_Display = "localhost";
64 } else {
65 1 $Default_Display = "unix";
66 }
67  
68 0 ▶sub give {
Subroutine give: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my($self) = shift;
70 0 $self->{'connection'}->give(@_);
71 }
72  
73 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my($self) = shift;
75 0 return $self->{'connection'}->get(@_);
76 }
77  
78 0 ▶sub flush {
Subroutine flush: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my $self = shift;
80 0 $self->{'connection'}->flush();
81 }
82  
83 1 my(%Const) =
84 (
85 'VisualClass' => ['StaticGray', 'GrayScale', 'StaticColor',
86 'PseudoColor', 'TrueColor', 'DirectColor'],
87 'BitGravity' => ['Forget', 'Static', 'NorthWest', 'North',
88 'NorthEast', 'West', 'Center', 'East',
89 'SouthWest', 'South', 'SouthEast'],
90 'WinGravity' => ['Unmap', 'Static', 'NorthWest', 'North',
91 'NorthEast', 'West', 'Center', 'East', 'SouthWest',
92 'South', 'SouthEast'],
93 'EventMask' => ['KeyPress', 'KeyRelease', 'ButtonPress', 'ButtonRelease',
94 'EnterWindow', 'LeaveWindow', 'PointerMotion',
95 'PointerMotionHint', 'Button1Motion', 'Button2Motion',
96 'Button3Motion', 'Button4Motion', 'Button5Motion',
97 'ButtonMotion', 'KeymapState', 'Exposure',
98 'VisibilityChange', 'StructureNotify', 'ResizeRedirect',
99 'SubstructureNotify', 'SubstructureRedirect',
100 'FocusChange', 'PropertyChange', 'ColormapChange',
101 'OwnerGrabButton'],
102 'Events' => [0, 0, 'KeyPress' , 'KeyRelease', 'ButtonPress',
103 'ButtonRelease', 'MotionNotify', 'EnterNotify',
104 'LeaveNotify', 'FocusIn', 'FocusOut', 'KeymapNotify',
105 'Expose', 'GraphicsExposure', 'NoExposure',
106 'VisibilityNotify', 'CreateNotify', 'DestroyNotify',
107 'UnmapNotify', 'MapNotify', 'MapRequest',
108 'ReparentNotify', 'ConfigureNotify', 'ConfigureRequest',
109 'GravityNotify', 'ResizeRequest', 'CirculateNotify',
110 'CirculateRequest', 'PropertyNotify', 'SelectionClear',
111 'SelectionRequest', 'SelectionNotify',
112 'ColormapNotify', 'ClientMessage', 'MappingNotify'],
113 'PointerEvent' => [0, 0, 'ButtonPress', 'ButtonRelease',
114 'EnterWindow', 'LeaveWindow', 'PointerMotion',
115 'PointerMotionHint', 'Button1Motion',
116 'Button2Motion', 'Button3Motion', 'Button4Motion',
117 'Button5Motion', 'ButtonMotion', 'KeymapState'],
118 'DeviceEvent' => ['KeyPress', 'KeyRelease', 'ButtonPress',
119 'ButtonRelease', 0, 0, 'PointerMotion',
120 'PointerMotionHint', 'Button1Motion',
121 'Button2Motion', 'Button3Motion', 'Button4Motion',
122 'Button5Motion', 'ButtonMotion'],
123 'KeyMask' => ['Shift', 'Lock', 'Control', 'Mod1', 'Mod2', 'Mod3',
124 'Mod4', 'Mod5'],
125 'Significance' => ['LeastSignificant', 'MostSignificant'],
126 'BackingStore' => ['Never', 'WhenMapped', 'Always'],
127 'Bool' => ['False', 'True'],
128 'Class' => ['CopyFromParent', 'InputOutput', 'InputOnly'],
129 'MapState' => ['Unmapped', 'Unviewable', 'Viewable'],
130 'StackMode' => ['Above', 'Below', 'TopIf', 'BottomIf', 'Opposite'],
131 'CirculateDirection' => ['RaiseLowest', 'LowerHighest'],
132 'ChangePropertyMode' => ['Replace', 'Prepend', 'Append'],
133 'CrossingNotifyDetail' => ['Ancestor', 'Virtual', 'Inferior',
134 'Nonlinear', 'NonlinearVirtual'],
135 'CrossingNotifyMode' => ['Normal', 'Grab', 'Ungrab'],
136 'FocusDetail' => ['Ancestor', 'Virtual', 'Inferior', 'Nonlinear',
137 'NonlinearVirtual', 'Pointer', 'PointerRoot',
138 'None'],
139 'FocusMode' => ['Normal', 'Grab', 'Ungrab', 'WhileGrabbed'],
140 'VisibilityState' => ['Unobscured', 'PartiallyObscured',
141 'FullyObscured'],
142 'CirculatePlace' => ['Top', 'Bottom'],
143 'PropertyNotifyState' => ['NewValue', 'Deleted'],
144 'ColormapNotifyState' => ['Uninstalled', 'Installed'],
145 'MappingNotifyRequest' => ['Modifier', 'Keyboard', 'Pointer'],
146 'SyncMode' => ['Synchronous', 'Asynchronous'],
147 'GrabStatus' => ['Success', 'AlreadyGrabbed', 'InvalidTime',
148 'NotViewable', 'Frozen'],
149 'AllowEventsMode' => ['AsyncPointer', 'SyncPointer', 'ReplayPointer',
150 'AsyncKeyboard', 'SyncKeyboard',
151 'ReplayKeyboard', 'AsyncBoth', 'SyncBoth'],
152 'InputFocusRevertTo' => ['None', 'PointerRoot', 'Parent'],
153 'DrawDirection' => ['LeftToRight', 'RightToLeft'],
154 'ClipRectangleOrdering' => ['UnSorted', 'YSorted', 'YXSorted',
155 'YXBanded'],
156 'CoordinateMode' => ['Origin', 'Previous'],
157 'PolyShape' => ['Complex', 'Nonconvex', 'Convex'],
158 'ImageFormat' => ['Bitmap', 'XYPixmap', 'ZPixmap'],
159 'SizeClass' => ['Cursor', 'Tile', 'Stipple'],
160 'LedMode' => ['Off', 'On'],
161 'AutoRepeatMode' => ['Off', 'On', 'Default'],
162 'ScreenSaver' => ['No', 'Yes', 'Default'],
163 'HostChangeMode' => ['Insert', 'Delete'],
164 'HostFamily' => ['Internet', 'DECnet', 'Chaos', 0, 0,
165 'ServerInterpreted', 'InternetV6'],
166 'AccessMode' => ['Disabled', 'Enabled'],
167 'CloseDownMode' => ['Destroy', 'RetainPermanent', 'RetainTemporary'],
168 'ScreenSaverAction' => ['Reset', 'Activate'],
169 'MappingChangeStatus' => ['Success', 'Busy', 'Failed'],
170 'GCFunction' => ['Clear', 'And', 'AndReverse', 'Copy',
171 'AndInverted', 'NoOp', 'Xor', 'Or', 'Nor', 'Equiv',
172 'Invert', 'OrReverse', 'CopyInverted', 'OrInverted',
173 'Nand', 'Set'],
174 'GCLineStyle' => ['Solid', 'OnOffDash', 'DoubleDash'],
175 'GCCapStyle' => ['NotLast', 'Butt', 'Round', 'Projecting'],
176 'GCJoinStyle' => ['Miter', 'Round', 'Bevel'],
177 'GCFillStyle' => ['Solid', 'Tiled', 'Stippled', 'OpaqueStippled'],
178 'GCFillRule' => ['EvenOdd', 'Winding'],
179 'GCSubwindowMode' => ['ClipByChildren', 'IncludeInferiors'],
180 'GCArcMode' => ['Chord', 'PieSlice'],
181 'Error' => [0, 'Request', 'Value', 'Window', 'Pixmap', 'Atom',
182 'Cursor', 'Font', 'Match', 'Drawable', 'Access', 'Alloc',
183 'Colormap', 'GContext', 'IDChoice', 'Name', 'Length',
184 'Implementation'],
185 );
186  
187 1 my(%Const_num) = (); # Filled in dynamically
188  
189 0 ▶sub interp {
Subroutine interp: not called CC=2 SCAR=17.9
Pod documented
190 0 my($self) = shift;
191 0 ▶ return $_[1] unless $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"do_interp"} 0 0 0
192 0 return $self->do_interp(@_);
193 }
194  
195 0 ▶sub do_interp {
Subroutine do_interp: not called CC=5 SCAR=34.0
Pod undocumented
196 0 my $self = shift;
197 0 my($type, $num) = @_;
198 carp "Unknown constant type `$type'\n"
199 unless exists $self->{'const'}{$type}
200 0 ▶ or exists $self->{'ext_const'}{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"const"}{$type} or exists $self->{"ext_const"}{$type} 0 0 0
Condition0%0/3
exists $self->{"const"}{$type} or exists $self->{"ext_const"}{$type}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $self->{"const"}{$type} or exists $self->{"ext_const"}{$type}
exists $self->{"const"}{$type} exists $self->{"ext_const"}{$type}
Truth table0%0/3
A or B
A= exists $self->{"const"}{$type}B= exists $self->{"ext_const"}{$type}
ABresult
1X1
011
000
201 0 ▶ return $num if $num < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num < 0 0 0 0
202 0 ▶ return $self->{'const'}{$type}[$num] || $self->{'ext_const'}{$type}[$num];
Condition0%0/3
$self->{'const'}{$type}[$num] || $self->{'ext_const'}{$type}[$num]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'const'}{$type}[$num] || $self->{'ext_const'}{$type}[$num]
$self->{'const'}{$type}[$num] $self->{'ext_const'}{$type}[$num]
Truth table0%0/3
A || B
A= $self->{'const'}{$type}[$num]B= $self->{'ext_const'}{$type}[$num]
ABresult
1X1
011
000
203 }
204  
205 0 ▶sub make_num_hash {
Subroutine make_num_hash: not called CC=1 SCAR=6.9
Pod documented
206 0 my($from) = @_;
207 0 my(%hash);
208 0 @hash{@$from} = (0 .. $#{$from});
209 0 return %hash;
210 }
211  
212 0 ▶sub num ($$) {
Subroutine num: not called CC=6 SCAR=37.4
Pod documented
213 0 my($self) = shift;
214 0 my($type, $x) = @_;
215 carp "Unknown constant type `$type'\n"
216 unless exists $self->{'const'}{$type}
217 0 ▶ or exists $self->{'ext_const'}{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"const"}{$type} or exists $self->{"ext_const"}{$type} 0 0 0
Condition0%0/3
exists $self->{"const"}{$type} or exists $self->{"ext_const"}{$type}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $self->{"const"}{$type} or exists $self->{"ext_const"}{$type}
exists $self->{"const"}{$type} exists $self->{"ext_const"}{$type}
Truth table0%0/3
A or B
A= exists $self->{"const"}{$type}B= exists $self->{"ext_const"}{$type}
ABresult
1X1
011
000
218 $self->{'const_num'}{$type} = {make_num_hash($self->{'const'}{$type})}
219 0 ▶ unless exists $self->{'const_num'}{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"const_num"}{$type} 0 0 0
220 0 ▶ if (exists $self->{'const_num'}{$type}{$x}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'const_num'}{$type}{$x}) { } 0 0 0
elsif (exists $self->{'ext_const_num'}{$type}{$x}) { } 0 0 0
221 0 return $self->{'const_num'}{$type}{$x};
222 } elsif (exists $self->{'ext_const_num'}{$type}{$x}) {
223 0 return $self->{'ext_const_num'}{$type}{$x};
224 } else {
225 0 return $x;
226 }
227 }
228  
229 my(@Attributes_ValueMask) =
230 0 ▶ (["background_pixmap", sub {$_[1] = 0 if $_[1] eq "None";
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "None" 0 0 0
231 0 ▶ $_[1] = 1 if $_[1] eq "ParentRelative";
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "ParentRelative" 0 0 0
232 0 pack "L", $_[1];}],
233 0 ▶ ["background_pixel", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
234 0 ▶ ["border_pixmap", sub {$_[1] = 0 if $_[1] eq "CopyFromParent";
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "CopyFromParent" 0 0 0
235 0 pack "L", $_[1];}],
236 0 ▶ ["border_pixel", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
237 0 ▶ ["bit_gravity", sub {$_[1] = $_[0]->num('BitGravity', $_[1]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
238 0 pack $Card8, $_[1];}],
239 0 ▶ ["win_gravity", sub {$_[1] = $_[0]->num('WinGravity', $_[1]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
240 0 pack $Card8, $_[1];}],
241 0 ▶ ["backing_store", sub {$_[1] = 0 if $_[1] eq "NotUseful";
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "NotUseful" 0 0 0
242 0 ▶ $_[1] = 1 if $_[1] eq "WhenMapped";
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "WhenMapped" 0 0 0
243 0 ▶ $_[1] = 2 if $_[1] eq "Always";
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "Always" 0 0 0
244 0 pack $Card8, $_[1];}],
245 0 ▶ ["backing_planes", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
246 0 ▶ ["backing_pixel", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
247 0 ▶ ["override_redirect", sub {pack $Card8, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
248 0 ▶ ["save_under", sub {pack $Card8, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
249 0 ▶ ["event_mask", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
250 0 ▶ ["do_not_propagate_mask", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
251 0 ▶ ["colormap", sub {$_[1] = 0 if $_[1] eq "CopyFromParent";
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "CopyFromParent" 0 0 0
252 0 pack "L", $_[1];}],
253 0 ▶ ["cursor", sub {$_[1] = 0 if $_[1] eq "None";
Subroutine __ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "None" 0 0 0
254 0 pack "L", $_[1];}]);
255  
256 my(@Configure_ValueMask) =
257 0 ▶ (["x", sub {pack $Int16, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
258 0 ▶ ["y", sub {pack $Int16, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
259 0 ▶ ["width", sub {pack $Card16, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
260 0 ▶ ["height", sub {pack $Card16, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
261 0 ▶ ["border_width", sub {pack $Card16, $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
262 0 ▶ ["sibling", sub {pack "L", $_[1];}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
263 0 ▶ ["stack_mode", sub {$_[1] = $_[0]->num('StackMode', $_[1]);
Subroutine __ANON__: not called CC=1 SCAR=2.6
264 0 pack $Card8, $_[1];}]);
265  
266 my(@GC_ValueMask) =
267 0 ▶ (['function', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
268 0 $_[1] = $_[0]->num('GCFunction', $_[1]);
269 0 $_[1] = pack($Card8, $_[1]);
270 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
271 0 ▶ ['plane_mask', sub {$_[1] = pack("L", $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
272 0 ▶ ['foreground', sub {$_[1] = pack("L", $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
273 0 ▶ ['background', sub {$_[1] = pack("L", $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
274 0 ▶ ['line_width', sub {$_[1] = pack($Card16, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
275 0 ▶ ['line_style', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
276 0 $_[1] = $_[0]->num('GCLineStyle', $_[1]);
277 0 $_[1] = pack($Card8, $_[1]);
278 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
279 0 ▶ ['cap_style', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
280 0 $_[1] = $_[0]->num('GCCapStyle', $_[1]);
281 0 $_[1] = pack($Card8, $_[1]);
282 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
283 0 ▶ ['join_style', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
284 0 $_[1] = $_[0]->num('GCJoinStyle', $_[1]);
285 0 $_[1] = pack($Card8, $_[1]);
286 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
287 0 ▶ ['fill_style', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
288 0 $_[1] = $_[0]->num('GCFillStyle', $_[1]);
289 0 $_[1] = pack($Card8, $_[1]);
290 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
291 0 ▶ ['fill_rule', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
292 0 $_[1] = $_[0]->num('GCFillRule', $_[1]);
293 0 $_[1] = pack($Card8, $_[1]);
294 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
295 0 ▶ ['tile', sub {$_[1] = pack("L", $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
296 0 ▶ ['stipple', sub {$_[1] = pack("L", $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
297 0 ▶ ['tile_stipple_x_origin', sub {$_[1] = pack($Int16, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
298 0 ▶ ['tile_stipple_y_origin', sub {$_[1] = pack($Int16, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
299 0 ▶ ['font', sub {$_[1] = pack("L", $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
300 0 ▶ ['subwindow_mode', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
301 0 $_[1] = $_[0]->num('GCSubwindowMode', $_[1]);
302 0 $_[1] = pack($Card8, $_[1]);
303 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
304 0 ▶ ['graphics_exposures', sub {$_[1] = pack($Card8, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
305 0 ▶ ['clip_x_origin', sub {$_[1] = pack($Int16, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
306 0 ▶ ['clip_y_origin', sub {$_[1] = pack($Int16, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
307 0 ▶ ['clip_mask', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
308 0 ▶ $_[1] = 0 if $_[1] eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] eq "None" 0 0 0
309 0 $_[1] = pack("L", $_[1]);
310 0 ▶ }, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=0.0
311 0 ▶ ['dash_offset', sub {$_[1] = pack($Card16, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
312 0 ▶ ['dashes', sub {$_[1] = pack($Card8, $_[1]);}, sub {}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
313 0 ▶ ['arc_mode', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
314 0 $_[1] = $_[0]->num('GCArcMode', $_[1]);
315 0 $_[1] = pack($Card8, $_[1]);
316 1 ▶ }, sub {}]);
Subroutine __ANON__: not called CC=1 SCAR=0.0
317  
318 my(@KeyboardControl_ValueMask) =
319 0 ▶ (['key_click_percent', sub {$_[1] = pack($Int8, $_[1]);}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
320 0 ▶ ['bell_percent', sub {$_[1] = pack($Int8, $_[1]);}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
321 0 ▶ ['bell_pitch', sub {$_[1] = pack($Int16, $_[1])}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
322 0 ▶ ['bell_duration', sub {$_[1] = pack($Int16, $_[1])}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
323 0 ▶ ['led', sub {$_[1] = pack($Card8, $_[1])}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
324 0 ▶ ['led_mode', sub {$_[1] = $_[0]->num('LedMode', $_[1]);
Subroutine __ANON__: not called CC=1 SCAR=6.9
325 0 $_[1] = pack($Card8, $_[1]);}],
326 0 ▶ ['key', sub {$_[1] = pack($Card8, $_[1]);}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
327 0 ▶ ['auto_repeat_mode', sub {$_[1] = $_[0]->num('AutoRepeatMode', $_[1]);
Subroutine __ANON__: not called CC=1 SCAR=2.6
328 0 $_[1] = pack($Card8, $_[1]);}]);
329  
330 my(@Events) =
331 (0, 0,
332 # if ($code >= 2 and $code <= 5) # (Key|Button)(Press|Release)
333 (["xCxxLLLLssssSCx", 'detail', 'time', 'root', 'event',
334 ['child', ['None']], 'root_x', 'root_y', 'event_x', 'event_y',
335 'state', 'same_screen']) x 4,
336 # elsif ($code == 6) # MotionNotify
337 ["xCxxLLLLssssSCx", ['detail', ['Normal', 'Hint']], 'time', 'root',
338 'event', ['child', ['None']], 'root_x', 'root_y', 'event_x',
339 'event_y', 'state', 'same_screen'],
340 # elsif ($code == 7 or $code == 8) # (Enter|Leave)Notify
341 (["xCxxLLLLssssSCC", ['detail', 'CrossingNotifyDetail'], 'time',
342 'root', 'event', ['child', ['None']], 'root_x', 'root_y',
343 'event_x', 'event_y', 'state', ['mode', 'CrossingNotifyMode'],
344 0 ▶ [0, sub {$_[0]{'flags'} |= 1 if $_[0]{'focus'};
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"focus"} 0 0 0
345 0 ▶ $_[0]{'flags'} |= 2 if $_[0]{'same_screen'};}],
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"same_screen"} 0 0 0
346 'flags',
347 0 ▶ [sub {$_[0]{'focus'} = $_[0]{'flags'} & 1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
348 0 $_[0]{'same_screen'} = (($_[0]{'flags'} & 2) != 0)}, 0]
349 ]) x 2,
350 # elsif ($code == 9 or $code == 10) # Focus(In|Out)
351 (["xCxxLCxxxxxxxxxxxxxxxxxxxxxxx", ['detail', 'FocusDetail'], 'event',
352 ['mode', 'FocusMode']]) x 2,
353 # elsif ($code == 11) # KeymapNotify (weird)
354 0 ▶ [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
355 0 my($self, $data, %h) = @_;
356 0 my($keys) = "\0" . substr($data, 1, 31);
357 0 $h{'keys'} = $keys;
358 0 delete $h{sequence_number};
359 0 return %h;
360 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
361 0 my $self = shift;
362 0 my(%h) = @_;
363 0 my($data) = "\0" . substr($h{"keys"}, 1, 31);
364 0 return ($data, 0);
365 }],
366 # elsif ($code == 12) # Expose
367 ["xxxxLSSSSSxxxxxxxxxxxxxx", 'window', 'x', 'y', 'width', 'height',
368 'count'],
369 # elsif ($code == 13) # GraphicsExposure
370 ["xxxxLSSSSSSCxxxxxxxxxxx", 'drawable', 'x', 'y', 'width', 'height',
371 'minor_opcode', 'count', 'major_opcode'],
372 # elsif ($code == 14) # NoExposure
373 ["xxxxLSCxxxxxxxxxxxxxxxxxxxxx", 'drawable', 'minor_opcode',
374 'major_opcode'],
375 # elsif ($code == 15) # VisibilityNotify
376 ["xxxxLCxxxxxxxxxxxxxxxxxxxxxxx", 'window', ['state', 'VisibilityState']],
377 # elsif ($code == 16) # CreateNotify
378 ["xxxxLLssSSSCxxxxxxxxx", 'parent', 'window', 'x', 'y', 'width',
379 'height', 'border_width', 'override_redirect'],
380 # elsif ($code == 17) # DestroyNotify
381 ["xxxxLLxxxxxxxxxxxxxxxxxxxx", 'event', 'window'],
382 # elsif ($code == 18) # UnmapNotify
383 ["xxxxLLCxxxxxxxxxxxxxxxxxxx", 'event', 'window', 'from_configure'],
384 # elsif ($code == 19) # MapNotify
385 ["xxxxLLCxxxxxxxxxxxxxxxxxxx", 'event', 'window', 'override_redirect'],
386 # elsif ($code == 20) # MapRequest
387 ["xxxxLLxxxxxxxxxxxxxxxxxxxx", 'parent', 'window'],
388 # elsif ($code == 21) # ReparentNotify
389 ["xxxxLLLssCxxxxxxxxxxx", 'event', 'window', 'parent', 'x', 'y',
390 'override_redirect'],
391 # elsif ($code == 22) # ConfigureNotify
392 ["xxxxLLLssSSSCxxxxx", 'event', 'window', 'above_sibling', 'x', 'y',
393 'width', 'height', 'border_width', 'override_redirect'],
394 # elsif ($code == 23) # ConfigureRequest
395 ["xCxxLLLssSSSSxxxx", ['stack_mode', 'StackMode'], 'parent', 'window',
396 0 ▶ [0, sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
397 0 my($m) = 0;
398 0 ▶ $m = 1 if exists $_[0]{'x'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"x"} 0 0 0
399 0 ▶ $m |= 2 if exists $_[0]{'y'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"y"} 0 0 0
400 0 ▶ $m |= 4 if exists $_[0]{'width'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"width"} 0 0 0
401 0 ▶ $m |= 8 if exists $_[0]{'height'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"height"} 0 0 0
402 0 ▶ $m |= 16 if exists $_[0]{'border_width'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"border_width"} 0 0 0
403 0 ▶ $m |= 32 if exists $_[0]{'sibling'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"sibling"} 0 0 0
404 0 ▶ $m |= 64 if exists $_[0]{'stack_mode'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]{"stack_mode"} 0 0 0
405 0 $_[0]{'mask'} = $m;
406 }],
407 ['sibling', ['None']], 'x', 'y', 'width', 'height', 'border_width',
408 'mask',
409 0 ▶ [sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
410 0 my($m) = $_[0]{'mask'};
411 0 ▶ delete $_[0]{'x'} unless $m & 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 1 0 0 0
412 0 ▶ delete $_[0]{'y'} unless $m & 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 2 0 0 0
413 0 ▶ delete $_[0]{'width'} unless $m & 4;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 4 0 0 0
414 0 ▶ delete $_[0]{'height'} unless $m & 8;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 8 0 0 0
415 0 ▶ delete $_[0]{'border_width'} unless $m & 16;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 16 0 0 0
416 0 ▶ delete $_[0]{'sibling'} unless $m & 32;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 32 0 0 0
417 0 ▶ delete $_[0]{'stack_mode'} unless $m & 64;
Branch: 1 branch
BranchTrueFalseTotal
unless $m & 64 0 0 0
418 }, 0]],
419 # elsif ($code == 24) # GravityNotify
420 ["xxxxLLssxxxxxxxxxxxxxxxx", 'event', 'window', 'x', 'y'],
421 # elsif ($code == 25) # ResizeRequest
422 ["xxxxLSSxxxxxxxxxxxxxxxxxxxx", 'window', 'width', 'height'],
423 # elsif ($code == 26 or $code == 27) # Circulate(Notify|Request)
424 (["xxxxLLxxxxCxxxxxxxxxxxxxxx", 'event', 'window',
425 ['place', 'CirculatePlace']]) x 2,
426 # elsif ($code == 28) # PropertyNotify
427 ["xxxxLLLCxxxxxxxxxxxxxxx", 'window', 'atom', 'time',
428 ['state', 'PropertyNotifyState']],
429 # elsif ($code == 29) # SelectionClear
430 ["xxxxLLLxxxxxxxxxxxxxxxx", 'time', 'owner', 'selection'],
431 # elsif ($code == 30) # SelectionRequest
432 ["xxxxLLLLLLxxxx", ['time', ['CurrentTime']], 'owner', 'requestor',
433 'selection', 'target', ['property', ['None']]],
434 # elsif ($code == 31) # SelectionNotify
435 ["xxxxLLLLLxxxxxxxx", ['time', ['CurrentTime']], 'requestor', 'selection',
436 'target', ['property', ['None']]],
437 # elsif ($code == 32) # ColormapNotify
438 ["xxxxLLCCxxxxxxxxxxxxxxxxxx", 'window', ['colormap', ['None']], 'new',
439 ['state', 'ColormapNotifyState']],
440 # elsif ($code == 33) # ClientMessage
441 0 ▶ [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
442 0 my($self, $data, %h) = @_;
443 0 my($format) = unpack("C", substr($data, 1, 1));
444 0 my($win, $type) = unpack("LL", substr($data, 4, 8));
445 0 my($dat) = substr($data, 12, 20);
446 0 return (%h, 'window' => $win, 'type' => $type, 'data' => $dat,
447 'format' => $format);
448 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
449 0 my $self = shift;
450 0 my(%h) = @_;
451 my($data) = pack("xCxxLL", $h{'format'}, $h{window}, $h{type})
452 0 . substr($h{data}, 0, 20);
453 0 return ($data, 1);
454 1 }],
455 # elsif ($code == 34) # MappingNotify
456 ["xxxxCCCxxxxxxxxxxxxxxxxxxxxxxxxx", ['request', 'MappingNotifyRequest'],
457 'first_keycode', 'count']
458 );
459  
460 0 ▶sub unpack_event {
Subroutine unpack_event: not called CC=15 SCAR=54.8
Pod documented
461 0 my $self = shift;
462 0 my($data) = @_;
463 0 my($code, $detail, $seq) = unpack("CCS", substr($data, 0, 4));
464 0 my($name) = $self->do_interp('Events', $code & 127);
465 0 my(%ret);
466 0 ▶ $ret{'synthetic'} = 1 if $code & 128; $code &= 127;
Branch: 1 branch
BranchTrueFalseTotal
if $code & 128 0 0 0
467 0 $ret{'name'} = $name;
468 0 $ret{'code'} = $code;
469 0 $ret{'sequence_number'} = $seq;
470 0 my($info);
471 0 ▶ $info = $self->{'events'}[$code] || $self->{'ext_events'}[$code];
Condition0%0/3
$self->{'events'}[$code] || $self->{'ext_events'}[$code]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'events'}[$code] || $self->{'ext_events'}[$code]
$self->{'events'}[$code] $self->{'ext_events'}[$code]
Truth table0%0/3
A || B
A= $self->{'events'}[$code]B= $self->{'ext_events'}[$code]
ABresult
1X1
011
000
472  
473 0 ▶ if ($info) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info) { } 0 0 0
474 0 my(@i) = @$info;
475 0 ▶ if (ref $i[0] eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $i[0] eq 'CODE') { } 0 0 0
476 0 %ret = &{$i[0]}($self, $data, %ret);
477 } else {
478 0 my($format, @fields) = @i;
479 0 my(@unpacked) = unpack($format, $data);
480 0 my($f);
481 0 for $f (@fields) {
482 0 ▶ if (not ref $f) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $f) { } 0 0 0
483 0 $ret{$f} = shift @unpacked;
484 } else {
485 0 my(@f) = @$f;
486 0 ▶ if (ref $f[0] eq "CODE" or ref $f[1] eq "CODE") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $f[0] eq 'CODE' or ref $f[1] eq 'CODE') { } 0 0 0
elsif (not ref $f[1]) { } 0 0 0
Condition0%0/3
ref $f[0] eq "CODE" or ref $f[1] eq "CODE"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $f[0] eq "CODE" or ref $f[1] eq "CODE"
ref $f[0] eq "CODE" ref $f[1] eq "CODE"
Truth table0%0/3
A or B
A= ref $f[0] eq "CODE"B= ref $f[1] eq "CODE"
ABresult
1X1
011
000
487 0 ▶ &{$f[0]}(\%ret) if $f[0];
Branch: 1 branch
BranchTrueFalseTotal
if $f[0] 0 0 0
488 } elsif (not ref $f[1]) {
489 0 $ret{$f[0]} = $self->interp($f[1], shift @unpacked);
490 } else {
491 0 my($v) = shift @unpacked;
492 0 ▶ $v = $f[1][$v] if $self->{'do_interp'} and
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"do_interp"} and $v == 0 || $v == 1 && $f[1][1] 0 0 0
Condition0%0/9
$self->{"do_interp"} and $v == 0 || $v == 1 && $f[1][1]
!ll&&!rl&&r
000
$v == 0 or $v == 1 and $f[1][1]
l!l&&r!l&&!r
000
$v == 1 and $f[1][1]
!ll&&!rl&&r
000
MC/DC0%0/4
$self->{"do_interp"} and $v == 0 || $v == 1 && $f[1][1]
$self->{"do_interp"} $v == 0 $v == 1 $f[1][1]
Truth table0%0/5
A and B or C and D
A= $self->{"do_interp"}B= $v == 0C= $v == 1D= $f[1][1]
ABCDresult
0XXX0
100X0
10100
11XX1
10111
493 ($v == 0 or $v == 1 && $f[1][1]);
494 0 $ret{$f[0]} = $v;
495 }
496 }
497 }
498 }
499 } else {
500 0 carp "Unknown event (code $code)!";
501 0 $ret{'data'} = $data;
502 }
503 0 return %ret;
504 }
505  
506 0 ▶sub pack_event {
Subroutine pack_event: not called CC=18 SCAR=58.3
Pod documented
507 0 my $self = shift;
508 0 my(%h) = @_;
509 0 my($code) = $h{code};
510 0 ▶ $code = $self->num('Events', $h{name}) unless exists $h{code};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $h{"code"} 0 0 0
511 0 ▶ $h{sequence_number} = 0 unless $h{sequence_number};
Branch: 1 branch
BranchTrueFalseTotal
unless $h{"sequence_number"} 0 0 0
512 0 ▶ $h{synthetic} = 0 unless $h{synthetic};
Branch: 1 branch
BranchTrueFalseTotal
unless $h{"synthetic"} 0 0 0
513 0 my($data, $info);
514 0 my($do_seq) = 1;
515 0 ▶ $info = $self->{'events'}[$code] || $self->{'ext_events'}[$code];
Condition0%0/3
$self->{'events'}[$code] || $self->{'ext_events'}[$code]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'events'}[$code] || $self->{'ext_events'}[$code]
$self->{'events'}[$code] $self->{'ext_events'}[$code]
Truth table0%0/3
A || B
A= $self->{'events'}[$code]B= $self->{'ext_events'}[$code]
ABresult
1X1
011
000
516  
517 0 ▶ if ($info) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info) { } 0 0 0
518 0 my(@i) = @$info;
519 0 ▶ if (ref $i[0] eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $i[0] eq 'CODE') { } 0 0 0
520 0 ($data, $do_seq) = &{$i[1]}($self, %h);
521 } else {
522 0 my($format, @fields) = @i;
523 0 my(@topack) = ();
524 0 my($f);
525 0 for $f (@fields) {
526 0 ▶ if (not ref $f) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $f) { } 0 0 0
527 0 push @topack, $h{$f};
528 } else {
529 0 my(@f) = @$f;
530 0 ▶ if (ref $f[0] eq "CODE" or ref $f[1] eq "CODE") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $f[0] eq 'CODE' or ref $f[1] eq 'CODE') { } 0 0 0
elsif (not ref $f[1]) { } 0 0 0
Condition0%0/3
ref $f[0] eq "CODE" or ref $f[1] eq "CODE"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $f[0] eq "CODE" or ref $f[1] eq "CODE"
ref $f[0] eq "CODE" ref $f[1] eq "CODE"
Truth table0%0/3
A or B
A= ref $f[0] eq "CODE"B= ref $f[1] eq "CODE"
ABresult
1X1
011
000
531 0 ▶ &{$f[1]}(\%h) if $f[1];
Branch: 1 branch
BranchTrueFalseTotal
if $f[1] 0 0 0
532 } elsif (not ref $f[1]) {
533 0 push @topack, $self->num($f[1], $h{$f[0]});
534 } else {
535 0 my($v) = $h{$f[0]};
536 0 ▶ $v = 0 if $v eq $f[1][0];
Branch: 1 branch
BranchTrueFalseTotal
if $v eq $f[1][0] 0 0 0
537 0 ▶ $v = 1 if $v eq $f[1][1] and $f[1][1];
Branch: 1 branch
BranchTrueFalseTotal
if $v eq $f[1][1] and $f[1][1] 0 0 0
Condition0%0/3
$v eq $f[1][1] and $f[1][1]
!ll&&!rl&&r
000
MC/DC0%0/2
$v eq $f[1][1] and $f[1][1]
$v eq $f[1][1] $f[1][1]
Truth table0%0/3
A and B
A= $v eq $f[1][1]B= $f[1][1]
ABresult
0X0
100
111
538 0 push @topack, $v;
539 }
540 }
541 }
542 0 $data = pack($format, @topack);
543 }
544 0 ▶ substr($data, 2, 2) = pack("S", $h{sequence_number}) if $do_seq;
Branch: 1 branch
BranchTrueFalseTotal
if $do_seq 0 0 0
545 0 ▶ substr($data, 0, 1) = pack("C", $code | ($h{synthetic} ? 128 : 0));
Branch: 1 branch
BranchTrueFalseTotal
$h{'synthetic'} ? : 0 0 0
546 } else {
547 0 carp "Unknown event (code $code)!";
548 0 return pack("Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $code);
549 }
550 0 return $data;
551 }
552  
553 0 ▶sub unpack_event_mask {
Subroutine unpack_event_mask: not called CC=3 SCAR=24.8
Pod documented
554 0 my $self = shift;
555 0 my($x) = @_;
556 0 my(@ans, $i);
557 0 for $i (@{$Const{'EventMask'}}) {
558 0 ▶ push @ans, $i if $x & 1;
Branch: 1 branch
BranchTrueFalseTotal
if $x & 1 0 0 0
559 0 $x >>= 1;
560 }
561 0 @ans;
562 }
563  
564 0 ▶sub pack_event_mask {
Subroutine pack_event_mask: not called CC=2 SCAR=17.9
Pod documented
565 0 my $self = shift;
566 0 my(@x) = @_;
567 0 my($i, $mask);
568 0 $mask = 0;
569 0 for $i (@x) {
570 0 $mask |= 1 << $self->num('EventMask', $i);
571 }
572 0 return $mask;
573 }
574  
575 0 ▶sub format_error_msg {
Subroutine format_error_msg: not called CC=5 SCAR=34.0
Pod undocumented
576 0 my($self, $data) = @_;
577 0 my($type, $seq, $info, $minor_op, $major_op)
578 = unpack("xCSLSCxxxxxxxxxxxxxxxxxxxxx", $data);
579 0 my($t);
580 $t = join("", "Protocol error: bad $type (",
581 $self->do_interp('Error', $type), "); ",
582 "Sequence Number $seq\n",
583 " Opcode ($major_op, $minor_op) = ",
584 ($self->do_interp('Request', $major_op)
585 0 ▶ or $self->{'ext_request'}{$major_op}[$minor_op][0]), "\n");
Condition0%0/3
$self->do_interp('Request', $major_op) || $self->{'ext_request'}{$major_op}[$minor_op][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->do_interp('Request', $major_op) || $self->{'ext_request'}{$major_op}[$minor_op][0]
$self->do_interp('Request', $major_op) $self->{'ext_request'}{$major_op}[$minor_op][0]
Truth table0%0/3
A || B
A= $self->do_interp('Request', $major_op)B= $self->{'ext_request'}{$major_op}[$minor_op][0]
ABresult
1X1
011
000
586 0 ▶ if ($type == 2) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == 2) { } 0 0 0
elsif ($self->{'error_type'}[$type] == 1 or $self->{'ext_error_type'}[$type] == 1) { } 0 0 0
587 0 $t .= " Bad value $info (" . hexi($info) . ")\n";
588 ▶ } elsif ($self->{'error_type'}[$type] == 1 or
Condition0%0/3
$self->{"error_type"}[$type] == 1 or $self->{"ext_error_type"}[$type] == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"error_type"}[$type] == 1 or $self->{"ext_error_type"}[$type] == 1
$self->{"error_type"}[$type] == 1 $self->{"ext_error_type"}[$type] == 1
Truth table0%0/3
A or B
A= $self->{"error_type"}[$type] == 1B= $self->{"ext_error_type"}[$type] == 1
ABresult
1X1
011
000
589 $self->{'ext_error_type'}[$type] == 1) {
590 0 $t .= " Bad resource $info (" . hexi($info) . ")\n";
591 }
592 0 return $t;
593 }
594  
595 0 ▶sub default_error_handler {
Subroutine default_error_handler: not called CC=1 SCAR=6.9
Pod undocumented
596 0 my($self, $data) = @_;
597 0 croak($self->format_error_msg($data));
598 }
599  
600 0 ▶sub handle_input {
Subroutine handle_input: not called CC=5 SCAR=34.0
Pod documented
601 0 my $self = shift;
602 0 my($type_b, $type);
603 0 $self->flush;
604 0 $type_b = $self->get(1);
605 0 $type = unpack "C", $type_b;
606 0 ▶ if ($type == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == 0) { } 0 0 0
elsif ($type > 1) { } 0 0 0
607 0 my $data = $type_b . $self->get(31);
608 0 &{$self->{'error_handler'}}($self, $data);
609 0 $self->{'error_seq'} = unpack("xxSx28", $data);
610 0 return -1;
611 } elsif ($type > 1) {
612 0 ▶ if ($self->{'event_handler'} eq "queue") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'event_handler'} eq 'queue') { } 0 0 0
613 0 push @{$self->{'event_queue'}}, $type_b . $self->get(31);
614 } else {
615 0 &{$self->{'event_handler'}}
616 ($self->unpack_event($type_b . $self->get(31)));
617 }
618 0 return -$type;
619 } else {
620 # $type == 1
621 0 my($data) = $self->get(31);
622 0 my($seq, $len) = unpack "SL", substr($data, 1, 6);
623 0 $data = join("", $type_b, $data, $self->get(4 * $len));
624 0 ▶ if ($self->{'replies'}->{$seq}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'replies'}{$seq}) { } 0 0 0
625 0 ${$self->{'replies'}->{$seq}} = $data;
626 0 return $seq;
627 } else {
628 0 carp "Unexpected reply to request $seq",
629 " (of $self->{'sequence_num'})";
630 0 return $seq;
631 }
632 }
633 }
634  
635 0 ▶sub handle_input_for {
Subroutine handle_input_for: not called CC=4 SCAR=30.0
Pod undocumented
636 0 my($self, $seq) = @_;
637 0 for (;;) {
638 0 my $stat = $self->handle_input();
639 0 ▶ return if $stat == $seq; # Normal reply for this request
Branch: 1 branch
BranchTrueFalseTotal
if $stat == $seq 0 0 0
640 0 ▶ return if $stat == -1 && $self->{'error_seq'} == $seq; # Error for this
Branch: 1 branch
BranchTrueFalseTotal
if $stat == -1 and $self->{"error_seq"} == $seq 0 0 0
Condition0%0/3
$stat == -1 and $self->{"error_seq"} == $seq
!ll&&!rl&&r
000
MC/DC0%0/2
$stat == -1 and $self->{"error_seq"} == $seq
$stat == -1 $self->{"error_seq"} == $seq
Truth table0%0/3
A and B
A= $stat == -1B= $self->{"error_seq"} == $seq
ABresult
0X0
100
111
641 }
642 }
643  
644 0 ▶sub dequeue_event {
Subroutine dequeue_event: not called CC=2 SCAR=17.9
Pod documented
645 0 my $self = shift;
646 0 my($data) = shift @{$self->{'event_queue'}};
647 0 ▶ return () unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
648 0 return $self->unpack_event($data);
649 }
650  
651 0 ▶sub next_event {
Subroutine next_event: not called CC=3 SCAR=24.8
Pod documented
652 0 my $self = shift;
653 0 ▶ if ($self->{'event_handler'} ne "queue") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"event_handler"} ne "queue") 0 0 0
654 0 carp "Setting event_handler to 'queue' to avoid infinite loop",
655 "in next_event()";
656 0 $self->{'event_handler'} = "queue";
657 }
658 0 my(%e);
659 0 ▶ $self->handle_input until %e = $self->dequeue_event;
Branch: 1 branch
BranchTrueFalseTotal
%e = $self->dequeue_event or do { $self->handle_input } 0 0 0
660 0 return %e;
661 }
662  
663 0 ▶sub next_sequence {
Subroutine next_sequence: not called CC=1 SCAR=6.9
Pod undocumented
664 0 my $self = shift;
665 0 my $ret = $self->{'sequence_num'}++;
666 0 $self->{'sequence_num'} &= 0xffff;
667 0 return $ret;
668 }
669  
670 0 ▶sub add_reply {
Subroutine add_reply: not called CC=1 SCAR=6.9
Pod documented
671 0 my $self = shift;
672 0 my($seq, $var) = @_;
673 0 $self->{'replies'}->{$seq} = $var;
674 }
675  
676 0 ▶sub delete_reply {
Subroutine delete_reply: not called CC=1 SCAR=6.9
Pod documented
677 0 my $self = shift;
678 0 my($seq) = @_;
679 0 delete $self->{'replies'}->{$seq};
680 }
681  
682 my(@Requests) =
683 (0,
684 0 ▶ ['CreateWindow', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
685 0 my $self = shift;
686 0 my($wid, $parent, $class, $depth, $visual, $x, $y, $width,
687 $height, $border_width, %values) = @_;
688 0 my($mask, $i, @values);
689 0 $mask = 0;
690 0 for $i (0 .. 14) {
691 0 ▶ if (exists $values{$Attributes_ValueMask[$i][0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $values{$Attributes_ValueMask[$i][0]}) 0 0 0
692 0 $mask |= (1 << $i);
693 push @values,
694 0 &{$Attributes_ValueMask[$i][1]}
695 0 ($self, $values{$Attributes_ValueMask[$i][0]});
696 }
697 }
698 0 ▶ $visual = 0 if $visual eq 'CopyFromParent';
Branch: 1 branch
BranchTrueFalseTotal
if $visual eq "CopyFromParent" 0 0 0
699 0 $class = $self->num('Class', $class);
700 0 return pack("LLssSSSSLL", $wid, $parent, $x, $y, $width, $height,
701 $border_width, $class, $visual, $mask) .
702 join("", @values), $depth;
703 }],
704  
705 0 ▶ ['ChangeWindowAttributes', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
706 0 my $self = shift;
707 0 my($wid, %values) = @_;
708 0 my($mask, $i, @values);
709 0 $mask = 0;
710 0 for $i (0 .. 14) {
711 0 ▶ if (exists $values{$Attributes_ValueMask[$i][0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $values{$Attributes_ValueMask[$i][0]}) 0 0 0
712 0 $mask |= (1 << $i);
713 push @values,
714 0 &{$Attributes_ValueMask[$i][1]}
715 0 ($self, $values{$Attributes_ValueMask[$i][0]});
716 }
717 }
718 0 return pack("LL", $wid, $mask) . join "", @values;
719 }],
720  
721 0 ▶ ['GetWindowAttributes', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
722 0 my $self = shift;
723 0 my($wid) = @_;
724 0 return pack "L", $wid;
725 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
726 0 my $self = shift;
727 0 my($data) = @_;
728 0 my($backing_store, $visual, $class, $bit_gravity, $win_gravity,
729 $backing_planes, $backing_pixel, $save_under, $map_is_installed,
730 $map_state, $override_redirect, $colormap, $all_event_masks,
731 $your_event_mask, $do_not_propagate_mask)
732 = unpack("xCxxxxxxLSCCLLCCCCLLLS", $data);
733  
734 0 ▶ $colormap = "None" if !$colormap and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if not $colormap and $self->{"do_interp"} 0 0 0
Condition0%0/3
not $colormap and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $colormap and $self->{"do_interp"}
not $colormap $self->{"do_interp"}
Truth table0%0/3
not(A) and B
A= not $colormapB= $self->{"do_interp"}
ABresult
0X0
100
111
735  
736 0 return ("backing_store" => $self->interp('BackingStore', $backing_store),
737 "visual" => $visual,
738 "class" => $self->interp('Class', $class),
739 "bit_gravity" => $self->interp('BitGravity', $bit_gravity),
740 "win_gravity" => $self->interp('WinGravity', $win_gravity),
741 "backing_planes" => $backing_planes,
742 "backing_pixel" => $backing_pixel, "save_under" => $save_under,
743 "map_is_installed" => $map_is_installed,
744 "map_state" => $self->interp('MapState', $map_state),
745 "override_redirect" => $override_redirect,
746 "colormap" => $colormap, "all_event_masks" => $all_event_masks,
747 "your_event_mask" => $your_event_mask,
748 "do_not_propagate_mask" => $do_not_propagate_mask);
749 }],
750  
751 0 ▶ ['DestroyWindow', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
752 0 my $self = shift;
753 0 my($wid) = @_;
754 0 return pack "L", $wid;
755 }],
756  
757 0 ▶ ['DestroySubwindows', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
758 0 my $self = shift;
759 0 my($wid) = @_;
760 0 return pack "L", $wid;
761 }],
762  
763 0 ▶ ['ChangeSaveSet', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
764 0 my $self = shift;
765 0 my($mode, $wid) = @_;
766 0 ▶ $mode = 0 if $mode eq "Insert";
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "Insert" 0 0 0
767 0 ▶ $mode = 1 if $mode eq "Delete";
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "Delete" 0 0 0
768 0 return pack("L", $wid), $mode;
769 }],
770  
771 0 ▶ ['ReparentWindow', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
772 0 my $self = shift;
773 0 my($wid, $new_parent, $x, $y) = @_;
774 0 return pack "LLss", $wid, $new_parent, $x, $y;
775 }],
776  
777 0 ▶ ['MapWindow', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
778 0 my $self = shift;
779 0 my($wid) = @_;
780 0 return pack "L", $wid;
781 }],
782  
783 0 ▶ ['MapSubwindows', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
784 0 my $self = shift;
785 0 my($wid) = @_;
786 0 return pack "L", $wid;
787 }],
788  
789 0 ▶ ['UnmapWindow', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
790 0 my $self = shift;
791 0 my($wid) = @_;
792 0 return pack "L", $wid;
793 }],
794  
795 0 ▶ ['UnmapSubwindows', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
796 0 my $self = shift;
797 0 my($wid) = @_;
798 0 return pack "L", $wid;
799 }],
800  
801 0 ▶ ['ConfigureWindow', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
802 0 my $self = shift;
803 0 my($wid, %values) = @_;
804 0 my($mask, $i, @values);
805 0 $mask = 0;
806 0 for $i (0 .. 6) {
807 0 ▶ if (exists $values{$Configure_ValueMask[$i][0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $values{$Configure_ValueMask[$i][0]}) 0 0 0
808 0 $mask |= (1 << $i);
809 push @values,
810 0 &{$Configure_ValueMask[$i][1]}
811 0 ($self, $values{$Configure_ValueMask[$i][0]});
812 }
813 }
814 0 return pack("LSxx", $wid, $mask) . join "", @values;
815 }],
816  
817 0 ▶ ['CirculateWindow', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
818 0 my $self = shift;
819 0 my($wid, $dir) = @_;
820 0 $dir = $self->num('CirculateDirection', $dir);
821 0 return pack("L", $wid), $dir;
822 }],
823  
824 0 ▶ ['GetGeometry', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
825 0 my $self = shift;
826 0 my($drawable) = @_;
827 0 return pack "L", $drawable;
828 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
829 0 my $self = shift;
830 0 my($data) = @_;
831 0 my($depth, $root, $x, $y, $width, $height, $border_width)
832 = unpack("xCxxxxxxLssSSSxxxxxxxxxx", $data);
833  
834 0 return ("depth" => $depth, "root" => $root, "x" => $x, "y" => $y,
835 "width" => $width, "height" => $height,
836 "border_width" => $border_width);
837 }],
838  
839 0 ▶ ['QueryTree', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
840 0 my $self = shift;
841 0 my($wid) = @_;
842 0 return pack "L", $wid;
843 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
844 0 my $self = shift;
845 0 my($data) = @_;
846 0 my($root, $parent, $n)
847 = unpack("xxxxxxxxLLSxxxxxxxxxxxxxx", substr($data, 0, 32));
848  
849 0 ▶ $parent = "None" if $parent == 0 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $parent == 0 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$parent == 0 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$parent == 0 and $self->{"do_interp"}
$parent == 0 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $parent == 0B= $self->{"do_interp"}
ABresult
0X0
100
111
850  
851 0 return ($root, $parent, unpack("L*", substr($data, 32)));
852 }],
853  
854 0 ▶ ['InternAtom', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
855 0 my $self = shift;
856 0 my($string, $only_if_exists) = @_;
857 0 return pack("Sxx" . padded($string), length($string), $string),
858 $only_if_exists;
859 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
860 0 my $self = shift;
861 0 my($data) = @_;
862 0 my($atom) = unpack("xxxxxxxxLxxxxxxxxxxxxxxxxxxxx", $data);
863 0 ▶ $atom = "None" if $atom == 0 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $atom == 0 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$atom == 0 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$atom == 0 and $self->{"do_interp"}
$atom == 0 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $atom == 0B= $self->{"do_interp"}
ABresult
0X0
100
111
864 0 return $atom;
865 }],
866  
867 0 ▶ ['GetAtomName', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
868 0 my $self = shift;
869 0 my($atom) = @_;
870 0 return pack "L", $atom;
871 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
872 0 my $self = shift;
873 0 my($data) = @_;
874 0 my($len) = unpack "xxxxxxxxSxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32);
875 0 return substr($data, 32, $len);
876 }],
877  
878 0 ▶ ['ChangeProperty', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
879 0 my $self = shift;
880 0 my($window, $property, $type, $format, $mode, $data) = @_;
881 0 $mode = $self->num('ChangePropertyMode', $mode);
882 0 my($x) = $format / 8;
883 0 return pack("LLLCxxxL" . padded($data), $window, $property, $type,
884 $format, length($data) / $x, $data), $mode;
885 }],
886  
887 0 ▶ ['DeleteProperty', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
888 0 my $self = shift;
889 0 my($wid, $atom) = @_;
890 0 return pack "LL", $wid, $atom;
891 }],
892  
893 0 ▶ ['GetProperty', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
894 0 my $self = shift;
895 0 my($wid, $prop, $type, $offset, $length, $delete) = @_;
896 0 ▶ $type = 0 if $type eq "AnyPropertyType";
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "AnyPropertyType" 0 0 0
897 0 return pack("LLLLL", $wid, $prop, $type, $offset, $length), $delete;
898 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
899 0 my $self = shift;
900 0 my($data) = @_;
901 0 my($format, $type, $bytes_after, $len) =
902 unpack "xCxxxxxxLLLxxxxxxxxxxxx", substr($data, 0, 32);
903 0 my($m) = $format / 8;
904 0 my($val) = substr($data, 32, $len * $m);
905 0 return ($val, $type, $format, $bytes_after);
906 }],
907  
908 0 ▶ ['ListProperties', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
909 0 my $self = shift;
910 0 my($wid) = @_;
911 0 return pack "L", $wid;
912 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
913 0 my $self = shift;
914 0 my($data) = @_;
915 0 my($n) = unpack "xxxxxxxxSxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32);
916 0 return unpack "L*", substr($data, 32, $n * 4);
917 }],
918  
919 0 ▶ ['SetSelectionOwner', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
920 0 my $self = shift;
921 0 my($selection, $owner, $time) = @_;
922 0 ▶ $owner = 0 if $owner eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $owner eq "None" 0 0 0
923 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
924 0 return pack "LLL", $owner, $selection, $time;
925 }],
926  
927 0 ▶ ['GetSelectionOwner', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
928 0 my $self = shift;
929 0 my($selection) = @_;
930 0 return pack "L", $selection;
931 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
932 0 my $self = shift;
933 0 my($data) = @_;
934 0 my($win) = unpack "xxxxxxxxLxxxxxxxxxxxxxxxxxxxx", $data;
935 0 ▶ $win = "None" if $win == 0 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $win == 0 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$win == 0 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$win == 0 and $self->{"do_interp"}
$win == 0 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $win == 0B= $self->{"do_interp"}
ABresult
0X0
100
111
936 0 return $win;
937 }],
938  
939 0 ▶ ['ConvertSelection', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
940 0 my $self = shift;
941 0 my($selection, $target, $prop, $requestor, $time) = @_;
942 0 ▶ $prop = 0 if $prop eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $prop eq "None" 0 0 0
943 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
944 0 return pack("LLLLL", $requestor, $selection, $target, $prop, $time);
945 }],
946  
947 0 ▶ ['SendEvent', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
948 0 my $self = shift;
949 0 my($destination, $propagate, $event_mask, $event) = @_;
950 0 ▶ $destination = 0 if $destination eq "PointerWindow";
Branch: 1 branch
BranchTrueFalseTotal
if $destination eq "PointerWindow" 0 0 0
951 0 ▶ $destination = 1 if $destination eq "InputFocus";
Branch: 1 branch
BranchTrueFalseTotal
if $destination eq "InputFocus" 0 0 0
952 0 return pack("LL", $destination, $event_mask) . $event, $propagate;
953 }],
954  
955 0 ▶ ['GrabPointer', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
956 0 my $self = shift;
957 0 my($window, $owner_events, $event_mask, $pointer_mode, $keybd_mode,
958 $confine_window, $cursor, $time) = @_;
959 0 $pointer_mode = $self->num('SyncMode', $pointer_mode);
960 0 $keybd_mode = $self->num('SyncMode', $keybd_mode);
961 0 ▶ $confine_window = 0 if $confine_window eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $confine_window eq "None" 0 0 0
962 0 ▶ $cursor = 0 if $cursor eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $cursor eq "None" 0 0 0
963 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
964 0 return pack("LSCCLLL", $window, $event_mask, $pointer_mode, $keybd_mode,
965 $confine_window, $cursor, $time), $owner_events;
966 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
967 0 my $self = shift;
968 0 my($data) = @_;
969 0 my($status) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $data);
970 0 return $self->interp('GrabStatus', $status);
971 }],
972  
973 0 ▶ ['UngrabPointer', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
974 0 my $self = shift;
975 0 my($time) = @_;
976 0 ▶ $time = 0 if $time eq 'CurrentTime';
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
977 0 return pack "L", $time;
978 }],
979  
980 0 ▶ ['GrabButton', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
981 0 my $self = shift;
982 0 my($modifiers, $button, $win, $owner_events, $mask, $p_mode, $k_mode,
983 $confine_w, $cursor) = @_;
984 0 $p_mode = $self->num('SyncMode', $p_mode);
985 0 $k_mode = $self->num('SyncMode', $k_mode);
986 0 ▶ $confine_w = 0 if $confine_w eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $confine_w eq "None" 0 0 0
987 0 ▶ $cursor = 0 if $cursor eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $cursor eq "None" 0 0 0
988 0 ▶ $button = 0 if $button eq "AnyButton";
Branch: 1 branch
BranchTrueFalseTotal
if $button eq "AnyButton" 0 0 0
989 0 ▶ $modifiers = 0x8000 if $modifiers eq "AnyModifier";
Branch: 1 branch
BranchTrueFalseTotal
if $modifiers eq "AnyModifier" 0 0 0
990 0 return pack("LSCCLLCxS", $win, $mask, $p_mode, $k_mode, $confine_w,
991 $cursor, $button, $modifiers), $owner_events;
992 }],
993  
994 0 ▶ ['UngrabButton', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
995 0 my $self = shift;
996 0 my($modifiers, $button, $win) = @_;
997 0 ▶ $button = 0 if $button eq "AnyButton";
Branch: 1 branch
BranchTrueFalseTotal
if $button eq "AnyButton" 0 0 0
998 0 ▶ $modifiers = 0x8000 if $modifiers eq "AnyModifier";
Branch: 1 branch
BranchTrueFalseTotal
if $modifiers eq "AnyModifier" 0 0 0
999 0 return pack("LSxx", $win, $modifiers), $button;
1000 }],
1001  
1002 0 ▶ ['ChangeActivePointerGrab', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1003 0 my $self = shift;
1004 0 my($mask, $cursor, $time) = @_;
1005 0 ▶ $cursor = 0 if $cursor eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $cursor eq "None" 0 0 0
1006 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
1007 0 return pack "LLSxx", $cursor, $time, $mask;
1008 }],
1009  
1010 0 ▶ ['GrabKeyboard', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1011 0 my $self = shift;
1012 0 my($win, $owner_events, $p_mode, $k_mode, $time) = @_;
1013 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
1014 0 $p_mode = $self->num('SyncMode', $p_mode);
1015 0 $k_mode = $self->num('SyncMode', $k_mode);
1016 0 return pack("LLCCxx", $win, $time, $p_mode, $k_mode), $owner_events;
1017 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1018 0 my $self = shift;
1019 0 my($data) = @_;
1020 0 my($status) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $data);
1021 0 return $self->interp('GrabStatus', $status);
1022 }],
1023  
1024 0 ▶ ['UngrabKeyboard', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1025 0 my $self = shift;
1026 0 my($time) = @_;
1027 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
1028 0 return pack("L", $time);
1029 }],
1030  
1031 0 ▶ ['GrabKey', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1032 0 my $self = shift;
1033 0 my($key, $modifiers, $win, $owner_events, $p_mode, $k_mode) = @_;
1034 0 ▶ $modifiers = 0x8000 if $modifiers eq "AnyModifier";
Branch: 1 branch
BranchTrueFalseTotal
if $modifiers eq "AnyModifier" 0 0 0
1035 0 ▶ $key = 0 if $key eq "AnyKey";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "AnyKey" 0 0 0
1036 0 $p_mode = $self->num('SyncMode', $p_mode);
1037 0 $k_mode = $self->num('SyncMode', $k_mode);
1038 0 return pack("LSCCCxxx", $win, $modifiers, $key, $p_mode, $k_mode),
1039 $owner_events;
1040 }],
1041  
1042 0 ▶ ['UngrabKey', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1043 0 my $self = shift;
1044 0 my($key, $modifiers, $win) = @_;
1045 0 ▶ $key = 0 if $key eq "AnyKey";
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "AnyKey" 0 0 0
1046 0 ▶ $modifiers = 0x8000 if $modifiers eq "AnyModifier";
Branch: 1 branch
BranchTrueFalseTotal
if $modifiers eq "AnyModifier" 0 0 0
1047 0 return pack("LSxx", $win, $modifiers), $key;
1048 }],
1049  
1050 0 ▶ ['AllowEvents', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1051 0 my $self = shift;
1052 0 my($mode, $time) = @_;
1053 0 $mode = $self->num('AllowEventsMode', $mode);
1054 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
1055 0 return pack("L", $time), $mode;
1056 }],
1057  
1058 0 ▶ ['GrabServer', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1059 0 my $self = shift;
1060 0 return "";
1061 }],
1062  
1063 0 ▶ ['UngrabServer', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1064 0 my $self = shift;
1065 0 return "";
1066 }],
1067  
1068 0 ▶ ['QueryPointer', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1069 0 my $self = shift;
1070 0 my($window) = @_;
1071 0 return pack "L", $window;
1072 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1073 0 my $self = shift;
1074 0 my($data) = @_;
1075 0 my($same_s, $root, $child, $root_x, $root_y, $win_x, $win_y, $mask)
1076 = unpack "xCxxxxxxLLssssSxxxxxx", $data;
1077 0 ▶ $child = 'None' if $child == 0 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $child == 0 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$child == 0 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$child == 0 and $self->{"do_interp"}
$child == 0 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $child == 0B= $self->{"do_interp"}
ABresult
0X0
100
111
1078 0 return ('same_screen' => $same_s, 'root' => $root, 'child' => $child,
1079 'root_x' => $root_x, 'root_y' => $root_y, 'win_x' => $win_x,
1080 'win_y' => $win_y, 'mask' => $mask);
1081 }],
1082  
1083 0 ▶ ['GetMotionEvents', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1084 0 my $self = shift;
1085 0 my($start, $stop, $win) = @_;
1086 0 ▶ $start = 0 if $start eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $start eq "CurrentTime" 0 0 0
1087 0 ▶ $stop = 0 if $stop eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $stop eq "CurrentTime" 0 0 0
1088 0 return pack "LLL", $win, $start, $stop;
1089 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1090 0 my $self = shift;
1091 0 my($data) = @_;
1092 0 my($n) = unpack "xxxxxxxxLxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32);
1093 0 my($events) = substr($data, 32, 8 * $n);
1094 0 my(@ret, $off);
1095 0 for $off (0 .. $n - 1)
1096 {
1097 0 push @ret, [unpack "Lss", substr($events, 8 * $off, 8)];
1098 }
1099 0 return @ret;
1100 }],
1101  
1102 0 ▶ ['TranslateCoordinates', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1103 0 my $self = shift;
1104 0 my($src_w, $dest_w, $src_x, $src_y) = @_;
1105 0 return pack "LLss", $src_w, $dest_w, $src_x, $src_y;
1106 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1107 0 my $self = shift;
1108 0 my($data) = @_;
1109 0 my($same_screen, $child, $dest_x, $dest_y) =
1110 unpack "xCxxxxxxLssxxxxxxxxxxxxxxxx", $data;
1111 0 ▶ $child = "None" if $child == 0 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $child == 0 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$child == 0 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$child == 0 and $self->{"do_interp"}
$child == 0 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $child == 0B= $self->{"do_interp"}
ABresult
0X0
100
111
1112 0 return ($same_screen, $child, $dest_x, $dest_y);
1113 }],
1114  
1115 0 ▶ ['WarpPointer', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1116 0 my $self = shift;
1117 0 my($src_w, $dst_w, $src_x, $src_y, $src_width, $src_height, $dst_x,
1118 $dst_y) = @_;
1119 0 ▶ $src_w = 0 if $src_w eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $src_w eq "None" 0 0 0
1120 0 ▶ $dst_w = 0 if $dst_w eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $dst_w eq "None" 0 0 0
1121 0 return pack("LLssSSss", $src_w, $dst_w, $src_x, $src_y, $src_width,
1122 $src_height, $dst_x, $dst_y);
1123 }],
1124  
1125 0 ▶ ['SetInputFocus', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1126 0 my $self = shift;
1127 0 my($focus, $revert_to, $time) = @_;
1128 0 $revert_to = $self->num('InputFocusRevertTo', $revert_to);
1129 0 ▶ $focus = 0 if $focus eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $focus eq "None" 0 0 0
1130 0 ▶ $focus = 1 if $focus eq "ParentRoot";
Branch: 1 branch
BranchTrueFalseTotal
if $focus eq "ParentRoot" 0 0 0
1131 0 ▶ $time = 0 if $time eq "CurrentTime";
Branch: 1 branch
BranchTrueFalseTotal
if $time eq "CurrentTime" 0 0 0
1132 0 return pack("LL", $focus, $time), $revert_to;
1133 }],
1134  
1135 0 ▶ ['GetInputFocus', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1136 0 my $self = shift;
1137 0 return "";
1138 0 ▶ }, sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1139 0 my $self = shift;
1140 0 my($data) = @_;
1141 0 my($revert_to, $focus) =
1142 unpack "xCxxxxxxLxxxxxxxxxxxxxxxxxxxx", $data;
1143 0 $revert_to = $self->interp('InputFocusRevertTo', $revert_to);
1144 0 ▶ $focus = "None" if $focus == 0 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $focus == 0 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$focus == 0 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$focus == 0 and $self->{"do_interp"}
$focus == 0 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $focus == 0B= $self->{"do_interp"}
ABresult
0X0
100
111
1145 0 ▶ $focus = "PointerRoot" if $focus == 1 and $self->{'do_interp'};
Branch: 1 branch
BranchTrueFalseTotal
if $focus == 1 and $self->{"do_interp"} 0 0 0
Condition0%0/3
$focus == 1 and $self->{"do_interp"}
!ll&&!rl&&r
000
MC/DC0%0/2
$focus == 1 and $self->{"do_interp"}
$focus == 1 $self->{"do_interp"}
Truth table0%0/3
A and B
A= $focus == 1B= $self->{"do_interp"}
ABresult
0X0
100
111
1146 0 return ($focus, $revert_to);
1147 }],
1148  
1149 0 ▶ ['QueryKeymap', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1150 0 my $self = shift;
1151 0 return "";
1152 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1153 0 my $self = shift;
1154 0 my($data) = @_;
1155 0 return substr($data, 8, 32);
1156 }],
1157  
1158 0 ▶ ['OpenFont', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1159 0 my $self = shift;
1160 0 my($fid, $name) = @_;
1161 0 return pack("LSxx" . padded($name), $fid, length($name), $name);
1162 }],
1163  
1164 0 ▶ ['CloseFont', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1165 0 my $self = shift;
1166 0 my($font) = @_;
1167 0 return pack "L", $font;
1168 }],
1169  
1170 0 ▶ ['QueryFont', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1171 0 my $self = shift;
1172 0 my($font) = @_;
1173 0 return pack "L", $font;
1174 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1175 0 my $self = shift;
1176 0 my($data) = @_;
1177 0 my($min_bounds) = substr($data, 8, 12);
1178 0 my($max_bounds) = substr($data, 24, 12);
1179 0 my($min_char_or_byte2, $max_char_or_byte2, $default_char, $n,
1180 $draw_direction, $min_byte1, $max_byte1, $all_chars_exist,
1181 $font_ascent, $font_descent, $m) = unpack("SSSSCCCCssL",
1182 substr($data, 40, 20));
1183 0 my($properties) = substr($data, 60, 8 * $n);
1184 0 my($char_infos) = substr($data, 60 + 8 * $n, 12 * $m);
1185 0 $draw_direction = $self->interp('DrawDirection', $draw_direction);
1186 0 my(%ret) = ('min_char_or_byte2' => $min_char_or_byte2,
1187 'max_char_or_byte2' => $max_char_or_byte2,
1188 'default_char' => $default_char,
1189 'draw_direction' => $draw_direction,
1190 'min_byte1' => $min_byte1, 'max_byte1' => $max_byte1,
1191 'all_chars_exist' => $all_chars_exist,
1192 'font_ascent' => $font_ascent,
1193 'font_descent' => $font_descent);
1194  
1195 0 $ret{'min_bounds'} = [unpack("sssssS", $min_bounds)];
1196 0 $ret{'max_bounds'} = [unpack("sssssS", $max_bounds)];
1197 0 my($i, @char_infos, %font_props);
1198 0 for $i (0 .. $m - 1) {
1199 0 push @char_infos, [unpack("sssssS",
1200 substr($char_infos, 12 * $i, 12))];
1201 }
1202 0 for $i (0 .. $n - 1) {
1203 0 my($atom, $value) = unpack("LL", substr($properties, 8 * $i, 8));
1204 0 $font_props{$atom} = $value;
1205 }
1206 0 $ret{'properties'} = {%font_props};
1207 0 $ret{'char_infos'} = [@char_infos];
1208 0 return %ret;
1209 }],
1210  
1211 0 ▶ ['QueryTextExtents', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1212 0 my $self = shift;
1213 0 my($font, $string) = @_;
1214 0 return pack("L" . padded($string), $font, $string), (pad($string) == 2);
1215 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1216 0 my $self = shift;
1217 0 my($data) = @_;
1218 0 my($draw_direction, $font_a, $font_d, $overall_a, $overall_d, $overall_w,
1219 $overall_l, $overall_r) = unpack("xCxxxxxxsssslllxxxx", $data);
1220 0 $draw_direction = $self->interp('DrawDirection', $draw_direction);
1221 0 return ('draw_direction' => $draw_direction, 'font_ascent' => $font_a,
1222 'font_descent' => $font_d, 'overall_ascent' => $overall_a,
1223 'overall_descent' => $overall_d, 'overall_width' => $overall_w,
1224 'overall_left' => $overall_l, 'overall_right' => $overall_r);
1225 }],
1226  
1227 0 ▶ ['ListFonts', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1228 0 my $self = shift;
1229 0 my($pat, $max) = @_;
1230 0 return pack("SS" . padded($pat), $max, length($pat), $pat);
1231 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1232 0 my $self = shift;
1233 0 my($data) = @_;
1234 0 my($n) = unpack("xxxxxxxxSxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32));
1235 0 my($list) = substr($data, 32);
1236 0 my(@ret, $offset, $len, $i);
1237 0 $offset = 0;
1238 0 ▶ while ($i++ < $n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i++ < $n) 0 0 0
1239 0 $len = unpack("C", substr($list, $offset, 1));
1240 0 push @ret, substr($list, $offset + 1, $len);
1241 0 $offset += $len + 1;
1242 }
1243 0 return @ret;
1244 }],
1245  
1246 0 ▶ ['ListFontsWithInfo', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1247 0 my $self = shift;
1248 0 my($pat, $max) = @_;
1249 0 return pack("SS" . padded($pat), $max, length($pat), $pat);
1250 0 ▶ }, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1251 0 my $self = shift;
1252 0 my($data) = @_;
1253 0 my($n) = unpack("C", substr($data, 1, 1));
1254 0 ▶ return () if $n == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $n == 0 0 0 0
1255 0 my($min_bounds) = substr($data, 8, 12);
1256 0 my($max_bounds) = substr($data, 24, 12);
1257 0 my($min_char_or_byte2, $max_char_or_byte2, $default_char, $m,
1258 $draw_direction, $min_byte1, $max_byte1, $all_chars_exist,
1259 $font_ascent, $font_descent) = unpack("SSSSCCCCssxxxx",
1260 substr($data, 40, 20));
1261 0 my($properties) = substr($data, 60, 8 * $m);
1262 0 my($name) = substr($data, 60 + 8 * $m, $n);
1263 0 $draw_direction = $self->interp('DrawDirection', $draw_direction);
1264 0 my(%ret) = ('min_char_or_byte2' => $min_char_or_byte2,
1265 'max_char_or_byte2' => $max_char_or_byte2,
1266 'default_char' => $default_char,
1267 'draw_direction' => $draw_direction,
1268 'min_byte1' => $min_byte1, 'max_byte1' => $max_byte1,
1269 'all_chars_exist' => $all_chars_exist,
1270 'font_ascent' => $font_ascent,
1271 'font_descent' => $font_descent, 'name' => $name);
1272  
1273 0 $ret{'min_bounds'} = [unpack("sssssS", $min_bounds)];
1274 0 $ret{'max_bounds'} = [unpack("sssssS", $max_bounds)];
1275 0 my($i, %font_props);
1276 0 for $i (0 .. $m - 1) {
1277 0 my($atom, $value) = unpack("LL", substr($properties, 8 * $i, 8));
1278 0 $font_props{$atom} = $value;
1279 }
1280 0 $ret{'properties'} = {%font_props};
1281 0 return %ret;
1282 }, 'HASH'],
1283  
1284 0 ▶ ['SetFontPath', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1285 0 my $self = shift;
1286 0 my(@dirs) = @_;
1287 0 my($n, $d, $path);
1288 0 for $d (@dirs) {
1289 0 $d = pack("C", length $d) . $d;
1290 0 $n++;
1291 }
1292 0 $path = join("", @dirs);
1293 0 return pack("Sxx" . padded($path), $n, $path);
1294 }],
1295  
1296 0 ▶ ['GetFontPath', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1297 0 my $self = shift;
1298 0 return "";
1299 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1300 0 my $self = shift;
1301 0 my($data) = @_;
1302 0 my($n) = unpack("xxxxxxxxSxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32));
1303 0 my($list) = substr($data, 32);
1304 0 my(@ret, $offset, $len, $i);
1305 0 $offset = 0;
1306 0 ▶ while ($i++ < $n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i++ < $n) 0 0 0
1307 0 $len = unpack("C", substr($list, $offset, 1));
1308 0 push @ret, substr($list, $offset + 1, $len);
1309 0 $offset += $len + 1;
1310 }
1311 0 return @ret;
1312 }],
1313  
1314 0 ▶ ['CreatePixmap', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1315 0 my $self = shift;
1316 0 my($pixmap, $drawable, $depth, $w, $h) = @_;
1317 0 return pack("LLSS", $pixmap, $drawable, $w, $h), $depth;
1318 }],
1319  
1320 0 ▶ ['FreePixmap', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1321 0 my $self = shift;
1322 0 my($pixmap) = @_;
1323 0 return pack "L", $pixmap;
1324 }],
1325  
1326 0 ▶ ['CreateGC', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1327 0 my $self = shift;
1328 0 my($gc, $drawable, %values) = @_;
1329 0 my($i, $mask, @values);
1330 0 $mask = 0;
1331 0 for $i (0 .. $#GC_ValueMask) {
1332 0 ▶ if (exists $values{$GC_ValueMask[$i][0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $values{$GC_ValueMask[$i][0]}) 0 0 0
1333 0 $mask |= (1 << $i);
1334 push @values,
1335 0 &{$GC_ValueMask[$i][1]}($self, $values{$GC_ValueMask[$i][0]});
1336 0 delete $values{$GC_ValueMask[$i][0]};
1337 }
1338 }
1339 0 ▶ croak "Invalid GC components: ", join(",", keys %values), "\n" if %values;
Branch: 1 branch
BranchTrueFalseTotal
if %values 0 0 0
1340 0 return pack("LLL", $gc, $drawable, $mask) . join("", @values);
1341 }],
1342  
1343 0 ▶ ['ChangeGC', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1344 0 my $self = shift;
1345 0 my($gc, %values) = @_;
1346 0 my($i, $mask, @values);
1347 0 $mask = 0;
1348 0 for $i (0 .. $#GC_ValueMask) {
1349 0 ▶ if (exists $values{$GC_ValueMask[$i][0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $values{$GC_ValueMask[$i][0]}) 0 0 0
1350 0 $mask |= (1 << $i);
1351 push @values,
1352 0 &{$GC_ValueMask[$i][1]}($self, $values{$GC_ValueMask[$i][0]});
1353 }
1354 }
1355 0 return pack("LL", $gc, $mask) . join("", @values);
1356 }],
1357  
1358 0 ▶ ['CopyGC', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1359 0 my $self = shift;
1360 0 my($src, $dst, @values) = @_;
1361 0 my(%values, $i, $mask);
1362 0 $mask = 0;
1363 0 @values{@values} = (1) x @values;
1364 0 for $i (0 .. $#GC_ValueMask) {
1365 0 ▶ $mask |= (1 << $i) if exists $values{$GC_ValueMask[$i][0]};
Branch: 1 branch
BranchTrueFalseTotal
if exists $values{$GC_ValueMask[$i][0]} 0 0 0
1366 }
1367 0 return pack "LLL", $src, $dst, $mask;
1368 }],
1369  
1370 0 ▶ ['SetDashes', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1371 0 my $self = shift;
1372 0 my($gc, $offset, @dashes) = @_;
1373 0 my($dash_list) = pack("C*", @dashes);
1374 0 my($n) = length $dash_list;
1375 0 return pack("LSS" . padded($dash_list), $gc, $offset, $n, $dash_list);
1376 }],
1377  
1378 0 ▶ ['SetClipRectangles', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1379 0 my $self = shift;
1380 0 my($gc, $clip_x_o, $clip_y_o, $ordering, @rects) = @_;
1381 0 $ordering = $self->num('ClipRectangleOrdering', $ordering);
1382 0 my($x);
1383 0 for $x (@rects) {
1384 0 $x = pack("ssSS", @$x);
1385 }
1386 0 return pack("Lss", $gc, $clip_x_o, $clip_y_o) . join("", @rects),
1387 $ordering;
1388 }],
1389  
1390 0 ▶ ['FreeGC', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1391 0 my $self = shift;
1392 0 my($gc) = @_;
1393 0 return pack "L", $gc;
1394 }],
1395  
1396 0 ▶ ['ClearArea', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1397 0 my $self = shift;
1398 0 my($win, $x, $y, $w, $h, $exposures) = @_;
1399 0 return pack("LssSS", $win, $x, $y, $w, $h), $exposures;
1400 }],
1401  
1402 0 ▶ ['CopyArea', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1403 0 my $self = shift;
1404 0 my($src_d, $dst_d, $gc, $src_x, $src_y, $w, $h, $dst_x, $dst_y) = @_;
1405 0 return pack("LLLssssSS", $src_d, $dst_d, $gc, $src_x, $src_y, $dst_x,
1406 $dst_y, $w, $h);
1407 }],
1408  
1409 0 ▶ ['CopyPlane', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1410 0 my $self = shift;
1411 0 my($src_d, $dst_d, $gc, $src_x, $src_y, $w, $h, $dst_x, $dst_y, $plane)
1412 = @_;
1413 0 return pack("LLLssssSSL", $src_d, $dst_d, $gc, $src_x, $src_y, $dst_x,
1414 $dst_y, $w, $h, $plane);
1415 }],
1416  
1417 0 ▶ ['PolyPoint', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1418 0 my $self = shift;
1419 0 my($drawable, $gc, $coord_mode, @points) = @_;
1420 0 $coord_mode = $self->num('CoordinateMode', $coord_mode);
1421 0 return pack("LLs*", $drawable, $gc, @points), $coord_mode;
1422 }],
1423  
1424 0 ▶ ['PolyLine', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1425 0 my $self = shift;
1426 0 my($drawable, $gc, $coord_mode, @points) = @_;
1427 0 $coord_mode = $self->num('CoordinateMode', $coord_mode);
1428 0 return pack("LLs*", $drawable, $gc, @points), $coord_mode;
1429 }],
1430  
1431 0 ▶ ['PolySegment', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1432 0 my $self = shift;
1433 0 my($drawable, $gc, @points) = @_;
1434 0 return pack("LLs*", $drawable, $gc, @points);
1435 }],
1436  
1437 0 ▶ ['PolyRectangle', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1438 0 my $self = shift;
1439 0 my($drawable, $gc, @rects) = @_;
1440 0 my($rr);
1441 0 for $rr (@rects) {
1442 0 $rr = pack("ssSS", @$rr);
1443 }
1444 0 return pack("LL", $drawable, $gc) . join("", @rects);
1445 }],
1446  
1447 0 ▶ ['PolyArc', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1448 0 my $self = shift;
1449 0 my($drawable, $gc, @arcs) = @_;
1450 0 my($ar);
1451 0 for $ar (@arcs) {
1452 0 $ar = pack("ssSSss", @$ar);
1453 }
1454 0 return pack("LL", $drawable, $gc) . join("", @arcs);
1455 }],
1456  
1457 0 ▶ ['FillPoly', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1458 0 my $self = shift;
1459 0 my($drawable, $gc, $shape, $coord_mode, @points) = @_;
1460 0 $shape = $self->num('PolyShape', $shape);
1461 0 $coord_mode = $self->num('CoordinateMode', $coord_mode);
1462 0 return pack("LLCCxxs*", $drawable, $gc, $shape, $coord_mode, @points);
1463 }],
1464  
1465 0 ▶ ['PolyFillRectangle', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1466 0 my $self = shift;
1467 0 my($drawable, $gc, @rects) = @_;
1468 0 my($rr);
1469 0 for $rr (@rects) {
1470 0 $rr = pack("ssSS", @$rr);
1471 }
1472 0 return pack("LL", $drawable, $gc) . join("", @rects);
1473 }],
1474  
1475 0 ▶ ['PolyFillArc', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1476 0 my $self = shift;
1477 0 my($drawable, $gc, @arcs) = @_;
1478 0 my($ar);
1479 0 for $ar (@arcs) {
1480 0 $ar = pack("ssSSss", @$ar);
1481 }
1482 0 return pack("LL", $drawable, $gc) . join("", @arcs);
1483 }],
1484  
1485 0 ▶ ['PutImage', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1486 0 my $self = shift;
1487 0 my($drawable, $gc, $depth, $w, $h, $x, $y, $left_pad, $format, $data)
1488 = @_;
1489 0 $format = $self->num('ImageFormat', $format);
1490 0 return pack("LLSSssCCxx" . padded($data), $drawable, $gc, $w, $h,
1491 $x, $y, $left_pad, $depth, $data), $format;
1492 }],
1493  
1494 0 ▶ ['GetImage', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1495 0 my $self = shift;
1496 0 my($drawable, $x, $y, $w, $h, $mask, $format) = @_;
1497 0 $format = $self->num('ImageFormat', $format);
1498 0 ▶ croak "GetImage() format must be (XY|Z)Pixmap" if $format == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $format == 0 0 0 0
1499 0 return pack("LssSSL", $drawable, $x, $y, $w, $h, $mask), $format;
1500 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1501 0 my $self = shift;
1502 0 my($data) = @_;
1503 0 my($depth, $visual) = unpack("xCxxxxxxLxxxxxxxxxxxxxxxxxxxx",
1504 substr($data, 0, 32));
1505 0 return ($depth, $visual, substr($data, 32));
1506 }],
1507  
1508 0 ▶ ['PolyText8', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1509 0 my $self = shift;
1510 0 my($drawable, $gc, $x, $y, @items) = @_;
1511 0 my(@i, $ir, @item, $n, $r, $items);
1512 0 for $ir (@items) {
1513 0 ▶ if (not ref $ir) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $ir) { } 0 0 0
1514 0 push @i, pack("CN", 255, $ir);
1515 } else {
1516 0 @item = @$ir;
1517 0 $n = 0;
1518 0 $r = length($item[1]);
1519 0 ▶ while ($r > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r > 0) 0 0 0
1520 0 ▶ if ($r >= 254) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r >= 254) { } 0 0 0
1521 0 push @i, pack("Cc", 254, 0) . substr($item[1], $n, 254);
1522 0 $n += 254;
1523 0 $r -= 254;
1524 } else {
1525 0 push @i, pack("Cc", $r, $item[0]) . substr($item[1], $n);
1526 0 $n += $r; # Superfluous
1527 0 $r = 0; # $r -= $r would be more symmetrical
1528 }
1529 }
1530 }
1531 }
1532 0 $items = join("", @i);
1533 0 return pack("LLss" . padded($items), $drawable, $gc, $x, $y, $items);
1534 }],
1535  
1536 0 ▶ ['PolyText16', sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
1537 0 my $self = shift;
1538 0 my($drawable, $gc, $x, $y, @items) = @_;
1539 0 my(@i, $ir, @item, $n, $r, $items);
1540 0 for $ir (@items) {
1541 0 ▶ if (not ref $ir) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $ir) { } 0 0 0
1542 0 push @i, pack("CN", 255, $ir);
1543 } else {
1544 0 @item = @$ir;
1545 0 $n = 0;
1546 0 $r = length($item[1]);
1547 0 ▶ while ($r > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r > 0) 0 0 0
1548 0 ▶ if ($r >= 508) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r >= 508) { } 0 0 0
1549 0 push @i, pack("Cc", 254, 0) . substr($item[1], $n, 508);
1550 0 $n += 508;
1551 0 $r -= 508;
1552 } else {
1553 0 push @i, pack("Cc", $r / 2, $item[0])
1554 . substr($item[1], $n);
1555 0 $n += $r; # Unnecessary
1556 0 $r = 0; # $r -= $r would be more symmetrical
1557 }
1558 }
1559 }
1560 }
1561 0 $items = join("", @i);
1562 0 return pack("LLss" . padded($items), $drawable, $gc, $x, $y, $items);
1563 }],
1564  
1565 0 ▶ ['ImageText8', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1566 0 my $self = shift;
1567 0 my($drawable, $gc, $x, $y, $str) = @_;
1568 0 return pack("LLss" . padded($str), $drawable, $gc, $x, $y, $str),
1569 length($str);
1570 }],
1571  
1572 0 ▶ ['ImageText16', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1573 0 my $self = shift;
1574 0 my($drawable, $gc, $x, $y, $str) = @_;
1575 0 return pack("LLss" . padded($str), $drawable, $gc, $x, $y, $str),
1576 length($str)/2;
1577 }],
1578  
1579 0 ▶ ['CreateColormap', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1580 0 my $self = shift;
1581 0 my($mid, $visual, $win, $alloc) = @_;
1582 0 ▶ $alloc = 0 if $alloc eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $alloc eq "None" 0 0 0
1583 0 ▶ $alloc = 1 if $alloc eq "All";
Branch: 1 branch
BranchTrueFalseTotal
if $alloc eq "All" 0 0 0
1584 0 return pack("LLL", $mid, $win, $visual), $alloc;
1585 }],
1586  
1587 0 ▶ ['FreeColormap', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1588 0 my $self = shift;
1589 0 my($cmap) = @_;
1590 0 return pack("L", $cmap);
1591 }],
1592  
1593 0 ▶ ['CopyColormapAndFree', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1594 0 my $self = shift;
1595 0 my($mid, $src) = @_;
1596 0 return pack("LL", $mid, $src);
1597 }],
1598  
1599 0 ▶ ['InstallColormap', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1600 0 my $self = shift;
1601 0 my($cmap) = @_;
1602 0 return pack("L", $cmap);
1603 }],
1604  
1605 0 ▶ ['UninstallColormap', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1606 0 my $self = shift;
1607 0 my($cmap) = @_;
1608 0 return pack("L", $cmap);
1609 }],
1610  
1611 0 ▶ ['ListInstalledColormaps', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1612 0 my $self = shift;
1613 0 my($win) = @_;
1614 0 return pack("L", $win);
1615 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1616 0 my $self = shift;
1617 0 my($data) = @_;
1618 0 return unpack("L*", substr($data, 32));
1619 }],
1620  
1621 0 ▶ ['AllocColor', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1622 0 my $self = shift;
1623 0 my($cmap, $r, $g, $b) = @_;
1624 0 return pack("LSSSxx", $cmap, $r, $g, $b);
1625 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1626 0 my $self = shift;
1627 0 my($data) = @_;
1628 0 my($r, $g, $b, $pixel) = unpack("xxxxxxxxSSSxxLxxxxxxxxxxxx", $data);
1629 0 return ($pixel, $r, $g, $b);
1630 }],
1631  
1632 0 ▶ ['AllocNamedColor', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1633 0 my $self = shift;
1634 0 my($cmap, $name) = @_;
1635 0 return pack("LSxx" . padded($name), $cmap, length($name), $name);
1636 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1637 0 my $self = shift;
1638 0 my($data) = @_;
1639 0 return unpack("xxxxxxxxLSSSSSSxxxxxxxx", $data);
1640 }],
1641  
1642 0 ▶ ['AllocColorCells', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1643 0 my $self = shift;
1644 0 my($cmap, $colors, $planes, $contig) = @_;
1645 0 return pack("LSS", $cmap, $colors, $planes), $contig;
1646 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1647 0 my $self = shift;
1648 0 my($data) = @_;
1649 0 my($n,$m) = unpack("xxxxxxxxSSxxxxxxxxxxxxxxxxxxxx",substr($data, 0, 32));
1650 0 return ([unpack("L*", substr($data, 32, 4 * $n))],
1651 [unpack("L*", substr($data, 32 + 4 * $n, 4 * $m))]);
1652 }],
1653  
1654 0 ▶ ['AllocColorPlanes', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1655 0 my $self = shift;
1656 0 my($cmap, $colors, $reds, $greens, $blues, $contig) = @_;
1657 0 return pack("LSSSS", $cmap, $colors, $reds, $greens, $blues), $contig;
1658 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1659 0 my $self = shift;
1660 0 my($data) = @_;
1661 0 my($n, $r_mask, $g_mask, $b_mask) =
1662 unpack("xxxxxxxxSxxLLLxxxxxxxx", substr($data, 0, 32));
1663 0 return ($r_mask, $g_mask, $b_mask, unpack("L*", substr($data, 32, 4*$n)));
1664 }],
1665  
1666 0 ▶ ['FreeColors', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1667 0 my $self = shift;
1668 0 my($cmap, $mask, @pixels) = @_;
1669 0 return pack("LLL*", $cmap, $mask, @pixels);
1670 }],
1671  
1672 0 ▶ ['StoreColors', sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1673 0 my $self = shift;
1674 0 my($cmap, @actions) = @_;
1675 0 my($l, @l);
1676 0 for $l (@actions) {
1677 0 @l = @$l;
1678 0 ▶ if (@l == 4) {
Branch: 2 branches
BranchTrueFalseTotal
if (@l == 4) { } 0 0 0
elsif (@l == 5) { } 0 0 0
1679 0 $l = pack("LSSSCx", @l, 7);
1680 } elsif (@l == 5) {
1681 0 $l = pack("LSSSCx", @l);
1682 } else {
1683 0 croak "Wrong # of items in arg to StoreColors";
1684 }
1685 }
1686 0 return pack("L", $cmap) . join("", @actions);
1687 }],
1688  
1689 0 ▶ ['StoreNamedColor', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1690 0 my $self = shift;
1691 0 my($cmap, $pixel, $name, $do) = @_;
1692 0 return pack("LLSxx" . padded($name), $cmap, $pixel, length($name),
1693 $name), $do;
1694 }],
1695  
1696 0 ▶ ['QueryColors', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1697 0 my $self = shift;
1698 0 my($cmap, @pixels) = @_;
1699 0 return pack("LL*", $cmap, @pixels);
1700 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1701 0 my $self = shift;
1702 0 my($data) = @_;
1703 0 my($n) = unpack("xxxxxxxxSxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32));
1704 0 my($i, @colors);
1705 0 for $i (0 .. $n - 1) {
1706 0 push @colors, [unpack("SSSxx", substr($data, 32 + 8 * $i, 8))];
1707 }
1708 0 return @colors;
1709 }],
1710  
1711 0 ▶ ['LookupColor', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1712 0 my $self = shift;
1713 0 my($cmap, $name) = @_;
1714 0 return pack("LSxx" . padded($name), $cmap, length($name), $name);
1715 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1716 0 my $self = shift;
1717 0 my($data) = @_;
1718 0 return unpack("xxxxxxxxSSSSSSxxxxxxxxxxxx", $data);
1719 }],
1720  
1721 0 ▶ ['CreateCursor', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1722 0 my $self = shift;
1723 0 my($cid, $src, $mask, $fr, $fg, $fb, $br, $bg, $bb, $x, $y) = @_;
1724 0 ▶ $mask = 0 if $mask eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $mask eq "None" 0 0 0
1725 0 return pack("LLLSSSSSSSS", $cid, $src, $mask, $fr, $fg, $fb, $br, $bg,
1726 $bb, $x, $y);
1727 }],
1728  
1729 0 ▶ ['CreateGlyphCursor', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1730 0 my $self = shift;
1731 0 my($cid, $src_fnt, $mask_fnt, $src_ch, $mask_ch, $fr, $fg, $fb, $br,
1732 $bg, $bb) = @_;
1733 0 ▶ $mask_fnt = 0 if $mask_fnt eq "None";
Branch: 1 branch
BranchTrueFalseTotal
if $mask_fnt eq "None" 0 0 0
1734 0 return pack("LLLSSSSSSSS", $cid, $src_fnt, $mask_fnt, $src_ch, $mask_ch,
1735 $fr, $fg, $fb, $br, $bg, $bb);
1736 }],
1737  
1738 0 ▶ ['FreeCursor', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1739 0 my $self = shift;
1740 0 my($cursor) = @_;
1741 0 return pack("L", $cursor);
1742 }],
1743  
1744 0 ▶ ['RecolorCursor', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1745 0 my $self = shift;
1746 0 my($cursor, $fr, $fg, $fb, $br, $bg, $bb) = @_;
1747 0 return pack("LSSSSSS", $cursor, $fr, $fg, $fb, $br, $bg, $bb);
1748 }],
1749  
1750 0 ▶ ['QueryBestSize', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1751 0 my $self = shift;
1752 0 my($class, $drawable, $w, $h) = @_;
1753 0 $class = $self->num('SizeClass', $class);
1754 0 return pack("LSS", $drawable, $w, $h), $class;
1755 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1756 0 my $self = shift;
1757 0 my($data) = @_;
1758 0 my($w, $h) = unpack("xxxxxxxxSSxxxxxxxxxxxxxxxxxxxx", $data);
1759 0 return ($w, $h);
1760 }],
1761  
1762 0 ▶ ['QueryExtension', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1763 0 my $self = shift;
1764 0 my($name) = @_;
1765 0 return pack("Sxx" . padded($name), length($name), $name);
1766 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1767 0 my $self = shift;
1768 0 my($data) = @_;
1769 0 my($present, $major, $event, $error) =
1770 unpack("xxxxxxxxCCCCxxxxxxxxxxxxxxxxxxxx", $data);
1771 0 ▶ return () unless $present;
Branch: 1 branch
BranchTrueFalseTotal
unless $present 0 0 0
1772 0 return ($major, $event, $error);
1773 }],
1774  
1775 0 ▶ ['ListExtensions', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1776 0 my $self = shift;
1777 0 return "";
1778 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1779 0 my $self = shift;
1780 0 my($data) = @_;
1781 0 my($num) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
1782 substr($data, 0, 32));
1783 0 my($list) = substr($data, 32);
1784 0 my(@ret, $offset, $len, $i);
1785 0 $offset = 0;
1786 0 ▶ while ($i++ < $num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i++ < $num) 0 0 0
1787 0 $len = unpack("C", substr($list, $offset, 1));
1788 0 push @ret, substr($list, $offset + 1, $len);
1789 0 $offset += $len + 1;
1790 }
1791 0 return @ret;
1792 }],
1793  
1794 0 ▶ ['ChangeKeyboardMapping', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1795 0 my $self = shift;
1796 0 my($first, $m, @info) = @_;
1797 0 my($ar);
1798 0 for $ar (@info) {
1799 0 $ar = pack("L$m", @{$ar}[0 .. $m - 1]);
1800 }
1801 0 return pack("CCxx", $first, $m) . join("", @info), scalar(@info);
1802 }],
1803  
1804 0 ▶ ['GetKeyboardMapping', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1805 0 my $self = shift;
1806 0 my($first, $count) = @_;
1807 0 return pack("CCxx", $first, $count);
1808 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1809 0 my $self = shift;
1810 0 my($data) = @_;
1811 0 my($n,$l) = unpack("xCxxLxxxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32));
1812 0 my(@ret, $i);
1813 0 for $i (0 .. $l/$n - 1) {
1814 0 push @ret, [unpack("L$n", substr($data, 32 + $i * $n * 4))];
1815 }
1816 0 return @ret;
1817 }],
1818  
1819 0 ▶ ['ChangeKeyboardControl', sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
1820 0 my $self = shift;
1821 0 my(%values) = @_;
1822 0 my($mask, $i, @values);
1823 0 $mask = 0;
1824 0 for $i (0 .. 7) {
1825 0 ▶ if (exists $values{$KeyboardControl_ValueMask[$i][0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $values{$KeyboardControl_ValueMask[$i][0]}) 0 0 0
1826 0 $mask |= (1 << $i);
1827 push @values,
1828 0 &{$KeyboardControl_ValueMask[$i][1]}
1829 0 ($self, $values{$KeyboardControl_ValueMask[$i][0]});
1830 }
1831 }
1832 0 return pack("L", $mask). join "", @values;
1833 }],
1834  
1835 0 ▶ ['GetKeyboardControl', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1836 0 my $self = shift;
1837 0 return "";
1838 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1839 0 my $self = shift;
1840 0 my($data) = @_;
1841 0 my($global_auto_repeat, $led_mask, $key_click_percent, $bell_percent,
1842 $bell_pitch, $bell_duration)
1843 = unpack("xCxxxxxxLCCSSxx", substr($data, 0, 20));
1844 0 my($auto_repeats) = substr($data, 20, 32);
1845 0 return ('global_auto_repeat' =>
1846 $self->interp('LedMode', $global_auto_repeat),
1847 'led_mask' => $led_mask,
1848 'key_click_percent' => $key_click_percent,
1849 'bell_percent' => $bell_percent, 'bell_pitch' => $bell_pitch,
1850 'bell_duration' => $bell_duration,
1851 'auto_repeats' => $auto_repeats);
1852 }],
1853  
1854 0 ▶ ['Bell', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1855 0 my $self = shift;
1856 0 my($percent) = @_;
1857 0 return "", unpack("C", pack("c", $percent)); # Ick
1858 }],
1859  
1860 0 ▶ ['ChangePointerControl', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1861 0 my $self = shift;
1862 0 my($do_accel, $do_thresh, $num, $denom, $thresh) = @_;
1863 0 return pack("sssCC", $num, $denom, $thresh, $do_accel, $do_thresh);
1864 }],
1865  
1866 0 ▶ ['GetPointerControl', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1867 0 my $self = shift;
1868 0 return "";
1869 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1870 0 my $self = shift;
1871 0 my($data) = @_;
1872 0 my($num, $deno, $thresh) = unpack("xxxxxxxxSSSxxxxxxxxxxxxxxxxxx", $data);
1873 0 return ($num, $deno, $thresh);
1874 }],
1875  
1876 0 ▶ ['SetScreenSaver', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1877 0 my $self = shift;
1878 0 my($timeout, $interval, $pref_blank, $exposures) = @_;
1879 0 $pref_blank = $self->num('ScreenSaver', $pref_blank);
1880 0 $exposures = $self->num('ScreenSaver', $exposures);
1881 0 return pack("ssCCxx", $timeout, $interval, $pref_blank, $exposures);
1882 }],
1883  
1884 0 ▶ ['GetScreenSaver', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1885 0 my $self = shift;
1886 0 return "";
1887 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1888 0 my $self = shift;
1889 0 my($data) = @_;
1890 0 my($timeout, $interval, $pref_blank, $exposures)
1891 = unpack("xxxxxxxxSSCCxxxxxxxxxxxxxxxxxx", $data);
1892 0 $pref_blank = $self->interp('ScreenSaver', $pref_blank);
1893 0 $exposures = $self->interp('ScreenSaver', $exposures);
1894 0 return ($timeout, $interval, $pref_blank, $exposures);
1895 }],
1896  
1897 0 ▶ ['ChangeHosts', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1898 0 my $self = shift;
1899 0 my($mode, $family, $address) = @_;
1900 0 $mode = $self->num('HostChangeMode', $mode);
1901 0 $family = $self->num('HostFamily', $family);
1902 0 return pack("CxS" . padded($address), $family, length($address),
1903 $address), $mode;
1904 }],
1905  
1906 0 ▶ ['ListHosts', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1907 0 my $self = shift;
1908 0 return "";
1909 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1910 0 my $self = shift;
1911 0 my($data) = @_;
1912 0 my($mode, $n) = unpack("xCxxxxxxSxxxxxxxxxxxxxxxxxxxxxx",
1913 substr($data, 0, 32));
1914 0 $mode = $self->interp('AccessMode', $mode);
1915 0 my(@ret, $fam, $off, $l);
1916 0 $off = 32;
1917 0 ▶ while ($n-- > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n-- > 0) 0 0 0
1918 0 ($fam, $l) = unpack("CxS", substr($data, $off, 4));
1919 0 $fam = $self->interp('HostFamily', $fam);
1920 0 push @ret, [$fam, substr($data, $off + 4, $l)];
1921 0 $off += 4 + $l + padding($l);
1922 }
1923 0 return ($mode, @ret);
1924 }],
1925  
1926 0 ▶ ['SetAccessControl', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1927 0 my $self = shift;
1928 0 my($mode) = @_;
1929 0 $mode = $self->num('AccessMode', $mode);
1930 0 return "", $mode;
1931 }],
1932  
1933 0 ▶ ['SetCloseDownMode', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1934 0 my $self = shift;
1935 0 my($mode) = @_;
1936 0 $mode = $self->num('CloseDownMode', $mode);
1937 0 return "", $mode;
1938 }],
1939  
1940 0 ▶ ['KillClient', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1941 0 my $self = shift;
1942 0 my($rsrc) = @_;
1943 0 ▶ $rsrc = 0 if $rsrc eq "AllTemporary";
Branch: 1 branch
BranchTrueFalseTotal
if $rsrc eq "AllTemporary" 0 0 0
1944 0 return pack("L", $rsrc);
1945 }],
1946  
1947 0 ▶ ['RotateProperties', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1948 0 my $self = shift;
1949 0 my($win, $delta, @atoms) = @_;
1950 0 return pack("LSsL*", $win, scalar(@atoms), $delta, @atoms);
1951 }],
1952  
1953 0 ▶ ['ForceScreenSaver', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1954 0 my $self = shift;
1955 0 my($mode) = @_;
1956 0 $mode = $self->num('ScreenSaverAction', $mode);
1957 0 return "", $mode;
1958 }],
1959  
1960 0 ▶ ['SetPointerMapping', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1961 0 my $self = shift;
1962 0 my(@map) = @_;
1963 0 my($map) = pack("C*", @map);
1964 0 return pack(padded($map), $map), length($map);
1965 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1966 0 my $self = shift;
1967 0 my($data) = @_;
1968 0 my($status) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $data);
1969 0 $status = $self->interp('MappingChangeStatus', $status);
1970 0 return $status;
1971 }],
1972  
1973 0 ▶ ['GetPointerMapping', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1974 0 my $self = shift;
1975 0 return "";
1976 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1977 0 my $self = shift;
1978 0 my($data) = @_;
1979 0 my($n) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32));
1980 0 return unpack("C*", substr($data, 32, $n));
1981 }],
1982  
1983 0 ▶ ['SetModifierMapping', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1984 0 my $self = shift;
1985 0 my(@keycodes) = @_;
1986 0 my($n) = scalar(@{$keycodes[0]});
1987 0 my($kr);
1988 0 for $kr (@keycodes) {
1989 0 $kr = pack("C$n", @$kr, (0) x (@$kr - $n));
1990 }
1991 0 return join("", @keycodes), $n;
1992 0 ▶ }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1993 0 my $self = shift;
1994 0 my($data) = @_;
1995 0 my($status) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $data);
1996 0 return $self->interp('MappingChangeStatus', $status);
1997 }],
1998  
1999 0 ▶ ['GetModifierMapping', sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
2000 0 my $self = shift;
2001 0 return "";
2002 0 ▶ }, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2003 0 my $self = shift;
2004 0 my($data) = @_;
2005 0 my($n) = unpack("xCxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", substr($data, 0, 32));
2006 0 my(@ret, $i);
2007 0 for $i (0 .. 7) {
2008 0 push @ret, [unpack("C$n", substr($data, 32 + $n * $i))];
2009 }
2010 0 return @ret;
2011 }],
2012  
2013 0, 0, 0, 0, 0, 0, 0,
2014  
2015 0 ▶ ['NoOperation', sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2016 0 my $self = shift;
2017 0 my($len) = @_;
2018 0 ▶ $len = 1 unless defined $len;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $len 0 0 0
2019 0 return "\0" x (($len - 1) * 4);
2020 1 }]);
2021  
2022 1 my($i);
2023 1 for $i (0 .. 127) {
2024 128 ▶ if (ref $Requests[$i] and $Requests[$i][0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $Requests[$i] and $Requests[$i][0]) { } 120 8 128
Condition66%2/3
ref $Requests[$i] and $Requests[$i][0]
!ll&&!rl&&r
80120
MC/DC50%1/2
ref $Requests[$i] and $Requests[$i][0]
ref $Requests[$i] $Requests[$i][0]
Truth table66%2/3
A and B
A= ref $Requests[$i]B= $Requests[$i][0]
ABresult
0X0
100
111
2025 120 $Const{'Request'}[$i] = $Requests[$i][0];
2026 } else {
2027 8 $Const{'Request'}[$i] = "";
2028 }
2029 }
2030  
2031 0 ▶sub get_request {
Subroutine get_request: not called CC=4 SCAR=30.0
Pod undocumented
2032 0 my $self = shift;
2033 0 my($name) = @_;
2034 0 my($major, $minor);
2035 0 $major = $self->num('Request', $name);
2036 0 ▶ if ($major =~ /^\d+$/) { # Core request
Branch: 1 branch
BranchTrueFalseTotal
if ($major =~ /^\d+$/) { } 0 0 0
2037 0 return ($self->{'requests'}[$major], $major);
2038 } else { # Extension request
2039 croak "Unknown request `$name'" unless
2040 0 ▶ exists $self->{'ext_request_num'}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"ext_request_num"}{$name} 0 0 0
2041 0 ($major, $minor) = @{$self->{'ext_request_num'}{$name}};
2042 0 ▶ croak "Unknown request `$name'" if int($major) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if int $major == 0 0 0 0
2043 0 return ($self->{'ext_request'}{$major}[$minor], $major, $minor);
2044 }
2045 }
2046  
2047 0 ▶sub assemble_request {
Subroutine assemble_request: not called CC=5 SCAR=34.0
Pod undocumented
2048 0 my $self = shift;
2049 0 my($op, $args, $major, $minor) = (@_, 0);
2050 0 my($data);
2051 0 ($data, $minor) = (&{$op->[1]}($self, @$args), $minor);
2052 0 ▶ $minor = 0 unless defined $minor;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $minor 0 0 0
2053 0 my($len) = (length($data) / 4) + 1;
2054 0 ▶ croak "Request too long!\n" if $len > $self->{'maximum_request_length'};
Branch: 1 branch
BranchTrueFalseTotal
if $len > $self->{"maximum_request_length"} 0 0 0
2055 0 ▶ if ($len <= 65535) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len <= 65535) { } 0 0 0
2056 0 return pack("CCS", $major, $minor, $len) . $data;
2057 } else {
2058 0 ▶ croak "Can't happen" unless $self->{'ext'}{'BIG_REQUESTS'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ext"}{"BIG_REQUESTS"} 0 0 0
2059 0 return pack("CCSL", $major, $minor, 0, $len) . $data;
2060 }
2061 }
2062  
2063 0 ▶sub req {
Subroutine req: not called CC=7 SCAR=40.3
Pod undocumented
2064 0 my $self = shift;
2065 0 my($name, @args) = @_;
2066 0 my($op, $major, $minor) = $self->get_request($name);
2067 0 ▶ if (@$op == 2) { # No reply
Branch: 3 branches
BranchTrueFalseTotal
if (@$op == 2) { } 0 0 0
elsif (@$op == 3) { } 0 0 0
elsif (@$op == 4) { } 0 0 0
2068 0 $self->give($self->assemble_request($op, \@args, $major, $minor));
2069 0 $self->next_sequence();
2070 } elsif (@$op == 3) { # One reply
2071 0 my($seq, $data);
2072 0 $self->give($self->assemble_request($op, \@args, $major, $minor));
2073 0 $seq = $self->next_sequence();
2074 0 $self->add_reply($seq & 0xffff, \$data);
2075 0 $self->handle_input_for($seq & 0xffff);
2076 0 $self->delete_reply($seq & 0xffff);
2077 0 return &{$op->[2]}($self, $data);
2078 } elsif (@$op == 4) { # Many replies
2079 0 my($seq, $data, @stuff, @ret);
2080 0 $self->give($self->assemble_request($op, \@args, $major, $minor));
2081 0 $seq = $self->next_sequence();
2082 0 $self->add_reply($seq & 0xffff, \$data);
2083 0 for (;;) {
2084 0 $data = 0; $self->handle_input_for($seq & 0xffff);
2085 0 @stuff = &{$op->[2]}($self, $data);
2086 0 ▶ last unless @stuff;
Branch: 1 branch
BranchTrueFalseTotal
unless @stuff 0 0 0
2087 0 ▶ if ($op->[3] eq "ARRAY") {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->[3] eq 'ARRAY') { } 0 0 0
elsif ($op->[3] eq 'HASH') { } 0 0 0
2088 0 push @ret, [@stuff];
2089 } elsif ($op->[3] eq "HASH") {
2090 0 push @ret, {@stuff};
2091 } else {
2092 0 push @ret, @stuff;
2093 }
2094 }
2095 0 $self->delete_reply($seq & 0xffff);
2096 0 return @ret;
2097 } else {
2098 0 croak "Can't handle request $name";
2099 }
2100 }
2101  
2102 0 ▶sub robust_req {
Subroutine robust_req: not called CC=7 SCAR=40.3
Pod documented
2103 0 my $self = shift;
2104 0 my($name, @args) = @_;
2105 0 my($op, $major, $minor) = $self->get_request($name);
2106 # Luckily, ListFontsWithInfo can't cause any errors
2107 0 ▶ return [$self->req($name, @args)] if @$op == 4;
Branch: 1 branch
BranchTrueFalseTotal
if @$op == 4 0 0 0
2108 0 my $err_data;
2109 0 ▶ local($self->{'error_handler'}) = sub { $err_data = $_[1]; };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2110 0 my($seq, $data);
2111 0 $self->give($self->assemble_request($op, \@args, $major, $minor));
2112 0 $seq = $self->next_sequence() & 0xffff;
2113 0 ▶ if (@$op == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$op == 2) 0 0 0
2114 # No real reply, but fake up a request with a reply so we can
2115 # tell how long to wait before knowing the real request
2116 # succeeded
2117 0 my($fake_op, $fake_major) = $self->get_request("GetScreenSaver");
2118 0 $self->give($self->assemble_request($fake_op, [], $fake_major, 0));
2119 0 $seq = $self->next_sequence() & 0xffff;
2120 }
2121 0 $self->add_reply($seq, \$data);
2122 0 for (;;) {
2123 0 my $stat = $self->handle_input();
2124 0 ▶ if ($stat == $seq) {
Branch: 2 branches
BranchTrueFalseTotal
if ($stat == $seq) { } 0 0 0
elsif ($stat == -1 and $self->{'error_seq'} == $seq) { } 0 0 0
2125 0 $self->delete_reply($seq);
2126 0 ▶ if (@$op == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$op == 3) { } 0 0 0
2127 0 return [&{$op->[2]}($self, $data)];
2128 } else {
2129 0 return [];
2130 }
2131 ▶ } elsif ($stat == -1 && $self->{'error_seq'} == $seq) {
Condition0%0/3
$stat == -1 and $self->{"error_seq"} == $seq
!ll&&!rl&&r
000
MC/DC0%0/2
$stat == -1 and $self->{"error_seq"} == $seq
$stat == -1 $self->{"error_seq"} == $seq
Truth table0%0/3
A and B
A= $stat == -1B= $self->{"error_seq"} == $seq
ABresult
0X0
100
111
2132 0 my($type, undef, $info, $minor_op, $major_op)
2133 = unpack("xCSLSCxxxxxxxxxxxxxxxxxxxxx", $err_data);
2134 0 return($self->interp('Error', $type),
2135 $major_op, $minor_op, $info);
2136 }
2137 }
2138 }
2139  
2140 0 ▶sub send {
Subroutine send: not called CC=1 SCAR=6.9
Pod documented
2141 0 my $self = shift;
2142 0 my($name, @args) = @_;
2143 0 my($op, $major, $minor) = $self->get_request($name);
2144 0 $self->give($self->assemble_request($op, \@args, $major, $minor));
2145 0 return $self->next_sequence();
2146 }
2147  
2148 0 ▶sub unpack_reply {
Subroutine unpack_reply: not called CC=1 SCAR=6.9
Pod documented
2149 0 my $self = shift;
2150 0 my($name, $data) = @_;
2151 0 my($op) = $self->get_request($name);
2152 0 return &{$op->[2]}($self, $data);
2153 }
2154  
2155 0 ▶sub request {
Subroutine request: not called CC=1 SCAR=6.9
Pod documented
2156 0 my $self = shift;
2157 0 $self->req(@_);
2158 }
2159  
2160 0 ▶sub atom_name {
Subroutine atom_name: not called CC=2 SCAR=17.9
Pod documented
2161 0 my $self = shift;
2162 0 my($num) = @_;
2163 0 ▶ if ($self->{'atom_names'}->[$num]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'atom_names'}[$num]) { } 0 0 0
2164 0 return $self->{'atom_names'}->[$num];
2165 } else {
2166 0 my($name) = $self->req('GetAtomName', $num);
2167 0 $self->{'atom_names'}->[$num] = $name;
2168 0 return $name;
2169 }
2170 }
2171  
2172 0 ▶sub atom {
Subroutine atom: not called CC=2 SCAR=17.9
Pod documented
2173 0 my $self = shift;
2174 0 my($name) = @_;
2175 0 ▶ if (exists $self->{'atoms'}{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'atoms'}{$name}) { } 0 0 0
2176 0 return $self->{'atoms'}{$name};
2177 } else {
2178 0 my($atom) = $self->req('InternAtom', $name, 0);
2179 0 $self->{'atoms'}{$name} = $atom;
2180 0 return $atom;
2181 }
2182 }
2183  
2184 0 ▶sub choose_screen {
Subroutine choose_screen: not called CC=2 SCAR=17.9
Pod documented
2185 0 my $self = shift;
2186 0 my($screen) = @_;
2187 0 my($k);
2188 0 for $k (keys %{$self->{'screens'}[$screen]}) {
2189 0 $self->{$k} = $self->{'screens'}[$screen]{$k};
2190 }
2191 }
2192  
2193 0 ▶sub init_extension {
Subroutine init_extension: not called CC=5 SCAR=34.0
Pod documented
2194 0 my $self = shift;
2195 0 my($name) = @_;
2196 0 ▶ my($major, $event, $error) = $self->req('QueryExtension', $name)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->req("QueryExtension", $name) or return 0 0 0 0
2197 or return 0;
2198 0 $name =~ tr/-/_/;
2199 0 ▶ unless (defined eval { require("X11/Protocol/Ext/$name.pm") }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined eval { do { require "X11/Protocol/Ext/$name.pm" } }) 0 0 0
2200 0 ▶ return 0 if substr($@, 0, 30) eq "Can't locate X11/Protocol/Ext/";
Branch: 1 branch
BranchTrueFalseTotal
if substr($@, 0, 30) eq "Can't locate X11/Protocol/Ext/" 0 0 0
2201 0 croak($@);
2202 }
2203 0 my($pkg) = "X11::Protocol::Ext::$name";
2204 0 my $obj = $pkg->new($self, $major, $event, $error);
2205 0 ▶ return 0 if not $obj;
Branch: 1 branch
BranchTrueFalseTotal
unless $obj 0 0 0
2206 0 $self->{'ext'}{$name} = [$major, $event, $error, $obj];
2207 }
2208  
2209 0 ▶sub init_extensions {
Subroutine init_extensions: not called CC=2 SCAR=17.9
Pod documented
2210 0 my $self = shift;
2211 0 my($ext);
2212 0 for $ext ($self->req('ListExtensions')) {
2213 0 $self->init_extension($ext);
2214 }
2215 }
2216  
2217 0 ▶sub new_rsrc {
Subroutine new_rsrc: not called CC=3 SCAR=24.8
Pod documented
2218 0 my $self = shift;
2219 0 ▶ if ($self->{'rsrc_id'} == $self->{'rsrc_max'} + 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"rsrc_id"} == $self->{"rsrc_max"} + 1) 0 0 0
2220 0 ▶ if (exists $self->{'ext'}{'XC_MISC'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'ext'}{'XC_MISC'}) { } 0 0 0
2221 0 my($start, $count) = $self->req('XCMiscGetXIDRange');
2222 0 $self->{'rsrc_shift'} = 0;
2223 0 $self->{'rsrc_id'} = 0;
2224 0 $self->{'rsrc_base'} = $start;
2225 0 $self->{'rsrc_max'} = $count - 1;
2226 #print "Got $start $count\n";
2227 } else {
2228 0 croak "Out of resource IDs, and we don't have XC_MISC";
2229 }
2230 }
2231 my $ret = ($self->{'rsrc_id'}++ << $self->{'rsrc_shift'})
2232 0 + $self->{'rsrc_base'};
2233 0 return $ret;
2234 }
2235  
2236 1 ▶sub new {
Subroutine new: called CC=26 SCAR=60.4
Pod documented
2237 1 my($class) = shift;
2238 1 my($host, $dispnum, $screen);
2239 1 my($conn, $display, $family);
2240 1 ▶ if (@_ == 0 or $_[0] eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 0 or $_[0] eq '') { } 1 0 1
Condition33%1/3
@_ == 0 or $_[0] eq ""
l!l&&r!l&&!r
010
MC/DC0%0/2
@_ == 0 or $_[0] eq ""
@_ == 0 $_[0] eq ""
Truth table33%1/3
A or B
A= @_ == 0B= $_[0] eq ""
ABresult
1X1
011
000
2241 1 ▶ if ($main::ENV{'DISPLAY'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'DISPLAY'}) { } 0 1 1
2242 0 $display = $main::ENV{'DISPLAY'};
2243 } else {
2244 1 carp "Can't find DISPLAY -- guessing `$Default_Display:0'";
2245 1 $display = "$Default_Display:0";
2246 }
2247 } else {
2248 0 ▶ if (ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 0 0 0
2249 0 $conn = $_[0];
2250 } else {
2251 0 $display = $_[0];
2252 }
2253 }
2254  
2255 1 ▶ unless ($conn) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn) 1 0 1
2256 1 ▶ $display =~ /^(?:[^:]*?\/)?(.*):(\d+)(?:.(\d+))?$/
Branch: 1 branch
BranchTrueFalseTotal
$display =~ m[^(?:[^:]*?/)?(.*):(\d+)(?:.(\d+))?$] or croak("Invalid display: `${display}'\n") 1 0 1
2257 or croak "Invalid display: `$display'\n";
2258 1 ▶ $host = $Default_Display unless $host = $1;
Branch: 1 branch
BranchTrueFalseTotal
unless $host = $1 0 1 1
2259 1 $dispnum = $2;
2260 1 ▶ $screen = 0 unless $screen = $3;
Branch: 1 branch
BranchTrueFalseTotal
unless $screen = $3 1 0 1
2261 1 ▶ if ($] >= 5.00301) { # IO::Socket is bundled
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.00301) { } 1 0 1
2262 1 ▶ if ($host eq 'unix') {
Branch: 1 branch
BranchTrueFalseTotal
if ($host eq 'unix') { } 1 0 1
2263 1 require 'X11/Protocol/Connection/UNIXSocket.pm';
2264 1 $conn = X11::Protocol::Connection::UNIXSocket
2265 ->open($host, $dispnum);
2266 0 $host = 'localhost';
2267 0 $family = 'Local';
2268 } else {
2269 0 require 'X11/Protocol/Connection/INETSocket.pm';
2270 0 $conn = X11::Protocol::Connection::INETSocket
2271 ->open($host, $dispnum);
2272 0 $family = 'Internet';
2273 }
2274 } else { # Use FileHandle
2275 0 ▶ if ($host eq 'unix') {
Branch: 1 branch
BranchTrueFalseTotal
if ($host eq 'unix') { } 0 0 0
2276 0 require 'X11/Protocol/Connection/UNIXFH.pm';
2277 0 $conn = X11::Protocol::Connection::UNIXFH
2278 ->open($host, $dispnum);
2279 0 $host = 'localhost';
2280 0 $family = 'Local';
2281 } else {
2282 0 require 'X11/Protocol/Connection/INETFH.pm';
2283 0 $conn = X11::Protocol::Connection::INETFH
2284 ->open($host, $dispnum);
2285 0 $family = 'Internet';
2286 }
2287 }
2288 }
2289  
2290 0 my $self = {};
2291 0 bless $self, $class;
2292 0 $self->{'connection'} = $conn;
2293 0 $self->{'byte_order'} = $Byte_Order;
2294 0 $self->{'protocol_major_version'} = 11;
2295 0 $self->{'protocol_minor_version'} = 0;
2296 0 $self->{'const'} = \%Const;
2297 0 $self->{'const_num'} = \%Const_num;
2298 0 $self->{'authorization_protocol_name'} = '';
2299 0 $self->{'authorization_protocol_data'} = '';
2300  
2301 0 my($auth);
2302  
2303 0 ▶ if (ref($_[1]) eq "ARRAY") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[1] eq 'ARRAY') { } 0 0 0
elsif ($display and eval { do { require X11::Auth } }) { } 0 0 0
2304 ($self->{'authorization_protocol_name'},
2305 0 $self->{'authorization_protocol_data'}) = @{$_[1]};
2306 0 ▶ } elsif ($display and eval {require X11::Auth}) {
Condition0%0/3
$display and eval { do { require X11::Auth } }
!ll&&!rl&&r
000
MC/DC0%0/2
$display and eval { do { require X11::Auth } }
$display eval { do { require X11::Auth } }
Truth table0%0/3
A and B
A= $displayB= eval { do { require X11::Auth } }
ABresult
0X0
100
111
2307 $auth = X11::Auth->new() and
2308 ($self->{'authorization_protocol_name'},
2309 0 ▶ $self->{'authorization_protocol_data'})
Branch: 1 branch
BranchTrueFalseTotal
$auth = "X11::Auth"->new and ($self->{"authorization_protocol_name"}, $self->{"authorization_protocol_data"}) = ($auth->get_by_host($host, $family, $dispnum), "", "") 0 0 0
2310 = ($auth->get_by_host($host, $family, $dispnum), "", "");
2311 }
2312  
2313 $self->give(pack("A2 SSSS xx" .
2314 padded($self->{'authorization_protocol_name'}) .
2315 padded($self->{'authorization_protocol_data'}),
2316 $self->{'byte_order'},
2317 $self->{'protocol_major_version'},
2318 $self->{'protocol_minor_version'},
2319 length($self->{'authorization_protocol_name'}),
2320 length($self->{'authorization_protocol_data'}),
2321 $self->{'authorization_protocol_name'},
2322 0 $self->{'authorization_protocol_data'}));
2323  
2324 0 $self->flush;
2325 0 my($ret) = ord($self->get(1));
2326 0 ▶ if ($ret == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if ($ret == 0) { } 0 0 0
elsif ($ret == 2) { } 0 0 0
elsif ($ret == 1) { } 0 0 0
2327 0 my($len, $major, $minor, $xlen) = unpack("CSSS", $self->get(7));
2328 0 my($reason) = $self->get($xlen * 4);
2329 0 croak("Connection to server failed -- (version $major.$minor)\n",
2330 substr($reason, 0, $len));
2331 } elsif ($ret == 2) {
2332 0 croak("FIXME: authentication required\n");
2333 } elsif ($ret == 1) {
2334 0 my($major, $minor, $xlen) = unpack('xSSS', $self->get(7));
2335 ($self->{'release_number'}, $self->{'resource_id_base'},
2336 $self->{'resource_id_mask'}, $self->{'motion_buffer_size'},
2337 my($vlen), $self->{'maximum_request_length'}, my($screens),
2338 my($formats), $self->{'image_byte_order'},
2339 $self->{'bitmap_bit_order'}, $self->{'bitmap_scanline_unit'},
2340 $self->{'bitmap_scanline_pad'}, $self->{'min_keycode'},
2341 0 $self->{'max_keycode'})
2342 = unpack('LLLLSSCCCCCCCCxxxx', $self->get(32));
2343 $self->{'bitmap_bit_order'} =
2344 0 $self->interp('Significance', $self->{'bitmap_bit_order'});
2345 $self->{'image_byte_order'} =
2346 0 $self->interp('Significance', $self->{'image_byte_order'});
2347 0 $self->{'vendor'} = substr($self->get($vlen + padding $vlen),
2348 0, $vlen);
2349 0 $self->{'rsrc_shift'} = 0;
2350 0 my $mask = $self->{'resource_id_mask'};
2351 0 ▶ $self->{'rsrc_shift'}++ until ($mask >> $self->{'rsrc_shift'}) & 1;
Branch: 1 branch
BranchTrueFalseTotal
$mask >> $self->{"rsrc_shift"} & 1 or do { ++$self->{"rsrc_shift"} } 0 0 0
2352 0 $self->{'rsrc_id'} = 0;
2353 0 $self->{'rsrc_base'} = $self->{'resource_id_base'};
2354 0 $self->{'rsrc_max'} = $mask;
2355
2356 0 my($fmts) = $self->get(8 * $formats);
2357 0 my($n, $fmt);
2358 0 for $n (0 .. $formats - 1) {
2359 0 $fmt = substr($fmts, 8 * $n, 8);
2360 0 my($depth, $bpp, $pad) = unpack('CCC', $fmt);
2361 0 $self->{'pixmap_formats'}{$depth} = {'bits_per_pixel' => $bpp,
2362 'scanline_pad' => $pad};
2363 }
2364  
2365 0 my(@screens);
2366 0 ▶ while ($screens--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($screens--) 0 0 0
2367 0 my($root_wid, $def_cmap, $w_pixel, $b_pixel, $input_masks,
2368 $w_p, $h_p, $w_mm, $h_mm, $min_maps, $max_maps,
2369 $root_visual, $b_store, $s_unders, $depth, $n_depths)
2370 = unpack('LLLLLSSSSSSLCCCC', $self->get(40));
2371 0 my(%s) = ('root' => $root_wid, 'width_in_pixels' => $w_p,
2372 'height_in_pixels' => $h_p,
2373 'width_in_millimeters' => $w_mm,
2374 'height_in_millimeters' => $h_mm,
2375 'root_depth' => $depth, 'root_visual' => $root_visual,
2376 'default_colormap' => $def_cmap,
2377 'white_pixel' => $w_pixel, 'black_pixel' => $b_pixel,
2378 'min_installed_maps' => $min_maps,
2379 'max_installed_maps' => $max_maps,
2380 'backing_stores' =>
2381 $self->interp('BackingStore', $b_store),
2382 'save_unders' => $s_unders,
2383 'current_input_masks' => $input_masks);
2384 0 my($nd, @depths) = ();
2385 0 for $nd (1 .. $n_depths) {
2386 0 my($dep, $n_visuals) = unpack('CxSxxxx', $self->get(8));
2387 0 my($nv, %vt, @visuals) = ();
2388 0 for $nv (1 .. $n_visuals) {
2389 0 my($vid, $class, $bits_per_rgb, $map_ent, $red_mask,
2390 $green_mask, $blue_mask)
2391 = unpack('LCCSLLLxxxx', $self->get(24));
2392 0 $class = $self->interp('VisualClass', $class);
2393 0 %vt = ('visual_id' => $vid, 'class' => $class,
2394 'red_mask' => $red_mask,
2395 'green_mask' => $green_mask,
2396 'blue_mask' => $blue_mask,
2397 'bits_per_rgb_value' => $bits_per_rgb,
2398 'colormap_entries', => $map_ent);
2399 0 push @visuals, {%vt};
2400 0 delete $vt{'visual_id'};
2401 0 $self->{'visuals'}{$vid} = {%vt, 'depth' => $dep};
2402 }
2403 0 push @depths, {'depth' => $dep, 'visuals' => [@visuals]};
2404 }
2405 0 $s{'allowed_depths'} = [@depths];
2406 0 push @screens, {%s};
2407 }
2408 0 $self->{'screens'} = [@screens];
2409 0 $self->{'sequence_num'} = 1;
2410 0 $self->{'error_handler'} = \&default_error_handler;
2411 0 ▶ $self->{'event_handler'} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
2412 0 $self->{'requests'} = \@Requests;
2413 0 $self->{'events'} = \@Events;
2414 # 1 = uses rsrc/atom id field
2415 0 $self->{'error_type'} = [undef, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1,
2416 1, 0, 0, 0];
2417 $self->choose_screen($screen) if defined($screen)
2418 0 ▶ and $screen <= $#{$self->{'screens'}};
Branch: 1 branch
BranchTrueFalseTotal
if defined $screen and $screen <= $#{$$self{"screens"};} 0 0 0
Condition0%0/3
defined $screen and $screen <= $#{$$self{"screens"};}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $screen and $screen <= $#{$$self{"screens"};}
defined $screen $screen <= $#{$$self{"screens"};}
Truth table0%0/3
A and B
A= defined $screenB= $screen <= $#{$$self{"screens"};}
ABresult
0X0
100
111
2419 0 $self->{'do_interp'} = 1;
2420 } else {
2421 0 croak("Unknown response");
2422 }
2423 0 $self->init_extension("XC-MISC");
2424 0 return $self;
2425 }
2426  
2427 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=7 SCAR=38.4
2428 0 my($name) = $AUTOLOAD;
2429 0 $name =~ s/^.*:://;
2430 0 ▶ return if $name eq "DESTROY"; # Avoid problems during final cleanup
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "DESTROY" 0 0 0
2431 0 ▶ if ($name =~ /^[A-Z]/) { # Protocol request
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^[A-Z]/) { } 0 0 0
2432 0 my($obj) = shift;
2433  
2434 # Make this faster next time
2435 1 ▶ no strict 'refs'; # This is slightly icky
Subroutine BEGIN: called CC=1 SCAR=0.0
2436 0 my($op, $major, $minor) = $obj->get_request($name);
2437 0 ▶ if (@$op == 2) { # No reply
Branch: 2 branches
BranchTrueFalseTotal
if (@$op == 2) { } 0 0 0
elsif (@$op == 3) { } 0 0 0
2438 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
2439 0 my $self = shift;
2440 0 $self->give($self->assemble_request($op, \@_, $major, $minor));
2441 0 $self->next_sequence();
2442 0 };
2443 } elsif (@$op == 3) { # One reply
2444 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
2445 0 my $self = shift;
2446 0 my($seq, $data);
2447 0 $self->give($self->assemble_request($op, \@_, $major, $minor));
2448 0 $seq = $self->next_sequence();
2449 0 $self->add_reply($seq & 0xffff, \$data);
2450 0 $self->handle_input_for($seq & 0xffff);
2451 0 $self->delete_reply($seq & 0xffff);
2452 0 return &{$op->[2]}($self, $data);
2453 0 };
2454 } else { # ListFontsWithInfo
2455 # Not worth it
2456 }
2457  
2458 0 return $obj->req($name, @_);
2459 } else { # Instance variable
2460 0 ▶ if (@_ == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
elsif (@_ == 2) { } 0 0 0
2461 0 return $_[0]->{$name};
2462 } elsif (@_ == 2) {
2463 0 $_[0]->{$name} = $_[1];
2464 } else {
2465 0 croak "No such function `$name'";
2466 }
2467 }
2468 }
2469  
2470 1 1;
2471 __END__
« Protocol/Ext/RENDER.pm ↑ Summary Auth.pm »