diff --git a/thunar/thunar-history-action.c b/thunar/thunar-history-action.c index 5f2baab5..ca31421f 100644 --- a/thunar/thunar-history-action.c +++ b/thunar/thunar-history-action.c @@ -42,7 +42,8 @@ struct _ThunarHistoryAction { GtkAction __parent__; - guint popup_delay; + guint popup_delay; + GdkEvent *stored_event; }; @@ -121,6 +122,9 @@ thunar_history_action_button_press_event (GtkWidget *toggle_button, /* schedule a popup for button press */ history_action->popup_delay = g_timeout_add (500, thunar_history_action_popup_delayed, toggle_button); + + /* store current event data */ + history_action->stored_event = gtk_get_current_event (); } else if (event->button == 3) { @@ -152,6 +156,10 @@ thunar_history_action_button_release_event (GtkWidget *toggle_button, g_source_remove (history_action->popup_delay); history_action->popup_delay = 0; + /* clear stored event data */ + gdk_event_free (history_action->stored_event); + history_action->stored_event = NULL; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* activate event */ gtk_action_activate (GTK_ACTION (history_action)); @@ -318,8 +326,16 @@ thunar_history_action_show_menu (GtkWidget *toggle_button, /* toggle the button */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_button), TRUE); - /* run the menu (takes over the floating of menu) */ - thunar_gtk_menu_run (GTK_MENU (menu)); + /* run the menu (takes over the floating of menu) + * and if there is a stored event (long press), use it */ + if (history_action->stored_event != NULL) + { + thunar_gtk_menu_run_at_event (GTK_MENU (menu), history_action->stored_event); + gdk_event_free (history_action->stored_event); + history_action->stored_event = NULL; + } + else + thunar_gtk_menu_run (GTK_MENU (menu)); }