aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/docs/coding-guidelines.html
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/docs/coding-guidelines.html')
-rw-r--r--phpBB/docs/coding-guidelines.html310
1 files changed, 243 insertions, 67 deletions
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index dd0ee0a82f..e73c563d5b 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -1,16 +1,9 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
+<!DOCTYPE html>
+<html dir="ltr" lang="en">
<head>
-
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<meta http-equiv="content-style-type" content="text/css" />
-<meta http-equiv="content-language" content="en" />
-<meta http-equiv="imagetoolbar" content="no" />
-<meta name="resource-type" content="document" />
-<meta name="distribution" content="global" />
-<meta name="copyright" content="phpBB Group" />
+<meta charset="utf-8">
<meta name="keywords" content="" />
-<meta name="description" content="Olympus coding guidelines document" />
+<meta name="description" content="Ascraeus coding guidelines document" />
<title>phpBB3 &bull; Coding Guidelines</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen, projection" />
@@ -28,7 +21,7 @@
<div id="doc-description">
<a href="../index.php" id="logo"><img src="site_logo.gif" alt="" /></a>
<h1>Coding Guidelines</h1>
- <p>Olympus coding guidelines document</p>
+ <p>Ascraeus coding guidelines document</p>
<p style="display: none;"><a href="#start_here">Skip</a></p>
</div>
@@ -42,7 +35,7 @@
<!-- BEGIN DOCUMENT -->
-<p>These are the phpBB Coding Guidelines for Olympus, all attempts should be made to follow them as closely as possible.</p>
+<p>These are the phpBB Coding Guidelines for Ascraeus, all attempts should be made to follow them as closely as possible.</p>
<h1>Coding Guidelines</h1>
@@ -62,11 +55,12 @@
</li>
<li><a href="#code">Code Layout/Guidelines</a>
<ol style="list-style-type: lower-roman;">
- <li><a href="#namingvars">Variable/Function Naming</a></li>
+ <li><a href="#namingvars">Variable/Function/Class Naming</a></li>
<li><a href="#codelayout">Code Layout</a></li>
<li><a href="#sql">SQL/SQL Layout</a></li>
<li><a href="#optimizing">Optimizations</a></li>
<li><a href="#general">General Guidelines</a></li>
-rw-r--r--
perl-install/Xconfig/FILES6
-rw-r--r--perl-install/Xconfig/card.pm635
-rw-r--r--perl-install/Xconfig/default.pm45
-rw-r--r--perl-install/Xconfig/main.pm262
-rw-r--r--perl-install/Xconfig/monitor.pm275
-rw-r--r--perl-install/Xconfig/parse.pm205
-rw-r--r--perl-install/Xconfig/proprietary.pm35
-rw-r--r--perl-install/Xconfig/resolution_and_depth.pm386
-rw-r--r--perl-install/Xconfig/screen.pm29
-rw-r--r--perl-install/Xconfig/test.pm140
-rw-r--r--perl-install/Xconfig/various.pm178
-rw-r--r--perl-install/Xconfig/xfree.pm742
12 files changed, 0 insertions, 2938 deletions
diff --git a/perl-install/Xconfig/FILES b/perl-install/Xconfig/FILES
deleted file mode 100644
index f6352dedf..000000000
--- a/perl-install/Xconfig/FILES
+++ /dev/null
@@ -1,6 +0,0 @@
-
-parse --- xfree ---- default ------------------ main
- \--- card -------------------/ test
- \-- monitor ---------------/ various
- \- screen ---------------/ proprietary
- \ resolution_and_depth-/
diff --git a/perl-install/Xconfig/card.pm b/perl-install/Xconfig/card.pm
deleted file mode 100644
index 686957ddb..000000000
--- a/perl-install/Xconfig/card.pm
+++ /dev/null
@@ -1,635 +0,0 @@
-package Xconfig::card; # $Id$
-
-use diagnostics;
-use strict;
-
-use detect_devices;
-use modules;
-use common;
-use log;
-
-
-my %VideoRams = (
- 256 => N_("256 kB"),
- 512 => N_("512 kB"),
- 1024 => N_("1 MB"),
- 2048 => N_("2 MB"),
- 4096 => N_("4 MB"),
- 8192 => N_("8 MB"),
- 16384 => N_("16 MB"),
- 32768 => N_("32 MB"),
- 65536 => N_("64 MB or more"),
-);
-
-my $lib = arch() =~ /x86_64/ ? "lib64" : "lib";
-
-my @xfree4_Drivers = ((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 vesa
- s3 s3virge savage siliconmotion sis tdfx tga trident tseng vmware)),
- qw(ati glint vga fbdev));
-
-sub from_raw_X {
- my ($raw_X) = @_;
-
- my $device = $raw_X->get_device or die "no card configured";
-
- my $card = {
- use_DRI_GLX => eval { any { /dri/ } $raw_X->get_modules },
- %$device,
- };
- add_to_card__using_Cards($card, $card->{BoardName});
- $card;
-}
-
-sub to_raw_X {
- my ($card, $raw_X) = @_;
-
- my @cards = ($card, @{$card->{cards} || []});
-
- foreach (@cards) {
- #- Specific ATI fglrx driver default options
- if ($_->{Driver} eq 'fglrx') {
- # $default_ATI_fglrx_config need to be move in proprietary ?
- $_->{raw_LINES} ||= default_ATI_fglrx_config();
- }
- if (arch() =~ /ppc/ && ($_->{Driver} eq 'r128' || $_->{Driver} eq 'radeon')) {
- $_->{UseFBDev} = 1;
- }
- }
-
- $raw_X->set_devices(@cards);
-
- $raw_X->get_ServerLayout->{Xinerama} = { commented => !$card->{Xinerama}, Option => 1 }
- if defined $card->{Xinerama};
-
- # cleanup previous special nvidia libglx
- $raw_X->remove_load_module($_) foreach @{$card->{REMOVE_GLX} || []};
-
- if ($card->{DRI_GLX_SPECIAL}) {
- $raw_X->remove_load_module('glx'); # this doesn't duplicate the above glx line
- # This loads the NVIDIA GLX extension module.
- # IT IS IMPORTANT TO KEEP NAME AS FULL PATH TO libglx.so ELSE
- # IT WILL LOAD XFree86 glx module and the server will crash.
- $raw_X->add_load_module($card->{DRI_GLX_SPECIAL});
- } else {
- $raw_X->set_load_module('glx', $card->{Driver} ne 'fbdev'); #- glx for everyone, except proprietary nvidia and fbdev
- $raw_X->set_load_module('dri', $card->{use_DRI_GLX});
- }
-
- $raw_X->remove_Section('DRI');
-
- $raw_X->remove_load_module('v4l') if $card->{use_DRI_GLX} && $card->{Driver} eq 'r128';
-}
-
-sub default_ATI_fglrx_config() { our $default_ATI_fglrx_config }
-
-sub probe() {
-#-for Pixel tests
-#- my @c = { driver => 'Card:Matrox Millennium G400 DualHead', description => 'Matrox|Millennium G400 Dual HeadCard' };
- my @c = detect_devices::matching_driver__regexp('^(Card|Server|Driver):');
-
- 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:(.*)/) { $card->{BoardName} = $1; add_to_card__using_Cards($card, $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!");
- my $s = cat_("/proc/fb");
- @cards = { server => $s =~ /Mach64/ ? "Mach64" : $s =~ /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 && !$cards[0]{MULTI_HEAD} && arch() !~ /ppc/) {
- delete $cards[0]{BusID};
- }
-
- @cards;
-}
-
-sub card_config__not_listed {
- my ($in, $card, $options) = @_;
-
- my $vendors_regexp = join '|', map { quotemeta } (
- '3Dlabs',
- 'AOpen', 'ASUS', 'ATI', 'Ark Logic', 'Avance Logic',
- 'Cardex', 'Chaintech', 'Chips & Technologies', 'Cirrus Logic', 'Compaq', 'Creative Labs',
- 'Dell', 'Diamond', 'Digital',
- 'ET', 'Elsa',
- 'Genoa', 'Guillemot', 'Hercules', 'Intel', 'Leadtek',
- 'Matrox', 'Miro', 'NVIDIA', 'NeoMagic', 'Number Nine',
- 'Oak', 'Orchid',
- 'RIVA', 'Rendition Verite',
- 'S3', 'Silicon Motion', 'STB', 'SiS', 'Sun',
- 'Toshiba', 'Trident',
- 'VideoLogic',
- );
- my $cards = readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+");
-
- my @xf4 = grep { $options->{allowFB} || $::isStandalone || $_ ne 'fbdev' } @xfree4_Drivers;
- my @list = (
- (map { 'Vendor|' . $_ } keys %$cards),
- (map { 'Xorg|' . $_ } @xf4),
- );
-
- my $r = exists $cards->{$card->{BoardName}} ? "Vendor|$card->{BoardName}" : 'Xorg|vesa';
- $in->ask_from_({ title => N("X server"),
- messages => N("Choose an X server"),
- interactive_help_id => 'configureX_card_list',
- },
- [ { val => \$r, separator => '|', list => \@list, sort => 1,
- format => sub { $_[0] =~ /^Vendor\|($vendors_regexp)\s*-?(.*)/ ? "Vendor|$1|$2" :
- $_[0] =~ /^Vendor\|(.*)/ ? "Vendor|Other|$1" : $_[0] } } ]) or return;
-
- log::explanations("Xconfig::card: $r manually chosen");
-
- $r eq "Vendor|$card->{BoardName}" and return 1; #- it is unchanged, do not modify $card
-
- my ($kind, $s) = $r =~ /(.*?)\|(.*)/;
-
- %$card = ();
- if ($kind eq 'Vendor') {
- add_to_card__using_Cards($card, $s);
- } else {
- $card->{Driver} = $s;
- }
- $card->{manually_chosen} = 1;
- 1;
-}
-
-sub multi_head_choose {
- my ($in, $auto, @cards) = @_;
-
- my @choices = multi_head_choices('', @cards);
-
- my $tc = $choices[0];
- if ($auto) {
- @choices == 1 or return;
- } else {
- $tc = $in->ask_from_listf(N("Multi-head configuration"),
- N("Your system supports 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 configure_auto_install {
- my ($raw_X, code>private</code> and <code>protected</code> for all properties instead of <code>var</code>.
+
+ <p>Place the <code>static</code> qualifier before the visibility qualifiers.</p>
+
+ <p class="bad">//Wrong </p>
+ <div class="codebox"><pre>
+var $x;
+private static function f()
+ </pre></div>
+
+ <p class="good">// Right </p>
+ <div class="codebox"><pre>
+public $x;
+static private function f()
+ </pre></div>
+
+ <h4>Constants</h4>
+ <p>Prefer class constants over global constants created with <code>define()</code>.</p>
+
<a name="sql"></a><h3>2.iii. SQL/SQL Layout</h3>
<h4>Common SQL Guidelines: </h4>
- <p>All SQL should be cross-DB compatible, if DB specific SQL is used alternatives must be provided which work on all supported DB's (MySQL3/4/5, MSSQL (7.0 and 2000), PostgreSQL (7.0+), Firebird, SQLite, Oracle8, ODBC (generalised if possible)).</p>
+ <p>All SQL should be cross-DB compatible, if DB specific SQL is used alternatives must be provided which work on all supported DB's (MySQL3/4/5, MSSQL (7.0 and 2000), PostgreSQL (8.3+), Firebird, SQLite, Oracle8, ODBC (generalised if possible)).</p>
<p>All SQL commands should utilise the DataBase Abstraction Layer (DBAL)</p>
<h4>SQL code layout:</h4>
@@ -1042,6 +1146,22 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<p>Your page should either call <code>page_footer()</code> in the end to trigger output through the template engine and terminate the script, or alternatively at least call the <code>exit_handler()</code>. That call is necessary because it provides a method for external applications embedding phpBB to be called at the end of the script.</p>
+ <a name="phprestrictions"></a><h3>2.vi. Restrictions on the Use of PHP</h3>
+
+ <h4>Dynamic code execution:</h4>
+
+ <p>Never execute dynamic PHP code (generated or in a constant string) using any of the following PHP functions:</p>
+
+ <ul>
+ <li><strong>eval</strong></li>
+ <li><strong>create_function</strong></li>
+ <li><strong>preg_replace</strong> with the <strong>e</strong> modifier in the pattern</li>
+ </ul>
+
+ <p>If absolutely necessary a file should be created, and a mechanism for creating this file prior to running phpBB should be provided as a setup process.</p>
+
+ <p>The <strong>e</strong> modifier in <strong>preg_replace</strong> can be replaced by <strong>preg_replace_callback</strong> and objects to encapsulate state that is needed in the callback code.</p>
+
</div>
<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
@@ -1057,15 +1177,19 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<div class="content">
<a name="cfgfiles"></a><h3>3.i. Style Config Files</h3>
- <p>Style cfg files are simple name-value lists with the information necessary for installing a style. Similar cfg files exist for templates, themes and imagesets. These follow the same principle and will not be introduced individually. Styles can use installed components by using the required_theme/required_template/required_imageset entries. The important part of the style configuration file is assigning an unique name.</p>
+ <p>Style cfg files are simple name-value lists with the information necessary for installing a style. The important part of the style configuration file is assigning an unique name.</p>
<div class="codebox"><pre>
- # General Information about this style
- name = prosilver_duplicate
- copyright = &copy; phpBB Group, 2007
- version = 3.0.3
- required_template = prosilver
- required_theme = prosilver
- required_imageset = prosilver
+# General Information about this style
+name = prosilver_duplicate
+copyright = &copy; phpBB Group, 2007
+version = 3.1.0
+
+# Defining a different template bitfield
+# template_bitfield = lNg=
+
+# Parent style
+# Set value to empty or to this style's name if this style does not have a parent style
+parent = prosilver
</pre></div>
<a name="genstyling"></a><h3>3.2. General Styling Rules</h3>
<p>Templates should be produced in a consistent manner. Where appropriate they should be based off an existing copy, e.g. index, viewforum or viewtopic (the combination of which implement a range of conditional and variable forms). Please also note that the indentation and coding guidelines also apply to templates where possible.</p>
@@ -1088,7 +1212,7 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<p>Row colours/classes are now defined by the template, use an <code>IF S_ROW_COUNT</code> switch, see viewtopic or viewforum for an example.</p>
-<p>Remember block level ordering is important ... while not all pages validate as XHTML 1.0 Strict compliant it is something we're trying to work on.</p>
+<p>Remember block level ordering is important.</p>
<p>Use a standard cellpadding of 2 and cellspacing of 0 on outer tables. Inner tables can vary from 0 to 3 or even 4 depending on the need.</p>
@@ -1156,13 +1280,13 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<p>A bit later loops will be explained further. To not irritate you we will explain conditionals as well as other statements first.</p>
<h4>Including files</h4>
-<p>Something that existed in 2.0.x which no longer exists in 3.0.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:</p>
+<p>Something that existed in 2.0.x which no longer exists in 3.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:</p>
<div class="codebox"><pre>
<span class="comment">&lt;!-- INCLUDE filename --&gt;</span>
</pre></div>
-<p>You will note in the 3.0 templates the major sources start with <code>&lt;!-- INCLUDE overall_header.html --&gt;</code> or <code>&lt;!-- INCLUDE simple_header.html --&gt;</code>, etc. In 2.0.x control of &quot;which&quot; header to use was defined entirely within the code. In 3.0.x the template designer can output what they like. Note that you can introduce new templates (i.e. other than those in the default set) using this system and include them as you wish ... perhaps useful for a common &quot;menu&quot; bar or some such. No need to modify loads of files as with 2.0.x.</p>
+<p>You will note in the 3.x templates the major sources start with <code>&lt;!-- INCLUDE overall_header.html --&gt;</code> or <code>&lt;!-- INCLUDE simple_header.html --&gt;</code>, etc. In 2.0.x control of &quot;which&quot; header to use was defined entirely within the code. In 3.x the template designer can output what they like. Note that you can introduce new templates (i.e. other than those in the default set) using this system and include them as you wish ... perhaps useful for a common &quot;menu&quot; bar or some such. No need to modify loads of files as with 2.0.x.</p>
<p>Added in <strong>3.0.6</strong> is the ability to include a file using a template variable to specify the file, this functionality only works for root variables (i.e. not block variables).</p>
<div class="codebox"><pre>
@@ -1194,7 +1318,7 @@ append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;
<p>it will be included and executed inline.<br /><br />A note, it is very much encouraged that template designers do not include PHP. The ability to include raw PHP was introduced primarily to allow end users to include banner code, etc. without modifying multiple files (as with 2.0.x). It was not intended for general use ... hence <!-- w --><a href="http://www.phpbb.com">www.phpbb.com</a><!-- w --> will <strong>not</strong> make available template sets which include PHP. And by default templates will have PHP disabled (the admin will need to specifically activate PHP for a template).</p>
<h4>Conditionals/Control structures</h4>
-<p>The most significant addition to 3.0.x are conditions or control structures, &quot;if something then do this else do that&quot;. The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:</p>
+<p>The most significant addition to 3.x are conditions or control structures, &quot;if something then do this else do that&quot;. The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:</p>
<div class="codebox"><pre>
<span class="comment">&lt;!-- IF expr --&gt;</span>
@@ -1265,7 +1389,7 @@ div
<span class="comment">&lt;!-- ENDIF --&gt;</span>
</pre></div>
-<p>Each statement will be tested in turn and the relevant output generated when a match (if a match) is found. It is not necessary to always use ELSEIF, ELSE can be used alone to match &quot;everything else&quot;.<br /><br />So what can you do with all this? Well take for example the colouration of rows in viewforum. In 2.0.x row colours were predefined within the source as either row color1, row color2 or row class1, row class2. In 3.0.x this is moved to the template, it may look a little daunting at first but remember control flows from top to bottom and it's not too difficult:</p>
+<p>Each statement will be tested in turn and the relevant output generated when a match (if a match) is found. It is not necessary to always use ELSEIF, ELSE can be used alone to match &quot;everything else&quot;.<br /><br />So what can you do with all this? Well take for example the colouration of rows in viewforum. In 2.0.x row colours were predefined within the source as either row color1, row color2 or row class1, row class2. In 3.x this is moved to the template, it may look a little daunting at first but remember control flows from top to bottom and it's not too difficult:</p>
<div class="codebox"><pre>
&lt;table&gt;
@@ -1536,26 +1660,78 @@ div
&lt;/form&gt;
</pre></div><br />
- <a name="inheritance"></a><h3>4.ii. Template Inheritance</h3>
- <p>When basing a new style on an existing one, it is not necessary to provide all the template files. By declaring the base style name in the <strong>inherit_from</strong> field in the template configuration file, the style can be set to inherit template files from the base style. The limitation on this is that the base style has to be installed and complete, meaning that it is not itself inheriting.</p>
+ <a name="stylestree"></a><h3>4.ii. Styles Tree</h3>
+ <p>When basing a new style on an existing one, it is not necessary to provide all the template files. By declaring the base style name in the <strong>parent</strong> field in the style configuration file, the style can be set to reuse template files from the parent style.</p>
- <p>The effect of doing so is that the template engine will use the template files in the new style where they exist, but fall back to files in the base style otherwise. Declaring a style to inherit from another also causes it to use some of the configuration settings of the base style, notably database storage.</p>
+ <p>The effect of doing so is that the template engine will use the template files in the new style where they exist, but fall back to files in the parent style otherwise.</p>
- <p>We strongly encourage the use of inheritance for styles based on the bundled styles, as it will ease the update procedure.</p>
+ <p>We strongly encourage the use of parent styles for styles based on the bundled styles, as it will ease the update procedure.</p>
<div class="codebox"><pre>
- # General Information about this template
- name = inherits
- copyright = &copy; phpBB Group, 2007
- version = 3.0.3
+# General Information about this style
+name = Custom Style
+copyright = &amp;copy; phpBB Group, 2007
+version = 3.1.0
- # Defining a different template bitfield
- template_bitfield = lNg=
+# Defining a different template bitfield
+# template_bitfield = lNg=
- # Are we inheriting?
- inherit_from = prosilver
+# Parent style
+# Set value to empty or to this style's name if this style does not have a parent style
+parent = prosilver
</pre></div>
+ <a name="template-events"></a><h3>4.iii. Template Events</h3>
+ <p>Template events must follow this format: <code>&lt;!-- EVENT event_name --&gt;</code></p>
+ <p>Using the above example, files named <code>event_name.html</code> located within extensions will be injected into the location of the event.</p>
+
+ <h4>Template event naming guidelines:</h4>
+ <ul>
+ <li>An event name must be all lowercase, with each word separated by an underscore.</li>
+ <li>An event name must briefly describe the location and purpose of the event.</li>
+ <li>An event name must end with one of the following suffixes:</li>
+ <ul>
+ <li><code>_prepend</code> - This event adds an item to the beginning of a block of related items, or adds to the beginning of individual items in a block.</li>
+ <li><code>_append</code> - This event adds an item to the end of a block of related items, or adds to the end of individual items in a block.</li>
+ <li><code>_before</code> - This event adds content directly before the specified block</li>
+ <li><code>_after</code> - This event adds content directly after the specified block</li>
+ </ul>
+ </ul>
+
+ <h4>Template event documentation</h4>
+ <p>Events must be documented in <code>phpBB/docs/events.md</code> in alphabetical order based on the event name. The format is as follows:</p>
+
+ <ul><li>An event found in only one template file:
+ <div class="codebox"><pre>event_name
+===
+* Location: styles/&lt;style_name&gt;/template/filename.html
+* Purpose: A brief description of what this event should be used for.
+This may span multiple lines.
+</pre></div></li>
+ <li>An event found in multiple template files:
+ <div class="codebox"><pre>event_name
+===
+* Locations:
+ + first/file/path.html
+ + second/file/path.html
+* Purpose: Same as above.
+</pre></div>
+ <li>An event that is found multiple times in a file should have the number of instances in parenthesis next to the filename.
+ <div class="codebox"><pre>event_name
+===
+* Locations:
+ + first/file/path.html (2)
+ + second/file/path.html
+* Purpose: Same as above.
+</pre></div></li>
+ <li>An actual example event documentation:
+ <div class="codebox"><pre>forumlist_body_last_post_title_prepend
+====
+* Locations:
+ + styles/prosilver/template/forumlist_body.html
+ + styles/subsilver2/template/forumlist_body.html
+* Purpose: Add content before the post title of the latest post in a forum on the forum list.</pre></div></ul><br />
+
</div>
<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
@@ -1668,7 +1844,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>With phpBB3, the output encoding for the forum in now UTF-8, a Universal Character Encoding by the Unicode Consortium that is by design a superset to US-ASCII and ISO-8859-1. By using one character set which simultaenously supports all scripts which previously would have required different encodings (eg: ISO-8859-1 to ISO-8859-15 (Latin, Greek, Cyrillic, Thai, Hebrew, Arabic); GB2312 (Simplified Chinese); Big5 (Traditional Chinese), EUC-JP (Japanese), EUC-KR (Korean), VISCII (Vietnamese); et cetera), we remove the need to convert between encodings and improves the accessibility of multilingual forums.</p>
- <p>The impact is that the language files for phpBB must now also be encoded as UTF-8, with a caveat that the files must <strong>not contain</strong> a <acronym title="Byte-Order-Mark">BOM</acronym> for compatibility reasons with non-Unicode aware versions of PHP. For those with forums using the Latin character set (ie: most European languages), this change is transparent since UTF-8 is superset to US-ASCII and ISO-8859-1.</p>
+ <p>The impact is that the language files for phpBB must now also be encoded as UTF-8, with a caveat that the files must <strong>not contain</strong> a <abbr title="Byte-Order-Mark">BOM</abbr> for compatibility reasons with non-Unicode aware versions of PHP. For those with forums using the Latin character set (ie: most European languages), this change is transparent since UTF-8 is superset to US-ASCII and ISO-8859-1.</p>
<h4>Language Tag:</h4>
@@ -1678,8 +1854,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>Most language tags consist of a two- or three-letter language subtag (from <a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO 639-1/ISO 639-2</a>). Sometimes, this is followed by a two-letter or three-digit region subtag (from <a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1 alpha-2</a> or <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">UN M.49</a>). Some examples are:</p>
- <table summary="Examples of various possible language tags as described by RFC 4646 and RFC 4647">
- <caption>Language tag examples</caption>
+ <table>
+ <caption>Examples of various possible language tags as described by RFC 4646 and RFC 4647</caption>
<thead>
<tr>
<th scope="col">Language tag</th>
@@ -1730,8 +1906,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>Next is the <a href="http://www.unicode.org/iso15924/iso15924-codes.html">ISO 15924</a> language script code and when one should or shouldn't use it. For example, whilst <code>en-Latn</code> is syntaxically correct for describing English written with Latin script, real world English writing is <strong>more-or-less exclusively in the Latin script</strong>. For such languages like English that are written in a single script, the <a href="http://www.iana.org/assignments/language-subtag-registry"><abbr title="Internet Assigned Numbers Authority">IANA</abbr> Language Subtag Registry</a> has a "Suppress-Script" field meaning the script code <strong>should be ommitted</strong> unless a specific language tag requires a specific script code. Some languages are <strong>written in more than one script</strong> and in such cases, the script code <strong>is encouraged</strong> since an end-user may be able to read their language in one script, but not the other. Some examples are:</p>
- <table summary="Examples of using a language subtag in combination with a script subtag">
- <caption>Language subtag + script subtag examples</caption>
+ <table>
+ <caption>Examples of using a language subtag in combination with a script subtag</caption>
<thead>
<tr>
<th scope="col">Language tag</th>
@@ -1797,8 +1973,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>Examples of English using marco-geographical regions:</p>
- <table summary="Examples for English of ISO 3166-1 alpha-2 vs. UN M.49 code">
- <caption>Coding for English using macro-geographical regions</caption>
+ <table>
+ <caption>Coding for English using macro-geographical regions (examples for English of ISO 3166-1 alpha-2 vs. UN M.49 code)</caption>
<thead>
<tr>
<th scope="col">ISO 639-1/ISO 639-2 + ISO 3166-1 alpha-2</th>
@@ -1823,8 +1999,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>Examples of Spanish using marco-geographical regions:</p>
- <table summary="Examples for Spanish of ISO 3166-1 alpha-2 vs. UN M.49 code">
- <caption>Coding for Spanish macro-geographical regions</caption>
+ <table>
+ <caption>Coding for Spanish macro-geographical regions (examples for Spanish of ISO 3166-1 alpha-2 vs. UN M.49 code)</caption>
<thead>
<tr>
<th scope="col">ISO 639-1/ISO 639-2 + ISO 3166-1 alpha-2</th>
@@ -1852,7 +2028,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>Example of where the <a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1 alpha-2</a> is ambiguous and why <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">UN M.49</a> might be preferred:</p>
- <table summary="Example where the ISO 3166-1 alpha-2 is ambiguous">
+ <table>
<caption>Coding for ambiguous ISO 3166-1 alpha-2 regions</caption>
<thead>
<tr>
@@ -1908,7 +2084,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p><a href="http://tools.ietf.org/html/rfc4646">RFC 4646</a> anticipates features which shall be available in (currently draft) <a href="http://www.sil.org/iso639-3/">ISO 639-3</a> which aims to provide as complete enumeration of languages as possible, including living, extinct, ancient and constructed languages, whether majour, minor or unwritten. A new feature of <a href="http://www.sil.org/iso639-3/">ISO 639-3</a> compared to the previous two revisions is the concept of <a href="http://www.sil.org/iso639-3/macrolanguages.asp">macrolanguages</a> where Arabic and Chinese are two such examples. In such cases, their respective codes of <code>ar</code> and <code>zh</code> is very vague as to which dialect/topolect is used or perhaps some terse classical variant which may be difficult for all but very educated users. For such macrolanguages, it is recommended that the sub-language tag is used as a suffix to the macrolanguage tag, eg:</p>
- <table summary="Examples of macrolanguages used with sub-language subtags">
+ <table>
<caption>Macrolanguage subtag + sub-language subtag examples</caption>
<thead>
<tr>
@@ -1952,7 +2128,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>For phpBB, the language tags are <strong>not</strong> used in their raw form and instead converted to all lower-case and have the hyphen <code>-</code> replaced with an underscore <code>_</code> where appropriate, with some examples below:</p>
- <table summary="Normalisation of language tags for usage in phpBB">
+ <table>
<caption>Language tag normalisation examples</caption>
<thead>
<tr>
@@ -2006,7 +2182,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>For the English language description, the language name is always first and any additional attributes required to describe the subtags within the language code are then listed in order separated with commas and enclosed within parentheses, eg:</p>
- <table summary="English language description examples of iso.txt for usage in phpBB">
+ <table>
<caption>English language description examples for iso.txt</caption>
<thead>
<tr>
@@ -2058,7 +2234,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>The various Unicode control characters for bi-directional text and their HTML enquivalents where appropriate are as follows:</p>
- <table summary="Table of the various Unicode bidirectional control characters">
+ <table>
<caption>Unicode bidirectional control characters &amp; HTML elements/entities</caption>
<thead>
<tr>
@@ -2124,7 +2300,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<p>For <code>iso.txt</code>, the directionality of the text can be explicitly set using special Unicode characters via any of the three methods provided by left-to-right/right-to-left markers/embeds/overrides, as without them, the ordering of characters will be incorrect, eg:</p>
- <table summary="Effect of using Unicode bidirectional control characters within iso.txt">
+ <table>
<caption>Unicode bidirectional control characters iso.txt</caption>
<thead>
<tr>
@@ -2260,7 +2436,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<div class="codebox"><pre>
...
-'FOO_BAR' =&gt; 'PHP version &lt; 4.3.3.&lt;br /&gt;
+'FOO_BAR' =&gt; 'PHP version &lt; 5.3.3.&lt;br /&gt;
Visit &quot;Downloads&quot; at &lt;a href=&quot;http://www.php.net/&quot;&gt;www.php.net&lt;/a&gt;.',
...
</pre></div>
@@ -2269,7 +2445,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<div class="codebox"><pre>
...
-'FOO_BAR' =&gt; 'PHP version &amp;lt; 4.3.3.&lt;br /&gt;
+'FOO_BAR' =&gt; 'PHP version &amp;lt; 5.3.3.&lt;br /&gt;
Visit &amp;quot;Downloads&amp;quot; at &lt;a href=&quot;http://www.php.net/&quot;&gt;www.php.net&lt;/a&gt;.',
...
</pre></div>
@@ -2278,7 +2454,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
<div class="codebox"><pre>
...
-'FOO_BAR' =&gt; 'PHP version &amp;lt; 4.3.3.&lt;br /&gt;
+'FOO_BAR' =&gt; 'PHP version &amp;lt; 5.3.3.&lt;br /&gt;
Visit &ldquo;Downloads&rdquo; at &lt;a href=&quot;http://www.php.net/&quot;&gt;www.php.net&lt;/a&gt;.',
...
</pre></div>
tion);
- }
- Xconfig::screen::configure($raw_X);
- $raw_X->set_resolution($X->{resolution}) if $X->{resolution};
- }
- }
- }
- };
-
- my $ok;
- $in->ask_from_({ interactive_help_id => 'configureX_chooser',
- if_($::isStandalone, ok => N("Quit")) },
- [
- { label => N("Graphic Card"), val => \$texts{card}, clicked => sub {
- $may_set->('card', Xconfig::card::configure($in, $raw_X, $do_pkgs, 0, $options));
- } },
- { label => N("Monitor"), val => \$texts{monitors}, clicked => sub {
- $may_set->('monitors', Xconfig::monitor::configure($in, $raw_X, int($raw_X->get_devices)));
- } },
- { label => N("Resolution"), val => \$texts{resolution}, disabled => sub { !$X->{card} || !$X->{monitors} },
- clicked => $prompt_for_resolution },
- if_(Xconfig::card::check_bad_card($X->{card}) || $::isStandalone,
- { val => N("Test"), disabled => sub { !$X->{card} || !$X->{monitors} },
- clicked => sub {
- $ok = Xconfig::test::test($in, $raw_X, $X->{card}, 'auto', 0);
- } },
- ),
- { val => N("Options"), clicked => sub {
- Xconfig::various::various($in, $X->{card}, $options);
- $X->{various} = 'done';
- } },
- ]);
- $ok, $b_modified;
-}
-
-sub configure_chooser {
- my ($in, $raw_X, $do_pkgs, $options) = @_;
-
- my $X = {
- card => scalar eval { Xconfig::card::from_raw_X($raw_X) },
- monitors => [ $raw_X->get_monitors ],
- resolution => scalar eval { $raw_X->get_resolution },
- };
- my $before = $raw_X->prepare_write;
- my ($ok) = configure_chooser_raw($in, $raw_X, $do_pkgs, $options, $X);
-
- if ($raw_X->prepare_write ne $before) {
- may_write($in, $raw_X, $X, $ok);
- } else {
- '';
- }
-}
-
-sub configure_everything_or_configure_chooser {
- my ($in, $options, $auto, $o_keyboard, $o_mouse) = @_;
-
- my $raw_X = eval { Xconfig::xfree->read };
- my $err = $@ && formatError($@);
- $err ||= check_valid($raw_X) if $raw_X && @$raw_X; #- that's ok if config is empty
- if ($err) {
- log::l("ERROR: bad X config file (error: $err)");
- $options->{ignore_bad_conf} or $in->ask_okcancel('',
- N("Your Xorg configuration file is broken, we will ignore it.")) or return;
- $raw_X = [];
- }
-
- my $rc = 'ok';
- if (is_empty_array_ref($raw_X)) {
- $raw_X = Xconfig::default::configure($in->do_pkgs, $o_keyboard, $o_mouse);
- $rc = configure_everything($in, $raw_X, $in->do_pkgs, $auto, $options);
- } elsif (!$auto) {
- $rc = configure_chooser($in, $raw_X, $in->do_pkgs, $options);
- }
- $rc && $raw_X, $rc;
-}
-
-
-sub may_write {
- my ($in, $raw_X, $X, $ok) = @_;
-
- $ok ||= $in->ask_yesorno('', N("Keep the changes?
-The current configuration is:
-
-%s", Xconfig::various::info($raw_X, $X->{card})), 1);
-
- $ok && &write($raw_X, $X);
-}
-
-sub write {
- my ($raw_X, $X) = @_;
- export_to_install_X($X) if $::isInstall;
- $raw_X->write;
- Xconfig::various::check_XF86Config_symlink();
- symlinkf "../../usr/X11R6/bin/Xorg", "$::prefix/etc/X11/X";
- if ($X->{resolution}{bios}) {
- Xconfig::various::setupFB($X->{resolution}{bios});
- 'need_reboot';
- } else {
- 'need_restart';
- }
-}
-
-
-sub export_to_install_X {
- my ($X) = @_;
-
- $::o->{X}{resolution_wanted} = $X->{resolution}{X};
- $::o->{X}{default_depth} = $X->{resolution}{Depth};
- $::o->{X}{bios_vga_mode} = $X->{resolution}{bios};
- $::o->{X}{monitors} = $X->{monitors} if $X->{monitors}[0]{manually_chosen} && $X->{monitors}[0]{vendor} ne "Plug'n Play";
- $::o->{X}{card} = $X->{card} if $X->{card}{manually_chosen};
- $::o->{X}{Xinerama} = 1 if $X->{card}{Xinerama};
-}
-
-sub check_valid {
- my ($raw_X) = @_;
-
- my %sections = map {
- my @l = $raw_X->get_Sections($_) or return "missing section $_";
- $_ => \@l;
- } qw(Files InputDevice Monitor Device Screen ServerLayout);
-
- $sections{Files}[0]{FontPath} or return "missing FontPath";
-
- '';
-}
-
-#- most usefull XFree86-4.0.1 server options. Default values is the first ones.
-our @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" ],
-);
-
-1;
diff --git a/perl-install/Xconfig/monitor.pm b/perl-install/Xconfig/monitor.pm
deleted file mode 100644
index ba5360b69..000000000
--- a/perl-install/Xconfig/monitor.pm
+++ /dev/null
@@ -1,275 +0,0 @@
-package Xconfig::monitor; #- $Id$
-
-use diagnostics;
-use strict;
-
-use Xconfig::xfree;
-use detect_devices;
-use common;
-use any;
-use log;
-
-
-sub good_default_monitor() {
- detect_devices::is_xbox() ? 'Generic|640x480 @ 60 Hz' :
- arch() =~ /ppc/ ?
- (detect_devices::get_mac_model() =~ /^iBook/ ? 'Apple|iBook 800x600' : 'Apple|iMac/PowerBook 1024x768') :
- (detect_devices::isLaptop() ? 'Generic|Flat Panel 1024x768' : 'Generic|1024x768 @ 60 Hz');
-}
-
-my @VertRefresh_ranges = ("50-70", "50-90", "50-100", "40-150");
-
-my @HorizSync_ranges = (
- "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",
-);
-
-sub configure {
- my ($in, $raw_X, $nb_monitors, $o_probed_info, $b_auto) = @_;
-
- my $monitors = [ $raw_X->get_or_new_monitors($nb_monitors) ];
- if ($o_probed_info) {
- put_in_hash($monitors->[0], $o_probed_info);
- }
- my $head_nb = 1;
- foreach my $monitor (@$monitors) {
- choose($in, $monitor, @$monitors > 1 ? $head_nb++ : 0, $raw_X->get_Driver, $b_auto) or return;
- }
- $raw_X->set_monitors(@$monitors);
- $monitors;
-}
-
-sub configure_auto_install {
- my ($raw_X, $old_X) = @_;
-
- if ($old_X->{monitor}) {
- #- keep compatibility
- $old_X->{monitor}{VertRefresh} = $old_X->{monitor}{vsyncrange};
- $old_X->{monitor}{HorizSync} = $old_X->{monitor}{hsyncrange};
-
- #- new name
- $old_X->{monitors} = [ delete $old_X->{monitor} ];
- }
-
- my $monitors = [ $raw_X->get_or_new_monitors($old_X->{monitors} ? int @{$old_X->{monitors}} : 1) ];
- mapn {
- my ($monitor, $auto_install_monitor) = @_;
- put_in_hash($monitor, $auto_install_monitor);
- configure_automatic($monitor);
- } $monitors, $old_X->{monitors} if $old_X->{monitors};
-
- if (!is_valid($monitors->[0])) {
- put_in_hash($monitors->[0], probe($old_X->{card}{Driver}));
- }
-
- foreach my $monitor (@$monitors) {
- if (!is_valid($monitor)) {
- good_default_monitor() =~ /(.*)\|(.*)/ or internal_error("bad good_default_monitor");
- put_in_hash($monitor, { VendorName => $1, ModelName => $2 });
- configure_automatic($monitor) or internal_error("good_default_monitor (" . good_default_monitor() . ") is unknown in MonitorsDB");
- }
- }
- $raw_X->set_monitors(@$monitors);
- $monitors;
-}
-
-sub choose {
- my ($in, $monitor, $head_nb, $card_Driver, $b_auto) = @_;
-
- my $ok = is_valid($monitor);
- if ($b_auto) {
- log::l("Xconfig::monitor: auto failed") if !$ok;
- return $ok;
- }
-
- my %h_monitors = map { ("$_->{VendorName}|$_->{ModelName}" => $_) } monitors_db();
-
- ask_monitor:
- my $merged_name = do {
- if ($monitor->{VendorName} eq "Plug'n Play") {
- $monitor->{VendorName};
- } else {
- my $merged_name = $monitor->{VendorName} . '|' . $monitor->{ModelName};
-
- if (!exists $h_monitors{$merged_name}) {
- $merged_name = is_valid($monitor) ? 'Custom' : good_default_monitor();
- } else {
- $merged_name;
- }
- }
- };
-
- $in->ask_from_({ title => N("Monitor"),
- messages => $head_nb ? N("Choose a monitor for head #%d", $head_nb) : N("Choose a monitor"),
- interactive_help_id => 'configureX_monitor'
- },
- [ { val => \$merged_name, separator => '|',
- list => ['Custom', "Plug'n Play", sort keys %h_monitors],
- format => sub { $_[0] eq 'Custom' ? N("Custom") :
- $_[0] eq "Plug'n Play" ? N("Plug'n Play") . ($monitor->{VendorName} eq "Plug'n Play" ? " ($monitor->{ModelName})" : '') :
- $_[0] =~ /^Generic\|(.*)/ ? N("Generic") . "|$1" :
- N("Vendor") . "|$_[0]" },
- sort => 0 } ]) or return;
-
- if ($merged_name eq "Plug'n Play") {
- local $::noauto = 0; #- hey, you asked for plug'n play, so i do probe!
- delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'};
- if ($head_nb <= 1) {
- if (my $probed_info = probe($card_Driver)) {
- put_in_hash($monitor, $probed_info);
- } else {
- $in->ask_warn('', N("Plug'n Play probing failed. Please select the correct monitor"));
- goto ask_monitor;
- }
- } else {
- $monitor->{VendorName} = "Plug'n Play";
- }
- } elsif ($merged_name eq 'Custom') {
- $in->ask_from('',
-N("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->{HorizSync}, list => \@HorizSync_ranges, label => N("Horizontal refresh rate"), not_edit => 0 },
- { val => \$monitor->{VertRefresh}, list => \@VertRefresh_ranges, label => N("Vertical refresh rate"), not_edit => 0 } ]) or goto &choose;
- delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'};
- } else {
- put_in_hash($monitor, $h_monitors{$merged_name});
- }
- $monitor->{manually_chosen} = 1;
- 1;
-}
-
-sub configure_automatic {
- my ($monitor) = @_;
-
- if ($monitor->{EISA_ID}) {
- log::l("EISA_ID: $monitor->{EISA_ID}");
- if (my $mon = find { lc($_->{EISA_ID}) eq $monitor->{EISA_ID} } monitors_db()) {
- add2hash($monitor, $mon);
- log::l("EISA_ID corresponds to: $monitor->{ModelName}");
- } elsif (!is_valid($monitor)) {
- log::l("unknown EISA_ID and partial DDC probe, so unknown monitor");
- delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'};
- }
- } elsif ($monitor->{VendorName}) {
- if (my $mon = find { $_->{VendorName} eq $monitor->{VendorName} && $_->{ModelName} eq $monitor->{ModelName} } monitors_db()) {
- put_in_hash($monitor, $mon);
- }
- }
- is_valid($monitor);
-}
-
-sub is_valid {
- my ($monitor) = @_;
- $monitor->{HorizSync} && $monitor->{VertRefresh};
-}
-
-sub probe {
- my ($o_card_Driver) = @_;
- probe_DDC() || probe_DMI() || probe_using_X($o_card_Driver);
-}
-
-sub probe_DDC() {
- my ($edid, $vbe) = any::monitor_full_edid() or return;
- my $monitor = eval($edid);
-
- if ($vbe =~ /Memory: (\d+)k/) {
- $monitor->{VideoRam_probed} = $1;
- }
- $monitor->{ModeLine} = Xconfig::xfree::default_ModeLine();
- my $detailed_timings = $monitor->{detailed_timings} || [];
- foreach (grep { !$_->{bad_ratio} } @$detailed_timings) {
- my $ratio = $_->{horizontal_active} / $_->{vertical_active};
-
- if (abs($ratio - 4 / 3) < 0.01) {
- #- we don't want the 4/3 modelines otherwise they conflict with the Xorg builtin vesamodes
- } else {
- unshift @{$monitor->{ModeLine}},
- { val => $_->{ModeLine}, pre_comment => $_->{ModeLine_comment} . "\n" };
- }
-
- if (@$detailed_timings == 1) {
- #- should we care about {has_preferred_timing} ?
- $monitor->{preferred_resolution} = { X => $_->{horizontal_active}, Y => $_->{vertical_active} };
- }
- }
-
- if ($monitor->{EISA_ID}) {
- $monitor->{VendorName} = "Plug'n Play";
- $monitor->{ModelName} = $monitor->{monitor_name};
- $monitor->{ModelName} =~ s/"/''/g;
- }
- configure_automatic($monitor) or return;
- $monitor;
-}
-
-sub probe_using_X {
- my ($card_Driver) = @_;
-
- detect_devices::isLaptop() or return;
-
- $card_Driver ||= do {
- require Xconfig::card;
- my @cards = Xconfig::card::probe();
- $cards[0]{Driver};
- } or return;
-
- my $resolution = run_program::rooted_get_stdout($::prefix, 'monitor-probe-using-X', $card_Driver) or return;
- generic_flat_panel(chomp_($resolution));
-}
-
-sub probe_DMI() {
- my $res = detect_devices::probe_unique_name('Resolution');
- $res && generic_flat_panel($res);
-}
-
-sub generic_flat_panel {
- my ($resolution) = @_;
- my ($X, $Y) = $resolution =~ /(\d+)x(\d+)/ or log::l("bad resolution $resolution"), return;
- {
- VendorName => 'Generic',
- ModelName => "Flat Panel $resolution",
- HorizSync => '31.5-100', VertRefresh => '60',
- preferred_resolution => { X => $X, Y => $Y },
- };
-}
-
-my $monitors_db;
-sub monitors_db() {
- $monitors_db ||= readMonitorsDB("$ENV{SHARE_PATH}/ldetect-lst/MonitorsDB");
- @$monitors_db;
-}
-sub readMonitorsDB {
- my ($file) = @_;
-
- my @monitors_db;
- my $F = openFileMaybeCompressed($file);
- local $_;
- my $lineno = 0; while (<$F>) {
- $lineno++;
- s/\s+$//;
- /^#/ and next;
- /^$/ and next;
-
- my @fields = qw(VendorName ModelName EISA_ID HorizSync VertRefresh dpms);
- my %l; @l{@fields} = split /\s*;\s*/;
- push @monitors_db, \%l;
- }
- \@monitors_db;
-}
-
-
-1;
-
diff --git a/perl-install/Xconfig/parse.pm b/perl-install/Xconfig/parse.pm
deleted file mode 100644
index 71062a093..000000000
--- a/perl-install/Xconfig/parse.pm
+++ /dev/null
@@ -1,205 +0,0 @@
-package Xconfig::parse; # $Id$
-
-use diagnostics;
-use strict;
-
-use common;
-
-
-sub read_XF86Config {
- my ($file) = @_;
- my $raw_X = raw_from_file($file);
- from_raw(@$raw_X);
- $raw_X;
-}
-
-sub prepare_write_XF86Config {
- my ($raw_X) = @_;
- map { raw_to_string(before_to_string({ %$_ }, 0)) } @$raw_X;
-}
-
-sub write_XF86Config {
- my ($raw_X, $file) = @_;
- my @blocks = prepare_write_XF86Config($raw_X);
- @blocks ? output($file, @blocks) : unlink $file;
-}
-
-sub read_XF86Config_from_string {
- my ($s) = @_;
- my $raw_X = raw_from_file('-', [ split "\n", $s ]);
- from_raw(@$raw_X);
- $raw_X;
-}
-
-#-###############################################################################
-#- raw reading/saving
-#-###############################################################################
-sub raw_from_file { #- internal
- my ($file, $o_lines) = @_;
- my $raw_X = [];
-
- my $lines = $o_lines || [ cat_($file) ];
- my $line;
-
- my ($comment, $obj, @objs);
-
- my $attach_comment = sub {
- $obj || @objs or warn "$file:$line: can not attach comment\n";
- if ($comment) {
- $comment =~ s/\n+$/\n/;
- ($obj || $objs[0])->{$_[0] . '_comment'} = $comment;
- $comment = '';
- }
- };
-
- foreach (@$lines) {
- $line++;
- s/^\s*//; s/\s*$//;
-
- if (/^$/) {
- $comment .= "\n" if $comment;
- next;
- } elsif (@objs ? m/^#\W/ || /^#$/ : /^#/) {
- s/^#\s+/# /;
- $comment .= "$_\n";
- next;
- }
-
- if (/^Section\s+"(.*)"/i) {
- die "$file:$line: missing EndSection\n" if @objs;
- my $e = { name => $1, l => [], kind => 'Section' };
- push @$raw_X, $e;
- unshift @objs, $e; $obj = '';
- $attach_comment->('pre');
- } elsif (/^Subsection\s+"(.*)"/i) {
- die "$file:$line: missing EndSubsection\n" if @objs && $objs[0]{kind} eq 'Subsection';
- die "$file:$line: not in Section\n" if !@objs || $objs[0]{kind} ne 'Section';
- my $e = { name => $1, l => [], kind => 'Subsection' };
- push @{$objs[0]{l}}, $e;
- unshift @objs, $e; $obj = '';
- $attach_comment->('pre');
- } elsif (/^EndSection/i) {
- die "$file:$line: not in Section\n" if !@objs || $objs[0]{kind} ne 'Section';
- $attach_comment->('post');
- shift @objs; $obj = '';
- } elsif (/^EndSubsection/i) {
- die "$file:$line: not in Subsection\n" if !@objs || $objs[0]{kind} ne 'Subsection';
- $attach_comment->('post');
- shift @objs; $obj = '';
- } else {
- die "$file:$line: not in Section\n" if !@objs;
-
- my $commented = s/^#//;
-
- my $comment_on_line;
- s/(\s*#.*)/$comment_on_line = $1; ''/e;
-
- if (/^$/) {
- die "$file:$line: weird";
- }
-
- (my $name, my $Option, $_) =
- /^Option\s*"(.*?)"(.*)/ ? ($1, 1, $2) : /^(\S+)(.*)/ ? ($1, 0, $2) : internal_error($_);
- my ($val) = /(\S.*)/;
-
- my %e = (Option => $Option, commented => $commented, comment_on_line => $comment_on_line, pre_comment => $comment);
- $comment = '';
- $obj = { name => $name, val => $val };
- $e{$_} and $obj->{$_} = $e{$_} foreach keys %e;
-
- push @{$objs[0]{l}}, $obj;
- }
- }
- $raw_X;
-}
-
-sub raw_to_string {
- my ($e, $b_want_spacing) = @_;
- my $s = do {
- if ($e->{l}) {
- my $inside = join('', map_index { raw_to_string($_, $::i) } @{$e->{l}});
- $inside .= $e->{post_comment} || '';
- $inside =~ s/^/ /mg;
- qq(\n$e->{kind} "$e->{name}"\n) . $inside . "End$e->{kind}";
- } else {
- ($e->{commented} ? '#' : '') .
- ($e->{Option} ? qq(Option "$e->{name}") : $e->{name}) .
- (defined $e->{val} ? ($e->{Option} && $e->{val} !~ /^"/ ? qq( "$e->{val}") : qq( $e->{val})) : '');
- }
- };
- ($e->{pre_comment} ? ($b_want_spacing ? "\n" : '') . $e->{pre_comment} : '') . $s . ($e->{comment_on_line} || '') . "\n" . (!$e->{l} && $e->{post_comment} || '');
-}
-
-#-###############################################################################
-#- refine the data structure for easier use
-#-###############################################################################
-my %kind_names = (
- Pointer => [ qw(Protocol Device Emulate3Buttons Emulate3Timeout EmulateWheel EmulateWheelButton) ],
- Mouse => [ qw(DeviceName Protocol Device AlwaysCore Emulate3Buttons Emulate3Timeout EmulateWheel EmulateWheelButton) ], # Subsection in XInput
- Keyboard => [ qw(Protocol Driver XkbModel XkbLayout XkbDisable) ],
- Monitor => [ qw(Identifier VendorName ModelName HorizSync VertRefresh) ],
- Device => [ qw(Identifier VendorName BoardName Chipset Driver VideoRam Screen BusID DPMS power_saver) ],
- Display => [ qw(Depth Modes Virtual) ], # Subsection in Device
- Screen => [ qw(Identifier Driver Device Monitor DefaultDepth DefaultColorDepth) ],
- InputDevice => [ qw(Identifier Driver Protocol Device Type Mode XkbModel XkbLayout XkbDisable Emulate3Buttons Emulate3Timeout EmulateWheel EmulateWheelButton) ],
- WacomCursor => [ qw(Port) ], #-\
- WacomStylus => [ qw(Port) ], #--> Port must be first
- WacomEraser => [ qw(Port) ], #-/
- ServerLayout => [ qw(Identifier) ],
-);
-my @want_string = qw(Identifier DeviceName VendorName ModelName BoardName Driver Device Chipset Monitor Protocol XkbModel XkbLayout XkbOptions XkbCompat Load BusID);
-
-%kind_names = map_each { lc $::a => [ map { lc } @$::b ] } %kind_names;
-@want_string = map { lc } @want_string;
-
-sub from_raw {
- sub from_raw__rec {
- my ($current, $e) = @_;
- if ($e->{l}) {
- from_raw($e);
- push @{$current->{l}{$e->{name}}}, $e;
- } else {
- if (member(lc $e->{name}, @want_string)) {
- $e->{val} =~ s/^"(.*)"$/$1/ or warn "$e->{name} $e->{val} has no quote\n";
- }
-
- if (member(lc $e->{name}, @{$kind_names{lc $current->{name}} || []})) {
- if ($current->{l}{$e->{name}} && !$current->{l}{$e->{name}}{commented}) {
- warn "skipping conflicting line for $e->{name} in $current->{name}\n" if !$e->{commented};
- } else {
- $current->{l}{$e->{name}} = $e;
- }
- } else {
- push @{$current->{l}{$e->{name}}}, $e;
- }
- }
- delete $e->{name};
- }
-
- foreach my $e (@_) {
- ($e->{l}, my $l) = ({}, $e->{l});
- from_raw__rec($e, $_) foreach @$l;
-
- delete $e->{kind};
- }
-}
-
-sub before_to_string {
- my ($e, $depth) = @_;
-
- if ($e->{l}) {
- $e->{kind} = $depth ? 'Subsection' : 'Section';
-
- my %rated = map_index { $_ => $::i + 1 } @{$kind_names{lc $e->{name}} || []};
- my @sorted = sort { ($rated{lc $a} || 99) <=> ($rated{lc $b} || 99) } keys %{$e->{l}};
- $e->{l} = [ map {
- my $name = $_;
- map {
- before_to_string({ name => $name, %$_ }, $depth+1);
- } deref_array($e->{l}{$name});
- } @sorted ];
- } elsif (member(lc $e->{name}, @want_string)) {
- $e->{val} = qq("$e->{val}");
- }
- $e;
-}
diff --git a/perl-install/Xconfig/proprietary.pm b/perl-install/Xconfig/proprietary.pm
deleted file mode 100644
index ed196deb7..000000000
--- a/perl-install/Xconfig/proprietary.pm
+++ /dev/null
@@ -1,35 +0,0 @@
-package Xconfig::proprietary; # $Id$
-
-use diagnostics;
-use strict;
-
-use common;
-
-
-sub install_matrox_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" || $::testing;
-
- 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.1/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/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm
deleted file mode 100644
index 294266480..000000000
--- a/perl-install/Xconfig/resolution_and_depth.pm
+++ /dev/null
@@ -1,386 +0,0 @@
-package Xconfig::resolution_and_depth; # $Id$
-
-use diagnostics;
-use strict;
-
-use common;
-
-
-our %depth2text = (
- 8 => N_("256 colors (8 bits)"),
- 15 => N_("32 thousand colors (15 bits)"),
- 16 => N_("65 thousand colors (16 bits)"),
- 24 => N_("16 million colors (24 bits)"),
-);
-our @depths_available = ikeys(%depth2text);
-
-my @bios_vga_modes = (
- { bios => 769, X => 640, Y => 480, Depth => 8 },
- { bios => 771, X => 800, Y => 600, Depth => 8 },
- { bios => 773, X => 1024, Y => 768, Depth => 8 },
- { bios => 775, X => 1280, Y => 1024, Depth => 8 },
- { bios => 777, X => 1600, Y => 1200, Depth => 8 },
- { bios => 784, X => 640, Y => 480, Depth => 15 },
- { bios => 787, X => 800, Y => 600, Depth => 15 },
- { bios => 790, X => 1024, Y => 768, Depth => 15 },
- { bios => 793, X => 1280, Y => 1024, Depth => 15 },
- { bios => 796, X => 1600, Y => 1200, Depth => 15 },
- { bios => 785, X => 640, Y => 480, Depth => 16 },
- { bios => 788, X => 800, Y => 600, Depth => 16 },
- { bios => 791, X => 1024, Y => 768, Depth => 16 },
- { bios => 794, X => 1280, Y => 1024, Depth => 16 },
- { bios => 797, X => 1600, Y => 1200, Depth => 16 },
-);
-
-sub from_bios {
- my ($bios) = @_;
- find { $_->{bios} == $bios } @bios_vga_modes;
-}
-
-sub bios_vga_modes() { @bios_vga_modes }
-
-sub size2default_resolution {
- my ($size) = @_; #- size in inch
-
- require detect_devices;
- if (arch() =~ /ppc/) {
- return "1024x768" if detect_devices::get_mac_model() =~ /^PowerBook|^iMac/;
- } elsif (detect_devices::is_xbox()) {
- return "640x480";
- }
-
- my %monitorSize2resolution = (
- 13 => "640x480",
- 14 => "800x600",
- 15 => "800x600",
- 16 => "1024x768",
- 17 => "1024x768",
- 18 => "1024x768",
- 19 => "1280x1024",
- 20 => "1280x1024",
- 21 => "1600x1200",
- 22 => "1600x1200",
- );
- $monitorSize2resolution{round($size)} || ($size < 13 ? "640x480" : "1600x1200");
-}
-
-sub to_string {
- my ($resolution) = @_;
- $resolution or return '';
-
- $resolution->{X} ? sprintf("%sx%s %dbpp", @$resolution{'X', 'Y', 'Depth'}) : 'frame-buffer';
-}
-
-sub allowed {
- my ($card) = @_;
-
- my ($prefered_depth, @resolution_and_depth);
-
- if ($card->{Driver} eq 'fbdev') {
- @resolution_and_depth = grep { $_->{Depth} == 16 } @bios_vga_modes;
- } else {
- my @depths;
- if ($card->{Driver} eq 'fglrx') {
- @depths = 24;
- } elsif ($card->{BoardName} eq 'RIVA128') {
- @depths = qw(8 15 24);
- } elsif ($card->{use_DRI_GLX}) {
- $prefered_depth = 16;
- @depths = (16, 24);
- } else {
- @depths = our @depths_available;
- }
- my @resolutions = @Xconfig::xfree::resolutions;
-
- push @resolution_and_depth,
- map {
- my $Depth = $_;
- map { m/(\d+)x(\d+)/ && { X => $1, Y => $2, Depth => $Depth } } @resolutions;
- } @depths;
- }
- $prefered_depth, @resolution_and_depth;
-}
-
-# ($card->{VideoRam} || ($card->{server} eq 'FBDev' ? 2048 : 32768))
-sub filter_using_VideoRam {
- my ($VideoRam, @resolutions) = @_;
- my $mem = 1024 * $VideoRam;
- grep { $_->{X} * $_->{Y} * $_->{Depth}/8 <= $mem } @resolutions;
-
-}
-sub filter_using_HorizSync_VertRefresh {
- my ($HorizSync, $VertRefresh, @resolutions) = @_;
- my $max_hsync = 1000 * max(split(/[,-]/, $HorizSync));
- my ($min_vsync, $max_vsync) = (min(split(/[,-]/, $VertRefresh)), max(split(/[,-]/, $VertRefresh)));
-
- #- enforce at least 60Hz, if max_vsync > 100 (ie don't do it on LCDs which are ok with low vsync)
- $min_vsync = max(60, $min_vsync) if $max_vsync > 100;
-
- #- computing with {Y} which is active sync instead of total sync, but that's ok
- grep { $max_hsync / $_->{Y} > $min_vsync } @resolutions;
-}
-
-sub choose {
- my ($in, $default_resolution, @resolutions) = @_;
-
- my $resolution = $default_resolution || {};
- $in->ask_from(N("Resolutions"), "",
- [ {
- val => \$resolution, type => 'list', sort => 0,
- list => [ sort { $a->{X} <=> $b->{X} } @resolutions ],
- format => \&to_string,
- } ]) or return;
- $resolution;
-}
-
-
-sub choices {
- my ($_raw_X, $resolution_wanted, $card, $monitors) = @_;
- $resolution_wanted ||= {};
-
- my ($prefered_depth, @resolutions) = allowed($card);
-
- @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);
- } elsif (!$resolution_wanted->{X}) {
- if ($monitors->[0]{preferred_resolution}) {
- put_in_hash($resolution_wanted, $monitors->[0]{preferred_resolution});
- } elsif ($monitors->[0]{ModelName} =~ /^Flat Panel (\d+)x(\d+)$/) {
- put_in_hash($resolution_wanted, { X => $1, Y => $2 });
- } elsif ($monitors->[0]{diagonal_size}) {
- my ($X, $Y) = split('x', size2default_resolution($monitors->[0]{diagonal_size} * 1.08));
- put_in_hash($resolution_wanted, { X => $X, Y => $Y });
- } else {
- put_in_hash($resolution_wanted, { X => 1024, Y => 768 });
- }
- }
- my @matching = grep { $_->{X} eq $resolution_wanted->{X} && $_->{Y} eq $resolution_wanted->{Y} } @resolutions;
- if (!@matching) {
- #- hard choice :-(
- #- first trying the greater resolution with same ratio
- my $ratio = $resolution_wanted->{X} / $resolution_wanted->{Y};
- @matching = grep { abs($ratio - $_->{X} / $_->{Y}) < 0.01 } @resolutions;
- }
- if (!@matching) {
- #- really hard choice :'-(
- #- take the first available resolution <= the wanted resolution
- @matching = grep { $_->{X} < $resolution_wanted->{X} } @resolutions;
- }
- if (!@matching) {
- @matching = @resolutions;
- }
-
- my $default_resolution;
- foreach my $Depth ($resolution_wanted->{Depth}, $prefered_depth) {
- $Depth and $default_resolution ||= find { $_->{Depth} eq $Depth } @matching;
- }
- $default_resolution ||= $matching[0];
-
- $default_resolution, @resolutions;
-}
-
-sub configure {
- my ($in, $raw_X, $card, $monitors, $b_auto) = @_;
-
- my ($default_resolution, @resolutions) = choices($raw_X, $raw_X->get_resolution, $card, $monitors);
-
- if ($b_auto) {
- #- use $default_resolution
- if ($card->{Driver} eq 'fglrx') {
- $default_resolution = first(find { $default_resolution->{Y} eq $_->{Y} && $_->{Depth} == 24 }
- $default_resolution, @resolutions);
- $default_resolution ||= first(find { $_->{Depth} == 24 } $default_resolution, @resolutions);
- }
- } elsif ($in->isa('interactive::gtk')) {
- $default_resolution = choose_gtk($in, $card, $default_resolution, @resolutions) or return;
- } else {
- $default_resolution = choose($in, $default_resolution, @resolutions) or return;
- }
- set_resolution($raw_X, $default_resolution);
-
- $default_resolution;
-}
-
-sub configure_auto_install {
- my ($raw_X, $card, $monitors, $old_X) = @_;
-
- my $resolution_wanted = do {
- my ($X, $Y) = split('x', $old_X->{resolution_wanted});
- { X => $X, Y => $Y, Depth => $old_X->{default_depth} };
- };
-
- my ($default_resolution) = choices($raw_X, $resolution_wanted, $card, $monitors);
- $default_resolution or die "you selected an unusable depth";
-
- 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 %theme = getVarsFromSh("$::prefix/etc/sysconfig/bootsplash");
- my @l =
- sort {
- $a->[1] <=> $b->[1] || $b->[2] <=> $a->[2] || $a->[3] <=> $b->[3];
- } map {
- if (my ($X, $Y) = /^\Q$theme{THEME}\E-(\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};
- $res eq '1280x1024' && $b_non_strict ? '4/3' : $Xconfig::xfree::resolution2ratio{$res};
-}
-
-sub choose_gtk {
- my ($in, $card, $default_resolution, @resolutions) = @_;
-
- $_->{ratio} ||= resolution2ratio($_) foreach @resolutions;
-
- my $chosen_Depth = $default_resolution->{Depth};
- my $chosen_res = { X => $default_resolution->{X} || 1024, Y => $default_resolution->{Y} };
- my $chosen_ratio = resolution2ratio($chosen_res, 'non-strict') || '4/3';
-
- my $filter_on_ratio = sub {
- grep {
- !$chosen_ratio
- || $_->{ratio} eq $chosen_ratio
- || $chosen_ratio eq '4/3' && "$_->{X}x$_->{Y}" eq '1280x1024';
- } @_;
- };
- my $filter_on_Depth = sub {
- grep { $_->{Depth} == $chosen_Depth } @_;
- };
- my $filter_on_res = sub {
- grep { $_->{X} == $chosen_res->{X} && $_->{Y} == $chosen_res->{Y} } @_;
- };
- #- $chosen_res must be one of @resolutions, so that it has a correct {ratio} field
- $chosen_res = first($filter_on_res->(@resolutions)) || $resolutions[0];
-
- require ugtk2;
- mygtk2->import;
- ugtk2->import(qw(:create :helpers :wrappers));
- my $W = ugtk2->new(N("Resolution"), modal => 1);
-
- my %monitor_images_x_res = do {
- my @l = qw(640 800 1024 1152 1280 1400 1600 1920 2048);
- my %h = map { $_ => ugtk2::_find_imgfile("monitor-$_.png") } @l;
-
- #- for the other, use the biggest smaller
- foreach my $x_res (uniq map { $_->{X} } @resolutions) {
- my $x_res_ = max(grep { $_ <= $x_res } @l);
- $h{$x_res} ||= $h{$x_res_} || $h{640};
- }
- %h;
- };
-
- my $res2text = sub { "$_[0]{X}x$_[0]{Y}" . ($chosen_ratio || $_[0]{ratio} =~ /other/ ? '' : " ($_[0]{ratio})") };
- my @matching_ratio;
- my $proposed_resolutions = [];
- my $set_proposed_resolutions = sub {
- my ($suggested_res) = @_;
- @matching_ratio = $filter_on_ratio->(@resolutions);
- gtkval_modify(\$proposed_resolutions, [
- (reverse uniq_ { $res2text->($_) } @matching_ratio),
- if_($chosen_ratio, { text => N_("Other") }),
- ]);
- if (!$filter_on_res->(@matching_ratio)) {
- my $res = $suggested_res || find { $_->{X} == $chosen_res->{X} } @matching_ratio;
- gtkval_modify(\$chosen_res, $res || $matching_ratio[0]);
- }
- };
- $set_proposed_resolutions->();
-
- my $depth_combo = gtknew('ComboBox', width => 220,
- text_ref => \$chosen_Depth,
- format => sub { translate($depth2text{$_[0]}) },
- list => [ uniq(reverse map { $_->{Depth} } @resolutions) ],
- changed => sub {
- my @matching_Depth = $filter_on_Depth->(@matching_ratio);
- if (!$filter_on_res->(@matching_Depth)) {
- gtkval_modify(\$chosen_res, $matching_Depth[0]);
- }
- });
- my $previous_res = $chosen_res;
- my $res_combo = gtknew('ComboBox',
- text_ref => \$chosen_res,
- format => sub { $_[0]{text} ? translate($_[0]{text}) : &$res2text },
- list_ref => \$proposed_resolutions,
- changed => sub {
- if ($chosen_res->{text}) {
- undef $chosen_ratio;
- $set_proposed_resolutions->($previous_res);
- } else {
- my @matching_res = $filter_on_res->(@matching_ratio);
- if (!$filter_on_Depth->(@matching_res)) {
- gtkval_modify(\$chosen_Depth, $matching_res[0]{Depth});
- }
- $previous_res = $chosen_res;
- }
- });
- my $pix_colors = gtknew('Image',
- file_ref => \$chosen_Depth,
- format => sub {
- $_[0] >= 24 ? "colors.png" : $_[0] >= 15 ? "colors16.png" : "colors8.png";
- });
- my $pixmap_mo = gtknew('Image',
- file_ref => \$chosen_res,
- format => sub {
- $monitor_images_x_res{$_[0]{X}} or internal_error("no image for resolution $chosen_res->{X}");
- });
-
- my $help_sub = $in->interactive_help_sub_display_id('configureX_resolution');
- gtkadd($W->{window},
- gtkpack_($W->create_box_with_title(N("Choose the resolution and the color depth"),
- if_($card->{BoardName}, "(" . N("Graphics card: %s", $card->{BoardName}) . ")"),
- ),
- 1, '',
- 0, $pixmap_mo,
- 0, gtknew('HBox', children => [
- 1, '',
- 0, gtknew('Table', col_spacings => 5, row_spacings => 5,
- children => [
- [ $res_combo, gtknew('Label', text => "") ],
- [ $depth_combo, gtknew('Frame', shadow_type => 'etched_out', child => $pix_colors) ],
- ]),
- 1, '',
- ]),
- 1, '',
- 0, gtkadd($W->create_okcancel(N("Ok"), N("Cancel"), '', if_($help_sub, [ N("Help"), $help_sub, 1 ]))),
- ));
- $W->{ok}->grab_focus;
-
- $W->main or return;
-
- find { $_->{X} == $chosen_res->{X} &&
- $_->{Y} == $chosen_res->{Y} &&
- $_->{Depth} == $chosen_Depth } @resolutions;
-}
-
-1;
diff --git a/perl-install/Xconfig/screen.pm b/perl-install/Xconfig/screen.pm
deleted file mode 100644
index e0a3ebd64..000000000
--- a/perl-install/Xconfig/screen.pm
+++ /dev/null
@@ -1,29 +0,0 @@
-package Xconfig::screen; # $Id$
-
-use diagnostics;
-use strict;
-
-use common;
-
-
-sub configure {
- my ($raw_X) = @_;
-
- my @devices = $raw_X->get_devices;
- my @monitors = $raw_X->get_monitors;
-
- if (@monitors < @devices) {
- $raw_X->set_monitors(@monitors, ({}) x (@devices - @monitors));
- @monitors = $raw_X->get_monitors;
- }
-
- my @sections = mapn {
- my ($device, $monitor) = @_;
- { Device => $device->{Identifier}, Monitor => $monitor->{Identifier} };
- } \@devices, \@monitors;
-
- $raw_X->set_screens(@sections);
- 1;
-}
-
-1;
diff --git a/perl-install/Xconfig/test.pm b/perl-install/Xconfig/test.pm
deleted file mode 100644
index 524530bef..000000000
--- a/perl-install/Xconfig/test.pm
+++ /dev/null
@@ -1,140 +0,0 @@
-package Xconfig::test; # $Id$
-
-use diagnostics;
-use strict;
-
-use Xconfig::card;
-use run_program;
-use common;
-use log;
-
-
-my $tmpconfig = "/tmp/Xconfig";
-
-
-sub xtest {
- my ($display) = @_;
- eval {
- require xf86misc::main;
- xf86misc::main::Xtest($display);
- };
-}
-
-sub test {
- my ($in, $raw_X, $card, $auto, $skip_badcard) = @_;
-
- my $bad_card = !Xconfig::card::check_bad_card($card);
- return 1 if $skip_badcard && $bad_card;
-
- if ($bad_card || !$auto) {
- $in->ask_yesorno(N("Test of the configuration"),
- N("Do you want to test the configuration?") . ($bad_card ? "\n" . N("Warning: testing this graphic card may freeze your computer") : ''),
- !$bad_card) or return 1;
- }
-
- 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;
- }
-
- #- ensure xfs is running
- fuzzy_pidofs(qr/\bxfs\b/) or do { run_program::rooted($::prefix, "/etc/rc.d/init.d/xfs", $_) foreach 'stop', 'start' };
- fuzzy_pidofs(qr/\bxfs\b/) or die "xfs is not running";
-
- my $f = $::testing ? $tmpconfig : "/etc/X11/XF86Config.test";
- $raw_X->write("$::prefix/$f");
-
- my $f_err = common::secured_file($::prefix . ($ENV{TMPDIR} || "$ENV{HOME}/tmp") . '/.drakx.Xoutput');
-
- my $pid;
- unless ($pid = fork()) {
- system("xauth add :9 . `mcookie`");
- open STDERR, ">$f_err";
- chroot $::prefix if $::prefix;
- exec 'Xorg', '-xf86config', $f, ":9" or c::_exit(0);
- }
-
- do { sleep 1 } until xtest(":9") || waitpid($pid, c::WNOHANG());
-
- my $_b = before_leaving { unlink $f_err };
-
- my $warn_error = sub {
- my ($error_msg) = @_;
- $in->ask_warn('', [ N("An error occurred:\n%s\nTry to change some parameters", $error_msg) ]);
- };
-
- if (!xtest(":9")) {
- open(my $F, $f_err);
-
- local $_;
- i: while (<$F>) {
- if (/^\(EE\)/ && !/Disabling/ || /^Fatal\b/) {
- my @msg = !/error/ && $_;
- local $_;
- while (<$F>) {
- /reporting a problem/ and last;
- $warn_error->(join('', @msg, $_));
- return 0;
- }
- }
- }
- }
-
- open(my $F, "|perl 2>/dev/null");
- printf $F q(
- use lib qw(%s);
- BEGIN { $::no_ugtk_init = 1 }
- require lang;
- require ugtk2; #- help perl_checker
- ugtk2->import(qw(:wrappers :helpers)); #- help perl_checker
- use interactive::gtk;
- use run_program;
- use common;
-
- $::prefix = "%s";
-
- lang::bindtextdomain();
-
- $ENV{DISPLAY} = ":9";
- Gtk2->init;
-
- gtkset_background(200 * 257, 210 * 257, 210 * 257);
- my $text = Gtk2::Label->new;
- my $time = 12;
- Glib::Timeout->add(1000, sub {
- $text->set(sprintf(translate("%s"), $time));
- $time-- or Gtk2->main_quit;
- 1;
- });
-
- eval { #- eval it so that missing pixmap will not break the test completely
- my $root = gtkroot();
- my $gc = Gtk2::Gdk::GC->new($root);
- my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file("$::prefix/usr/share/mdk/xfdrake/xfdrake-test-card.png");
- my ($w, $h) = ($pixbuf->get_width, $pixbuf->get_height);
- my $pixmap = Gtk2::Gdk::Pixmap->new($root, $w, $h, $root->get_depth);
- $pixbuf->render_to_drawable($pixmap, $gc, 0, 0, 0, 0, $w, $h, 'none', 0, 0);
- $root->set_back_pixmap($pixmap, 0);
- $root->clear;
- };
-
- my $in = interactive::gtk->new;
- $in->exit($in->ask_yesorno('', [ translate("%s"), $text ], 0) ? 0 : 222);
- ), join(' ', @INC), $::prefix, N_("Leaving in %d seconds"), N_("Is this the correct setting?");
- my $rc = close $F;
- my $err = $?;
-
- $rc || $err == 222 << 8 or $warn_error->('');
-
- unlink "$::prefix/$f", "$::prefix/$f-4";
- unlink "/tmp/.X11-unix/X9" if $::prefix;
- kill 2, $pid;
-
- $rc;
-}
diff --git a/perl-install/Xconfig/various.pm b/perl-install/Xconfig/various.pm
deleted file mode 100644
index c38205fe6..000000000
--- a/perl-install/Xconfig/various.pm
+++ /dev/null
@@ -1,178 +0,0 @@
-package Xconfig::various; # $Id$
-
-use diagnostics;
-use strict;
-
-use Xconfig::card;
-use Xconfig::default;
-use Xconfig::resolution_and_depth;
-use common;
-
-
-sub to_string {
- my ($raw_X) = @_;
-
- $raw_X->is_fbdev ? 'frame-buffer' : Xconfig::resolution_and_depth::to_string($raw_X->get_resolution);
-}
-
-sub info {
- my ($raw_X, $card) = @_;
- my $info;
- my $xf_ver = Xconfig::card::xorg_version();
- my $title = $card->{use_DRI_GLX} ? N("Xorg %s with 3D hardware acceleration", $xf_ver) :
- N("Xorg %s", $xf_ver);
- my $keyboard = eval { $raw_X->get_keyboard } || {};
- my @monitors = eval { $raw_X->get_monitors };
- my $device = eval { $raw_X->get_device } || {};
- my $mouse = eval { first($raw_X->get_mice) } || {};
-
- $info .= N("Keyboard layout: %s\n", $keyboard->{XkbLayout});
- $info .= N("Mouse type: %s\n", $mouse->{Protocol});
- $info .= N("Mouse device: %s\n", $mouse->{Device}) if $::expert;
- foreach my $monitor (@monitors) {
- $info .= N("Monitor: %s\n", $monitor->{ModelName});
- $info .= N("Monitor HorizSync: %s\n", $monitor->{HorizSync}) if $::expert;
- $info .= N("Monitor VertRefresh: %s\n", $monitor->{VertRefresh}) if $::expert;
- }
- $info .= N("Graphics card: %s\n", $device->{VendorName} . ' ' . $device->{BoardName});
- $info .= N("Graphics memory: %s kB\n", $device->{VideoRam}) if $device->{VideoRam};
- if (my $resolution = eval { $raw_X->get_resolution }) {
- $info .= N("Color depth: %s\n", translate($Xconfig::resolution_and_depth::depth2text{$resolution->{Depth}}));
- $info .= N("Resolution: %s\n", join('x', @$resolution{'X', 'Y'}));
- }
- $info .= N("Xorg driver: %s\n", $device->{Driver}) if $device->{Driver};
- "$title\n\n$info";
-}
-
-sub various {
- my ($in, $card, $options, $b_auto) = @_;
-
- tvout($in, $card, $options) if !$b_auto;
- choose_xdm($in, $b_auto);
- 1;
-}
-
-sub runlevel {
- my ($o_runlevel) = @_;
- my $f = "$::prefix/etc/inittab";
- -r $f or log::l("missing inittab!!!"), return;
- if ($o_runlevel) {
- substInFile { s/^id:\d:initdefault:\s*$/id:$o_runlevel:initdefault:\n/ } $f if !$::testing;
- } else {
- cat_($f) =~ /^id:(\d):initdefault:\s*$/m && $1;
- }
-}
-
-sub choose_xdm {
- my ($in, $b_auto) = @_;
- my $xdm = $::isStandalone ? runlevel() == 5 : 1;
-
- if (!$b_auto) {
- $xdm = $in->ask_yesorno_({
- title => N("Graphical interface at startup"),
- messages =>
-N("I can setup your computer to automatically start the graphical interface (Xorg) upon booting.
-Would you like Xorg to start when you reboot?"),
- interactive_help_id => 'configureXxdm',
- }, $xdm);
- }
- runlevel($xdm ? 5 : 3);
-}
-
-sub tvout {
- my ($in, $card, $options) = @_;
-
- $card->{FB_TVOUT} && $options->{allowFB} or return;
-
- $in->ask_yesorno('', N("Your graphic card seems to have a TV-OUT connector.
-It can be configured to work using frame-buffer.
-
-For this you have to plug your graphic card to your TV before booting your computer.
-Then choose the \"TVout\" entry in the bootloader
-
-Do you have this feature?")) or return;
-
- #- rough default value (rationale: http://download.nvidia.com/XFree86_40/1.0-2960/README.txt)
- require timezone;
- my $norm = timezone::read()->{timezone} =~ /America/ ? 'NTSC' : 'PAL';
-
- $norm = $in->ask_from_list('', N("What norm is your TV using?"), [ 'NTSC', 'PAL' ], $norm) or return;
-
- configure_FB_TVOUT($in->do_pkgs, { norm => $norm });
-}
-
-sub configure_FB_TVOUT {
- my ($do_pkgs, $use_FB_TVOUT) = @_;
-
- my $raw_X = Xconfig::default::configure($do_pkgs);
- return if is_empty_array_ref($raw_X);
-
- $raw_X->set_monitors({ HorizSync => '30-50', VertRefresh => ($use_FB_TVOUT->{norm} eq 'NTSC' ? 60 : 50),
- ModeLine => [
- { val => '"640x480" 29.50 640 675 678 944 480 530 535 625', pre_comment => "# PAL\n" },
- { val => '"800x600" 36.00 800 818 820 960 600 653 655 750' },
- { val => '"640x480" 28.195793 640 656 658 784 480 520 525 600', pre_comment => "# NTSC\n" },
- { val => '"800x600" 38.769241 800 812 814 880 600 646 649 735' },
- ] });
- $raw_X->set_devices({ Driver => 'fbdev' });
-
- my ($device) = $raw_X->get_devices;
- my ($monitor) = $raw_X->get_monitors;
- $raw_X->set_screens({ Device => $device->{Identifier}, Monitor => $monitor->{Identifier} });
-
- my $Screen = $raw_X->get_default_screen;
- $Screen->{Display} = [ map { { l => { Depth => { val => $_ } } } } 8, 16 ];
-
- $raw_X->write("$::prefix/etc/X11/XF86Config.tvout");
-
- check_XF86Config_symlink();
-
- {
- require bootloader;
- require fsedit;
- require detect_devices;
- my $all_hds = $::isInstall ? $::o->{all_hds} : fsedit::get_hds();
- my $bootloader = $::isInstall ? $::o->{bootloader} : bootloader::read($all_hds);
-
- if (my $tvout = bootloader::duplicate_kernel_entry($bootloader, 'TVout')) {
- $tvout->{append} .= " XFree=tvout";
- bootloader::install($bootloader, $all_hds);
- }
- }
-}
-
-sub check_XF86Config_symlink() {
- my $f = "$::prefix/etc/X11/XF86Config";
- if (!-l $f && -e "$f.tvout") {
- rename $f, "$f.standard";
- symlink "XF86Config.standard", $f;
- }
-}
-
-sub setupFB {
- my ($bios_vga_mode) = @_;
-
- require bootloader;
- my ($bootloader, $all_hds);
-
- if ($::isInstall && !$::globetrotter) {
- ($bootloader, $all_hds) = ($::o->{bootloader}, $::o->{all_hds});
- } else {
- require fsedit;
- require fs;
- require bootloader;
- $all_hds = fsedit::get_hds();
- fs::get_info_from_fstab($all_hds);
-
- $bootloader = bootloader::read($all_hds) or return;
- }
-
- foreach (@{$bootloader->{entries}}) {
- $_->{vga} = $bios_vga_mode if $_->{vga}; #- replace existing vga= with
- }
-
- bootloader::action($bootloader, 'write', $all_hds);
- bootloader::action($bootloader, 'when_config_changed');
-}
-
-1;
diff --git a/perl-install/Xconfig/xfree.pm b/perl-install/Xconfig/xfree.pm
deleted file mode 100644
index 5cba3eec4..000000000
--- a/perl-install/Xconfig/xfree.pm
+++ /dev/null
@@ -1,742 +0,0 @@
-package Xconfig::xfree; # $Id$
-
-use diagnostics;
-use strict;
-
-use common;
-use Xconfig::parse;
-
-#- mostly internal only
-sub new {
- my ($class, $val) = @_;
- bless $val, $class;
-}
-
-sub _conf_files() {
- map { "$::prefix/etc/X11/$_" } 'xorg.conf', 'XF86Config-4', 'XF86Config';
-}
-
-################################################################################
-# I/O ##########################################################################
-################################################################################
-sub read_and_prepare_write {
- my ($class) = @_;
- my $file = find { -f $_ } _conf_files();
- my $raw_X = $class->new(Xconfig::parse::read_XF86Config($file));
- my $before = $raw_X->prepare_write;
-
- if (my ($Keyboard) = $raw_X->get_InputDevices('Keyboard')) {
- $Keyboard->{Driver}{val} = 'keyboard';
- }
-
- #- ugly hack to fix empty ModeLine lines, XFdrake seems to generate some, but where???
- #- at least this allows fixing the pb by re-running XFdrake
- foreach ($raw_X->get_Sections('Monitor')) {
- my $l = $_->{ModeLine} or next;
- @$l = grep { $_->{val} } @$l;
- }
-
- $raw_X, $before;
-}
-sub read {
- my ($class) = @_;
- first(read_and_prepare_write($class));
-}
-sub write {
- my ($raw_X, $o_file) = @_;
- my $file = $o_file || first(_conf_files());
- if (!$o_file) {
- foreach (_conf_files()) {
- if (-l $_) {
- unlink $_;
- } else {
- renamef($_, "$_.old"); #- there will not be any XF86Config nor XF86Config-4 anymore, we want this!
- }
- }
- #- keep it for old programs still using this name
- symlink basename($file), "$::prefix/etc/X11/XF86Config";
- }
- Xconfig::parse::write_XF86Config($raw_X, $file);
-}
-sub prepare_write {
- my ($raw_X) = @_;
- join('', Xconfig::parse::prepare_write_XF86Config($raw_X));
-}
-sub empty_config {
- my ($class) = @_;
- $class->new(Xconfig::parse::read_XF86Config_from_string(our $default_header));
-}
-
-################################################################################
-# keyboard #####################################################################
-################################################################################
-my @keyboard_fields = qw(XkbLayout XkbModel XkbDisable XkbOptions XkbCompat);
-sub get_keyboard {
- my ($raw_X) = @_;
- my $raw_kbd = first(map { $raw_X->get_InputDevices($_) } 'keyboard', 'kbd') or die "no keyboard section";
- raw_export_section($raw_kbd, \@keyboard_fields);
-}
-sub set_keyboard {
- my ($raw_X, $kbd) = @_;
- my $raw_kbd = first(map { $raw_X->get_InputDevices($_) } 'keyboard', 'kbd') || _new_keyboard_section($raw_X);
- raw_import_section($raw_kbd, $kbd);
- _set_Option('keyboard', $raw_kbd, keys %$kbd);
-}
-sub _new_keyboard_section {
- my ($raw_X) = @_;
- my $raw_kbd = { Identifier => { val => 'Keyboard1' }, Driver => { val => 'keyboard' } };
- $raw_X->add_Section('InputDevice', $raw_kbd);
-
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- push @$layout, { val => '"Keyboard1" "CoreKeyboard"' };
-
- $raw_kbd;
-}
-
-
-################################################################################
-# mouse ########################################################################
-################################################################################
-#- example: { Protocol => 'IMPS/2', Device => '/dev/psaux', Emulate3Buttons => undef, Emulate3Timeout => 50, ZAxisMapping => [ '4 5', '6 7' ] }
-my @mouse_fields = qw(Protocol Device ZAxisMapping Emulate3Buttons Emulate3Timeout); #-);
-sub get_mice {
- my ($raw_X) = @_;
- my @raw_mice = $raw_X->get_InputDevices('mouse');
- map { raw_export_section($_, \@mouse_fields) } @raw_mice;
-}
-sub set_mice {
- my ($raw_X, @mice) = @_;
- my @raw_mice = _new_mouse_sections($raw_X, int @mice);
- mapn {
- my ($raw_mouse, $mouse) = @_;
- raw_import_section($raw_mouse, $mouse);
- _set_Option('mouse', $raw_mouse, keys %$mouse);
- } \@raw_mice, \@mice;
-}
-sub _new_mouse_sections {
- my ($raw_X, $nb_new) = @_;
- $raw_X->remove_InputDevices('mouse');
-
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- @$layout = grep { $_->{val} !~ /^"Mouse/ } @$layout;
-
- $nb_new or return;
-
- my @l = map {
- my $h = { Identifier => { val => "Mouse$_" }, Driver => { val => 'mouse' } };
- $raw_X->add_Section('InputDevice', $h);
- } (1 .. $nb_new);
-
- push @$layout, { val => qq("Mouse1" "CorePointer") };
- push @$layout, { val => qq("Mouse$_" "SendCoreEvents") } foreach 2 .. $nb_new;
-
- @l;
-}
-
-
-################################################################################
-# resolution ###################################################################
-################################################################################
-sub get_resolution {
- my ($raw_X, $o_Screen) = @_;
- my $Screen = $o_Screen || $raw_X->get_default_screen or return {};
-
- my $depth = val($Screen->{DefaultColorDepth} || $Screen->{DefaultDepth});
- my $Display = find { !$depth || val($_->{l}{Depth}) eq $depth } @{$Screen->{Display} || []} or return {};
- $Display->{l}{Virtual} && val($Display->{l}{Virtual}) =~ /(\d+)\s+(\d+)/ or
- val($Display->{l}{Modes}) =~ /(\d+)x(\d+)/ or return {};
- { X => $1, Y => $2, Depth => val($Display->{l}{Depth}) };
-}
-sub set_resolution {
- my ($raw_X, $resolution, $o_Screen_) = @_;
-
- foreach my $Screen ($o_Screen_ ? $o_Screen_ : $raw_X->get_Sections('Screen')) {
- $Screen ||= $raw_X->get_default_screen or internal_error('no screen');
-
- my $Mode_name = (any { $_->{l}{Modes} } @{$Screen->{Display} || []}) ? 'Modes' : 'Virtual';
- my $Mode = sprintf($Mode_name eq 'Modes' ? '"%dx%d"' : '%d %d', @$resolution{'X', 'Y'});
-
- delete $Screen->{DefaultDepth};
- $Screen->{DefaultColorDepth} = { val => $resolution->{Depth} eq '32' ? 24 : $resolution->{Depth} };
- $Screen->{Display} = [ map {
- { l => { Depth => { val => $_ }, $Mode_name => { val => $Mode } } };
- } 8, 15, 16, 24 ];
- }
- add_gtf_ModeLines($raw_X, $resolution);
-}
-
-
-################################################################################
-# device #######################################################################
-################################################################################
-my @device_fields = qw(VendorName BoardName Driver VideoRam Screen BusID); #-);
-sub get_device {
- my ($raw_X) = @_;
- first(get_devices($raw_X));
-}
-sub get_devices {
- my ($raw_X) = @_;
- my @raw_devices = $raw_X->get_Sections('Device');
- map {
- my $raw_device = $_;
- my $device = raw_export_section($raw_device, [ 'Identifier', @device_fields ]);
- $device->{Options} = raw_export_section($raw_device, [ grep { (deref_array($raw_device->{$_}))[0]->{Option} } keys %$raw_device ]);
- $device;
- } @raw_devices;
-}
-sub set_devices {
- my ($raw_X, @devices) = @_;
- my @raw_devices = _new_device_sections($raw_X, int @devices);
- mapn {
- my ($raw_device, $device) = @_;
- my %Options = %{$device->{Options} || {}};
- raw_import_section($raw_device, $device, \@device_fields);
- raw_import_section($raw_device, \%Options);
- $_->{Option} = 1 foreach map { deref_array($raw_device->{$_}) } keys %Options;
- $raw_device->{''} = [ { post_comment => $device->{raw_LINES} } ] if $device->{raw_LINES};
- } \@raw_devices, \@devices;
-}
-sub _new_device_sections {
- my ($raw_X, $nb_new) = @_;
- $raw_X->remove_Section('Device');
- map { $raw_X->add_Section('Device', { Identifier => { val => "device$_" }, DPMS => { Option => 1 } }) } (1 .. $nb_new);
-}
-sub get_Driver {
- my ($raw_X) = @_;
- my $card = eval { $raw_X->get_device };
- $card && $card->{Driver};
-}
-
-################################################################################
-# wacoms #######################################################################
-################################################################################
-sub set_wacoms {
- my ($raw_X, @wacoms) = @_;
- $raw_X->remove_InputDevices('wacom');
-
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- @$layout = grep { $_->{val} !~ /^"(Stylus|Eraser|Cursor)/ } @$layout;
-
- @wacoms or return;
-
- my %Modes = (Stylus => 'Absolute', Eraser => 'Absolute', Cursor => 'Relative');
-
- each_index {
- my $wacom = $_;
- foreach (keys %Modes) {
- my $identifier = $_ . ($::i + 1);
- my $h = { Identifier => { val => $identifier },
- Driver => { val => 'wacom' },
- Type => { val => lc $_, Option => 1 },
- Device => { val => $wacom->{Device}, Option => 1 },
- Mode => { val => $Modes{$_}, Option => 1 },
- if_($wacom->{USB}, USB => { Option => 1 })
- };
- $raw_X->add_Section('InputDevice', $h);
- push @$layout, { val => qq("$identifier" "AlwaysCore") };
- }
- } @wacoms;
-}
-
-
-################################################################################
-# synaptics ####################################################################
-################################################################################
-sub set_synaptics {
- my ($raw_X, @synaptics) = @_;
- $raw_X->remove_InputDevices('synaptics');
-
- my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
- @$layout = grep { $_->{val} !~ /^"SynapticsMouse/ } @$layout;
-
- @synaptics or return;
- add_load_module($raw_X, "synaptics");
-
- each_index {
- my $synaptics_mouse = $_;
- my $identifier = "SynapticsMouse" . ($::i + 1);
- my $pointer_type = $synaptics_mouse->{Primary} ? "CorePointer" : "AlwaysCore";
- my $h = {
- Identifier => { val => $identifier },
- Driver => { val => "synaptics" },
- };
- my %opts = (
- Device => $synaptics_mouse->{Device},
- Protocol => $synaptics_mouse->{Protocol},
- $synaptics_mouse->{ALPS} ? (
- #- from /usr/share/doc/synaptics-0.14.0/README.alps
- #- and http://qa.mandrakesoft.com/show_bug.cgi?id=14512
- LeftEdge => 120,
- RightEdge => 830,
- TopEdge => 120,
- BottomEdge => 650,
- FingerLow => 14,
- FingerHigh => 15,
- MaxTapTime => 180,
- MaxTapMove => 110,
- EmulateMidButtonTime => 75,
- VertScrollDelta => 20,
- HorizScrollDelta => 20,
- MinSpeed => '0.8',
- MaxSpeed => '1.00',
- AccelFactor => '0.015',
- EdgeMotionMinSpeed => 200,
- EdgeMotionMaxSpeed => 200,
- UpDownScrolling => 1,
- CircularScrolling => 1,
- CircScrollDelta => '0.1',
- CircScrollTrigger => 2,
- UpDownScrolling => 0,
- ) : (
- #- from /usr/share/doc/synaptics-0.14.0/INSTALL
- LeftEdge => 1700,
- RightEdge => 5300,
- TopEdge => 1700,
- BottomEdge => 4200,
- FingerLow => 25,
- FingerHigh => 30,
- MaxTapTime => 180,
- MaxTapMove => 220,
- VertScrollDelta => 100,
- MinSpeed => '0.09',
- MaxSpeed => '0.18',
- AccelFactor => '0.0015',
- ),
- SHMConfig => "on",
- );
- while (my ($k, $v) = each %opts) {
- $h->{$k} = { val => $v, Option => 1 };
- }
- $raw_X->add_Section('InputDevice', $h);
- push @$layout, { val => qq("$identifier" "$pointer_type") };
- } @synaptics;
-}
-
-
-################################################################################
-# monitor ######################################################################
-################################################################################
-my @monitor_fields = qw(VendorName ModelName HorizSync VertRefresh);
-sub get_monitors {
- my ($raw_X) = @_;
- my @raw_monitors = $raw_X->get_Sections('Monitor');
- map {
- my $h = raw_export_section($_, [ 'Identifier', @monitor_fields ]);
- $h->{ModeLine} = $_->{ModeLine} if $_->{ModeLine};
- $h;
- } @raw_monitors;
-}
-sub set_monitors {
- my ($raw_X, @monitors) = @_;
- my @raw_monitors = _new_monitor_sections($raw_X, int @monitors);
- mapn {
- my ($raw_monitor, $monitor) = @_;
- raw_import_section($raw_monitor, $monitor, \@monitor_fields);
- $raw_monitor->{ModeLine} = $monitor->{ModeLine} if $monitor->{ModeLine};
- } \@raw_monitors, \@monitors;
-}
-sub get_or_new_monitors {
- my ($raw_X, $nb_new) = @_;
- my @monitors = $raw_X->get_monitors;
-
- #- ensure we have exactly $nb_new monitors;
- if ($nb_new > @monitors) {
- @monitors, ({}) x ($nb_new - @monitors);
- } else {
- splice(@monitors, 0, $nb_new);
- }
-}
-sub _new_monitor_sections {
- my ($raw_X, $nb_new) = @_;
- $raw_X->remove_Section('Monitor');
- map { $raw_X->add_Section('Monitor', { Identifier => { val => "monitor$_" }, ModeLine => default_ModeLine() }) } (1 .. $nb_new);
-}
-sub default_ModeLine() {
- ModeLine_from_string(qq(Section "Monitor"\n) . (our $default_ModeLine) . qq(EndSection\n));
-}
-
-sub add_gtf_ModeLines {
- my ($raw_X, $resolution) = @_;
-
- my $banner = 'modeline generated by gtf(1) [handled by XFdrake]';
- my $res = $resolution->{X} . 'x' . $resolution->{Y};
- my @to_add;
- if ($res ne '1280x1024' &&
- ($res eq '1400x1050' || $res eq '1152x864' || $Xconfig::xfree::resolution2ratio{$res} ne '4/3')) {
- @to_add = map {
- my $s = run_program::rooted_get_stdout($::prefix, 'gtf', $resolution->{X}, $resolution->{Y}, $_);
- if (my ($name, $val) = $s =~ /ModeLine\s*"(.*)"(.*)/i) {
- chomp $val;
- $name =~ s/\.00//; #- nicer that way
- { val => qq("${name}"$val), pre_comment => "# $banner\n" };
- } else { () }
- } reverse(sort_numbers(@Xconfig::xfree::vfreqs));
- }
-
- $raw_X->set_monitors(map {
- @{$_->{ModeLine}} = (
- (grep { index($_->{pre_comment}, $banner) == -1 } @{$_->{ModeLine}}),
- @to_add,
- );
- $_;
- } $raw_X->get_monitors);
-
- 1;
-}
-
-
-################################################################################
-# screens ######################################################################
-################################################################################
-sub get_default_screen {
- my ($raw_X) = @_;
- my @l = $raw_X->get_Sections('Screen');
- (find { $_->{Identifier} && val($_->{Identifier}) eq 'screen1' ||
- $_->{Driver} && val($_->{Driver}) =~ /svga|accel/ } @l) || $l[0];
-}
-sub set_screens {
- my ($raw_X, @screens) = @_;
- my @raw_screens = _new_screen_sections($raw_X, int @screens);
- mapn {
- my ($raw_screen, $screen) = @_;
- raw_import_section($raw_screen, $screen);
- } \@raw_screens, \@screens;
-}
-sub _new_screen_sections {
- my ($raw_X, $nb_new) = @_;
- $raw_X->remove_Section('Screen');
- my @l = map { $raw_X->add_Section('Screen', { Identifier => { val => "screen$_" } }) } (1 .. $nb_new);
-
- get_ServerLayout($raw_X)->{Screen} = [
- { val => qq("screen1") },
- map { { val => sprintf('"screen%d" RightOf "screen%d"', $_, $_ - 1) } } (2 .. $nb_new)
- ];
- @l;
-}
-sub is_fbdev {
- my ($raw_X, $o_Screen) = @_;
-
- my $Screen = $o_Screen || $raw_X->get_default_screen or return;
-
- my $Device = $raw_X->get_Section_by_Identifier('Device', val($Screen->{Device})) or internal_error("no device named $Screen->{Device}");
- val($Device->{Driver}) eq 'fbdev';
-}
-
-
-
-
-################################################################################
-# modules ######################################################################
-################################################################################
-sub get_modules {
- my ($raw_X) = @_;
- my $raw_Module = $raw_X->get_Section('Module') or return;
- my $Module = raw_export_section($raw_Module, ['Load']);
- @{$Module->{Load} || []};
-}
-sub add_load_module {
- my ($raw_X, $module) = @_;
- my $raw_Module = $raw_X->get_Section('Module') || $raw_X->add_Section('Module', {});
-
- my %load_modules_comment = (
- dbe => 'Double-Buffering Extension',
- v4l => 'Video for Linux',
- dri => 'direct rendering',
- glx => '3D layer',
- 'glx-3.so' => '3D layer',
- );
- my $comment = $load_modules_comment{$module};
- push @{$raw_Module->{Load}}, { val => $module,
- comment_on_line => $comment && " # $comment",
- } if !member($module, $raw_X->get_modules);
-}
-sub remove_load_module {
- my ($raw_X, $module) = @_;
- my $raw_Module = $raw_X->get_Section('Module') or return;
- if (my @l = grep { $_->{val} ne $module } @{$raw_Module->{Load}}) {
- $raw_Module->{Load} = \@l;
- } else {
- $raw_X->remove_Section('Module');
- }
-}
-sub set_load_module {
- my ($raw_X, $module, $bool) = @_;
- $bool ? add_load_module($raw_X, $module) : remove_load_module($raw_X, $module);
-}
-
-
-#-##############################################################################
-#- helpers
-#-##############################################################################
-sub _set_Option {
- my ($category, $node, @names) = @_;
-
- if (member($category, 'keyboard', 'mouse')) {
- #- everything we export is an Option
- $_->{Option} = 1 foreach map { deref_array($node->{$_}) } @names;
- }
-}
-
-sub get_InputDevices {
- my ($raw_X, $Driver) = @_;
- $raw_X->get_Sections('InputDevice', sub { val($_[0]{Driver}) eq $Driver });
-}
-sub remove_InputDevices {
- my ($raw_X, $Driver) = @_;
- $raw_X->remove_Section('InputDevice', sub { val($_[0]{Driver}) ne $Driver });
-}
-
-sub get_ServerLayout {
- my ($raw_X) = @_;
- $raw_X->get_Section('ServerLayout') ||
- $raw_X->add_Section('ServerLayout', { Identifier => { val => 'layout1' } });
-}
-
-#-##############################################################################
-#- helpers
-#-##############################################################################
-sub raw_export_section {
- my ($section, $fields) = @_;
-
- my $export_name = sub {
- my ($name) = @_;
- my $h = $section->{$name} or return;
-
- my @l = map { if_(!$_->{commented}, $_->{val}) } deref_array($h) or return;
- $name => (ref($h) eq 'ARRAY' ? \@l : $l[0]);
- };
-
- my %h = map { $export_name->($_) } @$fields;
- \%h;
-}
-
-sub raw_import_section {
- my ($section, $h, $o_fields) = @_;
- foreach ($o_fields ? grep { exists $h->{$_} } @$o_fields : keys %$h) {
- my @l = map { ref($_) eq 'HASH' ? $_ : { val => $_ } } deref_array($h->{$_});
- $section->{$_} = (ref($h->{$_}) eq 'ARRAY' ? \@l : $l[0]);
- }
-}
-
-sub add_Section {
- my ($raw_X, $Section, $h) = @_;
- my @suggested_ordering = qw(Files ServerFlags Module DRI Keyboard Pointer XInput InputDevice Monitor Device Screen ServerLayout);
- my %order = map_index { { lc($_) => $::i } } @suggested_ordering;
- my $e = { name => $Section, l => $h };
- my $added;
- @$raw_X = map {
- if ($order{lc $_->{name}} > $order{lc $Section} && !$added) {
- $added = 1;
- ($e, $_);
- } else { $_ }
- } @$raw_X;
- push @$raw_X, $e if !$added;
- $h;
-}
-sub remove_Section {
- my ($raw_X, $Section, $o_when) = @_;
- @$raw_X = grep { $_->{name} ne $Section || $o_when && $o_when->($_->{l}) } @$raw_X;
- $raw_X;
-}
-sub get_Sections {
- my ($raw_X, $Section, $o_when) = @_;
- map { if_(lc($_->{name}) eq lc($Section) && (!$o_when || $o_when->($_->{l})), $_->{l}) } @$raw_X;
-}
-sub get_Section {
- my ($raw_X, $Section, $o_when) = @_;
- my @l = get_Sections($raw_X, $Section, $o_when);
- @l > 1 and log::l("Xconfig: found more than one Section $Section");
- $l[0];
-}
-sub get_Section_by_Identifier {
- my ($raw_X, $Section, $Identifier) = @_;
- my @l = get_Sections($raw_X, $Section, sub { val($_[0]{Identifier}) eq $Identifier });
- @l > 1 and die "more than one Section $Section has Identifier $Identifier";
- $l[0];
-}
-
-sub val {
- my ($ref) = @_;
- $ref && $ref->{val};
-}
-
-
-sub ModeLine_from_string {
- my ($s) = @_;
- my $raw_X_for_ModeLine = Xconfig::parse::read_XF86Config_from_string($s);
- get_Section($raw_X_for_ModeLine, 'Monitor')->{ModeLine};
-}
-
-
-
-# http://home.comcast.net/~igpl/Aspect.html
-# movies http://www.technosound.co.uk/nav.php?pageid=hcg_widescreen
-# esp for 1360x768 http://www.winischhofer.at/linuxsispart1.shtml
-
-# www.dell.com/downloads/global/vectors/2003_cvt.pdf
-# file vesamodes in Xorg is DMT Standard Display Modes
-
-# http://www.vesa.org/Public
-# http://www.vesa.org/Public/EEDIDguideV1.pdf
-
-#- http://www.vesa.org/Public/CVT
-our @CVT_ratios = qw(4/3 16/9 16/10 5/4 15/9 3/2);
-our @CVT_vfreqs = qw(50 60 75 85); # and also 60Hz "reduced blanking" in CVT
-
-our @vfreqs = (@CVT_vfreqs, qw(100 120));
-
-our %ratio2resolutions = (
-
- # first all the CVT_ratios
-
- # 1.25
- '5/4' => [ qw(640x512 720x576 1280x1024 1800x1440) ],
- # SXGA=1280x1024 QSXGA=2560x2048
-
- # 1.33
- '4/3' => [
- qw(320x240 480x360 640x480 800x600 832x624
- 1024x768 1152x864 1280x960 1400x1050
- 1600x1200 1920x1440 2048x1536), # 768x576 1792x1344 1856x1392
- # DBLSCAN: 400x300 416x312 512x384 576x432 700x525 896x672 928x696 960x720
- ], # VGA=640x480, SVGA=800x600, XGA=1024x768, SXGA+=1400x1050, UXGA=1600x1200, QXGA=2048x1536 QSXGA+=2800x2100, QUXGA=3200x2400
-
- # 1.5
- '3/2' => [ qw(360x240 720x480 1152x768) ], # 576x384 (DBLSCAN of 1152x768)
-
- # 1.6
- '16/10' => [ qw(1280x800 1440x900 1600x1000 1680x1050 1920x1200) ], # 320x200 640x400 960x600 2560x1600
- # WSXGA+=1680x1050, WUXGA=1920x1200, WQUXGA=3840x2400
-
- # 1.67
- '15/9' => [ qw(1280x768) ], # 800x480
- # WXGA=1280x768 or ??? (should be 1366x768)
-
- # 1.78
- '16/9' => [ qw(1280x720 1600x900 1920x1080) ], # 960x540 1024x576
-
-
- # now more weird things
-
- # 1.32
- # '192/145' => [ qw(1152x870) ],
-
- # 1.328
- # '85/64' => [ qw(1360x1024) ],
-
- # 1.42
- # '17/12' => [ qw(544x384) ] ,
-
- # 1.56
- # '25/16' => [ qw(1600x1024) ], # WSXGA, (DBLSCAN 800x512)
-
- # 1.707
- # '128/75' => [ qw(1024x600) ],
-
- # 1.767
- # '53/30' => [ qw(848x480) ],
-
- # 1.771
- # '85/48' => [ qw(1360x768) ],
-
- # 1.775
- # '71/40' => [ qw(852x480) ],
-
- # 1.783
- # '107/60' => [ qw(856x480) ],
-
- N_("_:weird aspect ratio\nother") => [
- # 2.13 = 32/15
- qw(1024x480 1280x600), # VAIO
-
- # 2.67 = 8/3
- qw(2048x768 2560x960 3200x1200),
-
- # 4.0 = 4/1
- qw(3072x768 3456x864 3840x960 4800x1200),
-
- # ?? 352x288 640x350 (DBLSCAN 320x175) 720x400 (DBLSCAN 360x200)
- ],
-);
-
-our %resolution2ratio = map_each { map { $_ => $::a } @$::b } %ratio2resolutions;
-our @resolutions = map_each { @$::b } %ratio2resolutions;
-
-foreach my $ratio (keys %ratio2resolutions) {
- if ($ratio =~ m!^(\d+)/(\d+)$!) {
- my $eval = $2 / $1;
- foreach (@{$ratio2resolutions{$ratio}}) {
- my ($x, $y) = /(\d+)x(\d+)/;
- my $y2 = round($x * $eval);
- $y == $y2 or do {
- my $good_ratio = (find { m!^(\d+)/(\d+)$! && $y == round($x * $2 / $1) } keys %ratio2resolutions) || '??';
- die "bad ratio $ratio for resolution $_, it should be $good_ratio\n";
- };
- }
- }
-}
-
-our $default_header = <<'END';
-# File generated by XFdrake.
-
-# **********************************************************************
-# Refer to the xorg.conf 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 <Crtl><Alt><BS> (server abort)
- #DontZoom # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
- AllowMouseOpenFail # allows the server to start up even if the mouse does not work
-END
-
-require detect_devices;
-$default_header .= <<'END_XBOX' if detect_devices::is_xbox();
- Option "PciProbe1" "false"
- Option "PciProbe2" "false"
- Option "PciForceConfig1" "false"
- Option "PciForceConfig2" "false"
- Option "PciOsConfig" "true"
-END_XBOX
-
-$default_header .= <<'END';
-EndSection
-END
-
-our $default_ModeLine = arch() =~ /ppc/ ? <<'END_PPC' : <<'END';
- # 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
-END_PPC
- # 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
-END
-
-1;