pyglet 2.1.13__py3-none-any.whl → 3.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyglet/__init__.py +67 -61
- pyglet/__init__.pyi +15 -8
- pyglet/app/__init__.py +22 -13
- pyglet/app/async_app.py +212 -0
- pyglet/app/base.py +2 -1
- pyglet/app/{xlib.py → linux.py} +3 -3
- pyglet/config/__init__.py +101 -0
- pyglet/config/gl/__init__.py +30 -0
- pyglet/config/gl/egl.py +120 -0
- pyglet/config/gl/macos.py +262 -0
- pyglet/config/gl/windows.py +267 -0
- pyglet/config/gl/x11.py +142 -0
- pyglet/customtypes.py +43 -2
- pyglet/display/__init__.py +8 -6
- pyglet/display/base.py +3 -63
- pyglet/display/cocoa.py +12 -17
- pyglet/display/emscripten.py +39 -0
- pyglet/display/headless.py +23 -30
- pyglet/display/wayland.py +157 -0
- pyglet/display/win32.py +5 -21
- pyglet/display/xlib.py +19 -27
- pyglet/display/xlib_vidmoderestore.py +2 -2
- pyglet/enums.py +183 -0
- pyglet/event.py +0 -1
- pyglet/experimental/geoshader_sprite.py +15 -13
- pyglet/experimental/hidraw.py +6 -15
- pyglet/experimental/multitexture_sprite.py +31 -19
- pyglet/experimental/particles.py +13 -35
- pyglet/font/__init__.py +251 -85
- pyglet/font/base.py +116 -61
- pyglet/font/dwrite/__init__.py +349 -204
- pyglet/font/dwrite/dwrite_lib.py +27 -5
- pyglet/font/fontconfig.py +14 -6
- pyglet/font/freetype.py +138 -87
- pyglet/font/freetype_lib.py +19 -0
- pyglet/font/group.py +179 -0
- pyglet/font/harfbuzz/__init__.py +3 -3
- pyglet/font/pyodide_js.py +310 -0
- pyglet/font/quartz.py +319 -126
- pyglet/font/ttf.py +45 -3
- pyglet/font/user.py +14 -19
- pyglet/font/win32.py +45 -21
- pyglet/graphics/__init__.py +8 -787
- pyglet/graphics/allocation.py +115 -1
- pyglet/graphics/api/__init__.py +77 -0
- pyglet/graphics/api/base.py +299 -0
- pyglet/graphics/api/gl/__init__.py +58 -0
- pyglet/graphics/api/gl/base.py +24 -0
- pyglet/graphics/{vertexbuffer.py → api/gl/buffer.py} +104 -159
- pyglet/graphics/api/gl/cocoa/context.py +76 -0
- pyglet/graphics/api/gl/context.py +391 -0
- pyglet/graphics/api/gl/default_shaders.py +0 -0
- pyglet/graphics/api/gl/draw.py +627 -0
- pyglet/graphics/api/gl/egl/__init__.py +0 -0
- pyglet/graphics/api/gl/egl/context.py +92 -0
- pyglet/graphics/api/gl/enums.py +76 -0
- pyglet/graphics/api/gl/framebuffer.py +315 -0
- pyglet/graphics/api/gl/gl.py +5463 -0
- pyglet/graphics/api/gl/gl_info.py +188 -0
- pyglet/graphics/api/gl/global_opengl.py +226 -0
- pyglet/{gl → graphics/api/gl}/lib.py +34 -18
- pyglet/graphics/api/gl/shader.py +1476 -0
- pyglet/graphics/api/gl/shapes.py +55 -0
- pyglet/graphics/api/gl/sprite.py +102 -0
- pyglet/graphics/api/gl/state.py +219 -0
- pyglet/graphics/api/gl/text.py +190 -0
- pyglet/graphics/api/gl/texture.py +1526 -0
- pyglet/graphics/{vertexarray.py → api/gl/vertexarray.py} +11 -13
- pyglet/graphics/api/gl/vertexdomain.py +751 -0
- pyglet/graphics/api/gl/win32/__init__.py +0 -0
- pyglet/graphics/api/gl/win32/context.py +108 -0
- pyglet/graphics/api/gl/win32/wgl_info.py +24 -0
- pyglet/graphics/api/gl/xlib/__init__.py +0 -0
- pyglet/graphics/api/gl/xlib/context.py +174 -0
- pyglet/{gl → graphics/api/gl/xlib}/glx_info.py +26 -31
- pyglet/graphics/api/gl1/__init__.py +0 -0
- pyglet/{gl → graphics/api/gl1}/gl_compat.py +3 -2
- pyglet/graphics/api/gl2/__init__.py +0 -0
- pyglet/graphics/api/gl2/buffer.py +320 -0
- pyglet/graphics/api/gl2/draw.py +600 -0
- pyglet/graphics/api/gl2/global_opengl.py +122 -0
- pyglet/graphics/api/gl2/shader.py +200 -0
- pyglet/graphics/api/gl2/shapes.py +51 -0
- pyglet/graphics/api/gl2/sprite.py +79 -0
- pyglet/graphics/api/gl2/text.py +175 -0
- pyglet/graphics/api/gl2/vertexdomain.py +364 -0
- pyglet/graphics/api/webgl/__init__.py +233 -0
- pyglet/graphics/api/webgl/buffer.py +302 -0
- pyglet/graphics/api/webgl/context.py +234 -0
- pyglet/graphics/api/webgl/draw.py +590 -0
- pyglet/graphics/api/webgl/enums.py +76 -0
- pyglet/graphics/api/webgl/framebuffer.py +360 -0
- pyglet/graphics/api/webgl/gl.py +1537 -0
- pyglet/graphics/api/webgl/gl_info.py +130 -0
- pyglet/graphics/api/webgl/shader.py +1346 -0
- pyglet/graphics/api/webgl/shapes.py +92 -0
- pyglet/graphics/api/webgl/sprite.py +102 -0
- pyglet/graphics/api/webgl/state.py +227 -0
- pyglet/graphics/api/webgl/text.py +187 -0
- pyglet/graphics/api/webgl/texture.py +1227 -0
- pyglet/graphics/api/webgl/vertexarray.py +54 -0
- pyglet/graphics/api/webgl/vertexdomain.py +616 -0
- pyglet/graphics/api/webgl/webgl_js.pyi +307 -0
- pyglet/{image → graphics}/atlas.py +33 -32
- pyglet/graphics/base.py +10 -0
- pyglet/graphics/buffer.py +245 -0
- pyglet/graphics/draw.py +578 -0
- pyglet/graphics/framebuffer.py +26 -0
- pyglet/graphics/instance.py +178 -69
- pyglet/graphics/shader.py +267 -1553
- pyglet/graphics/state.py +83 -0
- pyglet/graphics/texture.py +703 -0
- pyglet/graphics/vertexdomain.py +695 -538
- pyglet/gui/ninepatch.py +10 -10
- pyglet/gui/widgets.py +120 -10
- pyglet/image/__init__.py +20 -1973
- pyglet/image/animation.py +12 -12
- pyglet/image/base.py +730 -0
- pyglet/image/codecs/__init__.py +9 -0
- pyglet/image/codecs/bmp.py +53 -30
- pyglet/image/codecs/dds.py +53 -31
- pyglet/image/codecs/gdiplus.py +38 -14
- pyglet/image/codecs/gdkpixbuf2.py +0 -2
- pyglet/image/codecs/js_image.py +99 -0
- pyglet/image/codecs/ktx2.py +161 -0
- pyglet/image/codecs/pil.py +1 -1
- pyglet/image/codecs/png.py +1 -1
- pyglet/image/codecs/wic.py +11 -2
- pyglet/info.py +26 -24
- pyglet/input/__init__.py +8 -0
- pyglet/input/base.py +163 -105
- pyglet/input/controller.py +13 -19
- pyglet/input/controller_db.py +39 -24
- pyglet/input/emscripten/__init__.py +18 -0
- pyglet/input/emscripten/gamepad_js.py +397 -0
- pyglet/input/linux/__init__.py +11 -5
- pyglet/input/linux/evdev.py +10 -11
- pyglet/input/linux/x11_xinput.py +2 -2
- pyglet/input/linux/x11_xinput_tablet.py +1 -1
- pyglet/input/macos/__init__.py +7 -2
- pyglet/input/macos/darwin_gc.py +559 -0
- pyglet/input/win32/__init__.py +1 -1
- pyglet/input/win32/directinput.py +34 -29
- pyglet/input/win32/xinput.py +11 -61
- pyglet/lib.py +3 -3
- pyglet/libs/__init__.py +1 -1
- pyglet/{gl → libs/darwin}/agl.py +1 -1
- pyglet/libs/darwin/cocoapy/__init__.py +2 -2
- pyglet/libs/darwin/cocoapy/cocoahelpers.py +181 -0
- pyglet/libs/darwin/cocoapy/cocoalibs.py +31 -0
- pyglet/libs/darwin/cocoapy/cocoatypes.py +27 -0
- pyglet/libs/darwin/cocoapy/runtime.py +81 -45
- pyglet/libs/darwin/coreaudio.py +4 -4
- pyglet/{gl → libs/darwin}/lib_agl.py +9 -8
- pyglet/libs/darwin/quartzkey.py +1 -3
- pyglet/libs/egl/__init__.py +2 -0
- pyglet/libs/egl/egl_lib.py +576 -0
- pyglet/libs/egl/eglext.py +51 -5
- pyglet/libs/linux/__init__.py +0 -0
- pyglet/libs/linux/egl/__init__.py +0 -0
- pyglet/libs/linux/egl/eglext.py +22 -0
- pyglet/libs/linux/glx/__init__.py +0 -0
- pyglet/{gl → libs/linux/glx}/glx.py +13 -14
- pyglet/{gl → libs/linux/glx}/glxext_arb.py +408 -192
- pyglet/{gl → libs/linux/glx}/glxext_mesa.py +1 -1
- pyglet/{gl → libs/linux/glx}/glxext_nv.py +345 -164
- pyglet/{gl → libs/linux/glx}/lib_glx.py +3 -2
- pyglet/libs/linux/wayland/__init__.py +0 -0
- pyglet/libs/linux/wayland/client.py +1068 -0
- pyglet/libs/linux/wayland/lib_wayland.py +207 -0
- pyglet/libs/linux/wayland/wayland_egl.py +38 -0
- pyglet/libs/{wayland → linux/wayland}/xkbcommon.py +26 -0
- pyglet/libs/{x11 → linux/x11}/xf86vmode.py +4 -4
- pyglet/libs/{x11 → linux/x11}/xinerama.py +2 -2
- pyglet/libs/{x11 → linux/x11}/xinput.py +10 -10
- pyglet/libs/linux/x11/xrandr.py +0 -0
- pyglet/libs/{x11 → linux/x11}/xrender.py +1 -1
- pyglet/libs/shared/__init__.py +0 -0
- pyglet/libs/shared/spirv/__init__.py +0 -0
- pyglet/libs/shared/spirv/lib_shaderc.py +85 -0
- pyglet/libs/shared/spirv/lib_spirv_cross.py +126 -0
- pyglet/libs/win32/__init__.py +28 -8
- pyglet/libs/win32/constants.py +59 -48
- pyglet/libs/win32/context_managers.py +20 -3
- pyglet/libs/win32/dinput.py +105 -88
- pyglet/{gl → libs/win32}/lib_wgl.py +52 -26
- pyglet/libs/win32/types.py +58 -23
- pyglet/{gl → libs/win32}/wgl.py +32 -25
- pyglet/{gl → libs/win32}/wglext_arb.py +364 -2
- pyglet/media/__init__.py +9 -10
- pyglet/media/codecs/__init__.py +12 -1
- pyglet/media/codecs/base.py +99 -96
- pyglet/media/codecs/ffmpeg.py +2 -2
- pyglet/media/codecs/ffmpeg_lib/libavformat.py +3 -8
- pyglet/media/codecs/webaudio_pyodide.py +111 -0
- pyglet/media/drivers/__init__.py +9 -4
- pyglet/media/drivers/base.py +4 -4
- pyglet/media/drivers/openal/__init__.py +1 -1
- pyglet/media/drivers/openal/adaptation.py +3 -3
- pyglet/media/drivers/pulse/__init__.py +1 -1
- pyglet/media/drivers/pulse/adaptation.py +3 -3
- pyglet/media/drivers/pyodide_js/__init__.py +8 -0
- pyglet/media/drivers/pyodide_js/adaptation.py +288 -0
- pyglet/media/drivers/xaudio2/adaptation.py +3 -3
- pyglet/media/player.py +276 -193
- pyglet/media/player_worker_thread.py +1 -1
- pyglet/model/__init__.py +39 -29
- pyglet/model/codecs/base.py +4 -4
- pyglet/model/codecs/gltf.py +3 -3
- pyglet/model/codecs/obj.py +71 -43
- pyglet/resource.py +129 -78
- pyglet/shapes.py +154 -194
- pyglet/sprite.py +47 -164
- pyglet/text/__init__.py +44 -54
- pyglet/text/caret.py +12 -7
- pyglet/text/document.py +19 -17
- pyglet/text/formats/html.py +2 -2
- pyglet/text/formats/structured.py +10 -40
- pyglet/text/layout/__init__.py +20 -13
- pyglet/text/layout/base.py +176 -287
- pyglet/text/layout/incremental.py +9 -10
- pyglet/text/layout/scrolling.py +7 -95
- pyglet/window/__init__.py +183 -172
- pyglet/window/cocoa/__init__.py +62 -51
- pyglet/window/cocoa/pyglet_delegate.py +2 -25
- pyglet/window/cocoa/pyglet_view.py +9 -8
- pyglet/window/dialog/__init__.py +184 -0
- pyglet/window/dialog/base.py +99 -0
- pyglet/window/dialog/darwin.py +121 -0
- pyglet/window/dialog/linux.py +72 -0
- pyglet/window/dialog/windows.py +194 -0
- pyglet/window/emscripten/__init__.py +779 -0
- pyglet/window/headless/__init__.py +44 -28
- pyglet/window/key.py +2 -0
- pyglet/window/mouse.py +2 -2
- pyglet/window/wayland/__init__.py +377 -0
- pyglet/window/win32/__init__.py +101 -46
- pyglet/window/xlib/__init__.py +104 -66
- {pyglet-2.1.13.dist-info → pyglet-3.0.dev1.dist-info}/METADATA +2 -3
- pyglet-3.0.dev1.dist-info/RECORD +322 -0
- {pyglet-2.1.13.dist-info → pyglet-3.0.dev1.dist-info}/WHEEL +1 -1
- pyglet/gl/__init__.py +0 -208
- pyglet/gl/base.py +0 -499
- pyglet/gl/cocoa.py +0 -309
- pyglet/gl/gl.py +0 -4625
- pyglet/gl/gl.pyi +0 -2320
- pyglet/gl/gl_compat.pyi +0 -3097
- pyglet/gl/gl_info.py +0 -190
- pyglet/gl/headless.py +0 -166
- pyglet/gl/wgl_info.py +0 -36
- pyglet/gl/wglext_nv.py +0 -1096
- pyglet/gl/win32.py +0 -268
- pyglet/gl/xlib.py +0 -295
- pyglet/image/buffer.py +0 -274
- pyglet/image/codecs/s3tc.py +0 -354
- pyglet/libs/x11/xrandr.py +0 -166
- pyglet-2.1.13.dist-info/RECORD +0 -234
- /pyglet/{libs/wayland → graphics/api/gl/cocoa}/__init__.py +0 -0
- /pyglet/libs/{egl → linux/egl}/egl.py +0 -0
- /pyglet/libs/{egl → linux/egl}/lib.py +0 -0
- /pyglet/libs/{ioctl.py → linux/ioctl.py} +0 -0
- /pyglet/libs/{wayland → linux/wayland}/gbm.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/__init__.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/cursorfont.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xlib.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xsync.py +0 -0
- {pyglet-2.1.13.dist-info/licenses → pyglet-3.0.dev1.dist-info}/LICENSE +0 -0
pyglet/window/xlib/__init__.py
CHANGED
|
@@ -23,14 +23,16 @@ from ctypes import (
|
|
|
23
23
|
pointer,
|
|
24
24
|
sizeof,
|
|
25
25
|
string_at,
|
|
26
|
+
c_float,
|
|
26
27
|
)
|
|
27
28
|
from functools import lru_cache
|
|
28
29
|
from typing import TYPE_CHECKING, Sequence
|
|
29
30
|
|
|
30
31
|
import pyglet
|
|
31
|
-
from pyglet.display.xlib import
|
|
32
|
+
from pyglet.display.xlib import XlibScreenXinerama
|
|
32
33
|
from pyglet.event import EventDispatcher
|
|
33
|
-
from pyglet.libs.x11 import cursorfont, xlib
|
|
34
|
+
from pyglet.libs.linux.x11 import cursorfont, xlib
|
|
35
|
+
from pyglet.libs.linux.x11.xrender import XRenderFindVisualFormat
|
|
34
36
|
from pyglet.util import asbytes
|
|
35
37
|
from pyglet.window import (
|
|
36
38
|
BaseWindow,
|
|
@@ -46,17 +48,18 @@ from pyglet.window import (
|
|
|
46
48
|
)
|
|
47
49
|
|
|
48
50
|
if TYPE_CHECKING:
|
|
51
|
+
from pyglet.config.gl.x11 import XlibGLSurfaceConfig
|
|
52
|
+
from pyglet.libs.linux.x11.xlib import Visual
|
|
49
53
|
from _ctypes import _Pointer
|
|
50
|
-
from pyglet.gl.xlib import XlibDisplayConfig
|
|
51
54
|
|
|
52
55
|
try:
|
|
53
|
-
from pyglet.libs.x11 import xsync
|
|
56
|
+
from pyglet.libs.linux.x11 import xsync
|
|
54
57
|
|
|
55
58
|
_have_xsync = True
|
|
56
59
|
except ImportError:
|
|
57
60
|
_have_xsync = False
|
|
58
61
|
|
|
59
|
-
_debug = pyglet.options
|
|
62
|
+
_debug = pyglet.options.debug_x11
|
|
60
63
|
|
|
61
64
|
|
|
62
65
|
class mwmhints_t(Structure):
|
|
@@ -111,7 +114,7 @@ class XlibException(WindowException):
|
|
|
111
114
|
|
|
112
115
|
|
|
113
116
|
class XlibMouseCursor(MouseCursor):
|
|
114
|
-
|
|
117
|
+
api_drawable: bool = False
|
|
115
118
|
hw_drawable: bool = True
|
|
116
119
|
|
|
117
120
|
def __init__(self, cursor: xlib.Cursor) -> None:
|
|
@@ -124,7 +127,7 @@ ViewEventHandler = _ViewEventHandler
|
|
|
124
127
|
|
|
125
128
|
|
|
126
129
|
class XlibWindow(BaseWindow):
|
|
127
|
-
config:
|
|
130
|
+
config: XlibGLSurfaceConfig
|
|
128
131
|
_x_display: xlib.Display | None = None # X display connection
|
|
129
132
|
_x_screen_id: int | None = None # X screen index
|
|
130
133
|
_x_ic: xlib.XIC | None = None # X input context
|
|
@@ -191,7 +194,7 @@ class XlibWindow(BaseWindow):
|
|
|
191
194
|
self.context.detach()
|
|
192
195
|
xlib.XDestroyWindow(self._x_display, self._window)
|
|
193
196
|
del self.display._window_map[self._window] # noqa: SLF001
|
|
194
|
-
del self.display._window_map[self.
|
|
197
|
+
del self.display._window_map[self._x_window] # noqa: SLF001
|
|
195
198
|
self._window = None
|
|
196
199
|
self._mapped = False
|
|
197
200
|
|
|
@@ -224,23 +227,36 @@ class XlibWindow(BaseWindow):
|
|
|
224
227
|
self._x_display = self.display._display # noqa: SLF001
|
|
225
228
|
self._x_screen_id = self.display.x_screen
|
|
226
229
|
|
|
230
|
+
self._is_transparent = False
|
|
231
|
+
|
|
227
232
|
# Create X window if not already existing.
|
|
228
233
|
if not self._window:
|
|
229
234
|
root = xlib.XRootWindow(self._x_display, self._x_screen_id)
|
|
230
235
|
|
|
231
|
-
|
|
236
|
+
# In OpenGL, it requires you to query GLX for the visual info.
|
|
237
|
+
if pyglet.options.backend is not None and not self._shadow:
|
|
238
|
+
if "gl" in pyglet.options.backend:
|
|
239
|
+
self._assign_config()
|
|
232
240
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
visual_info = self.config.get_visual_info()
|
|
242
|
+
|
|
243
|
+
visual = visual_info.visual
|
|
244
|
+
depth = visual_info.depth
|
|
245
|
+
|
|
246
|
+
# Vulkan just uses the default visual ID
|
|
247
|
+
elif pyglet.options.backend == "vulkan":
|
|
248
|
+
visual = xlib.XDefaultVisual(self._x_display, self._x_screen_id)
|
|
249
|
+
depth = xlib.XDefaultDepth(self._x_display, self._x_screen_id)
|
|
250
|
+
else:
|
|
251
|
+
msg = f"{pyglet.options.backend} Backend not supported."
|
|
252
|
+
raise Exception(msg)
|
|
241
253
|
else:
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
visual = xlib.XDefaultVisual(self._x_display, self._x_screen_id)
|
|
255
|
+
depth = xlib.XDefaultDepth(self._x_display, self._x_screen_id)
|
|
256
|
+
|
|
257
|
+
window_attributes = xlib.XSetWindowAttributes()
|
|
258
|
+
window_attributes.colormap = xlib.XCreateColormap(self._x_display, root,
|
|
259
|
+
visual, xlib.AllocNone)
|
|
244
260
|
window_attributes.bit_gravity = xlib.StaticGravity
|
|
245
261
|
|
|
246
262
|
# Issue 287: Compiz on Intel/Mesa doesn't draw window decoration
|
|
@@ -264,36 +280,42 @@ class XlibWindow(BaseWindow):
|
|
|
264
280
|
else:
|
|
265
281
|
width, height = self._width, self._height
|
|
266
282
|
self._view_x = self._view_y = 0
|
|
267
|
-
if pyglet.options.dpi_scaling
|
|
283
|
+
if pyglet.options.dpi_scaling == "stretch":
|
|
268
284
|
w, h = self.get_requested_size()
|
|
269
285
|
self._width = width = int(w * self.scale)
|
|
270
286
|
self._height = height = int(h * self.scale)
|
|
271
287
|
|
|
272
288
|
self._window = xlib.XCreateWindow(self._x_display, root,
|
|
273
|
-
0, 0, width, height, 0,
|
|
289
|
+
0, 0, width, height, 0, depth,
|
|
274
290
|
xlib.InputOutput, visual, mask,
|
|
275
291
|
byref(window_attributes))
|
|
276
|
-
self.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
xlib.XMapWindow(self._x_display, self.
|
|
282
|
-
xlib.XSelectInput(self._x_display, self.
|
|
292
|
+
self._x_window = xlib.XCreateWindow(self._x_display,
|
|
293
|
+
self._window, self._view_x, self._view_y,
|
|
294
|
+
self._width, self._height, 0, depth,
|
|
295
|
+
xlib.InputOutput, visual, mask,
|
|
296
|
+
byref(window_attributes))
|
|
297
|
+
xlib.XMapWindow(self._x_display, self._x_window)
|
|
298
|
+
xlib.XSelectInput(self._x_display, self._x_window, self._default_event_mask)
|
|
283
299
|
|
|
284
300
|
self.display._window_map[self._window] = self.dispatch_platform_event # noqa: SLF001
|
|
285
|
-
self.display._window_map[self.
|
|
301
|
+
self.display._window_map[self._x_window] = self.dispatch_platform_event_view # noqa: SLF001
|
|
286
302
|
|
|
287
|
-
|
|
303
|
+
# Vulkan surface needs to be created after the window. Possibly move surface creation to context.attach.
|
|
304
|
+
if pyglet.options.backend == "vulkan" and not self._shadow:
|
|
305
|
+
self._assign_config()
|
|
288
306
|
|
|
289
|
-
self.context
|
|
290
|
-
|
|
307
|
+
if self.context:
|
|
308
|
+
self.context.attach(self)
|
|
309
|
+
self.context.set_vsync(self._vsync) # XXX ?VulkanWindowConfig
|
|
291
310
|
|
|
292
|
-
|
|
311
|
+
self._enable_xsync = self.display._enable_xsync and self.config.double_buffer
|
|
312
|
+
else:
|
|
313
|
+
self._enable_xsync = False
|
|
293
314
|
|
|
294
315
|
# Set supported protocols
|
|
295
316
|
protocols = list()
|
|
296
317
|
protocols.append(xlib.XInternAtom(self._x_display, asbytes('WM_DELETE_WINDOW'), False))
|
|
318
|
+
|
|
297
319
|
if self._enable_xsync:
|
|
298
320
|
protocols.append(xlib.XInternAtom(self._x_display,
|
|
299
321
|
asbytes('_NET_WM_SYNC_REQUEST'),
|
|
@@ -310,14 +332,19 @@ class XlibWindow(BaseWindow):
|
|
|
310
332
|
if self._enable_xsync:
|
|
311
333
|
value = xsync.XSyncValue()
|
|
312
334
|
self._sync_counter = xlib.XID(xsync.XSyncCreateCounter(self._x_display, value))
|
|
313
|
-
atom = xlib.XInternAtom(self._x_display,
|
|
314
|
-
asbytes('_NET_WM_SYNC_REQUEST_COUNTER'), False)
|
|
335
|
+
atom = xlib.XInternAtom(self._x_display, asbytes('_NET_WM_SYNC_REQUEST_COUNTER'), False)
|
|
315
336
|
ptr = pointer(self._sync_counter)
|
|
316
337
|
|
|
317
|
-
xlib.XChangeProperty(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
338
|
+
xlib.XChangeProperty(
|
|
339
|
+
self._x_display,
|
|
340
|
+
self._window,
|
|
341
|
+
atom,
|
|
342
|
+
XA_CARDINAL,
|
|
343
|
+
32,
|
|
344
|
+
xlib.PropModeReplace,
|
|
345
|
+
cast(ptr, POINTER(c_ubyte)),
|
|
346
|
+
1,
|
|
347
|
+
)
|
|
321
348
|
|
|
322
349
|
# Atoms required for Xdnd
|
|
323
350
|
self._create_xdnd_atoms(self._x_display)
|
|
@@ -435,10 +462,17 @@ class XlibWindow(BaseWindow):
|
|
|
435
462
|
if self._visible:
|
|
436
463
|
self.set_visible(True)
|
|
437
464
|
|
|
438
|
-
self.
|
|
465
|
+
self.set_mouse_cursor_platform_visible()
|
|
439
466
|
self._applied_mouse_exclusive = None
|
|
440
467
|
self._update_exclusivity()
|
|
441
468
|
|
|
469
|
+
def _is_visual_transparent(self, visual: _Pointer[Visual]) -> bool:
|
|
470
|
+
if not XRenderFindVisualFormat:
|
|
471
|
+
return False
|
|
472
|
+
|
|
473
|
+
xrender_format = XRenderFindVisualFormat(self._x_display, visual)
|
|
474
|
+
return xrender_format and xrender_format.contents.direct.alphaMask != 0
|
|
475
|
+
|
|
442
476
|
def set_mouse_passthrough(self, state: bool) -> None:
|
|
443
477
|
"""Sets the clickable area in the application to an empty region if enabled."""
|
|
444
478
|
if state:
|
|
@@ -509,13 +543,14 @@ class XlibWindow(BaseWindow):
|
|
|
509
543
|
if not self._window:
|
|
510
544
|
return
|
|
511
545
|
|
|
512
|
-
self.context
|
|
546
|
+
if self.context:
|
|
547
|
+
self.context.destroy()
|
|
513
548
|
self._unmap()
|
|
514
549
|
if self._window:
|
|
515
550
|
xlib.XDestroyWindow(self._x_display, self._window)
|
|
516
551
|
|
|
517
552
|
del self.display._window_map[self._window] # noqa: SLF001
|
|
518
|
-
del self.display._window_map[self.
|
|
553
|
+
del self.display._window_map[self._x_window]
|
|
519
554
|
self._window = None
|
|
520
555
|
|
|
521
556
|
self._view_event_handlers.clear()
|
|
@@ -531,18 +566,22 @@ class XlibWindow(BaseWindow):
|
|
|
531
566
|
if self.context:
|
|
532
567
|
self.context.set_current()
|
|
533
568
|
|
|
569
|
+
def before_draw(self) -> None:
|
|
570
|
+
if self.context:
|
|
571
|
+
self.context.before_draw()
|
|
572
|
+
|
|
534
573
|
def flip(self):
|
|
535
574
|
self.draw_mouse_cursor()
|
|
536
575
|
|
|
537
|
-
# TODO
|
|
576
|
+
# TODO window.flip?
|
|
538
577
|
if self.context:
|
|
539
578
|
self.context.flip()
|
|
540
579
|
|
|
541
580
|
self._sync_resize()
|
|
542
581
|
|
|
543
582
|
def set_vsync(self, vsync: bool) -> None:
|
|
544
|
-
if pyglet.options
|
|
545
|
-
vsync = pyglet.options
|
|
583
|
+
if pyglet.options.vsync is not None:
|
|
584
|
+
vsync = pyglet.options.vsync
|
|
546
585
|
|
|
547
586
|
super().set_vsync(vsync)
|
|
548
587
|
self.context.set_vsync(vsync)
|
|
@@ -582,7 +621,7 @@ class XlibWindow(BaseWindow):
|
|
|
582
621
|
self.dispatch_event('_on_internal_resize', width, height)
|
|
583
622
|
|
|
584
623
|
def _update_view_size(self) -> None:
|
|
585
|
-
xlib.XResizeWindow(self._x_display, self.
|
|
624
|
+
xlib.XResizeWindow(self._x_display, self._x_window, self._width, self._height)
|
|
586
625
|
|
|
587
626
|
def set_location(self, x: int, y: int) -> None:
|
|
588
627
|
if self._is_reparented():
|
|
@@ -669,7 +708,7 @@ class XlibWindow(BaseWindow):
|
|
|
669
708
|
width = texture.width
|
|
670
709
|
height = texture.height
|
|
671
710
|
|
|
672
|
-
alpha_luma_bytes = texture.get_image_data().
|
|
711
|
+
alpha_luma_bytes = texture.get_image_data().get_bytes('AL', -width * 2)
|
|
673
712
|
mask_data = self._downsample_1bit(alpha_luma_bytes[0::2])
|
|
674
713
|
bmp_data = self._downsample_1bit(alpha_luma_bytes[1::2])
|
|
675
714
|
|
|
@@ -687,11 +726,11 @@ class XlibWindow(BaseWindow):
|
|
|
687
726
|
|
|
688
727
|
return cursor
|
|
689
728
|
|
|
690
|
-
def
|
|
729
|
+
def set_mouse_cursor_platform_visible(self, platform_visible: bool | None = None) -> None:
|
|
691
730
|
if not self._window:
|
|
692
731
|
return
|
|
693
732
|
if platform_visible is None:
|
|
694
|
-
platform_visible = self._mouse_visible and not self._mouse_cursor.
|
|
733
|
+
platform_visible = self._mouse_visible and not self._mouse_cursor.api_drawable
|
|
695
734
|
|
|
696
735
|
if platform_visible is False:
|
|
697
736
|
# Hide pointer by creating an empty cursor:
|
|
@@ -726,7 +765,7 @@ class XlibWindow(BaseWindow):
|
|
|
726
765
|
|
|
727
766
|
if mouse_exclusive != self._applied_mouse_exclusive:
|
|
728
767
|
if mouse_exclusive:
|
|
729
|
-
self.
|
|
768
|
+
self.set_mouse_cursor_platform_visible(False)
|
|
730
769
|
|
|
731
770
|
# Restrict to client area
|
|
732
771
|
xlib.XGrabPointer(self._x_display, self._window,
|
|
@@ -743,28 +782,28 @@ class XlibWindow(BaseWindow):
|
|
|
743
782
|
y = self._height // 2
|
|
744
783
|
self._mouse_exclusive_client = x, y
|
|
745
784
|
self.set_mouse_position(x, y)
|
|
746
|
-
elif self._fullscreen:
|
|
785
|
+
elif self._fullscreen:
|
|
747
786
|
if isinstance(self.screen, XlibScreenXinerama) and self.screen._xinerama:
|
|
748
787
|
return
|
|
749
788
|
|
|
750
789
|
# Restrict to fullscreen area (prevent viewport scrolling)
|
|
751
790
|
self.set_mouse_position(0, 0)
|
|
752
|
-
r = xlib.XGrabPointer(self._x_display, self.
|
|
791
|
+
r = xlib.XGrabPointer(self._x_display, self._x_window,
|
|
753
792
|
True, 0,
|
|
754
793
|
xlib.GrabModeAsync,
|
|
755
794
|
xlib.GrabModeAsync,
|
|
756
|
-
self.
|
|
795
|
+
self._x_window,
|
|
757
796
|
0,
|
|
758
797
|
xlib.CurrentTime)
|
|
759
798
|
if r:
|
|
760
799
|
# Failed to grab, try again later
|
|
761
800
|
self._applied_mouse_exclusive = None
|
|
762
801
|
return
|
|
763
|
-
self.
|
|
802
|
+
self.set_mouse_cursor_platform_visible()
|
|
764
803
|
else:
|
|
765
804
|
# Unclip
|
|
766
805
|
xlib.XUngrabPointer(self._x_display, xlib.CurrentTime)
|
|
767
|
-
self.
|
|
806
|
+
self.set_mouse_cursor_platform_visible()
|
|
768
807
|
|
|
769
808
|
self._applied_mouse_exclusive = mouse_exclusive
|
|
770
809
|
|
|
@@ -845,7 +884,7 @@ class XlibWindow(BaseWindow):
|
|
|
845
884
|
pitch = -(image.width * len(fmt))
|
|
846
885
|
s = c_buffer(sizeof(c_ulong) * 2)
|
|
847
886
|
memmove(s, cast((c_ulong * 2)(image.width, image.height), POINTER(c_ubyte)), len(s))
|
|
848
|
-
data += s.raw + image.
|
|
887
|
+
data += s.raw + image.get_bytes(fmt, pitch)
|
|
849
888
|
buffer = (c_ubyte * len(data))()
|
|
850
889
|
memmove(buffer, data, len(data))
|
|
851
890
|
atom = xlib.XInternAtom(self._x_display, asbytes('_NET_WM_ICON'), False)
|
|
@@ -960,7 +999,7 @@ class XlibWindow(BaseWindow):
|
|
|
960
999
|
name_atom = xlib.XInternAtom(self._x_display, asbytes(name), False)
|
|
961
1000
|
atoms = [xlib.XInternAtom(self._x_display, asbytes(value), False) for value in values]
|
|
962
1001
|
atom_type = xlib.XInternAtom(self._x_display, asbytes('ATOM'), False)
|
|
963
|
-
if
|
|
1002
|
+
if atoms:
|
|
964
1003
|
atoms_ar = (xlib.Atom * len(atoms))(*atoms)
|
|
965
1004
|
xlib.XChangeProperty(self._x_display, self._window,
|
|
966
1005
|
name_atom, atom_type, 32, mode,
|
|
@@ -975,7 +1014,7 @@ class XlibWindow(BaseWindow):
|
|
|
975
1014
|
net_wm_state = xlib.XInternAtom(self._x_display, asbytes('_NET_WM_STATE'), False)
|
|
976
1015
|
atoms = [xlib.XInternAtom(self._x_display, asbytes(state), False) for state in states]
|
|
977
1016
|
atom_type = xlib.XInternAtom(self._x_display, asbytes('ATOM'), False)
|
|
978
|
-
if
|
|
1017
|
+
if atoms:
|
|
979
1018
|
atoms_ar = (xlib.Atom * len(atoms))(*atoms)
|
|
980
1019
|
xlib.XChangeProperty(self._x_display, self._window,
|
|
981
1020
|
net_wm_state, atom_type, 32, xlib.PropModePrepend,
|
|
@@ -1008,7 +1047,7 @@ class XlibWindow(BaseWindow):
|
|
|
1008
1047
|
# Cache these in case window is closed from an event handler
|
|
1009
1048
|
_x_display = self._x_display
|
|
1010
1049
|
_window = self._window
|
|
1011
|
-
|
|
1050
|
+
_x_window = self._x_window
|
|
1012
1051
|
|
|
1013
1052
|
# Check for the events specific to this window
|
|
1014
1053
|
while xlib.XCheckWindowEvent(_x_display, _window, 0x1ffffff, byref(e)):
|
|
@@ -1020,7 +1059,7 @@ class XlibWindow(BaseWindow):
|
|
|
1020
1059
|
self.dispatch_platform_event(e)
|
|
1021
1060
|
|
|
1022
1061
|
# Check for the events specific to this view
|
|
1023
|
-
while xlib.XCheckWindowEvent(_x_display,
|
|
1062
|
+
while xlib.XCheckWindowEvent(_x_display, _x_window, 0x1ffffff, byref(e)):
|
|
1024
1063
|
# Key events are filtered by the xlib window event
|
|
1025
1064
|
# handler so they get a shot at the prefiltered event.
|
|
1026
1065
|
if e.xany.type not in (xlib.KeyPress, xlib.KeyRelease):
|
|
@@ -1059,7 +1098,7 @@ class XlibWindow(BaseWindow):
|
|
|
1059
1098
|
event_handler(e)
|
|
1060
1099
|
|
|
1061
1100
|
@staticmethod
|
|
1062
|
-
@lru_cache
|
|
1101
|
+
@lru_cache
|
|
1063
1102
|
def _translate_modifiers(state: int) -> int:
|
|
1064
1103
|
modifiers = 0
|
|
1065
1104
|
if state & xlib.ShiftMask:
|
|
@@ -1205,10 +1244,9 @@ class XlibWindow(BaseWindow):
|
|
|
1205
1244
|
for auto_event in reversed(saved):
|
|
1206
1245
|
xlib.XPutBackEvent(self._x_display, byref(auto_event))
|
|
1207
1246
|
return
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
break
|
|
1247
|
+
# Key code of press did not match, therefore no repeating
|
|
1248
|
+
# is going on, stop searching.
|
|
1249
|
+
break
|
|
1212
1250
|
# Whoops, put the events back, it's for real.
|
|
1213
1251
|
for auto_event in reversed(saved):
|
|
1214
1252
|
xlib.XPutBackEvent(self._x_display, byref(auto_event))
|
|
@@ -1528,7 +1566,7 @@ class XlibWindow(BaseWindow):
|
|
|
1528
1566
|
self._current_sync_valid = False
|
|
1529
1567
|
|
|
1530
1568
|
@staticmethod
|
|
1531
|
-
@lru_cache
|
|
1569
|
+
@lru_cache
|
|
1532
1570
|
def _translate_button(value: int) -> int:
|
|
1533
1571
|
"""Translate mouse button values to match mouse constants.
|
|
1534
1572
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: pyglet
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.dev1
|
|
4
4
|
Summary: pyglet is a cross-platform games and multimedia package.
|
|
5
5
|
Author-email: Alex Holkner & contributors <Alex.Holkner@gmail.com>
|
|
6
6
|
Requires-Python: >=3.8
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
-
License-File: LICENSE
|
|
9
8
|
Project-URL: Home, https://pyglet.org
|
|
10
9
|
|
|
11
10
|
[](https://pypi.python.org/pypi/pyglet) [](https://pyglet.readthedocs.io) [](https://github.com/pyglet/pyglet/actions/workflows/unittests.yml)
|