Get the list of window types of the given window (property
        _NET_WM_WINDOW_TYPE).

        :param win: the window object
        :param str: True to get a list of string types instead of int
        :return: list of (int|str)
321818
def getWmWindowType(self, win, str=False):
        
        types = self._getProperty('_NET_WM_WINDOW_TYPE', win) or []
        if not str:
            return types
        return [self._getAtomName(t) for t in types]
1197143
def getWindowPID(self, hwnd):
        
        for w in self._get_window_list():
            if "kCGWindowNumber" in w and w["kCGWindowNumber"] == hwnd:
                return w["kCGWindowOwnerPID"]
292132
def document_windows(self) -> typing.List[DocumentWindow]:
        
        return [DocumentWindow(document_controller) for document_controller in self.__application.document_controllers]
1180962
def _posix_get_window_size():
    
    # see README.txt for reference information
    # http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html

    from fcntl import ioctl
    from termios import TIOCGWINSZ
    from array import array

    """
    struct winsize {
        unsigned short ws_row;
        unsigned short ws_col;
        unsigned short ws_xpixel;   /* unused */
        unsigned short ws_ypixel;   /* unused */
    };
    """
    winsize = array("H", [0] * 4)
    try:
        ioctl(sys.stdout.fileno(), TIOCGWINSZ, winsize)
    except IOError:
        # for example IOError: [Errno 25] Inappropriate ioctl for device
        # when output is redirected
        # [ ] TODO: check fd with os.isatty
        pass
    return (winsize[1], winsize[0])
395154
def sort_window_ids(winid_list, order='mru'):
        
        import utool as ut
        winid_order = XCtrl.sorted_window_ids(order)
        sorted_win_ids = ut.isect(winid_order, winid_list)
        return sorted_win_ids
1213528
def getWindowRect(self, hwnd):
        
        rect = ctypes.wintypes.RECT()
        if ctypes.windll.user32.GetWindowRect(hwnd, ctypes.byref(rect)):
            x1 = rect.left
            y1 = rect.top
            x2 = rect.right
            y2 = rect.bottom
            return (x1, y1, x2-x1, y2-y1)
        return None
1074358
def window(self, window_name):
        
        if self._driver.w3c:
            self._w3c_window(window_name)
            return
        data = {'name': window_name}
        self._driver.execute(Command.SWITCH_TO_WINDOW, data)
1102208
def _windows_wwns():
    '''
    
    '''
    ps_cmd = r'Get-WmiObject -ErrorAction Stop ' \
             r'-class MSFC_FibrePortHBAAttributes ' \
             r'-namespace "root\WMI" | ' \
             r'Select -Expandproperty Attributes | ' \
             r'%{($_.PortWWN | % {"{0:x2}" -f $_}) -join ""}'
    ret = []
    cmd_ret = salt.modules.cmdmod.powershell(ps_cmd)
    for line in cmd_ret:
        ret.append(line.rstrip())
    return ret
627953
def GetHandle(self):
        ''' 
        '''
        win_id = self.winId()  # this returns either an int or voitptr

        if "%s"%type(win_id) == "<type 'PyCObject'>":  # PySide
            ### with PySide, self.winId() does not return an integer
            if sys.platform == "win32":
                ## Be careful, this hack is py27 specific
                ## does not work with python31 or higher
                ## since the PyCObject api was changed
                import ctypes
                ctypes.pythonapi.PyCObject_AsVoidPtr.restype = ctypes.c_void_p
                ctypes.pythonapi.PyCObject_AsVoidPtr.argtypes = [
                    ctypes.py_object]
                win_id = ctypes.pythonapi.PyCObject_AsVoidPtr(win_id)
        elif type(win_id) is not int:  #PyQt4 or 5
            ## below integer cast may be required because self.winId() can
            ## returns a sip.voitptr according to the PyQt version used
            ## as well as the python version
            win_id = int(win_id)
        return win_id
1354333
def get_active_window():
    
    active_win = None
    default = wnck.screen_get_default()
    while gtk.events_pending():
        gtk.main_iteration(False)
    window_list = default.get_windows()
    if len(window_list) == 0:
        print "No Windows Found"
    for win in window_list:
        if win.is_active():
            active_win = win.get_name()
    return active_win
540956
def _walk_through_windows(self):
        
        def walk(split):
            for c in split:
                if isinstance(c, (HSplit, VSplit)):
                    for i in walk(c):
                        yield i
                elif isinstance(c, Window):
                    yield split, c

        return walk(self.root)
253519
def getWindow(title, exact=False):
    
    titles = getWindows()
    hwnd = titles.get(title, None)
    if not hwnd and not exact:
        for k, v in titles.items():
            if title in k:
                hwnd = v
                break
    if hwnd:
        return Window(hwnd)
    else:
        return None
375258
def _get_serial_ports_windows():
    '''
    
    '''
    import six.moves.winreg as winreg

    reg_path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
    try:
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_path)
    except WindowsError:
        # No serial ports. Return empty generator.
        return

    for i in itertools.count():
        try:
            val = winreg.EnumValue(key, i)
            yield str(val[1])
        except EnvironmentError:
            break
298805
def getWindowTitle(self, hwnd):
        
        for w in self._get_window_list():
            if "kCGWindowNumber" in w and w["kCGWindowNumber"] == hwnd:
                return w["kCGWindowName"]
772331
def list():
        """"""
        handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
        tzkey = winreg.OpenKey(handle, TZKEYNAME)
        result = [winreg.EnumKey(tzkey, i)
                  for i in range(winreg.QueryInfoKey(tzkey)[0])]
        tzkey.Close()
        handle.Close()
        return result
748782
def _get_types(type_):
    

    return list(
        itertools.chain.from_iterable(
            map(lambda x: TYPE_MAPPINGS[x].get(type_, []), TYPE_MAPPINGS)
        )
    )
14011
def __grabHotkeysForWindow(self, window):
        
        c = self.app.configManager
        hotkeys = c.hotKeys + c.hotKeyFolders
        window_info = self.get_window_info(window)
        for item in hotkeys:
            if item.get_applicable_regex() is not None and item._should_trigger_window_title(window_info):
                self.__enqueue(self.__grabHotkey, item.hotKey, item.modifiers, window)
            elif self.__needsMutterWorkaround(item):
                self.__enqueue(self.__grabHotkey, item.hotKey, item.modifiers, window)