[gimp/nielsdg/fix-context-menus: 6/6] app: Remove old GimpUiManager popup API
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/nielsdg/fix-context-menus: 6/6] app: Remove old GimpUiManager popup API
- Date: Mon, 13 Dec 2021 20:02:54 +0000 (UTC)
commit bb4403fd49982b62a494e7fb224e3ce298413014
Author: Niels De Graef <nielsdegraef gmail com>
Date: Wed Dec 8 00:09:08 2021 +0100
app: Remove old GimpUiManager popup API
The code used `gtk_menu_popup()`, which was deprecated a while ago, as
it was broken on certain GDK backends, like Wayland.
Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/5319
app/widgets/gimpeditor.c | 20 ------
app/widgets/gimpuimanager.c | 168 --------------------------------------------
app/widgets/gimpuimanager.h | 7 --
3 files changed, 195 deletions(-)
---
diff --git a/app/widgets/gimpeditor.c b/app/widgets/gimpeditor.c
index a70ddccc3a..e32ceee300 100644
--- a/app/widgets/gimpeditor.c
+++ b/app/widgets/gimpeditor.c
@@ -445,26 +445,6 @@ gimp_editor_create_menu (GimpEditor *editor,
editor->priv->popup_data = popup_data;
}
-gboolean
-gimp_editor_popup_menu (GimpEditor *editor,
- GimpMenuPositionFunc position_func,
- gpointer position_data)
-{
- g_return_val_if_fail (GIMP_IS_EDITOR (editor), FALSE);
-
- if (editor->priv->ui_manager && editor->priv->ui_path)
- {
- gimp_ui_manager_update (editor->priv->ui_manager, editor->priv->popup_data);
- gimp_ui_manager_ui_popup (editor->priv->ui_manager, editor->priv->ui_path,
- GTK_WIDGET (editor),
- position_func, position_data,
- NULL, NULL);
- return TRUE;
- }
-
- return FALSE;
-}
-
gboolean
gimp_editor_popup_menu_at_pointer (GimpEditor *editor,
const GdkEvent *trigger_event)
diff --git a/app/widgets/gimpuimanager.c b/app/widgets/gimpuimanager.c
index c3300cb87d..43845192e3 100644
--- a/app/widgets/gimpuimanager.c
+++ b/app/widgets/gimpuimanager.c
@@ -92,11 +92,6 @@ static void gimp_ui_manager_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data);
-static void gimp_ui_manager_menu_pos (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer data);
static void gimp_ui_manager_delete_popdown_data (GtkWidget *widget,
GimpUIManager *manager);
static void gimp_ui_manager_item_realize (GtkWidget *widget,
@@ -630,102 +625,6 @@ gimp_ui_manager_ui_register (GimpUIManager *manager,
manager->registered_uis = g_list_prepend (manager->registered_uis, entry);
}
-
-typedef struct
-{
- guint x;
- guint y;
-} MenuPos;
-
-static void
-menu_pos_free (MenuPos *pos)
-{
- g_slice_free (MenuPos, pos);
-}
-
-void
-gimp_ui_manager_ui_popup (GimpUIManager *manager,
- const gchar *ui_path,
- GtkWidget *parent,
- GimpMenuPositionFunc position_func,
- gpointer position_data,
- GDestroyNotify popdown_func,
- gpointer popdown_data)
-{
- GtkWidget *menu;
- GdkEvent *current_event;
- gint x, y;
- guint button;
- guint32 activate_time;
- MenuPos *menu_pos;
-
- g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
- g_return_if_fail (ui_path != NULL);
- g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
-
- menu = gimp_ui_manager_get_widget (manager, ui_path);
-
- if (GTK_IS_MENU_ITEM (menu))
- menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
-
- if (! menu)
- return;
-
- g_return_if_fail (GTK_IS_MENU (menu));
-
- if (! position_func)
- {
- position_func = gimp_ui_manager_menu_position;
- position_data = parent;
- }
-
- (* position_func) (GTK_MENU (menu), &x, &y, position_data);
-
- current_event = gtk_get_current_event ();
-
- if (current_event && current_event->type == GDK_BUTTON_PRESS)
- {
- GdkEventButton *bevent = (GdkEventButton *) current_event;
-
- button = bevent->button;
- activate_time = bevent->time;
- }
- else
- {
- button = 0;
- activate_time = 0;
- }
-
- if (current_event)
- gdk_event_free (current_event);
-
- menu_pos = g_object_get_data (G_OBJECT (menu), "menu-pos");
-
- if (! menu_pos)
- {
- menu_pos = g_slice_new0 (MenuPos);
- g_object_set_data_full (G_OBJECT (menu), "menu-pos", menu_pos,
- (GDestroyNotify) menu_pos_free);
- }
-
- menu_pos->x = x;
- menu_pos->y = y;
-
- if (popdown_func && popdown_data)
- {
- g_object_set_data_full (G_OBJECT (manager), "popdown-data",
- popdown_data, popdown_func);
- g_signal_connect (menu, "selection-done",
- G_CALLBACK (gimp_ui_manager_delete_popdown_data),
- manager);
- }
-
- gtk_menu_popup (GTK_MENU (menu),
- NULL, NULL,
- gimp_ui_manager_menu_pos, menu_pos,
- button, activate_time);
-}
-
void
gimp_ui_manager_ui_popup_at_widget (GimpUIManager *manager,
const gchar *ui_path,
@@ -1007,73 +906,6 @@ gimp_ui_manager_entry_ensure (GimpUIManager *manager,
return entry;
}
-static void
-gimp_ui_manager_menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
- gpointer data)
-{
- GdkSeat *seat;
- GdkDevice *device;
- GdkScreen *screen;
- GtkRequisition requisition;
- GdkRectangle workarea;
- gint pointer_x;
- gint pointer_y;
-
- g_return_if_fail (GTK_IS_MENU (menu));
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
- g_return_if_fail (GTK_IS_WIDGET (data));
-
- seat = gdk_display_get_default_seat (gtk_widget_get_display (data));
- device = gdk_seat_get_pointer (seat);
-
- gdk_device_get_position (device, &screen, &pointer_x, &pointer_y);
-
- gdk_monitor_get_workarea (gimp_get_monitor_at_pointer (), &workarea);
-
- gtk_menu_set_screen (menu, screen);
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
-
- if (gtk_widget_get_direction (GTK_WIDGET (menu)) == GTK_TEXT_DIR_RTL)
- {
- *x = pointer_x - 2 - requisition.width;
-
- if (*x < workarea.x)
- *x = pointer_x + 2;
- }
- else
- {
- *x = pointer_x + 2;
-
- if (*x + requisition.width > workarea.x + workarea.width)
- *x = pointer_x - 2 - requisition.width;
- }
-
- *y = pointer_y + 2;
-
- if (*y + requisition.height > workarea.y + workarea.height)
- *y = pointer_y - 2 - requisition.height;
-
- if (*x < workarea.x) *x = workarea.x;
- if (*y < workarea.y) *y = workarea.y;
-}
-
-static void
-gimp_ui_manager_menu_pos (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer data)
-{
- MenuPos *menu_pos = data;
-
- *x = menu_pos->x;
- *y = menu_pos->y;
-}
-
static void
gimp_ui_manager_delete_popdown_data (GtkWidget *widget,
GimpUIManager *manager)
diff --git a/app/widgets/gimpuimanager.h b/app/widgets/gimpuimanager.h
index 2b6cabf5f6..319668e291 100644
--- a/app/widgets/gimpuimanager.h
+++ b/app/widgets/gimpuimanager.h
@@ -126,13 +126,6 @@ void gimp_ui_manager_ui_register (GimpUIManager *manager,
const gchar *basename,
GimpUIManagerSetupFunc setup_func);
-void gimp_ui_manager_ui_popup (GimpUIManager *manager,
- const gchar *ui_path,
- GtkWidget *parent,
- GimpMenuPositionFunc position_func,
- gpointer position_data,
- GDestroyNotify popdown_func,
- gpointer popdown_data);
void gimp_ui_manager_ui_popup_at_widget
(GimpUIManager *manager,
const gchar *ui_path,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]