1 From 7070ebeebaca1b51f8a2801989120784a1c374ae Mon Sep 17 00:00:00 2001
2 From: Oleg Samarin <osamarin68@gmail.com>
3 Date: Thu, 3 Apr 2014 11:19:14 -0300
4 Subject: [PATCH] xfree86: add new key MatchSeat to xorg.conf sections
5 "Device", "Screen", and "ServerLayout"
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 This patch introduces a new key MatchSeat in xorg.conf (also applies to
11 any .conf file in xorg.conf.d). It will allow targeting a given
12 "Device", "Screen", and/or "ServerLayout" section to a particular
13 seat only (specified by option "-seat" in X server command line),
14 so that other seats won't be affected.
16 Without this patch, one needs to write a separate xorg.conf.custom
17 file and pass it to X server via "-config" option, if one wants that
18 these settings only apply for the right seat. However, in some cases,
19 this solution is undesirable or even impossible (e.g. when using GDM,
20 which doesn't allow X server command line customization).
22 Example file (/etc/X11/xorg.conf.d/seat1.conf), which would be ignored
23 by X server unless it was started with "-seat seat1" option:
28 Option "NoLogo" "True"
32 Signed-off-by: Oleg Samarin <osamarin68@gmail.com>
33 Signed-off-by: LaƩrcio de Sousa <lbsousajr@gmail.com>
34 Reviewed-by: Dave Airlie <airlied@redhat.com>
35 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
37 hw/xfree86/common/xf86Config.c | 34 +++++++++++++++++++++++++---------
38 hw/xfree86/parser/Device.c | 6 ++++++
39 hw/xfree86/parser/Layout.c | 6 ++++++
40 hw/xfree86/parser/Screen.c | 6 ++++++
41 hw/xfree86/parser/xf86Parser.h | 3 +++
42 hw/xfree86/parser/xf86tokens.h | 1 +
43 6 files changed, 47 insertions(+), 9 deletions(-)
45 --- a/hw/xfree86/common/xf86Config.c
46 +++ b/hw/xfree86/common/xf86Config.c
47 @@ -233,6 +233,18 @@ xf86ValidateFontPath(char *path)
51 +#define FIND_SUITABLE(pointertype, listhead, ptr) \
53 + pointertype _l, _p; \
55 + for (_l = (listhead), _p = NULL; !_p && _l; _l = (pointertype)_l->list.next) { \
56 + if (!_l->match_seat || (SeatId && xf86nameCompare(_l->match_seat, SeatId) == 0)) \
64 * use the datastructure that the parser provides and pick out the parts
65 * that we need at this point
66 @@ -1604,8 +1616,11 @@ configLayout(serverLayoutPtr servlayoutp
67 * config file, or - if it is NULL - configScreen autogenerates one for
70 + XF86ConfScreenPtr screen;
72 + FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
73 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
74 - if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
75 + if (!configScreen(slp[0].screen, screen,
79 @@ -1845,7 +1860,7 @@ configScreen(confScreenPtr screenp, XF86
80 * set it to NULL so that the section can be autoconfigured later */
81 screenp->device = xnfcalloc(1, sizeof(GDevRec));
82 if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
83 - conf_screen->scrn_device = xf86configptr->conf_device_lst;
84 + FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device);
85 xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
86 "\tUsing the first device section listed.\n", screenp->id);
88 @@ -2378,6 +2393,7 @@ xf86HandleConfigFile(Bool autoconfig)
91 Bool implicit_layout = FALSE;
92 + XF86ConfLayoutPtr layout;
95 char *filename, *dirname, *sysdirname;
96 @@ -2453,14 +2469,17 @@ xf86HandleConfigFile(Bool autoconfig)
99 /* First check if a layout section is present, and if it is valid. */
100 + FIND_SUITABLE(XF86ConfLayoutPtr, xf86configptr->conf_layout_lst, layout);
101 + if (layout == NULL || xf86ScreenName != NULL) {
102 + XF86ConfScreenPtr screen;
104 - if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
105 if (xf86ScreenName == NULL) {
107 "No Layout section. Using the first Screen section.\n");
109 + FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
110 if (!configImpliedLayout(&xf86ConfigLayout,
111 - xf86configptr->conf_screen_lst,
114 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
115 return CONFIG_PARSE_ERROR;
116 @@ -2475,16 +2494,13 @@ xf86HandleConfigFile(Bool autoconfig)
117 if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
119 xf86SetStrOption(optlist, "defaultserverlayout", NULL);
121 - (&xf86ConfigLayout, xf86configptr->conf_layout_lst,
123 + if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
124 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
125 return CONFIG_PARSE_ERROR;
129 - if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
131 + if (!configLayout(&xf86ConfigLayout, layout, NULL)) {
132 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
133 return CONFIG_PARSE_ERROR;
135 --- a/hw/xfree86/parser/Device.c
136 +++ b/hw/xfree86/parser/Device.c
137 @@ -72,6 +72,7 @@ xf86ConfigSymTabRec DeviceTab[] = {
139 {DACSPEED, "dacspeed"},
141 + {MATCHSEAT, "matchseat"},
143 {VIDEORAM, "videoram"},
144 {BIOSBASE, "biosbase"},
145 @@ -217,6 +218,11 @@ xf86parseDeviceSection(void)
146 Error(NUMBER_MSG, "TextClockFreq");
147 ptr->dev_textclockfreq = (int) (val.realnum * 1000.0 + 0.5);
150 + if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
151 + Error(QUOTE_MSG, "MatchSeat");
152 + ptr->match_seat = val.str;
155 ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
157 --- a/hw/xfree86/parser/Layout.c
158 +++ b/hw/xfree86/parser/Layout.c
159 @@ -71,6 +71,7 @@ static xf86ConfigSymTabRec LayoutTab[] =
160 {ENDSECTION, "endsection"},
162 {IDENTIFIER, "identifier"},
163 + {MATCHSEAT, "matchseat"},
164 {INACTIVE, "inactive"},
165 {INPUTDEVICE, "inputdevice"},
167 @@ -110,6 +111,11 @@ xf86parseLayoutSection(void)
168 ptr->lay_identifier = val.str;
172 + if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
173 + Error(QUOTE_MSG, "MatchSeat");
174 + ptr->match_seat = val.str;
178 XF86ConfInactivePtr iptr;
179 --- a/hw/xfree86/parser/Screen.c
180 +++ b/hw/xfree86/parser/Screen.c
181 @@ -199,6 +199,7 @@ xf86parseDisplaySubSection(void)
182 static xf86ConfigSymTabRec ScreenTab[] = {
183 {ENDSECTION, "endsection"},
184 {IDENTIFIER, "identifier"},
185 + {MATCHSEAT, "matchseat"},
186 {OBSDRIVER, "driver"},
188 {MONITOR, "monitor"},
189 @@ -237,6 +238,11 @@ xf86parseScreenSection(void)
190 Error(ONLY_ONE_MSG, "Identifier or Driver");
194 + if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
195 + Error(QUOTE_MSG, "MatchSeat");
196 + ptr->match_seat = val.str;
199 if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
200 Error(QUOTE_MSG, "Driver");
201 --- a/hw/xfree86/parser/xf86Parser.h
202 +++ b/hw/xfree86/parser/xf86Parser.h
203 @@ -224,6 +224,7 @@ typedef struct {
205 XF86OptionPtr dev_option_lst;
208 } XF86ConfDeviceRec, *XF86ConfDevicePtr;
211 @@ -275,6 +276,7 @@ typedef struct {
212 XF86OptionPtr scrn_option_lst;
214 int scrn_virtualX, scrn_virtualY;
216 } XF86ConfScreenRec, *XF86ConfScreenPtr;
219 @@ -366,6 +368,7 @@ typedef struct {
220 XF86ConfInactivePtr lay_inactive_lst;
221 XF86ConfInputrefPtr lay_input_lst;
222 XF86OptionPtr lay_option_lst;
225 } XF86ConfLayoutRec, *XF86ConfLayoutPtr;
227 --- a/hw/xfree86/parser/xf86tokens.h
228 +++ b/hw/xfree86/parser/xf86tokens.h
229 @@ -87,6 +87,7 @@ typedef enum {