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 Index: xorg-server-trusty-matchseat/hw/xfree86/common/xf86Config.c
46 ===================================================================
47 --- xorg-server-trusty-matchseat.orig/hw/xfree86/common/xf86Config.c 2014-09-11 10:50:39.823851011 -0300
48 +++ xorg-server-trusty-matchseat/hw/xfree86/common/xf86Config.c 2014-09-11 10:55:16.098992439 -0300
53 +#define FIND_SUITABLE(pointertype, listhead, ptr) \
55 + pointertype _l, _p; \
57 + for (_l = (listhead), _p = NULL; !_p && _l; _l = (pointertype)_l->list.next) { \
58 + if (!_l->match_seat || (SeatId && xf86nameCompare(_l->match_seat, SeatId) == 0)) \
66 * use the datastructure that the parser provides and pick out the parts
67 * that we need at this point
68 @@ -1600,8 +1612,11 @@
69 * config file, or - if it is NULL - configScreen autogenerates one for
72 + XF86ConfScreenPtr screen;
74 + FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
75 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
76 - if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
77 + if (!configScreen(slp[0].screen, screen,
82 * set it to NULL so that the section can be autoconfigured later */
83 screenp->device = xnfcalloc(1, sizeof(GDevRec));
84 if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
85 - conf_screen->scrn_device = xf86configptr->conf_device_lst;
86 + FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device);
87 xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
88 "\tUsing the first device section listed.\n", screenp->id);
93 Bool implicit_layout = FALSE;
94 + XF86ConfLayoutPtr layout;
97 char *filename, *dirname, *sysdirname;
98 @@ -2449,14 +2465,17 @@
101 /* First check if a layout section is present, and if it is valid. */
102 + FIND_SUITABLE(XF86ConfLayoutPtr, xf86configptr->conf_layout_lst, layout);
103 + if (layout == NULL || xf86ScreenName != NULL) {
104 + XF86ConfScreenPtr screen;
106 - if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
107 if (xf86ScreenName == NULL) {
109 "No Layout section. Using the first Screen section.\n");
111 + FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
112 if (!configImpliedLayout(&xf86ConfigLayout,
113 - xf86configptr->conf_screen_lst,
116 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
117 return CONFIG_PARSE_ERROR;
118 @@ -2471,16 +2490,13 @@
119 if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
121 xf86SetStrOption(optlist, "defaultserverlayout", NULL);
123 - (&xf86ConfigLayout, xf86configptr->conf_layout_lst,
125 + if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
126 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
127 return CONFIG_PARSE_ERROR;
131 - if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
133 + if (!configLayout(&xf86ConfigLayout, layout, NULL)) {
134 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
135 return CONFIG_PARSE_ERROR;
137 Index: xorg-server-trusty-matchseat/hw/xfree86/parser/Device.c
138 ===================================================================
139 --- xorg-server-trusty-matchseat.orig/hw/xfree86/parser/Device.c 2014-09-11 10:48:54.272129993 -0300
140 +++ xorg-server-trusty-matchseat/hw/xfree86/parser/Device.c 2014-09-11 10:55:16.094992284 -0300
143 {DACSPEED, "dacspeed"},
145 + {MATCHSEAT, "matchseat"},
147 {VIDEORAM, "videoram"},
148 {BIOSBASE, "biosbase"},
150 Error(NUMBER_MSG, "TextClockFreq");
151 ptr->dev_textclockfreq = (int) (val.realnum * 1000.0 + 0.5);
154 + if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
155 + Error(QUOTE_MSG, "MatchSeat");
156 + ptr->match_seat = val.str;
159 ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
161 Index: xorg-server-trusty-matchseat/hw/xfree86/parser/Layout.c
162 ===================================================================
163 --- xorg-server-trusty-matchseat.orig/hw/xfree86/parser/Layout.c 2014-09-11 10:48:54.272129993 -0300
164 +++ xorg-server-trusty-matchseat/hw/xfree86/parser/Layout.c 2014-09-11 10:55:16.094992284 -0300
166 {ENDSECTION, "endsection"},
168 {IDENTIFIER, "identifier"},
169 + {MATCHSEAT, "matchseat"},
170 {INACTIVE, "inactive"},
171 {INPUTDEVICE, "inputdevice"},
174 ptr->lay_identifier = val.str;
178 + if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
179 + Error(QUOTE_MSG, "MatchSeat");
180 + ptr->match_seat = val.str;
184 XF86ConfInactivePtr iptr;
185 Index: xorg-server-trusty-matchseat/hw/xfree86/parser/Screen.c
186 ===================================================================
187 --- xorg-server-trusty-matchseat.orig/hw/xfree86/parser/Screen.c 2014-09-11 10:48:54.272129993 -0300
188 +++ xorg-server-trusty-matchseat/hw/xfree86/parser/Screen.c 2014-09-11 10:55:16.094992284 -0300
190 static xf86ConfigSymTabRec ScreenTab[] = {
191 {ENDSECTION, "endsection"},
192 {IDENTIFIER, "identifier"},
193 + {MATCHSEAT, "matchseat"},
194 {OBSDRIVER, "driver"},
196 {MONITOR, "monitor"},
198 Error(ONLY_ONE_MSG, "Identifier or Driver");
202 + if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
203 + Error(QUOTE_MSG, "MatchSeat");
204 + ptr->match_seat = val.str;
207 if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
208 Error(QUOTE_MSG, "Driver");
209 Index: xorg-server-trusty-matchseat/hw/xfree86/parser/xf86Parser.h
210 ===================================================================
211 --- xorg-server-trusty-matchseat.orig/hw/xfree86/parser/xf86Parser.h 2014-09-11 10:48:54.272129993 -0300
212 +++ xorg-server-trusty-matchseat/hw/xfree86/parser/xf86Parser.h 2014-09-11 10:55:16.094992284 -0300
215 XF86OptionPtr dev_option_lst;
218 } XF86ConfDeviceRec, *XF86ConfDevicePtr;
222 XF86OptionPtr scrn_option_lst;
224 int scrn_virtualX, scrn_virtualY;
226 } XF86ConfScreenRec, *XF86ConfScreenPtr;
230 XF86ConfInactivePtr lay_inactive_lst;
231 XF86ConfInputrefPtr lay_input_lst;
232 XF86OptionPtr lay_option_lst;
235 } XF86ConfLayoutRec, *XF86ConfLayoutPtr;
237 Index: xorg-server-trusty-matchseat/hw/xfree86/parser/xf86tokens.h
238 ===================================================================
239 --- xorg-server-trusty-matchseat.orig/hw/xfree86/parser/xf86tokens.h 2014-09-11 10:48:54.272129993 -0300
240 +++ xorg-server-trusty-matchseat/hw/xfree86/parser/xf86tokens.h 2014-09-11 10:55:16.094992284 -0300