[PATCH] xfree86: Reorder InputClass option priorities
Dan Nicholson
dbn.lists at gmail.com
Sat Feb 13 10:40:40 PST 2010
Currently the config and InputClasses are merged together so that the
options from the config backend have the highest priority. This is bad
since it means options such as a default XKB layout set by the backend
cannot be changed by the user.
This patch changes order of precedence to be:
1. xorg.conf
2. xorg.conf.d (later files have higher priority)
3. config backend
In order to allow this ordering, the config parsing has been changed to
read the xorg.conf.d files before xorg.conf. This has the consequence
that the core device picking which looks for the first InputDevice may
not find it in xorg.conf.
Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
---
hw/xfree86/common/xf86Config.c | 2 +-
hw/xfree86/common/xf86Xinput.c | 35 ++++++++++++++++++---------------
hw/xfree86/doc/man/xorg.conf.man.pre | 4 +-
hw/xwin/winconfig.c | 2 +-
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 1abc182..132e8bc 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2460,8 +2460,8 @@ xf86HandleConfigFile(Bool autoconfig)
dirfrom = X_CMDLINE;
xf86initConfigFiles();
- filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
+ filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
if (filename) {
xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
xf86ConfigFile = xnfstrdup(filename);
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index c2d9f49..e9f7f2f 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -586,37 +586,40 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
/*
* Merge in any InputClass configurations. Options in each InputClass
- * section have less priority than the original device configuration as
+ * section have more priority than the original device configuration as
* well as any previous InputClass sections.
*/
static int
MergeInputClasses(IDevPtr idev, InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
- XF86OptionPtr classopts;
+ XF86OptionPtr classopts, mergedopts = NULL;
+ char *classdriver = NULL;
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
if (!InputClassMatches(cl, attrs))
continue;
+ /* Collect class options and merge over previous classes */
xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
idev->identifier, cl->identifier);
- if (cl->driver && !idev->driver) {
- idev->driver = xstrdup(cl->driver);
- if (!idev->driver) {
- xf86Msg(X_ERROR, "Could not allocate memory while merging "
- "InputClass configuration");
- return BadAlloc;
- }
- }
-
+ if (cl->driver)
+ classdriver = cl->driver;
classopts = xf86optionListDup(cl->option_lst);
- if (idev->commonOptions)
- idev->commonOptions = xf86optionListMerge(classopts,
- idev->commonOptions);
- else
- idev->commonOptions = classopts;
+ mergedopts = xf86optionListMerge(mergedopts, classopts);
+ }
+
+ /* Apply options to device with InputClass settings preferred. */
+ if (classdriver) {
+ xfree(idev->driver);
+ idev->driver = xstrdup(classdriver);
+ if (!idev->driver) {
+ xf86Msg(X_ERROR, "Failed to allocate memory while merging "
+ "InputClass configuration");
+ return BadAlloc;
+ }
}
+ idev->commonOptions = xf86optionListMerge(idev->commonOptions, mergedopts);
return Success;
}
diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 270c057..021b766 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -988,8 +988,8 @@ These sections are optional and are used to provide configuration for a
class of input devices as they are automatically added. An input device can
match more than one
.B InputClass
-section. Each class can only supplement settings from a previous class, so
-it is best to arrange the sections with the most generic matches last.
+section. Each class can override settings from a previous class, so it is
+best to arrange the sections with the most generic matches first.
.PP
.B InputClass
sections have the following format:
diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c
index f1e805c..259b3d2 100644
--- a/hw/xwin/winconfig.c
+++ b/hw/xwin/winconfig.c
@@ -136,8 +136,8 @@ winReadConfigfile ()
/* Parse config file into data structure */
xf86initConfigFiles();
- filename = xf86openConfigFile (CONFIGPATH, xf86ConfigFile, PROJECTROOT);
dirname = xf86openConfigDirFiles (CONFIGDIRPATH, xf86ConfigDir, PROJECTROOT);
+ filename = xf86openConfigFile (CONFIGPATH, xf86ConfigFile, PROJECTROOT);
/* Hack for backward compatibility */
if (!filename && from == X_DEFAULT)
--
1.6.6
More information about the xorg-devel
mailing list