Skip to content

Commit

Permalink
more type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 14, 2023
1 parent 412d146 commit 1b37c11
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 63 deletions.
3 changes: 2 additions & 1 deletion xpra/client/gtk3/u2f_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def printmsgs(*msgs):
"%s" % (str(e) or type(e)))
return 1

from pyu2f.model import RegisteredKey
info("Please activate your U2F device now to generate a new key")
registered_keys = []
registered_keys : List[RegisteredKey] = []
challenge= b'01234567890123456789012345678901' #unused
rr = dev.Register(APP_ID, challenge, registered_keys)
b = rr.registration_data
Expand Down
11 changes: 7 additions & 4 deletions xpra/platform/posix/fd_portal_shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
class PipewireWindowModel(RootWindowModel):
__slots__ = ("pipewire_id", "pipewire_props")

def __init__(self, root_window, capture, title:str, geometry, node_id:int, props:typedict):
super().__init__(root_window=root_window, capture=capture, title=title, geometry=geometry)
self.pipewire_id = node_id
self.pipewire_props = props


class PortalShadow(GTKShadowServerBase):
def __init__(self, multi_window=True):
Expand Down Expand Up @@ -258,7 +263,7 @@ def create_capture_pipeline(self, fd : int, node_id : int, w : int, h : int) ->
log.info(f"cannot use {encoding}: {e}")
return Capture(el, pixel_format="BGRX", width=w, height=h)

def start_pipewire_capture(self, node_id, props) -> None:
def start_pipewire_capture(self, node_id:int, props:typedict) -> None:
log(f"start_pipewire_capture({node_id}, {props})")
if not isinstance(node_id, int):
raise ValueError(f"node-id is a {type(node_id)}, must be an int")
Expand All @@ -282,9 +287,7 @@ def start_pipewire_capture(self, node_id, props) -> None:
source_type = props.intget("source_type")
title = f"{AvailableSourceTypes(source_type)} {node_id}"
geometry = (x, y, w, h)
model = PipewireWindowModel(self.root, self.capture, title, geometry)
model.pipewire_id = node_id
model.pipewire_props = props
model = PipewireWindowModel(self.root, self.capture, title, geometry, node_id, props)
#must be called from the main thread:
log(f"new model: {model}")
self.do_add_new_window_common(node_id, model)
Expand Down
3 changes: 2 additions & 1 deletion xpra/platform/posix/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def c_attrs(props):

def get_xdisplay() -> int:
ptr = get_display_ptr()
assert ptr, "no X11 display registered"
if not ptr:
raise RuntimeError("no X11 display registered")
# pylint: disable=import-outside-toplevel
from OpenGL.raw.GLX._types import struct__XDisplay
return cast(ptr, POINTER(struct__XDisplay))
Expand Down
11 changes: 6 additions & 5 deletions xpra/platform/win32/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from xpra.platform.win32.glwin32 import (
wglCreateContext, wglMakeCurrent, wglDeleteContext,
HGLRC,
PIXELFORMATDESCRIPTOR, PFD_TYPE_RGBA, PFD_DRAW_TO_WINDOW, PFD_SUPPORT_OPENGL,
PFD_DOUBLEBUFFER, PFD_DEPTH_DONTCARE, PFD_SUPPORT_COMPOSITION, PFD_MAIN_PLANE,
PAINTSTRUCT,
Expand All @@ -38,11 +39,11 @@ def DefWndProc(hwnd, msg, wParam, lParam):

class WGLWindowContext:

def __init__(self, hwnd, hdc, context):
def __init__(self, hwnd:int, hdc:int, context):
self.hwnd = hwnd
self.hdc = hdc
self.context = context
self.ps = None
self.ps = PAINTSTRUCT()
self.paint_hdc = None

def __enter__(self):
Expand Down Expand Up @@ -129,10 +130,10 @@ def check_support(self, force_enable=False):
def get_bit_depth(self):
return 0

def is_double_buffered(self):
def is_double_buffered(self) -> bool:
return DOUBLE_BUFFERED #self.pixel_format_props.get("double-buffered", False)

def get_paint_context(self, gdk_window):
def get_paint_context(self, gdk_window) -> WGLWindowContext:
hwnd = get_window_handle(gdk_window)
if self.hwnd!=hwnd:
#(this shouldn't happen)
Expand All @@ -142,7 +143,7 @@ def get_paint_context(self, gdk_window):
self.context = self.create_wgl_context(hwnd)
return WGLWindowContext(hwnd, self.hdc, self.context)

def create_wgl_context(self, hwnd):
def create_wgl_context(self, hwnd:int) -> HGLRC:
bpc = 8
self.hwnd = hwnd
self.pixel_format_props = {}
Expand Down
Loading

0 comments on commit 1b37c11

Please sign in to comment.