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

Port video.Window to C #2114

Merged
merged 40 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
33034cf
Squashed commit of the following:
yunline Apr 12, 2023
ab107cf
properties
yunline Apr 12, 2023
ef0c00d
docs & format
yunline Apr 12, 2023
df7c41c
fix warning
yunline Apr 12, 2023
fbb9c56
fix warning
yunline Apr 12, 2023
e0d464c
update gen_stubs.py
yunline Apr 17, 2023
de0a8a7
rerun gen_stub.py
yunline Apr 18, 2023
5e8fe0b
adapt to video.Renderer
yunline Apr 27, 2023
e563c39
Merge branch 'main' into port-window
yunline Apr 27, 2023
927536c
update docs
yunline Apr 27, 2023
073b482
update tests
yunline Apr 27, 2023
449bc1e
simulate the behavior of video.Window
yunline Apr 28, 2023
b5b87a3
add `PyObject *_null`
yunline May 12, 2023
8c04ca9
Use Py_BuildValue, add error check
yunline May 12, 2023
4300f57
cast float to double
yunline May 12, 2023
f49951b
fix setters.
yunline May 12, 2023
d3d8845
pygame.window -> pygame._window
yunline May 14, 2023
5116f40
change video docs back
yunline May 16, 2023
acbcfde
change tests back
yunline May 16, 2023
300da75
Add newline an the end of files
yunline May 16, 2023
4e0b727
Modify stubs
yunline May 16, 2023
a090c56
remove window docs use video docs
yunline May 16, 2023
d26cf9b
remove 'window'from elements.html
yunline May 16, 2023
5c5eb61
Merge branch 'main' into port-window
yunline May 17, 2023
2f567da
Merge branch 'main' into port-window
yunline May 22, 2023
a2c7c3e
remove WindowType and SDL_syswm.h
yunline May 22, 2023
7b07a4a
use DOC_SDL2_VIDEO_GETGRABBEDWINDOW doc string
yunline May 22, 2023
9812a1f
Use PyLong_Check
yunline May 22, 2023
32dde23
remove comma
yunline May 22, 2023
fcec13f
use Py_TYPE(self)->tp_free(self);
yunline May 23, 2023
cbcc72e
destroy window when dealloc
yunline May 23, 2023
a6b97e0
fix `from_display_module()`
yunline May 23, 2023
b271db2
stub fix
yunline May 23, 2023
768c1fe
Add relativemouse back
yunline May 23, 2023
14ff36e
fix stub
yunline May 27, 2023
07b6822
Merge branch 'main' into port-window
yunline May 28, 2023
1bc30cb
Remove _window from default imports
yunline May 29, 2023
397e51f
use PyErr_Format instead of sprintf
yunline May 29, 2023
ae11dfb
add icon when opening a window
yunline Jun 1, 2023
f1d5abd
fix CI warning
yunline Jun 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildconfig/Setup.Emscripten.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ surflock src_c/void.c
rect src_c/void.c
rwobject src_c/void.c
system src_c/void.c
_window src_c/void.c

#_sdl2.controller src_c/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc_c
_sdl2.controller_old src_c/void.c
Expand Down
1 change: 1 addition & 0 deletions buildconfig/Setup.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ math src_c/math.c $(SDL) $(DEBUG)
pixelcopy src_c/pixelcopy.c $(SDL) $(DEBUG)
newbuffer src_c/newbuffer.c $(SDL) $(DEBUG)
system src_c/system.c $(SDL) $(DEBUG)
_window src_c/window.c $(SDL) $(DEBUG)
2 changes: 1 addition & 1 deletion buildconfig/stubs/gen_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"font": ["Font"],
"mixer": ["Channel"],
"time": ["Clock"],
"joystick": ["Joystick"]
"joystick": ["Joystick"],
}

# pygame modules from which __init__.py does the equivalent of
Expand Down
2 changes: 2 additions & 0 deletions buildconfig/stubs/pygame/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ from .constants import (
WINDOWMAXIMIZED as WINDOWMAXIMIZED,
WINDOWMINIMIZED as WINDOWMINIMIZED,
WINDOWMOVED as WINDOWMOVED,
WINDOWPOS_CENTERED as WINDOWPOS_CENTERED,
WINDOWPOS_UNDEFINED as WINDOWPOS_UNDEFINED,
WINDOWRESIZED as WINDOWRESIZED,
WINDOWRESTORED as WINDOWRESTORED,
WINDOWSHOWN as WINDOWSHOWN,
Expand Down
9 changes: 6 additions & 3 deletions buildconfig/stubs/pygame/_sdl2/video.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Generator, Iterable, Optional, Tuple, Union
from typing import Any, Generator, Iterable, Optional, Tuple, Union, final

from pygame.color import Color
from pygame.rect import Rect
Expand Down Expand Up @@ -38,6 +38,7 @@ def messagebox(
escape_button: int = 0,
) -> int: ...

@final
class Window:
DEFAULT_SIZE: Tuple[Literal[640], Literal[480]]
def __init__(
Expand Down Expand Up @@ -73,6 +74,8 @@ class Window:
display_index: int
def set_modal_for(self, Window) -> None: ...

_Window = Window

class Texture:
def __init__(
self,
Expand Down Expand Up @@ -153,14 +156,14 @@ class Image:
class Renderer:
def __init__(
self,
window: Window,
window: Union[Window,_Window],
index: int = -1,
accelerated: int = -1,
vsync: bool = False,
target_texture: bool = False,
) -> None: ...
@classmethod
def from_window(cls, window: Window) -> Renderer: ...
def from_window(cls, window: Union[Window,_Window]) -> Renderer: ...
draw_blend_mode: int
draw_color: Color
def clear(self) -> None: ...
Expand Down
1 change: 1 addition & 0 deletions buildconfig/stubs/pygame/_sdl2/window.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from pygame._sdl2.video import _Window as Window
38 changes: 38 additions & 0 deletions buildconfig/stubs/pygame/_window.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from typing import Iterable, Optional, Tuple, Union, final
from pygame.surface import Surface
from ._common import RectValue
from pygame.locals import WINDOWPOS_UNDEFINED

def get_grabbed_window() -> Optional[Window]: ...
@final
class Window:
def __init__(
self,
title: str = "pygame window",
size: Iterable[int] = (640, 480),
position: Union[int, Iterable[int]] = WINDOWPOS_UNDEFINED,
**flags: bool
) -> None: ...
def destroy(self) -> None: ...
def set_windowed(self) -> None: ...
def set_fullscreen(self, desktop: bool = False) -> None: ...
def focus(self, input_only: bool = False) -> None: ...
def hide(self) -> None: ...
def show(self) -> None: ...
def restore(self) -> None: ...
def maximize(self) -> None: ...
def minimize(self) -> None: ...
def set_modal_for(self, parent: Window) -> None: ...
def set_icon(self, icon: Surface) -> None: ...
grab: bool
title: str
resizable: bool
borderless: bool
relative_mouse: bool
id: int
size: Iterable[int]
position: Union[int, Iterable[int]]
opacity: float
display_index: int
@classmethod
def from_display_module(cls) -> Window: ...
2 changes: 2 additions & 0 deletions buildconfig/stubs/pygame/constants.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ WINDOWLEAVE: int
WINDOWMAXIMIZED: int
WINDOWMINIMIZED: int
WINDOWMOVED: int
WINDOWPOS_CENTERED: int
WINDOWPOS_UNDEFINED: int
WINDOWRESIZED: int
WINDOWRESTORED: int
WINDOWSHOWN: int
Expand Down
2 changes: 2 additions & 0 deletions buildconfig/stubs/pygame/locals.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ WINDOWLEAVE: int
WINDOWMAXIMIZED: int
WINDOWMINIMIZED: int
WINDOWMOVED: int
WINDOWPOS_CENTERED: int
WINDOWPOS_UNDEFINED: int
WINDOWRESIZED: int
WINDOWRESTORED: int
WINDOWSHOWN: int
Expand Down
1 change: 1 addition & 0 deletions docs/reST/c_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pygame C API
c_api/surface.rst
c_api/surflock.rst
c_api/version.rst
c_api/window.rst


src_c/include/ contains header files for applications
Expand Down
30 changes: 30 additions & 0 deletions docs/reST/c_api/window.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. include:: ../common.txt

.. highlight:: c

************************************************
Class Window API exported by pygame.window
************************************************

src_c/window.c
===============

This extension module defines Python type :py:class:`pygame.Window`.

Header file: src_c/include/pygame.h


.. c:type:: pgWindowObject

A :py:class:`pygame.window.Window` instance.

.. c:var:: PyTypeObject *pgWindow_Type

The :py:class:`pygame.window.Window` Python type.

.. c:function:: int pgWindow_Check(PyObject *x)

Return true if *x* is a :py:class:`pygame.window.Window` instance

Will return false if *x* is not a subclass of `Window`.
This is a macro. No check is made that *x* is not *NULL*.
1 change: 1 addition & 0 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,6 @@ struct pgColorObject {
#define PYGAMEAPI_MATH_NUMSLOTS 2
#define PYGAMEAPI_BASE_NUMSLOTS 24
#define PYGAMEAPI_EVENT_NUMSLOTS 6
#define PYGAMEAPI_WINDOW_NUMSLOTS 1

#endif /* _PYGAME_INTERNAL_H */
Loading