Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start processing shortcuts after showing main window #17873

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,15 +1814,6 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
// init the gui part of views
dt_view_manager_gui_init(darktable.view_manager);

// Save the default shortcuts
dt_shortcuts_save(".defaults", FALSE);

// Then load any shortcuts if available (wipe defaults first if requested)
dt_shortcuts_load(NULL, !dt_conf_get_bool("accel/load_defaults"));

// Save the shortcuts including defaults
dt_shortcuts_save(NULL, TRUE);

// now that other initialization is complete, we can show the main window
// we need to do this before Lua is started or we'll either get a hang, or
// the module groups don't get set up correctly
Expand All @@ -1844,10 +1835,21 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load

if(init_gui)
{
// we have to call dt_ctl_switch_mode_to() here already to not run
// into a lua deadlock. having another call later is ok
dt_ctl_switch_mode_to("lighttable");

// Save the default shortcuts
dt_shortcuts_save(".defaults", FALSE);

// Then load any shortcuts if available (wipe defaults first if requested)
dt_shortcuts_load(NULL, !dt_conf_get_bool("accel/load_defaults"));

// Save the shortcuts including defaults
dt_shortcuts_save(NULL, TRUE);

// connect the shortcut dispatcher
g_signal_connect(dt_ui_main_window(darktable.gui->ui), "event",
G_CALLBACK(dt_shortcut_dispatcher), NULL);

#ifndef MAC_INTEGRATION
// load image(s) specified on cmdline. this has to happen after
// lua is initialized as image import can run lua code
Expand Down
14 changes: 5 additions & 9 deletions src/gui/accelerators.c
Original file line number Diff line number Diff line change
Expand Up @@ -3611,11 +3611,7 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
static gboolean _shortcut_match(dt_shortcut_t *f,
gchar **fb_log)
{
if(!darktable.view_manager->current_view)
return FALSE;

f->views =
darktable.view_manager->current_view->view(darktable.view_manager->current_view);
f->views = dt_view_get_current();
gpointer v = GINT_TO_POINTER(f->views);

GSequenceIter *existing =
Expand Down Expand Up @@ -3974,7 +3970,7 @@ float dt_action_process(const gchar *action,
}

const dt_view_type_flags_t vws = _find_views(ac);
if(!(vws & darktable.view_manager->current_view->view(darktable.view_manager->current_view)))
if(!(vws & dt_view_get_current()))
{
if(DT_PERFORM_ACTION(move_size))
dt_print(DT_DEBUG_ALWAYS,
Expand Down Expand Up @@ -4207,15 +4203,15 @@ void dt_shortcut_key_press(const dt_input_device_t id,
}
else if(g_slist_find_custom(_hold_keys, &this_key, _cmp_key))
{} // ignore repeating hold key
else if(darktable.view_manager && darktable.view_manager->current_view)
else
{
if(id) _sc.mods = _key_modifiers_clean(dt_key_modifier_state());

dt_shortcut_t just_key
= { .key_device = id,
.key = key,
.mods = _sc.mods,
.views = darktable.view_manager->current_view->view(darktable.view_manager->current_view) };
.views = dt_view_get_current() };

dt_shortcut_t *s = NULL;
GSequenceIter *existing
Expand Down Expand Up @@ -4350,7 +4346,7 @@ static void _delay_for_double_triple(guint time, guint is_key)
_sc.press += DT_SHORTCUT_DOUBLE & is_key;
_sc.click += DT_SHORTCUT_DOUBLE & ~is_key;

_sc.views = darktable.view_manager->current_view->view(darktable.view_manager->current_view);
_sc.views = dt_view_get_current();
GSequenceIter *multi =
g_sequence_search(darktable.control->shortcuts, &_sc, _shortcut_compare_func,
GINT_TO_POINTER(_sc.views));
Expand Down
2 changes: 0 additions & 2 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,8 +1382,6 @@ int dt_gui_gtk_init(dt_gui_gtk_t *gui)
widget = dt_ui_main_window(darktable.gui->ui);
g_signal_connect(G_OBJECT(widget), "configure-event",
G_CALLBACK(_window_configure), NULL);
g_signal_connect(G_OBJECT(widget), "event",
G_CALLBACK(dt_shortcut_dispatcher), NULL);
g_signal_override_class_handler("query-tooltip", gtk_widget_get_type(),
G_CALLBACK(dt_shortcut_tooltip_callback));

Expand Down
Loading