diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-03-01 11:44:05 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-03-01 11:44:05 +0000 |
commit | 8e4f76c9b8bf323c4c748f8db8cb0f9ed61a649b (patch) | |
tree | c2b66437792d7639cc3df8517de8dcbbea32a65a | |
parent | 53c6afea2261f2665780ef3164f1da06f7f0f080 (diff) | |
download | drakx-8e4f76c9b8bf323c4c748f8db8cb0f9ed61a649b.tar drakx-8e4f76c9b8bf323c4c748f8db8cb0f9ed61a649b.tar.gz drakx-8e4f76c9b8bf323c4c748f8db8cb0f9ed61a649b.tar.bz2 drakx-8e4f76c9b8bf323c4c748f8db8cb0f9ed61a649b.tar.xz drakx-8e4f76c9b8bf323c4c748f8db8cb0f9ed61a649b.zip |
- sort the whole resolutions to simplify the code, and get better choices
- add a failsafe resolution
-rw-r--r-- | perl-install/Xconfig/resolution_and_depth.pm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm index 83df2fbed..f869368a0 100644 --- a/perl-install/Xconfig/resolution_and_depth.pm +++ b/perl-install/Xconfig/resolution_and_depth.pm @@ -143,6 +143,9 @@ sub choices { @resolutions = filter_using_HorizSync_VertRefresh($monitors->[0]{HorizSync}, $monitors->[0]{VertRefresh}, @resolutions) if $monitors->[0]{HorizSync}; @resolutions = filter_using_VideoRam($card->{VideoRam}, @resolutions) if $card->{VideoRam}; + #- sort it, so we can take the first one when we want the "best" + @resolutions = sort { $b->{X} <=> $a->{X} || $b->{Y} <=> $a->{Y} || $b->{Depth} <=> $a->{Depth} } @resolutions; + if ($resolution_wanted->{X} && !$resolution_wanted->{Y}) { #- assuming ratio 4/3 $resolution_wanted->{Y} = round($resolution_wanted->{X} * 3 / 4); @@ -168,12 +171,15 @@ sub choices { #- take the first available resolution <= the wanted resolution @matching = grep { $_->{X} < $resolution_wanted->{X} } @resolutions; } + if (!@matching) { + @matching = @resolutions; + } - my $max_Depth = max(map { $_->{Depth} } @matching); my $default_resolution; - foreach my $Depth ($resolution_wanted->{Depth}, $prefered_depth, $max_Depth) { - $default_resolution = find { $_->{Depth} eq $Depth } @matching and last; + foreach my $Depth ($resolution_wanted->{Depth}, $prefered_depth) { + $Depth and $default_resolution ||= find { $_->{Depth} eq $Depth } @matching; } + $default_resolution ||= $matching[0]; $default_resolution, @resolutions; } |