Commit Graph

116 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult 691b51cfb8 xkb: unexport _XkbLookup*() functions
Not used by any drivers, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult 3bd240cdee xkb: unexport notification sender functions
These aren't used by any drivers, so no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult 827277821b xkb: unexport rules management functions
These aren't called by any driver, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult 3029236cf3 xkb: unexport key latch functions
These aren't used by drivers, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult d16cd74129 xkb: unexport DDX entry points
These functions are entry points of the DDX (or stubs thereof), not supposed
to be called by any drivers, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult fd7cf62ccc xkb: unexport client resource functions
These aren't used by any drivers, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult 97b98c18c3 xkb: unexport AccessX* functions
These aren't used by any drivers, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult 3970fa674b xkb: unexport internal variables
These aren't used by any drivers/modules, and it doesn't seem make much
sense doing so, thus no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:45 +02:00
Enrico Weigelt, metux IT consult a07e572665 xkb: unexport XKBDEVICEINFO() and xkbDevicePrivateKeyRec
These aren't used by any drivers/modules, so no need to keep 'em exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult adf2ca2907 xkb: move event mask defines int private header
These are only used inside xkb internally, no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult 1ed2685712 xkb: move *WRAP*() macros into private header
These are only used inside xkb internally, so no need to keep them
in a public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult cfcf686484 xkb: move _XkbErrCode*() macros into private header
These are only used internally in xkb, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult 4638d865f7 xkb: move _XkbLibError macro into private header
It's only used internally in xkb.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult 2d22dea09b xkb: move _XkbStateNotifyInProgress define into private header
It's only used in xkb internally.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult 89cf70a31f xkb: move _XkbClient* flags into private header
These are only used by xkb internally.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult ed6fb03363 xkb: move XkbSLI_IsDefault() and XkbSLI_HasOwnState() into private header
These macros aren't used by any drivers, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult e4f93dd59a xkb: move XkbSetCause* macros into private header.
These aren't used by any drivers/modules, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult c4c2150423 xkb: move _BEEP_* defines into private header
These are only used inside xkb, not by any drivers, so no need to
keep them in public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:44 +02:00
Enrico Weigelt, metux IT consult f8fc46cbbf include: drop now empty xkbfile.h
This (public) file isn't used by anybody outside Xserver tree
and doesn't contain anything useful anymore, so lets drop it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1729>
2025-02-06 22:45:25 +00:00
Enrico Weigelt, metux IT consult cdb4d5648a kbd: move _XkbWantsDetectableAutoRepeat() macro into dix/events.c
That's the only place where it is used, so no need to keep it
in a public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1462>
2024-06-18 02:10:04 +00:00
Enrico Weigelt, metux IT consult bae6cbc8ca include: move private defs to dixstruct_priv.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to dixstruct_priv.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Enrico Weigelt, metux IT consult feb5c785fc xkb: move *_TIMER defines into xkbAccessX.c
These are only used in this file (and also not any external driver),
so no need to have them in a public header file.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1459>
2024-04-23 02:01:17 +00:00
Enrico Weigelt, metux IT consult c5e88238f2 xkb: drop unused defines
These aren't used anywhere, neither in Xserver nor drivers,
for about 11 years now. Fallout of removing component listing support.

Fixes: 710065da37
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1458>
2024-04-08 03:44:42 +00:00
Enrico Weigelt, metux IT consult 95faea8880 xkb: make XkbUpdateKeyTypesFromCore() static
This function is only used inside the same .c file where it's defined,
no outside users, also not in drivers. Thus no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1468>
2024-04-03 19:54:51 +02:00
Yao Wei 7ce57e179b dix: Force update LEDs after device state update in EnableDevice
This is to make sure the hardware gets the device states regardless
whether the internal state has changed or not, to overcome situations
that device LEDs are out of sync e.g. switching between VTs.

Signed-off-by: Yao Wei (魏銘廷) <yao.wei@canonical.com>
2023-02-21 03:43:05 +00:00
Peter Hutterer d9dd300b8d xkb: move the SProcXkbDispatch declaration
Let's move this to where all the other protocol handlers are.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2022-07-08 14:27:04 +00:00
Adam Jackson c2c6e9e68a dix: Don't track the XKB client versions in the ClientRec
XKB stores some stuff in the ClientRec that, style-wise, should probably
be in a client private.  vMinor tracks the client's idea of the XKB
minor version, but is never read, we can just nuke it.  vMajor is only
used for a bug-compat workaround for X11R6.0-vintage clients.  We're
only using though (1<<4) for xkbClientFlags in the protocol, so we can
pack that field down to a u8 and store the bug-compat flag there.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2017-10-24 15:53:28 -04:00
Mihail Konev 9d32b71c93 xkb: Match key releases with an overlaid press
Testcase:

In ~/.xbindkeysrc:
  "xterm &"
       XF86LaunchA

In ~/ov.xkb:
  xkb_keymap {
      xkb_keycodes { include "evdev" };
      xkb_types    { include "complete" };
      xkb_compat   { include "complete"
          interpret Overlay1_Enable+AnyOfOrNone(all) {
              action= SetControls(controls=Overlay1);
          };
      };
      xkb_symbols  { include "pc+inet(evdev)+us"
          key <INS> { [ Overlay1_Enable ] };
          key <AE01> { overlay1 = <AE02> }; // Insert+1 => 2
          key <TLDE> { overlay1 = <I128> }; // Insert+~ => XF86LaunchA
      };
      xkb_geometry { include "pc(pc104)" };
  };

Apply this layout: 'xkbcomp ~/ov.xkb $DISPLAY'.
Run "xbindkeys -n -v"
In the exact order:
- press Insert
- press Tilde
- release Insert
- wait
- release Tilde
Keyboard input in the new terminal window(s) would be locked
until another Insert+Tilde .

Reported-by: Mariusz Mazur <mariusz.g.mazur@gmail.com>
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-04 13:23:31 +10:00
Olivier Fourdan fda5675f9d xkb: add hook to allow/deny AccessX key repeat
The xserver generates the key repeat by itself.

But when used with another server processing inputs first (e.g. a
Wayland compositor), the other server may be busy dealing with some
other things and not queue up key release events in time.

Add a vfunc in XkbSrvInfo to possibly add a check before re-emitting a
keypress event in the AccessX timer handler, so that the key repeat has
a chance to be denied if the server processing the input is not ready.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-03 09:39:42 +02:00
Peter Hutterer ac164e5887 xkb: after changing the keymap, force an indicator update
When NumLock is on and a new keymap is applied, the next modifier state
change will turn off that LED (but leave the state enabled). The cause
for this is a bit convoluted:

* the SLI explicitState is copied from the current state in
  ProcXkbGetKbdByName. Thus, if NumLock is on, that state is 0x2.
* on the next modifier key press (e.g. Shift), XkbApplyState() calls into
  XkbUpdateIndicators() -> XkbUpdateLedAutoState() to update SLIs (if any)
  for the currently changed modifier. But it does so with a mask only for
  the changed modifier (i.e. for Shift).
* XkbUpdateLedAutoState() calculates the state based on this mask and
  ends up with 0 because we don't have a Shift LED and we masked out the
  others.
* XkbUpdateLedAutoState() compares that state with the previous state
  (which is still 0x2) and then proceeds to turn the LED off

This doesn't happen in the normal case because either the mask
encompasses all modifiers or the state matches of the masked-out
modifiers matches the old state.

Avoid this issue by forcing an SLI update after changing the keymap.
This updates the sli->effectiveState and thus restores everything to
happy working order.

https://bugzilla.redhat.com/show_bug.cgi?id=1047151

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-05-04 10:55:09 -04:00
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
Peter Harris 5eb77697ea Avoid starting a comment with */*
Even though -Wcomment doesn't mind it (in gcc or clang), the appearance
of */* confuses the syntax highlighter of some editors (eg. vim), and
causes warnings in MSVC.

Signed-off-by: Peter Harris <pharris@opentext.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-07-17 10:19:52 -07: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
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 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 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
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
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
Peter Hutterer 191b630656 include: document _XkbErrCode2 macros
Why sending the number of the (implementation-dependent) error statement to
the client is a good idea is a bit beyond me, but at least document it so we
can all share the despair.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 10:51:00 +10:00
Peter Hutterer 03318835a5 include: don't redeclare device events in xkbsrv.h
../../include/xkbsrv.h:308:51: warning: redundant redeclaration of
‘DeviceKeyPress’ [-Wredundant-decls]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-16 10:59:39 +10: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
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
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
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
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