Commit Graph

585 Commits

Author SHA1 Message Date
Peter Hutterer 732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Keith Packard da70c7d556 xkb: Initialize 'bad' Atom in _XkbSetNamesCheck
When _XkbCheckAtoms returns NULL for an error, it always sets the
error return code, but GCC can't figure that out, so just initialize
the local variable, 'bad', in _XkbSetNamesCheck to eliminate the warning.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-10-28 11:26:23 -07:00
Adam Jackson a5e7701058 xkb: Remove some fascinating paranoia from event emission
XkbInterestPtrs are created by clients that already exist, meaning,
clients that have already had ProcVector installed as something other
than InitialProcVector.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-07-29 09:53:45 -04:00
Keith Packard c7011249d2 xkb: Verify reads of compiled keymap header and TOC
Check the return values from fread to make sure the elements are
actually getting read from the file.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2014-04-18 16:30:18 -07:00
Peter Hutterer 98924719d5 Revert "xkb: ProcesssPointerEvent must work on the VCP if it gets the VCP"
This was the wrong fix to the problem, and it triggered a change in XKB
behavior: previously a button event would unlock a latched modifier, now it
doesn't anymore.
https://bugs.freedesktop.org/show_bug.cgi?id=73155

Note that the new behavior is is strictly spec compliant but we've had the
other behavior for a long time so we shouldn't break it.

The bug this patch originally fixed was a null-pointer dereference when
releasing button events on server shutdown. This was addressed by the commit
below, so the need for this patch has gone away anyway.

commit 3e4be4033a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jan 25 11:47:32 2013 +1000

    dix: when shutting down slave devices, shut down xtest devices last

This reverts commit 2decff6393.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-04-03 14:17:40 +10:00
Adam Jackson 78167a98a8 xkb: Restore XkbCopyDeviceKeymap
Removed in d35a02a767, tigervnc 1.2.80 and
xf86-video-nested need it for now.

Signed-off-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>
2014-03-25 08:50:35 +10:00
Kristian Høgsberg 0e531fbb97 xkb: add XkbLoadKeymapFromString
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-19 08:37:15 +10:00
Kristian Høgsberg 8b6c79e19c xkb: add KeymapOrDefault
Helper function to return a default map if the keymap compilation failed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-17 15:10:47 +10:00
Kristian Høgsberg cb9a1d0146 xkb: factor out xkb loading to LoadXkm
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-17 15:10:37 +10:00
Peter Hutterer 4391cf27f4 xkb: add a callback to xkbcomp
This provides a callback to write to xkbcomp's buffer once everything is
prepared.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-17 15:10:31 +10:00
Peter Hutterer 6ebd838d80 xkb: constify XkbDDXOpenConfigFile
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-17 15:10:07 +10:00
Rui Matos d35a02a767 xkb: Repurpose XkbCopyDeviceKeymap to apply a given keymap to a device
This will also make it useful for cases when we have a new keymap to
apply to a device but don't have a source device.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-12 16:43:23 +10:00
Rui Matos 361f405d3c xkb: Factor out a function to copy a keymap's controls onto another
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-12 15:45:38 +10:00
Peter Hutterer 45fb3a934d xkb: push locked modifier state down to attached slave devices
Whenever the master changes, push the locked modifier state to the attached
slave devices, then update the indicators. This way, when NumLock or CapsLock
are hit on any device, the LED will light up on all devices. Likewise, a new
keyboard attached to a master device will light up with the correct
indicators.

The indicators are handled per-keyboard, depending on the layout, i.e. if one
keyboard has grp_led:num set, the NumLock LED won't light up on that keyboard.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-03-11 17:43:34 +10:00
Peter Hutterer 656841798c xkb: factor out state update into a function
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-03-11 17:43:34 +10:00
Peter Hutterer dda2468e57 xkb: factor out the StateNotify flag check
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-03-11 17:43:34 +10:00
Peter Hutterer 2fc38d1e29 xkb: add a call to init an XkbRMLVOSet from const chars
Just forcing everything to const char* is not helpful, compiler warnings are
supposed to warn about broken code. Forcing everything to const when it
clearly isn't less than ideal.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-02-04 10:53:59 +10:00
Keith Packard 60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Keith Packard eda9356271 xkb: Make XkbWriteCountedString take a const char * input parameter
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:50 -08:00
Keith Packard 6e51645b47 xkb: Clean up warnings
Add const to lots of strings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Julien Cristau a2d6932ad4 xkb: don't call atoi(NULL) when parsing argv
If the -ardelay or -arinterval options have no argument, there's no
point trying to read it.

See
http://www.forallsecure.com/bug-reports/feb3db57fc206d8df22ca53a6907f74973876272/

Reported-by: Alexandre Rebert <alexandre@cmu.edu>
Signed-off-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-02 15:12:29 +10:00
Peter Hutterer 2f1aedcaed input: print warnings if drivers don't initialize properly
If drivers supply incorrect values don't just quietly return False, spew to
the log so we can detect what's going on. All these cases are driver bugs
and should be fixed immediately.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2013-05-10 11:05:00 +10:00
Peter Hutterer 8a88b0ab52 dix: don't overwrite proximity/focus classes
InitPointerClassDeviceStruct/InitKeyboardDeviceStruct allocate a
proximity/focus class, respectively. If a driver calls
InitFocusClassDeviceStruct or InitProximityClassDeviceStruct beforehand,
the previously allocated class is overwritten, leaking the memory.

Neither takes a parameter other than the device, so we can simply skip
initialising it if we already have one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2013-05-10 11:04:53 +10:00
Peter Hutterer 6f44d672aa xkb: free XkbRulesUsed and XkbRulesDflt on extension cleanup
==2547== 1 bytes in 1 blocks are still reachable in loss record 1 of 111
==2547==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==2547==    by 0x64D1551: strdup (strdup.c:43)
==2547==    by 0x4802FB: Xstrdup (utils.c:1113)
==2547==    by 0x585B6C: XkbSetRulesUsed (xkbInit.c:219)
==2547==    by 0x58700F: InitKeyboardDeviceStruct (xkbInit.c:595)
==2547==    by 0x419FA3: vfbKeybdProc (InitInput.c:74)
==2547==    by 0x425A3D: ActivateDevice (devices.c:540)
==2547==    by 0x425F65: InitAndStartDevices (devices.c:713)
==2547==    by 0x5ACA57: main (main.c:259)

and a few more of the above.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:40:51 +10:00
Andreas Wettstein 0f537da72d xkb: Fixes to LatchMods/LatchGroup
The main problem this patch addresses is that if a latch is put on
multi-level key with a Latch/Lock/Set, it is possible that after all
keys are released, still base modifiers are set, which typically will
make the keyboard unusable.  To see how it happens (without the patch),
assume that key AltGr sets Mod5 when pressed by itself, and latches Mod3
when pressed together with Shift.  Now press Shift, then AltGr and
release both keys in reverse order.  Mod3 is now latched, and the
LatchMods filter remains active as the second filter.  Now press AltGr;
Mod5 base modifier gets set, and the SetMods filter will become active
as the first filter.  Release AltGr: First, the SetMods filter will set
clearMods to Mod5, then the LatchMods filter will overwrite clearMods
with Mod3.  Result: the Mod5 base modifier will remain set.  This
example becomes practically relevant for the revised German standard
layout (DIN 2137-1:2012-06).

Other changes implement the latch behaviour more accurately according to
the specification.  For example, releasing a modifier latching key can
at the same time clear a locked modifier, promote another modifier that
is latched to locked, and latch a third modifier.  Overall, what the
code does should be straightforward to compare what the XKB protocol
specification demands, see the table in section 6.3.

Finally, releasing a key no longer cancels a latch that has not become
pending yet.  In my opinion, the specification is not clear; it speaks
of "operating" a key, which the patch effectivly interprets as "press"
rather than "press or release".  From my experience, using the latter
interpretation makes latches on higher levels practically unusable.  In
the example given above, one would have to release AltGr always before
Shift to get the Mod3-Latch.  The practical relevance of latches on
higher levels is once more given by the revised German standard layout.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-03-06 11:22:38 +10:00
Peter Harris e27b2e6163 xkb: Set nIndicators in XkbGetIndicatorMap
Xlib doesn't use this value (it computes it from the reply length
instead) which is why nobody has noticed yet. But the spec
http://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html
says that it should be set.

Signed-off-by: Peter Harris <pharris@opentext.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-21 10:07:22 +10:00
Peter Hutterer 6133c41759 xkb: remove unused variable 'names'
xkb.c: In function '_XkbSetNamesCheck':
xkb.c:3987:18: warning: variable 'names' set but not used
[-Wunused-but-set-variable]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
2013-02-15 11:58:38 +10:00
Andreas Wettstein b33fcb1497 xkb: Fix repeat behaviour of redirect and message actions
The redirect and the message action filter functions implicitly assumed that
when they receive an event for the same keycode they were activated for, that
this is the a release of the key that activated the filter.  This is not true
if the key autorepeats.  Due to the incorrect assumption, the effective key
repeat rate was effectively halved.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-08 13:54:09 +10:00
Andreas Wettstein 3578cc3c2e xkb: Do not use base group as an array index.
The base group is not brought into range and, therefore, using it as an array
index crashed the X server.  Also, at this place, we should ignore locked
groups, but not latched groups.  Therefore, use sum of base and latched groups,
brought into range.

Reproducible with:
key <FK07> {
    type= "ONE_LEVEL",
    symbols[Group1]= [              NoSymbol ],
    actions[Group1]= [ LatchGroup(group=-1, clearLocks) ]
};

And hitting F7 will exceed the group level and access arbitrary memory.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-01-09 11:23:12 +10:00
Keith Packard 0eb1559eb2 Merge remote-tracking branch 'yselkowitz/master'
I checked this patch with diff -w to check that it only affected
whitespace.
2012-12-19 12:22:03 -08:00
Yaakov Selkowitz ea1d76d1b6 Fix formatting of address operators
The formatter confused address operators preceded by casts with
bitwise-and expressions, placing spaces on either side of both.
That syntax isn't used by ordinary address operators, however,
so fix them for consistency.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05 18:09:48 -06:00
Peter Hutterer 5daa442fe1 xkb: only post a XTest release if the XTest device has the button down
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05 17:22:28 +10:00
Peter Hutterer c4fee9d2ec xkb: always post XTest button up when the physical button released (#28808)
Regression introduced by commit 2decff6393
  xkb: ProcesssPointerEvent must work on the VCP if it gets the VCP

XTest buttons must be released when a physical button is released. This was
fixed in 1432785839, but
2decff6393 changed a condition that this code
didn't get triggered anymore.

"dev" for pointer events is now always the VCP which doesn't have a xkbi
struct. So move this condition out and always trigger the XTest released for
button events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Frank Roscher <Frank-Roscher@gmx.net>
2012-12-05 17:22:18 +10:00
Peter Hutterer 2c4388a00e xkb: fill in keycode and event type for slow keys enablement
eventType is set for the type that triggered a XkbControlsNotify event.
Technically, SlowKeys is triggered by a timer which doesn't have a matching
core event type. So we used to use 0 here.

Practically, the timer is triggered by a key press + hold and cancelled when
the key is released before the timeout expires. So we might as well set
KeyPress (keycode) in the ControlsNotify to give clients a chance to differ
between timer-triggered SlowKeys and client-triggered ones.

This is a chance in behaviour, though I suspect with little impact.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2012-11-29 14:48:54 +10:00
Daniel Stone 710065da37 XKB: Remove component listing support
No-one uses this - not xkbcomp, not GNOME, not KDE.  The preferred way
to deal with component listing (which gives you RMLVO rather than
KcCGST) is to use the XML files on the client side.

Indeed, a couple of hours after making this commit, it emerged that all
*.dir files built with xkbcomp 1.1.1 (released two years ago) and later
have been catastrophically broken and nearly empty.  So I think that's
reasonable proof that no-one uses them.

Signed-off-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>
2012-11-19 12:12:28 +10:00
Keith Packard 011f845880 Merge remote-tracking branch 'whot/for-keith' 2012-11-05 17:16:07 -08:00
Alexey Ten (Lynn) 5b7384a315 Apply partial matches for option (#25873)
Rules which match star (*) and option, like one below, should be applied

layout[2] option    = symbols
*         misc:typo = +typo(base)

This is port of patch from #19563 (https://bugs.freedesktop.org/19563)
because here we have own copy of maprules.c

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

Signed-off-by: Alexey Ten (Lynn) <alexeyten@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-06 10:48:32 +10:00
Yaakov Selkowitz 344eea237f xkb: fix shadow warnings
Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-05 13:25:05 -06:00
Peter Hutterer 2decff6393 xkb: ProcesssPointerEvent must work on the VCP if it gets the VCP
For button release events, the current code picks the VCK. Because that has
a XKB struct, it thinks this is a PointerKeys event and proceeds to send the
release event through the XTest pointer. That has no effect in normal
operation as the button is never down and an attempt is silently discarded
(normal event processing continues with the VCP).

On server shutdown, the XTest device is already removed, leading to a
null-pointer derefernce when the device is checked for whether buttons are
down (XkbFakeDeviceButton → button_is_down(xtest pointer)).

The current state has only worked by accident, the right approach here is to
handle the VCP's event as such and not switch to the keyboard.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-10-29 13:15:50 +10:00
Keith Packard 75966a4186 xwin: Clean up os wrappers for System, Popen and Pclose on Windows
Popen and Pclose are never used on Windows, so don't bother to even
try to define them.

System(s) was defined as system(s), but the two users of that
function are in xkb, which carefully redefines that as
Win32System. Move Win32System and Win32TempDir to os/utils.c, renaming
Win32System to be just System, which simplifies the xkb code

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-07-17 16:08:04 +01:00
Daniel Stone 06e4ba8b26 XKB: Geom: Remove unused code
These codepaths were never called by anyone.  Shame there weren't more
of them.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-10 00:42:09 -07:00
Daniel Stone a1d41e311c Move extension initialisation prototypes into extinit.h
Create extinit.h (and xf86Extensions.h, for Xorg-specific extensions) to
hold all our extension initialisation prototypes, rather than
duplicating them everywhere.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 23:06:41 -07:00
Alan Coopersmith 9805cedf7b Use C99 designated initializers in extension Events
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith a406bd0759 Use C99 designated initializers in xkb Replies
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 19:58:30 -07:00
Alan Coopersmith 789d64e19a Remove unneccesary casts from WriteToClient calls
Casting return to (void) was used to tell lint that you intended
to ignore the return value, so it didn't warn you about it.

Casting the third argument to (char *) was used as the most generic
pointer type in the days before compilers supported C89 (void *)
(except for a couple places it's used for byte-sized pointer math).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 19:12:56 -07:00
Peter Hutterer 252a69b592 xkb: use local variable instead of casting arg
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-04 21:16:16 +10:00
Peter Hutterer ff41753b1b xkb: warn if XKB SlowKeys have been automatically enabled
Slow keys are enabled when the XKB AccessX features are generally enabled
(ctrls->enabled_ctrls & XkbAccessXKeysMask) and either shift key is held for
8 seconds. For the unsuspecting user this appears as if the keyboard
suddenly stops working.

Print a warning to the log, so we can later tell them "told you so".

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2012-06-07 07:23:56 +10:00
Siddhesh Poyarekar 42ae2e8199 xkb: Allocate size_syms correctly when width of a type increases
The current code seems to skip syms with width less than
type->num_levels when calculating the total size for the new
size_syms. This leads to less space being allocated than necessary
during the next phase, which is to copy over the syms to the new
location. This results in an overflow leading to a crash.

Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-06-04 11:28:44 +10:00
Michal Suchanek c59c9dac84 xkb: Remove redundant declarations.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-05-14 13:16:50 +01:00
Andreas Wettstein 9e017cf0cf XKB: Redirect actions defunct with Gtk3 (XInput?)
When redirect actions are used with Gtk3, Gtk3 complained about
events not holding a GdkDevice.  This was caused by device IDs
not being set for redirect actions.

More seriously, Gtk3 did not receive state changes redirect
actions might specify.  This was because event_set_state in
dix/inpututils.c accesses the prev_state field, but the changes
for the redirect action were only put into the state field.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-03-22 11:33:18 +10:00
Daniel Stone ab3a815a75 Indentation: Change '& stuff' to '&stuff'
If the typedef wasn't perfect, indent would get confused and change:
    foo = (SomePointlessTypedef *) &stuff[1];
to:
    foo = (SomePointlessTypedef *) & stuff[1];

Fix this up with a really naïve sed script, plus some hand-editing to
change some false positives in XKB back.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-21 14:02:30 -07:00
Keith Packard 9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Andreas Wettstein 6b19436536 xkb: Message actions suppress other key presses #28575
When a key to which a message action is mapped is held down, presses of
other keys were not registered.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-01-09 10:51:13 +10:00
Alan Coopersmith 41dd7cf673 _XkbFilterDeviceBtn: move variable declarations to match usage scope
The main body of this function is an if { } else if { } pair of blocks.
Previously there was int button at the top level scope which is used
only in the first block, and a redeclaration of int button inside the
second block.   Since there's no overlap in the code paths for the
two uses of button, move the one from the outer block into the first
block to help the programmer more quickly determine they are unrelated
usages, and to silence the gcc warning of:

xkbActions.c: In function '_XkbFilterDeviceBtn':
xkbActions.c:999:6: warning: declaration of 'button' shadows a previous local
xkbActions.c:955:6: warning: shadowed declaration is here

For consistency, move DeviceIntPtr dev declarations as well that are
used in the same way.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:11 -08:00
Alan Coopersmith d8eb9b5faa XkbFindSrvLedInfo: remove extraneous name-clashing sli variable
Variable is already defined outside the outer if statement, and
there's no need to redefine inside the if statement.

No point in setting sli before if (dev->kbdfeed->xkb_sli==NULL)
check - if check is true, we immediately set it, if check is false,
we immediately return without further reference or use of it.

The one thing we do with it inside the inner if statement is store
an allocation in it for a brief moment before writing to the final
destination, which is immediately returned to the caller.

In short, there's no benefit to the variable at all in this block,
it just gives the optimizer more code to figure out how to omit.

Fixes gcc warning:
xkbLEDs.c: In function 'XkbFindSrvLedInfo':
xkbLEDs.c:683:19: warning: declaration of 'sli' shadows a previous local
xkbLEDs.c:679:18: warning: shadowed declaration is here

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:11 -08:00
Alan Coopersmith 232f1ddf3d Fix gcc -Wwrite-strings warnings in XkbGetRulesDflts
Stop temporarily storing a pointer to a constant literal string
in a char *, just to strdup it a few lines later.

Fixes gcc -Wwrite-strings warnings:

xkbInit.c: In function 'XkbGetRulesDflts':
xkbInit.c:121:38: warning: assignment discards qualifiers from pointer target type
xkbInit.c:123:23: warning: assignment discards qualifiers from pointer target type
xkbInit.c:125:24: warning: assignment discards qualifiers from pointer target type
xkbInit.c:127:25: warning: assignment discards qualifiers from pointer target type
xkbInit.c:129:25: warning: assignment discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:07 -08:00
Alan Coopersmith f8dd5efb67 Mark XKB char * as const to clean up gcc -Wwrite-strings warnings
Cleans up around 120 warnings from this set

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith 3d0ece5e84 Reduce unnecessary string copying in xkbtext routines
Instead of using sprintf to copy a static string to a local buffer,
just to pass it to TryCopyStr, pass the static string to TryCopyStr
directly, as is already done in other parts of this code.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith 05d8a7f7a7 Convert a bunch of sprintf to snprintf calls
This batch is the straightforward set - others are more complex and
need more analysis to determine right size to pass.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith 615f93a3d0 Remove unnecessary variable rtrn in XkbKeysymText
Also removes even more unnecessary use of variable assignment inside
function arguments.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-11-23 12:15:06 -08:00
Alan Coopersmith 6e6d732bac Convert strncpy/strncat to strlcpy/strlcat
As long as we're carrying around a compatibility copy in os/strl*.c,
might as well use them.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:05 -08:00
Peter Hutterer 35ec24cf24 input: replace remaining GetPairedDevice() with GetMaster()
Wherever it's obvious which device we need (keyboard or pointer), use
GetMaster() instead of GetPairedDevice(). It is more reliable in actually
getting the device type we want.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-11-09 13:26:47 +10:00
Colin Harrison f6529a05a2 Xming: Always remove temporary file used when invoking xkbcomp on Win32
When built for native Win32, pipe() & fork() aren't available, so we
use a tempoary file and system() to invoke xkbcomp

Ensure the temporary file is always removed. It was only being removed
on most errors, not on success :S

Also fix a couple of warnings which occur when built with WIN32 defined

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2011-11-02 14:07:36 +00:00
Andreas Wettstein e3f6a76dd4 xkb: Support noLock and noUnlock flags for LockMods
These flags are required by the XKB spec section 6.3.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-25 14:06:41 +10:00
Alan Coopersmith 524e5445c0 Add #include "inpututils.h" to xkbAccessX.c for init_device_event
Fixes Sun compiler warning:
"xkbAccessX.c", line 128: warning: implicit function declaration: init_device_event

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-03 08:54:09 +10:00
Keith Packard afb1fe695d Merge remote-tracking branch 'whot/next' 2011-09-26 20:24:15 -07:00
Peter Harris c90903b4f7 xkb: add missing swaps for xkbGetDeviceInfoReply
Caught during review of e095369bf.

Signed-off-by: Peter Harris <pharris@opentext.com>
Reviewed-by-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:14:45 -04:00
Matt Turner 54770c980c Cast char* buffers to swap functions
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:14:44 -04:00
Matt Turner 9edcae78c4 Use correct swap{l,s} (or none at all for CARD8)
Swapping the wrong size was never caught because swap{l,s} are macros.

It's clear in the case of Xext/xres.c, that the author believed
client_major/minor to be CARD16 from looking at the code in the first
hunk.

v2: dmx.c fixes from Keith.

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:14:16 -04:00
Matt Turner 2c7c520cfe Use internal temp variable for swap macros
Also, fix whitespace, mainly around
	swaps(&rep.sequenceNumber)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:12:04 -04:00
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