diff --git a/src/gui/gtk.c b/src/gui/gtk.c index 3334f05d9a69..06b332ac254c 100644 --- a/src/gui/gtk.c +++ b/src/gui/gtk.c @@ -4367,12 +4367,12 @@ void dt_gui_collapsible_section_set_label(dt_gui_collapsible_section_t *cs, dt_control_queue_redraw_widget(cs->label); } -gboolean dt_gui_long_click(const int second, - const int first) +gboolean dt_gui_long_click(const guint second, + const guint first) { int delay = 0; g_object_get(gtk_settings_get_default(), "gtk-double-click-time", &delay, NULL); - return second - first > delay; + return second - delay > first; } static int busy_nest_count = 0; diff --git a/src/gui/gtk.h b/src/gui/gtk.h index c1a2f8905a21..9c9bd8e5a943 100644 --- a/src/gui/gtk.h +++ b/src/gui/gtk.h @@ -534,8 +534,8 @@ void dt_gui_update_collapsible_section(dt_gui_collapsible_section_t *cs); void dt_gui_hide_collapsible_section(dt_gui_collapsible_section_t *cs); // is delay between first and second click/press longer than double-click time? -gboolean dt_gui_long_click(const int second, - const int first); +gboolean dt_gui_long_click(const guint second, + const guint first); // control whether the mouse pointer displays as a "busy" cursor, e.g. watch or timer // the calls may be nested, but must be matched diff --git a/src/gui/presets.c b/src/gui/presets.c index 03638c96fc22..eeac2bb3cc3c 100644 --- a/src/gui/presets.c +++ b/src/gui/presets.c @@ -1253,18 +1253,28 @@ gboolean dt_gui_presets_autoapply_for_module(dt_iop_module_t *module, GtkWidget return applied; } +static guint _click_time = G_MAXUINT; + +static gboolean _menuitem_motion_preset(GtkMenuItem *menuitem, + GdkEventMotion *event, + dt_iop_module_t *module) +{ + if(!_click_time) _click_time = G_MAXUINT; + + return FALSE; +} + static gboolean _menuitem_button_preset(GtkMenuItem *menuitem, GdkEventButton *event, dt_iop_module_t *module) { - static guint click_time = G_MAXINT; - gboolean long_click = dt_gui_long_click(event->time, click_time); + gboolean long_click = dt_gui_long_click(event->time, _click_time); gchar *name = g_object_get_data(G_OBJECT(menuitem), "dt-preset-name"); - if(event->button == 1 || (module->flags() & IOP_FLAGS_ONE_INSTANCE)) + if(event->button == 1) { - if(click_time > event->time) + if(_click_time > event->time) { GtkContainer *menu = GTK_CONTAINER(gtk_widget_get_parent(GTK_WIDGET(menuitem))); for(GList *c = gtk_container_get_children(menu); c; c = g_list_delete_link(c, c)) @@ -1274,9 +1284,9 @@ static gboolean _menuitem_button_preset(GtkMenuItem *menuitem, dt_gui_presets_apply_preset(name, module); } } - else if(event->button == 3 && event->type == GDK_BUTTON_RELEASE) + else if(event->button == 3 && event->type == GDK_BUTTON_RELEASE && _click_time) { - if(long_click) + if(long_click || (module->flags() & IOP_FLAGS_ONE_INSTANCE)) dt_shortcut_copy_lua((dt_action_t*)module, name); else { @@ -1294,7 +1304,7 @@ static gboolean _menuitem_button_preset(GtkMenuItem *menuitem, dt_iop_connect_accels_multi(module->so); } - click_time = event->type == GDK_BUTTON_PRESS ? event->time : G_MAXINT; + _click_time = event->type == GDK_BUTTON_PRESS ? event->time : G_MAXUINT; return long_click; // keep menu open on long click } @@ -1321,6 +1331,8 @@ static void _menuitem_connect_preset(GtkWidget *mi, G_CALLBACK(_menuitem_button_preset), iop); g_signal_connect(G_OBJECT(mi), "button-release-event", G_CALLBACK(_menuitem_button_preset), iop); + g_signal_connect(G_OBJECT(mi), "motion-notify-event", + G_CALLBACK(_menuitem_motion_preset), iop); gtk_widget_set_has_tooltip(mi, TRUE); } @@ -1819,6 +1831,8 @@ GtkMenu *dt_gui_presets_popup_menu_show_for_module(dt_iop_module_t *module) if(module->set_preferences) module->set_preferences(GTK_MENU_SHELL(menu), module); } + _click_time = 0; + return menu; }