X11/Protocol/Ext/XINERAMA.pm

filter: Statementstmt 35.0% 20 / 57 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 31.5% 6 / 19 Podpod 0.0% 0 / 1 totaltotal 30.2% 26 / 86 CC 5 SCAR 13.2
CC
5
Cov
31%
_num_none
12.0
_ext_requests_install
6.0
_request_empty
6.0
CRAP 3.7
« X11/Protocol/Ext/Composite.pm ↑ Summary X11/Protocol/Ext/XTEST.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2017 Kevin Ryde
2  
3 # This file is part of X11-Protocol-Other.
4 #
5 # X11-Protocol-Other is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as published
7 # by the Free Software Foundation; either version 3, or (at your option) any
8 # later version.
9 #
10 # X11-Protocol-Other is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with X11-Protocol-Other. If not, see <http://www.gnu.org/licenses/>.
17  
18 1 ▶BEGIN { require 5 }
Subroutine BEGIN: called CC=1 SCAR=0.0
19 package X11::Protocol::Ext::XINERAMA;
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use vars '$VERSION', '@CARP_NOT';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 $VERSION = 31;
25 1 @CARP_NOT = ('X11::Protocol');
26  
27 # uncomment this to run the ### lines
28 #use Smart::Comments;
29  
30 # /usr/include/X11/extensions/panoramiXproto.h
31 # Protocol structs etc.
32 # http://cgit.freedesktop.org/xorg/proto/xineramaproto/tree/panoramiXproto.h
33 #
34 # /usr/include/X11/extensions/Xinerama.h
35 # /usr/include/X11/extensions/panoramiXext.h
36 # Xlib.
37 #
38 # http://www.kernel.org/doc/als1999/Conference/IMcCartney/xinerama.html
39 #
40 # XINERAMA 1.0 in X11R6.4
41 # XINERAMA 1.1 in X11R6.7
42 #
43  
44 ### XINERAMA.pm loads
45  
46 # these not documented yet ...
47 1 ▶use constant CLIENT_MAJOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use constant CLIENT_MINOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 my $reqs =
51 [
52 [ 'PanoramiXQueryVersion', # 0
53 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 my ($X, $major, $minor) = @_;
55 ### PanoramiXQueryVersion
56 0 return pack 'CCxx', $major, $minor;
57 },
58 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 my ($X, $data) = @_;
60 0 return unpack 'x8SS', $data;
61 }],
62  
63 [ 'PanoramiXGetState', # 1
64 \&_request_xids, # ($X, $window)
65 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 my ($X, $data) = @_;
67 ### PanoramiXGetState reply
68 ### state and window: unpack 'xCx6L', $data
69  
70 # Reply "window" field may be set only in XINERAMA 1.1, not the
71 # X11R6.4 1.0. It's a copy of the request, so think can ignore.
72 0 return unpack 'xC', $data;
73 }],
74  
75 [ 'PanoramiXGetScreenCount', # 2
76 \&_request_xids, # ($X, $window)
77 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 0 my ($X, $data) = @_;
79 ### PanoramiXGetScreenCount reply: unpack "C*", $data
80 ### count and window: unpack 'xCx6L', $data
81  
82 # Reply "window" field may be set only in XINERAMA 1.1, not the
83 # X11R6.4 1.0. It's a copy of the request, so think can ignore.
84 0 return unpack 'xC', $data;
85 }],
86  
87 [ 'PanoramiXGetScreenSize', # 3
88 # ($X, $window, $screen)
89 # $screen is an integer not an xid, so ought not allow 'None' there
90 \&_request_xids,
91 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 0 my ($X, $data) = @_;
93 ### PanoramiXGetScreenSize reply
94 ### w,h,win,screen: unpack 'x8L*', $data
95  
96 # Reply "window" and "screen" fields may be set only in XINERAMA 1.1,
97 # not the X11R6.4 1.0. They're a copy of the request, so think can
98 # ignore.
99 0 return unpack 'x8LL', $data; # ($width,$height)
100 }],
101  
102 #------------
103 # version 1.1
104  
105 ["XineramaIsActive", # 4
106 \&_request_empty, # ($X)
107 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 0 my ($X, $data) = @_;
109 0 return unpack 'x8L', $data;
110 }],
111  
112 ["XineramaQueryScreens", # 5
113 \&_request_empty, # ($X)
114 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
115 0 my ($X, $data) = @_;
116 ### XineramaQueryScreens reply: unpack 'x8L*', $data
117 0 my $num = unpack 'x8L', $data;
118 0 map {[ unpack 'ssSS', substr($data, 32+8*$_, 8) ]} 0 .. $num-1;
119 1 }],
120 ];
121  
122 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
123 0 my ($class, $X, $request_num, $event_num, $error_num) = @_;
124 ### XINERAMA new()
125  
126 0 _ext_requests_install ($X, $request_num, $reqs);
127  
128 # Any need to negotiate?
129 # my ($major, $minor) = $X->req('PanoramiXQueryVersion',
130 # CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION);
131 # ### $major
132 # ### $minor
133  
134 0 return bless {
135 # major => $major,
136 # minor => $minor,
137 }, $class;
138 }
139  
140 0 ▶sub _ext_requests_install {
Subroutine _ext_requests_install: not called CC=2 SCAR=17.9
141 0 my ($X, $request_num, $reqs) = @_;
142  
143 0 $X->{'ext_request'}->{$request_num} = $reqs;
144 0 my $href = $X->{'ext_request_num'};
145 0 my $i;
146 0 foreach $i (0 .. $#$reqs) {
147 0 $href->{$reqs->[$i]->[0]} = [$request_num, $i];
148 }
149 }
150  
151 0 ▶sub _request_empty {
Subroutine _request_empty: not called CC=2 SCAR=17.9
152 0 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
153 0 croak "No parameters in this request";
154 }
155 0 return '';
156 }
157  
158 0 ▶sub _request_xids {
Subroutine _request_xids: not called CC=1 SCAR=6.9
159 0 my $X = shift;
160 ### _request_xids(): @_
161 0 return _request_card32s ($X, map {_num_none($_)} @_);
162 }
163 0 ▶sub _request_card32s {
Subroutine _request_card32s: not called CC=1 SCAR=6.9
164 0 shift;
165 ### _request_card32s(): @_
166 0 return pack 'L*', @_;
167 }
168 0 ▶sub _num_none {
Subroutine _num_none: not called CC=3 SCAR=24.8
169 0 my ($xid) = @_;
170 0 ▶ if (defined $xid && $xid eq 'None') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xid and $xid eq 'None') { } 0 0 0
Condition0%0/3
defined $xid and $xid eq "None"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $xid and $xid eq "None"
defined $xid $xid eq "None"
Truth table0%0/3
A and B
A= defined $xidB= $xid eq "None"
ABresult
0X0
100
111
171 0 return 0;
172 } else {
173 0 return $xid;
174 }
175 }
176  
177 1 1;
178 __END__
« X11/Protocol/Ext/Composite.pm ↑ Summary X11/Protocol/Ext/XTEST.pm »