Skip to content

Commit

Permalink
Merge pull request #3011 from dolik-rce/fix-context-menus-on-wayland
Browse files Browse the repository at this point in the history
Fix context menus on wayland (#3009)
  • Loading branch information
eht16 committed Sep 17, 2022
2 parents 465e60b + 3bffc45 commit 3698462
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/callbacks.c
Expand Up @@ -634,7 +634,7 @@ gboolean toolbar_popup_menu(GtkWidget *widget, GdkEventButton *event, gpointer u
{
if (event->button == 3)
{
gtk_menu_popup(GTK_MENU(ui_widgets.toolbar_menu), NULL, NULL, NULL, NULL, event->button, event->time);
ui_menu_popup(GTK_MENU(ui_widgets.toolbar_menu), NULL, NULL, event->button, event->time);
return TRUE;
}
return FALSE;
Expand Down
4 changes: 1 addition & 3 deletions src/editor.c
Expand Up @@ -346,9 +346,7 @@ static gboolean on_editor_button_press_event(GtkWidget *widget, GdkEventButton *
g_signal_emit_by_name(geany_object, "update-editor-menu",
current_word, editor_info.click_pos, doc);

gtk_menu_popup(GTK_MENU(main_widgets.editor_menu),
NULL, NULL, NULL, NULL, event->button, event->time);

ui_menu_popup(GTK_MENU(main_widgets.editor_menu), NULL, NULL, event->button, event->time);
return TRUE;
}
return FALSE;
Expand Down
12 changes: 6 additions & 6 deletions src/msgwindow.c
Expand Up @@ -1236,20 +1236,20 @@ static gboolean on_msgwin_button_press_event(GtkWidget *widget, GdkEventButton *
{
case MSG_STATUS:
{
gtk_menu_popup(GTK_MENU(msgwindow.popup_status_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(msgwindow.popup_status_menu), NULL, NULL,
event->button, event->time);
break;
}
case MSG_MESSAGE:
{
gtk_menu_popup(GTK_MENU(msgwindow.popup_msg_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(msgwindow.popup_msg_menu), NULL, NULL,
event->button, event->time);
break;
}
case MSG_COMPILER:
{
gtk_menu_popup(GTK_MENU(msgwindow.popup_compiler_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(msgwindow.popup_compiler_menu), NULL, NULL,
event->button, event->time);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/notebook.c
Expand Up @@ -508,7 +508,7 @@ static void show_tab_bar_popup_menu(GdkEventButton *event, GeanyDocument *doc)
gtk_container_add(GTK_CONTAINER(menu), menu_item);
g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_all1_activate), NULL);

gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
ui_menu_popup(GTK_MENU(menu), NULL, NULL, event->button, event->time);
}


Expand Down
4 changes: 2 additions & 2 deletions src/plugins.c
Expand Up @@ -1642,8 +1642,8 @@ static gboolean pm_treeview_button_press_cb(GtkWidget *widget, GdkEventButton *e
{
if (event->button == 3)
{
gtk_menu_popup(GTK_MENU(pm_widgets.popup_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(pm_widgets.popup_menu), NULL, NULL,
event->button, event->time);
}
return FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/prefs.c
Expand Up @@ -246,7 +246,7 @@ static void kb_show_popup_menu(KbData *kbdata, GtkWidget *widget, GdkEventButton
event_time = gtk_get_current_event_time();
}

gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, event_time);
ui_menu_popup(GTK_MENU(menu), NULL, NULL, button, event_time);
}


Expand Down
11 changes: 5 additions & 6 deletions src/sidebar.c
Expand Up @@ -145,8 +145,7 @@ on_default_tag_tree_button_press_event(GtkWidget *widget, GdkEventButton *event,
{
if (event->button == 3)
{
gtk_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, event->button, event->time);
return TRUE;
}
return FALSE;
Expand Down Expand Up @@ -1503,13 +1502,13 @@ static gboolean sidebar_button_press_cb(GtkWidget *widget, GdkEventButton *event

/* update menu item sensitivity */
documents_menu_update(selection);
gtk_menu_popup(GTK_MENU(openfiles_popup_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(openfiles_popup_menu), NULL, NULL,
event->button, event->time);
}
else
{
gtk_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL, NULL, NULL,
event->button, event->time);
ui_menu_popup(GTK_MENU(tv.popup_taglist), NULL, NULL,
event->button, event->time);
}
handled = TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/symbols.c
Expand Up @@ -1536,8 +1536,8 @@ static void show_goto_popup(GeanyDocument *doc, GPtrArray *tags, gboolean have_b

g_object_set_data_full(G_OBJECT(menu), "geany-button-event", button_event,
button_event ? (GDestroyNotify) gdk_event_free : NULL);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, goto_popup_position_func, doc->editor->sci,
button_event ? button_event->button : 0, gtk_get_current_event_time ());
ui_menu_popup(GTK_MENU(menu), goto_popup_position_func, doc->editor->sci,
button_event ? button_event->button : 0, gtk_get_current_event_time ());
}


Expand Down
12 changes: 12 additions & 0 deletions src/ui_utils.c
Expand Up @@ -3229,3 +3229,15 @@ gboolean ui_encodings_combo_box_set_active_encoding(GtkComboBox *combo, gint enc
}
return FALSE;
}

void ui_menu_popup(GtkMenu* menu, GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time)
{
/* Use appropriate function for menu popup:
- gtk_menu_popup_at_pointer is not available on GTK older than 3.22
- gtk_menu_popup is deprecated and causes issues on multimonitor wayland setups */
#if GTK_CHECK_VERSION(3,22,0)
gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, func, data, button, activate_time);
#endif
}
2 changes: 2 additions & 0 deletions src/ui_utils.h
Expand Up @@ -368,6 +368,8 @@ gboolean ui_encodings_combo_box_set_active_encoding(GtkComboBox *combo, gint enc

gchar *ui_get_project_directory(const gchar *path);

void ui_menu_popup(GtkMenu* menu, GtkMenuPositionFunc func, gpointer data, guint button, guint32 activate_time);

#endif /* GEANY_PRIVATE */

G_END_DECLS
Expand Down
2 changes: 1 addition & 1 deletion src/vte.c
Expand Up @@ -526,7 +526,7 @@ static gboolean vte_button_pressed(GtkWidget *widget, GdkEventButton *event, gpo
if (event->button == 3)
{
gtk_widget_grab_focus(vte_config.vte);
gtk_menu_popup(GTK_MENU(vte_config.menu), NULL, NULL, NULL, NULL, event->button, event->time);
ui_menu_popup(GTK_MENU(vte_config.menu), NULL, NULL, event->button, event->time);
return TRUE;
}
else if (event->button == 2)
Expand Down

0 comments on commit 3698462

Please sign in to comment.