Commit 6ba662b
linux: Check the server for Xrandr support version (#417)
* Check the server for Xrandr support version
We currently only check the client libXrandr to see if it supports the
XRRGetScreenResourcesCurrent function. To make sure the function will
work, we also need to check the server's Xrandr version.
* Fix the test for missing XRRGetScreenResourcesCurrent
Previously, the test would try to monkey-patch the libXrandr module by
deleting the XRRGetScreenResourcesCurrent function.
However, this actually doesn't work as expected. It deletes all the
configuration you've assigned to that C function (argument and return
types). But ctypes.CDLL resolves symbols lazily in __getattr__ via
dlsym. Deleting the attribute only discards the previously created
_FuncPtr object; the next getattr/hasattr on the CDLL will just call
dlsym again and recreate it.
The existing test's code path seemed to be working, because the
implementation was just testing for AttributeError. The assumption
had been that if XRRGetScreenResourcesCurrent was deleted, then trying
to access it would raise an AttributeError. However, what was
actually being raised was when the .contents attribute of the return
value was being accessed: since the restype had been erased, then the
return value was now an int, not a pointer.
XRRGetScreenResourcesCurrent was still getting called, but trying to
read its .contents raised the AttributeError.
The new test now uses a proxy object to genuinely hide
XRRGetScreenResourcesCurrent.
Additionally, the test was split into three. The tests now will
ensure that the right functions are being called based on whether
XRRGetScreenResourcesCurrent is supported, missing on the client
library, or missing on the server.
---------
Co-authored-by: Mickaël Schoentgen <[email protected]>1 parent b83cc58 commit 6ba662b
2 files changed
+72
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| |||
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
391 | 396 | | |
392 | 397 | | |
393 | 398 | | |
| |||
400 | 405 | | |
401 | 406 | | |
402 | 407 | | |
403 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
404 | 411 | | |
405 | | - | |
| 412 | + | |
406 | 413 | | |
407 | 414 | | |
408 | 415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
| |||
133 | 143 | | |
134 | 144 | | |
135 | 145 | | |
136 | | - | |
| 146 | + | |
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
| 150 | + | |
| 151 | + | |
140 | 152 | | |
141 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
142 | 157 | | |
143 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
144 | 163 | | |
145 | 164 | | |
146 | 165 | | |
147 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
148 | 176 | | |
149 | 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 | + | |
150 | 210 | | |
151 | 211 | | |
152 | 212 | | |
| |||
0 commit comments