Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defined WINDOWEVENT_MINIMIZED (so you don't have to check for '7') #2090

Merged
merged 1 commit into from Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildconfig/pygame-stubs/constants.pyi
Expand Up @@ -538,6 +538,6 @@ VIDEOEXPOSE: int
VIDEORESIZE: int
WINDOWEVENT: int
WINDOWEVENT_CLOSE: int

WINDOWEVENT_MINIMIZED: int

__all__: List[str]
5 changes: 4 additions & 1 deletion docs/reST/ref/display.rst
Expand Up @@ -472,7 +472,10 @@ required).
True if successful.

When the display is iconified ``pygame.display.get_active()`` will return
False. The event queue should receive a ``ACTIVEEVENT`` event when the
False. When using SDL 1 (usually in pygame versions less than 2.0.0) the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this backwards compatibility should be captured in an issue?

I think it's easier for users to read the wording pygame 2, rather than SDL1 or SDL2. Since understanding SDL versions is maybe above the heads of most people.

event queue should receive a ``ACTIVEEVENT`` event when the window has been
iconified. When using SDL 2 (usually in pygame versions greater than 2.0.0)
the event queue should receive a ``WINDOWEVENT_MINIMIZED`` event when the
window has been iconified.

.. ## pygame.display.iconify ##
Expand Down
2 changes: 2 additions & 0 deletions src_c/constants.c
Expand Up @@ -393,6 +393,7 @@ MODINIT_DEFINE(constants)
DEC_CONST(TEXTEDITING);
DEC_CONST(WINDOWEVENT);
DEC_CONST(WINDOWEVENT_CLOSE);
DEC_CONST(WINDOWEVENT_MINIMIZED);

DEC_CONST(CONTROLLERAXISMOTION);
DEC_CONST(CONTROLLERBUTTONDOWN);
Expand Down Expand Up @@ -462,6 +463,7 @@ MODINIT_DEFINE(constants)
DEC_CONSTS(TEXTEDITING, -1);
DEC_CONSTS(WINDOWEVENT, -1);
DEC_CONSTS(WINDOWEVENT_CLOSE, -1);
DEC_CONSTS(WINDOWEVENT_MINIMIZED, -1);

DEC_CONSTS(CONTROLLERAXISMOTION, -1);
DEC_CONSTS(CONTROLLERBUTTONDOWN, -1);
Expand Down
1 change: 1 addition & 0 deletions src_py/locals.py
Expand Up @@ -542,4 +542,5 @@
'VIDEORESIZE',
'WINDOWEVENT',
'WINDOWEVENT_CLOSE',
'WINDOWEVENT_MINIMIZED',
]
6 changes: 3 additions & 3 deletions test/display_test.py
Expand Up @@ -259,7 +259,7 @@ def todo_test_gl_set_attribute(self):
# GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_STEREO

self.fail()

@unittest.skipIf(
os.environ.get("SDL_VIDEODRIVER") in ["dummy", "android"],
'iconify is only supported on some video drivers/platforms'
Expand All @@ -279,7 +279,7 @@ def test_iconify(self):
for event in pygame.event.get():
if SDL2:
if (event.type == pygame.WINDOWEVENT and
event.event == 7): # should be WINDOWEVENT_MINIMIZED
event.event == pygame.WINDOWEVENT_MINIMIZED):
minimized_event = True

if SDL2:
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_set_gamma(self):
gammas = [(0.5,0.5,0.5),(1.0,1.0,1.0),(0.22,0.33,0.44),(0.0,0.0,0.0)]
for gammaTuple in gammas:
self.assertEqual(pygame.display.set_gamma(gammaTuple[0],gammaTuple[1],gammaTuple[2]),True)

@unittest.skipIf(
not hasattr(pygame.display,"set_gamma_ramp"),
"Not all systems and hardware support gamma ramps"
Expand Down