File bug524724-defaultModesForLowerSizeOnly.patch of Package xorg-x11-server

Index: xorg-server-1.5.2/hw/xfree86/modes/xf86Crtc.c
===================================================================
--- xorg-server-1.5.2.orig/hw/xfree86/modes/xf86Crtc.c
+++ xorg-server-1.5.2/hw/xfree86/modes/xf86Crtc.c
@@ -1418,6 +1418,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn,
 	int		    max_clock = 0;
 	double		    clock;
 	enum { sync_config, sync_edid, sync_default } sync_source = sync_default;
+	int		    maxMonX = 0, maxMonY = 0;
 	
 	while (output->probed_modes != NULL)
 	    xf86DeleteMode(&output->probed_modes, output->probed_modes);
@@ -1554,6 +1555,28 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn,
 	    xf86ValidateModesClocks(scrn, output_modes,
 				    &min_clock, &max_clock, 1);
 	}
+	/*
+	 * Get monitor resolution.
+	 * This is an approximation: get the biggest supported mode
+	 */
+	if (output_modes)
+	    for (mode = output_modes; mode != NULL; mode = mode->next) {
+		if (mode->HDisplay > maxMonX)
+		    maxMonX = mode->HDisplay;
+		if (mode->VDisplay > maxMonY)
+		    maxMonY = mode->VDisplay;
+		if (mode->next == output_modes)
+		    break;
+	    }
+	if (config_modes)
+	    for (mode = config_modes; mode != NULL; mode = mode->next) {
+		if (mode->HDisplay > maxMonX)
+		    maxMonX = mode->HDisplay;
+		if (mode->VDisplay > maxMonY)
+		    maxMonY = mode->VDisplay;
+		if (mode->next == config_modes)
+		    break;
+	    }
 	
 	output->probed_modes = NULL;
 	output->probed_modes = xf86ModesAdd (output->probed_modes, config_modes);
@@ -1561,6 +1584,13 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn,
 	output->probed_modes = xf86ModesAdd (output->probed_modes, default_modes);
 	
 	/*
+	 * Only allow modes lower than max monitor resolution
+	 */
+	if (maxMonX && maxMonY)
+	    xf86ValidateModesSize (scrn, output->probed_modes,
+				       maxMonX, maxMonY, 0);
+	
+	/*
 	 * Check all modes against max size
 	 */
 	if (maxX && maxY)
openSUSE Build Service is sponsored by