sync pyglet to master

This commit is contained in:
shenjack 2023-09-21 20:37:37 +08:00
parent 91acbc490c
commit 7040cc35b0
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 8 additions and 45 deletions

View File

@ -1,51 +1,12 @@
"""Holds type aliases used throughout the codebase.""" """Holds type aliases used throughout the codebase."""
import ctypes import ctypes
from typing import Union, Tuple, TypeVar from typing import Union
# just Number
Number = Union[int, float]
# Colors __all__ = [
Channel = TypeVar('Channel', int, float) "Buffer"
]
# Backwards compatible placeholder for `collections.abc.Buffer` from Python 3.12 # Backwards compatible placeholder for `collections.abc.Buffer` from Python 3.12
Buffer = Union[bytes, bytearray, memoryview, ctypes.Array] Buffer = Union[bytes, bytearray, memoryview, ctypes.Array]
# Points
Point2D = Tuple[Number, Number]
Point3D = Tuple[Number, Number, Number]
RGB = Tuple[Channel, Channel, Channel]
RGBA = Tuple[Channel, Channel, Channel, Channel]
# Can be used as Color[int] or Color[float]
Color = Union[RGB[Channel], RGBA[Channel]]
# predefined Colors
RGB255 = RGB[int]
RGBFloat = RGB[float]
RGBA255 = RGBA[int]
RGBAFloat = RGBA[float]
Color255 = Color[int]
ColorFloat = Color[float]
__all__ = [
'Number',
'Channel',
'Buffer',
'Point2D',
'Point3D',
'RGB',
'RGBA',
'Color',
'RGB255', 'RGBFloat',
'RGBA255', 'RGBAFloat',
'Color255', 'ColorFloat',
]

View File

@ -1,9 +1,12 @@
import locale
import unicodedata import unicodedata
import urllib.parse import urllib.parse
from ctypes import * from ctypes import *
from functools import lru_cache from functools import lru_cache
import pyglet import pyglet
from pyglet.window import WindowException, MouseCursorException from pyglet.window import WindowException, MouseCursorException
from pyglet.window import MouseCursor, DefaultMouseCursor, ImageMouseCursor from pyglet.window import MouseCursor, DefaultMouseCursor, ImageMouseCursor
from pyglet.window import BaseWindow, _PlatformEventHandler, _ViewEventHandler from pyglet.window import BaseWindow, _PlatformEventHandler, _ViewEventHandler
@ -47,8 +50,7 @@ XA_ATOM = 4
XDND_VERSION = 5 XDND_VERSION = 5
# Do we have the November 2000 UTF8 extension? _have_utf8 = locale.getlocale()[1] == 'UTF-8'
_have_utf8 = hasattr(xlib._lib, 'Xutf8TextListToTextProperty')
# symbol,ctrl -> motion mapping # symbol,ctrl -> motion mapping
_motion_map = { _motion_map = {