Skip to content

Commit 2b6cd9c

Browse files
committed
Add wayland specific skips
1 parent 014f7d0 commit 2b6cd9c

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

buildconfig/stubs/pygame/display.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ def set_window_position(position: Point) -> None:
745745
still be able to move the window after this call. See also
746746
:func:`pygame.display.get_window_position()`.
747747
748+
.. note:: This function is not supported on some video drivers (like wayland)
749+
and a :exc:`pygame.error` exception may be raised in such cases.
750+
748751
.. versionadded:: 2.5.0
749752
"""
750753

buildconfig/stubs/pygame/window.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ class Window:
222222
223223
Setting the always-on-top mode requires SDL 2.0.16+.
224224
225+
.. note:: Setting this property is not supported on some video drivers (like wayland)
226+
and a :exc:`pygame.error` exception may be raised in such cases.
227+
225228
.. versionadded:: 2.3.1
226229
"""
227230

@@ -296,12 +299,19 @@ class Window:
296299
297300
The position may be a tuple of (x, y) coordinates or ``WINDOWPOS_CENTERED`` or
298301
``WINDOWPOS_UNDEFINED``. The origin is the topleft of the main display.
302+
303+
.. note:: Setting this property is not supported on some video drivers (like wayland)
304+
and a :exc:`pygame.error` exception may be raised in such cases.
299305
"""
300306

301307
@position.setter
302308
def position(self, value: Union[int, Point]) -> None: ...
303309
opacity: float
304-
"""Get or set the window opacity, between 0.0 (fully transparent) and 1.0 (fully opaque)."""
310+
"""Get or set the window opacity, between 0.0 (fully transparent) and 1.0 (fully opaque).
311+
312+
.. note:: Setting this property is not supported on some video drivers (like wayland)
313+
and a :exc:`pygame.error` exception may be raised in such cases.
314+
"""
305315

306316
@property
307317
def opengl(self) -> bool:

test/display_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
from pygame import display
99
from pygame.tests.test_utils import question
1010

11+
pygame.display.init()
12+
is_wayland = pygame.display.get_driver() == "wayland"
13+
pygame.display.quit()
14+
1115

1216
class DisplayModuleTest(unittest.TestCase):
1317
default_caption = "pygame window"
@@ -71,6 +75,7 @@ def test_get_active(self):
7175
os.environ.get("SDL_VIDEODRIVER") == pygame.NULL_VIDEODRIVER,
7276
"requires the SDL_VIDEODRIVER to be a non-null value",
7377
)
78+
@unittest.skipIf(is_wayland, "broken on wayland")
7479
def test_get_active_iconify(self):
7580
"""Test the get_active function after an iconify"""
7681

@@ -411,6 +416,7 @@ def test_gl_set_attribute(self):
411416
os.environ.get("SDL_VIDEODRIVER") in [pygame.NULL_VIDEODRIVER, "android"],
412417
"iconify is only supported on some video drivers/platforms",
413418
)
419+
@unittest.skipIf(is_wayland, "broken on wayland")
414420
def test_iconify(self):
415421
pygame.display.set_mode((640, 480))
416422

@@ -519,6 +525,7 @@ def test_quit__multiple(self):
519525
pygame.version.SDL >= (2, 32, 50),
520526
"set_gamma is removed in SDL3, does not work in sdl2-compat either",
521527
)
528+
@unittest.skipIf(is_wayland, "not supported on wayland")
522529
def test_set_gamma(self):
523530
pygame.display.set_mode((1, 1))
524531

@@ -537,6 +544,7 @@ def test_set_gamma(self):
537544
pygame.version.SDL >= (2, 32, 50),
538545
"set_gamma is removed in SDL3, does not work in sdl2-compat either",
539546
)
547+
@unittest.skipIf(is_wayland, "not supported on wayland")
540548
def test_set_gamma__tuple(self):
541549
pygame.display.set_mode((1, 1))
542550

@@ -690,6 +698,7 @@ def test_toggle_fullscreen(self):
690698
(test_surf.get_width(), test_surf.get_height()), width_height
691699
)
692700

701+
@unittest.skipIf(is_wayland, "not supported on wayland")
693702
def test_get_set_window_position(self):
694703
pygame.display.set_mode((500, 500))
695704
pygame.display.set_window_position((420, 360))

test/event_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
import pygame
77

8+
pygame.display.init()
9+
is_wayland = pygame.display.get_driver() == "wayland"
10+
pygame.display.quit()
11+
812
EVENT_TYPES = (
913
# pygame.NOEVENT,
1014
# pygame.ACTIVEEVENT,
@@ -837,8 +841,9 @@ def test_pump(self):
837841

838842
@unittest.skipIf(
839843
os.environ.get("SDL_VIDEODRIVER") == pygame.NULL_VIDEODRIVER,
840-
'requires the SDL_VIDEODRIVER to be a non-null value',
844+
"requires the SDL_VIDEODRIVER to be a non-null value",
841845
)
846+
@unittest.skipIf(is_wayland, "broken on wayland")
842847
def test_set_grab__and_get_symmetric(self):
843848
"""Ensure event grabbing can be enabled and disabled.
844849
@@ -905,8 +910,9 @@ def test_get_blocked__event_sequence(self):
905910

906911
@unittest.skipIf(
907912
os.environ.get("SDL_VIDEODRIVER") == pygame.NULL_VIDEODRIVER,
908-
'requires the SDL_VIDEODRIVER to be a non-null value',
913+
"requires the SDL_VIDEODRIVER to be a non-null value",
909914
)
915+
@unittest.skipIf(is_wayland, "broken on wayland")
910916
def test_get_grab(self):
911917
"""Ensure get_grab() works as expected"""
912918
surf = pygame.display.set_mode((10, 10))

test/window_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
IS_PYPY = "PyPy" == platform.python_implementation()
1313

14+
pygame.display.init()
15+
is_wayland = pygame.display.get_driver() == "wayland"
16+
pygame.display.quit()
17+
1418

1519
class WindowTypeTest(unittest.TestCase):
1620
DEFAULT_TITLE = "pygame window"
@@ -102,6 +106,7 @@ def test_always_on_top(self):
102106
SDL < (2, 0, 16),
103107
"requires SDL 2.0.16+",
104108
)
109+
@unittest.skipIf(is_wayland, "not supported on wayland")
105110
def test_always_on_top_set(self):
106111
self.win.always_on_top = True
107112
self.assertTrue(self.win.always_on_top)
@@ -149,6 +154,7 @@ def test_size(self):
149154

150155
self.win.size = (640, 480)
151156

157+
@unittest.skipIf(is_wayland, "not supported on wayland")
152158
def test_position(self):
153159
new_pos = (self.win.position[0] + 20, self.win.position[1] + 10)
154160
self.win.position = new_pos
@@ -160,8 +166,8 @@ def test_position(self):
160166
self.assertRaises(TypeError, lambda: setattr(self.win, "position", 123))
161167

162168
# test set position when init
163-
win = Window(position=(20, 48))
164-
self.assertTupleEqual((20, 48), win.position)
169+
win = Window(position=new_pos)
170+
self.assertTupleEqual(new_pos, win.position)
165171
win.destroy()
166172

167173
self.assertRaises(TypeError, lambda: Window(position=123))
@@ -255,6 +261,7 @@ def test_opacity(self):
255261
os.environ.get("SDL_VIDEODRIVER") == pygame.NULL_VIDEODRIVER,
256262
"requires the SDL_VIDEODRIVER to be a non-null value",
257263
)
264+
@unittest.skipIf(is_wayland, "not supported on wayland")
258265
def test_opacity_set(self):
259266
self.win.opacity = 0.5
260267
self.assertEqual(self.win.opacity, 0.5)

0 commit comments

Comments
 (0)