home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * $Id: inst_config_x11.ycp,v 1.21 2000/03/09 09:06:41 kkaempf Exp $
- *
- * Module: inst_config_x11.ycp
- *
- * Author: Stefan Hundhammer <sh@suse.de>
- * Stefan Schubert <schubi@suse.de>
- *
- * Purpose: Let the user choose screen resolution and color depth.
- * Optionally select "No X11 configuration".
- * Additionally toggle 3D acceleration.
- * Branch into X11 test (xfine).
- *
- * user_settings: monitor ( have the same format as SCR-output )
- * monitor_auto_probed
- */
- {
- boolean test_mode = lookup ( user_settings, "test_mode", false );
-
- // allow going back only if monitor wasn't autoprobed
- boolean allow_back = ( lookup( user_settings, "monitor_auto_probed", false ) == false );
-
- if ( ! lookup(user_settings,"have_x11",true ) )
- {
- // Doing nothing cause there was no X-Server installed
- return `next;
- }
-
- // evaluate monitor and display settings and ask the user if it
- // would be needed.
-
- map monitor = lookup ( user_settings, "monitor", $[] );
-
- any video_ret = `again;
-
- if ( size ( monitor ) <= 0 || allow_back )
- {
- // check only, if monitor is not set.
- video_ret = CallFunction( `inst_video_data( false, true ) );
-
- if ( video_ret == `no_x11 )
- {
- // Doing nothing cause user didn't want X11 to be configured
- Shell("rm /etc/XF86Config");
- Shell("rm /var/X11R6/bin/X");
- return `next;
- }
-
- monitor = lookup ( user_settings, "monitor", $[] );
- }
-
-
- list all_resolutions =
- [
- $[ `x: 640, `y: 480 ],
- $[ `x: 800, `y: 600 ],
- $[ `x: 1024, `y: 768 ],
- $[ `x: 1152, `y: 864 ],
- $[ `x: 1280, `y: 960 ],
- $[ `x: 1280, `y: 1024 ],
- $[ `x: 1600, `y: 1200 ]
- ];
-
- list rev_all_resolutions =
- [
- $[ `x: 1600, `y: 1200 ],
- $[ `x: 1280, `y: 1024 ],
- $[ `x: 1280, `y: 960 ],
- $[ `x: 1152, `y: 864 ],
- $[ `x: 1024, `y: 768 ],
- $[ `x: 800, `y: 600 ],
- $[ `x: 640, `y: 480 ]
- ];
-
- list vga = SCR(`Read(.probe.bios_video) );
- map display = select ( vga, 0 ); // first entry
-
- list resolution_list = lookup ( lookup ( monitor, "resource", $[] ),
- "monitor_resol", [] );
- string video_card_name = lookup ( display ,"sub_vendor", "" ) +
- " " + lookup ( display ,"sub_device", "" );
- string x_server_name = lookup ( user_settings, "xservername","SVGA");
- boolean have_3d_accel = false;
-
- list allVga = SCR(`Read(.probe.display));
-
- y2log(.milestone, "inst_config_x11", 5,sformat("all vga cards: %1", allVga ));
-
- foreach ( `display, allVga, ``{
- map x11 = lookup ( display , "x11", $[] );
- list x3d = lookup ( x11, "x3d", [] );
-
- if ( size(x3d) > 0 )
- {
- have_3d_accel = true;
- }
- });
-
-
-
- //
- // Get the width of the selected screen-resolution
- //
- define getCurrentWidth( )
- ``{
- integer ret = 0;
- foreach ( `resolution, all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- if ( UI(`QueryWidget(`id( res_id ), `Value)) )
- {
- //entry found
- ret = lookup ( resolution, `x );
- }
-
- });
- return(ret);
- };
-
-
- //
- // Get the height of the selected screen-resolution
- //
- define getCurrentHeight( )
- ``{
- integer ret = 0;
- foreach ( `resolution, all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- if ( UI(`QueryWidget(`id( res_id ), `Value)) )
- {
- //entry found
- ret = lookup ( resolution, `y );
- }
-
- });
- return(ret);
- };
-
- //
- // Get the selected color-depth
- //
- define getCurrentColorDepth( )
- ``{
-
- if ( UI(`QueryWidget(`id( `depth8 ), `Value)) )
- {
- return ( 8 );
- }
- if ( UI(`QueryWidget(`id( `depth16 ), `Value)) )
- {
- return ( 16 );
- }
- if ( UI(`QueryWidget(`id( `depth24 ), `Value)) )
- {
- return ( 24 );
- }
- if ( UI(`QueryWidget(`id( `depth32 ), `Value)) )
- {
- return ( 32 );
- }
- return ( 0 );
- };
-
-
- //
- // Get the frequency
- //
- define getCurrentFrequency( )
- ``{
- integer max_frequency = 0;
- integer height = getCurrentHeight();
- integer width = getCurrentWidth();
-
- foreach ( `monitor_resolution, resolution_list, ``{
- // find maximal frequency for this resolution
- if ( width == lookup ( monitor_resolution, "width",0 ) &&
- height == lookup ( monitor_resolution, "height",0 ) )
- {
- integer frequency = lookup ( monitor_resolution, "vfreq", 0 );
- if ( max_frequency < frequency )
- {
- max_frequency = frequency;
- }
- }
- });
-
- return ( max_frequency );
- };
-
-
- //
- // Disable color-depth and resolution input
- //
- define disableX11Input( )
- ``{
-
- UI( `ChangeWidget(`id(`depth8), `Enabled, false));
- UI( `ChangeWidget(`id(`depth16), `Enabled, false));
- UI( `ChangeWidget(`id(`depth24), `Enabled, false));
- UI( `ChangeWidget(`id(`depth32), `Enabled, false));
-
- foreach ( `resolution, all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- UI( `ChangeWidget(`id(res_id), `Enabled, false));
- });
- UI( `ChangeWidget(`id(`use_3D_accel), `Enabled, false));
- UI( `ChangeWidget(`id(`test_X11), `Enabled, false));
- };
-
- //
- // Check, if the resolution-input is valid. If not, setting a valid value automatically.
- //
- define checkResolutionInput( )
- ``{
- boolean wrongEntry = false;
- boolean firstValidEntry = false;
- foreach ( `resolution, rev_all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- if ( ! UI( `QueryWidget(`id(res_id), `Enabled)) &&
- UI(`QueryWidget(`id( res_id ), `Value)) )
- {
- // wrong entry found
- wrongEntry = true;
- }
- if ( wrongEntry &&
- UI( `QueryWidget(`id(res_id), `Enabled)) )
- {
- // setting new entry
- if ( ! firstValidEntry )
- {
- // take the second valid entry
- firstValidEntry = true;
- }
- else
- {
- // set entry
- UI( `ChangeWidget( `id( res_id ), `Value, true ) );
- firstValidEntry = false;
- wrongEntry = false;
- monitor = add ( monitor,"currentWidth",lookup ( resolution, `x ) );
- monitor = add ( monitor,"currentHeight", lookup ( resolution, `y ));
- }
- }
- });
- if ( wrongEntry )
- {
- // set minimal resolution
- UI( `ChangeWidget( `id( "640 x 480" ), `Value, true ));
- monitor = add ( monitor,"currentWidth", 640);
- monitor = add ( monitor,"currentHeight", 480);
- }
- };
-
-
- //
- // Enable color-depth and resolution input and set the previous user-settings
- //
- define enableX11Input( )
- ``{
- // Get user_settings values
- integer height = lookup ( monitor, "currentHeight", 0 );
- integer width = lookup ( monitor, "currentWidth", 0 );
-
- if ( height > 0 && width > 0 )
- {
- string res_monitor = sformat ( "%1 x %2",
- width,
- height );
- UI( `ChangeWidget( `id( res_monitor ), `Value, true ) );
- }
- else
- {
- // Select a default resolution
- UI( `ChangeWidget( `id( "1280 x 960" ), `Value, true ) );
- monitor = add ( monitor,"currentWidth", 1280);
- monitor = add ( monitor,"currentHeight", 960);
- }
-
-
- integer colorDepth = lookup ( monitor, "currentColorDepth", 0);
- if ( UI(`QueryWidget(`id(`use_3D_accel), `Value)))
- {
- // 3d selected --> depth 16
- UI( `ChangeWidget( `id( `depth16 ), `Value, true ) );
- monitor = add ( monitor,"currentColorDepth",
- 16);
- colorDepth = 16;
- }
- else
- {
- if ( colorDepth > 0 )
- {
- if ( colorDepth == 8 )
- {
- UI( `ChangeWidget( `id( `depth8 ), `Value, true ) );
- }
- else if ( colorDepth == 16 )
- {
- UI( `ChangeWidget( `id( `depth16 ), `Value, true ) );
- }
- else if ( colorDepth == 24 )
- {
- UI( `ChangeWidget( `id( `depth24 ), `Value, true ) );
- }
- else if ( colorDepth == 32 )
- {
- UI( `ChangeWidget( `id( `depth32 ), `Value, true ) );
- }
- }
- else
- {
- // Select a default color depth
- UI( `ChangeWidget( `id( `depth16 ), `Value, true ) );
- monitor = add ( monitor,"currentColorDepth",
- 16);
- colorDepth = 16;
- }
- }
-
- // 3d support ?
-
- UI(`ChangeWidget(`id(`use_3D_accel),`Value, lookup( monitor,"3dSelected",false) ));
-
-
- // Evaluate all possible settings for screen resolution
- if ( size ( resolution_list ) > 0 )
- {
- // hidden all entries in the screen resolution
- foreach ( `resolution, all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- UI( `ChangeWidget(`id(res_id), `Enabled, false));
- });
-
- // enable if supported
- foreach ( `monitor_resolution, resolution_list, ``{
- string res_monitor = sformat ( "%1 x %2",
- lookup ( monitor_resolution, "width" ),
- lookup ( monitor_resolution, "height" ) );
- integer color = lookup ( monitor_resolution, "color", 0 );
-
- foreach ( `resolution, all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- if ( res_id == res_monitor && color == colorDepth)
- {
- UI( `ChangeWidget(`id(res_id), `Enabled, true));
- }
- });
- });
- }
-
- map x11 = lookup ( display , "x11", $[] );
-
- // check if the color depth is supported by the video-card
- if ( UI(`QueryWidget(`id(`use_3D_accel), `Value)))
- {
- //3d supported --> only depth 16 is valid
- UI( `ChangeWidget(`id(`depth8), `Enabled, false ));
- UI( `ChangeWidget(`id(`depth16), `Enabled, true ));
- UI( `ChangeWidget(`id(`depth24), `Enabled, false ));
- UI( `ChangeWidget(`id(`depth32), `Enabled, false ));
- }
- else
- {
- if ( size( x11 ) > 0 )
- {
- UI( `ChangeWidget(`id(`depth8), `Enabled, lookup ( x11, "c8", true )));
- UI( `ChangeWidget(`id(`depth16), `Enabled, lookup ( x11, "c16", true )));
- UI( `ChangeWidget(`id(`depth24), `Enabled, lookup ( x11, "c24", true )));
- UI( `ChangeWidget(`id(`depth32), `Enabled, lookup ( x11, "c32", true )));
- }
- else
- {
- UI( `ChangeWidget(`id(`depth8), `Enabled, true ));
- UI( `ChangeWidget(`id(`depth16), `Enabled, true ));
- UI( `ChangeWidget(`id(`depth24), `Enabled, true ));
- UI( `ChangeWidget(`id(`depth32), `Enabled, true ));
- }
- }
-
- if ( have_3d_accel )
- {
- UI( `ChangeWidget(`id(`use_3D_accel), `Enabled, true));
- }
- else
- {
- UI( `ChangeWidget(`id(`use_3D_accel), `Enabled, false));
- UI( `ChangeWidget(`id(`use_3D_accel), `Value, false));
- }
- UI( `ChangeWidget(`id(`test_X11), `Enabled, true));
-
- // Check, if the resolution-input is valid. If not, setting a valid value automatically.
- checkResolutionInput();
-
- };
-
-
-
-
- string video_card_info = sformat (
- // Video card information string:
- // %1 will be substituted with the name of the video card
- // (e.g. "Hyper VGA DeLuxe Pro"),
- // %2 with the amount of video memory (+MB etc.).
- UI( _( "%1 " ) ),
- video_card_name );
-
- string x_server_info = sformat(
- // X server information string:
- // %1 will be substituted with the name of the X server to use
- // (e.g. "SVGA").
- UI( _( "X server: %1" ) ), x_server_name );
-
-
- // Create radio box for screen resolution
-
- term resolution_radio_buttons = `VBox();
-
- foreach ( `resolution, all_resolutions, ``{
- string res_id = sformat ( "%1 x %2",
- lookup ( resolution, `x ),
- lookup ( resolution, `y ) );
- resolution_radio_buttons = add ( resolution_radio_buttons,
- `Left( `RadioButton( `id( res_id ), `opt(`notify),res_id ) ) );
-
- });
-
-
-
-
- // Create radio box for color depth
-
- term color_depth_radio_buttons =
- `VBox(
- // Radio button for 8 bit color depth
- `Left( `RadioButton( `id( `depth8 ),`opt(`notify), _( "256 colors (8 bpp)" ) ) ),
-
- // Radio button for 16 bit color depth
- `Left( `RadioButton( `id( `depth16 ),`opt(`notify), _( "65K colors (16 bpp)" ) ) ),
-
- // Radio button for 24 bit color depth
- `Left( `RadioButton( `id( `depth24 ),`opt(`notify), _( "16.7M colors (24 bpp)" ) ) ),
-
- // Radio button for 32 bit color depth
- `Left( `RadioButton( `id( `depth32 ),`opt(`notify), _( "16.7M colors (32 bpp)" ) ) )
- );
-
-
- // Build window contents
-
- term contents = `HBox(
- `HWeight( 3, `HStretch() ),
- `HWeight( 100, `VBox( `Left( `Label ( video_card_info ) ),
- `Left( `Label ( x_server_info ) ),
- `Label( " " ),
-
- // Check box to skip X configuration alltogether
- // (will disable all other settings in this dialog when checked)
- `Left( `CheckBox ( `id( `no_X11 ),`opt(`notify), _( "No X11 configuration" ) ) ),
- `Label( " " ),
-
- `HBox(
- `HWeight( 45, `Top(
- `Frame(
- // Frame title for screen resolution radio box
- _( "Resolution" ),
- `RadioButtonGroup( resolution_radio_buttons )
- )
- )
- ),
- `HWeight( 3, `HStretch() ),
- `HWeight( 55, `VBox(
- `Top(
- `Frame(
- // Frame title for color depth radio box
- _( "Colors" ),
- `RadioButtonGroup( color_depth_radio_buttons )
- )
- ),
-
- // Check box to enable/disable 3D graphics acceleration
- `VCenter(
- `Left(
- `CheckBox( `id( `use_3D_accel ),`opt(`notify), _("Use 3D acceleration") )
- )
- )
- )
- )
- ),
-
- // Push button to test the selected settings:
- // starts the selected X server and 'xfine'
- `PushButton( `id( `test_X11 ),`opt(`notify), _( "&Test" ) )
- )
- ),
- `HWeight( 3, `HStretch() )
- );
-
- // Help text for inst_config_x11.ycp: The user selects video resulution and color depth.
- // Window layout:
- //
- // <Information about automatically detected video card and its amount of memory>
- // <Information about what X server to use (depends on the video card)>
- //
- // <Check box "No X11 configuration">
- //
- // <Radio box for screen resolutions> <Radio box for color depth>
- //
- // <Check box "Use 3D acceleration">
- //
- // <Push button "Test">
- //
- //
- // "No X11 configuration" will disable most the other items in this
- // window, if checked.
- //
- // "Use 3D acceleration" specifies whether or not to use hardware
- // accelerated 3D graphics (e.g. Voodoo- and TNT-based video cards).
- //
- // The "Test" button will start the appropriate X server and "xfine"
- // to let the user fine-tune the video settings (horizontal/vertical
- // sizes and positions).
- //
- // Help text (HTML-like) START
- string help_text = UI( _( "<p>
- Please select the <b>Desktop Settings</b> to use for the X Window System (X11).
- </p>" ) );
-
- // Help text (HTML-like) continued
- help_text = help_text + UI( _( "<p>
- The video card shown has automatically been detected.
- The appropriate X server for this video card has been chosen accordingly.
- </p>" ) );
-
- // Help text (HTML-like) continued
- help_text = help_text + UI( _( "<p>
- Select <b>No X11 configuration</b> to skip X Window configuration.
- You can configure X11 manually later (using <b><i>sax</i></b>) if you wish.
- </p>" ) );
-
- // Help text (HTML-like) continued
- help_text = help_text + UI( _( "<p>
- Select one of the possible screen <b>Resolutions</b> from the box on
- the left side and one of the possible <b>Color</b> settings from the
- box on the right side.
- </p>" ) );
-
- // Help text (HTML-like) continued
- help_text = help_text + UI( _( "<p>
- Please notice that not all combinations of colors and resolution may
- be valid with your video card; this depends on the amount of memory
- (shown above) on the card.
- The higher the resolution and the number of colors, the more memory is required.
- </p>" ) );
-
- // Help text (HTML-like) continued
- help_text = help_text + UI( _( "<p>
- Select <b>Use 3D acceleration</b> to enable hardware accelerated 3D graphics.
- Not all video cards are capable of using this feature.
- </p>" ) );
-
- // Help text (HTML-like) continued
- help_text = help_text + UI( _( "<p>
- When you are satisfied with your selections, make sure to select
- <b>Test</b> to check the settings.
- </p>" ) );
-
- // Help text (HTML-like) END
- //
- // The screen that is being referred to is 'xfine' - a tool that
- // displays a full screen image and some arrow buttons to adjust image
- // sizes and position.
- help_text = help_text + UI( _( "<p>
- Adjust the horizontal and vertical sizes and positions
- of the screen image that is displayed when you press that button.
- </p>" ) );
-
- UI(`SetWizardContents(
- // Headline for X11 configuration screen:
- // The user selects screen resolution and color depth.
- _("Desktop Settings"),
- contents,
- help_text,
- ( Args(0) && allow_back ), // have_back_button
- Args(1) // have_next_button
- )
- );
-
-
-
- if ( ! lookup(monitor,"no_x11_selected",false ) )
- {
- UI(`ChangeWidget(`id(`no_X11 ), `Value, false));
- enableX11Input();
- }
- else
- {
- UI(`ChangeWidget(`id(`no_X11 ), `Value, true));
- disableX11Input();
- }
-
-
- // Event loop
-
- any ret = nil;
- boolean asked = false;
-
- repeat
- {
- ret = UI(`UserInput());
-
- if ( ret == `cancel )
- break;
- if ( ret == `next )
- {
- if ( ! test_mode &&
- ! lookup ( monitor, "settingsChecked", false ) &&
- ! lookup( monitor,"no_x11_selected",false ) )
- {
- UI(`DisplayMessage(_("Please test your selected video mode first.")));
- }
- else
- {
- break;
- }
- }
-
- if ( UI(`QueryWidget(`id(`no_X11 ), `Value)))
- {
- // no server settings
- disableX11Input();
- monitor = add ( monitor,"no_x11_selected", true );
- user_settings = add ( user_settings, "monitor", monitor );
- }
- else
- {
- monitor = add ( monitor,"no_x11_selected", false );
- monitor = add ( monitor,"currentWidth",getCurrentWidth());
- monitor = add ( monitor,"currentHeight",getCurrentHeight());
- monitor = add ( monitor,"currentFrquency",
- getCurrentFrequency());
- monitor = add ( monitor,"currentColorDepth",
- getCurrentColorDepth());
- monitor = add ( monitor,"3dSelected",
- UI(`QueryWidget(`id(`use_3D_accel),`Value )));
- enableX11Input();
- user_settings = add ( user_settings, "monitor", monitor );
-
- // testing settings
- if ( ret == `test_X11 )
- {
- if ( asked ||
- UI(`ContinueCancel( _(
- // Warning message dialog before starting 'xfine'
- "The selected video mode will now be tested.
- If you do not see the test picture, press the
- ESC key to return to this screen immediately."),
- // Continue button in xfine warning dialog -> xfine will be started
- _("C&ontinue"),
-
- // Cancel button in xfine warning dialog -> xfine will not be started
- _("&Cancel") ) ) )
- {
- any ret = `next; UI(`NormalCursor());
- ret = CallFunction( `inst_xf86config( true, true ) );
- UI(`NormalCursor()); // shouldn't be neccessary, but unfortunately, it is :-((
-
- if ( ret == `next )
- {
- monitor = add ( monitor, "settingsChecked", true );
- }
- else
- {
- monitor = add ( monitor, "settingsChecked", false );
- }
- asked = true;
- }
- else
- {
- monitor = add ( monitor, "settingsChecked", false );
- asked = false;
- }
- }
- else
- {
- monitor = add ( monitor, "settingsChecked", false );
- }
- }
- } until ( ret == `back);
-
- user_settings = add ( user_settings, "monitor", monitor );
-
- // delete X11 files if X11 is not selected
- if ( lookup( monitor, "no_x11_selected", false) && ret == `next )
- {
- Shell("rm /etc/XF86Config");
- Shell("rm /var/X11R6/bin/X");
- }
-
- // if monitor was selected manually allow going back to this screen
- if ( ret == `back && allow_back ) ret = `again;
-
- return ret;
- }
-