Imported Debian patch 2:1.15.1-0ubuntu2.6
[deb_xorg-server.git] / debian / patches / xfree86_add_matchseat_key_to_xorg_conf.patch
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"
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
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.
15
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).
21
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:
24
25 Section "Device"
26 Identifier "card0"
27 Driver "nvidia"
28 Option "NoLogo" "True"
29 MatchSeat "seat1"
30 EndSection
31
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>
36 ---
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(-)
44
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
49 @@ -232,6 +232,18 @@
50 return tmp_path;
51 }
52
53 +#define FIND_SUITABLE(pointertype, listhead, ptr) \
54 + do { \
55 + pointertype _l, _p; \
56 + \
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)) \
59 + _p = _l; \
60 + } \
61 + \
62 + (ptr) = _p; \
63 + } while(0)
64 +
65 /*
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
70 * us */
71 if (!count) {
72 + XF86ConfScreenPtr screen;
73 +
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,
78 0, X_CONFIG)) {
79 free(slp[0].screen);
80 free(slp);
81 @@ -1841,7 +1856,7 @@
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);
89 }
90 @@ -2374,6 +2389,7 @@
91 char *scanptr;
92 Bool singlecard = 0;
93 Bool implicit_layout = FALSE;
94 + XF86ConfLayoutPtr layout;
95
96 if (!autoconfig) {
97 char *filename, *dirname, *sysdirname;
98 @@ -2449,14 +2465,17 @@
99 */
100
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;
105
106 - if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
107 if (xf86ScreenName == NULL) {
108 xf86Msg(X_DEFAULT,
109 "No Layout section. Using the first Screen section.\n");
110 }
111 + FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
112 if (!configImpliedLayout(&xf86ConfigLayout,
113 - xf86configptr->conf_screen_lst,
114 + screen,
115 xf86configptr)) {
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"))
120 dfltlayout =
121 xf86SetStrOption(optlist, "defaultserverlayout", NULL);
122 - if (!configLayout
123 - (&xf86ConfigLayout, xf86configptr->conf_layout_lst,
124 - dfltlayout)) {
125 + if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
126 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
127 return CONFIG_PARSE_ERROR;
128 }
129 }
130 else {
131 - if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
132 - NULL)) {
133 + if (!configLayout(&xf86ConfigLayout, layout, NULL)) {
134 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
135 return CONFIG_PARSE_ERROR;
136 }
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
141 @@ -72,6 +72,7 @@
142 {RAMDAC, "ramdac"},
143 {DACSPEED, "dacspeed"},
144 {CLOCKS, "clocks"},
145 + {MATCHSEAT, "matchseat"},
146 {OPTION, "option"},
147 {VIDEORAM, "videoram"},
148 {BIOSBASE, "biosbase"},
149 @@ -217,6 +218,11 @@
150 Error(NUMBER_MSG, "TextClockFreq");
151 ptr->dev_textclockfreq = (int) (val.realnum * 1000.0 + 0.5);
152 break;
153 + case MATCHSEAT:
154 + if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
155 + Error(QUOTE_MSG, "MatchSeat");
156 + ptr->match_seat = val.str;
157 + break;
158 case OPTION:
159 ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
160 break;
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
165 @@ -71,6 +71,7 @@
166 {ENDSECTION, "endsection"},
167 {SCREEN, "screen"},
168 {IDENTIFIER, "identifier"},
169 + {MATCHSEAT, "matchseat"},
170 {INACTIVE, "inactive"},
171 {INPUTDEVICE, "inputdevice"},
172 {OPTION, "option"},
173 @@ -110,6 +111,11 @@
174 ptr->lay_identifier = val.str;
175 has_ident = TRUE;
176 break;
177 + case MATCHSEAT:
178 + if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
179 + Error(QUOTE_MSG, "MatchSeat");
180 + ptr->match_seat = val.str;
181 + break;
182 case INACTIVE:
183 {
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
189 @@ -199,6 +199,7 @@
190 static xf86ConfigSymTabRec ScreenTab[] = {
191 {ENDSECTION, "endsection"},
192 {IDENTIFIER, "identifier"},
193 + {MATCHSEAT, "matchseat"},
194 {OBSDRIVER, "driver"},
195 {MDEVICE, "device"},
196 {MONITOR, "monitor"},
197 @@ -237,6 +238,11 @@
198 Error(ONLY_ONE_MSG, "Identifier or Driver");
199 has_ident = TRUE;
200 break;
201 + case MATCHSEAT:
202 + if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
203 + Error(QUOTE_MSG, "MatchSeat");
204 + ptr->match_seat = val.str;
205 + break;
206 case OBSDRIVER:
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
213 @@ -224,6 +224,7 @@
214 int dev_screen;
215 XF86OptionPtr dev_option_lst;
216 char *dev_comment;
217 + char *match_seat;
218 } XF86ConfDeviceRec, *XF86ConfDevicePtr;
219
220 typedef struct {
221 @@ -275,6 +276,7 @@
222 XF86OptionPtr scrn_option_lst;
223 char *scrn_comment;
224 int scrn_virtualX, scrn_virtualY;
225 + char *match_seat;
226 } XF86ConfScreenRec, *XF86ConfScreenPtr;
227
228 typedef struct {
229 @@ -366,6 +368,7 @@
230 XF86ConfInactivePtr lay_inactive_lst;
231 XF86ConfInputrefPtr lay_input_lst;
232 XF86OptionPtr lay_option_lst;
233 + char *match_seat;
234 char *lay_comment;
235 } XF86ConfLayoutRec, *XF86ConfLayoutPtr;
236
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
241 @@ -87,6 +87,7 @@
242 VENDOR,
243 DASH,
244 COMMA,
245 + MATCHSEAT,
246 OPTION,
247 COMMENT,
248