Пример #1
0
def get_output_property(display_no=0, property_name=None, 
						property_type=XA_CARDINAL, x_hostname="", 
						x_display_no=0, x_screen_no=0):
	xrandr_output_xid = RDSMM.GetXRandROutputXID(display_no)
	if not xrandr_output_xid:
		raise ValueError("Invalid display number %r specified or XrandR "
						 "unsupported" % display_no)
	
	display = get_display()
	if not x_hostname:
		x_hostname = display[0]
	if not x_display_no:
		x_display_no = display[1]
	if not x_screen_no:
		x_screen_no = display[2]
	display = "%s:%i.%i" % (x_hostname, x_display_no, x_screen_no)
	x_display = libx11.XOpenDisplay(display)
	if not x_display:
		libx11.XCloseDisplay(x_display)
		raise ValueError("Invalid X display %r" % display)

	x_atom = libx11.XInternAtom(x_display, property_name, False)
	if not x_atom:
		libx11.XCloseDisplay(x_display)
		raise ValueError("Invalid property name %r" % property_name)

	ret_type, ret_format, ret_len, ret_togo, atomv = (c_ulong(), 
													  c_int(), 
													  c_ulong(), 
													  c_ulong(), 
													  pointer(c_ubyte()))

	property = None
	if libxrandr.XRRGetOutputProperty(x_display, 
									  xrandr_output_xid, 
									  x_atom, 0, 0x7ffffff, False, False, 
									  property_type, ret_type, ret_format, 
									  ret_len, ret_togo, atomv) == 0 and \
	   ret_len.value > 0:
		if debug:
			print "ret_type:", ret_type.value
			print "ret_format:", ret_format.value
			print "ret_len:", ret_len.value
			print "ret_togo:", ret_togo.value
		property = [atomv[i] for i in xrange(ret_len.value)]
	
	libx11.XCloseDisplay(x_display)

	return property
Пример #2
0
def get_atom(atom_name=None, atom_type=XA_CARDINAL, x_hostname="", 
			 x_display_no=0, x_screen_no=0):
	display = get_display()
	if not x_hostname:
		x_hostname = display[0]
	if not x_display_no:
		x_display_no = display[1]
	if not x_screen_no:
		x_screen_no = display[2]
	display = "%s:%i.%i" % (x_hostname, x_display_no, x_screen_no)
	x_display = libx11.XOpenDisplay(display)
	if not x_display:
		libx11.XCloseDisplay(x_display)
		raise ValueError("Invalid X display %r" % display)
	
	x_window = libx11.XRootWindow(x_display, x_screen_no)
	if not x_window:
		libx11.XCloseDisplay(x_display)
		raise ValueError("Invalid X screen %r" % x_screen_no)
	
	x_atom = libx11.XInternAtom(x_display, atom_name, True)
	if not x_atom:
		libx11.XCloseDisplay(x_display)
		raise ValueError("Invalid atom name %r" % atom_name)

	ret_type, ret_format, ret_len, ret_togo, atomv = (c_ulong(), 
													  c_int(), 
													  c_ulong(), 
													  c_ulong(), 
													  pointer(c_ubyte()))
	
	property = None
	if libx11.XGetWindowProperty(x_display, x_window, 
								 x_atom, 0, 0x7ffffff, False, atom_type, 
								 ret_type, ret_format, ret_len, ret_togo,
								 atomv) == 0 and ret_len.value > 0:
		if debug:
			print "ret_type:", ret_type.value
			print "ret_format:", ret_format.value
			print "ret_len:", ret_len.value
			print "ret_togo:", ret_togo.value
		property = [atomv[i] for i in xrange(ret_len.value)]
	
	libx11.XCloseDisplay(x_display)
	
	return property