xfree86: add new key MatchSeat to xorg.conf sections "Device", "Screen", and "ServerLayout"

This patch introduces a new key MatchSeat in xorg.conf (also applies to
any .conf file in xorg.conf.d). It will allow targeting a given
"Device", "Screen", and/or "ServerLayout" section to a particular
seat only (specified by option "-seat" in X server command line),
so that other seats won't be affected.

Without this patch, one needs to write a separate xorg.conf.custom
file and pass it to X server via "-config" option, if one wants that
these settings only apply for the right seat. However, in some cases,
this solution is undesirable or even impossible (e.g. when using GDM,
which doesn't allow X server command line customization).

Example file (/etc/X11/xorg.conf.d/seat1.conf), which would be ignored
by X server unless it was started with "-seat seat1" option:

Section "Device"
    Identifier "card0"
    Driver "nvidia"
    Option "NoLogo" "True"
    MatchSeat "seat1"
EndSection

Signed-off-by: Oleg Samarin <osamarin68@gmail.com>
Signed-off-by: Laércio de Sousa <lbsousajr@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Oleg Samarin 2014-04-03 11:19:14 -03:00 committed by Peter Hutterer
parent 29b1484bb9
commit 7070ebeeba
6 changed files with 47 additions and 9 deletions

View File

@ -232,6 +232,17 @@ xf86ValidateFontPath(char *path)
return tmp_path;
}
#define FIND_SUITABLE(pointertype, listhead, ptr) \
{ \
pointertype l, p; \
\
for (l = listhead, p = NULL; !p && l; l = (pointertype) l->list.next) { \
if (! l->match_seat || SeatId && xf86nameCompare(l->match_seat, SeatId) == 0) \
p = l; \
} \
ptr = p; \
}
/*
* use the datastructure that the parser provides and pick out the parts
* that we need at this point
@ -1580,8 +1591,11 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
* config file, or - if it is NULL - configScreen autogenerates one for
* us */
if (!count) {
XF86ConfScreenPtr screen;
FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
if (!configScreen(slp[0].screen, screen,
0, X_CONFIG)) {
free(slp[0].screen);
free(slp);
@ -1821,7 +1835,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
* set it to NULL so that the section can be autoconfigured later */
screenp->device = xnfcalloc(1, sizeof(GDevRec));
if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
conf_screen->scrn_device = xf86configptr->conf_device_lst;
FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device);
xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
"\tUsing the first device section listed.\n", screenp->id);
}
@ -2429,14 +2443,19 @@ xf86HandleConfigFile(Bool autoconfig)
*/
/* First check if a layout section is present, and if it is valid. */
XF86ConfLayoutPtr layout;
FIND_SUITABLE(XF86ConfLayoutPtr, xf86configptr->conf_layout_lst, layout);
if (layout == NULL || xf86ScreenName != NULL) {
XF86ConfScreenPtr screen;
if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
if (xf86ScreenName == NULL) {
xf86Msg(X_DEFAULT,
"No Layout section. Using the first Screen section.\n");
}
FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
if (!configImpliedLayout(&xf86ConfigLayout,
xf86configptr->conf_screen_lst,
screen,
xf86configptr)) {
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return CONFIG_PARSE_ERROR;
@ -2451,16 +2470,13 @@ xf86HandleConfigFile(Bool autoconfig)
if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
dfltlayout =
xf86SetStrOption(optlist, "defaultserverlayout", NULL);
if (!configLayout
(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
dfltlayout)) {
if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return CONFIG_PARSE_ERROR;
}
}
else {
if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
NULL)) {
if (!configLayout(&xf86ConfigLayout, layout, NULL)) {
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return CONFIG_PARSE_ERROR;
}

View File

@ -71,6 +71,7 @@ xf86ConfigSymTabRec DeviceTab[] = {
{RAMDAC, "ramdac"},
{DACSPEED, "dacspeed"},
{CLOCKS, "clocks"},
{MATCHSEAT, "matchseat"},
{OPTION, "option"},
{VIDEORAM, "videoram"},
{BIOSBASE, "biosbase"},
@ -216,6 +217,11 @@ xf86parseDeviceSection(void)
Error(NUMBER_MSG, "TextClockFreq");
ptr->dev_textclockfreq = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
break;
case MATCHSEAT:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "MatchSeat");
ptr->match_seat = xf86_lex_val.str;
break;
case OPTION:
ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
break;

View File

@ -70,6 +70,7 @@ static xf86ConfigSymTabRec LayoutTab[] = {
{ENDSECTION, "endsection"},
{SCREEN, "screen"},
{IDENTIFIER, "identifier"},
{MATCHSEAT, "matchseat"},
{INACTIVE, "inactive"},
{INPUTDEVICE, "inputdevice"},
{OPTION, "option"},
@ -109,6 +110,11 @@ xf86parseLayoutSection(void)
ptr->lay_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case MATCHSEAT:
if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
Error(QUOTE_MSG, "MatchSeat");
ptr->match_seat = xf86_lex_val.str;
break;
case INACTIVE:
{
XF86ConfInactivePtr iptr;

View File

@ -198,6 +198,7 @@ xf86parseDisplaySubSection(void)
static xf86ConfigSymTabRec ScreenTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{MATCHSEAT, "matchseat"},
{OBSDRIVER, "driver"},
{MDEVICE, "device"},
{MONITOR, "monitor"},
@ -236,6 +237,11 @@ xf86parseScreenSection(void)
Error(ONLY_ONE_MSG, "Identifier or Driver");
has_ident = TRUE;
break;
case MATCHSEAT:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "MatchSeat");
ptr->match_seat = xf86_lex_val.str;
break;
case OBSDRIVER:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "Driver");

View File

@ -224,6 +224,7 @@ typedef struct {
int dev_screen;
XF86OptionPtr dev_option_lst;
char *dev_comment;
char *match_seat;
} XF86ConfDeviceRec, *XF86ConfDevicePtr;
typedef struct {
@ -275,6 +276,7 @@ typedef struct {
XF86OptionPtr scrn_option_lst;
char *scrn_comment;
int scrn_virtualX, scrn_virtualY;
char *match_seat;
} XF86ConfScreenRec, *XF86ConfScreenPtr;
typedef struct {
@ -366,6 +368,7 @@ typedef struct {
XF86ConfInactivePtr lay_inactive_lst;
XF86ConfInputrefPtr lay_input_lst;
XF86OptionPtr lay_option_lst;
char *match_seat;
char *lay_comment;
} XF86ConfLayoutRec, *XF86ConfLayoutPtr;

View File

@ -87,6 +87,7 @@ typedef enum {
VENDOR,
DASH,
COMMA,
MATCHSEAT,
OPTION,
COMMENT,