diff options
Diffstat (limited to 'src/XF86Config-parser/Screen.c')
-rw-r--r-- | src/XF86Config-parser/Screen.c | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/src/XF86Config-parser/Screen.c b/src/XF86Config-parser/Screen.c index f58d76b..2adcb79 100644 --- a/src/XF86Config-parser/Screen.c +++ b/src/XF86Config-parser/Screen.c @@ -79,6 +79,8 @@ static XConfigSymTabRec DisplayTab[] = #define CLEANUP xconfigFreeDisplayList +static int addImpliedScreen(XConfigPtr config); + XConfigDisplayPtr xconfigParseDisplaySubSection (void) { @@ -490,12 +492,12 @@ xconfigValidateScreen (XConfigPtr p) XConfigDevicePtr device; XConfigAdaptorLinkPtr adaptor; - if (!screen) - { - xconfigErrorMsg(ValidationErrorMsg, "At least one Screen section " - "is required."); - return (FALSE); - } + /* + * if we do not have a screen, just return TRUE; we'll add a + * screen later during the Sanitize step + */ + + if (!screen) return TRUE; while (screen) { @@ -559,6 +561,10 @@ int xconfigSanitizeScreen(XConfigPtr p) { XConfigScreenPtr screen = p->screens; XConfigMonitorPtr monitor; + + if (!addImpliedScreen(p)) { + return FALSE; + } while (screen) { @@ -600,8 +606,9 @@ int xconfigSanitizeScreen(XConfigPtr p) screen->monitor_name = xconfigStrdup(monitor->identifier); - if (!xconfigValidateMonitor(p, screen)) - return (FALSE); + if (!xconfigValidateMonitor(p, screen)) { + return FALSE; + } } } @@ -676,4 +683,43 @@ xconfigRemoveMode(XConfigModePtr head, const char *name) } +static int addImpliedScreen(XConfigPtr config) +{ + XConfigScreenPtr screen; + XConfigDevicePtr device; + XConfigMonitorPtr monitor; + if (config->screens) return TRUE; + + xconfigErrorMsg(WarnMsg, "No Screen specified, constructing implicit " + "screen section.\n"); + + /* allocate the new screen section */ + + screen = calloc(1, sizeof(XConfigScreenRec)); + if (!screen) return FALSE; + + screen->identifier = xconfigStrdup("Default Screen"); + + /* + * Use the first device section if there is one. + */ + if (config->devices) { + device = config->devices; + screen->device_name = xconfigStrdup(device->identifier); + screen->device = device; + } + + /* + * Use the first monitor section if there is one. + */ + if (config->monitors) { + monitor = config->monitors; + screen->monitor_name = xconfigStrdup(monitor->identifier); + screen->monitor = monitor; + } + + config->screens = screen; + + return TRUE; +} |