Skip to content

Commit e3460c9

Browse files
committed
Linux: fix several XLib functions signature (fixes BoboTiG#92)
1 parent 527304b commit e3460c9

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ History:
22

33
<see Git checking messages for history>
44

5+
4.0.1 2019/0x/xx
6+
- Linux: fix several XLib functions signature (fixes #92)
7+
58
4.0.0 2019/01/11
69
- MSS: remove use of setup.py for setup.cfg
710
- MSS: renamed MSSBase to MSSMixin in base.py

CHANGES.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
4.0.0 (2019-xx-xx)
1+
4.0.1 (2019-0x-xx)
2+
==================
3+
4+
linux.py
5+
--------
6+
- Removed use of ``MSS.xlib.XDefaultScreen()``
7+
8+
9+
4.0.0 (2019-01-11)
210
==================
311

412
base.py

mss/linux.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,17 @@ def __init__(self, display=None):
180180
self._set_cfunctions()
181181

182182
self.display = self.xlib.XOpenDisplay(display)
183-
self.root = self.xlib.XDefaultRootWindow(
184-
self.display, self.xlib.XDefaultScreen(self.display)
185-
)
183+
self.root = self.xlib.XDefaultRootWindow(self.display)
186184

187185
# Fix for XRRGetScreenResources and XGetImage:
188186
# expected LP_Display instance instead of LP_XWindowAttributes
189187
self.drawable = ctypes.cast(self.root, ctypes.POINTER(Display))
190188

191189
def _set_cfunctions(self):
192-
""" Set all ctypes functions and attach them to attributes. """
190+
"""
191+
Set all ctypes functions and attach them to attributes.
192+
See https://tronche.com/gui/x/xlib/function-index.html for details.
193+
"""
193194

194195
def cfactory(
195196
attr=self.xlib, func=None, argtypes=None, restype=None, errcheck=validate
@@ -216,19 +217,13 @@ def cfactory(
216217
cfactory(func="XSetErrorHandler", argtypes=[void], restype=c_int)
217218
cfactory(
218219
func="XGetErrorText",
219-
argtypes=[pointer(Display), void, char_p, void],
220+
argtypes=[pointer(Display), c_int, char_p, c_int],
220221
restype=void,
221222
)
222223
cfactory(func="XOpenDisplay", argtypes=[char_p], restype=pointer(Display))
223-
cfactory(
224-
errcheck=None,
225-
func="XDefaultScreen",
226-
argtypes=[pointer(Display)],
227-
restype=void,
228-
)
229224
cfactory(
230225
func="XDefaultRootWindow",
231-
argtypes=[pointer(Display), void],
226+
argtypes=[pointer(Display)],
232227
restype=pointer(XWindowAttributes),
233228
)
234229
cfactory(
@@ -238,19 +233,19 @@ def cfactory(
238233
pointer(XWindowAttributes),
239234
pointer(XWindowAttributes),
240235
],
241-
restype=void,
236+
restype=c_int,
242237
)
243238
cfactory(
244239
func="XGetImage",
245240
argtypes=[
246241
pointer(Display),
247242
pointer(Display),
248-
void,
249-
void,
243+
c_int,
244+
c_int,
250245
uint,
251246
uint,
252247
ulong,
253-
void,
248+
c_int,
254249
],
255250
restype=pointer(XImage),
256251
)

0 commit comments

Comments
 (0)