Ejemplo n.º 1
0
    def _get_property(self, atom_name):
        try:
            if not Atom.get_type_name(atom_name):
                return ''

            rsp = connection.get_core().GetProperty(
                False,
                self.wid,
                Atom.get_atom(atom_name),
                Atom.get_atom_type(atom_name),
                0,
                (2 ** 32) - 1
            ).reply()

            if Atom.get_type_name(atom_name) in ('UTF8_STRING', 'STRING'):
                if atom_name == 'WM_CLASS':
                    return Atom.null_terminated_to_strarray(rsp.value)
                else:
                    return Atom.ords_to_str(rsp.value)
            elif Atom.get_type_name(atom_name) in ('UTF8_STRING[]', 'STRING[]'):
                return Atom.null_terminated_to_strarray(rsp.value)
            else:
                return list(struct.unpack('I' * (len(rsp.value) / 4), rsp.value.buf()))
        except:
            pass