diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-12-21 15:56:35 +1000 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2009-12-22 23:22:09 -0800 |
commit | e1165632bdfbd720889ed1adf5f7ab338032c0ee (patch) | |
tree | 3c4340a1666c87291e9295d7ffb0a6e0467a9ae8 /hw/xfree86/parser/Layout.c | |
parent | 592b20c517461d32daf44a940386ffcc11c434f8 (diff) |
xfree86: Add Option AutoServerLayout for input devices.
Any input device with this option will be automatically added to whichever
server layout is selected at startup. This removes the need to reference a
device from the ServerLayout section. The two following configuration are
identical:
CONFIG 1:
Section "ServerLayout"
InputDevice "foo"
EndSection
Section "InputDevice"
Identifier "foo"
...
EndSection
CONFIG 2:
Section "InputDevice"
Identifier "foo"
Option "AutoServerLayout" "on"
...
EndSection
The selection of the server layout affects both explicitly specified
layouts and the implicit layout.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp at keithp.com>
Diffstat (limited to 'hw/xfree86/parser/Layout.c')
-rw-r--r-- | hw/xfree86/parser/Layout.c | 79 |
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); |