ODROID-U3 xorg-server debian package fork :
[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 --- a/hw/xfree86/common/xf86Config.c
46 +++ b/hw/xfree86/common/xf86Config.c
47 @@ -233,6 +233,18 @@ xf86ValidateFontPath(char *path)
48 return tmp_path;
49 }
50
51 +#define FIND_SUITABLE(pointertype, listhead, ptr) \
52 + do { \
53 + pointertype _l, _p; \
54 + \
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)) \
57 + _p = _l; \
58 + } \
59 + \
60 + (ptr) = _p; \
61 + } while(0)
62 +
63 /*
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
68 * us */
69 if (!count) {
70 + XF86ConfScreenPtr screen;
71 +
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,
76 0, X_CONFIG)) {
77 free(slp[0].screen);
78 free(slp);
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);
87 }
88 @@ -2378,6 +2393,7 @@ xf86HandleConfigFile(Bool autoconfig)
89 char *scanptr;
90 Bool singlecard = 0;
91 Bool implicit_layout = FALSE;
92 + XF86ConfLayoutPtr layout;
93
94 if (!autoconfig) {
95 char *filename, *dirname, *sysdirname;
96 @@ -2453,14 +2469,17 @@ xf86HandleConfigFile(Bool autoconfig)
97 */
98
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;
103
104 - if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
105 if (xf86ScreenName == NULL) {
106 xf86Msg(X_DEFAULT,
107 "No Layout section. Using the first Screen section.\n");
108 }
109 + FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
110 if (!configImpliedLayout(&xf86ConfigLayout,
111 - xf86configptr->conf_screen_lst,
112 + screen,
113 xf86configptr)) {
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"))
118 dfltlayout =
119 xf86SetStrOption(optlist, "defaultserverlayout", NULL);
120 - if (!configLayout
121 - (&xf86ConfigLayout, xf86configptr->conf_layout_lst,
122 - dfltlayout)) {
123 + if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
124 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
125 return CONFIG_PARSE_ERROR;
126 }
127 }
128 else {
129 - if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
130 - NULL)) {
131 + if (!configLayout(&xf86ConfigLayout, layout, NULL)) {
132 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
133 return CONFIG_PARSE_ERROR;
134 }
135 --- a/hw/xfree86/parser/Device.c
136 +++ b/hw/xfree86/parser/Device.c
137 @@ -72,6 +72,7 @@ xf86ConfigSymTabRec DeviceTab[] = {
138 {RAMDAC, "ramdac"},
139 {DACSPEED, "dacspeed"},
140 {CLOCKS, "clocks"},
141 + {MATCHSEAT, "matchseat"},
142 {OPTION, "option"},
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);
148 break;
149 + case MATCHSEAT:
150 + if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
151 + Error(QUOTE_MSG, "MatchSeat");
152 + ptr->match_seat = val.str;
153 + break;
154 case OPTION:
155 ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
156 break;
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"},
161 {SCREEN, "screen"},
162 {IDENTIFIER, "identifier"},
163 + {MATCHSEAT, "matchseat"},
164 {INACTIVE, "inactive"},
165 {INPUTDEVICE, "inputdevice"},
166 {OPTION, "option"},
167 @@ -110,6 +111,11 @@ xf86parseLayoutSection(void)
168 ptr->lay_identifier = val.str;
169 has_ident = TRUE;
170 break;
171 + case MATCHSEAT:
172 + if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
173 + Error(QUOTE_MSG, "MatchSeat");
174 + ptr->match_seat = val.str;
175 + break;
176 case INACTIVE:
177 {
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"},
187 {MDEVICE, "device"},
188 {MONITOR, "monitor"},
189 @@ -237,6 +238,11 @@ xf86parseScreenSection(void)
190 Error(ONLY_ONE_MSG, "Identifier or Driver");
191 has_ident = TRUE;
192 break;
193 + case MATCHSEAT:
194 + if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
195 + Error(QUOTE_MSG, "MatchSeat");
196 + ptr->match_seat = val.str;
197 + break;
198 case OBSDRIVER:
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 {
204 int dev_screen;
205 XF86OptionPtr dev_option_lst;
206 char *dev_comment;
207 + char *match_seat;
208 } XF86ConfDeviceRec, *XF86ConfDevicePtr;
209
210 typedef struct {
211 @@ -275,6 +276,7 @@ typedef struct {
212 XF86OptionPtr scrn_option_lst;
213 char *scrn_comment;
214 int scrn_virtualX, scrn_virtualY;
215 + char *match_seat;
216 } XF86ConfScreenRec, *XF86ConfScreenPtr;
217
218 typedef struct {
219 @@ -366,6 +368,7 @@ typedef struct {
220 XF86ConfInactivePtr lay_inactive_lst;
221 XF86ConfInputrefPtr lay_input_lst;
222 XF86OptionPtr lay_option_lst;
223 + char *match_seat;
224 char *lay_comment;
225 } XF86ConfLayoutRec, *XF86ConfLayoutPtr;
226
227 --- a/hw/xfree86/parser/xf86tokens.h
228 +++ b/hw/xfree86/parser/xf86tokens.h
229 @@ -87,6 +87,7 @@ typedef enum {
230 VENDOR,
231 DASH,
232 COMMA,
233 + MATCHSEAT,
234 OPTION,
235 COMMENT,
236