From 748e43ac03172adf9bd27d43dd53df762470353c Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sun, 28 Jul 2002 22:06:15 +0000 Subject: thou hast served well, you may now lie in peace --- perl-install/Xconfig.pm | 329 -------- perl-install/Xconfigurator.pm | 1407 ---------------------------------- perl-install/Xconfigurator_consts.pm | 366 --------- 3 files changed, 2102 deletions(-) delete mode 100644 perl-install/Xconfig.pm delete mode 100644 perl-install/Xconfigurator.pm delete mode 100644 perl-install/Xconfigurator_consts.pm (limited to 'perl-install') diff --git a/perl-install/Xconfig.pm b/perl-install/Xconfig.pm deleted file mode 100644 index 0e08af34a..000000000 --- a/perl-install/Xconfig.pm +++ /dev/null @@ -1,329 +0,0 @@ -package Xconfig; # $Id$ - -use diagnostics; -use strict; - -use any; -use log; -use common; -use mouse; -use devices; -use keyboard; -use Xconfigurator_consts; - - -sub keyboard_from_kmap { - my ($loadkey) = @_; - foreach (keyboard::keyboards()) { - keyboard::keyboard2kmap($_) eq $loadkey and return keyboard::keyboard2xkb($_); - } - ''; -} - - -sub info { - my ($X) = @_; - my $info; - my $xf_ver = $X->{card}{driver} && !$X->{card}{prefer_xf3} ? "4.2.0" : "3.3.6"; - my $title = ($X->{card}{use_DRI_GLX} || $X->{card}{use_UTAH_GLX} ? - _("XFree %s with 3D hardware acceleration", $xf_ver) : _("XFree %s", $xf_ver)); - - $info .= _("Keyboard layout: %s\n", $X->{keyboard}{XkbLayout}); - $info .= _("Mouse type: %s\n", $X->{mouse}{XMOUSETYPE}); - $info .= _("Mouse device: %s\n", $X->{mouse}{device}) if $::expert; - $info .= _("Monitor: %s\n", $X->{monitor}{ModelName}); - $info .= _("Monitor HorizSync: %s\n", $X->{monitor}{hsyncrange}) if $::expert; - $info .= _("Monitor VertRefresh: %s\n", $X->{monitor}{vsyncrange}) if $::expert; - $info .= _("Graphics card: %s\n", $X->{card}{VendorName} . ' '. $X->{card}{BoardName}); - $info .= _("Graphics card identification: %s\n", $X->{card}{identifier}) if $::expert; - $info .= _("Graphics memory: %s kB\n", $X->{card}{VideoRam}) if $X->{card}{VideoRam}; - if ($X->{default_depth} and my $depth = $X->{card}{depth}{$X->{default_depth}}) { - $info .= _("Color depth: %s\n", translate($Xconfigurator_consts::depths{$X->{default_depth}})); - $info .= _("Resolution: %s\n", join "x", @{$depth->[0]}) if $depth && !is_empty_array_ref($depth->[0]); - } - $info .= _("XFree86 server: %s\n", $X->{card}{server}) if $X->{card}{server}; - $info .= _("XFree86 driver: %s\n", $X->{card}{driver}) if $X->{card}{driver}; - "$title\n\n$info"; -} - -sub getinfo { - my $X = shift || {}; - getinfoFromDDC($X); - getinfoFromSysconfig($X); - - my ($mouse) = mouse::detect(); - add2hash($X->{mouse}, $mouse) if !$X->{mouse}{XMOUSETYPE}; - add2hash($X->{mouse}{auxmouse}, $mouse->{auxmouse}) if !$X->{mouse}{auxmouse}{XMOUSETYPE}; - $X->{mouse}{auxmouse}{XMOUSETYPE} or delete $X->{mouse}{auxmouse}; - - $X->{mouse}{device} ||= "mouse" if -e "/dev/mouse"; - $X; -} - -sub getinfoFromXF86Config { - my ($X, $prefix) = @_; #- original $::o->{X} which must be changed only if sure! - $X ||= {}; - - #- don't keep the preference on upgrades?? - $X->{card}{prefer_xf3} = readlink("$::prefix/etc/X11/X") =~ /XF86_/ if $::isStandalone; - - my (%keyboard, %mouse, %wacom, %card, %monitor); - my (%c, $depth); - - foreach (cat_("$prefix/etc/X11/XF86Config-4")) { - if (my $i = /^Section "InputDevice"/ .. /^EndSection/) { - %c = () if $i == 1; - - $c{driver} = $1 if /^\s*Driver\s+"(.*?)"/; - $c{id} = $1 if /^\s*Identifier\s+"[^\d"]*(\d*)"/; - $c{XkbModel} ||= $1 if /^\s*Option\s+"XkbModel"\s+"(.*?)"/; - $c{XkbLayout} ||= $1 if /^\s*Option\s+"XkbLayout"\s+"(.*?)"/; - $c{XMOUSETYPE} ||= $1 if /^\s*Option\s+"Protocol"\s+"(.*?)"/; - $c{device} ||= $1 if /^\s*Option\s+"Device"\s+"\/dev\/(.*?)"/; - $c{nbuttons} = 2 if /^\s*Option\s+"Emulate3Buttons"\s+/; - $c{nbuttons} ||= 5 if /^\s*#\s*Option\s+"ZAxisMapping"\s.*5/; - $c{nbuttons} = 7 if /^\s*#\s*Option\s+"ZAxisMapping"\s.*7/; - - if ($i =~ /E0/) { - @keyboard{qw(XkbLayout)} = @c{qw(XkbLayout)} - if $c{driver} =~ /keyboard/i; - @{$mouse{auxmouse}}{qw(XMOUSETYPE device nbuttons)} = @c{qw(XMOUSETYPE device nbuttons)} - if $c{driver} =~ /mouse/i && $c{id} > 1; - @mouse{qw(XMOUSETYPE device nbuttons)} = @c{qw(XMOUSETYPE device nbuttons)} - if $c{driver} =~ /mouse/i && $c{id} < 1; - $wacom{$c{device}} = undef - if $c{driver} =~ /wacom/i; - } - } elsif (/^Section "Monitor"/ .. /^EndSection/) { - $monitor{hsyncrange} ||= $1 if /^\s*HorizSync\s+(.*)/; - $monitor{vsyncrange} ||= $1 if /^\s*VertRefresh\s+(.*)/; - $monitor{VendorName} ||= $1 if /^\s*VendorName\s+"(.*?)"/; - $monitor{ModelName} ||= $1 if /^\s*ModelName\s+"(.*?)"/; - $monitor{ModeLines} .= $_ if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+/; - } elsif (my $s = /^Section "Screen"/ .. /^EndSection/) { - $card{default_depth} ||= $1 if /^\s*DefaultColorDepth\s+(\d+)/; - if (my $i = /^\s*Subsection\s+"Display"/ .. /^\s*EndSubsection/) { - undef $depth if $i == 1; - $depth = $1 if /^\s*Depth\s+(\d*)/; - if (/^\s*Modes\s+(.*)/) { - my $a = 0; - unshift @{$card{depth}{$depth || 8} ||= []}, #- insert at the beginning for resolution_wanted! - grep { $_->[0] >= 640 } map { [ /"(\d+)x(\d+)"/ ] } split ' ', $1; - } - } - } - } - my $first_screen_section; - foreach (cat_("$prefix/etc/X11/XF86Config")) { - if (/^Section "Keyboard"/ .. /^EndSection/) { - $keyboard{XkbModel} ||= $1 if /^\s*XkbModel\s+"(.*?)"/; - $keyboard{XkbLayout} ||= $1 if /^\s*XkbLayout\s+"(.*?)"/; - } elsif (/^Section "Pointer"/ .. /^EndSection/) { - $mouse{XMOUSETYPE} ||= $1 if /^\s*Protocol\s+"(.*?)"/; - $mouse{device} ||= $1 if m|^\s*Device\s+"/dev/(.*?)"|; - $mouse{nbuttons} = 2 if m/^\s*Emulate3Buttons\s+/; - $mouse{nbuttons} ||= 5 if m/^\s*ZAxisMapping\s.*5/; - $mouse{nbuttons} = 7 if m/^\s*ZAxisMapping\s.*7/; - } elsif (/^Section "XInput"/ .. /^EndSection/) { - if (/^\s*SubSection "Wacom/ .. /^\s*EndSubSection/) { - $wacom{$1} = undef if /^\s*Port\s+"\/dev\/(.*?)"/; - } - } elsif (/^Section "Monitor"/ .. /^EndSection/) { - $monitor{hsyncrange} ||= $1 if /^\s*HorizSync\s+(.*)/; - $monitor{vsyncrange} ||= $1 if /^\s*VertRefresh\s+(.*)/; - $monitor{VendorName} ||= $1 if /^\s*VendorName\s+"(.*?)"/; - $monitor{ModelName} ||= $1 if /^\s*ModelName\s+"(.*?)"/; - $monitor{ModeLines_xf3} .= $_ if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+/; - } elsif (my $i = /^Section "Device"/ .. /^EndSection/) { - %c = () if $i == 1; - - $c{indentifier} ||= $1 if /^\s*Identifier\s+"(.*?)"/; - $c{VideoRam} ||= $1 if /VideoRam\s+(\d+)/; - $c{needVideoRam} ||= 1 if /^\s*VideoRam\s+/; - $c{driver} ||= $1 if /^\s*Driver\s+"(.*?)"/; - $c{VendorName} ||= $1 if /^\s*VendorName\s+"(.*?)"/; - $c{BoardName} ||= $1 if /^\s*BoardName\s+"(.*?)"/; - $c{Chipset} ||= $1 if /^\s*Chipset\s+"(.*?)"/; - $c{options_xf3}{$1} ||= 0 if /^\s*#\s*Option\s+"(.*?)"/; - $c{options_xf3}{$1} ||= 1 if /^\s*Option\s+"(.*?)"/; - - add2hash(\%card, \%c) if ($i =~ /E0/ && $c{identifier} && $c{identifier} ne "Generic VGA"); - } elsif (my $s = /^Section "Screen"/ .. /^EndSection/) { - $first_screen_section++ if $s =~ /E0/; - $first_screen_section or next; - - $card{default_depth} ||= $1 if /^\s*DefaultColorDepth\s+(\d+)/; - if (my $i = /^\s*Subsection\s+"Display"/ .. /^\s*EndSubsection/) { - undef $depth if $i == 1; - $depth = $1 if /^\s*Depth\s+(\d*)/; - if (/^\s*Modes\s+(.*)/) { - my $a = 0; - unshift @{$card{depth}{$depth || 8} ||= []}, #- insert at the beginning for resolution_wanted! - grep { $_->[0] >= 640 } map { [ /"(\d+)x(\d+)"/ ] } split ' ', $1; - } - } - } - } - - #- get the default resolution according the the current file. - #- suggestion to take into account, but that have to be checked. - $X->{card}{suggest_depth} = $card{default_depth}; - if (my @depth = keys %{$card{depth}}) { - $X->{card}{suggest_x_res} = ($card{depth}{$X->{card}{suggest_depth} || $depth[0]}[0][0]); - } - - #- final clean-up. - $mouse{nbuttons} ||= 3; #- when no tag found, this is because there is 3 buttons. - $mouse{auxmouse}{nbuttons} ||= 3; - mouse::update_type_name(\%mouse); #- allow getting fullname (type|name). - mouse::update_type_name($mouse{auxmouse}); - delete $mouse{auxmouse} if !$mouse{auxmouse}{XMOUSETYPE}; #- only take care of a true mouse. - - #- try to merge with $X, the previous has been obtained by ddcxinfos. - put_in_hash($X->{keyboard} ||= {}, \%keyboard); - add2hash($X->{mouse} ||= {}, \%mouse); - @{$X->{wacom} || []} > 0 or $X->{wacom} = [ keys %wacom ]; - add2hash($X->{monitor} ||= {}, \%monitor); - - $X; -} - -sub getinfoFromSysconfig { - my $X = shift || {}; - my $prefix = shift || ""; - - add2hash($X->{mouse} ||= {}, { getVarsFromSh("$prefix/etc/sysconfig/mouse") }); - - if (my %keyboard = getVarsFromSh "$prefix/etc/sysconfig/keyboard") { - $X->{keyboard}{XkbLayout} ||= keyboard_from_kmap($keyboard{KEYTABLE}) if $keyboard{KEYTABLE}; - } - $X; -} - -sub getinfoFromDDC { - my $X = shift || {}; - my $O = $X->{monitor} ||= {}; - #- return $X if $O->{hsyncrange} && $O->{vsyncrange} && $O->{ModeLines}; - my ($m, @l) = any::ddcxinfos(); - $? == 0 or return $X; - - $X->{card}{VideoRam} ||= to_int($m); - local $_; - while (($_ = shift @l) ne "\n") { - my ($depth, $x, $y) = split; - $depth = int(log($depth) / log(2)); - if ($depth >= 8 && $x >= 640) { - push @{$X->{card}{depth}{$depth}}, [ $x, $y ] - if ! grep { $_->[0] == $x && $_->[1] == $y } @{$X->{card}{depth}{$depth}}; - push @{$X->{card}{depth}{32}}, [ $x, $y ] - if $depth == 24 && ! grep { $_->[0] == $x && $_->[1] == $y } @{$X->{card}{depth}{32}}; - } - } - my ($h, $v, $size, @m) = @l; - - $O->{hsyncrange} ||= first($h =~ /^(\S*)/); - $O->{vsyncrange} ||= first($v =~ /^(\S*)/); - $O->{size} ||= to_float($size); - $O->{EISA_ID} = lc($1) if $size =~ /EISA ID=(\S*)/; - $O->{ModeLines_xf3} ||= join '', map { " $_" } @m; - $X; -} - - -sub XF86check_link { - my ($prefix, $ext) = @_; - - my $f = "$prefix/etc/X11/XF86Config$ext"; - touch($f); - - my $l = "$prefix/usr/X11R6/lib/X11/XF86Config$ext"; - - if (-e $l && (stat($f))[1] != (stat($l))[1]) { #- compare the inode, must be the sames - -e $l and unlink($l) || die "can't remove bad $l"; - symlinkf "../../../../etc/X11/XF86Config$ext", $l; - } -} - -sub add2card { - my ($card, $other_card) = @_; - - push @{$card->{lines}}, @{$other_card->{lines} || []}; - add2hash($card, $other_card); -} - -sub readCardsDB { - my ($file) = @_; - my ($card, %cards); - - my $F = common::openFileMaybeCompressed($file); - - my ($lineno, $cmd, $val) = 0; - my $fs = { - NAME => sub { - $cards{$card->{card_name}} = $card if $card; - $card = { card_name => $val }; - }, - SEE => sub { - my $c = $cards{$val} or die "Error in database, invalid reference $val at line $lineno"; - add2card($card, $c); - }, - LINE => sub { push @{$card->{lines}}, $val }, - CHIPSET => sub { $card->{Chipset} = $val }, - SERVER => sub { $card->{server} = $val }, - DRIVER => sub { $card->{driver} = $val }, - DRIVER2 => sub { $card->{driver2} = $val }, - NEEDVIDEORAM => sub { $card->{needVideoRam} = 1 }, - DRI_GLX => sub { $card->{DRI_GLX} = 1 if $card->{driver} }, - UTAH_GLX => sub { $card->{UTAH_GLX} = 1 if $card->{server} }, - DRI_GLX_EXPERIMENTAL => sub { $card->{DRI_GLX_EXPERIMENTAL} = 1 if $card->{driver} }, - UTAH_GLX_EXPERIMENTAL => sub { $card->{UTAH_GLX_EXPERIMENTAL} = 1 if $card->{server} }, - MULTI_HEAD => sub { $card->{MULTI_HEAD} = $val if $card->{driver} }, - BAD_FB_RESTORE => sub { $card->{BAD_FB_RESTORE} = 1 }, - BAD_FB_RESTORE_XF3 => sub { $card->{BAD_FB_RESTORE_XF3} = 1 }, - UNSUPPORTED => sub { delete $card->{driver} }, - - COMMENT => sub {}, - }; - - local $_; - while (<$F>) { $lineno++; - s/\s+$//; - /^#/ and next; - /^$/ and next; - /^END/ and do { $cards{$card->{card_name}} = $card if $card; last }; - - ($cmd, $val) = /(\S+)\s*(.*)/ or next; - - my $f = $fs->{$cmd}; - - $f ? $f->() : log::l("unknown line $lineno ($_)"); - } - \%cards; -} - -sub install_matrox_proprietary_hal { - my ($prefix) = @_; - my $tmpdir = "$prefix/root/tmp"; - - my $tar = "mgadrivers-2.0.tgz"; - my $dir_in_tar = "mgadrivers"; - my $dest_dir = "$prefix/usr/X11R6/lib/modules/drivers"; - - #- already installed - return if -e "$dest_dir/mga_hal_drv.o"; - - system("wget -O $tmpdir/$tar ftp://ftp.matrox.com/pub/mga/archive/linux/2002/$tar") if !-e "$tmpdir/$tar"; - system("tar xzC $tmpdir -f $tmpdir/$tar"); - - my $src_dir = "$tmpdir/$dir_in_tar/xfree86/4.2.0/drivers"; - foreach (all($src_dir)) { - my $src = "$src_dir/$_"; - my $dest = "$dest_dir/$_"; - rename $dest, "$dest.non_hal"; - cp_af($src, $dest_dir); - } - rm_rf("$tmpdir/$tar"); - rm_rf("$tmpdir/$dir_in_tar"); -} - -1; diff --git a/perl-install/Xconfigurator.pm b/perl-install/Xconfigurator.pm deleted file mode 100644 index 5e6fb981e..000000000 --- a/perl-install/Xconfigurator.pm +++ /dev/null @@ -1,1407 +0,0 @@ -package Xconfigurator; # $Id$ - -use diagnostics; -use strict; -use vars; - -use common; -use log; -use detect_devices; -use run_program; -use Xconfigurator_consts; -use Xconfig; -use any; -use modules; - -my $tmpconfig = "/tmp/Xconfig"; -my $force_xf4 = arch() =~ /ppc|ia64/; - - -sub xtest { - my ($display) = @_; - $::isStandalone ? - system("DISPLAY=$display /usr/X11R6/bin/xtest") == 0 : - c::Xtest($display); -} - -sub using_xf4 { - my ($card) = @_; - $card->{driver} && !$card->{prefer_xf3}; -} - -sub add_to_card__using_Cards { - my ($card, $name) = @_; - my $cards = Xconfig::readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+"); - Xconfig::add2card($card, $cards->{$name}); - - delete @$card{'server'} if $force_xf4; - - delete @$card{'UTAH_GLX', 'UTAH_GLX_EXPERIMENTAL'} - if $force_xf4 || availableRamMB() > 800; #- no Utah GLX if more than 800 Mb (server, or kernel-enterprise, Utha GLX does not work with latest). - - $card->{prefer_xf3} = 1 if $card->{driver} eq 'neomagic' && !$force_xf4; - - $card; -} - -sub readMonitorsDB { - my ($file) = @_; - - my (%monitors, %standard_monitors); - - my $F = common::openFileMaybeCompressed($file); - local $_; - my $lineno = 0; while (<$F>) { - $lineno++; - s/\s+$//; - /^#/ and next; - /^$/ and next; - - my @fields = qw(VendorName ModelName EISA_ID hsyncrange vsyncrange dpms); - my @l = split /\s*;\s*/; - - my %l; @l{@fields} = @l; - if ($monitors{$l{ModelName}}) { - my $i; for ($i = 0; $monitors{"$l{ModelName} ($i)"}; $i++) {} - $l{ModelName} = "$l{ModelName} ($i)"; - } - $monitors{"$l{VendorName}|$l{ModelName}"} = \%l; - } - \%monitors; -} - -sub keepOnlyLegalModes { - my ($card, $monitor) = @_; - my $mem = 1024 * ($card->{VideoRam} || ($card->{server} eq 'FBDev' ? 2048 : 32768)); #- limit to 2048x1536x64 - my $hsync = max(split(/[,-]/, $monitor->{hsyncrange})); - - while (my ($depth, $res) = each %{$card->{depth}}) { - @$res = grep { - $mem >= product(@$_, $depth / 8) && - $hsync >= ($Xconfigurator_consts::min_hsync4x_res{$_->[0]} || 0) && - ($card->{server} ne 'FBDev' || (Xconfigurator_consts::bios_vga_modes($_->[0], $depth))[2] == $_->[1]) - } @$res; - delete $card->{depth}{$depth} if @$res == 0; - } -} - -sub probe_cards() { -#-for Pixel tests -#- my @c = { driver => 'Card:Matrox Millennium G400 DualHead', description => 'Matrox|Millennium G400 Dual HeadCard' }; - my @c = grep { $_->{driver} =~ /(Card|Server|Driver):/ } detect_devices::probeall(); - - my @cards = map { - my @l = $_->{description} =~ /(.*?)\|(.*)/; - my $card = { - description => $_->{description}, - VendorName => $l[0], BoardName => $l[1], - busid => "PCI:$_->{pci_bus}:$_->{pci_device}:$_->{pci_function}", - }; - if ($_->{driver} =~ /Card:(.*)/) { add_to_card__using_Cards($card, $1) } - elsif ($_->{driver} =~ /Server:(.*)/) { $card->{server} = $1 } - elsif ($_->{driver} =~ /Driver:(.*)/) { $card->{driver} = $1 } - else { internal_error() } - - $card; - } @c; - - if (@cards >= 2 && $cards[0]{card_name} eq $cards[1]{card_name} && $cards[0]{card_name} eq 'Intel 830') { - shift @cards; - } - #- take a default on sparc if nothing has been found. - if (arch() =~ /^sparc/ && !@cards) { - log::l("Using probe with /proc/fb as nothing has been found!"); - local $_ = cat_("/proc/fb"); - @cards = { server => /Mach64/ ? "Mach64" : /Permedia2/ ? "3DLabs" : "Sun24" }; - } - - #- disabling MULTI_HEAD when not available - foreach (@cards) { - $_->{MULTI_HEAD} && $_->{card_name} =~ /G[24]00/ or next; - if ($ENV{MATROX_HAL}) { - $_->{need_MATROX_HAL} = 1; - } else { - delete $_->{MULTI_HEAD}; - } - } - - #- in case of only one cards, remove all busid reference, this will avoid - #- need of change of it if the card is moved. - #- on many PPC machines, card is on-board, busid is important, leave? - if (@cards == 1 && arch() !~ /ppc/) { - delete $cards[0]{busid}; - } - - @cards; -} - -sub install_server { - my ($card, $cardOptions, $do_pkgs) = @_; - - my $prog = "/usr/X11R6/bin/" . - (using_xf4($card) ? 'XFree86' : - $card->{server} =~ /Sun(.*)/ ? "Xsun$1" : - $card->{server} eq 'Xpmac' ? 'Xpmac' : - "XF86_$card->{server}"); - - my @packages = (); - push @packages, using_xf4($card) ? 'XFree86-server' : "XFree86-$card->{server}" if ! -x "$::prefix$prog"; - - #- additional packages to install according available card. - #- add XFree86-libs-DRI here if using DRI (future split of XFree86 TODO) - if ($card->{use_DRI_GLX}) { - push @packages, 'Glide_V5' if $card->{card_name} eq 'Voodoo5 (generic)'; - push @packages, 'Glide_V3-DRI' if member($card->{card_name}, 'Voodoo3 (generic)', 'Voodoo Banshee (generic)'); - push @packages, 'XFree86-glide-module' if $card->{card_name} =~ /Voodoo/; - } - if ($card->{use_UTAH_GLX}) { - push @packages, 'Mesa'; - } - #- 3D acceleration configuration for XFree 4 using NVIDIA driver (TNT, TN2 and GeForce cards only). - push @packages, @{$cardOptions->{allowNVIDIA_rpms}} if $card->{driver2} eq 'nvidia' && $cardOptions->{allowNVIDIA_rpms}; - - $do_pkgs->install(@packages) if @packages; - -x "$::prefix$prog" or die "server $card->{server} is not available (should be in $::prefix$prog)"; - - #- make sure everything is correct at this point, packages have really been installed - #- and driver and GLX extension is present. - if ($card->{driver2} eq 'nvidia' && - -e "$::prefix/usr/X11R6/lib/modules/drivers/nvidia_drv.o" && - -e "$::prefix/usr/X11R6/lib/modules/extensions/libglx.so") { - log::l("Using specific NVIDIA driver and GLX extensions"); - $card->{driver} = 'nvidia'; - } - - Xconfig::install_matrox_proprietary_hal($::prefix) if $card->{need_MATROX_HAL}; - - $prog; -} - -sub multi_head_choices { - my (@cards) = @_; - my @choices; - - my $has_multi_head = @cards > 1 || $cards[0]{MULTI_HEAD} > 1; - my $disable_multi_head = grep { - $_->{driver} or log::l("found card $_->{description} not supported by XF4, disabling multi-head support"); - !$_->{driver}; - } @cards; - - if ($has_multi_head && !$disable_multi_head) { - my $configure_multi_head = sub { - - #- special case for multi head card using only one busid. - @cards = map { - map_index { { screen => $::i, %$_ } } ($_) x ($_->{MULTI_HEAD} || 1); - } @cards; - - delete $_->{server} foreach @cards; #- XFree 3 doesn't handle multi head (?) - my $card = shift @cards; #- assume good default. - $card->{cards} = \@cards; - $card->{Xinerama} = $_[0]; - $card; - }; - push @choices, { text => _("Configure all heads independently"), code => sub { $configure_multi_head->('') } }; - push @choices, { text => _("Use Xinerama extension"), code => sub { $configure_multi_head->(1) } }; - } - - foreach my $c (@cards) { - push @choices, { text => _("Configure only card \"%s\"%s", $c->{description}, $c->{busid} && " ($c->{busid})"), - code => sub { $c } }; - } - @choices; -} - -sub multi_head_choose { - my ($in, $noauto, @cards) = @_; - - my @choices = multi_head_choices(@cards); - - my $tc = $in->ask_from_listf(_("Multi-head configuration"), - _("Your system support multiple head configuration. -What do you want to do?"), sub { $_[0]{text} }, \@choices) or return; - - $tc->{code} or die internal_error(); - return $tc->{code}(); -} - -sub xfree_and_glx_choices { - my ($card) = @_; - - #- XFree version available, better to parse available package and get version from it. - my ($xf4_ver, $xf3_ver) = ('4.2.0', '3.3.6'); - - my @choices = do { - #- basic installation, use of XFree 4.2 or XFree 3.3. - my $xf3 = { text => _("XFree %s", $xf4_ver), code => sub { $card->{prefer_xf3} = 0 } }; - my $xf4 = { text => _("XFree %s", $xf3_ver), code => sub { $card->{prefer_xf3} = 1 } }; - $card->{prefer_xf3} ? ($xf3, $xf4) : ($xf4, $xf3); - }; - - #- try to figure if 3D acceleration is supported - #- by XFree 3.3 but not XFree 4 then ask user to keep XFree 3.3 ? - if ($card->{UTAH_GLX}) { - unshift @choices, { text => _("XFree %s with 3D hardware acceleration", $xf3_ver), - code => sub { $card->{prefer_xf3} = 1; $card->{use_UTAH_GLX} = 1 }, - more_messages => ($card->{driver} && !$card->{DRI_GLX} ? -_("Your card can have 3D hardware acceleration support but only with XFree %s. -Your card is supported by XFree %s which may have a better support in 2D.", $xf3_ver, $xf4_ver) : -_("Your card can have 3D hardware acceleration support with XFree %s.", $xf3_ver)), - }; - } - - #- an expert user may want to try to use an EXPERIMENTAL 3D acceleration, currenlty - #- this is with Utah GLX and so, it can provide a way of testing. - if ($card->{UTAH_GLX_EXPERIMENTAL} && $::expert) { - push @choices, { text => _("XFree %s with EXPERIMENTAL 3D hardware acceleration", $xf3_ver), - code => sub { $card->{prefer_xf3} = 1; $card->{use_UTAH_GLX} = 1 }, - more_messages => (using_xf4($card) && !$card->{DRI_GLX} ? -_("Your card can have 3D hardware acceleration support but only with XFree %s, -NOTE THIS IS EXPERIMENTAL SUPPORT AND MAY FREEZE YOUR COMPUTER. -Your card is supported by XFree %s which may have a better support in 2D.", $xf3_ver, $xf4_ver) : -_("Your card can have 3D hardware acceleration support with XFree %s, -NOTE THIS IS EXPERIMENTAL SUPPORT AND MAY FREEZE YOUR COMPUTER.", $xf3_ver)), - }; - } - - #- ask the expert or any user on second pass user to enable or not hardware acceleration support. - if ($card->{DRI_GLX} && !$card->{Xinerama}) { - unshift @choices, { text => _("XFree %s with 3D hardware acceleration", $xf4_ver), - code => sub { $card->{prefer_xf3} = 0; $card->{use_DRI_GLX} = 1 }, - more_messages => _("Your card can have 3D hardware acceleration support with XFree %s.", $xf4_ver), - }; - } - - #- an expert user may want to try to use an EXPERIMENTAL 3D acceleration. - if ($card->{DRI_GLX_EXPERIMENTAL} && !$card->{Xinerama} && $::expert) { - push @choices, { text => _("XFree %s with EXPERIMENTAL 3D hardware acceleration", $xf4_ver), - code => sub { $card->{prefer_xf3} = 0; $card->{use_DRI_GLX} = 1 }, - more_messages => _("Your card can have 3D hardware acceleration support with XFree %s, -NOTE THIS IS EXPERIMENTAL SUPPORT AND MAY FREEZE YOUR COMPUTER.", $xf4_ver), - }; - } - - if (arch() =~ /ppc/ && $ENV{DISPLAY}) { - push @choices, { text => _("Xpmac (installation display driver)"), code => sub { - #- HACK: re-allowing XFree 3 - $::force_xf4 = 0; - $card->{server} = "Xpmac"; - $card->{prefer_xf3} = 1; - }}; - } - @choices; -} - -sub set_glx_restrictions { - my ($card) = @_; - - #- hack for ATI Mach64 cards where two options should be used if using Utah-GLX. - if (member($card->{card_name}, 'ATI Mach64 Utah', 'ATI Rage Mobility')) { - $card->{options_xf3}{no_font_cache} = $card->{use_UTAH_GLX}; - $card->{options_xf3}{no_pixmap_cache} = $card->{use_UTAH_GLX}; - } - #- hack for SiS cards where an option should be used if using Utah-GLX. - if (member($card->{card_name}, 'SiS 6326', 'SiS 630')) { - $card->{options_xf3}{no_pixmap_cache} = $card->{use_UTAH_GLX}; - } - - #- 3D acceleration configuration for XFree 4 using DRI, this is enabled by default - #- but for some there is a need to specify VideoRam (else it won't run). - if ($card->{use_DRI_GLX}) { - #- always enable (as a reminder for people using a better AGP mode to change it at their own risk). - $card->{options_xf4}{AGPMode} = '1'; - - $card->{needVideoRam} = 1 if $card->{description} =~ /Matrox.* G[245][05]0/; - ($card->{needVideoRam}, $card->{VideoRam}) = (1, 16384) - if member($card->{card_name}, 'Intel 810', 'Intel 815'); - - #- hack for ATI Rage 128 card using a bttv or peripheral with PCI bus mastering exchange - #- AND using DRI at the same time. - if (member($card->{card_name}, 'ATI Rage 128', 'ATI Rage 128 Mobility')) { - $card->{options_xf4}{UseCCEFor2D} = bool2text(modules::probe_category('multimedia/tv')); - } - } -} - -sub xfree_and_glx_choose { - my ($in, $card, $noauto) = @_; - - my @choices = xfree_and_glx_choices($card); - - @choices = $choices[0] if !$::expert && !$noauto; - - my $msg = join("\n\n\n", - (grep {$_} map { $_->{more_messages} } @choices), - _("Which configuration of XFree do you want to have?")); - #- examine choice of user, beware the list MUST NOT BE REORDERED AS the first item should be the - #- proposed one by DrakX. - my $tc = $in->ask_from_listf(_("XFree configuration"), formatAlaTeX($msg), sub { $_[0]{text} }, \@choices) or return; - #- in case of class discarding, this can help ... - $tc or $tc = $choices[0]; - log::l("Using $tc->{text}"); - - #- must be done before calling a choice - $card->{use_UTAH_GLX} = $card->{use_DRI_GLX} = 0; - - $tc->{code} and $tc->{code}(); - - set_glx_restrictions($card); -} - -sub card_config__not_listed { - my ($in, $card, $cardOptions) = @_; - - my @xf3 = $cardOptions->{allowFB} ? @Xconfigurator_consts::allservers : @Xconfigurator_consts::allbutfbservers; - my @xf4 = $cardOptions->{allowFB} ? @Xconfigurator_consts::alldrivers : @Xconfigurator_consts::allbutfbdrivers; - my @list = (if_(!$force_xf4, map { 'XFree 3|' . $_ } @xf3), map { 'XFree 4|' . $_ } @xf4); - - my $default = $card->{prefer_xf3} ? 'XFree 3|' . $card->{server} : 'XFree 4|' . ($card->{driver} || 'fbdev'); - - my $r = $in->ask_from_treelist(_("X server"), _("Choose a X server"), '|', \@list, $default) or return; - - my ($kind, $s) = split '\|', $r; - - if ($kind eq 'XFree 3') { - delete $card->{driver}; - $card->{server} = $s; - } else { - delete $card->{server}; - $card->{driver} = $s; - } - $card->{prefer_xf3} = $kind eq 'XFree 3'; - delete $card->{card_name}; - 1; -} - -sub card_config { - my ($in, $card, $noauto, $cardOptions, $do_pkgs) = @_; - - #- using XF4 if {driver} && !{prefer_xf3} otherwise using XF3 - #- error if $force_xf4 && !{driver} || !{driver} && !{server} - #- internal error if $force_xf4 && {prefer_xf3} || {prefer_xf3} && !{server} - - $card->{prefer_xf3} = 0 if $force_xf4; #- sanitizing in case Xconfig::getinfoFromXF86Config may have found a weird existing configuration - - - if ($card->{card_name}) { - #- try to get info from given card_name - add_to_card__using_Cards($card, $card->{card_name}); - undef $card->{card_name} if !$card->{server} && !$card->{driver}; #- bad card_name as we can't find the server - } - - if (!$card->{server} && !$card->{driver} && !$noauto) { - my @cards = probe_cards(); - - my $card_ = $in->isa('class_discard') ? $cards[0] : - multi_head_choose($in, $noauto, @cards) or return; - put_in_hash($card, $card_); - - $card->{server} = 'FBDev' if $cardOptions->{allowFB} && !$card->{server} && !$card->{driver}; - } - - - if (!$card->{server} && !$card->{driver} || $noauto) { - card_config__not_listed($in, $card, $cardOptions) or return; - } - - foreach ($card, @{$card->{cards} || []}) { - $_->{VideoRam} = 4096, delete $_->{depth} if $_->{driver} eq 'i810'; - $_->{VideoRam} = 16384, delete $_->{depth} if $_->{Chipset} =~ /PERMEDIA/ && $_->{VideoRam} <= 1024; - } - - xfree_and_glx_choose($in, $card, $noauto); - - $card->{prog} = install_server($card, $cardOptions, $do_pkgs); - - #- check for Matrox G200 PCI cards, disable AGP in such cases, causes black screen else. - if (member($card->{card_name}, 'Matrox Millennium 200', 'Matrox Millennium 200', 'Matrox Mystique') && $card->{description} !~ /AGP/) { - log::l("disabling AGP mode for Matrox card, as it seems to be a PCI card"); - log::l("this is only used for XFree 3.3.6, see /etc/X11/glx.conf"); - substInFile { s/^\s*#*\s*mga_dma\s*=\s*\d+\s*$/mga_dma = 0\n/ } "$::prefix/etc/X11/glx.conf"; - } - - delete $card->{depth}{32} if $card->{card_name} =~ /S3 Trio3D|SiS/; - $card->{options_xf3}{power_saver} = 1; - $card->{options_xf4}{DPMS} = 'on'; - - $in->ask_from('', _("Select the memory size of your graphics card"), - [ { val => \$card->{VideoRam}, - list => [ sort keys %Xconfigurator_consts::VideoRams ], - format => sub { translate($Xconfigurator_consts::VideoRams{$_[0]}) }, - not_edit => !$::expert } ]) or return - if $card->{needVideoRam} && !$card->{VideoRam}; - - - 1; -} - -sub optionsConfiguration { - my ($in, $X) = @_; - my @l; - my %l; - - foreach (@Xconfigurator_consts::options) { - if ($X->{card}{server} eq $_->[1] && $X->{card}{description} =~ /$_->[2]/) { - my $options = 'options_' . ($X->{card}{server} eq 'XFree86' ? 'xf4' : 'xf3'); - $X->{card}{$options}{$_->[0]} ||= 0; - if (!$l{$_->[0]}) { - push @l, { label => $_->[0], val => \$X->{card}{$options}{$_->[0]}, type => 'bool' }; - $l{$_->[0]} = 1; - } - } - } - @l = @l[0..9] if @l > 9; #- reduce list size to 10 for display - - $in->ask_from('', _("Choose options for server"), \@l); -} - -sub monitor_config_automatic { - my ($monitors, $monitor, $noauto) = @_; - - if ($monitor->{EISA_ID}) { - log::l("EISA_ID: $monitor->{EISA_ID}"); - if (my ($mon) = grep { lc($_->{EISA_ID}) eq $monitor->{EISA_ID} } values %$monitors) { - add2hash($monitor, $mon); - log::l("EISA_ID corresponds to: $monitor->{ModelName}"); - } - } - my $merged_name = $monitor->{VendorName} . '|' . $monitor->{ModelName}; - - $merged_name = $Xconfigurator_consts::low_default_monitor - if $::auto_install && !exists $monitors->{$merged_name}; - - put_in_hash($monitor, $monitors->{$merged_name}); - - return $monitor->{hsyncrange} && $monitor->{vsyncrange} && !$noauto; -} - -sub monitor_config { - my ($in, $monitor, $noauto) = @_; - - my $monitors = readMonitorsDB("$ENV{SHARE_PATH}/ldetect-lst/MonitorsDB"); - - monitor_config_automatic($monitors, $monitor, $noauto) and return 1; - - my $merged_name = $monitor->{VendorName} . '|' . $monitor->{ModelName}; - - if (!exists $monitors->{$merged_name}) { - $merged_name = $monitor->{hsyncrange} ? 'Custom' : $Xconfigurator_consts::good_default_monitor; - } - - $merged_name = $in->ask_from_treelistf(_("Monitor"), _("Choose a monitor"), '|', - sub { $_[0] eq 'Custom' ? _("Custom") : $_[0] =~ /^Generic\|(.*)/ ? _("Generic") . "|$1" : _("Vendor") . "|$_[0]" }, - ['Custom', keys %$monitors], $merged_name) or return; - - if ($merged_name ne 'Custom') { - put_in_hash($monitor, $monitors->{$merged_name}); - } else { - $in->ask_from('', -_("The two critical parameters are the vertical refresh rate, which is the rate -at which the whole screen is refreshed, and most importantly the horizontal -sync rate, which is the rate at which scanlines are displayed. - -It is VERY IMPORTANT that you do not specify a monitor type with a sync range -that is beyond the capabilities of your monitor: you may damage your monitor. - If in doubt, choose a conservative setting."), - [ { val => \$monitor->{hsyncrange}, list => \@Xconfigurator_consts::hsyncranges, label => _("Horizontal refresh rate"), not_edit => 0 }, - { val => \$monitor->{vsyncrange}, list => \@Xconfigurator_consts::vsyncranges, label => _("Vertical refresh rate"), not_edit => 0 } ]) or return; - delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'}; - } - 1; -} - -sub finalize_config { - my ($X) = @_; - - $X->{monitor}{ModeLines_xf3} .= $Xconfigurator_consts::ModeLines_text_standard; - $X->{monitor}{ModeLines_xf3} .= $Xconfigurator_consts::ModeLines_text_ext; - $X->{monitor}{ModeLines} .= $Xconfigurator_consts::ModeLines_text_ext; - - #- clean up duplicated ModeLines - foreach ($X->{monitor}{ModeLines}, $X->{monitor}{ModeLines_xf3}) { - s/Modeline/ModeLine/g; #- normalize - my @l = reverse split "\n"; - my %seen; - @l = grep { - !/^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+(.*)/ || !$seen{"$1 $2"}++; - } @l; - $_ = join("\n", reverse @l); - s/^\n*/\n/; s/\n*$/\n/; #- have exactly one CR at beginning and end - } - - $X->{keyboard}{XkbModel} ||= - arch() =~ /sparc/ ? 'sun' : - $X->{keyboard}{XkbLayout} eq 'jp' ? 'jp106' : - $X->{keyboard}{XkbLayout} eq 'br' ? 'abnt2' : 'pc105'; - -} - -sub check_config { - my ($X) = @_; - - finalize_config($X); - - $X->{monitor}{hsyncrange} && $X->{monitor}{vsyncrange} or die _("Monitor not configured") . "\n"; - $X->{card}{server} || $X->{card}{driver} or die _("Graphics card not configured yet") . "\n"; - $X->{card}{depth} or die _("Resolutions not chosen yet") . "\n"; -} - -#- needed for bad cards not restoring cleanly framebuffer, according to which version of XFree are used. -sub check_bad_card { - my ($card) = @_; - my $bad_card = using_xf4($card) ? $card->{BAD_FB_RESTORE} : $card->{BAD_FB_RESTORE_XF3}; - $bad_card ||= $card->{driver} eq 'i810' || $card->{driver} eq 'fbdev'; - $bad_card ||= $card->{description} =~ /S3.*ViRGE/ if $::live; - $bad_card ||= $card->{driver} eq 'nvidia' if !$::isStandalone; #- avoid testing during install at any price. - - log::l("the graphics card does not like X in framebuffer") if $bad_card; - - !$bad_card; -} - -sub testFinalConfig { - my ($in, $X, $auto, $skiptest, $skip_badcard) = @_; - - my $f = "/etc/X11/XF86Config.test"; - - eval { write_XF86Config($X, $::testing ? $tmpconfig : "$::prefix/$f") }; - if (my $err = $@) { - $in->ask_warn('', $err); - return; - } - - $skiptest || $X->{card}{server} =~ 'FBDev|Sun' and return 1; #- avoid testing with these. - - check_bad_card($X->{card}) or return 1; - - $in->ask_yesorno(_("Test of the configuration"), _("Do you want to test the configuration?"), 1) or return 1 if !$auto; - - unlink "$::prefix/tmp/.X9-lock"; - - #- create a link from the non-prefixed /tmp/.X11-unix/X9 to the prefixed one - #- that way, you can talk to :9 without doing a chroot - #- but take care of non X11 install :-) - if (-d "/tmp/.X11-unix") { - symlinkf "$::prefix/tmp/.X11-unix/X9", "/tmp/.X11-unix/X9" if $::prefix; - } else { - symlinkf "$::prefix/tmp/.X11-unix", "/tmp/.X11-unix" if $::prefix; - } - #- restart_xfs; - - my $f_err = "$::prefix/tmp/Xoutput"; - my $pid; - unless ($pid = fork) { - system("xauth add :9 . `mcookie`"); - open STDERR, ">$f_err"; - chroot $::prefix if $::prefix; - exec $X->{card}{prog}, - if_($X->{card}{prog} !~ /Xsun/, "-xf86config", ($::testing ? $tmpconfig : $f) . (using_xf4($X->{card}) && "-4")), - ":9" or c::_exit(0); - } - - do { sleep 1 } until xtest(":9") || waitpid($pid, c::WNOHANG()); - - my $b = before_leaving { unlink $f_err }; - - if (!xtest(":9")) { - local $_; - local *F; open F, $f_err; - i: while () { - if (using_xf4($X->{card})) { - if (/^\(EE\)/ && !/Disabling/ || /^Fatal\b/) { - my @msg = !/error/ && $_ ; - while () { - /reporting a problem/ and last; - push @msg, $_; - $in->ask_warn('', [ _("An error occurred:"), " ", @msg, _("\ntry to change some parameters") ]); - return 0; - } - } - } else { - if (/\b(error|not supported)\b/i) { - my @msg = !/error/ && $_ ; - while () { - /not fatal/ and last i; - /^$/ and last; - push @msg, $_; - } - $in->ask_warn('', [ _("An error occurred:"), " ", @msg, _("\ntry to change some parameters") ]); - return 0; - } - } - } - } - - $::noShadow = 1; - local *F; - open F, "|perl 2>/dev/null" or die ''; - print F "use lib qw(", join(' ', @INC), ");\n"; - print F q{ - require lang; - use interactive::gtk; - use run_program; - use my_gtk qw(:wrappers); - - $::prefix = "} . $::$prefix . q{"; - $::isStandalone = 1; - - lang::bindtextdomain(); - - $ENV{DISPLAY} = ":9"; - - gtkset_background(200 * 257, 210 * 257, 210 * 257); - my ($h, $w) = Gtk::Gdk::Window->new_foreign(Gtk::Gdk->ROOT_WINDOW)->get_size; - $my_gtk::force_position = [ $w / 3, $h / 2.4 ]; - $my_gtk::force_focus = 1; - my $text = Gtk::Label->new; - my $time = 8; - Gtk->timeout_add(1000, sub { - $text->set(_("Leaving in %d seconds", $time)); - $time-- or Gtk->main_quit; - 1; - }); - - my $background = "/usr/share/pixmaps/backgrounds/linux-mandrake/XFdrake-image-test.jpg"; - my $qiv = "/usr/bin/qiv"; - run_program::rooted($::prefix, $qiv, "-y", $background) - if -r "$::prefix/$background" && -x "$::prefix/$qiv"; - - my $in = interactive::gtk->new; - $in->exit($in->ask_yesorno('', [ _("Is this the correct setting?"), $text ], 0) ? 0 : 222); - }; - my $rc = close F; - my $err = $?; - - unlink "/tmp/.X11-unix/X9" if $::prefix; - kill 2, $pid; - $::noShadow = 0; - - $rc || $err == 222 << 8 or $in->ask_warn('', _("An error occurred, try to change some parameters")); - $rc; -} - -sub allowedDepth($) { - my ($card) = @_; - my %allowed_depth; - - if ($card->{use_UTAH_GLX} || $card->{use_DRI_GLX}) { - $allowed_depth{16} = 1; #- this is the default. - $card->{description} =~ /Voodoo 5/ and $allowed_depth{24} = undef; - $card->{description} =~ /Matrox.* G[245][05]0/ and $allowed_depth{24} = undef; - $card->{description} =~ /Rage 128/ and $allowed_depth{24} = undef; - $card->{description} =~ /Radeon/ and $allowed_depth{24} = undef; - } - - for ($card->{server}) { - #- this should work by default, FBDev is allowed only if install currently uses it at 16bpp. - /FBDev/ and $allowed_depth{16} = 1; - - #- Sun servers, Sun24 handles 24,8,2; Sun only 8 and 2; and SunMono only 2. - /^Sun24$/ and @allowed_depth{qw(24 8 2)} = (1); - /^Sun$/ and @allowed_depth{qw(8 2)} = (1); - /^SunMono$/ and @allowed_depth{qw(2)} = (1); - } - - return %allowed_depth && \%allowed_depth; #- no restriction if false is returned. -} - -sub autoDefaultDepth($$) { - my ($card, $x_res_wanted) = @_; - my ($best, $depth); - - #- check for forced depth according to current environment. - my $allowed_depth = allowedDepth($card); - if ($allowed_depth) { - foreach (keys %$allowed_depth) { - $allowed_depth->{$_} and return $_; #- a default depth is given. - } - } - - while (my ($d, $r) = each %{$card->{depth}}) { - $allowed_depth && ! exists $allowed_depth->{$d} and next; #- reject depth. - $depth = max($depth || 0, $d); - - #- try to have resolution_wanted - $best = max($best || 0, $d) if $r->[0][0] >= $x_res_wanted; - $best = $card->{suggest_depth}, last if ($card->{suggest_depth} && - $card->{suggest_x_res} && $r->[0][0] >= $card->{suggest_x_res}); - } - $best || $depth or die "no valid modes"; -} - -sub autoDefaultResolution { - # return "1024x768" if detect_devices::hasPCMCIA; - - if (arch() =~ /ppc/) { - return "1024x768" if detect_devices::get_mac_model =~ /^PowerBook|^iMac/; - } - - my ($size) = @_; - $Xconfigurator_consts::monitorSize2resolution[round($size || 14)] || #- assume a small monitor (size is in inch) - $Xconfigurator_consts::monitorSize2resolution[-1]; #- no corresponding resolution for this size. It means a big monitor, take biggest we have -} - -sub chooseResolutionsGtk { - my ($card, $chosen_depth, $chosen_w) = @_; - - require my_gtk; - my_gtk->import(qw(:helpers :wrappers)); - - my $W = my_gtk->new(_("Resolution")); - my %txt2depth = reverse %Xconfigurator_consts::depths; - my ($r, $depth_combo, %w2depth, %w2h, %w2widget, $pix_monitor, $pix_colors, $w2_combo); - $w2_combo = new Gtk::Combo; - my $best_w; - my $allowed_depth = allowedDepth($card); - my %allowed_depth; - while (my ($depth, $res) = each %{$card->{depth}}) { - $allowed_depth && ! exists $allowed_depth->{$depth} and next; #- reject depth. - foreach (@$res) { - ++$allowed_depth{$depth}; - $w2h{$_->[0]} = $_->[1]; - push @{$w2depth{$_->[0]}}, $depth; - - $best_w = max($_->[0], $best_w) if $_->[0] <= $chosen_w; - } - } - $chosen_w = $best_w; - $chosen_w ||= 640; #- safe guard ? - - my $set_depth = sub { $depth_combo->entry->set_text(translate($Xconfigurator_consts::depths{$chosen_depth})) }; - - #- the set function is usefull to toggle the CheckButton with the callback being ignored - my $ignore; - my $no_human; # is the w2_combo->entry changed by a human? - my $set = sub { $ignore = 1; $_[0] and $_[0]->set_active(1); $ignore = 0 }; - - my %monitor; - $monitor{$_} = [ gtkcreate_png("monitor-" . $_ . ".png") ] foreach (640, 800, 1024, 1280); - $monitor{$_} = [ gtkcreate_png("monitor-" . 1024 . ".png") ] foreach (1152); - #- add default icons for resolutions not taken into account (assume largest image available). - $monitor{$_} ||= [ gtkcreate_png("monitor-" . 1280 . ".png") ] foreach map { (split 'x', $_)[0] } @Xconfigurator_consts::resolutions; - - my $pixmap_mo = new Gtk::Pixmap( $monitor{$chosen_w}[0] , $monitor{$chosen_w}[1] ); - - while (my ($w, $h) = each %w2h) { - my $V = $w . "x" . $h; - $w2widget{$w} = $r = new Gtk::RadioButton($r ? ($V, $r) : $V); - if ($chosen_w == $w) { - &$set($r); - } - $r->signal_connect("clicked" => sub { - $ignore and return; - $chosen_w = $w; - $no_human=1; - $w2_combo->entry->set_text($w . "x" . $w2h{$w}); - if (!member($chosen_depth, @{$w2depth{$w}})) { - $chosen_depth = max(@{$w2depth{$w}}); - &$set_depth(); - } - }); - } - gtkadd($W->{window}, - gtkpack_($W->create_box_with_title(_("Choose the resolution and the color depth"), - "(" . ($card->{card_name} ? - _("Graphics card: %s", $card->{card_name}) : - _("XFree86 server: %s", $card->{server})) . ")" - ), - 1, gtkpack2(new Gtk::VBox(0,0), - gtkpack2__(new Gtk::VBox(0, $::isEmbedded ? 15 : 0), - if_($::isEmbedded, $pixmap_mo), - if_(!$::isEmbedded, map {$w2widget{$_} } ikeys(%w2widget)), - gtkpack2(new Gtk::HBox(0,0), - create_packtable({ col_spacings => 5, row_spacings => 5}, - [ if_($::isEmbedded,$w2_combo) , new Gtk::Label("")], - [ $depth_combo = new Gtk::Combo, gtkadd(gtkset_shadow_type(new Gtk::Frame, 'etched_out'), $pix_colors = gtkpng ("colors")) ], - ), - ), - ), - ), - 0, gtkadd($W->create_okcancel(_("Ok"), _("More")), - $::isEmbedded ? - gtksignal_connect(new Gtk::Button(_("Expert Mode")), clicked => sub { system ("XFdrake --expert") }) : - gtksignal_connect(new Gtk::Button(_("Show all")), clicked => sub { $W->{retval} = 1; $chosen_w = 0; Gtk->main_quit })), - )); - $depth_combo->disable_activate; - $depth_combo->set_use_arrows_always(1); - $depth_combo->entry->set_editable(0); - $depth_combo->set_popdown_strings(map { translate($Xconfigurator_consts::depths{$_}) } grep { $Xconfigurator_consts::allowed_depth{$_} } ikeys(%{$card->{depth}})); - $depth_combo->entry->signal_connect(changed => sub { - $chosen_depth = $txt2depth{untranslate($depth_combo->entry->get_text, keys %txt2depth)}; - my $w = $card->{depth}{$chosen_depth}[0][0]; - $chosen_w > $w and &$set($w2widget{$chosen_w = $w}); - $pix_colors->set(gtkcreate_png( - $chosen_depth >= 24 ? "colors.png" : - $chosen_depth >= 15 ? "colors16.png" : - "colors8.png")); - }); - if ($::isEmbedded) { - $w2_combo->disable_activate; - $w2_combo->set_use_arrows_always(1); - $w2_combo->entry->set_editable(0); - $w2_combo->set_popdown_strings(map { $_ . "x" . $w2h{$_} } keys %w2h); - $w2_combo->entry->signal_connect(changed => sub { - ($chosen_w) = $w2_combo->entry->get_text =~ /([^x]*)x.*/; - $no_human ? $no_human=0 : $w2widget{$chosen_w}->set_active(1); - $pixmap_mo->set($monitor{$chosen_w}[0], $monitor{$chosen_w}[1]); - }); - } - &$set_depth(); - $W->{ok}->grab_focus; - - if ($::isEmbedded) { - $no_human=1; - $w2_combo->entry->set_text($chosen_w . "x" . $w2h{$chosen_w}); - } - $W->main or return; - ($chosen_depth, $chosen_w); -} - -sub chooseResolutions { - my ($in, $card, $chosen_depth, $chosen_w) = @_; - - return chooseResolutionsGtk($card, $chosen_depth, $chosen_w) if $in->isa('interactive::gtk'); - - my $best_w; - my $allowed_depth = allowedDepth($card); - - local $_ = $in->ask_from_list(_("Resolutions"), "", - [ map_each { if_(!$allowed_depth || exists $allowed_depth->{$::a}, - map { "$_->[0]x$_->[1] ${main::a}bpp" } @$::b) } %{$card->{depth}} ]) - or return; - reverse /(\d+)x\S+ (\d+)/; -} - - -sub resolutionsConfiguration { - my ($in, $X, $auto) = @_; - my $card = $X->{card}; - - #- For the vga16 server, no further configuration is required. - if ($card->{server} eq "VGA16") { - $card->{depth}{8} = [[ 640, 480 ]]; - return; - } elsif ($card->{server} =~ /Sun/) { - $card->{depth}{2} = [[ 1152, 864 ]] if $card->{server} =~ /^(SunMono)$/; - $card->{depth}{8} = [[ 1152, 864 ]] if $card->{server} =~ /^(SunMono|Sun)$/; - $card->{depth}{24} = [[ 1152, 864 ]] if $card->{server} =~ /^(SunMono|Sun|Sun24)$/; - $card->{default_x_res} = 1152; - $X->{default_depth} = max(keys %{$card->{depth}}); - return 1; #- aka we cannot test, assumed as good (should be). - } - if (is_empty_hash_ref($card->{depth})) { - $card->{depth}{$_} = [ map { [ split "x" ] } @Xconfigurator_consts::resolutions ] - foreach @Xconfigurator_consts::depths; - } - #- sort resolutions in each depth - foreach (values %{$card->{depth}}) { - my $i = 0; - @$_ = grep { first($i != $_->[0], $i = $_->[0]) } - sort { $b->[0] <=> $a->[0] } @$_; - } - - #- remove unusable resolutions (based on the video memory size and the monitor hsync rate) - keepOnlyLegalModes($card, $X->{monitor}); - - my $res = $X->{resolution_wanted} || $card->{suggest_x_res} || autoDefaultResolution($X->{monitor}{size}); - my $x_res = first(split 'x', $res); - - #- take the first available resolution <= the wanted resolution - eval { $x_res = max map { first(grep { $_->[0] <= $x_res } @$_)->[0] } values %{$card->{depth}} }; - my $depth = eval { $X->{default_depth} || autoDefaultDepth($card, $x_res) }; - - $auto or ($depth, $x_res) = chooseResolutions($in, $card, $depth, $x_res) or return; - - #- if nothing has been found for x_res, - #- try to find if memory used by mode found match the memory available - #- card, if this is the case for a relatively low resolution ( < 1024 ), - #- there could be a problem. - #- memory in KB is approximated by $x_res*$dpeth/14 which is little less - #- than memory really used, (correct factor is 13.65333 for w/h ratio of 1.33333). - if (!$x_res || $auto && !$in->isa('class_discard') && ($x_res < 1024 && ($card->{VideoRam} / ($x_res * $depth / 14)) > 2)) { - delete $card->{depth}; - return resolutionsConfiguration($in, $X); - } - - #- needed in auto mode when all has been provided by the user - $card->{depth}{$depth} or die "you selected an unusable depth"; - - #- remove all biggest resolution (keep the small ones for ctl-alt-+) - #- otherwise there'll be a virtual screen :( - $_ = [ grep { $_->[0] <= $x_res } @$_ ] foreach values %{$card->{depth}}; - $card->{default_x_res} = $x_res; - $card->{bios_vga_mode} = (Xconfigurator_consts::bios_vga_modes($x_res, $depth))[0]; #- for use with frame buffer. - $X->{default_depth} = $depth; - 1; -} - -#- Create the XF86Config file. -sub write_XF86Config { - my ($X, $file) = @_; - my $O; - - check_config($X); - - $::g_auto_install and return; - - local (*F, *G); - open F, ">$file" or die "can't write XF86Config in $file: $!"; - open G, ">$file-4" or die "can't write XF86Config in $file-4: $!"; - - print F $Xconfigurator_consts::XF86firstchunk_text; - print G $Xconfigurator_consts::XF86firstchunk_text; - - #- Write keyboard section. - $O = $X->{keyboard}; - - print F ' -Section "Keyboard" - Protocol "Standard" -'; - print G ' -Section "InputDevice" - Identifier "Keyboard1" - Driver "Keyboard" -'; - - print F qq( XkbDisable\n) if !$O->{XkbLayout}; - print G qq( Option "XkbDisable"\n) if !$O->{XkbLayout}; - - print F qq( XkbModel "$O->{XkbModel}"\n); - print G qq( Option "XkbModel" "$O->{XkbModel}"\n); - print F qq( XkbLayout "$O->{XkbLayout}"\n); - print G qq( Option "XkbLayout" "$O->{XkbLayout}"\n); - print F join '', map { " $_\n" } @{$Xconfigurator_consts::XkbOptions{$O->{XkbLayout}} || []}; - print G join '', map { /(\S+)(.*)/; qq( Option "$1" $2\n) } @{$Xconfigurator_consts::XkbOptions{$O->{XkbLayout}} || []}; - print F "EndSection\n"; - print G "EndSection\n"; - - #- Write pointer section. - my $pointer = sub { - my ($O, $id) = @_; - print F $id > 1 ? qq(\nSection "XInput"\n) : qq(\nSection "Pointer"\n); - $id > 1 and print F qq( SubSection "Mouse"\n); - print G qq(\nSection "InputDevice"\n); - $id > 1 and print F qq( DeviceName "Mouse$id"\n); - print G qq( Identifier "Mouse$id"\n); - print G qq( Driver "mouse"\n); - print F ($id > 1 && " ") . qq( Protocol "$O->{XMOUSETYPE}"\n); - print G qq( Option "Protocol" "$O->{XMOUSETYPE}"\n); - print F ($id > 1 && " ") . qq( Device "/dev/$O->{device}"\n); - print G qq( Option "Device" "/dev/$O->{device}"\n); - print F " AlwaysCore\n" if $id > 1; - #- this will enable the "wheel" or "knob" functionality if the mouse supports it - print F ($id > 1 && " ") . " ZAxisMapping 4 5\n" if $O->{nbuttons} > 3; - print F ($id > 1 && " ") . " ZAxisMapping 6 7\n" if $O->{nbuttons} > 5; - print G qq( Option "ZAxisMapping" "4 5"\n) if $O->{nbuttons} > 3; - print G qq( Option "ZAxisMapping" "6 7"\n) if $O->{nbuttons} > 5; - - print F "#" if $O->{nbuttons} >= 3; - print G "#" if $O->{nbuttons} >= 3; - print F ($id > 1 && " ") . qq( Emulate3Buttons\n); - print G qq( Option "Emulate3Buttons"\n); - print F "#" if $O->{nbuttons} >= 3; - print G "#" if $O->{nbuttons} >= 3; - print F ($id > 1 && " ") . qq( Emulate3Timeout 50\n); - print G qq( Option "Emulate3Timeout" "50"\n); - $id > 1 and print F qq( EndSubSection\n); - print F "EndSection\n"; - print G "EndSection\n"; - }; - $pointer->($X->{mouse}, 1); - $pointer->($X->{mouse}{auxmouse}, 2) if $X->{mouse}{auxmouse}; - - #- write module section for version 3. - if (@{$X->{wacom}} || $X->{card}{use_UTAH_GLX}) { - print F qq(\nSection "Module"\n); - print F qq( Load "xf86Wacom.so"\n) if @{$X->{wacom}}; - print F qq( Load "glx-3.so"\n) if $X->{card}{use_UTAH_GLX}; #- glx.so may clash with server version 4. - print F qq(EndSection\n); - } - - #- write wacom device support. - foreach (1 .. @{$X->{wacom}}) { - my $dev = "/dev/" . $X->{wacom}[$_-1]; - print F $dev =~ /input\/event/ ? qq( -Section "XInput" - SubSection "WacomStylus" - Port "$dev" - DeviceName "Stylus$_" - USB - AlwaysCore - Mode Absolute - EndSubSection - SubSection "WacomCursor" - Port "$dev" - DeviceName "Cursor$_" - USB - AlwaysCore - Mode Relative - EndSubSection - SubSection "WacomEraser" - Port "$dev" - DeviceName "Eraser$_" - USB - AlwaysCore - Mode Absolute - EndSubSection -EndSection -) : qq( -Section "XInput" - SubSection "WacomStylus" - Port "$dev" - DeviceName "Stylus$_" - AlwaysCore - Mode Absolute - EndSubSection - SubSection "WacomCursor" - Port "$dev" - DeviceName "Sursor$_" - AlwaysCore - Mode Relative - EndSubSection - SubSection "WacomEraser" - Port "$dev" - DeviceName "Eraser$_" - AlwaysCore - Mode Absolute - EndSubSection -EndSection -); - } - - foreach (1..@{$X->{wacom}}) { - my $dev = "/dev/" . $X->{wacom}[$_-1]; - print G $dev =~ m|input/event| ? qq( -Section "InputDevice" - Identifier "Stylus$_" - Driver "wacom" - Option "Type" "stylus" - Option "Device" "$dev" - Option "Mode" "Absolute" - Option "USB" "on" -EndSection -Section "InputDevice" - Identifier "Eraser$_" - Driver "wacom" - Option "Type" "eraser" - Option "Device" "$dev" - Option "Mode" "Absolute" - Option "USB" "on" -EndSection -Section "InputDevice" - Identifier "Cursor$_" - Driver "wacom" - Option "Type" "cursor" - Option "Device" "$dev" - Option "Mode" "Relative" - Option "USB" "on" -EndSection -) : qq( -Section "InputDevice" - Identifier "Stylus$_" - Driver "wacom" - Option "Type" "stylus" - Option "Device" "$dev" - Option "Mode" "Absolute" -EndSection -Section "InputDevice" - Identifier "Eraser$_" - Driver "wacom" - Option "Type" "eraser" - Option "Device" "$dev" - Option "Mode" "Absolute" -EndSection -Section "InputDevice" - Identifier "Cursor$_" - Driver "wacom" - Option "Type" "cursor" - Option "Device" "$dev" - Option "Mode" "Relative" -EndSection -); - } - - #- write modules section for version 4. - print G qq(\nSection "Module"\n); - print G qq( Load "dbe" # Double-Buffering Extension\n); - print G qq( Load "v4l" # Video for Linux\n) if !($X->{card}{use_DRI_GLX} && $X->{card}{driver} eq 'r128'); - print G qq( Load "extmod"\n); - - #- For example, this loads the NVIDIA GLX extension module. - #- When DRI_GLX_SPECIAL is set, use_DRI_GLX is also set - if ($X->{card}{DRI_GLX_SPECIAL}) { - print G $X->{card}{DRI_GLX_SPECIAL}; - } elsif ($X->{card}{use_DRI_GLX}) { - print G qq( Load "dri" # direct rendering\n); - print G qq( Load "glx" # 3D layer\n); - } - print G qq( Load "type1"\n); - print G qq( Load "freetype"\n); - - print G qq(EndSection\n); - - print G qq( -Section "DRI" - Mode 0666 -EndSection -) if $X->{card}{use_DRI_GLX}; - - #- Write monitor section. - $O = $X->{monitor}; - print F qq(\nSection "Monitor"\n); - print G qq(\nSection "Monitor"\n); - print F qq( Identifier "monitor1"\n); - print G qq( Identifier "monitor1"\n); - print F qq( VendorName "$O->{VendorName}"\n) if $O->{VendorName}; - print G qq( VendorName "$O->{VendorName}"\n) if $O->{VendorName}; - print F qq( ModelName "$O->{ModelName}"\n) if $O->{ModelName}; - print G qq( ModelName "$O->{ModelName}"\n) if $O->{ModelName}; - print F qq( HorizSync $O->{hsyncrange}\n); - print G qq( HorizSync $O->{hsyncrange}\n); - print F qq( VertRefresh $O->{vsyncrange}\n); - print G qq( VertRefresh $O->{vsyncrange}\n); - print F $O->{ModeLines_xf3} if $O->{ModeLines_xf3}; - print G $O->{ModeLines} if $O->{ModeLines}; - print F "EndSection\n"; - print G "EndSection\n"; - foreach (1..@{$X->{card}{cards} || []}) { - print G qq(\nSection "Monitor"\n); - print G qq( Identifier "monitor), $_+1, qq("\n); - print G qq( HorizSync $O->{hsyncrange}\n); - print G qq( VertRefresh $O->{vsyncrange}\n); - print G qq(EndSection\n); - } - - #- Write Device section. - $O = $X->{card}; - print F $Xconfigurator_consts::devicesection_text; - print F qq(\nSection "Device"\n); - print F qq( Identifier "device1"\n); - print F qq( VendorName "$O->{VendorName}"\n) if $O->{VendorName}; - print F qq( BoardName "$O->{BoardName}"\n) if $O->{BoardName}; - print F qq( Chipset "$O->{Chipset}"\n) if $O->{Chipset}; - - print F "#" if $O->{VideoRam} && !$O->{needVideoRam}; - print F " VideoRam $O->{VideoRam}\n" if $O->{VideoRam}; - print F "\n"; - - print F map { " $_\n" } @{$O->{lines} || []}; - - print F qq( #Option "sw_cursor" # Uncomment following option if you see a big white block instead of the cursor!\n); - - my $p_xf3 = sub { - my $l = $O->{$_[0]}; - map { (!$l->{$_} && '#') . qq( Option "$_"\n) } keys %{$l || {}}; - }; - my $p_xf4 = sub { - my $l = $O->{$_[0]}; - map { (! defined $l->{$_} && '#') . qq( Option "$_" "$l->{$_}"\n) } keys %{$l || {}}; - }; - print F $p_xf3->('options'); - print F $p_xf3->('options_xf3'); - print F "EndSection\n"; - - #- configure all drivers here! - each_index { - print G qq(\nSection "Device"\n); - print G qq( Identifier "device), $::i+1, qq("\n); - print G qq( VendorName "$_->{VendorName}"\n) if $_->{VendorName}; - print G qq( BoardName "$_->{BoardName}"\n) if $_->{BoardName}; - print G qq( Driver "$_->{driver}"\n); - print G "#" if $_->{VideoRam} && !$_->{needVideoRam}; - print G " VideoRam $_->{VideoRam}\n" if $_->{VideoRam}; - print G "\n"; - print G map { " $_\n" } @{$_->{lines} || []}; - - print G qq( #Option "sw_cursor" # Uncomment following option if you see a big white block instead of the cursor!\n); - - print G $p_xf3->('options'); #- keep $O for these! - print G $p_xf4->('options_xf4'); #- keep $O for these! - print G qq( Screen $_->{screen}\n) if defined $_->{screen}; - print G qq( BusID "$_->{busid}"\n) if $_->{busid}; - if ((arch =~ /ppc/) && ($_->{driver} eq "r128")) { - print G qq( Option "UseFBDev"\n); - } - print G "EndSection\n"; - } $O, @{$O->{cards} || []}; - - my $subscreen = sub { - my ($f, $server, $defdepth, $depths) = @_; - print $f " DefaultColorDepth $defdepth\n" if $defdepth; - - foreach (ikeys(%$depths)) { - my $m = $server ne "fbdev" ? join(" ", map { qq("$_->[0]x$_->[1]") } @{$depths->{$_}}) : qq("default"); #-" - print $f qq(\n); - print $f qq( Subsection "Display"\n); - print $f qq( Depth $_\n) if $_; - print $f qq( Modes $m\n); - print $f qq( EndSubsection\n); - } - print $f "EndSection\n"; - }; - - my $screen = sub { - my ($server, $defdepth, $device, $depths) = @_; - print F qq( -Section "Screen" - Driver "$server" - Device "$device" - Monitor "monitor1" -); #-" - $subscreen->(*F, $server, $defdepth, $depths); - }; - - &$screen("svga", $X->{default_depth}, 'device1', $O->{depth}) - if $O->{server} eq 'SVGA'; - - &$screen("accel", $X->{default_depth}, 'device1', $O->{depth}) - if $Xconfigurator_consts::serversdriver{$O->{server}} eq 'accel'; - - &$screen("fbdev", $X->{default_depth}, 'device1', $O->{depth}); - - &$screen("vga16", '', "Generic VGA", { '' => [[ 640, 480 ], [ 800, 600 ]]}); - - foreach (1 .. 1 + @{$O->{cards} || []}) { - print G qq( -Section "Screen" - Identifier "screen$_" - Device "device$_" - Monitor "monitor$_" -); - #- bpp 32 not handled by XF4 - $subscreen->(*G, "svga", min($X->{default_depth}, 24), $O->{depth}); - } - - print G qq( -Section "ServerLayout" - Identifier "layout1" - Screen "screen1" -); - foreach (1..@{$O->{cards} || []}) { - my ($curr, $prev) = ($_ + 1, $_); - print G qq( Screen "screen$curr" RightOf "screen$prev"\n); - } - print G '#' if defined $O->{Xinerama} && !$O->{Xinerama}; - print G qq( Option "Xinerama" "on"\n) if defined $O->{Xinerama}; - - print G qq( InputDevice "Mouse1" "CorePointer"\n); - print G qq( InputDevice "Mouse2" "SendCoreEvents"\n) if $X->{mouse}{auxmouse}; - - foreach (1..@{$X->{wacom}}) { - print G qq( - InputDevice "Stylus$_" "AlwaysCore" - InputDevice "Eraser$_" "AlwaysCore" - InputDevice "Cursor$_" "AlwaysCore" -); - } - print G qq( InputDevice "Keyboard1" "CoreKeyboard"\n); - print G "EndSection\n"; - - close F; - close G; -} - -sub show_info { - my ($in, $X) = @_; - $in->ask_warn('', Xconfig::info($X)); -} - -#- Program entry point. -sub main { - my ($X, $in, $do_pkgs, $cardOptions) = @_; - $X ||= {}; - - Xconfig::XF86check_link($::prefix, ''); - Xconfig::XF86check_link($::prefix, '-4'); - - my $ok = 1; - { - my $w = $in->wait_message('', _("Preparing X-Window configuration"), 1); - - $ok &&= card_config($in, $X->{card} ||= {}, $::noauto, $cardOptions, $do_pkgs); - - $ok &&= monitor_config($in, $X->{monitor} ||= {}, $::noauto); - } - $ok &&= resolutionsConfiguration($in, $X, $::auto); - - $ok &&= testFinalConfig($in, $X, $::auto, $X->{skiptest}, $::auto); - - my $quit; - until ($ok || $quit) { - ref($in) =~ /discard/ and die "automatic X configuration failed, ensure you give hsyncrange and vsyncrange with non-DDC aware videocards/monitors"; - - $in->set_help('configureXmain') if !$::isStandalone; - - my $f; - $in->ask_from_( - { - title => 'XFdrake', - messages => _("What do you want to do?"), - cancel => '', - }, [ - { format => sub { $_[0][0] }, val => \$f, - list => [ - [ _("Change Monitor") => sub { monitor_config($in, $X->{monitor}, 'noauto') } ], - [ _("Change Graphics card") => sub { card_config($in, $X->{card}, 'noauto', $cardOptions, $do_pkgs) } ], - if_($::expert, - [ _("Change Server options") => sub { optionsConfiguration($in, $X) } ]), - [ _("Change Resolution") => sub { resolutionsConfiguration($in, $X) } ], - [ _("Show information") => sub { show_info($in, $X) } ], - [ _("Test again") => sub { $ok = testFinalConfig($in, $X, 1) } ], - [ _("Quit") => sub { $quit = 1 } ], - ], - } - ]); - $f->[1]->(); - $in->kill; - } - if (!$ok) { - $ok = $in->ask_yesorno('', _("Keep the changes? -The current configuration is: - -%s", Xconfig::info($X))); - } - if ($ok) { - if (!$::testing) { - my $f = "$::prefix/etc/X11/XF86Config"; - if (-e "$f.test") { - rename $f, "$f.old" or die "unable to make a backup of XF86Config"; - rename "$f-4", "$f-4.old"; - rename "$f.test", $f if $X->{card}{server}; - rename "$f.test-4", "$f-4" if $X->{card}{driver}; - symlinkf "../..$X->{card}{prog}", "$::prefix/etc/X11/X" if $X->{card}{server} !~ /Xpmac/; - } - } - - if (!$::isStandalone || $0 !~ /Xdrakres/) { - $in->set_help('configureXxdm') if !$::isStandalone; - my $run = exists $X->{xdm} ? $X->{xdm} : $::auto || $in->ask_yesorno(_("Graphical interface at startup"), -_("I can setup your computer to automatically start the graphical interface (XFree) upon booting. -Would you like XFree to start when you reboot?"), 1); - any::runlevel($::prefix, $run ? 5 : 3) if !$::testing; - } - if ($::isStandalone && $in->isa('interactive::gtk')) { - if (my $wm = any::running_window_manager()) { - if ($in->ask_okcancel('', _("Please relog into %s to activate the changes", ucfirst (lc $wm)), 1)) { - fork and $in->exit; - any::ask_window_manager_to_logout($wm); - - open STDIN, "/dev/null"; - open STDERR, ">&STDERR"; - c::setsid(); - exec qw(perl -e), q{ - my $wm = shift; - for (my $nb = 30; $nb && `pidof "$wm"` > 0; $nb--) { sleep 1 } - system("killall X ; killall -15 xdm gdm kdm prefdm") if !(`pidof "$wm"` > 0); - }, $wm; - } - } else { - $in->ask_warn('', _("Please log out and then use Ctrl-Alt-BackSpace")); - } - } - } -} - -1; diff --git a/perl-install/Xconfigurator_consts.pm b/perl-install/Xconfigurator_consts.pm deleted file mode 100644 index 91e0f3419..000000000 --- a/perl-install/Xconfigurator_consts.pm +++ /dev/null @@ -1,366 +0,0 @@ -package Xconfigurator_consts; # $Id$ - -use common; - -%depths = ( - 8 => __("256 colors (8 bits)"), - 15 => __("32 thousand colors (15 bits)"), - 16 => __("65 thousand colors (16 bits)"), - 24 => __("16 million colors (24 bits)"), - 32 => __("4 billion colors (32 bits)"), -); -@depths = ikeys(%depths); - -@resolutions = ('640x480', '800x600', '1024x768', (arch() =~ /ppc/ ? '1152x864' : '1152x768'), '1280x1024', '1400x1050', '1600x1200', '1920x1440', '2048x1536'); - -%serversdriver = arch() =~ /^sparc/ ? ( - 'Mach64' => "accel", - '3DLabs' => "accel", - 'Sun' => "fbdev", - 'Sun24' => "fbdev", - 'SunMono' => "fbdev", - 'VGA16' => "vga16", - 'FBDev' => "fbdev", -) : ( - 'SVGA' => "svga", - 'S3' => "accel", - 'Mach32' => "accel", - 'Mach8' => "accel", - '8514' => "accel", - 'P9000' => "accel", - 'AGX' => "accel", - 'W32' => "accel", - 'Mach64' => "accel", - 'I128' => "accel", - 'S3V' => "accel", - '3DLabs' => "accel", - 'VGA16' => "vga16", - 'FBDev' => "fbdev", -); -@allbutfbservers = grep { arch() =~ /^sparc/ || $serversdriver{$_} ne "fbdev" } keys(%serversdriver); -@allservers = keys(%serversdriver); - -@allbutfbdrivers = ((arch() =~ /^sparc/ ? qw(sunbw2 suncg14 suncg3 suncg6 sunffb sunleo suntcx) : - qw(apm ark chips cirrus cyrix glide i128 i740 i810 imstt - mga neomagic newport nv rendition r128 radeon - s3 s3virge savage siliconmotion sis tdfx tga trident tseng vmware)), qw(ati glint vga)); -@alldrivers = (@allbutfbdrivers, 'fbdev', 'vesa'); - -%bios_vga_modes = ( - 769 => [ 640, 480, 8 ], - 771 => [ 800, 600, 8 ], - 773 => [ 1024, 768, 8 ], - 775 => [ 1280, 1024, 8 ], - 784 => [ 640, 480, 15 ], - 787 => [ 800, 600, 15 ], - 790 => [ 1024, 768, 15 ], - 793 => [ 1280, 1024, 15 ], - 785 => [ 640, 480, 16 ], - 788 => [ 800, 600, 16 ], - 791 => [ 1024, 768, 16 ], - 794 => [ 1280, 1024, 16 ], -); -sub bios_vga_modes { - my ($xres, $depth) = @_; - foreach (keys %bios_vga_modes) { - my $l = $bios_vga_modes{$_}; - return ($_, @$l) if $xres == $l->[0] && $depth == $l->[2]; - } - (); -} - -{ #- @monitorSize2resolution - my %l = my @l = ( #- size in inch - 13 => "640x480", - 14 => "800x600", - 15 => "800x600", - 16 => "1024x768", - 17 => "1024x768", - 18 => "1024x768", - 19 => "1280x1024", - 20 => "1280x1024", - 21 => "1600x1200", - 22 => "1600x1200", - ); - for (my $i = 0; $i < $l[0]; $i++) { - $monitorSize2resolution[$i] = $l[1]; - } - while (my ($s, $r) = each %l) { - $monitorSize2resolution[$s] = $r; - } -} - -%VideoRams = ( - 256 => __("256 kB"), - 512 => __("512 kB"), - 1024 => __("1 MB"), - 2048 => __("2 MB"), - 4096 => __("4 MB"), - 8192 => __("8 MB"), - 16384 => __("16 MB"), - 32768 => __("32 MB"), - 65536 => __("64 MB or more"), -); - -$good_default_monitor = arch() !~ /ppc/ ? 'Generic|1024x768 @ 70 Hz' : - detect_devices::get_mac_model =~ /^iBook/ ? 'Apple|iBook 800x600' : 'Apple|iMac/PowerBook 1024x768'; -$low_default_monitor = 'Generic|800x600 @ 56 Hz'; - -@vsyncranges = ("50-70", "50-90", "50-100", "40-150"); - -@hsyncranges = ( - "31.5", - "31.5-35.1", - "31.5-37.9", - "31.5-48.5", - "31.5-57.0", - "31.5-64.3", - "31.5-79.0", - "31.5-82.0", - "31.5-88.0", - "31.5-94.0", -); - -%min_hsync4x_res = ( - 640 => 31.5, - 800 => 35.1, - 1024 => 35.5, - 1152 => 44.0, - 1280 => 51.0, - 1400 => 65.5, - 1600 => 75.0, - 1920 => 90.0, - 2048 => 136.5, -); - - -#- most usefull XFree86-4.0.1 server options. Default values is the first ones. -@options_serverflags = ( - 'DontZap' => [ "Off", "On" ], - 'DontZoom' => [ "Off", "On" ], - 'DisableVidModeExtension' => [ "Off", "On" ], - 'AllowNonLocalXvidtune' => [ "Off", "On" ], - 'DisableModInDev' => [ "Off", "On" ], - 'AllowNonLocalModInDev' => [ "Off", "On" ], - 'AllowMouseOpenFail' => [ "False", "True" ], - 'VTSysReq' => [ "Off", "On" ], - 'BlankTime' => [ "10", "5", "3", "15", "30" ], - 'StandByTime' => [ "20", "10", "6", "30", "60" ], - 'SuspendTime' => [ "30", "15", "9", "45", "90" ], - 'OffTime' => [ "40", "20", "12", "60", "120" ], - 'Pixmap' => [ "32", "24" ], - 'PC98' => [ "auto-detected", "False", "True" ], - 'NoPM' => [ "False", "True" ], -); - -#- most usefull server options have to be accessible at the beginning, since -#- no more than a small set of options will be available for the user, maybe ? -@options = ( - [ 'DPMS', 'XFree86', '.*' ], - [ 'SyncOnGreen', 'XFree86', '.*' ], -); - -%XkbOptions = ( - 'ru(winkeys)' => [ 'XkbOptions "grp:caps_toggle"' ], -); - -$XF86firstchunk_text = q(# File generated by XFdrake. - -# ********************************************************************** -# Refer to the XF86Config man page for details about the format of -# this file. -# ********************************************************************** - -Section "Files" - # Multiple FontPath entries are allowed (they are concatenated together) - # By default, Mandrake 6.0 and later now use a font server independent of - # the X server to render fonts. - FontPath "unix/:-1" -EndSection - -Section "ServerFlags" - #DontZap # disable (server abort) - #DontZoom # disable / (resolution switching) - AllowMouseOpenFail # allows the server to start up even if the mouse doesn't work -EndSection - -); - -$ModeLines_text_ext = - arch() =~ /ppc/ ? ' - # Apple iMac modes - ModeLine "1024x768" 78.525 1024 1049 1145 1312 768 769 772 800 +hsync +vsync - ModeLine "800x600" 62.357 800 821 901 1040 600 601 604 632 +hsync +vsync - ModeLine "640x480" 49.886 640 661 725 832 480 481 484 514 +hsync +vsync - # Apple monitors tend to do 832x624 - ModeLine "832x624" 57 832 876 940 1152 624 625 628 667 -hsync -vsync - # Apple PowerBook G3 - ModeLine "800x600" 100 800 816 824 840 600 616 624 640 -hsync -vsync - # Apple TI Powerbook - ModeLine "1152x768" 78.741 1152 1173 1269 1440 768 769 772 800 +vsync +vsync - # Pismo Firewire G3 - ModeLine "1024x768" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync - # iBook2 - ModeLine "1024x768" 65 1024 1048 1184 1344 768 771 777 806 -hsync -vsync - # 17" Apple Studio Display - ModeLine "1024x768" 112.62 1024 1076 1248 1420 768 768 780 808 +hsync +vsync - # HiRes Apple Studio Display - ModeLine "1280x1024" 135 1280 1288 1392 1664 1024 1027 1030 1064 - # Another variation - ModeLine "1280x1024" 134.989 1280 1317 1429 1688 1024 1025 1028 1066 +hsync +vsync -' : ' - # Sony Vaio C1(X,XS,VE,VN)? - # 1024x480 @ 85.6 Hz, 48 kHz hsync - ModeLine "1024x480" 65.00 1024 1032 1176 1344 480 488 494 563 -hsync -vsync - - # TV fullscreen mode or DVD fullscreen output. - # 768x576 @ 79 Hz, 50 kHz hsync - ModeLine "768x576" 50.00 768 832 846 1000 576 590 595 630 - # 768x576 @ 100 Hz, 61.6 kHz hsync - ModeLine "768x576" 63.07 768 800 960 1024 576 578 590 616 - -'; - -$ModeLines_text_standard = ' - # This is a set of standard mode timings. Modes that are out of monitor spec - # are automatically deleted by the server (provided the HorizSync and - # VertRefresh lines are correct), so there\'s no immediate need to - # delete mode timings (unless particular mode timings don\'t work on your - # monitor). With these modes, the best standard mode that your monitor - # and video card can support for a given resolution is automatically - # used. - - # 640x400 @ 70 Hz, 31.5 kHz hsync - ModeLine "640x400" 25.175 640 664 760 800 400 409 411 450 - # 640x480 @ 60 Hz, 31.5 kHz hsync - ModeLine "640x480" 25.175 640 664 760 800 480 491 493 525 - # 800x600 @ 56 Hz, 35.15 kHz hsync - ModeLine "800x600" 36 800 824 896 1024 600 601 603 625 - # 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync - ModeLine "1024x768" 44.9 1024 1048 1208 1264 768 776 784 817 Interlace - - # 640x400 @ 85 Hz, 37.86 kHz hsync - ModeLine "640x400" 31.5 640 672 736 832 400 401 404 445 -HSync +VSync - # 640x480 @ 75 Hz, 37.50 kHz hsync - ModeLine "640x480" 31.5 640 656 720 840 480 481 484 500 -HSync -VSync - # 800x600 @ 60 Hz, 37.8 kHz hsync - ModeLine "800x600" 40 800 840 968 1056 600 601 605 628 +hsync +vsync - - # 640x480 @ 85 Hz, 43.27 kHz hsync - ModeLine "640x480" 36 640 696 752 832 480 481 484 509 -HSync -VSync - # 1152x864 @ 89 Hz interlaced, 44 kHz hsync - ModeLine "1152x864" 65 1152 1168 1384 1480 864 865 875 985 Interlace - - # 800x600 @ 72 Hz, 48.0 kHz hsync - ModeLine "800x600" 50 800 856 976 1040 600 637 643 666 +hsync +vsync - # 1024x768 @ 60 Hz, 48.4 kHz hsync - ModeLine "1024x768" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync - - # 640x480 @ 100 Hz, 53.01 kHz hsync - ModeLine "640x480" 45.8 640 672 768 864 480 488 494 530 -HSync -VSync - # 1152x864 @ 60 Hz, 53.5 kHz hsync - ModeLine "1152x864" 89.9 1152 1216 1472 1680 864 868 876 892 -HSync -VSync - # 800x600 @ 85 Hz, 55.84 kHz hsync - ModeLine "800x600" 60.75 800 864 928 1088 600 616 621 657 -HSync -VSync - - # 1024x768 @ 70 Hz, 56.5 kHz hsync - ModeLine "1024x768" 75 1024 1048 1184 1328 768 771 777 806 -hsync -vsync - # 1280x1024 @ 87 Hz interlaced, 51 kHz hsync - ModeLine "1280x1024" 80 1280 1296 1512 1568 1024 1025 1037 1165 Interlace - - # 800x600 @ 100 Hz, 64.02 kHz hsync - ModeLine "800x600" 69.65 800 864 928 1088 600 604 610 640 -HSync -VSync - # 1024x768 @ 76 Hz, 62.5 kHz hsync - ModeLine "1024x768" 85 1024 1032 1152 1360 768 784 787 823 - # 1152x864 @ 70 Hz, 62.4 kHz hsync - ModeLine "1152x864" 92 1152 1208 1368 1474 864 865 875 895 - # 1280x1024 @ 61 Hz, 64.2 kHz hsync - ModeLine "1280x1024" 110 1280 1328 1512 1712 1024 1025 1028 1054 - # 1400x1050 @ 60 Hz, 65.5 kHz - ModeLine "1400x1050" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +HSync +VSync - - # 1024x768 @ 85 Hz, 70.24 kHz hsync - ModeLine "1024x768" 98.9 1024 1056 1216 1408 768 782 788 822 -HSync -VSync - # 1152x864 @ 78 Hz, 70.8 kHz hsync - ModeLine "1152x864" 110 1152 1240 1324 1552 864 864 876 908 - - # 1280x1024 @ 70 Hz, 74.59 kHz hsync - ModeLine "1280x1024" 126.5 1280 1312 1472 1696 1024 1032 1040 1068 -HSync -VSync - # 1600x1200 @ 60Hz, 75.00 kHz hsync - ModeLine "1600x1200" 162 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync - # 1152x864 @ 84 Hz, 76.0 kHz hsync - ModeLine "1152x864" 135 1152 1464 1592 1776 864 864 876 908 - - # 1280x1024 @ 75 Hz, 79.98 kHz hsync - ModeLine "1280x1024" 135 1280 1296 1440 1688 1024 1025 1028 1066 +HSync +VSync - - # 1024x768 @ 100Hz, 80.21 kHz hsync - ModeLine "1024x768" 115.5 1024 1056 1248 1440 768 771 781 802 -HSync -VSync - # 1400x1050 @ 75 Hz, 82.2 kHz hsync - ModeLine "1400x1050" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +HSync +VSync - - # 1600x1200 @ 70 Hz, 87.50 kHz hsync - ModeLine "1600x1200" 189 1600 1664 1856 2160 1200 1201 1204 1250 -HSync -VSync - # 1152x864 @ 100 Hz, 89.62 kHz hsync - ModeLine "1152x864" 137.65 1152 1184 1312 1536 864 866 885 902 -HSync -VSync - # 1280x1024 @ 85 Hz, 91.15 kHz hsync - ModeLine "1280x1024" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +HSync +VSync - # 1600x1200 @ 75 Hz, 93.75 kHz hsync - ModeLine "1600x1200" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync - # 1600x1200 @ 85 Hz, 105.77 kHz hsync - ModeLine "1600x1200" 220 1600 1616 1808 2080 1200 1204 1207 1244 +HSync +VSync - # 1600x1200 @ 85 Hz, 106.3 kHz hsync - ModeLine "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync - # 1280x1024 @ 100 Hz, 107.16 kHz hsync - ModeLine "1280x1024" 181.75 1280 1312 1440 1696 1024 1031 1046 1072 -HSync -VSync - - # 1800x1440 @ 64Hz, 96.15 kHz hsync - ModeLine "1800X1440" 230 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync - # 1800x1440 @ 70Hz, 104.52 kHz hsync - ModeLine "1800X1440" 250 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync - - # 1920x1440 @ 60 Hz, 90.0 kHz hsync - ModeLine "1920x1440" 234.0 1920 2048 2256 2600 1440 1441 1444 1500 -HSync +VSync - # 1920x1440 @ 75 Hz, 112.5kHz hsync - ModeLine "1920x1440" 297.0 1920 2064 2288 2640 1440 1441 1444 1500 -HSync +VSync - - # 512x384 @ 78 Hz, 31.50 kHz hsync - ModeLine "512x384" 20.160 512 528 592 640 384 385 388 404 -HSync -VSync - # 512x384 @ 85 Hz, 34.38 kHz hsync - ModeLine "512x384" 22 512 528 592 640 384 385 388 404 -HSync -VSync - - - # Low-res Doublescan modes - # If your chipset does not support doublescan, you get a \'squashed\' - # resolution like 320x400. - - # 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio - ModeLine "320x200" 12.588 320 336 384 400 200 204 205 225 Doublescan - # 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio - ModeLine "320x240" 12.588 320 336 384 400 240 245 246 262 Doublescan - # 320x240 @ 72 Hz, 36.5 kHz hsync - ModeLine "320x240" 15.750 320 336 384 400 240 244 246 262 Doublescan - # 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio - ModeLine "400x300" 18 400 416 448 512 300 301 302 312 Doublescan - # 400x300 @ 60 Hz, 37.8 kHz hsync - ModeLine "400x300" 20 400 416 480 528 300 301 303 314 Doublescan - # 400x300 @ 72 Hz, 48.0 kHz hsync - ModeLine "400x300" 25 400 424 488 520 300 319 322 333 Doublescan - # 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio - ModeLine "480x300" 21.656 480 496 536 616 300 301 302 312 Doublescan - # 480x300 @ 60 Hz, 37.8 kHz hsync - ModeLine "480x300" 23.890 480 496 576 632 300 301 303 314 Doublescan - # 480x300 @ 63 Hz, 39.6 kHz hsync - ModeLine "480x300" 25 480 496 576 632 300 301 303 314 Doublescan - # 480x300 @ 72 Hz, 48.0 kHz hsync - ModeLine "480x300" 29.952 480 504 584 624 300 319 322 333 Doublescan - -'; - -$devicesection_text = ' -Section "Device" - Identifier "Generic VGA" - Chipset "generic" -EndSection - -'; -- cgit v1.2.1