summaryrefslogtreecommitdiff
path: root/hw/xfree86/parser/Layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/parser/Layout.c')
-rw-r--r--hw/xfree86/parser/Layout.c79
1 files changed, 62 insertions, 17 deletions
diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c
index beb008b35..00c1e7d09 100644
--- a/hw/xfree86/parser/Layout.c
+++ b/hw/xfree86/parser/Layout.c
@@ -64,6 +64,10 @@
#include "Configint.h"
#include <string.h>
+
+/* Needed for auto server layout */
+extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
+
extern LexRec val;
static xf86ConfigSymTabRec LayoutTab[] =
@@ -436,15 +440,67 @@ xf86freeLayoutList (XF86ConfLayoutPtr ptr)
}
int
+xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
+{
+ int count = 0;
+ XF86ConfInputPtr input = config->conf_input_lst;
+ XF86ConfInputrefPtr inptr;
+
+ /* add all AutoServerLayout devices to the server layout */
+ while (input)
+ {
+ if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
+ {
+ XF86ConfInputrefPtr iref = layout->lay_input_lst;
+
+ /* avoid duplicates if referenced but lists AutoServerLayout too */
+ while (iref)
+ {
+ if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
+ break;
+ iref = iref->list.next;
+ }
+
+ if (!iref)
+ {
+ XF86ConfInputrefPtr iptr;
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->iref_inputdev_str = input->inp_identifier;
+ layout->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
+ count++;
+ }
+ }
+ input = input->list.next;
+ }
+
+ inptr = layout->lay_input_lst;
+ while (inptr)
+ {
+ input = xf86findInput (inptr->iref_inputdev_str,
+ config->conf_input_lst);
+ if (!input)
+ {
+ xf86validationError (UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str, layout->lay_identifier);
+ return -1;
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
+ }
+
+ return count;
+}
+
+int
xf86validateLayout (XF86ConfigPtr p)
{
XF86ConfLayoutPtr layout = p->conf_layout_lst;
XF86ConfAdjacencyPtr adj;
XF86ConfInactivePtr iptr;
- XF86ConfInputrefPtr inptr;
XF86ConfScreenPtr screen;
XF86ConfDevicePtr device;
- XF86ConfInputPtr input;
while (layout)
{
@@ -479,21 +535,10 @@ xf86validateLayout (XF86ConfigPtr p)
iptr->inactive_device = device;
iptr = iptr->list.next;
}
- inptr = layout->lay_input_lst;
- while (inptr)
- {
- input = xf86findInput (inptr->iref_inputdev_str,
- p->conf_input_lst);
- if (!input)
- {
- xf86validationError (UNDEFINED_INPUT_MSG,
- inptr->iref_inputdev_str, layout->lay_identifier);
- return (FALSE);
- }
- else
- inptr->iref_inputdev = input;
- inptr = inptr->list.next;
- }
+
+ if (xf86layoutAddInputDevices(p, layout) == -1)
+ return FALSE;
+
layout = layout->list.next;
}
return (TRUE);