summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-03-22 15:02:41 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-03-22 15:02:41 +0000
commit5a25139340c132dd79469911a757e485a5544a75 (patch)
tree15dee420dfdbed88849e47e3ca04e11651d80311
parentc7739083bcfd4bcf7012c093a35da6a4e096649f (diff)
downloaddrakx-backup-do-not-use-5a25139340c132dd79469911a757e485a5544a75.tar
drakx-backup-do-not-use-5a25139340c132dd79469911a757e485a5544a75.tar.gz
drakx-backup-do-not-use-5a25139340c132dd79469911a757e485a5544a75.tar.bz2
drakx-backup-do-not-use-5a25139340c132dd79469911a757e485a5544a75.tar.xz
drakx-backup-do-not-use-5a25139340c132dd79469911a757e485a5544a75.zip
choose the default background best matching the resolution
-rw-r--r--perl-install/Xconfig/resolution_and_depth.pm31
1 files changed, 29 insertions, 2 deletions
diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm
index c23194d22..f41a722f1 100644
--- a/perl-install/Xconfig/resolution_and_depth.pm
+++ b/perl-install/Xconfig/resolution_and_depth.pm
@@ -203,7 +203,7 @@ sub configure {
} else {
$default_resolution = choose($in, $default_resolution, @resolutions) or return;
}
- $raw_X->set_resolution($default_resolution);
+ set_resolution($raw_X, $default_resolution);
$default_resolution;
}
@@ -219,11 +219,38 @@ sub configure_auto_install {
my ($default_resolution) = choices($raw_X, $resolution_wanted, $card, $monitors);
$default_resolution or die "you selected an unusable depth";
- $raw_X->set_resolution($default_resolution);
+ set_resolution($raw_X, $default_resolution);
$default_resolution;
}
+sub set_resolution {
+ my ($raw_X, $resolution) = @_;
+ $raw_X->set_resolution($resolution);
+ set_default_background($resolution);
+}
+sub set_default_background {
+ my ($resolution) = @_;
+
+ my $ratio = $resolution->{X} / $resolution->{Y};
+ my $dir = "$::prefix/usr/share/mdk/backgrounds";
+ my @l =
+ sort {
+ $a->[1] <=> $b->[1] || $b->[2] <=> $a->[2] || $a->[1] <=> $b->[1]
+ } map {
+ if (my ($X, $Y) = /^Mandrakelinux-(\d+)x(\d+).png$/) {
+ [
+ $_,
+ int(abs($ratio - $X / $Y) * 100), #- we want the nearest ratio (precision .01)
+ $X >= $resolution->{X}, #- then we don't want a resolution smaller
+ abs($X - $resolution->{X}), #- the nearest resolution
+ ];
+ } else { () }
+ } all($dir);
+
+ symlinkf $l[0][0], "$dir/default.png";
+}
+
sub resolution2ratio {
my ($resolution, $b_non_strict) = @_;
my $res = $resolution->{X} . 'x' . $resolution->{Y};