コード例 #1
0
def fixup_window_style(self, *args):
    """ a fixup function we want to call from other places """
    hwnd = get_window_handle(self)
    if not hwnd:
        return
    try:
        #warning: accessing "_metadata" on the client window class is fugly..
        metadata = getattr(self, "_metadata", {})
        if metadata.get("modal", False):
            #window is not / no longer meant to be decorated
            #(this is what GTK does for modal windows - keep it consistent)
            return
        cur_style = GetWindowLongW(hwnd, win32con.GWL_STYLE)
        #re-add taskbar menu:
        style = cur_style
        if cur_style & win32con.WS_CAPTION:
            style |= win32con.WS_SYSMENU
            style |= win32con.WS_MAXIMIZEBOX
            style |= win32con.WS_MINIMIZEBOX
            if style!=cur_style:
                log("fixup_window_style() using %s (%#x) instead of %s (%#x) on window %#x with metadata=%s", style_str(style), style, style_str(cur_style), cur_style, hwnd, metadata)
                SetWindowLongW(hwnd, win32con.GWL_STYLE, style)
            else:
                log("fixup_window_style() unchanged style %s (%#x) on window %#x", style_str(style), style, hwnd)
    except:
        log.warn("failed to fixup window style", exc_info=True)
コード例 #2
0
def pointer_grab(window, *args):
    hwnd = get_window_handle(window)
    grablog("pointer_grab%s window=%s, hwnd=%s", args, window, hwnd)
    if not hwnd:
        window._client.pointer_grabbed = None
        return
    wrect = RECT()
    GetWindowRect(hwnd, byref(wrect))
    grablog("GetWindowRect(%i)=%s", hwnd, wrect)
    if DwmGetWindowAttribute:
        # Vista & 7 stuff
        rect = RECT()
        DWMWA_EXTENDED_FRAME_BOUNDS = 9
        DwmGetWindowAttribute(HWND(hwnd), DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),
                              byref(rect), sizeof(rect))
        #wx1,wy1,wx2,wy2 = rect.left, rect.top, rect.right, rect.bottom
        grablog("DwmGetWindowAttribute: DWMWA_EXTENDED_FRAME_BOUNDS(%i)=%s",
                hwnd, (rect.left, rect.top, rect.right, rect.bottom))
    bx = GetSystemMetrics(win32con.SM_CXSIZEFRAME)
    by = GetSystemMetrics(win32con.SM_CYSIZEFRAME)
    top = by
    style = GetWindowLongW(hwnd, win32con.GWL_STYLE)
    if style & win32con.WS_CAPTION:
        top += GetSystemMetrics(win32con.SM_CYCAPTION)
    grablog(" window style=%s, SIZEFRAME=%s, top=%i", style_str(style),
            (bx, by), top)
    coords = wrect.left + bx, wrect.top + top, wrect.right - bx, wrect.bottom - by
    clip = RECT(*coords)
    r = ClipCursor(clip)
    grablog("ClipCursor%s=%s", coords, r)
    window._client.pointer_grabbed = window._id
コード例 #3
0
def fixup_window_style(self, *_args):
    """ a fixup function we want to call from other places """
    hwnd = get_window_handle(self)
    if not hwnd:
        return
    try:
        #warning: accessing "_metadata" on the client window class is fugly..
        metadata = getattr(self, "_metadata", {})
        if metadata.get("modal", False):
            #window is not / no longer meant to be decorated
            #(this is what GTK does for modal windows - keep it consistent)
            return
        cur_style = GetWindowLongW(hwnd, win32con.GWL_STYLE)
        #re-add taskbar menu:
        style = cur_style
        if cur_style & win32con.WS_CAPTION:
            style |= win32con.WS_SYSMENU
            style |= win32con.WS_MAXIMIZEBOX
            style |= win32con.WS_MINIMIZEBOX
        #we can't enable this because GTK would then get confused
        #and paint the window contents at the wrong offset
        if False:
            hints = metadata.get("size-constraints")
            if hints:
                minw, minh = hints.get("minimum-size", (0, 0))
                maxw, maxh = hints.get("maximum-size", (0, 0))
                if minw > 0 and minw == maxw and minh > 0 and minh == maxh:
                    #not resizable
                    style &= ~win32con.WS_MAXIMIZEBOX
                    style &= ~win32con.WS_SIZEBOX
        if style != cur_style:
            log(
                "fixup_window_style() using %s (%#x) instead of %s (%#x) on window %#x with metadata=%s",
                style_str(style), style, style_str(cur_style), cur_style, hwnd,
                metadata)
            SetWindowLongW(hwnd, win32con.GWL_STYLE, style)
        else:
            log("fixup_window_style() unchanged style %s (%#x) on window %#x",
                style_str(style), style, hwnd)
        ws_visible = bool(style & win32con.WS_VISIBLE)
        client = self._client
        cur_ws_visible = getattr(self, "_ws_visible", True)
        iconified = getattr(self, "_iconified", False)
        been_mapped = getattr(self, "_been_mapped", False)
        log(
            "fixup_window_style() ws_visible=%s (was %s), iconified=%s, been_mapped=%s",
            ws_visible, cur_ws_visible, iconified, been_mapped)
        if client and been_mapped and not iconified and ws_visible != cur_ws_visible:
            log("window changed visibility to: %s", ws_visible)
            setattr(self, "_ws_visible", ws_visible)
            if ws_visible:
                #with opengl, we need to re-create the window (PITA):
                if REINIT_VISIBLE_WINDOWS:
                    client.reinit_window(self._id, self)
                self.send_control_refresh(False)
            else:
                self.send_control_refresh(True)
    except Exception:
        log.warn("failed to fixup window style", exc_info=True)
コード例 #4
0
def fixup_window_style(window):
    from xpra.platform.win32.gui import get_window_handle
    from xpra.platform.win32.common import GetWindowLongW, SetWindowLongW
    from xpra.platform.win32 import win32con
    hwnd = get_window_handle(window)
    cur_style = GetWindowLongW(hwnd, win32con.GWL_STYLE)
    #re-add taskbar menu:
    style = cur_style
    if cur_style & win32con.WS_CAPTION:
        style |= win32con.WS_SYSMENU
        style |= win32con.WS_MAXIMIZEBOX
        style |= win32con.WS_MINIMIZEBOX
    if False:
        #not resizable
        style &= ~win32con.WS_MAXIMIZEBOX
        style &= ~win32con.WS_SIZEBOX
    if style != cur_style:
        print("fixup_window_style() from %#x to %#x" % (cur_style, style))
        SetWindowLongW(hwnd, win32con.GWL_STYLE, style)
コード例 #5
0
ファイル: gui.py プロジェクト: rudresh2319/Xpra
def fixup_window_style(self, *_args):
    """ a fixup function we want to call from other places """
    hwnd = get_window_handle(self)
    if not hwnd:
        return
    try:
        #warning: accessing "_metadata" on the client window class is fugly..
        metadata = getattr(self, "_metadata", {})
        if metadata.get("modal", False):
            #window is not / no longer meant to be decorated
            #(this is what GTK does for modal windows - keep it consistent)
            return
        cur_style = GetWindowLongW(hwnd, win32con.GWL_STYLE)
        #re-add taskbar menu:
        style = cur_style
        if cur_style & win32con.WS_CAPTION:
            style |= win32con.WS_SYSMENU
            style |= win32con.WS_MAXIMIZEBOX
            style |= win32con.WS_MINIMIZEBOX
        #we can't enable this because GTK would then get confused
        #and paint the window contents at the wrong offset
        if False:
            hints = metadata.get("size-constraints")
            if hints:
                minw, minh = hints.get("minimum-size", (0, 0))
                maxw, maxh = hints.get("maximum-size", (0, 0))
                if minw > 0 and minw == maxw and minh > 0 and minh == maxh:
                    #not resizable
                    style &= ~win32con.WS_MAXIMIZEBOX
                    style &= ~win32con.WS_SIZEBOX
        if style != cur_style:
            log(
                "fixup_window_style() using %s (%#x) instead of %s (%#x) on window %#x with metadata=%s",
                style_str(style), style, style_str(cur_style), cur_style, hwnd,
                metadata)
            SetWindowLongW(hwnd, win32con.GWL_STYLE, style)
        else:
            log("fixup_window_style() unchanged style %s (%#x) on window %#x",
                style_str(style), style, hwnd)
    except:
        log.warn("failed to fixup window style", exc_info=True)