The kbproto header is already not needed here anymore.
Move the _X_EXPORT's to the corresponding function definitions, and use
straight extern "C" clauses instead of _XFUNCPROTOBEGIN/END.
It also makes more sense to have the EXPORT's in the source files, as it
provides some documentation to the reader, whereas in the header it's
obvious.
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Updated for xkb_keymap changes.]
#ifndef _XKBCOMMON_H_
#define _XKBCOMMON_H_
+#include <stddef.h>
#include <stdint.h>
-#include <stdio.h>
-#include <X11/Xfuncproto.h>
-#include <X11/extensions/XKB.h>
typedef uint32_t xkb_keycode_t;
typedef uint32_t xkb_keysym_t;
xkb_keycode_is_legal_ext(xkb->min_key_code) && \
xkb_keycode_is_legal_ext(xkb->max_key_code))
-
/**
* Names to compile a keymap with, also known as RMLVO. These names together
* should be the primary identifier for a keymap.
*/
struct xkb_state;
-_XFUNCPROTOBEGIN
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* Canonicalises component names by prepending the relevant component from
* If a component in names needs to be modified, the existing value will be
* free()d, and a new one allocated with malloc().
*/
-_X_EXPORT extern void
+void
xkb_canonicalise_components(struct xkb_component_names *names,
const struct xkb_component_names *old);
* Converts a keysym to a string; will return unknown Unicode codepoints
* as "Ua1b2", and other unknown keysyms as "0xabcd1234".
*/
-_X_EXPORT extern void
+void
xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size);
/*
* See xkb_keysym_to_string comments: this function will accept any string
* from that function.
*/
-_X_EXPORT extern xkb_keysym_t
+xkb_keysym_t
xkb_string_to_keysym(const char *s);
/**
* holds a reference on the context, and must free it when finished with
* xkb_context_unref().
*/
-_X_EXPORT struct xkb_context *
+struct xkb_context *
xkb_context_new(void);
/**
* Returns 1 on success, or 0 if the include path could not be added or is
* inaccessible.
*/
-_X_EXPORT int
+int
xkb_context_include_path_append(struct xkb_context *context, const char *path);
/**
* Returns 1 on success, or 0 if the primary include path could not be
* added.
*/
-_X_EXPORT int
+int
xkb_context_include_path_append_default(struct xkb_context *context);
/**
* default paths. Returns 1 on success, or 0 if the primary include path
* could not be added.
*/
-_X_EXPORT int
+int
xkb_context_include_path_reset_defaults(struct xkb_context *context);
/**
* Removes all entries from the context's include path.
*/
-_X_EXPORT void
+void
xkb_context_include_path_clear(struct xkb_context *context);
/**
* Returns the number of include paths currently active in the context.
*/
-_X_EXPORT unsigned int
+unsigned int
xkb_context_num_include_paths(struct xkb_context *context);
/**
* Returns the include path at the specified index within the context.
*/
-_X_EXPORT const char *
+const char *
xkb_context_include_path_get(struct xkb_context *context, unsigned int index);
/**
* Takes a new reference on an XKB context.
*/
-_X_EXPORT struct xkb_context *
+struct xkb_context *
xkb_context_ref(struct xkb_context *context);
/**
* Releases a reference on an XKB context, and possibly frees it.
*/
-_X_EXPORT void
+void
xkb_context_unref(struct xkb_context *context);
/** @} */
* You should almost certainly be using this and nothing else to create
* keymaps.
*/
-_X_EXPORT extern struct xkb_keymap *
+struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *context,
const struct xkb_rule_names *names);
*
* Geometry will be ignored since xkbcommon does not support it in any way.
*/
-_X_EXPORT extern struct xkb_keymap *
+struct xkb_keymap *
xkb_map_new_from_kccgst(struct xkb_context *context,
const struct xkb_component_names *kccgst);
* Creates an XKB keymap from a full text XKB keymap passed into the
* file descriptor.
*/
-_X_EXPORT extern struct xkb_keymap *
+struct xkb_keymap *
xkb_map_new_from_fd(struct xkb_context *context,
int fd, enum xkb_keymap_format format);
* Creates an XKB keymap from a full text XKB keymap serialised into one
* enormous string.
*/
-_X_EXPORT extern struct xkb_keymap *
+struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *context,
const char *string,
enum xkb_keymap_format format);
/**
* Takes a new reference on a keymap.
*/
-_X_EXPORT extern struct xkb_keymap *
+struct xkb_keymap *
xkb_map_ref(struct xkb_keymap *xkb);
/**
* Releases a reference on a keymap.
*/
-_X_EXPORT extern void
+void
xkb_map_unref(struct xkb_keymap *xkb);
/** @} */
/**
* Returns the number of modifiers active in the keymap.
*/
-_X_EXPORT xkb_mod_index_t
+xkb_mod_index_t
xkb_map_num_mods(struct xkb_keymap *xkb);
/**
* Returns the name of the modifier specified by 'idx', or NULL if invalid.
*/
-_X_EXPORT const char *
+const char *
xkb_map_mod_get_name(struct xkb_keymap *xkb, xkb_mod_index_t idx);
/**
* Returns the index of the modifier specified by 'name', or XKB_MOD_INVALID.
*/
-_X_EXPORT xkb_mod_index_t
+xkb_mod_index_t
xkb_map_mod_get_index(struct xkb_keymap *xkb, const char *name);
/**
* Returns the number of groups active in the keymap.
*/
-_X_EXPORT xkb_group_index_t
+xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *xkb);
/**
* Returns the name of the group specified by 'idx', or NULL if invalid.
*/
-_X_EXPORT const char *
+const char *
xkb_map_group_get_name(struct xkb_keymap *xkb, xkb_group_index_t idx);
/**
* Returns the index of the group specified by 'name', or XKB_GROUP_INVALID.
*/
-_X_EXPORT xkb_group_index_t
+xkb_group_index_t
xkb_map_group_get_index(struct xkb_keymap *xkb, const char *name);
/**
* Returns the number of groups active for the specified key.
*/
-_X_EXPORT xkb_group_index_t
+xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *xkb, xkb_keycode_t key);
/**
* Returns the number of LEDs in the given map.
*/
-_X_EXPORT xkb_led_index_t
+xkb_led_index_t
xkb_map_num_leds(struct xkb_keymap *xkb);
/**
* Returns the name of the LED specified by 'idx', or NULL if invalid.
*/
-_X_EXPORT const char *
+const char *
xkb_map_led_get_name(struct xkb_keymap *xkb, xkb_led_index_t idx);
/**
* Returns the index of the LED specified by 'name', or XKB_LED_INVALID.
*/
-_X_EXPORT xkb_led_index_t
+xkb_led_index_t
xkb_map_led_get_index(struct xkb_keymap *xkb, const char *name);
/** @} */
* Returns a new XKB state object for use with the given keymap, or NULL on
* failure.
*/
-_X_EXPORT struct xkb_state *
+struct xkb_state *
xkb_state_new(struct xkb_keymap *xkb);
/**
* Takes a new reference on a state object.
*/
-_X_EXPORT struct xkb_state *
+struct xkb_state *
xkb_state_ref(struct xkb_state *state);
/**
* Unrefs and potentially deallocates a state object; the caller must not
* use the state object after calling this.
*/
-_X_EXPORT void
+void
xkb_state_unref(struct xkb_state *state);
enum xkb_key_direction {
/**
* Updates a state object to reflect the given key being pressed or released.
*/
-_X_EXPORT void
+void
xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key,
enum xkb_key_direction direction);
*
* This should be called before xkb_state_update_key.
*/
-_X_EXPORT unsigned int
+unsigned int
xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
const xkb_keysym_t **syms_out);
*
* Please do not use this unless you fit the description above.
*/
-_X_EXPORT void
+void
xkb_state_update_mask(struct xkb_state *state,
xkb_mod_mask_t base_mods,
xkb_mod_mask_t latched_mods,
*
* Can return NULL on failure.
*/
-_X_EXPORT xkb_mod_mask_t
+xkb_mod_mask_t
xkb_state_serialise_mods(struct xkb_state *state,
enum xkb_state_component component);
* The group equivalent of xkb_state_serialise_mods: please see its
* documentation.
*/
-_X_EXPORT xkb_group_index_t
+xkb_group_index_t
xkb_state_serialise_group(struct xkb_state *state,
enum xkb_state_component component);
* specified by 'type', 0 if it is unset, or -1 if the modifier does not
* exist in the current map.
*/
-_X_EXPORT int
+int
xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type);
* specified by 'type', 0 if it is unset, or -1 if the modifier does not
* exist in the current map.
*/
-_X_EXPORT int
+int
xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx,
enum xkb_state_component type);
* specified by 'type', 0 if it is unset, or -1 if the group does not
* exist in the current map.
*/
-_X_EXPORT int
+int
xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type);
* specified by 'type', 0 if it is unset, or -1 if the group does not
* exist in the current map.
*/
-_X_EXPORT int
+int
xkb_state_group_index_is_active(struct xkb_state *state, xkb_group_index_t idx,
enum xkb_state_component type);
* Returns 1 if the LED specified by 'name' is active, 0 if it is unset, or
* -1 if the LED does not exist in the current map.
*/
-_X_EXPORT int
+int
xkb_state_led_name_is_active(struct xkb_state *state, const char *name);
/**
* Returns 1 if the LED specified by 'idx' is active, 0 if it is unset, or
* -1 if the LED does not exist in the current map.
*/
-_X_EXPORT int
+int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx);
/** @} */
-_XFUNCPROTOEND
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
#endif /* _XKBCOMMON_H_ */
#include <stdlib.h>
#include <string.h>
+#include <X11/extensions/XKB.h>
#include "xkbcommon/xkbcommon.h"
/**
* Append one directory to the context's include path.
*/
-int
+_X_EXPORT int
xkb_context_include_path_append(struct xkb_context *context, const char *path)
{
struct stat stat_buf;
/**
* Append the default include directories to the context.
*/
-int
+_X_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *context)
{
const char *home = getenv("HOME");
/**
* Remove all entries in the context's include path.
*/
-void
+_X_EXPORT void
xkb_context_include_path_clear(struct xkb_context *context)
{
int i;
/**
* xkb_context_include_path_clear() + xkb_context_include_path_append_default()
*/
-int
+_X_EXPORT int
xkb_context_include_path_reset_defaults(struct xkb_context *context)
{
xkb_context_include_path_clear(context);
/**
* Returns the number of entries in the context's include path.
*/
-unsigned int
+_X_EXPORT unsigned int
xkb_context_num_include_paths(struct xkb_context *context)
{
return context->num_include_paths;
* Returns the given entry in the context's include path, or NULL if an
* invalid index is passed.
*/
-const char *
+_X_EXPORT const char *
xkb_context_include_path_get(struct xkb_context *context, unsigned int idx)
{
if (idx >= xkb_context_num_include_paths(context))
/**
* Take a new reference on the context.
*/
-struct xkb_context *
+_X_EXPORT struct xkb_context *
xkb_context_ref(struct xkb_context *context)
{
context->refcnt++;
* Drop an existing reference on the context, and free it if the refcnt is
* now 0.
*/
-void
+_X_EXPORT void
xkb_context_unref(struct xkb_context *context)
{
if (--context->refcnt > 0)
/**
* Create a new context.
*/
-struct xkb_context *
+_X_EXPORT struct xkb_context *
xkb_context_new(void)
{
struct xkb_context *context = calloc(1, sizeof(*context));
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <X11/keysymdef.h>
-#include "xkbmisc.h"
-#include "xkbcommon/xkbcommon.h"
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
+#include <X11/keysymdef.h>
#include "ks_tables.h"
+#include "xkbmisc.h"
+#include "xkbcommon/xkbcommon.h"
-void
+_X_EXPORT void
xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size)
{
int i, n, h, idx;
snprintf(buffer, size, "0x%08x", ks);
}
-xkb_keysym_t
+_X_EXPORT xkb_keysym_t
xkb_string_to_keysym(const char *s)
{
int i, n, h, c, idx;
/**
* Returns the total number of modifiers active in the keymap.
*/
-xkb_mod_index_t
+_X_EXPORT xkb_mod_index_t
xkb_map_num_mods(struct xkb_keymap *xkb)
{
xkb_mod_index_t i;
/**
* Return the name for a given modifier.
*/
-const char *
+_X_EXPORT const char *
xkb_map_mod_get_name(struct xkb_keymap *xkb, xkb_mod_index_t idx)
{
if (idx >= xkb_map_num_mods(xkb))
/**
* Returns the index for a named modifier.
*/
-xkb_mod_index_t
+_X_EXPORT xkb_mod_index_t
xkb_map_mod_get_index(struct xkb_keymap *xkb, const char *name)
{
xkb_mod_index_t i;
/**
* Return the total number of active groups in the keymap.
*/
-xkb_group_index_t
+_X_EXPORT xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *xkb)
{
xkb_group_index_t ret = 0;
/**
* Returns the name for a given group.
*/
-const char *
+_X_EXPORT const char *
xkb_map_group_get_name(struct xkb_keymap *xkb, xkb_group_index_t idx)
{
if (idx >= xkb_map_num_groups(xkb))
/**
* Returns the index for a named group.
*/
-xkb_group_index_t
+_X_EXPORT xkb_group_index_t
xkb_map_group_get_index(struct xkb_keymap *xkb, const char *name)
{
xkb_group_index_t num_groups = xkb_map_num_groups(xkb);
/**
* Returns the number of groups active for a particular key.
*/
-xkb_group_index_t
+_X_EXPORT xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *xkb, xkb_keycode_t key)
{
return XkbKeyNumGroups(xkb, key);
/**
* Return the total number of active LEDs in the keymap.
*/
-xkb_led_index_t
+_X_EXPORT xkb_led_index_t
xkb_map_num_leds(struct xkb_keymap *xkb)
{
xkb_led_index_t ret = 0;
/**
* Returns the name for a given group.
*/
-const char *
+_X_EXPORT const char *
xkb_map_led_get_name(struct xkb_keymap *xkb, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(xkb))
/**
* Returns the index for a named group.
*/
-xkb_group_index_t
+_X_EXPORT xkb_group_index_t
xkb_map_led_get_index(struct xkb_keymap *xkb, const char *name)
{
xkb_led_index_t num_leds = xkb_map_num_leds(xkb);
/**
* Returns the level to use for the given key and state, or -1 if invalid.
*/
-unsigned int
+_X_EXPORT unsigned int
xkb_key_get_level(struct xkb_state *state, xkb_keycode_t key,
unsigned int group)
{
* Returns the group to use for the given key and state, taking
* wrapping/clamping/etc into account.
*/
-unsigned int
+_X_EXPORT unsigned int
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key)
{
unsigned int info = XkbKeyGroupInfo(state->xkb, key);
/**
* As below, but takes an explicit group/level rather than state.
*/
-unsigned int
+_X_EXPORT unsigned int
xkb_key_get_syms_by_level(struct xkb_keymap *xkb, xkb_keycode_t key, unsigned int group,
unsigned int level, const xkb_keysym_t **syms_out)
{
* Provides the symbols to use for the given key and state. Returns the
* number of symbols pointed to in syms_out.
*/
-unsigned int
+_X_EXPORT unsigned int
xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
const xkb_keysym_t **syms_out)
{
#include "xkbcommon/xkbcommon.h"
#include "XKBcommonint.h"
+#include "xkbmisc.h"
struct xkb_filter {
struct xkb_state *state;
return;
}
-struct xkb_state *
+_X_EXPORT struct xkb_state *
xkb_state_new(struct xkb_keymap *xkb)
{
struct xkb_state *ret;
return ret;
}
-struct xkb_state *
+_X_EXPORT struct xkb_state *
xkb_state_ref(struct xkb_state *state)
{
state->refcnt++;
return state;
}
-void
+_X_EXPORT void
xkb_state_unref(struct xkb_state *state)
{
state->refcnt--;
* Given a particular key event, updates the state structure to reflect the
* new modifiers.
*/
-void
+_X_EXPORT void
xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key,
enum xkb_key_direction direction)
{
* lossy, and should only be used to update a slave state mirroring the
* master, e.g. in a client/server window system.
*/
-void
+_X_EXPORT void
xkb_state_update_mask(struct xkb_state *state,
xkb_mod_mask_t base_mods,
xkb_mod_mask_t latched_mods,
* Serialises the requested modifier state into an xkb_mod_mask_t, with all
* the same disclaimers as in xkb_state_update_mask.
*/
-xkb_mod_mask_t
+_X_EXPORT xkb_mod_mask_t
xkb_state_serialise_mods(struct xkb_state *state,
enum xkb_state_component type)
{
* Serialises the requested group state, with all the same disclaimers as
* in xkb_state_update_mask.
*/
-xkb_group_index_t
+_X_EXPORT xkb_group_index_t
xkb_state_serialise_group(struct xkb_state *state,
enum xkb_state_component type)
{
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
-int
+_X_EXPORT int
xkb_state_mod_index_is_active(struct xkb_state *state,
xkb_mod_index_t idx,
enum xkb_state_component type)
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
-int
+_X_EXPORT int
xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
* Returns 1 if the given group is active with the specified type(s), 0 if
* not, or -1 if the group is invalid.
*/
-int
+_X_EXPORT int
xkb_state_group_index_is_active(struct xkb_state *state,
xkb_group_index_t idx,
enum xkb_state_component type)
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
-int
+_X_EXPORT int
xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
/**
* Returns 1 if the given LED is active, 0 if not, or -1 if the LED is invalid.
*/
-int
+_X_EXPORT int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(state->xkb))
/**
* Returns 1 if the given LED is active, 0 if not, or -1 if the LED is invalid.
*/
-int
+_X_EXPORT int
xkb_state_led_name_is_active(struct xkb_state *state, const char *name)
{
xkb_led_index_t idx = xkb_map_led_get_index(state->xkb, name);
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <stdio.h>
+
#include "xkbmisc.h"
#include "xkbcommon/xkbcommon.h"
#include "XKBcommonint.h"
return name;
}
-void
+_X_EXPORT void
xkb_canonicalise_components(struct xkb_component_names * names,
const struct xkb_component_names * old)
{
return names;
}
-struct xkb_keymap *
+_X_EXPORT struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *context,
const struct xkb_rule_names *rmlvo)
{
return xkb;
}
-struct xkb_keymap *
+_X_EXPORT struct xkb_keymap *
xkb_map_new_from_kccgst(struct xkb_context *context,
const struct xkb_component_names *kccgst)
{
return compile_keymap(context, file);
}
-struct xkb_keymap *
+_X_EXPORT struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *context,
const char *string,
enum xkb_keymap_format format)
return compile_keymap(context, file);
}
-struct xkb_keymap *
+_X_EXPORT struct xkb_keymap *
xkb_map_new_from_fd(struct xkb_context *context,
int fd,
enum xkb_keymap_format format)
return compile_keymap(context, file);
}
-struct xkb_keymap *
+_X_EXPORT struct xkb_keymap *
xkb_map_ref(struct xkb_keymap *xkb)
{
xkb->refcnt++;
return xkb;
}
-void
+_X_EXPORT void
xkb_map_unref(struct xkb_keymap *xkb)
{
if (--xkb->refcnt > 0)
#define _XKBMISC_H_
#include <X11/Xdefs.h>
+#include <X11/Xfuncproto.h>
+
#include "xkbcommon/xkbcommon.h"
#include "XKBcommonint.h"