Add xkb_map_mod_mask_remove_consumed
[platform/upstream/libxkbcommon.git] / xkbcommon / xkbcommon.h
index 42f70ad..0c2f06f 100644 (file)
@@ -249,6 +249,89 @@ xkb_context_unref(struct xkb_context *context);
 /** @} */
 
 /**
+ * @defgroup logging Logging handling
+ * These functions allow you to manipulate how logging from this library
+ * will be handled.
+ *
+ * @{
+ */
+
+enum xkb_log_level {
+    /** Log critical internal errors only */
+    XKB_LOG_LEVEL_CRITICAL = 0,
+    /** Log all errors */
+    XKB_LOG_LEVEL_ERROR = 1,
+    /** Log warnings and errors */
+    XKB_LOG_LEVEL_WARNING = 2,
+    /** Log information, warnings, and errors */
+    XKB_LOG_LEVEL_INFO = 3,
+    /** Log all the things */
+    XKB_LOG_LEVEL_DEBUG = 4,
+};
+
+/**
+ * Sets the function to be called for logging messages.
+ * Passing NULL restores the default function, which logs to stderr.
+ **/
+void
+xkb_set_log_fn(struct xkb_context *context,
+               void (*log_fn)(struct xkb_context *context, int priority,
+                              const char *format, va_list args));
+/**
+ * Sets the current logging priority. The value controls which messages
+ * are logged.  The default priority is LOG_ERR.
+ *
+ * The environment variable XKB_LOG, if set, overrides the default value
+ * and may be specified as a priority number or name.
+ */
+void
+xkb_set_log_priority(struct xkb_context *context, enum xkb_log_level priority);
+
+/**
+ * Returns the current logging priority.
+ */
+enum xkb_log_level
+xkb_get_log_priority(struct xkb_context *context);
+
+/**
+ * Sets the current logging verbosity, a value from 0 to 10.
+ *
+ * The library can generate a number of warnings which are not helpful to
+ * ordinary users of the library.  The verbosity may be increased if more
+ * information is desired (e.g. when developing a keymap).  Defaults to 0.
+ * The environment variable XKB_VERBOSITY, if set, overrdies the default
+ * value.
+ *
+ * Note that most verbose messages are of priority XKB_LOG_LEVEL_WARNING
+ * or lower.
+ */
+void
+xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity);
+
+/**
+ * Returns the current logging verbosity.
+ */
+int
+xkb_get_log_verbosity(struct xkb_context *ctx);
+
+/**
+ * Retrieves stored data pointer from the context.  This might be useful
+ * to access from callbacks like a custom logging function.
+ *
+ * If context is NULL, returns NULL.
+ **/
+void *
+xkb_get_user_data(struct xkb_context *context);
+
+/**
+ * Store custom user data in the context.
+ */
+void
+xkb_set_user_data(struct xkb_context *context, void *user_data);
+
+/** @} */
+
+/**
  * @defgroup map Keymap management
  * These utility functions allow you to create and deallocate XKB keymaps.
  *
@@ -564,6 +647,25 @@ xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx,
                               enum xkb_state_component type);
 
 /**
+ * Returns 1 if the modifier specified by 'idx' is used in the
+ * translation of the keycode 'key' to the key symbols obtained by
+ * pressing it (as in xkb_key_get_syms), given the current state.
+ * Returns 0 otherwise.
+ */
+int
+xkb_key_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t key,
+                              xkb_mod_index_t idx);
+
+/**
+ * Takes the given modifier mask, and removes all modifiers which are
+ * marked as 'consumed' (see xkb_key_mod_index_is_consumed definition)
+ * for that particular key.
+ */
+xkb_mod_mask_t
+xkb_key_mod_mask_remove_consumed(struct xkb_state *state, xkb_keycode_t key,
+                                 xkb_mod_mask_t mask);
+
+/**
  * Returns 1 if the modifiers specified by the varargs (treated as
  * xkb_mod_index_t, terminated with XKB_MOD_INVALID) are active in the manner
  * specified by 'match' and 'type', 0 otherwise, or -1 if the modifier does not