예제 #1
0
 def command_callback(hwnd, cid):
     if cid == 1024:
         from xpra.platform.win32.win32_balloon import notify
         notify(hwnd, "hello", "world")
     elif cid == 1025:
         print("Goodbye")
         DestroyWindow(hwnd)
     else:
         print("OnCommand for ID=%s" % cid)
예제 #2
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())
예제 #3
0
 def cleanup_window(self):
     w = self.window
     if w:
         self.window = None
         RemoveClipboardFormatListener(w)
         DestroyWindow(w)
     wch = self.wndclass_handle
     if wch:
         self.wndclass = None
         self.wndclass_handle = None
         UnregisterClassW(clipboard_window_class_name, GetModuleHandleA(0))
예제 #4
0
파일: clipboard.py 프로젝트: frostbane/xpra
 def cleanup_window(self):
     w = self.window
     if w:
         self.window = None
         RemoveClipboardFormatListener(w)
         DestroyWindow(w)
     wch = self.wndclass_handle
     if wch:
         self.wndclass = None
         self.wndclass_handle = None
         UnregisterClassW(CLIPBOARD_WINDOW_CLASS_NAME, GetModuleHandleA(0))
예제 #5
0
    def cleanup(self):
        log("Win32EventListener.cleanup()")
        self.event_callback = {}

        hwnd = self.hwnd
        if hwnd:
            WTSUnRegisterSessionNotification(hwnd)

            self.hwnd = None
            try:
                DestroyWindow(hwnd)
            except Exception as e:
                log.error("Error during cleanup of event window instance:")
                log.error(" %s", e)

            wc = self.wc
            self.wc = None
            try:
                UnregisterClassW(wc.lpszClassName, wc.hInstance)
            except Exception as e:
                log.error("Error during cleanup of event window class:")
                log.error(" %s", e)
예제 #6
0
 def command_callback(hwnd, cid):
     if cid == 1024:
         from xpra.platform.win32.win32_balloon import notify
         try:
             from PIL import Image  #@UnresolvedImport
             from io import BytesIO
             img = Image.open("icons\\printer.png")
             buf = BytesIO()
             img.save(buf, "PNG")
             data = buf.getvalue()
             buf.close()
             icon = (b"png", img.size[0], img.size[1], data)
         except Exception as e:
             print("could not find icon: %s" % (e, ))
             icon = None
         else:
             pass
         notify(hwnd, 0, "hello", "world", timeout=1000, icon=icon)
     elif cid == 1025:
         print("Goodbye")
         DestroyWindow(hwnd)
     else:
         print("OnCommand for ID=%s" % cid)