Skip to content

Commit

Permalink
New TIMECAPS structure.
Browse files Browse the repository at this point in the history
Minor cleanup.
  • Loading branch information
benmoran56 committed Nov 24, 2022
1 parent f157c0b commit 2aeb170
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions pyglet/libs/win32/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
# POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------------

import sys
import ctypes
from . import com

from ctypes import *
from ctypes.wintypes import *

from . import com


_int_types = (c_int16, c_int32)
if hasattr(ctypes, 'c_int64'):
Expand All @@ -53,11 +54,6 @@
del _int_types


# PUINT is defined only from >= python 3.2
if sys.version_info < (3, 2)[:2]:
PUINT = POINTER(UINT)


class c_void(Structure):
# c_void_p is a buggy return type, converting to int, so
# POINTER(None) == c_void_p is actually written as
Expand All @@ -76,6 +72,7 @@ def from_param(cls, x):
return cls()
else:
return x

p.from_param = classmethod(from_param)

return p
Expand Down Expand Up @@ -367,13 +364,15 @@ class _DUMMYSTRUCTNAME(Structure):
('dmPrintQuality', c_short),
]


class _DUMMYSTRUCTNAME2(Structure):
_fields_ = [
('dmPosition', POINTL),
('dmDisplayOrientation', DWORD),
('dmDisplayFixedOutput', DWORD)
]


class _DUMMYDEVUNION(Union):
_anonymous_ = ('_dummystruct1', '_dummystruct2')
_fields_ = [
Expand All @@ -382,6 +381,7 @@ class _DUMMYDEVUNION(Union):
('_dummystruct2', _DUMMYSTRUCTNAME2),
]


class DEVMODE(Structure):
_anonymous_ = ('_dummyUnion',)
_fields_ = [
Expand All @@ -391,7 +391,7 @@ class DEVMODE(Structure):
('dmSize', WORD),
('dmDriverExtra', WORD),
('dmFields', DWORD),
# Just using largest union member here
# Just using the largest union member here
('_dummyUnion', _DUMMYDEVUNION),
# End union
('dmColor', c_short),
Expand All @@ -404,7 +404,7 @@ class DEVMODE(Structure):
('dmBitsPerPel', DWORD),
('dmPelsWidth', DWORD),
('dmPelsHeight', DWORD),
('dmDisplayFlags', DWORD), # union with dmNup
('dmDisplayFlags', DWORD), # union with dmNup
('dmDisplayFrequency', DWORD),
('dmICMMethod', DWORD),
('dmICMIntent', DWORD),
Expand Down Expand Up @@ -511,15 +511,15 @@ class RAWINPUT(Structure):


# PROPVARIANT wrapper, doesn't require InitPropVariantFromInt64 this way.
class _VarTable(ctypes.Union):
class _VarTable(Union):
"""Must be in an anonymous union or values will not work across various VT's."""
_fields_ = [
('llVal', ctypes.c_longlong),
('pwszVal', LPWSTR)
]


class PROPVARIANT(ctypes.Structure):
class PROPVARIANT(Structure):
_anonymous_ = ['union']

_fields_ = [
Expand All @@ -530,14 +530,15 @@ class PROPVARIANT(ctypes.Structure):
('union', _VarTable)
]

class _VarTableVariant(ctypes.Union):

class _VarTableVariant(Union):
"""Must be in an anonymous union or values will not work across various VT's."""
_fields_ = [
('bstrVal', LPCWSTR)
]


class VARIANT(ctypes.Structure):
class VARIANT(Structure):
_anonymous_ = ['union']

_fields_ = [
Expand All @@ -548,7 +549,8 @@ class VARIANT(ctypes.Structure):
('union', _VarTableVariant)
]

class DWM_BLURBEHIND(ctypes.Structure):

class DWM_BLURBEHIND(Structure):
_fields_ = [
("dwFlags", DWORD),
("fEnable", BOOL),
Expand All @@ -557,7 +559,7 @@ class DWM_BLURBEHIND(ctypes.Structure):
]


class STATSTG(ctypes.Structure):
class STATSTG(Structure):
_fields_ = [
('pwcsName', LPOLESTR),
('type', DWORD),
Expand All @@ -572,6 +574,12 @@ class STATSTG(ctypes.Structure):
('reserved', DWORD),
]


class TIMECAPS(Structure):
_fields_ = (('wPeriodMin', UINT),
('wPeriodMax', UINT))


class IStream(com.pIUnknown):
_methods_ = [
('Read',
Expand Down

0 comments on commit 2aeb170

Please sign in to comment.