File bug-507190_xorg-x11-server-bnc381139-randr-reprobe-on-unsuspend.diff of Package xorg-x11-server

Index: xorg-server-1.6.3.901/hw/xfree86/modes/xf86RandR12.c
===================================================================
--- xorg-server-1.6.3.901.orig/hw/xfree86/modes/xf86RandR12.c
+++ xorg-server-1.6.3.901/hw/xfree86/modes/xf86RandR12.c
@@ -55,6 +55,13 @@ typedef struct _xf86RandR12Info {
     int				    pointerY;
     Rotation			    rotation; /* current mode */
     Rotation                        supported_rotations; /* driver supported */
+
+    /* Used to wrap EnterVT so we can re-probe the outputs when a laptop unsuspends
+     * (actually, any time that we switch back into our VT).
+     *
+     * See https://bugs.freedesktop.org/show_bug.cgi?id=21554
+     */
+    xf86EnterVTProc *orig_EnterVT;
 } XF86RandRInfoRec, *XF86RandRInfoPtr;
 
 #ifdef RANDR_12_INTERFACE
@@ -1648,10 +1655,25 @@ xf86RandR13SetPanning (ScreenPtr
 }
 
 static Bool
+xf86RandR12EnterVT (int screen_index, int flags)
+{
+    ScreenPtr        pScreen = screenInfo.screens[screen_index];
+    XF86RandRInfoPtr randrp  = XF86RANDRINFO(pScreen);
+
+    if (randrp->orig_EnterVT) {
+	if (!randrp->orig_EnterVT (screen_index, flags))
+	    return FALSE;
+    }
+
+    return RRGetInfo (pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
+}
+
+static Bool
 xf86RandR12Init12 (ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
     rrScrPrivPtr	rp = rrGetScrPriv(pScreen);
+    XF86RandRInfoPtr	randrp  = XF86RANDRINFO(pScreen);
 
     rp->rrGetInfo = xf86RandR12GetInfo12;
     rp->rrScreenSetSize = xf86RandR12ScreenSetSize;
@@ -1667,6 +1689,10 @@ xf86RandR12Init12 (ScreenPtr pScreen)
     rp->rrModeDestroy = xf86RandR12ModeDestroy;
     rp->rrSetConfig = NULL;
     pScrn->PointerMoved = xf86RandR12PointerMoved;
+
+    randrp->orig_EnterVT = pScrn->EnterVT;
+    pScrn->EnterVT = xf86RandR12EnterVT;
+
     if (!xf86RandR12CreateObjects12 (pScreen))
 	return FALSE;
 
openSUSE Build Service is sponsored by