[PATCH evdev 1/2] Localise XKB initialization

Peter Hutterer peter.hutterer at who-t.net
Sun Jan 6 20:38:14 PST 2013


No need to store this in the evdev struct.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c | 42 +++++++++++++++++++++---------------------
 src/evdev.h |  3 ---
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 09d51ec..9337552 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1171,32 +1171,34 @@ EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
 static int
 EvdevAddKeyClass(DeviceIntPtr device)
 {
+    int rc = Success;
+    XkbRMLVOSet rmlvo = {0};
     InputInfoPtr pInfo;
-    EvdevPtr pEvdev;
 
     pInfo = device->public.devicePrivate;
-    pEvdev = pInfo->private;
 
     /* sorry, no rules change allowed for you */
     xf86ReplaceStrOption(pInfo->options, "xkb_rules", "evdev");
-    SetXkbOption(pInfo, "xkb_rules", &pEvdev->rmlvo.rules);
-    SetXkbOption(pInfo, "xkb_model", &pEvdev->rmlvo.model);
-    if (!pEvdev->rmlvo.model)
-        SetXkbOption(pInfo, "XkbModel", &pEvdev->rmlvo.model);
-    SetXkbOption(pInfo, "xkb_layout", &pEvdev->rmlvo.layout);
-    if (!pEvdev->rmlvo.layout)
-        SetXkbOption(pInfo, "XkbLayout", &pEvdev->rmlvo.layout);
-    SetXkbOption(pInfo, "xkb_variant", &pEvdev->rmlvo.variant);
-    if (!pEvdev->rmlvo.variant)
-        SetXkbOption(pInfo, "XkbVariant", &pEvdev->rmlvo.variant);
-    SetXkbOption(pInfo, "xkb_options", &pEvdev->rmlvo.options);
-    if (!pEvdev->rmlvo.options)
-        SetXkbOption(pInfo, "XkbOptions", &pEvdev->rmlvo.options);
-
-    if (!InitKeyboardDeviceStruct(device, &pEvdev->rmlvo, NULL, EvdevKbdCtrl))
-        return !Success;
+    SetXkbOption(pInfo, "xkb_rules", &rmlvo.rules);
+    SetXkbOption(pInfo, "xkb_model", &rmlvo.model);
+    if (!rmlvo.model)
+        SetXkbOption(pInfo, "XkbModel", &rmlvo.model);
+    SetXkbOption(pInfo, "xkb_layout", &rmlvo.layout);
+    if (!rmlvo.layout)
+        SetXkbOption(pInfo, "XkbLayout", &rmlvo.layout);
+    SetXkbOption(pInfo, "xkb_variant", &rmlvo.variant);
+    if (!rmlvo.variant)
+        SetXkbOption(pInfo, "XkbVariant", &rmlvo.variant);
+    SetXkbOption(pInfo, "xkb_options", &rmlvo.options);
+    if (!rmlvo.options)
+        SetXkbOption(pInfo, "XkbOptions", &rmlvo.options);
+
+    if (!InitKeyboardDeviceStruct(device, &rmlvo, NULL, EvdevKbdCtrl))
+        rc = !Success;
+
+    XkbFreeRMLVOSet(&rmlvo, FALSE);
 
-    return Success;
+    return rc;
 }
 
 #ifdef MULTITOUCH
@@ -2470,8 +2472,6 @@ EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     EvdevPtr pEvdev = pInfo ? pInfo->private : NULL;
     if (pEvdev)
     {
-        /* Release strings allocated in EvdevAddKeyClass. */
-        XkbFreeRMLVOSet(&pEvdev->rmlvo, FALSE);
         /* Release string allocated in EvdevOpenDevice. */
         free(pEvdev->device);
         pEvdev->device = NULL;
diff --git a/src/evdev.h b/src/evdev.h
index 2901886..51b7fa0 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -181,9 +181,6 @@ typedef struct {
     int delta[REL_CNT];
     unsigned int abs_queued, rel_queued, prox_queued;
 
-    /* XKB stuff has to be per-device rather than per-driver */
-    XkbRMLVOSet rmlvo;
-
     /* Middle mouse button emulation */
     struct {
         BOOL                enabled;
-- 
1.8.1



More information about the xorg-devel mailing list