From 7040cc35b07d886ead06d2bf512f4a2bc4c20869 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 21 Sep 2023 20:37:37 +0800 Subject: [PATCH] sync pyglet to master --- libs/pyglet/customtypes.py | 47 +++-------------------------- libs/pyglet/window/xlib/__init__.py | 6 ++-- 2 files changed, 8 insertions(+), 45 deletions(-) diff --git a/libs/pyglet/customtypes.py b/libs/pyglet/customtypes.py index d4449a7..d792cc5 100644 --- a/libs/pyglet/customtypes.py +++ b/libs/pyglet/customtypes.py @@ -1,51 +1,12 @@ """Holds type aliases used throughout the codebase.""" import ctypes -from typing import Union, Tuple, TypeVar +from typing import Union -# just Number -Number = Union[int, float] -# Colors -Channel = TypeVar('Channel', int, float) +__all__ = [ + "Buffer" +] # Backwards compatible placeholder for `collections.abc.Buffer` from Python 3.12 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', -] diff --git a/libs/pyglet/window/xlib/__init__.py b/libs/pyglet/window/xlib/__init__.py index c1de9d7..cb42402 100644 --- a/libs/pyglet/window/xlib/__init__.py +++ b/libs/pyglet/window/xlib/__init__.py @@ -1,9 +1,12 @@ +import locale import unicodedata import urllib.parse + from ctypes import * from functools import lru_cache import pyglet + from pyglet.window import WindowException, MouseCursorException from pyglet.window import MouseCursor, DefaultMouseCursor, ImageMouseCursor from pyglet.window import BaseWindow, _PlatformEventHandler, _ViewEventHandler @@ -47,8 +50,7 @@ XA_ATOM = 4 XDND_VERSION = 5 -# Do we have the November 2000 UTF8 extension? -_have_utf8 = hasattr(xlib._lib, 'Xutf8TextListToTextProperty') +_have_utf8 = locale.getlocale()[1] == 'UTF-8' # symbol,ctrl -> motion mapping _motion_map = {