miext/sync: Fix multi-screen support in SyncFence initialization
authorKeith Packard <keithp@keithp.com>
Wed, 24 Apr 2013 21:58:27 +0000 (14:58 -0700)
committerAdam Jackson <ajax@redhat.com>
Tue, 10 Sep 2013 17:26:25 +0000 (13:26 -0400)
miSyncSetup was checking to see if the screen private key had been
registered, and if so, skipping the setup of the provided screen.

Instead, it should register the private index only once, but then
initialize the screen unless it has already been initialized. This
latter step allows drivers to initialize the sync private structures
before the Sync extension itself is initialized.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
miext/sync/misync.c

index d24921a..b6914d1 100644 (file)
@@ -182,20 +182,21 @@ miSyncSetup(ScreenPtr pScreen)
         &miSyncScreenDestroyFence
     };
 
-    if (dixPrivateKeyRegistered(syncScreenPrivateKey))
-        return TRUE;
-
-    if (!dixRegisterPrivateKey(syncScreenPrivateKey, PRIVATE_SCREEN,
-                               sizeof(SyncScreenPrivRec)))
-        return FALSE;
+    if (!dixPrivateKeyRegistered(syncScreenPrivateKey)) {
+        if (!dixRegisterPrivateKey(syncScreenPrivateKey, PRIVATE_SCREEN,
+                                   sizeof(SyncScreenPrivRec)))
+            return FALSE;
+    }
 
     pScreenPriv = SYNC_SCREEN_PRIV(pScreen);
 
-    pScreenPriv->funcs = miSyncScreenFuncs;
+    if (pScreenPriv->funcs.CreateFence) {
+        pScreenPriv->funcs = miSyncScreenFuncs;
 
-    /* Wrap CloseScreen to clean up */
-    pScreenPriv->CloseScreen = pScreen->CloseScreen;
-    pScreen->CloseScreen = SyncCloseScreen;
+        /* Wrap CloseScreen to clean up */
+        pScreenPriv->CloseScreen = pScreen->CloseScreen;
+        pScreen->CloseScreen = SyncCloseScreen;
+    }
 
     return TRUE;
 }