Example #1
0
	def run(self):
		self.xlock.acquire()
		# get X objects
		self.display = Xlib.display.Display(':0')
		display = self.display
		self.root = display.screen().root
		root = self.root

		if not display.has_extension("RANDR"):
			print "RANDR extension not found"
			sys.exit(1)

		display.query_extension('RANDR')
		if mplugd.verbose:
			r = display.xrandr_query_version()
			print "RANDR extension version %d.%d" % (r.major_version, r.minor_version)

		# set which types of events we want to receive
		root.xrandr_select_input(
			randr.RRScreenChangeNotifyMask
			| randr.RRCrtcChangeNotifyMask
			| randr.RROutputChangeNotifyMask
			| randr.RROutputPropertyNotifyMask
			)
		
		self.xlock.release()
		self.initflag.set()
		
		import time
		# enter event loop
		while not self.stop:
			for x in range(0, self.root.display.pending_events()):
				e = self.root.display.next_event()
				mp_ev = XMP_Event(self, e)
				self.queue.push(mp_ev)
			
			# TODO find something better
			time.sleep(1)
Example #2
0
import os
import getopt

from Xlib import X, display, protocol
from Xlib.ext import shape

global hasRun
hasRun = False

display = display.Display()
screen = display.screen()

screenResolution = screen.root.get_geometry()
screenResolution = [screenResolution.width, screenResolution.height]

if not display.has_extension("SHAPE"):  # Need X's shape extension
    sys.stderr.write("%s: X server has no SHAPE extension\n")
    sys.exit(1)


def create_window(
    bg_size, corners
):  # This function serves to create the window and pixmaps, but does not map them
    bg_size = bg_size  # Size of the corners in pixels
    bg_pm = screen.root.create_pixmap(bg_size, bg_size, screen.root_depth)
    bg_gc = screen.root.create_gc(foreground=screen.black_pixel,
                                  background=screen.black_pixel)
    bg_pm.fill_rectangle(bg_gc, 0, 0, bg_size, bg_size)

    window = screen.root.create_window(0,
                                       0,
            keyboardActivity = False
            sys.stdout.flush()
            time.sleep(1)


printThread = PrintThread()
printThread.daemon = True
printThread.start()


def callback(reply):
    global keyboardActivity
    keyboardActivity = True


if not display.has_extension("RECORD"):
    raise Exception("No RECORD extension")

context = display.record_create_context(
    0, [record.AllClients], [{
        'core_requests': (0, 0),
        'core_replies': (0, 0),
        'ext_requests': (0, 0, 0, 0),
        'ext_replies': (0, 0, 0, 0),
        'delivered_events': (0, 0),
        'device_events': (X.KeyPress, X.KeyPress),
        'errors': (0, 0),
        'client_started': False,
        'client_died': False,
    }])
            keyboardActivity = False
            sys.stdout.flush()
            time.sleep(1)


printThread = PrintThread()
printThread.daemon = True
printThread.start()


def callback(reply):
    global keyboardActivity
    keyboardActivity = True


if not display.has_extension("RECORD"):
    raise Exception("No RECORD extension")

context = display.record_create_context(
        0,
        [record.AllClients],
        [{
                'core_requests': (0, 0),
                'core_replies': (0, 0),
                'ext_requests': (0, 0, 0, 0),
                'ext_replies': (0, 0, 0, 0),
                'delivered_events': (0, 0),
                'device_events': (X.KeyPress, X.KeyPress),
                'errors': (0, 0),
                'client_started': False,
                'client_died': False,