gitmodules: Update libnkutils

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2021-10-28 06:33:12 +00:00
parent f24cbe270e
commit bde8175d39
No known key found for this signature in database
GPG key ID: AC203F96E2C34BB7
7 changed files with 92 additions and 17 deletions

View file

@ -170,8 +170,16 @@ void rofi_view_restart(RofiViewState *state);
*
* @returns TRUE if action was handled.
*/
gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
guint action);
gboolean rofi_view_check_action(RofiViewState *state, BindingsScope scope,
guint action);
/**
* @param state The handle to the view
* @param scope The scope of the action
* @param action The action
*/
void rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
guint action);
/**
* @param state The handle to the view

View file

@ -281,6 +281,20 @@ gboolean widget_need_redraw(widget *wid);
*/
widget *widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y);
/**
* @param wid The widget handle
* @param action The action to trigger
* @param x A pointer to the x coordinate of the click
* @param y A pointer to the y coordinate of the click
*
* Trigger an action on widget.
* param x and param y are relative to param wid .
*
* @returns Whether the action would be handled or not
*/
WidgetTriggerActionResult widget_check_action(widget *wid, guint action,
gint x, gint y);
/**
* @param wid The widget handle
* @param action The action to trigger

View file

@ -142,9 +142,14 @@ void setup_abe ( void )
}
}
static gboolean binding_trigger_action ( guint64 scope, G_GNUC_UNUSED gpointer target, gpointer user_data )
static gboolean binding_check_action ( guint64 scope, G_GNUC_UNUSED gpointer target, gpointer user_data )
{
return rofi_view_trigger_action ( rofi_view_get_active (), scope, GPOINTER_TO_UINT ( user_data ) );
return rofi_view_check_action ( rofi_view_get_active (), scope, GPOINTER_TO_UINT ( user_data ) ) ? NK_BINDINGS_BINDING_TRIGGERED : NK_BINDINGS_BINDING_NOT_TRIGGERED;
}
static void binding_trigger_action ( guint64 scope, G_GNUC_UNUSED gpointer target, gpointer user_data )
{
rofi_view_trigger_action ( rofi_view_get_active (), scope, GPOINTER_TO_UINT ( user_data ) );
}
guint key_binding_get_action_from_name ( const char *name )
@ -171,7 +176,7 @@ gboolean parse_keys_abe ( NkBindings *bindings )
// Iter over bindings.
const char *const sep = ",";
for ( char *entry = strtok_r ( keystr, sep, &sp ); entry != NULL; entry = strtok_r ( NULL, sep, &sp ) ) {
if ( !nk_bindings_add_binding ( bindings, b->scope, entry, binding_trigger_action, GUINT_TO_POINTER ( b->id ), NULL, &error ) ) {
if ( !nk_bindings_add_binding ( bindings, b->scope, entry, binding_check_action, binding_trigger_action, GUINT_TO_POINTER ( b->id ), NULL, &error ) ) {
char *str = g_markup_printf_escaped ( "Failed to set binding <i>%s</i> for: <i>%s (%s)</i>:\n\t<span size=\"smaller\" style=\"italic\">%s</span>\n",
b->binding, b->comment, b->name, error->message );
g_string_append ( error_msg, str );
@ -191,7 +196,7 @@ gboolean parse_keys_abe ( NkBindings *bindings )
for ( gsize i = SCOPE_MIN_FIXED; i <= SCOPE_MAX_FIXED; ++i ) {
for ( gsize j = 1; j < G_N_ELEMENTS ( mouse_default_bindings ); ++j ) {
nk_bindings_add_binding ( bindings, i, mouse_default_bindings[j], binding_trigger_action, GSIZE_TO_POINTER ( j ), NULL, NULL );
nk_bindings_add_binding ( bindings, i, mouse_default_bindings[j], binding_check_action, binding_trigger_action, GSIZE_TO_POINTER ( j ), NULL, NULL );
}
}

View file

@ -1470,12 +1470,10 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
}
}
gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
guint action) {
rofi_view_set_user_timeout(NULL);
gboolean rofi_view_check_action(RofiViewState *state, BindingsScope scope,
guint action) {
switch (scope) {
case SCOPE_GLOBAL:
rofi_view_trigger_global_action(action);
return TRUE;
case SCOPE_MOUSE_LISTVIEW:
case SCOPE_MOUSE_LISTVIEW_ELEMENT:
@ -1489,15 +1487,11 @@ gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
return FALSE;
}
widget_xy_to_relative(target, &x, &y);
switch (widget_trigger_action(target, action, x, y)) {
switch (widget_check_action(target, action, x, y)) {
case WIDGET_TRIGGER_ACTION_RESULT_IGNORED:
return FALSE;
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END:
target = NULL;
/* FALLTHRU */
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN:
state->mouse.motion_target = target;
/* FALLTHRU */
case WIDGET_TRIGGER_ACTION_RESULT_HANDLED:
return TRUE;
}
@ -1507,6 +1501,42 @@ gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
return FALSE;
}
void rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
guint action) {
rofi_view_set_user_timeout(NULL);
switch (scope) {
case SCOPE_GLOBAL:
rofi_view_trigger_global_action(action);
return;
case SCOPE_MOUSE_LISTVIEW:
case SCOPE_MOUSE_LISTVIEW_ELEMENT:
case SCOPE_MOUSE_EDITBOX:
case SCOPE_MOUSE_SCROLLBAR:
case SCOPE_MOUSE_MODE_SWITCHER: {
gint x = state->mouse.x, y = state->mouse.y;
widget *target = widget_find_mouse_target(WIDGET(state->main_window),
(WidgetType)scope, x, y);
if (target == NULL) {
return;
}
widget_xy_to_relative(target, &x, &y);
switch (widget_trigger_action(target, action, x, y)) {
case WIDGET_TRIGGER_ACTION_RESULT_IGNORED:
return;
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END:
target = NULL;
/* FALLTHRU */
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN:
state->mouse.motion_target = target;
/* FALLTHRU */
case WIDGET_TRIGGER_ACTION_RESULT_HANDLED:
return;
}
break;
}
}
}
void rofi_view_handle_text(RofiViewState *state, char *text) {
if (textbox_append_text(state->text, text, strlen(text))) {
state->refilter = TRUE;

View file

@ -548,6 +548,21 @@ widget *widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y) {
return NULL;
}
WidgetTriggerActionResult widget_check_action(widget *wid, guint action,
gint x, gint y) {
if (wid == NULL) {
return FALSE;
}
if (wid->trigger_action == NULL) {
return FALSE;
}
/*
* TODO: We should probably add a check_action callback to the widgets
* to do extra checks
*/
return WIDGET_TRIGGER_ACTION_RESULT_HANDLED;
}
WidgetTriggerActionResult widget_trigger_action(widget *wid, guint action,
gint x, gint y) {
if (wid == NULL) {

@ -1 +1 @@
Subproject commit 6164bacaef10031ce77380499cfad2ae818ab6b0
Subproject commit 24377c9d163b520778ce6511f3d649e1dc4521d2

View file

@ -97,10 +97,13 @@ RofiViewState * rofi_view_get_active ( void )
{
return NULL;
}
gboolean rofi_view_trigger_action ( G_GNUC_UNUSED RofiViewState *state, G_GNUC_UNUSED BindingsScope scope, G_GNUC_UNUSED guint action )
gboolean rofi_view_check_action ( G_GNUC_UNUSED RofiViewState *state, G_GNUC_UNUSED BindingsScope scope, G_GNUC_UNUSED guint action )
{
return FALSE;
}
void rofi_view_trigger_action ( G_GNUC_UNUSED RofiViewState *state, G_GNUC_UNUSED BindingsScope scope, G_GNUC_UNUSED guint action )
{
}
void display_startup_notification ( G_GNUC_UNUSED RofiHelperExecuteContext *context, G_GNUC_UNUSED GSpawnChildSetupFunc *child_setup, G_GNUC_UNUSED gpointer *user_data )
{