Example #1
0
 def check_support(self, force_enable=False):
     #create a temporary window to query opengl attributes:
     hInst = GetModuleHandleA(0)
     log("check_support() GetModuleHandleW()=%#x", hInst or 0)
     classname = "Xpra Temporary Window for OpenGL"
     wndc = WNDCLASSEX()
     wndc.cbSize = sizeof(WNDCLASSEX)
     wndc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW
     wndc.hInstance = hInst
     wndc.hBrush = COLOR_WINDOW
     wndc.lpszClassName = classname
     wndc.lpfnWndProc = WNDPROC(DefWndProc)
     reg_atom = RegisterClassExA(byref(wndc))
     log("check_support() RegisterClassExW()=%#x", reg_atom or 0)
     if not reg_atom:
         return {
             "info":
             "disabled: failed to register window class, %s" %
             FormatError()
         }
     style = WS_OVERLAPPED | WS_SYSMENU
     window_name = "Xpra OpenGL Test"
     self.hwnd = CreateWindowExA(0, reg_atom, window_name, style,
                                 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0,
                                 hInst, None)
     log("check_support() CreateWindowExW()=%#x", self.hwnd or 0)
     if not self.hwnd:
         return {
             "info":
             "disabled: failed to create temporary window, %s" %
             FormatError()
         }
     try:
         self.context = self.create_wgl_context(self.hwnd)
         with WGLWindowContext(self.hwnd, self.hdc, self.context):
             props = check_PyOpenGL_support(force_enable)
         props["display_mode"] = [
             ["SINGLE", "DOUBLE"][int(DOUBLE_BUFFERED)],
         ]  #, "ALPHA"]
         return props
     finally:
         hwnd = self.hwnd
         self.destroy()
         if hwnd and not DestroyWindow(hwnd):
             log.warn(
                 "Warning: failed to destroy temporary OpenGL test window")
         latom = c_void_p(reg_atom)
         if not UnregisterClassW(cast(latom, LPCWSTR), hInst):
             log.warn(
                 "Warning: failed to unregister class for OpenGL test window"
             )
             log.warn(" for class %r and module handle %#x:", classname,
                      hInst or 0)
             log.warn(" '%s'", FormatError())
Example #2
0
def get_notifyicon_wnd_class():
    global _notifyicon_wnd_class
    if _notifyicon_wnd_class is None:
        hmodule = HMODULE(0)
        assert GetModuleHandleExA(0, None, byref(hmodule))
        log("GetModuleHandleExA(..)=%#x", int(hmodule.value))

        NIwc = WNDCLASSEX()
        NIwc.cbSize = sizeof(WNDCLASSEX)
        NIwc.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW
        NIwc.lpfnWndProc = WNDPROC(NotifyIconWndProc)
        NIwc.hInstance = hmodule
        NIwc.hBrush = GetStockObject(win32con.WHITE_BRUSH)
        NIwc.lpszClassName = "win32NotifyIcon"

        NIclassAtom = RegisterClassExA(byref(NIwc))
        log("RegisterClassExA(%s)=%i", NIwc.lpszClassName, NIclassAtom)
        if NIclassAtom == 0:
            raise ctypes.WinError(ctypes.get_last_error())
        NIwc.NIclassAtom = NIclassAtom
        _notifyicon_wnd_class = NIwc
    return _notifyicon_wnd_class
Example #3
0
        (hwnd, msg, wParam, lParam), instance, msg, fn)
    #log("potential matching win32 constants for message: %s", [x for x in dir(win32con) if getattr(win32con, x)==msg])
    if instance and fn:
        return fn(instance, hwnd, msg, wParam, lParam) or 0
    return DefWindowProcA(hwnd, msg, wParam, lParam)


NIwc = WNDCLASSEX()
NIwc.cbSize = sizeof(WNDCLASSEX)
NIwc.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW
NIwc.lpfnWndProc = WNDPROC(NotifyIconWndProc)
NIwc.hInstance = GetModuleHandleA(0)
NIwc.hBrush = GetStockObject(win32con.WHITE_BRUSH)
NIwc.lpszClassName = u"win32NotifyIcon"

NIclassAtom = RegisterClassExA(byref(NIwc))
if NIclassAtom == 0:
    raise ctypes.WinError(ctypes.get_last_error())
log("RegisterClassExA(%s)=%i", NIwc.lpszClassName, NIclassAtom)


def main():
    import os
    from xpra.platform.win32.common import user32

    def click_callback(button, pressed):
        menu = CreatePopupMenu()
        AppendMenu(menu, win32con.MF_STRING, 1024, u"Generate balloon")
        AppendMenu(menu, win32con.MF_STRING, 1025, u"Exit")
        pos = POINT()
        GetCursorPos(byref(pos))