Commit Graph

585 Commits

Author SHA1 Message Date
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
Pauli Nieminen adc0697cfc xkb: Fix memory leak in error path
map is allocated but not freed if reply length and data don't match.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:43:00 +10:00
Pauli Nieminen 67cfb66562 xkb: Remove redurant intialization code
calloc already initializes allocated memory to zero.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:42:59 +10:00
Pauli Nieminen 2475ef6097 xkb: Fix NULL pointer dereference
xkb->names is dereferenced in else path too.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:42:58 +10:00
Pauli Nieminen 184ef0d356 xkb: Don't check for NULL before calling free
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:42:56 +10:00
Pauli Nieminen 1223340644 xkb: Fix memory leak if opening file fails
If fopen fails pointer in buf would be overwriten with a new pointer.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:42:55 +10:00
Pauli Nieminen 20cb9c923e xkb: Use memcpy for copy that has known length
Fixes warning that strncpy is not able to append NULL to the end
of destination.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-09-01 14:42:53 +10:00
Keith Packard 0af322858e Silence GCC warning about uninitialized lastSlave variable
Not an actual bug, but gcc can't tell that this variable cannot be
used without being initialized

Signed-off-by: Keith Packard <keithp@keithp.com>
2010-08-12 22:58:39 -07:00
Peter Hutterer 1a172f3297 xkb: if the button isn't down, don't fake an event.
If the button we're about to fake isn't down (or up), don't fake a release
(or press) event for it. Behaviour is the same as before, this just saves
a few cycles.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-08-13 11:07:21 +10:00
Peter Hutterer 651c36e95e xkb: post-fix PointerKeys button events with a DeviceChangedEvent.
commit 1432785839
    xkb: release XTEST pointer buttons on physical releases. (#28808)
revealed a bug with the XTEST/PointerKeys interaction.

Events resulting from PointerKeys are injected into the event processing
stream, not appended to the event queue. The events generated for the fake
button press include a DeviceChangedEvent (DCE), a raw button event and the
button event itself. The DCE causes the master to switch classes to the
attached XTEST pointer device.

Once the fake button is processed, normal event processing continues with
events in the EQ. The master still contains the XTEST classes, causing some
events to be dropped if e.g. the number of valuators of the event in the
queue exceeds the XTEST device's number of valuators.

Example: the EQ contains the following events, processed one-by-one, left to
right.

[DCE (dev)][Btn down][Btn up][Motion][Motion][...]
                  ^ XkbFakeDeviceButton injects [DCE (XTEST)][Btn up]

Thus the event sequence processed looks like this:

[DCE (dev)][Btn down][Btn up][DCE (XTEST)][Btn up][Motion][Motion][...]

The first DCE causes the master to switch to the device. The button up event
injects a DCE to the XTEST device, causing the following Motion events to be
processed with the master still being on XTEST classes.

This patch post-fixes the injected event sequence with a DCE to restore the
classes of the original slave device, resulting in an event sequence like
this:
[DCE (dev)][Btn down][Btn up][DCE (XTEST)][Btn up][DCE (dev)][Motion][Motion]

Note that this is a simplified description. The event sequence injected by
the PointerKeys code is injected for the master device only and the matching
slave device that caused the injection has already finished processing on
the slave. Furthermore, the injection happens as part of the the XKB layer,
before the unwrapping of the processInputProc takes us into the DIX where
the DCE is actually handled.

Bug reproducible with a device that reports more than 2 valuators. Simply
cause button releases on the device and wait for a "too many valuators"
warning message.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-08-13 11:07:13 +10:00
Peter Hutterer 9ac8e206ff xkb: use GetMaster instead of dev->u.master.
Devices that are both pointers and keyboards are not affected by keyboard
changes as their master device is a master pointer, not a master keyboard.
Use GetMaster() instead to ensure devices that are attached to the paired
master pointer device will still be update.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-07-21 08:12:03 +10:00
Alan Coopersmith f0fcffe55f Update the sprite immediately when moving it with MouseKeys
Fix for OpenSolaris bug 6949755: Mouse Keys are ununusable
and possibly https://bugs.freedesktop.org/show_bug.cgi?id=24856

Ensures waitForUpdate is False before calling SetCursorPosition.
Normally waitForUpdate is False when SilkenMouse is active, True
when it's not.   When it's True, the mouse cursor position on
screen is not updated immediately.

This is more critical on Solaris, since we disabled SigIO, thus in turn
disable SilkenMouse, due to the SSE2 vs. signal handler issues described in
Sun bugs 6849925, 6859428, and 6879897.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-02 14:27:50 +10:00
Peter Hutterer 1432785839 xkb: release XTEST pointer buttons on physical releases. (#28808)
If a button release event is posted for the MD pointer, post a release event
through the matching XTEST device. This way, a client who posts a button
press through the XTEST extension cannot inadvertedly lock the button.

This behaviour is required for historical reasons, until server 1.7 the core
pointer would release a button press on physical events, regardless of the
XTEST state. Clients seem to rely on this behaviour, causing seemingly stuck
grabs.

The merged behaviour is kept for multiple keyboard PointerKey events, if two
physical keyboards hold the button down as a result of PointerKey actions,
the button is not released until the last keyboard releases the button.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-02 08:51:30 +10:00
Peter Hutterer 339f62b1bf xkb: emulate PointerKeys events only on the master device.
This patch replicates the behaviour for button events. Only generate a
PointerKeys motion event on the master device, not on the slave device.
Fixes the current issue of PointerKey motion events generating key events as
well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-01 14:05:39 +10:00
Peter Hutterer 69ac909878 xkb: merge lockedPtrButtons state from all attached SDs.
Problem:
lockedPtrButtons keeps the state of the buttons locked by a PointerKeys button
press. Unconditionally clearing the bits may cause stuck buttons in this
sequence of events:

1. type Shift + NumLock to enable PointerKeys
2. type 0/Ins on keypad to emulate Button 1 press
        → button1 press event to client
3. press and release button 1 on physical mouse
        → button1 release event to client

Button 1 on the MD is now stuck and cannot be released.

Cause:
XKB PointerKeys button events are posted through the XTEST pointer device.
Once a press is generated, the XTEST device's button is down. The DIX merges
the button state of all attached SDs, hence the MD will have a button down
while the XTEST device has a button down.

PointerKey button events are only generated on the master device to avoid
duplicate events (see XkbFakeDeviceButton()). If the MD has the
lockedPtrButtons bit cleared by a release event on a physical device, no
such event is generated when a keyboard device triggers the PointerKey
ButtonRelease trigger. Since the event - if generated - is posted through
the XTEST pointer device, lack of a generated ButtonRelease event on the
XTEST pointer device means the button is never released, resulting in the
stuck button observed above.

Solution:
This patch merges the MD's lockedPtrButtons with the one of all attached
slave devices on release events. Thus, as long as one attached keyboard has
a lockedPtrButtons bit set, this bit is kept in the MD. Once a PointerKey
button is released on all keyboards, the matching release event is emulated
from the MD through the XTEST pointer device, thus also releasing the button
in the DIX.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-01 14:05:39 +10:00
Peter Hutterer 09645864f5 xkb: Mark switch case fallthrough with comment.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-01 14:05:32 +10:00
Peter Hutterer dbf249ec66 xkb: remove now obsolete comment.
Looks like nothing broke from removing the hardcoded CoreProcessPointerEvent
call. Whoop. Di. Doo.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-01 14:04:58 +10:00
Matt Turner f4190feb25 Remove more superfluous if(p) checks around free(p)
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-06-11 19:05:46 +07:00
Mikhail Gusarov a54a766dfb xkb: replace xstrdup with strdup in Win32System
The only caller of Win32System is XkbDDXCompileKeymapByNames. Add allocation
check there to avoid passing NULL pointers to various functions down the code.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-11 19:05:46 +07:00
Mikhail Gusarov 6592db6bb5 Get rid of xstrdup when argument is definitely non-NULL
Replace xstrdup with strdup when either constant string is
being duplicated or argument is guarded by conditionals and
obviously can't be NULL

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-06-11 19:04:23 +07:00
Mikhail Gusarov 7287ef9e6c Remove unnecessary parentheses around return values in functions
This patch was generated by the following Perl code:

perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;'

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10 06:42:42 -07:00
Keith Packard bc26665661 Initialize private keys in test suite
Make sure all of the private keys used by the test code are
initialized before being used.

Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Robert Hooker <sarvatt@ubuntu.com>
2010-06-06 21:24:04 -07:00
Mikhail Gusarov 0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Mikhail Gusarov 5a0fc0ad21 Replace deprecated bzero with memset
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Marcin Baczyński <marbacz@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 15:07:27 +07:00
Mikhail Gusarov f9810ba914 xkb: Remove superfluous if(x) x = realloc(x, sz); else x = malloc(sz); logic
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Marcin Baczyński <marbacz@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-06-06 15:07:24 +07:00
Mikhail Gusarov 77ea20895c xkb: Remove superfluous if(p) checks around free(p)
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-06-06 15:07:17 +07:00
Keith Packard faeebead7b Change the devPrivates API to require dixRegisterPrivateKey
This patch only changes the API, not the implementation of the
devPrivates infrastructure. This will permit a new devPrivates
implementation to be layed into the server without requiring
simultaneous changes in every devPrivates user.

Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-06-05 19:23:03 -07:00
Peter Hutterer 7f19a7a6e9 xkb: fix invalid memory writes in _XkbCopyGeom.
Classic strlen/strcpy mistake of
   foo = malloc(strlen(bar));
   strcpy(foo, bar);

Testcase: valgrind Xephyr :1

==8591== Invalid write of size 1
==8591==    at 0x4A0638F: strcpy (mc_replace_strmem.c:311)
==8591==    by 0x605593: _XkbCopyGeom (xkbUtils.c:1994)
==8591==    by 0x605973: XkbCopyKeymap (xkbUtils.c:2118)
==8591==    by 0x6122B3: InitKeyboardDeviceStruct (xkbInit.c:560)
==8591==    by 0x4472E2: CoreKeyboardProc (devices.c:577)
==8591==    by 0x447162: ActivateDevice (devices.c:530)
==8591==    by 0x4475D6: InitCoreDevices (devices.c:672)
==8591==    by 0x4449EE: main (main.c:254)
==8591==  Address 0x6f96505 is 0 bytes after a block of size 53 alloc'd
==8591==    at 0x4A0515D: malloc (vg_replace_malloc.c:195)
==8591==    by 0x6054B7: _XkbCopyGeom (xkbUtils.c:1980)
==8591==    by 0x605973: XkbCopyKeymap (xkbUtils.c:2118)
==8591==    by 0x6122B3: InitKeyboardDeviceStruct (xkbInit.c:560)
==8591==    by 0x4472E2: CoreKeyboardProc (devices.c:577)
==8591==    by 0x447162: ActivateDevice (devices.c:530)
==8591==    by 0x4475D6: InitCoreDevices (devices.c:672)
==8591==    by 0x4449EE: main (main.c:254)

Reported-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by-and-apologised-for: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-04 00:20:53 -07:00
Jamey Sharp e7fae9ecc4 Move each screen's root-window pointer into ScreenRec.
Many references to the WindowTable array already had the corresponding
screen pointer handy, which meant they usually looked like
"WindowTable[pScreen->myNum]". Adding a field to ScreenRec instead of
keeping this information in a parallel array simplifies those
expressions, and eliminates a MAXSCREENS-sized array.

Since dix uses this data, a screen private entry isn't appropriate.

xf86-video-dummy currently uses WindowTable, so it needs to be updated
to reflect this change.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
2010-06-03 14:03:23 -07:00
Jamey Sharp 8033fb6c97 Set event sequence number in WriteEventsToClient instead of at callers.
TryClientEvents already did this; this commit just moves the assignment
one level down so that no event source has to worry about sequence
numbers.

...No event source, that is, except XKB, which inexplicably calls
WriteToClient directly for several events.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:34 -07:00
Jamey Sharp 92ed75ac59 Eliminate boilerplate around client->noClientException.
Just let Dispatch() check for a noClientException, rather than making
every single dispatch procedure take care of it.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-05-13 17:14:07 -07:00
Mikhail Gusarov 5a8e2f2745 Do not jump through the hoops to deallocate xkbbasedirflag variable
Fixes gcc warning as well.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-05-13 04:54:29 +07:00
Mikhail Gusarov 3f3ff971ec Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Dirk Wallenstein bac1c5f1be xkb: Fix omissions in geometry initialization #27679
_XkbCopyGeom did not copy all of the data from the source geometry. This
resulted in failures when trying to obtain the keymap from a server
where the default geometry has not been replaced by a custom
configuration.

Signed-off-by: Dirk Wallenstein <halsmit@t-online.de>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-27 15:50:26 +10:00
Tiago Vignatti b36eeb713a xkb: check for NULL pointer before dereferences it in XkbWriteXKBSymbols
move srv assignment to before it's being used. Also, check for xkb being nil.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-21 18:07:25 +03:00
Tiago Vignatti 96784f4fcb xkb: check for NULL pointer before dereferences it in XkbAddClientResource
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-21 18:07:20 +03:00
Peter Hutterer 0ad022a729 xkb: rename XkbFakeDeviceButton and XkbFakeDeviceMotion, move into xkbActions.c
The name XkbDDXFakeDeviceButton and XkbDDXFakeDeviceMotion is somewhat
misleading, there's no DDX involved in the game at all anymore.

This removes XkbFakeDeviceMotion and XkbFakeDeviceButton from the API where
it arguably shouldn't have been in the first place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-19 09:23:20 +10:00
Peter Hutterer da4e2e3828 xkb: purge unneeded includes from ddxDevBtn.c
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-19 09:23:15 +10:00
Peter Hutterer f4106c0231 xkb: use GPE for XKB fake motion events.
Section 4.6.1 of the XKB spec says that "the initial event always moves the
cursor the distance specified in the action [...]", so skip the
POINTER_ACCELERATE flag for GPE, it would cause double-acceleration.

Potential regression - GPE expects the coordinates to be either relative or
both. XKB in theory allows for x to be relative and y to be absolute (or
vice versa). Let's pretend that scenario has no users.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-04-16 16:33:38 +10:00
Peter Hutterer 6c42c8c356 xkb: Guard against SIGIO updates during PointerKeys.
In theory, an event coming in during GPE could reset our lastSlave, leading
to rather interesting events lateron.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-04-16 16:33:33 +10:00
Peter Hutterer 108457dff8 xkb: Post PointerKeys through the XTEST device.
Posting an event through a master device may cause pointer jumps once
lastSlave == master, caused by double scaling. To avoid this, post the fake
event generated by XKB through the XTEST device instead.

Fedora bug #560356 <https://bugzilla.redhat.com/560356>
Tested-by: Andrew McNabb

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-04-16 16:30:21 +10:00
Jeremy Huddleston 8311cd5f89 XKB: Fix garbage initialization
XkbEnableDisableControls set extra garbage bits on the xkbControlsNotify
changedControls mask because it was uninitialized on the stack.

Found by clang

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-03-24 08:07:42 +10:00
Peter Hutterer db687f718f xkb: sed True -> TRUE and False -> FALSE
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-02-02 10:03:30 +10:00
Peter Hutterer 0ea2b0bd02 xkb: Add XKM file format description.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-02-02 10:03:21 +10:00
Horst Wente b91cec26de xkb: make ctrl+alt+keypad + / ctrl+alt+keypad - work again (#25743)
Video mode switching via keypad keys did not work

Signed-off-by: Horst Wente <horst.wente@acm.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-02 10:00:30 +10:00
Peter Hutterer c8bba14a39 xkb: remove XkbAtomGetString, replace with NameForAtom.
XKB really XKBdoes not XKBneed its own XKBdefines for XKBeverything.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-25 09:29:19 +13:00
Peter Hutterer f37799c971 xkb: remove IsKeypadKey define, only used in two places.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-25 09:28:22 +13:00
Peter Hutterer c8076f317e xkb: remove XConvertCase.
Since it's typedef'd to XkbConvertCase anyway and the headers are now split
from the client headers, simply get rid of it altogether.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-25 09:26:40 +13:00
Peter Hutterer d627dd9d1e xkb: remove _XkbClearElems, a memset will do.
Bonus point - it's easier to understand what's actually being done with the
memory.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-25 09:25:21 +13:00
Peter Hutterer ea1de3fcdc xkb: remove _XkbTyped*alloc
Please no extension-specific macros for memory allocation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-25 09:24:31 +13:00
Alan Coopersmith 895f40792a Add type name argument to CreateNewResourceType
Convert all calls of CreateNewResourceType to pass name argument

Breaks DIX ABI.

ABI versions bumped:

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-18 17:44:12 -08:00
Alan Coopersmith a11c58fa0c Ensure all resource types created have names registered
Calls RegisterResourceName to record the type name for
use by X-Resource, XACE/SELinux/XTsol, and DTrace.

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2009-12-18 16:51:45 -08:00
Alan Coopersmith eb750f8b5e Check for failures from CreateNewResourceType
Make sure to check return value before setting bitmask flags.
For most calls, just fails to init the extension.   Since Xinput
already calls FatalError() on initialization failure, so does
failure to allocate Xinput's resource type.

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2009-12-18 16:51:45 -08:00
Peter Hutterer 12fb31815d xkb: don't assign garbage value to led_return.
As the comment for the function states, led_return is undefined if map is
NULL. We might as well skip writing to it then.

Found by clang.

Reported-by: Tomas Carnecky <tom@dbservice.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2009-12-11 11:37:37 +10:00
Tomas Carnecky 8861407878 Fix possible NULL dereference in XkbFlushLedEvents()
Through some code paths it is possible that NULL is being passed in the
'ed' parameter to XkbFlushLedEvents(). Make sure we don't pass it along
to bzero().

Signed-off-by: Tomas Carnecky <tom@dbservice.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-11 11:37:36 +10:00
Tomas Carnecky 92d9cb7e13 XkbWriteCountedString(): return early if str is NULL
This avoids NULL from being passed to memcpy() later in the code. While
that wasn't an issue before - that value being NULL implied 'size == 0'
so memcpy() wouldn't try to dereference it - it made the code harder
to read and also confused clang.

Signed-off-by: Tomas Carnecky <tom@dbservice.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-11 11:37:36 +10:00
Peter Hutterer b584c224a8 Set the source and deviceid for key repeat events (#24785)
X.Org Bug 24785 <http://bugs.freedesktop.org/show_bug.cgi?id=24785>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Adam Jackson <ajax@redhat.com>
2009-12-03 08:24:04 +10:00
Peter Hutterer ff3e171568 xkb: don't conditionally include xkb-config.h.
If HAVE_XKB_CONFIG_H is ever undefined, we fail to build anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-20 13:32:14 +10:00
Eamon Walsh c4ffce4dc8 xace: Relax permissions on XkbGetState from Read to Getattr.
This request is used to get the current keyboard group and is called from
GTK.  It does not return an actual keymap (aside from modifiers) so it
should be safe to relax the permission on it.  However it does return
button state information which should be controlled through a separate
pointer Read check.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2009-10-14 19:19:19 -04:00
Nirbheek Chauhan 9bc7cbf9c0 xkb: check permissions on XKM_OUTPUT_DIR
Checking just for root is insufficient since that does not guarantee write/read
permissions in XKM_OUTPUT_DIR (for example with sandbox).

Check if we can write a file, as well as read it later. Otherwise, invoke the
fallback to /tmp

Signed-off-by: Nirbheek Chauhan <nirbheek@gentoo.org>
Signed-off-by: Rémi Cardona <remi@gentoo.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-10-01 19:02:36 +10:00
Jeremy Huddleston 7bef78e199 xkb: Use XkbPerKeyBitArraySize instead of hardcoded value of 32 2009-09-30 00:23:47 -07:00
Peter Hutterer 90aa0e4a49 input: don't use typecasts to access members of InternalEvent.
To avoid confusion, the member names are now postfixed with _event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-22 11:15:32 +10:00
Peter Hutterer 55747d256d input: define server-supported protocol versions in one single file.
include/protocol-versions.h specifies each extension version as supported by
the server and sent back on the wire to the client.

This fixes up several issues with the server potentially reporting a higher
version of the protocol if recompiled against a newer version of the
protocol.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Rémi Cardona <remi@gentoo.org>
Acked-by: Julien Cristau <jcristau@debian.org>
2009-09-21 21:47:35 +10:00
Peter Hutterer 4650e6ebe6 xkb: drop key presses for already repeating keys. (#23889)
The event sequence for continuously pressed keys with the keyboard driver is
PRESS - PRESS - PRESS - ... - RELEASE.
The first press sets the repeatKey to the keycode and the matching timer.
The second press (on the same keycode) can be silently dropped instead of
overwriting the timer again.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2009-09-14 12:54:27 +10:00
Peter Hutterer 4da59f4786 xkb: split effectiveGroup calculation into separate utility function.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-13 10:30:14 +10:00
Peter Hutterer 8af2793a90 xkb: xkbGetKbdByName on the lastSlave needs to change the master (#21859)
If the layout is changed on a master's lastSlave, the master needs to change
layout immediately. Otherwise, the master stays on the same layout until the
lastSlave changes - which may not happen if only a single keyboard is
available.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-04 13:12:43 +10:00
Daniel Stone bfb219f532 input: allow for detectable autorepeat.
For core and XI1 events, store the key_repeat flag in the sequence number
until TryClientEvents. The sequenceNumber is unset until TryClientEvents.

[Also thrown in, some random indentation changes. Thanks]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-04 12:59:41 +10:00
Peter Hutterer 1e210d6d10 xkb: remove now-unused XkbGetKeysym.
XkbGetKeysyms was only used by the now-removed Keysym grabs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-08-05 07:59:07 +10:00
Peter Hutterer 845e65f080 xkb: move XkbFilterEvents to xkbsrv.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:14 +10:00
Peter Hutterer a148d40742 xkb: restore XKB PtrBtn actions.
Ifdef'd out since the switch to internal events. PtrBtn actions now work
again. Instead of generating the event directly, GPE generates the event and
it is then posted through the usual event processing routines
(mieqProcessDeviceEvent).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:13 +10:00
Peter Hutterer 4e9b2938cd include: untangle events.h from the SDK headers.
InternalEvents shouldn't be used anywhere outside the X server itself. Split
up into events.h for opaque typedefs for the events needed by various
headers and eventstr.h for the actual struct definitions.

eventstr.h must only be included by code that requires internal events and
is not part of the SDK.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-30 08:43:13 +10:00
Peter Hutterer 6a90c7b937 xkb: cosmetic fix, use TRUE instead of True.
Rest of InitKeyboardDeviceStruct uses TRUE and FALSE.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-16 09:29:17 +10:00
Peter Hutterer 693babbf12 xkb: Remove XKMformat.h include from xkbsrv.h into the files that need it.
xkbsrv.h is used by drivers, they don't need the XKM format and shouldn't
require it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-15 12:30:44 +10:00
Peter Hutterer 089c460058 xkb: switch to byte counting functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-14 10:14:02 +10:00
Peter Hutterer 3711d68f65 Revert "XKB: Sanitise * actions" commits (#19602)
Reverts the following four patches:

feb757f384 "XKB: Sanitise vmods for redirected keys"
b5f49382fe "XKB: Sanitise ctrls action"
1bd7fd195d "XKB: Sanitise pointer actions"
61c508fa78 "XKB: Sanitise vmods in actions"

Strictly speaking, the structs used in the server are not part of the client
ABI. Practically, they are as we copy from the wire straight into the
structs. Changing the struct sizes breaks various wire/server conversions.

Even when the structs have the same size, some internal magic causes
conversions to fail. Visible by diffing the output files of:
setxkbmap -layout de; xkbcomp -xkb :0 busted.xkb
setxkbmap -layout de -print | xkbcomp -xkb - correct.xkb

Interestingly enough, busted.xkb is the working one although the output is
incorrect. Revert the four offending patches until the exact cause of this
breakage can be determined.

This patch restores functionality to Level3 modifiers.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-10 11:23:52 +10:00
Peter Hutterer 01241b4247 Xi: Add support for sourceid in the device classes. 2009-06-17 11:21:19 +10:00
Peter Hutterer b40289c876 xkb: allow pointer events to pass through for floating SDs without a key class.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-06-02 16:37:39 +10:00
Peter Hutterer d7aef3f663 Merge branch 'master' into xi2
Conflicts:
	Xext/geext.c
	Xi/chdevcur.c
	Xi/extgrbdev.c
	Xi/xiproperty.c
	configure.ac
	dix/ptrveloc.c
	hw/xfree86/common/xf86Config.c
	mi/mipointer.h
	test/input.c
	xkb/xkb.c
2009-05-28 17:20:58 +10:00
Peter Hutterer c9df51b070 input: allow for master pointers to not have a button class.
There's devices (e.g. some barcode readers) that have axes but no buttons.
When such a device sends a motion event, the valuator and button class is
copied into the master pointer (i.e. removing the button class).
So we need a couple of extra sanity checks for the button class to exist.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 15:44:57 +10:00
Peter Hutterer b12d302df8 Input: rename DeviceIntRec->isMaster to ->type.
isMaster is not enough as long as we differ between master pointers and
keyboard. With flexible device classes, the usual checks for whether a
master device is a pointer (currently check for ->button, ->valuators or
->key) do not work as an SD may post an event through a master and mess this
check up.

Example, a device with valuators but no buttons would remove the button
class from the VCP and thus result in the
IsPointerDevice(inputInfo.pointer) == FALSE.

This will become worse in the future when new device classes are introduced
that aren't provided in the current system (e.g. a switch class).

This patch replaces isMaster with "type", one of SLAVE, MASTER_POINTER and
MASTER_KEYBOARD. All checks for dev->isMaster are replaced with an
IsMaster(dev).
2009-05-22 15:44:50 +10:00
Tomas Janousek 525aa17f80 Bug #6428, #16458, #21464: Fix crash due to uninitialized VModMap fields.
In ProcXkbGetKbdByName, mrep.firstVModMapKey, .nVModMapKeys and
.totalVModMapKeys were not initialized, contained random values and caused
accesses to unallocated and later modified memory, causing
XkbSizeVirtualModMap and XkbWriteVirtualModMap to see different number of
nonzero values, resulting in writes past the end of an array in XkbSendMap.

This patch initializes those values sensibly and reverts commits 5c0a2088 and
6dd4fc46, which have been plain non-sense.

Signed-off-by: Tomas Janousek <tomi@nomi.cz>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-22 12:24:21 +10:00
Peter Hutterer 1cce55cc03 input: rename device->type to device->xinput_type.
This type is only used in XI to give a hint of what type this device may be.
Call it xinput_type for clarity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 10:42:35 +10:00
Tomas Janousek 81b3b0cce0 Bug #6428, #16458, #21464: Fix crash due to uninitialized VModMap fields.
In ProcXkbGetKbdByName, mrep.firstVModMapKey, .nVModMapKeys and
.totalVModMapKeys were not initialized, contained random values and caused
accesses to unallocated and later modified memory, causing
XkbSizeVirtualModMap and XkbWriteVirtualModMap to see different number of
nonzero values, resulting in writes past the end of an array in XkbSendMap.

This patch initializes those values sensibly and reverts commits 5c0a2088 and
6dd4fc46, which have been plain non-sense.

Signed-off-by: Tomas Janousek <tomi@nomi.cz>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-21 10:42:35 +10:00
Peter Hutterer 8fb51feae2 xkb: if kbd init failed, NULL out the pointers after freeing them (#21278)
Reproducible:
Configure a server that uses the keyboard driver with an invalid ruleset,
e.g. (Option "XkbRules" "foobar"). Ensure that Option "AllowEmptyInput" is
"off" in the ServerFlags or ServerLayout section. Start the server.
After failing to init the keymap, the server will try to clean up after the
device, double-freeing some xkb structs that have not been reset properly.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-16 12:20:58 +10:00
Peter Hutterer ac13145dbc xkb: if kbd init failed, NULL out the pointers after freeing them (#21278)
Reproducible:
Configure a server that uses the keyboard driver with an invalid ruleset,
e.g. (Option "XkbRules" "foobar"). Ensure that Option "AllowEmptyInput" is
"off" in the ServerFlags or ServerLayout section. Start the server.
After failing to init the keymap, the server will try to clean up after the
device, double-freeing some xkb structs that have not been reset properly.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-11 15:54:12 +10:00
Peter Hutterer 9c5b761c8c Revert "xkb: write the _XKB_RF_RULES_PROP to each device."
This commit shouldn't have been pushed, we're still sorting out the API we
want to use.

This reverts commit 876910a951.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-09 16:19:42 +10:00
Peter Hutterer 5cf7018381 xkb: remove _XkbAlloc, _XkbCalloc, _XkbRealloc and _XkbFree
We all agree that wrapping is fun, but seriously. One of these days someone
will get hurt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:28:53 +10:00
Peter Hutterer 0e31d3906d xkb: remove some now-useless XFUNCPROTOBEGIN
We bring them back if we start rewriting the server in C++, promise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-08 14:28:44 +10:00
Peter Hutterer d220d6907d Xi: add GrabButton and GrabKeysym code.
We don't do keycode grabs in XI2, they're pointless.
2009-05-06 14:37:33 +10:00
Peter Hutterer 35a4b8e7f4 xkb: remove oldState from XkbHandleActions.
I really don't know what the purpose of this variable is or was, aside from
potentially clobbering up our key state since there's a path where it may be
used uninitialised.

Also, this means that xkbi->prev_state is now accessible from the DIX with
meaningful data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-06 14:37:32 +10:00
Alan Coopersmith 557dbadf3b XkbSetNamedIndicator should ignore SD's without LED's
When ProcXkbSetNamedIndicator is called on a core device, and we
walk the slaves to set the LED's on each of them, ignore any slaves
that do not have either a KbdFeedbackCtrl or LedCtrl structure.

(This is much more critical in xserver-1.5-branch, where we walk
 *all* devices, not just the slaves of the specified master, and
 thus return failure when setting an LED on the Core Keyboard and
 hit a xf86-input-mouse device with no LED's to set.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-05-03 20:11:21 -07:00
Peter Hutterer 876910a951 xkb: write the _XKB_RF_RULES_PROP to each device.
We only have one root window and writing the rules used to the same property
for each device is quite pointless if you don't have the same RMLVO on all
devices. So let's be sensible and write the same property to the device too,
so at least we know which device got loaded with which RMLVO.
2009-05-01 09:07:39 +10:00
Peter Hutterer 057fc9a4f8 Merge branch 'master' into xi2
Conflicts:
	Xi/chdevhier.c
	include/input.h
2009-04-24 16:15:47 +10:00
Colin Harrison 6559f02ef8 xkb: set bell_func in InitKeyboardDeviceStruct.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-20 16:40:34 +10:00
Peter Hutterer d5ad14c8ed Merge branch 'master' into xi2 2009-04-19 22:28:22 +10:00
Peter Hutterer 62d2fb6863 xkb: Add XkbFreeRMLVOSet helper function.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Dan Nicholson <dbn.lists@gmail.com>
2009-04-19 22:20:18 +10:00
Peter Hutterer 56a5955c8c xkb: strdup the values returned by XkbGetRulesDflts
XkbGetRulesDftls may get a copy of what will later be freed when passed into
XkbSetRulesDftls.

On the second run of XkbGet/SetRulesDflts:
XkbGetRulesDflts(rmlvo)
        rmlvo->rules = current-rules

XkbSetRulesDflts(rmlvo)
        free(current-rules)
        current-rules = strdup(rmlvo->rules)

Leaving us with garbage in current-rules.

This patch requires callers of XkbGetRulesDflts to free the associated memory.

See also
http://lists.freedesktop.org/archives/xorg-devel/2009-February/000305.html

Reported-by: Benjamin Close <Benjamin.Close@clearchain.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-04-17 10:04:28 +10:00
Peter Hutterer b406886bbf input: allow NULL as XkbRMVLOSet in InitKeyboardDeviceStruct.
Virtually all callers use
    XkbGetRulesDefault(&rmlvo);
    InitKeyboardDeviceStruct(..., rmlvo);

Let's save them the trouble and accept NULL as a hint to take the
default RMLVO.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-04-17 10:03:40 +10:00
Peter Hutterer 6c3b633299 Merge branch 'master' into xi2 2009-04-07 19:36:27 +10:00
Maarten Maathuis d698e62690 xkb: plug a memory leak in XkbCopySrvLedInfo (#20756)
X.Org Bug 20756 <http://bugs.freedesktop.org/show_bug.cgi?id=20756>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-23 16:07:23 +10:00
Peter Hutterer e26f79335b xkb: put a few extra checks in against non-keyboards 2009-03-23 16:07:05 +10:00
Peter Hutterer 04ed0bcb25 xkb: remove Device/Enter leave handling - XI2 enter/leave don't have compat state. 2009-03-20 15:17:55 +10:00
Peter Hutterer 836864b657 xkb: don't overrun the map index when accessing symbols.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-20 14:48:57 +10:00
Peter Hutterer 4eeaee1e5a xkb: xkbi has a pointer to the device - use this instead of inputInfo.pointer. 2009-03-16 13:29:07 +10:00
Peter Hutterer 3f801ba62a xkb: the VCP can post device events, don't stop xkb filtering on it. 2009-03-16 13:29:07 +10:00
Peter Hutterer 23686e5680 xkb: Fix a mis-use of inputInfo.keyboard. 2009-03-16 13:29:07 +10:00
Peter Hutterer c97c6c3de3 xkb: fix a couple of device checks when looping through all devices.
Generally, we want to apply stuff to the device and to all attached slave
devices.
2009-03-16 13:29:07 +10:00
Jason Vas Dias e0ed9f16d0 Fix build with --enable-debug.
[amended by Peter Hutterer]
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-03 16:53:06 +10:00
Peter Hutterer 763848d3ab Input: change processing API to InternalEvents.
Don't pass xEvent* and count through to processing, pass a single
InternalEvent.

Custom handlers are disabled for the time being. And for extra fun,
XKB's pointer motion emulation is disabled. But stick an error in there so
that we get reminded should we forget about it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-23 17:52:40 +10:00
Peter Hutterer 0b4066c116 xkb: _XkbFilterRedirectKey needs to pass InternalEvents down.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-23 17:52:40 +10:00
Peter Hutterer 8829d966a6 Xi: support InternalEvents in UpdateDeviceState, parts of POE and EnqueueEvent
Note that this breaks DGA. Life is tough.

EnqueueEvent is a somewhat half-baked solution, we immediately drop back into
XI and store them. But it should in theory work.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Don't let the dcce be random data.
2009-02-23 17:52:39 +10:00
Peter Hutterer 007e93c869 xkb: Switch the xkb event processing path over to InternalEvents.
Before dropping down into the DIX, convert back into XI events. This is a
temporary solution only, until the DIX is capable of handling InternalEvents
anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-23 17:52:39 +10:00
Dan Nicholson 225853d51d xkb: Use cached XKB keymap when rules haven't changed
Rather than compiling a new keymap every time InitKeyboardDeviceStruct
is called, cache the previous keymap and reuse it if the rules have not
changed.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-20 09:42:27 +10:00
Peter Hutterer f5bf1fdaf3 xkb: Fix wrong colour reference in XKB geometry copying. #20081
base_color and label_color need to reference the color in the destination, not
in the source.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-02-17 08:04:16 +10:00
Peter Åstrand ddb8d8945d xserver: Avoid sending uninitialized padding data over the network
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:28:38 +10:00
Adam Jackson 0bad0552bf XKB: Remove -kb and +kb from -help text and man page. 2009-02-04 17:21:19 -05:00
Tomas Carnecky a88995dfb8 Make gcc happy: correct third argument of CopyGetMasterEvent()
Signed-off-by: Tomas Carnecky <tom@dbservice.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-04 09:43:44 +10:00
Tomas Carnecky bc57efffe6 Fix "warning: unused variable XXX"
events.c:4614: warning: unused variable ‘kbd’
xkbUtils.c:361: warning: unused variable ‘maxKeysPerMod’
xf86Events.c:409: warning: unused variable ‘ke’
generic.c:131: warning: unused variable ‘cs’
generic.c:130: warning: unused variable ‘size’
xf86RandR12.c:591: warning: unused variable ‘crtc’

Signed-off-by: Tomas Carnecky <tom@dbservice.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-04 09:41:25 +10:00
Alan Coopersmith 5623c27700 Constify atom name strings
Changes MakeAtom to take a const char * and NameForAtom to return them,
since many callers pass pointers to constant strings stored in read-only
ELF sections.   Updates in-tree callers as necessary to clear const
mismatch warnings introduced by this change.

Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-03 10:06:00 -08:00
Pierre Willenbrock 756a2c8483 Fix duplicate code, off-by one in space calculation, not initialized members 2009-01-28 20:15:08 -02:00
Daniel Stone 6aef4e96af XKB: Fix logic error
Use logical or instead of bitwise or.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:09:00 +11:00
Daniel Stone 0ec9b1069a XKB: Remove unused XkbProcessOtherEvent
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:59 +11:00
Daniel Stone 7c4c00649c XKB: Remove unused DDX functions
They were complete no-ops anyway.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:59 +11:00
Daniel Stone 4fa3872dc2 Input: Remove core keysyms from KeyClassRec
Instead of always keeping two copies of the keymap, only generate the
core keymap from the XKB keymap when we really need to, and use the XKB
keymap as the canonical keymap.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:59 +11:00
Daniel Stone f06a9d2e05 Input: Clean up keymap change notifications
Keyboard map notifications are always generated from within XKB code,
which also takes care of copying the keysyms, etc.  If you need to
mangle the keymap yourself, generate a new core keymap/modmap, and pass
it to XkbApplyMappingChange.

SendMappingNotify is renamed to SendPointerMappingNotify (and ditto its
Device variants), which still only _sends_ the notifications, as opposed
to also doing the copying a la XkbApplyMappingChange.

Also have the modmap change code traverse the device hierachy, rather
than just going off the core keyboard.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-01-22 15:08:58 +11:00
Daniel Stone b5242789ed XKB: Simplify keymap writing a bit
We don't need no temporary variable.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-01-22 15:08:57 +11:00
Daniel Stone feb757f384 XKB: Sanitise vmods for redirected keys
Turn two unsigned chars into one unsigned int for both vmods and the
vmod mask.  As a bonus, remove broken unused accessor macro for setting
the vmods.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:57 +11:00
Daniel Stone b5f49382fe XKB: Sanitise ctrls action
Turn four unsigned chars into one unsigned long.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:57 +11:00
Daniel Stone 1bd7fd195d XKB: Sanitise pointer actions
Turn two unsigned chars into one int.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:57 +11:00
Daniel Stone 61c508fa78 XKB: Sanitise vmods in actions
Turn vmods from two unsigned chars into one int.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:57 +11:00
Daniel Stone edeb033f29 XKB: Explicitly decode action data
Rather than requiring a one-to-one correspondence between XKM and struct
formats in action data, explicitly fill the action data, so we can break
API.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:56 +11:00
Daniel Stone 699824a357 XKB: Remove descriptions from maprules
We don't use them, as they're not up to the task.  We'll get a better
solution someday, promise.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:56 +11:00
Daniel Stone 1ad80678d8 XKB: Remove support for setting combined keymaps
We don't do full keymaps anymore.  Deal.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:56 +11:00
Daniel Stone 133e0bd6f1 XKB: Remove 'extra' functionality from rules parsing
When we find something weird in the rules, don't stash it as an extra
freeform component, just state that the rules file is likely broken and
move on with our lives.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:56 +11:00
Daniel Stone cc5c6d628a XKB: Remove unsupported Xi operation flags
We support every XKB operation on Xi devices, so always report that we
support everything, and that nothing is ever unsupported.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:56 +11:00
Daniel Stone 32db27a7f8 Input: Remove modifierMap from core
We already have modmap (in the exact same format!) in XKB, so just use
that all the time, instead of duplicating the information.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:55 +11:00
Daniel Stone f062e90a95 Input: Remove modifierKeyMap
Since modifierKeyMap is generated from modifierMap, just remove it, and
only generate it when we need to send the modifier map to the client.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:55 +11:00
Daniel Stone cf6a2fc2bd Input: Ignore modifiers in core input processing
Modifiers get cleared by the XKB code when we drop down into core input
processing, so just delete the dead code path to simplify things a bit.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:55 +11:00
Daniel Stone 6727ee9408 Input: Remove state from KeyClassRec
We already have state fully stored within XKB, so instead of duplicating it,
just generate the values to send to clients when required.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:55 +11:00
Daniel Stone 08363c5830 Input: Overhaul keyboard initialisation process
XkbInitKeyboardDeviceStruct is now the only valid keyboard
initialisation: all the details are hidden behind here.  This now makes
it impossible to supply a core keymap at startup.

If dev->key is valid, dev->key->xkbInfo->desc is also valid.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:08:51 +11:00
Daniel Stone 40877c6680 XKB: Make XKB mandatory
No more #ifdef XKB, because you can't disable the build, and no more
noXkbExtension either.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-22 15:06:25 +11:00
Daniel Stone 5c281446d2 XKB: Remove lock actions disabling
For some reason, XKB allows clients to set a global (!) flag that simply
turns lock keys into state no-ops.  Ignore this flag.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-01-22 14:23:24 +11:00
Daniel Stone e1611d8d55 XKB: Be more verbose about XkbCopyKeymap failure in debug mode
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 15:32:19 +11:00
Daniel Stone 5ee504cae5 XKB: Trying to copy to the same keymap is not fatal
Humour the user if they run XkbCopyKeymap(foo, foo).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 15:32:19 +11:00
Daniel Stone 534669b376 XKB: Remove unnecessary prototype
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 15:32:19 +11:00
Daniel Stone 27ea1a7e4e XKB: Only Xi events are processed
Core events aren't run through these functions, so don't bother testing
for them.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 15:32:19 +11:00
Daniel Stone 2762cafc32 XkbCopyKeymap: inputInfo.keyboard is not a special case
The device-walking code is still depressing, though.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 15:32:18 +11:00
Daniel Stone 07c3bb922b XKB: Move XkbCopyKeymap definition to xkbsrv.h
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-20 15:32:18 +11:00
Daniel Stone 23862ede59 XKB: Allow build-time configuration of XKB defaults
Instead of hardcoding base/pc105/us, allow users to change the defaults at
./configure time.  Change the default model to be evdev on Linux.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-01-20 15:32:18 +11:00
Peter Hutterer d645721170 mi: ensure chained button mappings from SD -> MD (#19282)
After copying the master event, flip the detail field to the mapped button of
the SD, not the physical button. This way if the SD has a mapping 1:3 and the
MD has a mapping of 3:4, a press on button 1 on the SD results in a core event
on button 4.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-15 09:28:01 +10:00
Julien Cristau 7f82114b1d xkb: ANSI cleanup 2009-01-11 08:54:12 +01:00
Peter Hutterer 515ce3e4ba xkb: fix typo - missing negation when checking button state.
Introduced with a85f0d6b98.

Reported by Thomas Jaeger.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-01-08 11:45:21 +10:00
Daniel Stone 48dbaf173a XKB: Also copy keyboard feedback when copying the keymap
When updating the XKB keymap, make sure the keyboard feedback is also
copied, to preserve autorepeat settings etc.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2008-12-30 12:17:14 +11:00
Peter Hutterer 25aac8b579 xkb: don't treat groups with different no of symbols as identical.
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-23 09:02:28 +10:00
Peter Hutterer f141c1b4bb xkb: explicitly check for group replication in the core representation.
Single-group keys may get replicated amongst all groups. Check explicitly for
this case and squash it down to one group.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-23 09:02:28 +10:00
Peter Hutterer 70a977c021 xkb: don't replicate past the number of groups we have.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-12-23 09:02:28 +10:00
Peter Hutterer a157575eee xkb: ensure enough symbols for core Group1 replication.
A single-group key on a multi-group keyboard has to be replicated across all
three groups (see Section 12.4 of the XKB protocol spec). Ensure that there's
enough symbols available to actually do that.

e.g. a key ABCD on a 3 group keyboard needs to be replicated as ABABCDCDABCD,
hence requiring space for 12 symbols, even if maxSymsPerKey is less than that.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-23 09:02:28 +10:00
Peter Hutterer cb95642dc8 Remove #define NEED_EVENTS and NEED_REPLIES
A grep on xorg/* revealed there's no consumer of this define.

Quote Alan Coopersmith:
"The consumer was in past versions of the headers now located
in proto/x11proto - for instance, in X11R6.0's xc/include/Xproto.h,
all the event definitions were only available if NEED_EVENTS were
defined, and all the reply definitions required NEED_REPLIES.

Looks like Xproto.h dropped them by X11R6.3, which didn't have
the #ifdef's anymore, so these are truly ancient now."

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2008-12-12 11:43:32 +10:00
Peter Hutterer d281866b74 mi: Clean up CopyGetMasterEvent, re-use the memory.
Alloc an EventList once and then re-use instead of allocing a new event each
time we need a master event.
There's a trick included: because all the event processing handlers only take
an xEvent, init a size 1 EventList and squash the events into this one.

Events that have count > 1 must be squished into an xEvent array anyway before
passing into the event handlers, so we don't lose anything here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2008-12-10 12:42:45 +10:00
Sascha Hlusiak bbf811514d ddxCtrls.c: XkbDDXUsesSoftRepeat always returns 1 now
We'd like to do soft repeat in the server for all keys. Remove obscure check, that'd
prevent the server from autorepeating when delay is set to exactly 660ms and rate is
set to exactly 25 (interval=40).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2008-12-08 12:24:39 +01:00
Paulo Cesar Pereira de Andrade 49f77fff14 Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.

  This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)

  LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.

  xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
Peter Hutterer 463e02e7de xkb: Allow NULL as rulesFile in XkbSetRulesDflts.
If no rules file is given, simply re-use the previous one. If no RF is given
the first time this function is called, use the built-in default.
This includes fixing the built-in default to something that actually exists.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-03 16:10:40 +10:00
Peter Hutterer 95fc59a199 xkb: Extra sanity checks to prevent dev->key == NULL dereferencing. 2008-12-02 15:50:38 +10:00
Peter Hutterer a425abf0ea xkb: don't attempt to filter events for devices without key classes.
Reported by Magnus Kessler.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-02 15:50:37 +10:00
Peter Hutterer a85f0d6b98 Xi: fix use of button->down - bitflags instead of int arrays.
The device's button down state array was changed to use DOWN_LENGTH and thus
bitflags for each button in cfcb3da7.

Update the DBSN events to copy this bit-wise state.
Update xkb and Xi to check for the bit flag instead of the array value.

Reported by ajax.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-12-02 15:50:37 +10:00
Paulo Cesar Pereira de Andrade 16b11cd03d Correct static symbol XkmReadTOC and first pass on compile warning fixes.
The warnings corrected were only the ones that should correct
real problems. The most common one is 64 bit integers as
"printf %l" arguments.
  Note that there is a patch related to this at:
http://bugs.freedesktop.org/show_bug.cgi?id=18204
2008-11-30 02:59:34 -02:00
Paulo Cesar Pereira de Andrade d6cbd4511e Export symbols defined in the sdk.
This is the biggest "visibility" patch. Instead of doing a "export"
symbol on demand, export everything in the sdk, so that if some module
fails due to an unresolved symbol, it is because it is using a symbol
not in the sdk.

  Most exported symbols shouldn't really be made visible, neither
advertised in the sdk, as they are only used by a single shared object.

  Symbols in the sdk (or referenced in sdk macros), but not defined
anywhere include:
XkbBuildCoreState()
XkbInitialMap
XkbXIUnsupported
XkbCheckActionVMods()
XkbSendCompatNotify()
XkbDDXFakePointerButton()
XkbDDXApplyConfig()
_XkbStrCaseCmp()
_XkbErrMessages[]
_XkbErrCode
_XkbErrLocation
_XkbErrData
XkbAccessXDetailText()
XkbNKNDetailMaskText()
XkbLookupGroupAndLevel()
XkbInitAtoms()
XkbGetOrderedDrawables()
XkbFreeOrderedDrawables()
XkbConvertXkbComponents()
XkbWriteXKBSemantics()
XkbWriteXKBLayout()
XkbWriteXKBKeymap()
XkbWriteXKBFile()
XkbWriteCFile()
XkbWriteXKMFile()
XkbWriteToServer()
XkbMergeFile()
XkmFindTOCEntry()
XkmReadFileSection()
XkmReadFileSectionName()
InitExtInput()
xf86CheckButton()
xf86SwitchCoreDevice()
RamDacSetGamma()
RamDacRestoreDACValues()
xf86Bpp
xf86ConfigPix24
xf86MouseCflags[]
xf86SupportedMouseTypes[]
xf86NumMouseTypes
xf86ChangeBusIndex()
xf86EntityEnter()
xf86EntityLeave()
xf86WrapperInit()
xf86RingBell()
xf86findOptionBoolean()
xf86debugListOptions()
LoadSubModuleLocal()
LoaderSymbolLocal()
getInt10Rec()
xf86CurrentScreen
xf86ReallocatePciResources()
xf86NewSerialNumber()
xf86RandRSetInitialMode()
fbCompositeSolidMask_nx1xn
fbCompositeSolidMask_nx8888x0565C
fbCompositeSolidMask_nx8888x8888C
fbCompositeSolidMask_nx8x0565
fbCompositeSolidMask_nx8x0888
fbCompositeSolidMask_nx8x8888
fbCompositeSrc_0565x0565
fbCompositeSrc_8888x0565
fbCompositeSrc_8888x0888
fbCompositeSrc_8888x8888
fbCompositeSrcAdd_1000x1000
fbCompositeSrcAdd_8000x8000
fbCompositeSrcAdd_8888x8888
fbGeneration
fbIn
fbOver
fbOver24
fbOverlayGeneration
fbRasterizeEdges
fbRestoreAreas
fbSaveAreas
composeFunctions
VBEBuildVbeModeList()
VBECalcVbeModeIndex()
TIramdac3030CalculateMNPForClock()
shadowBufPtr
shadowFindBuf()
miRRGetScreenInfo()
RRSetScreenConfig()
RRModePruneUnused()
PixmanImageFromPicture()
extern int miPointerGetMotionEvents()
miClipPicture()
miRasterizeTriangle()
fbPush1toN()
fbInitializeBackingStore()
ddxBeforeReset()
SetupSprite()
InitSprite()
DGADeliverEvent()

  SPECIAL CASES
o defined as _X_INTERNAL
	xf86NewInputDevice()
o defined as static
	fbGCPrivateKey
	fbOverlayScreenPrivateKey
	fbScreenPrivateKey
	fbWinPrivateKey
o defined in libXfont.so, but declared in xorg/dixfont.h
	GetGlyphs()
	QueryGlyphExtents()
	QueryTextExtents()
	ParseGlyphCachingMode()
	InitGlyphCaching()
	SetGlyphCachingMode()
2008-11-29 23:56:06 -02:00
Alan Coopersmith d5ad296869 Remove duplication from code paths in XkbDDXCompileKeymapByNames 2008-11-25 15:51:17 -08:00
Alan Coopersmith 1cd894173e Always use server-<display>.xkm to avoid races when multiple servers start
Previously each server starting ran xkbcomp with the output set to
<keymapname>.xkm, read it, then deleted it - which led to races if
two servers were starting at the same time with the same keymap.

Sun bug #6773816 Xorg uses the same xkm output file for compiled keymap file
  <http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6773816>
2008-11-20 14:02:11 -08:00
James Cloos b3c7e62664 Remove some null statements.
Remove several doubled statement-terminal semicolons.

Reported by Fernando Carrijo.
2008-11-08 12:21:20 -05:00
Peter Hutterer de1a8b68eb xkb: extract the correct device in XkbFilterEvents.
If the event is an XI event, we need to work on the correct device, not on
the VCK.

Adds XIGetDevice(event) function to extract the device from an event.
2008-11-04 16:04:16 +10:30
Peter Hutterer cbc6f98395 xkb: when faking mouse button events, fake them on the correct devices.
When MouseKeys are activated, keyboard devices may generate fake mouse button
events through XKB. Let's get then running through the appropriate paths, i.e.
as XI events on the correct device.

To make matters more fun, ProcessOtherEvents drops events if the DIX device
state cannot be updated accordingly, i.e. all button events from keyboard
devices.
Hence we need to get the paired MD for the device in XkbDDXFakeDeviceButton,
and post the event through the paired MD (usually the VCP).

Removes now-unused ddxFakeBtn.c.

Note: this patch only half-arsedly fixed button events, motion events are a
more complicated matter.
2008-11-04 16:04:15 +10:30
Daniel Stone 064ee458c7 XKB: Tiny cleanups to _XkbLookupAnyDevice
A couple of coding style cleanups, a warning fix via removing a
now-unused label, and also put an else so we don't spuriously trip a
condition that should admittedly never occur anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-11-04 16:01:41 +10:30
Daniel Stone 97c9e6a713 XKB: Fix thinko, causing warning (erroneously fixed in 5544c51447)
newTypes is a local variable which always has an address.  newTypesIn,
on the other hand, might be sus.

See also 5544c51447.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-11-04 16:01:07 +10:30
Peter Hutterer 0a076b6a7f xkb: remove unused label "out", clean up program flow. 2008-10-31 18:36:14 +10:30
Peter Hutterer b6b26560d6 Move EXTENSION_BASE and EXTENSION_EVENT_BASE to misc.h. 2008-10-31 17:09:13 +10:30
Peter Hutterer 245d1c162c xkb: ProcXkbSetCompatMap should do dry-runs, then normal runs.
Was doing only dry-runs, which kinda explains why changing the compat map
didn't really have any effect.
Fallout from e8c2a3d7c9.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-10-31 16:00:48 +10:30
Peter Hutterer 30c3c13f10 xkb: squash canonical types into explicit ones on core reconstruction.
If we update key types from core, and groups 2 - n have a canonical type but
the same symbols as the explicit type of group 1, assume that it was a core
sym duplication according to Section 12.4 of the XKB Protocol Spec.
Ignore the canonical types and pretend there's only one group for the key -
with the explicit key type.

The protocol spec does not cover this case, so we have to guess here.
2008-09-26 09:33:39 +09:30
Peter Hutterer ae986d1c73 xkb: fix core keyboard map generation. #14373
According to Section 12.4 of the XKB Protocol Spec, if a key only has a single
group but the keyboard has multiple groups defined, the core description of
the key is a duplication of the single group across all symbols. i.e.
G1L1 G1L2 G1L1 G1L2 G1L3 G1L4 G1L3 G1L4

The previous code generated G1L1 G1L2 G1L3 G1L4 G1L3 G1L4, leading to
"invented" groups when the process is reversed.

Note that this creates wrong key types on reconstruction from core to xkb,
i.e. any single-group key with a key type that is not one of the canonical
four (Sec 12.2.3), will get the assigned type on group 1, and a canonical type
for the other gruops.

X.Org Bug 14373 <http://bugs.freedesktop.org/show_bug.cgi?id=14373>
2008-09-26 09:33:39 +09:30
Kim Woelders 8c46505d7d xkb: fix use of uninitialized variable.
And some cosmetic changes to use stuff->change consistently.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
2008-09-22 08:37:29 +09:30
Tomas Carnecky ebea78cdba Prepare for array-index based devPrivates.
TODO: static indices can be made just an int; some indices
can be combined.
2008-08-28 18:05:40 -04:00