Commit Graph

465 Commits

Author SHA1 Message Date
Peter Hutterer
3a077f246e input: provide a single function to init DeviceEvents to 0
getevents.c already had that function, but XKB was manually initializing it,
causing bugs when the event structure was updated in one place but not the
other.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-22 15:56:52 +10:00
Daniel Stone
82f5521a6d XKB: Work around broken interps from old xkbcomp
Bugfix for broken xkbcomp: if we encounter an XFree86Private action with
Any+AnyOfOrNone(All), then we skip the interp as broken.  Versions of
xkbcomp below 1.2.2 had a bug where they would interpret a symbol that
couldn't be found in an interpret as Any.  So, an
XF86LogWindowTree+AnyOfOrNone(All) interp that triggered the PrWins
action would make every key without an action trigger PrWins if libX11
didn't yet know about the XF86LogWindowTree keysym.  None too useful.

We only do this for XFree86 actions, as the current XKB dataset relies
on Any+AnyOfOrNone(All) -> SetMods for Ctrl in particular.

See xkbcomp commits 2a473b906943ffd807ad81960c47530ee7ae9a60 and
3caab5aa37decb7b5dc1642a0452efc3e1f5100e for more details.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-07-15 15:44:19 +10:00
Cyril Brulebois
ab0df72cd3 xkb: Fix case checks for Latin 4.
That one was missing _XkbKSLower:
  XK_kra: U+0138 LATIN SMALL LETTER KRA

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2011-06-06 16:25:56 +02:00
Cyril Brulebois
9eb6e34c2d xkb: Fix case checks for Latin 2.
Those ones were getting _XkbKSLower for no reasons:
  XK_ogonek: U+02DB OGONEK
  XK_doubleacute: U+02DD DOUBLE ACUTE ACCENT

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2011-06-06 16:25:52 +02:00
Cyril Brulebois
2b88189863 xkb: Fix case checks for Latin 1.
That one was missing _XkbKSLower:
  XK_ssharp: U+00DF LATIN SMALL LETTER SHARP S

That one was getting _XkbKSLower for no reasons:
  XK_division: U+00F7 DIVISION SIGN

For reference, XK_multiply was already excluded from the _XkbKSUpper
check, it's no big surprise XK_division has to be excluded from the
_XkbKSLower check.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2011-06-06 16:25:33 +02:00
Cyril Brulebois
408ed1576d xkb: Fix case checks for Latin 8.
Spotted by -Wlogical-op:
|   CC     xkbfmisc.lo
| xkbfmisc.c: In function '_XkbKSCheckCase':
| xkbfmisc.c:104:3: warning: logical 'and' of mutually exclusive tests is always false [-Wlogical-op]
| xkbfmisc.c:118:3: warning: logical 'and' of mutually exclusive tests is always false [-Wlogical-op]

A quick look at the keysymdef.h file (from xproto) suggests the
implementor chose to use interval checks to determine the case, but
since lines weren't sorted by codepoints, checks were quite wrong.

Implement _XkbKSUpper/_XkbKSLower checks based on a grep for
CAPITAL/SMALL (respectively) on the Latin 8 part of the said file.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2011-06-03 18:09:48 +02:00
Peter Hutterer
8670c46bdf input: replace EventListPtr with InternalEvent array
EventListPtr is a relic from pre-1.6, when we had protocol events in the
event queue and thus events of varying size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-05-11 14:27:36 +10:00
Daniel Stone
3231962db8 XKB: Fix sense inversion for core MapNotify events
Due to an unfortunate sense inversion incident while switching from a
if (foo) { ... } to if (!foo) continue; style in f06a9d, we punished any
client who attempted to use XKB to restrict the MapNotify events they
wanted by sending them exactly the events they _didn't_ want, and
nothing else.

NewKeyboardNotifies (coming from a client setting the map with an XKB
request, when switching between master devices, etc) weren't affected,
but this would impact anyone using xmodmap-style core requests.  Could
explain a fair bit.

Clarified the comments while I was at it.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-06 13:15:28 +10:00
Daniel Stone
460a377ef2 XKB: Send XKB events for all devices to all clients
We were using XIShouldNotify(client, device) as a test for whether or
not to send XKB map/state/etc changed events, which limits it to only
sending events for the current ClientPointer/ClientKeyboard for that
client.  While this makes perfect sense for core events (e.g.
MappingNotify), XKB events carry a device ID, so are safe to send to all
clients for all devices.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-06 13:15:26 +10:00
Daniel Stone
a79d4544fe XKB: Send NewKeyboardNotify for dev before its master/slaves
When we change the keymap on a device, send the NewKeyboardNotify for
that device before we copy the keymap to and notify for its attached
master/slave devices.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-06 13:15:25 +10:00
Daniel Stone
c7634498d4 XKB: Remove duplicate keymap-copying loop
Previously we had:
    foreach (device + slaves of device) {
        XkbCopyDeviceKeymap(i, device);
        [...]
    }
    if (device was last slave of its MD) {
        XkbCopyDeviceKeymap(master, device);
    }
and now:
    foreach (device + slaves of device + MD if device was last slave) {
        XkbCopyDeviceKeymap(i, device);
        [...]
    }

As an extra bonus, when changing the keymap on a slave device, we now
ensure the LED info on the master is kept in sync.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-06 13:15:24 +10:00
Daniel Stone
b8540d18c7 XKB: Simplify a loop in ProcXkbGetKbdByName
Replace:
    for (stuff; things; etc) {
        if (misc || other) {
            [...]
        }
    }
with:
    for (stuff; things; etc) {
        if (!misc && !other)
            continue;
        [...]
    }

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-06 13:15:23 +10:00
Daniel Stone
72b6639c83 XKB: Don't send unnecessary NewKeyboardNotifies
In the XKB GetKeyboardByName handler, we had the following pseudocode:
    if (device was last slave of its MD) {
        XkbCopyDeviceKeymap(master, slave);
        XkbSendNewKeyboardNotify(slave, &notify);
    }

Even if the SendNewKeyboardNotify line nominated the correct device,
which it didn't, it's unnecessary as XkbCopyDeviceKeymap already sends a
NewKeyboardNotify on the destination device.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-05-06 13:15:22 +10:00
Nicolas Kaiser
5423da9fb2 xkb: remove duplicated include
Remove duplicated include.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2011-04-25 10:45:34 -07:00
Keith Packard
c9d89cec14 Merge remote-tracking branch 'vignatti/for-keith' 2011-04-04 11:57:39 -07:00
Tiago Vignatti
45b6667b65 xkb: fix fd leak in XkbDDXListComponent
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
2011-04-04 15:47:58 +03:00
Rami Ylimäki
9c4aae2141 xkb: Prevent leaking of XKB geometry information on copy.
Currently shapes, sections and doodads may leak on copy.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 09:55:05 +10:00
Rami Ylimäki
29d63ba175 xkb: Introduce helper function to handle similar reallocations.
This is preparation for a memory leak fix and doesn't contain any
functional changes.

Note that two variables are generally used for reallocation and
clearing of arrays: geom->sz_elems (reallocation) and geom->num_elems
(clearing). The interface of XkbGeomRealloc is deliberately kept
simple and it only accepts geom->sz_elems as argument, because that is
needed to determine whether the array needs to be resized. When the
array is cleared, we just assume that either geom->sz_elems and
geom->num_elems are synchronized to be equal or that unused elements
are cleared whenever geom->num_elems is set to be less than
geom->sz_elems without reallocation.

Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 09:55:04 +10:00
Rami Ylimäki
dc9ce695a6 xkb: Initialize pad bytes sent in replies of geometry requests.
Valgrind complains about uninitialized data being written to clients.

Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-17 10:53:35 +10:00
Peter Hutterer
ee3a4951a4 xkb: Document XkbWriteCountedString.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-03-17 10:53:22 +10:00
Rami Ylimäki
5c47f8beac xkb: Release XKB component names when compiling keymap.
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-16 15:21:41 +10:00
Rami Ylimäki
40e56d3453 xkb: Ensure that XKB device private won't leak on device disconnect.
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-03-09 07:59:40 +10:00
Peter Hutterer
579ee8f5d8 Merge branch 'mi-cleanup' into next 2011-02-23 08:44:42 +10:00
Peter Hutterer
17265ccb02 Move master/lastSlave out of the union into separate fields.
The removal of the double-use will cause some suble bugs as some conditions
to check for the dev->u.master case were broken and also evaluated as true
if lastSlave was set (instead of master).

Also breaks the input ABI.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-22 14:35:45 +10:00
Peter Hutterer
2936635698 xkb: Fix a check for MASTER_KEYBOARD
And copy into the master keyboard, not just the directly attached device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-22 14:35:45 +10:00
Peter Hutterer
dc57f89959 Switch to use IsFloating()
This is not a straightforward search/replacement due to a long-standing
issue.

dev->u.master is the same field as dev->u.lastSlave. Thus, if dev is a master
device, a check for dev->u.master may give us false positives and false
negatives.
The switch to IsFloating() spells out these cases and modifies the
conditions accordingly to cover both cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
2011-02-22 14:35:44 +10:00
Alan Coopersmith
0f9c6f2f82 xkb: Replace malloc(strlen) + strcpy with strdup
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-02-15 10:35:45 +10:00
Alan Coopersmith
682865c460 XkbAddGeomProperty: Fix checks for malloc failure
Check the variable we just tried to malloc, not the string we're copying
and already checked for NULL at the beginning of the function.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-02-15 10:35:43 +10:00
Alan Coopersmith
aac1b43566 Replace _XkbDupString with Xstrdup
The two functions have identical semantics, including safely returning
NULL when NULL is passed in (which POSIX strdup does not guarantee).

Some callers could probably be adjusted to call libc strdup directly,
when we know the input is non-NULL.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-02-15 10:35:41 +10:00
Alan Coopersmith
a4a2e814d5 xkb: Use snprintf to measure string lengths instead of manual strlen math
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-02-15 10:35:38 +10:00
Peter Hutterer
d3499556d8 xkb: if the keymap failed to compile, load the default keymap instead.
We really need symbols, compat, keynames, vmods and types for a sensible keymap.

Try this in your xorg.conf.d snippets for all keyboards:
        Option "XkbLayout" "us"
        Option "XkbVariant" "nodeadkeys"

us(nodeadkeys) doesn't exist so xkbcomp provides everything but the symbols
map. We say we want everything but don't _need_ anything, the server happily
gives us a keymap with every key mapped to NoSymbol. This in turn isn't what
we want after all.

So instead, require symbols, compat, keynames, vmods and types from the
keymap and if that fails, load the default keymap instead. If that fails
too, all bets are off.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2011-02-14 09:12:59 +10:00
Peter Hutterer
47d1d2fed6 xkb: split out keymap compilation.
Refactoring for simpler double-use in the next patch. No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2011-02-14 09:12:59 +10:00
Ander Conselvan de Oliveira
85f9017393 ProcXkbGetXkbByName: fix use of uninitialised bytes valgrind error.
==9999== Syscall param writev(vector[...]) points to uninitialised byte(s)
==9999==    at 0x4AB5154: writev (writev.c:51)
==9999==    by 0x7C7C3: _XSERVTransWritev (Xtrans.c:912)
==9999==    by 0x61C8B: FlushClient (io.c:924)
==9999==    by 0x62423: WriteToClient (io.c:846)
==9999==    by 0xCE39B: XkbSendMap (xkb.c:1408)
==9999==    by 0xD247B: ProcXkbGetKbdByName (xkb.c:5814)
==9999==    by 0x4AB53: Dispatch (dispatch.c:432)
==9999==    by 0x205BF: main (main.c:291)
==9999==  Address 0x557eb68 is 40 bytes inside a block of size 4,096 alloc'd
==9999==    at 0x48334A4: calloc (vg_replace_malloc.c:467)
==9999==    by 0x62567: WriteToClient (io.c:1065)
==9999==    by 0x452EB: ProcEstablishConnection (dispatch.c:3685)
==9999==    by 0x4AB53: Dispatch (dispatch.c:432)
==9999==    by 0x205BF: main (main.c:291)
==9999==  Uninitialised value was created by a stack allocation
==9999==    at 0xD1910: ProcXkbGetKbdByName (xkb.c:5559)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>
2011-02-14 09:12:59 +10:00
Ander Conselvan de Oliveira
8a34d7a853 XkbSendNames: fix use of uninitialised bytes valgrind error.
==537== Syscall param writev(vector[...]) points to uninitialised byte(s)
==537==    at 0x4AB7154: writev (writev.c:51)
==537==    by 0x8935B: _XSERVTransWritev (Xtrans.c:912)
==537==    by 0x6C55F: FlushClient (io.c:924)
==537==    by 0x6CCF3: WriteToClient (io.c:846)
==537==    by 0xD51D3: XkbSendNames (xkb.c:3765)
==537==    by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825)
==537==    by 0x27B7B: Dispatch (dispatch.c:432)
==537==    by 0x205B7: main (main.c:291)
==537==  Address 0x55899f2 is 154 bytes inside a block of size 1,896 alloc'd
==537==    at 0x4834C48: malloc (vg_replace_malloc.c:236)
==537==    by 0xD47AF: XkbSendNames (xkb.c:3642)
==537==    by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825)
==537==    by 0x27B7B: Dispatch (dispatch.c:432)
==537==    by 0x205B7: main (main.c:291)
==537==  Uninitialised value was created by a heap allocation
==537==    at 0x4834C48: malloc (vg_replace_malloc.c:236)
==537==    by 0xD47AF: XkbSendNames (xkb.c:3642)
==537==    by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825)
==537==    by 0x27B7B: Dispatch (dispatch.c:432)
==537==    by 0x205B7: main (main.c:291)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>
2011-02-14 09:12:59 +10:00
Erkki Seppälä
5927e070b4 xkb: Cancel a key's repetition when its autorepeat is disabled.
When XkbChangeEnabledControls is called to disable key repetition of a
certain key (or keys), currently ongoing repetition of that key was
not cancelled. It was cancelled if ChangeKeyboardControl was used to
disable key repetition globally.

Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Dirk Wallenstein <halsmit@t-online.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-01-27 14:22:02 +10:00
Keith Packard
57a1d9b853 Merge remote branch 'whot/for-keith' 2011-01-20 21:16:24 -08:00
Peter Hutterer
6423769799 xkb: after making changes to the xkb ctrls, copy them back into kbdfeed.
enabled_ctrls_changes nowhere near the usual event or config paths. So this
condition always evaluated to false and the memcpy would thus never been
hit. As a result, any modification to the XKB struct during
XkbUpdateDescActions was not reflected in the kbdfeed ctrls.
The flag that is set by XkbUpdateDescActions() if ctrls were changed are in
enabled_ctrls.

This mainly affected keyboard repeat control as XKB uses the kbdfeed ctrls,
not XKB's per_key_repeats, to determine if a key needs to be repeated. Thus,
adding a "repeat= False" to the XKB map of any action did not have any
effect.

Test case:
assign Mode_switch to any key that by default repeats, e.g. the menu key.

    key <COMP> {         [     Mode_switch ] };

Then modify the Mode_switch action to not repeat the key.

    interpret Mode_switch+AnyOfOrNone(all) {
        virtualModifier= AltGr;
        useModMapMods=level1;
        action= SetGroup(group=+1);
        // Add this line
        repeat= False;
    };

Though the flags are correctly reflected in the description loaded in the
server, the change is not handed back to the kbdfeed struct and XKB will
trigger softrepeats of this key.

This patch also adds two explanatory comments and an extra check, as this
path may be hit before the CtrlProc for the kbdfeed struct is set.

Red Hat Bug 537708 <https://bugzilla.redhat.com/show_bug.cgi?id=537708>

Also fixes broken auto-repeat of the backspace key in the colemak layout
(mapped to CapsLock).

X.Org Bug 16318 <http://bugs.freedesktop.org/show_bug.cgi?id=16318>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Dirk Wallenstein <halsmit@t-online.de>
Reviewed-by: Dirk Wallenstein <halsmit@t-online.de>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-01-21 09:07:09 +10:00
Peter Hutterer
f1326ed291 xkb: Replace a few manual bitflips with SetBit & friends.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dirk Wallenstein <halsmit@t-online.de>
2011-01-20 07:48:47 +10:00
Alan Coopersmith
c6aa4755ec xkb/ddxLoad.c doesn't need <paths.h> any more
Was previously used for _PATH_VARTMP, but that was removed in
534fc5140b

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-01-18 15:22:04 -08:00
Alan Coopersmith
03e8bfa1d1 Convert existing Xprintf style calls to asprintf style
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Peter Hutterer
88cb61e1e5 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-api
Conflicts:
	dix/getevents.c
	hw/xfree86/common/xf86Xinput.h

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11 12:54:46 +10:00
Cyril Brulebois
b142b0d274 Remove more superfluous if(p!=NULL) checks around free(p).
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@
- if (E != NULL)
-   free(E);
+ free(E);

Signed-off-by: Cyril Brulebois <kibi@debian.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11 08:29:54 +10:00
Cyril Brulebois
99275ad2fa Remove superfluous if(p!=NULL) checks around free(p); p=NULL;
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@
-  if (E != NULL) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
-  }
+ free(E);
+ E = NULL;

Signed-off-by: Cyril Brulebois <kibi@debian.org>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11 08:22:59 +10:00
Peter Hutterer
675f4a8525 Abstract valuator masks through a set of APIs.
This commit introduces an abstraction API for handling masked valuators. The
intent is that drivers just allocate a mask, set the data and pass the mask
to the server. The actual storage type of the mask is hidden from the
drivers.

The new calls for drivers are:
    valuator_mask_new()     /* to allocate a valuator mask */
    valuator_mask_zero()    /* to reset a mask to zero */
    valuator_mask_set()     /* to set a valuator value */

The new interface to the server is
    xf86PostMotionEventM()
    xf86PostButtonEventM()
    xf86PostKeyboardEventM()
    xf86PostProximityEventM()

all taking a mask instead of the valuator array.

The ValuatorMask is currently defined for MAX_VALUATORS fixed size due to
memory allocation restrictions in SIGIO handlers.

For easier review, a lot of the code still uses separate valuator arrays.
This will be fixed in a later patch.

This patch was initially written by Chase Douglas.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2010-10-22 11:02:48 +10:00
Peter Hutterer
649293f6b6 xkb: always fill the symsPerKey array, regardless of client flags (#30527)
Even if a client does not modify the symbols, symsPerKey and mapWidths must
be filled from the current configuration. Both arrays are then passed into
other functions (pending the right flag), thus they must contain valid
values regardless of the XkbKeySymsMask flag in req->present.

X.Org Bug 30527 <http://bugs.freedesktop.org/show_bug.cgi?id=30527>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-10-20 08:01:54 +10:00
Peter Hutterer
ca21a26622 xkb: init mapWidth and symsPerKey arrays to 0.
Helps debugging greatly, random 8 or 16 bit values can sometimes look like
valid values, causing much excitement on the client front.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-10-20 08:01:31 +10:00
David Ge
a90052ba86 xkb: Fix RedirectKey didn't send any event.
Xorg.log shows error: Valuators reported for non-valuator device.
This is caused by uninitialized valuators.mask in _XkbFilterRedirectKey(),
which trigger the error in UpdateDeviceState().

Signed-off-by: David Ge <davidqge@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:43:34 +10:00
Pauli Nieminen
b5c9953bbf xkb: Check if AddResource failed
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:43:05 +10:00
Pauli Nieminen
2e6d717404 xkb: Fix possible NULL pointer dereference
sli is null before allocation assigment so deference t osli has to be
protected.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:43:03 +10:00
Pauli Nieminen
d6642de7eb xkb: Fix possible NULL pointer dereference
If search for device failed sli is NULL. In that case we have to protect
dereference to prevent server crash.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:43:02 +10:00