Skip to content

Commit 9db422c

Browse files
ONykyfmetux
authored andcommitted
xfree86: add MatchLayout entry to OutputClass
It is patch 2/2 of a series that provides a convenient way to specify module search paths on a per-driver basis. This entry proved to be useful in InputClass, so added it to OutputClass as well. This allows to configure graphic drivers separately depending on server layout names. Signed-off-by: Oleh Nykyforchyn <[email protected]>
1 parent 9f25f5d commit 9db422c

File tree

4 files changed

+63
-11
lines changed

4 files changed

+63
-11
lines changed

hw/xfree86/common/xf86platformBus.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,23 @@ OutputClassMatches(const XF86ConfOutputClassPtr oclass,
179179
struct xf86_platform_device *dev)
180180
{
181181
char *driver = dev->attribs->driver;
182+
const char *layout;
182183

183184
if (!MatchAttrToken(driver, &oclass->match_driver))
184185
return FALSE;
185186

187+
/* MatchLayout string
188+
*
189+
* If no Layout section is found, xf86ServerLayout.id becomes "(implicit)"
190+
* It is convenient that "" in patterns means "no explicit layout"
191+
*/
192+
if (strcmp(xf86ConfigLayout.id,"(implicit)"))
193+
layout = xf86ConfigLayout.id;
194+
else
195+
layout = "";
196+
if (!MatchAttrToken(layout, &oclass->match_layout))
197+
return FALSE;
198+
186199
return TRUE;
187200
}
188201

hw/xfree86/man/xorg.conf.man

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,20 +1290,38 @@ module from the first
12901290
.B Driver
12911291
entry will be enabled when using the loadable server.
12921292
.PP
1293-
When an output device is automatically added, its characteristics are
1293+
When an output device is automatically added, its characteristics and the active layout are
12941294
checked against all
12951295
.B OutputClass
12961296
sections.
12971297
Each section can contain optional entries to narrow the match of the class.
1298+
.RE
1299+
.TP 7
1300+
.BI "MatchDriver \*q" matchdriver \*q
1301+
Check the case-sensitive string
1302+
.RI \*q matchdriver \*q
1303+
against the kernel driver of the device.
1304+
.RE
1305+
.TP 7
1306+
.BI "MatchLayout \*q" matchlayout \*q
1307+
Check the case-sensitive string
1308+
.RI \*q matchlayout \*q
1309+
against the currently active
1310+
.B ServerLayout
1311+
section or against
1312+
.RI \*q\*q
1313+
, if no named
1314+
.B ScreenLayout
1315+
sections are present.
1316+
.PP
12981317
If none of the optional entries appear, the
12991318
.B OutputClass
13001319
section is generic and will match any output device.
13011320
If more than one of these entries appear, they all must match for the
13021321
configuration to apply.
13031322
.PP
1304-
The following list of tokens can be matched against attributes of the device.
1305-
An entry can be constructed to match attributes from different devices by
1306-
separating arguments with a '|' character.
1323+
An entry can be constructed to match attributes from different devices or
1324+
different screen layouts by separating arguments with a '|' character.
13071325
.PP
13081326
For example:
13091327
.PP
@@ -1313,15 +1331,12 @@ For example:
13131331
.B " Identifier \*qMy Class\*q"
13141332
.B " # kernel driver must be either foo or bar"
13151333
.B " MatchDriver \*qfoo\^|\^bar\*q"
1334+
.B " # active layout must be either Seat1 or implicit"
1335+
.B " MatchLayout \*qSeat1|\*q"
13161336
.I " \&.\|.\|.\&"
13171337
.B EndSection
13181338
.fi
13191339
.RE
1320-
.TP 7
1321-
.BI "MatchDriver \*q" matchdriver \*q
1322-
Check the case-sensitive string
1323-
.RI \*q matchdriver \*q
1324-
against the kernel driver of the device.
13251340
.PP
13261341
When an output device has been matched to the
13271342
.B OutputClass

hw/xfree86/parser/OutputClass.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const xf86ConfigSymTabRec OutputClassTab[] = {
4242
{MODULEPATH, "modulepath"},
4343
{OPTION, "option"},
4444
{MATCH_DRIVER, "matchdriver"},
45+
{MATCH_LAYOUT, "matchlayout"},
4546
{-1, ""},
4647
};
4748

@@ -58,6 +59,8 @@ xf86freeOutputClassList(XF86ConfOutputClassPtr ptr)
5859
TestFree(ptr->modulepath);
5960

6061
xf86freeMatchGroupList(&ptr->match_driver);
62+
xf86freeMatchGroupList(&ptr->match_layout);
63+
6164
xf86optionListFree(ptr->option_lst);
6265

6366
prev = ptr;
@@ -77,8 +80,8 @@ xf86parseOutputClassSection(void)
7780

7881
parsePrologue(XF86ConfOutputClassPtr, XF86ConfOutputClassRec)
7982

80-
/* Initialize MatchGroup lists */
81-
xorg_list_init(&ptr->match_driver);
83+
/* MatchGroup and MatchLayout lists are zeroed by parsePrologue(),
84+
* which is equivalent to xorg_list_init() */
8285

8386
while ((token = xf86getToken(OutputClassTab)) != ENDSECTION) {
8487
switch (token) {
@@ -140,6 +143,16 @@ xf86parseOutputClassSection(void)
140143
free(xf86_lex_val.str);
141144
}
142145
break;
146+
case MATCH_LAYOUT:
147+
if (xf86getSubToken(&(ptr->comment)) != XF86_TOKEN_STRING)
148+
Error(QUOTE_MSG, "MatchLayout");
149+
else {
150+
group = xf86createMatchGroup(xf86_lex_val.str, MATCH_EXACT, FALSE);
151+
if (group)
152+
xorg_list_add(&group->entry, &ptr->match_layout);
153+
free(xf86_lex_val.str);
154+
}
155+
break;
143156
case EOF_TOKEN:
144157
Error(UNEXPECTED_EOF_MSG);
145158
break;
@@ -189,6 +202,16 @@ xf86printOutputClassSection(FILE * cf, XF86ConfOutputClassPtr ptr)
189202
fprintf(cf, "\"\n");
190203
}
191204

205+
xorg_list_for_each_entry(group, &ptr->match_layout, entry) {
206+
fprintf(cf, "\tMatchLayout \"");
207+
not_first = FALSE;
208+
xorg_list_for_each_entry(pattern, &group->patterns, entry) {
209+
xf86printMatchPattern(cf, pattern, not_first);
210+
not_first = TRUE;
211+
}
212+
fprintf(cf, "\"\n");
213+
}
214+
192215
fprintf(cf, "EndSection\n\n");
193216
ptr = ptr->list.next;
194217
}

hw/xfree86/parser/xf86Parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ typedef struct {
362362
char *modules;
363363
char *modulepath;
364364
struct xorg_list match_driver;
365+
struct xorg_list match_layout;
365366
XF86OptionPtr option_lst;
366367
char *comment;
367368
} XF86ConfOutputClassRec, *XF86ConfOutputClassPtr;

0 commit comments

Comments
 (0)