xkb: unexport functions from xkbfmisc.c

These are only used inside xkb/*, so no need to keep them exported.

Also replacing some macros by inline functions in order to improve
type-safety and debugging, and adding documentation.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1729>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-04-05 16:14:12 +02:00 committed by Marge Bot
parent 114c1c84b1
commit 5d98664ec1
8 changed files with 92 additions and 28 deletions

View File

@ -71,21 +71,6 @@ typedef void (*XkbFileAddOnFunc) (FILE * /* file */ ,
_XFUNCPROTOBEGIN
#define _XkbKSLower (1<<0)
#define _XkbKSUpper (1<<1)
#define XkbKSIsLower(k) (_XkbKSCheckCase(k)&_XkbKSLower)
#define XkbKSIsUpper(k) (_XkbKSCheckCase(k)&_XkbKSUpper)
#define XkbKSIsKeypad(k) (((k)>=XK_KP_Space)&&((k)<=XK_KP_Equal))
extern _X_EXPORT unsigned _XkbKSCheckCase(KeySym /* sym */
);
extern _X_EXPORT int XkbFindKeycodeByName(XkbDescPtr /* xkb */ ,
char * /* name */ ,
Bool /* use_aliases */
);
extern _X_EXPORT Bool XkbWriteXKBKeycodes(FILE * /* file */ ,
XkbDescPtr /* result */ ,
Bool /* topLevel */ ,
@ -126,14 +111,6 @@ extern _X_EXPORT Bool XkbWriteXKBGeometry(FILE * /* file */ ,
void * /* priv */
);
extern _X_EXPORT Bool XkbWriteXKBKeymapForNames(FILE * /* file */ ,
XkbComponentNamesPtr /* names */
,
XkbDescPtr /* xkb */ ,
unsigned /* want */ ,
unsigned /* need */
);
/***====================================================================***/
extern _X_EXPORT unsigned XkmReadFile(FILE * /* file */ ,

View File

@ -29,9 +29,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include "xkb/xkbfmisc_priv.h"
#include "misc.h"
#include "inputstr.h"
#include <X11/keysym.h>
#include <xkbsrv.h>
/***====================================================================***/

View File

@ -40,6 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "dix/dix_priv.h"
#include "os/osdep.h"
#include "xkb/xkbfmisc_priv.h"
#include "inputstr.h"
#include "scrnintstr.h"

View File

@ -34,6 +34,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "dix/dix_priv.h"
#include "os/osdep.h"
#include "xkb/xkbfmisc_priv.h"
#include "misc.h"
#include "inputstr.h"

View File

@ -29,14 +29,15 @@
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
#include <X11/extensions/XKMformat.h>
#include <X11/X.h>
#include <X11/keysym.h>
#include <X11/Xproto.h>
#include "xkb/xkbfmisc_priv.h"
#include "misc.h"
#include "inputstr.h"
#include "dix.h"

79
xkb/xkbfmisc_priv.h Normal file
View File

@ -0,0 +1,79 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#ifndef _XSERVER_XKB_XKBFMISC_PRIV_H
#define _XSERVER_XKB_XKBFMISC_PRIV_H
/* needed for X11/keysymdef.h to define all symdefs */
#define XK_MISCELLANY
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xdefs.h>
#include <X11/keysymdef.h>
#include "xkbstr.h"
/*
* return mask bits for _XkbKSCheckCase()
*/
#define _XkbKSLower (1<<0)
#define _XkbKSUpper (1<<1)
/*
* check whether given KeySym is a upper or lower case key
*
* @param sym the KeySym to check
* @return mask of _XkbKS* flags
*/
unsigned int _XkbKSCheckCase(KeySym sym);
/*
* check whether given KeySym is an lower case key
*
* @param k the KeySym to check
* @return TRUE if k is a lower case key
*/
static inline Bool XkbKSIsLower(KeySym k) { return _XkbKSCheckCase(k)&_XkbKSLower; }
/*
* check whether given KeySym is an upper case key
*
* @param k the KeySym to check
* @return TRUE if k is a upper case key
*/
static inline Bool XkbKSIsUpper(KeySym k) { return _XkbKSCheckCase(k)&_XkbKSUpper; }
/*
* check whether given KeySym is an keypad key
*
* @param k the KeySym to check
* @return TRUE if k is a keypad key
*/
static inline Bool XkbKSIsKeypad(KeySym k) { return (((k)>=XK_KP_Space)&&((k)<=XK_KP_Equal)); }
/*
* find a keycode by its name
*
* @param xkb pointer to xkb descriptor
* @param name the key name
* @param use_aliases TRUE if aliases should be resolved
* @return keycode ID
*/
int XkbFindKeycodeByName(XkbDescPtr xkb, char *name, Bool use_aliases);
/*
* write keymap for given component names
*
* @param file the FILE to write to
* @param names pointer to list of keymap component names to write out
* @param xkb pointer to xkb descriptor
* @param want bitmask of wanted elements
* @param need bitmask of needed elements
* @return TRUE if succeeded
*/
Bool XkbWriteXKBKeymapForNames(FILE *file, XkbComponentNamesPtr names,
XkbDescPtr xkb, unsigned want, unsigned need);
#endif /* _XSERVER_XKB_XKBFMISC_PRIV_H */

View File

@ -35,6 +35,7 @@
#include <X11/Xproto.h>
#include <X11/extensions/XKMformat.h>
#include "xkb/xkbfmisc_priv.h"
#include "xkb/xkbtext_priv.h"
#include "misc.h"

View File

@ -27,14 +27,15 @@
#include <dix-config.h>
#include <stdio.h>
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include <X11/extensions/XKMformat.h>
#include "xkb/xkbfmisc_priv.h"
#include "misc.h"
#include "inputstr.h"
#include "xkbstr.h"