Skip to content

Commit

Permalink
cache ctypes lookups, expose single vs double buffering status
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@17371 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 11, 2017
1 parent 9302fb9 commit 9577ba8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/xpra/platform/win32/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
log = Logger("opengl")

from ctypes import sizeof, byref, FormatError
from xpra.os_util import PYTHON2
from xpra.os_util import PYTHON2, PYTHON3
from xpra.client.gl.gl_check import check_PyOpenGL_support
from xpra.platform.win32.constants import CS_OWNDC, CS_HREDRAW, CS_VREDRAW, COLOR_WINDOW, WS_OVERLAPPED, WS_SYSMENU, CW_USEDEFAULT
from xpra.platform.win32.common import (
Expand All @@ -18,6 +18,16 @@

DOUBLE_BUFFERED = True

if PYTHON3:
from ctypes import CDLL, pythonapi, c_void_p, py_object
PyCapsule_GetPointer = pythonapi.PyCapsule_GetPointer
PyCapsule_GetPointer.restype = c_void_p
PyCapsule_GetPointer.argtypes = [py_object]
log("PyCapsute_GetPointer=%s", PyCapsule_GetPointer)
gdkdll = CDLL("libgdk-3-0.dll")
log("gdkdll=%s", gdkdll)


def DefWndProc(hwnd, msg, wParam, lParam):
return DefWindowProcA(hwnd, msg, wParam, lParam)

Expand Down Expand Up @@ -94,7 +104,9 @@ def check_support(self, force_enable=False):
try:
self.context = self.create_wgl_context(self.hwnd)
with WGLWindowContext(self.hwnd, self.hdc, self.context):
return check_PyOpenGL_support(force_enable)
props = check_PyOpenGL_support(force_enable)
props["display_mode"] = [["SINGLE","DOUBLE"][int(DOUBLE_BUFFERED)], ] #, "ALPHA"]
return props
finally:
hwnd = self.hwnd
self.destroy()
Expand All @@ -114,13 +126,6 @@ def get_paint_context(self, gdk_window):
if PYTHON2:
hwnd = gdk_window.handle
else:
from ctypes import CDLL, pythonapi, c_void_p, py_object
gdkdll = CDLL("libgdk-3-0.dll")
log("gdkdll=%s", gdkdll)
PyCapsule_GetPointer = pythonapi.PyCapsule_GetPointer
PyCapsule_GetPointer.restype = c_void_p
PyCapsule_GetPointer.argtypes = [py_object]
log("PyCapsute_GetPointer=%s", PyCapsule_GetPointer)
gpointer = PyCapsule_GetPointer(gdk_window.__gpointer__, None)
log("gpointer=%s", gpointer)
hwnd = gdkdll.gdk_win32_window_get_handle(gpointer)
Expand Down

0 comments on commit 9577ba8

Please sign in to comment.