This file is indexed.

/usr/lib/python2.7/dist-packages/Xlib/ext/xinerama.py is in python-xlib 0.20-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# Xlib.ext.xinerama -- Xinerama extension module
#
#    Copyright (C) 2006 Mike Meyer <mwm@mired.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
#    Free Software Foundation, Inc.,
#    59 Temple Place,
#    Suite 330,
#    Boston, MA 02111-1307 USA


"""Xinerama - provide access to the Xinerama extension information.

There are at least there different - and mutually incomparable -
Xinerama extensions available. This uses the one bundled with XFree86
4.6 and/or Xorg 6.9 in the ati/radeon driver. It uses the include
files from that X distribution, so should work with it as well.  I
provide code for the lone Sun 1.0 request that isn't part of 1.1, but
this is untested because I don't have a server that implements it.

The functions loosely follow the libXineram functions. Mostly, they
return an rq.Struct in lieue of passing in pointers that get data from
the rq.Struct crammed into them. The exception is isActive, which
returns the state information - because that's what libXinerama does."""


from Xlib import X
from Xlib.protocol import rq, structs

extname = 'XINERAMA'


class QueryVersion(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(0),
        rq.RequestLength(),
        rq.Card8('major_version'),
        rq.Card8('minor_version'),
        rq.Pad(2),
        )

    _reply = rq.Struct(
            rq.ReplyCode(),
            rq.Pad(1),
            rq.Card16('sequence_number'),
            rq.ReplyLength(),
            rq.Card16('major_version'),
            rq.Card16('minor_version'),
            rq.Pad(20),
            )

def query_version(self):
    return QueryVersion(display=self.display,
                        opcode=self.display.get_extension_major(extname),
                        major_version=1,
                        minor_version=1)


class GetState(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(1),
        rq.RequestLength(),
        rq.Window('window'),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Bool('state'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Window('window'),
        rq.Pad(20),
        )

def get_state(self):
    return GetState(display=self.display,
                    opcode=self.display.get_extension_major(extname),
                    window=self.id,
                    )


class GetScreenCount(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(2),
        rq.RequestLength(),
        rq.Window('window'),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('screen_count'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Window('window'),
        rq.Pad(20),
        )

def get_screen_count(self):
    return GetScreenCount(display=self.display,
                          opcode=self.display.get_extension_major(extname),
                          window=self.id,
                          )


class GetScreenSize(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(3),
        rq.RequestLength(),
        rq.Window('window'),
        rq.Card32('screen'),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.Card32('length'),
        rq.Card32('width'),
        rq.Card32('height'),
        rq.Window('window'),
        rq.Card32('screen'),
        rq.Pad(8),
        )

def get_screen_size(self, screen_no):
    """Returns the size of the given screen number"""
    return GetScreenSize(display=self.display,
                         opcode=self.display.get_extension_major(extname),
                         window=self.id,
                         screen=screen_no,
                         )


# IsActive is only available from Xinerama 1.1 and later.
# It should be used in preference to GetState.
class IsActive(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(4),
        rq.RequestLength(),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('state'),
        rq.Pad(20),
        )

def is_active(self):
    r = IsActive(display=self.display,
                 opcode=self.display.get_extension_major(extname),
                 )
    return r.state


# QueryScreens is only available from Xinerama 1.1 and later
class QueryScreens(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(5),
        rq.RequestLength(),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('number'),
        rq.Pad(20),
        rq.List('screens', structs.Rectangle),
        )

def query_screens(self):
    # Hmm. This one needs to read the screen data from the socket. Ooops...
    return QueryScreens(display=self.display,
                        opcode=self.display.get_extension_major(extname),
                        )


# GetInfo is only available from some Xinerama 1.0, and *NOT* later! Untested
class GetInfo(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(4),
        rq.RequestLength(),
        rq.Card32('visual'),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Window('window'),
        # An array of subwindow slots goes here. Bah.
        )

def get_info(self, visual):
    r = GetInfo(display=self.display,
             opcode=self.display.get_extension_major(extname),
             visual=visual)

def init(disp, info):
    disp.extension_add_method('display', 'xinerama_query_version', query_version)
    disp.extension_add_method('window', 'xinerama_get_state', get_state)
    disp.extension_add_method('window', 'xinerama_get_screen_count', get_screen_count)
    disp.extension_add_method('window', 'xinerama_get_screen_size', get_screen_size)
    disp.extension_add_method('display', 'xinerama_is_active', is_active)
    disp.extension_add_method('display', 'xinerama_query_screens', query_screens)
    disp.extension_add_method('display', 'xinerama_get_info', get_info)