xpra icon
Bug tracker and wiki

Ticket #1570: win32-opengl-alpha.patch

File win32-opengl-alpha.patch, 2.6 KB (added by Antoine Martin, 3 years ago)

try to enable transparency with opengl

  • xpra/platform/win32/common.py

     
    257257
    258258IID = GUID
    259259REFIID = POINTER(IID)
     260
     261
     262HGRN = HANDLE
     263class DWM_BLURBEHIND(Structure):
     264    _fields_ = [
     265        ("dwFlags",                 DWORD),
     266        ("fEnable",                 BOOL),
     267        ("hRgnBlur",                HGRN),
     268        ("fTransitionOnMaximized",  BOOL),
     269    ]
     270CreateRectRgn = gdi32.CreateRectRgn
     271CreateRectRgn.restype = HGRN
     272CreateRectRgn.argtypes = [INT, INT, INT, INT]
     273
     274DWM_BB_ENABLE = 1
     275DWM_BB_BLURREGION = 2
     276DWM_BB_TRANSITIONONMAXIMIZED = 4
     277
     278dwmapi = WinDLL("dwmapi", use_last_error=True)
     279DwmEnableBlurBehindWindow = dwmapi.DwmEnableBlurBehindWindow
     280DwmEnableBlurBehindWindow.restype = HRESULT
     281DwmEnableBlurBehindWindow.argtypes = [HWND, POINTER(DWM_BLURBEHIND)]
  • xpra/client/gl/gtk3/gl_client_window.py

     
    99
    1010from xpra.client.gtk3.client_window import ClientWindow
    1111from xpra.client.gl.gtk_base.gl_client_window_common import GLClientWindowCommon
     12from xpra.platform.win32.gui import get_window_handle
    1213
    1314
    1415class GLClientWindowBase(GLClientWindowCommon, ClientWindow):
     
    1718        ClientWindow.set_alpha(self)
    1819        rgb_formats = self._client_properties.get("encodings.rgb_formats", [])
    1920        GLClientWindowCommon.add_rgb_formats(self, rgb_formats)
     21        log.info("set_alpha() has_alpha=%s", self._has_alpha)
     22        if self._has_alpha:
     23            self.when_realized("alpha", self._enable_gl_alpha)
     24            self.timeout_add(1000, self._enable_gl_alpha)
    2025
     26    def _enable_gl_alpha(self):
     27        log.info("_enable_gl_alpha() window=%s", self.get_window())
     28        from xpra.platform.win32.common import CreateRectRgn, DWM_BLURBEHIND, DWM_BB_ENABLE, DWM_BB_BLURREGION, DwmEnableBlurBehindWindow
     29        from ctypes import byref
     30        rgn = CreateRectRgn(0, 0, 1000, 1000)
     31        log.info("CreateRectRgn(..)=%#x", rgn)
     32        bb = DWM_BLURBEHIND()
     33        bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION
     34        bb.hRgnBlur = rgn
     35        bb.fEnable = True
     36        hwnd = get_window_handle(self)
     37        log.info("hwnd=%x", hwnd)
     38        r = DwmEnableBlurBehindWindow(hwnd, byref(bb))
     39        log.info("r=%s", r)
     40
    2141    def do_configure_event(self, event):
    2242        log("GL do_configure_event(%s)", event)
    2343        ClientWindow.do_configure_event(self, event)