Blob Blame Raw
diff -Naur disper/src/xrandr/__init__.py disper-new/src/xrandr/__init__.py
--- disper/src/xrandr/__init__.py	2011-09-09 16:20:45.000000000 +0200
+++ disper-new/src/xrandr/__init__.py	2016-07-28 15:33:34.391703460 +0200
@@ -83,10 +83,20 @@
 
 from core import Screen, xlib, rr
 
+xopendisplay = None
+class Display(Structure): pass
+
+def get_display(name):
+    global xopendisplay
+    if xopendisplay is None:
+        xopendisplay = xlib.XOpenDisplay
+        xopendisplay.restype = POINTER(Display)
+    return xopendisplay(name)
+
 def get_current_display():
     """Returns the currently used display"""
     display_url = os.getenv("DISPLAY")
-    dpy = xlib.XOpenDisplay(display_url)
+    dpy = get_display(display_url)
     return dpy
 
 def get_current_screen():
@@ -98,7 +108,7 @@
 
 def get_screen_of_display(display, count):
     """Returns the screen of the given display"""
-    dpy = xlib.XOpenDisplay(display)
+    dpy = get_display(display)
     return Screen(dpy, count)
 
 def get_version():