Skip to content

Commit

Permalink
Modules: ensure the first widget child is focused when opening a new …
Browse files Browse the repository at this point in the history
…module
  • Loading branch information
aurelienpierre committed Feb 4, 2025
1 parent 5495bcd commit 98b51db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
6 changes: 0 additions & 6 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,14 @@ gboolean dt_bauhaus_focus_in_callback(GtkWidget *widget, GdkEventFocus event, gp

gboolean dt_bauhaus_focus_out_callback(GtkWidget *widget, GdkEventFocus event, gpointer user_data)
{
// Scroll focus needs to be managed separately from Gtk focus
// because of Gtk notebooks (tabs): Gtk gives focus automatically to the first
// notebook child, which is not what we want for scroll event capture.
gtk_widget_set_state_flags(widget, GTK_STATE_FLAG_NORMAL, TRUE);
gtk_widget_queue_draw(widget);
fprintf(stdout, "focus_out\n");
return TRUE;
}


gboolean dt_bauhaus_focus_callback(GtkWidget *widget, GtkDirectionType direction, gpointer data)
{
fprintf(stdout, "focus\n");

// Let user focus on the next/previous widget on arrow up/down
if(direction == GTK_DIR_UP || direction == GTK_DIR_DOWN) return FALSE;

Expand Down
8 changes: 4 additions & 4 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ void dt_iop_gui_init(dt_iop_module_t *module)
{
++darktable.gui->reset;
--darktable.bauhaus->skip_accel;
module->focused = NULL;

// Add the accelerators
if(!dt_iop_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED))
Expand Down Expand Up @@ -1833,7 +1832,6 @@ void dt_iop_request_focus(dt_iop_module_t *module)

dt_iop_color_picker_reset(out_focus_module, TRUE);
gtk_widget_grab_focus(dt_ui_center(darktable.gui->ui));
out_focus_module->focused = NULL;

gtk_widget_set_state_flags(dt_iop_gui_get_pluginui(out_focus_module), GTK_STATE_FLAG_NORMAL, TRUE);

Expand Down Expand Up @@ -1864,10 +1862,12 @@ void dt_iop_request_focus(dt_iop_module_t *module)
/* redraw the expander */
gtk_widget_queue_draw(module->expander);
gtk_widget_grab_focus(module->expander);
module->focused = NULL;

/* set the focus on the first child to enable arrow-key navigation and accessibility stuff */
GtkWidget *first_child = (GtkWidget *)g_list_first(((dt_gui_module_t *)module)->widget_list)->data;
if(first_child) gtk_widget_grab_focus(first_child);

// we also add the focus css class
// FIXME: focused CSS node have a :focus pseudo-class already, this is redundant
GtkWidget *iop_w = gtk_widget_get_parent(dt_iop_gui_get_pluginui(darktable.develop->gui_module));
dt_gui_add_class(iop_w, "dt_module_focus");
}
Expand Down
3 changes: 0 additions & 3 deletions src/develop/imageop.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ typedef struct dt_iop_module_t
/** delayed-event handling */
guint timeout_handle;

/** internal widget having the focus */
GtkWidget *focused;

void (*process_plain)(struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece,
const void *const i, void *const o, const struct dt_iop_roi_t *const roi_in,
const struct dt_iop_roi_t *const roi_out);
Expand Down

0 comments on commit 98b51db

Please sign in to comment.