Top | ![]() |
![]() |
![]() |
![]() |
GQuark | nk_bindings_error () |
NkBindings * | nk_bindings_new () |
void | nk_bindings_free () |
gboolean | (*NkBindingsCallback) () |
gboolean | nk_bindings_add_binding () |
void | nk_bindings_reset_bindings () |
NkBindingsSeat * | nk_bindings_seat_new () |
void | nk_bindings_seat_free () |
void | nk_bindings_seat_update_keymap () |
struct xkb_context * | nk_bindings_seat_get_context () |
gchar * | nk_bindings_seat_handle_key () |
gchar * | nk_bindings_seat_handle_key_with_modmask () |
gboolean | nk_bindings_seat_handle_button () |
gboolean | nk_bindings_seat_handle_scroll () |
void | nk_bindings_seat_update_mask () |
void | nk_bindings_seat_reset () |
NkBindings | |
enum | NkBindingsKeyState |
enum | NkBindingsButtonState |
enum | NkBindingsMouseButton |
enum | NkBindingsScrollAxis |
#define | NK_BINDINGS_SCROLL_NUM_AXIS |
enum | NkBindingsError |
#define | NK_BINDINGS_ERROR |
#define | NK_BINDINGS_BINDING_NOT_TRIGGERED |
#define | NK_BINDINGS_BINDING_TRIGGERED |
NkBindingsSeat |
NkBindings *
nk_bindings_new (guint64 double_click_delay
);
Creates a new NkBindings context.
Any relevant setting will be retrieved from the Desktop Environment when possible, then from GTK settings. If none is available, the application settings passed as parameters will be used, with a fallback if the value is unusable.
void
nk_bindings_free (NkBindings *bindings
);
Frees the NkBindings context and all its seats.
gboolean (*NkBindingsCallback) (guint64 scope
,gpointer target
,gpointer user_data
);
This function is called when a binding might be triggered.
It is up to the caller to check in scope
and target
matches a valid
situation in the application.
If the binding is valid, the application can do the relevant actions
and return NK_BINDINGS_BINDING_TRIGGERED
.
If not, returns NK_BINDINGS_BINDING_NOT_TRIGGERED
and the next scope is
checked in the NkBindings context.
scope |
the scope this binding was |
|
target |
the target passed to |
|
user_data |
user_data passed to |
NK_BINDINGS_BINDING_TRIGGERED
if the binding was valid,
NK_BINDINGS_BINDING_NOT_TRIGGERED
otherwise
gboolean nk_bindings_add_binding (NkBindings *bindings
,guint64 scope
,const gchar *string
,NkBindingsCallback callback
,gpointer user_data
,GDestroyNotify notify
,GError **error
);
Adds a binding to the bindings
context.
The scope
is fully opaque to NkBindings.
Scopes are ordered higher-first and checked in order.
See NkBindingsCallback.
bindings |
an NkBindings context |
|
scope |
an opaque scope ID |
|
string |
a binding string |
|
callback |
the callback to call when the binding might be triggered |
|
user_data |
user_data for |
|
notify |
function to call to free |
[nullable] |
error |
void
nk_bindings_reset_bindings (NkBindings *bindings
);
Removes all bindings from the bindings
context.
NkBindingsSeat * nk_bindings_seat_new (NkBindings *bindings
,enum xkb_context_flags flags
);
Creates a new NkBindingsSeat in the context to handle the state of a set of devices.
You must call nk_bindings_seat_update_keymap()
with non-NULL
values before any call to nk_bindings_seat_handle_key()
and others.
void
nk_bindings_seat_free (NkBindingsSeat *seat
);
Frees the seat
and all its state.
This will not trigger and pending on-release binding.
void nk_bindings_seat_update_keymap (NkBindingsSeat *seat
,struct xkb_keymap *keymap
,struct xkb_state *state
);
Updates the keymap
and state
of this seat
.
Both keymap
and state
can either be NULL
to clear the state
or non-NULL
to update/create it.
struct xkb_context *
nk_bindings_seat_get_context (NkBindingsSeat *seat
);
Gets the xkb_context of the seat
.
gchar * nk_bindings_seat_handle_key (NkBindingsSeat *seat
,gpointer target
,xkb_keycode_t key
,NkBindingsKeyState state
);
Handles a key press/release event on target
. target
is usually the widget the event occured on.
If the event might trigger a binding, the corresponding callback will be called.
See NkBindingsCallback and nk_bindings_add_binding()
.
If no binding was triggered and the event resulted in text, said text is returned.
gchar * nk_bindings_seat_handle_key_with_modmask (NkBindingsSeat *seat
,gpointer target
,xkb_mod_mask_t modmask
,xkb_keycode_t key
,NkBindingsKeyState state
);
A variant of nk_bindings_seat_handle_key()
for cases where you get a modmask
with the event
instead on relying on the current state (i.e. in the X11 world).
gboolean nk_bindings_seat_handle_button (NkBindingsSeat *seat
,gpointer target
,NkBindingsMouseButton button
,NkBindingsButtonState state
,guint64 timestamp
);
Handles a button press/release event on target
. target
is usually the widget the event occured on.
If the event might trigger a binding, the corresponding callback will be called.
See NkBindingsCallback and nk_bindings_add_binding()
.
seat |
||
target |
an opaque target pointer |
|
button |
||
state |
||
timestamp |
the timestamp for when the evnte occured |
NK_BINDINGS_BINDING_TRIGGERED
if a binding was triggered,
NK_BINDINGS_BINDING_NOT_TRIGGERED
otherwise
gboolean nk_bindings_seat_handle_scroll (NkBindingsSeat *seat
,gpointer target
,NkBindingsScrollAxis axis
,gint32 steps
);
Handles a scroll event on target
. target
is usually the widget the event occured on.
If the event might trigger a binding, the corresponding callback will be called step
times.
See NkBindingsCallback and nk_bindings_add_binding()
.
A negative value of step
means up or left scrolling, a positive value means down or right scrolling.
NK_BINDINGS_BINDING_TRIGGERED
if a binding was triggered,
NK_BINDINGS_BINDING_NOT_TRIGGERED
otherwise
void nk_bindings_seat_update_mask (NkBindingsSeat *seat
,gpointer target
,xkb_mod_mask_t depressed_mods
,xkb_mod_mask_t latched_mods
,xkb_mod_mask_t locked_mods
,xkb_layout_index_t depressed_layout
,xkb_layout_index_t latched_layout
,xkb_layout_index_t locked_layout
);
Handles a modifiers mask event on target
. target
is usually the widget the event occured on.
If the event might trigger a binding, the corresponding callback will be called.
See NkBindingsCallback and nk_bindings_add_binding()
.
Only on-release bindings may be triggered by this function.
See xkb_state_update_mask()
for more information about
depressed_mods
, latched_mods
, locked_mods
, depressed_layout
, latched_layout
, locked_layout
.
Most of the time you should just pass the values you got with your event, using 0 for missing values.
void
nk_bindings_seat_reset (NkBindingsSeat *seat
);
Reset any pending on-release bindings on the seat
.
typedef struct _NkBindings NkBindings;
An opaque structure holding all the bindings and seats.
An enumeration describing a key state.
NK_BINDINGS_KEY_STATE_PRESSED
is to be used for keyboard
focus-in-like events when you get a list of already pressed keys
that should not trigger on-press bindings.
See nk_bindings_seat_handle_key()
.
An enumeration describing a mouse button.
Mice may have an arbritrary number of extra buttons,
which will be mapped to values starting at
NK_BINDINGS_MOUSE_BUTTON_EXTRA
.
the primary mouse button (“left click” for right-handed people) |
||
the secondary mouse button (“right click” for right-handed people) |
||
the middle mouse button (“wheel click”) |
||
the first commonly-available extra button, usually known as “back” |
||
the second commonly-available extra button, usually known as “forward” |
||
the first value for any button after the commonly-available first five |
#define NK_BINDINGS_SCROLL_NUM_AXIS 2
The number of scroll axis currently supported.
#define NK_BINDINGS_BINDING_NOT_TRIGGERED FALSE
Return value for NkBindingsCallback if the binding was not valid.
#define NK_BINDINGS_BINDING_TRIGGERED TRUE
Return value for NkBindingsCallback if the binding was valid.