diff options
author | damien <damien@mandriva.com> | 2000-11-28 16:56:52 +0000 |
---|---|---|
committer | damien <damien@mandriva.com> | 2000-11-28 16:56:52 +0000 |
commit | 0880c7ba8ce88e87fa600aeb367a8f88a3ae71e7 (patch) | |
tree | 33f7ac905998f9ad6d85090f777ee4c0d0c67032 /perl-install/Xconfig.pm | |
parent | d5c526273db473a7d87a26000585900fc10dda7d (diff) | |
download | drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar.gz drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar.bz2 drakx-backup-do-not-use-topic/unlabeled-1.1.1.tar.xz drakx-backup-do-not-use-topic/unlabeled-1.1.1.zip |
branch to build the firewall install.topic/unlabeled-1.1.1
Diffstat (limited to 'perl-install/Xconfig.pm')
-rw-r--r-- | perl-install/Xconfig.pm | 144 |
1 files changed, 99 insertions, 45 deletions
diff --git a/perl-install/Xconfig.pm b/perl-install/Xconfig.pm index 042388e85..350c7df33 100644 --- a/perl-install/Xconfig.pm +++ b/perl-install/Xconfig.pm @@ -1,11 +1,17 @@ -package Xconfig; +package Xconfig; # $Id$ + +use diagnostics; +use strict; use common qw(:common :file :system); +use mouse; +use devices; +use Xconfigurator; # otherwise uses the rule substr($keymap, 0, 2) my %keymap_translate = ( cf => "ca_enhanced", - uk => "gb", + uk => "gb", ); @@ -17,73 +23,121 @@ sub keymap_translate { sub getinfo { - my $o = {}; - getinfoFromXF86Config($o); + my $o = shift || {}; + getinfoFromDDC($o); getinfoFromSysconfig($o); - unless ($o->{mouse}->{xtype}) { - my ($type, $dev) = split("\n", `mouseconfig --nointeractive 2>/dev/null`) or die "mouseconfig failed"; - $o->{mouse}->{xtype} ||= $type; - $o->{mouse}->{device} ||= "/dev/$dev"; - } - $o->{mouse}->{device} ||= "/dev/mouse" if -e "/dev/mouse"; + add2hash($o->{mouse}, mouse::detect()) unless $o->{mouse}{XMOUSETYPE}; + + $o->{mouse}{device} ||= "mouse" if -e "/dev/mouse"; $o; } sub getinfoFromXF86Config { my $o = shift || {}; - my (%c, $depth); + my $prefix = shift || ""; + my (%c, $depth, $driver); + + $o->{card}{server} ||= $1 if readlink("$prefix/etc/X11/X") =~ /XF86_ (\w+)$/x; #- /x for perl2fcalls - $o->{card}->{server} ||= $1 if readlink("/etc/X11/X") =~ /XF86_ (\w+)$/x; # /x for perl2fcalls - - local *F; - open F, "/etc/X11/XF86Config" or return {}; - foreach (<F>) { + local *F; open F, "$prefix/etc/X11/XF86Config" or return {}; + local $_; + while (<F>) { if (/^Section "Keyboard"/ .. /^EndSection/) { - $o->{keyboard}->{xkb_keymap} ||= $1 if /^\s*XkbLayout\s+"(.*?)"/; + $o->{keyboard}{xkb_keymap} ||= $1 if /^\s*XkbLayout\s+"(.*?)"/; } elsif (/^Section "Pointer"/ .. /^EndSection/) { - $o->{mouse}->{xtype} ||= $1 if /^\s*Protocol\s+"(.*?)"/; - $o->{mouse}->{device} ||= $1 if /^\s*Device\s+"(.*?)"/; + $o->{mouse}{XMOUSETYPE} ||= $1 if /^\s*Protocol\s+"(.*?)"/; + $o->{mouse}{device} ||= $1 if m|^\s*Device\s+"/dev/(.*?)"|; + $o->{mouse}{cleardtrrts} ||= 1 if m/^\s*ClearDTR\s+/; + $o->{mouse}{cleardtrrts} ||= 1 if m/^\s*ClearRTS\s+/; + $o->{mouse}{nbuttons} = 2 if m/^\s*Emulate3Buttons\s+/; + $o->{mouse}{nbuttons} ||= 5 if m/^\s*ZAxisMapping\s.*5/; + $o->{mouse}{nbuttons} = 7 if m/^\s*ZAxisMapping\s.*7/; } elsif (my $i = /^Section "Device"/ .. /^EndSection/) { - if ($i = 1 && $c{type} && $c{type} ne "Generic VGA") { - add2hash($o->{card} ||= {}, \%c); - %c = (); - } + %c = () if $i == 1; + $c{type} ||= $1 if /^\s*Identifier\s+"(.*?)"/; - $c{memory} ||= $1 if /^\s*VideoRam\s+(\d+)/; + $c{memory} ||= $1 if /VideoRam\s+(\d+)/; + $c{flags}{needVideoRam} ||= 1 if /^\s*VideoRam\s+/; $c{vendor} ||= $1 if /^\s*VendorName\s+"(.*?)"/; $c{board} ||= $1 if /^\s*BoardName\s+"(.*?)"/; - - push @{$c{lines}}, $_ unless /(Section|Identifier|VideoRam|VendorName|BoardName)/; + $c{driver} ||= $1 if /^\s*Driver\s+"(.*?)"/; + $c{options}{$1} ||= 1 if /^\s*Option\s+"(.*?)"/; + $c{options}{$1} ||= 0 if /^\s*#\s*Option\s+"(.*?)"/; + + #- clockchip, ramdac, dacspeed read with following line. + push @{$c{lines}}, $_ unless /(Section|Identifier|VideoRam|VendorName|BoardName|Option)/; + + add2hash($o->{card} ||= {}, \%c) if ($i =~ /E0/ && $c{type} && $c{type} ne "Generic VGA"); } elsif (/^Section "Monitor"/ .. /^EndSection/) { - $o->{monitor}->{type} ||= $1 if /^\s*Identifier\s+"(.*?)"/; - $o->{monitor}->{hsyncrange} ||= $1 if /^\s*HorizSync\s+(.*)/; - $o->{monitor}->{vsyncrange} ||= $1 if /^\s*VertRefresh\s+(.*)/; - $o->{monitor}->{vendor} ||= $1 if /^\s*VendorName\s+"(.*?)"/; - $o->{monitor}->{model} ||= $1 if /^\s*ModelName\s+"(.*?)"/; - } elsif (/^Section "Screen"/ .. /^EndSection/) { - $o->{card}->{default_depth} ||= $1 if /^\s*DefaultColorDepth\s+(\d+)/; - if (my $i = /^\s*Subsection\s+"Display"/ .. /^\s*EndSubsection/) { - $depth = undef if $i == 1; - $depth = $1 if /^\s*Depth\s+(\d*)/; - if (/^\s*Modes\s+(.*)/) { - my $a = 0; - push @{$o->{card}->{depth}->{$depth || 8}}, - grep { $_->[0] >= 640 } map { [ /"(\d+)x(\d+)"/ ] } split ' ', $1; + $o->{monitor}{type} ||= $1 if /^\s*Identifier\s+"(.*?)"/; + $o->{monitor}{hsyncrange} ||= $1 if /^\s*HorizSync\s+(.*)/; + $o->{monitor}{vsyncrange} ||= $1 if /^\s*VertRefresh\s+(.*)/; + $o->{monitor}{vendor} ||= $1 if /^\s*VendorName\s+"(.*?)"/; + $o->{monitor}{model} ||= $1 if /^\s*ModelName\s+"(.*?)"/; + $o->{monitor}{modelines} .= $_ if /^\s*Mode[lL]ine\s+/; + } elsif (my $s = /^Section "Screen"/ .. /^EndSection/) { + undef $driver if $s == 1; + $driver = $1 if /^\s*Driver\s+"(.*?)"/; + if ($driver eq $Xconfigurator::serversdriver{$o->{card}{server}}) { + $o->{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 @{$o->{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. + if (my @depth = keys %{$o->{card}{depth}}) { + $o->{resolution_wanted} ||= + ($o->{card}{depth}{$o->{default_depth} || $depth[0]}[0][0]) . "x" . + ($o->{card}{depth}{$o->{default_depth} || $depth[0]}[0][1]); + } $o; } sub getinfoFromSysconfig { my $o = shift || {}; - if (my %mouse = getVarsFromSh "/etc/sysconfig/mouse") { - $o->{mouse}->{xtype} ||= $mouse{XMOUSETYPE}; + my $prefix = shift || ""; + + add2hash($o->{mouse} ||= {}, { getVarsFromSh("$prefix/etc/sysconfig/mouse") }); + + if (my %keyboard = getVarsFromSh "$prefix/etc/sysconfig/keyboard") { + $o->{keyboard}{xkb_keymap} ||= keymap_translate($keyboard{KEYTABLE}) if $keyboard{KEYTABLE}; } - if (my %keyboard = getVarsFromSh "/etc/sysconfig/keyboard") { - $keyboard{KEYTABLE} or last; - $o->{keyboard}->{xkb_keymap} ||= keymap_translate($keyboard{KEYTABLE}); + $o; +} + +sub getinfoFromDDC { + my $o = shift || {}; + my $O = $o->{monitor} ||= {}; + #- return $o if $O->{hsyncrange} && $O->{vsyncrange} && $O->{modelines}; + devices::make("/dev/zero"); #- needed by ddcxinfos + my ($m, @l) = `ddcxinfos`; + $? == 0 or return $o; + + $o->{card}{memory} ||= 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 @{$o->{card}{depth}{$depth}}, [ $x, $y ] unless scalar grep { $_->[0] == $x && $_->[1] == $y } @{$o->{card}{depth}{$depth}}; + push @{$o->{card}{depth}{32}}, [ $x, $y ] if $depth == 24 && ! scalar grep { $_->[0] == $x && $_->[1] == $y } @{$o->{card}{depth}{32}}; + } } + my ($h, $v, $size, @m) = @l; + + chop $h; chop $v; + $O->{hsyncrange} ||= $h; + $O->{vsyncrange} ||= $v; + $O->{size} ||= to_float($size); + $O->{modelines} ||= join '', @m; + $o; } |