open-src/xserver/xorg/6535006.patch
author Henry Zhao <Henry.Zhao@Sun.COM>
Mon, 07 May 2007 17:53:20 -0700
changeset 154 ae2bd8710ae2
parent 140 fb0ff1642f9a
child 606 068c11b419c9
permissions -rw-r--r--
6540484: ast_drv.so in S10 U4 build3 and nv_60 will cause GUI garbled up 6554441: Need to fix these problems in 6535006.patch

--- hw/xfree86/common/xf86Mode.c.orig	Fri May  4 17:59:09 2007
+++ hw/xfree86/common/xf86Mode.c	Fri May  4 17:58:42 2007
@@ -1508,7 +1508,45 @@
 	virtX = virtualX;
 	virtY = virtualY;
 	scrp->virtualFrom = X_CONFIG;
-    } else if (!modeNames || !*modeNames) {
+    } 
+
+    if  ((modeNames == NULL) || (*modeNames == NULL)) {
+	if (UseDefaultRate) {
+	    modeNames = xnfcalloc(2, sizeof(char *));
+	    modeNames[0] = strdup("1024x768");
+	    modeNames[1] = NULL;
+	} else {
+	    char *mode_pref = NULL;
+	    const int types[] = {
+            	M_T_BUILTIN | M_T_PREFERRED,
+            	M_T_USERDEF | M_T_PREFERRED,
+            	M_T_DRIVER | M_T_PREFERRED
+		};
+	    const int ntypes = sizeof(types) / sizeof(int);
+	    int n, type;
+	    DisplayModePtr modes = scrp->modePool ? scrp->modePool : availModes;
+
+	    for (n = 0; n < ntypes; n++) {
+	        type = types[n];
+		
+	    	for (p = modes;  p != NULL;  p = p->next) {
+	    	    if ((p->type & type) == type) {
+		    	mode_pref = strdup(p->name);
+		    	break;
+	    	    }
+	    	}
+	    	if (mode_pref)
+		    break;
+	    }
+	    if (mode_pref) {
+	    	modeNames = xnfcalloc(2, sizeof(char *));
+	    	modeNames[0] = strdup(mode_pref);
+	    	modeNames[1] = NULL;
+	    }
+	}
+    }
+
+    if ((virtualY <= 0) && (!modeNames || !*modeNames)) {
 	/* No virtual size given in the config, try to infer */
 	/* XXX this doesn't take m{in,ax}Pitch into account; oh well */
 	inferred_virtual = inferVirtualSize(scrp, availModes, &virtX, &virtY);
@@ -1593,12 +1631,7 @@
 	xf86DeleteMode(&scrp->modes, scrp->modes);
     endp = &scrp->modes;
     last = NULL;
-    if (UseDefaultRate && ((modeNames == NULL) || (*modeNames == NULL))) {
-	modeNames = xnfcalloc(2, sizeof(char *));
-	modeNames[0] = strdup("1024x768");
-	modeNames[1] = NULL;
-    }
-    if (modeNames != NULL) {
+    if ((modeNames != NULL) && (*modeNames != NULL)) {
 	for (i = 0; modeNames[i] != NULL; i++) {
 	    userModes = TRUE;
 	    new = xnfcalloc(1, sizeof(DisplayModeRec));