コード例 #1
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
コード例 #2
0
ファイル: shadow_server.py プロジェクト: chewi/xpra
 def enum_windows_cb(hwnd, lparam):
     if not IsWindowVisible(hwnd):
         log("window %#x is not visible", hwnd)
         return True
     pid = c_ulong()
     thread_id = GetWindowThreadProcessId(hwnd, byref(pid))
     if pid==ourpid:
         log("skipped our own window %#x, thread id=%#x", hwnd, thread_id)
         return True
     rect = RECT()
     if GetWindowRect(hwnd, byref(rect))==0:
         log("GetWindowRect failure")
         return True
     if hwnd==taskbar:
         log("skipped taskbar")
         return True
     #skipping IsWindowEnabled check
     length = GetWindowTextLengthW(hwnd)
     buf = create_unicode_buffer(length+1)
     if GetWindowTextW(hwnd, buf, length+1)>0:
         window_title = buf.value
     else:
         window_title = ''
     left, top, right, bottom = rect.left, rect.top, rect.right, rect.bottom
     w = right-left
     h = bottom-top
     if left<=-32000 or top<=-32000:
         log("%r is not visible: %s", window_title, (left, top, w, h))
     if w<=0 and h<=0:
         log("skipped invalid window size: %ix%i", w, h)
         return True
     windows[hwnd] = (window_title, (left, top, w, h))
     return True
コード例 #3
0
 def enum_windows_cb(hwnd, lparam):
     if not IsWindowVisible(hwnd):
         l("skipped invisible window %#x", hwnd)
         return True
     pid = c_int()
     thread_id = GetWindowThreadProcessId(hwnd, byref(pid))
     if pid == ourpid:
         l("skipped our own window %#x", hwnd)
         return True
     #skipping IsWindowEnabled check
     length = GetWindowTextLengthW(hwnd)
     buf = create_unicode_buffer(length + 1)
     if GetWindowTextW(hwnd, buf, length + 1) > 0:
         window_title = buf.value
     else:
         window_title = ''
     l(
         "get_shape_rectangles() found window '%s' with pid=%i and thread id=%i",
         window_title, pid, thread_id)
     rect = RECT()
     if GetWindowRect(hwnd, byref(rect)) == 0:
         l("GetWindowRect failure")
         return True
     left, top, right, bottom = rect.left, rect.top, rect.right, rect.bottom
     if right < 0 or bottom < 0:
         l("skipped offscreen window at %ix%i", right, bottom)
         return True
     if hwnd == taskbar:
         l("skipped taskbar")
         return True
     #dirty way:
     if window_title == 'Program Manager':
         return True
     #this should be the proper way using GetTitleBarInfo (but does not seem to work)
     #import ctypes
     #from ctypes.windll.user32 import GetTitleBarInfo        #@UnresolvedImport
     #from ctypes.wintypes import (DWORD, RECT)
     #class TITLEBARINFO(ctypes.Structure):
     #    pass
     #TITLEBARINFO._fields_ = [
     #    ('cbSize', DWORD),
     #    ('rcTitleBar', RECT),
     #    ('rgstate', DWORD * 6),
     #]
     #ti = TITLEBARINFO()
     #ti.cbSize = sizeof(ti)
     #GetTitleBarInfo(hwnd, byref(ti))
     #if ti.rgstate[0] & win32con.STATE_SYSTEM_INVISIBLE:
     #    log("skipped system invisible window")
     #    return True
     w = right - left
     h = bottom - top
     l("shape(%s - %#x)=%s", window_title, hwnd, (left, top, w, h))
     if w <= 0 and h <= 0:
         l("skipped invalid window size: %ix%i", w, h)
         return True
     if left == -32000 and top == -32000:
         #there must be a better way of skipping those - I haven't found it
         l("skipped special window")
         return True
     #now clip rectangle:
     if left < 0:
         left = 0
         w = right
     if top < 0:
         top = 0
         h = bottom
     rectangles.append((left, top, w, h))
     return True