[evolution] Bug 779170 - [Wayland] gtk_menu_popup() lefts menu out of screen
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 779170 - [Wayland] gtk_menu_popup() lefts menu out of screen
- Date: Mon, 11 Sep 2017 16:06:36 +0000 (UTC)
commit 0283bc958b9f22cb2db0cd2924b927fdf7b561e6
Author: William Hua <william attente ca>
Date: Mon Sep 11 18:06:24 2017 +0200
Bug 779170 - [Wayland] gtk_menu_popup() lefts menu out of screen
CMakeLists.txt | 4 +-
src/calendar/gui/e-day-view-time-item.c | 4 +-
src/calendar/gui/e-meeting-time-sel.c | 104 +++++-------------------
src/calendar/gui/e-to-do-pane.c | 13 +---
src/e-util/e-accounts-window.c | 73 +++---------------
src/e-util/e-attachment-icon-view.c | 5 +-
src/e-util/e-attachment-tree-view.c | 5 +-
src/e-util/e-attachment-view.c | 30 +------
src/e-util/e-attachment-view.h | 5 -
src/e-util/e-calendar-item.c | 39 +---------
src/e-util/e-html-editor.c | 13 +--
src/e-util/e-name-selector-list.c | 2 +-
src/e-util/e-table-header-item.c | 14 +---
src/e-util/e-text.c | 51 ++++---------
src/e-util/e-web-view.c | 8 +--
src/mail/e-mail-browser.c | 8 +--
src/mail/e-mail-display.c | 65 ++++------------
src/mail/e-mail-reader.c | 73 +++--------------
src/mail/em-subscription-editor.c | 76 ++++++------------
src/modules/calendar/e-calendar-preferences.c | 4 +-
src/modules/mail/e-mail-shell-view-private.c | 8 +--
src/shell/e-shell-view.c | 15 +---
src/smime/gui/certificate-manager.c | 6 +-
23 files changed, 132 insertions(+), 493 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f4b3e6..3f14494 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,8 +50,8 @@ set(glib_minimum_version 2.46)
set(glib_encoded_version GLIB_VERSION_2_46)
# Keep these two definitions in agreement.
-set(gdk_minimum_version 3.10)
-set(gdk_encoded_version GDK_VERSION_3_10)
+set(gdk_minimum_version 3.22)
+set(gdk_encoded_version GDK_VERSION_3_22)
# Keep these two definitions in agreement.
set(soup_minimum_version 2.42)
diff --git a/src/calendar/gui/e-day-view-time-item.c b/src/calendar/gui/e-day-view-time-item.c
index 67de79d..0afec82 100644
--- a/src/calendar/gui/e-day-view-time-item.c
+++ b/src/calendar/gui/e-day-view-time-item.c
@@ -888,9 +888,7 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item,
gtk_menu_attach_to_widget (GTK_MENU (menu),
GTK_WIDGET (day_view),
NULL);
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button.button, event->button.time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), event);
}
static void
diff --git a/src/calendar/gui/e-meeting-time-sel.c b/src/calendar/gui/e-meeting-time-sel.c
index 1898ba7..24269bb 100644
--- a/src/calendar/gui/e-meeting-time-sel.c
+++ b/src/calendar/gui/e-meeting-time-sel.c
@@ -115,11 +115,6 @@ static void e_meeting_time_selector_on_canvas_realized (GtkWidget *widget,
static void e_meeting_time_selector_on_options_button_clicked (GtkWidget *button,
EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_options_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
static void e_meeting_time_selector_on_zoomed_out_toggled (GtkCheckMenuItem *button,
EMeetingTimeSelector *mts);
static void e_meeting_time_selector_on_working_hours_toggled (GtkCheckMenuItem *menuitem,
@@ -130,11 +125,6 @@ static void e_meeting_time_selector_on_update_free_busy (GtkWidget *button,
EMeetingTimeSelector *mts);
static void e_meeting_time_selector_on_autopick_button_clicked (GtkWidget *button,
EMeetingTimeSelector *mts);
-static void e_meeting_time_selector_autopick_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
static void e_meeting_time_selector_on_autopick_option_toggled (GtkWidget *button,
EMeetingTimeSelector *mts);
static void e_meeting_time_selector_on_prev_button_clicked (GtkWidget *button,
@@ -1678,42 +1668,17 @@ static void
e_meeting_time_selector_on_options_button_clicked (GtkWidget *button,
EMeetingTimeSelector *mts)
{
- gtk_menu_popup (
- GTK_MENU (mts->options_menu), NULL, NULL,
- e_meeting_time_selector_options_menu_position_callback,
- mts, 1, GDK_CURRENT_TIME);
-}
-
-static void
-e_meeting_time_selector_options_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- EMeetingTimeSelector *mts;
- GtkRequisition menu_requisition;
- GtkAllocation allocation;
- GtkWidget *widget;
- GdkWindow *window;
- gint max_x, max_y;
-
- mts = E_MEETING_TIME_SELECTOR (user_data);
-
- /* Calculate our preferred position. */
- widget = mts->options_button;
- window = gtk_widget_get_window (widget);
- gdk_window_get_origin (window, x, y);
- gtk_widget_get_allocation (widget, &allocation);
- *x += allocation.x;
- *y += allocation.y + allocation.height - 2;
+ g_object_set (mts->options_menu,
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
- /* Now make sure we are on the screen. */
- gtk_widget_get_preferred_size (mts->options_menu, &menu_requisition, NULL);
- max_x = MAX (0, gdk_screen_width () - menu_requisition.width);
- max_y = MAX (0, gdk_screen_height () - menu_requisition.height);
- *x = CLAMP (*x, 0, max_x);
- *y = CLAMP (*y, 0, max_y);
+ gtk_menu_popup_at_widget (GTK_MENU (mts->options_menu),
+ mts->options_button,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
}
static void
@@ -1732,42 +1697,17 @@ static void
e_meeting_time_selector_on_autopick_button_clicked (GtkWidget *button,
EMeetingTimeSelector *mts)
{
- gtk_menu_popup (
- GTK_MENU (mts->autopick_menu), NULL, NULL,
- e_meeting_time_selector_autopick_menu_position_callback,
- mts, 1, GDK_CURRENT_TIME);
-}
-
-static void
-e_meeting_time_selector_autopick_menu_position_callback (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- EMeetingTimeSelector *mts;
- GtkRequisition menu_requisition;
- GtkAllocation allocation;
- GtkWidget *widget;
- GdkWindow *window;
- gint max_x, max_y;
-
- mts = E_MEETING_TIME_SELECTOR (user_data);
-
- /* Calculate our preferred position. */
- widget = mts->autopick_button;
- window = gtk_widget_get_window (widget);
- gdk_window_get_origin (window, x, y);
- gtk_widget_get_allocation (widget, &allocation);
- *x += allocation.x;
- *y += allocation.y + allocation.height - 2;
-
- /* Now make sure we are on the screen. */
- gtk_widget_get_preferred_size (mts->autopick_menu, &menu_requisition, NULL);
- max_x = MAX (0, gdk_screen_width () - menu_requisition.width);
- max_y = MAX (0, gdk_screen_height () - menu_requisition.height);
- *x = CLAMP (*x, 0, max_x);
- *y = CLAMP (*y, 0, max_y);
+ g_object_set (mts->autopick_menu,
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
+
+ gtk_menu_popup_at_widget (GTK_MENU (mts->autopick_menu),
+ mts->autopick_button,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
}
static void
diff --git a/src/calendar/gui/e-to-do-pane.c b/src/calendar/gui/e-to-do-pane.c
index 973d6a6..3fd10f4 100644
--- a/src/calendar/gui/e-to-do-pane.c
+++ b/src/calendar/gui/e-to-do-pane.c
@@ -1993,7 +1993,6 @@ etdp_popup_menu (EToDoPane *to_do_pane,
GdkEvent *event)
{
GtkMenu *menu;
- guint button, event_time;
menu = GTK_MENU (gtk_menu_new ());
@@ -2002,18 +2001,8 @@ etdp_popup_menu (EToDoPane *to_do_pane,
etdp_fill_popup_menu (to_do_pane, menu);
- if (event) {
- if (!gdk_event_get_button (event, &button))
- button = 0;
-
- event_time = gdk_event_get_time (event);
- } else {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
gtk_menu_attach_to_widget (menu, GTK_WIDGET (to_do_pane->priv->tree_view), NULL);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, event_time);
+ gtk_menu_popup_at_pointer (menu, event);
}
static gboolean
diff --git a/src/e-util/e-accounts-window.c b/src/e-util/e-accounts-window.c
index f47d8c6..9047df4 100644
--- a/src/e-util/e-accounts-window.c
+++ b/src/e-util/e-accounts-window.c
@@ -1380,59 +1380,6 @@ accounts_window_tree_view_new (EAccountsWindow *accounts_window)
}
static void
-accounts_window_add_menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkRequisition menu_requisition;
- GtkTextDirection direction;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkScreen *screen;
- GdkWindow *window;
- GtkWidget *widget = user_data;
- gint monitor_num;
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL);
-
- window = gtk_widget_get_parent_window (widget);
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gdk_window_get_origin (window, x, y);
- *x += allocation.x;
- *y += allocation.y;
-
- direction = gtk_widget_get_direction (widget);
- if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (allocation.width - menu_requisition.width, 0);
- else if (menu_requisition.width > allocation.width)
- *x -= menu_requisition.width - allocation.width;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- if ((*y + allocation.height +
- menu_requisition.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_requisition.height) >= monitor.y)
- *y -= menu_requisition.height;
- else if (monitor.y + monitor.height -
- (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_requisition.height;
-
- *push_in = FALSE;
-}
-
-static void
accounts_window_add_menu_activate_cb (GObject *item,
gpointer user_data)
{
@@ -1487,15 +1434,17 @@ accounts_window_show_add_popup (EAccountsWindow *accounts_window,
gtk_menu_attach_to_widget (GTK_MENU (popup_menu), accounts_window->priv->add_box, NULL);
- if (event) {
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- accounts_window_add_menu_position, accounts_window->priv->add_box,
- event->button, event->time);
- } else {
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- accounts_window_add_menu_position, accounts_window->priv->add_box,
- 0, gtk_get_current_event_time ());
- }
+ g_object_set (popup_menu,
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
+
+ gtk_menu_popup_at_widget (GTK_MENU (popup_menu),
+ accounts_window->priv->add_box,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (const GdkEvent *) event);
}
static void
diff --git a/src/e-util/e-attachment-icon-view.c b/src/e-util/e-attachment-icon-view.c
index 1f33644..6a49982 100644
--- a/src/e-util/e-attachment-icon-view.c
+++ b/src/e-util/e-attachment-icon-view.c
@@ -340,8 +340,11 @@ static gboolean
attachment_icon_view_popup_menu (GtkWidget *widget)
{
EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
+ GtkWidget *menu;
- e_attachment_view_show_popup_menu (view, NULL, NULL, NULL);
+ e_attachment_view_update_actions (view);
+ menu = e_attachment_view_get_popup_menu (view);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
return TRUE;
}
diff --git a/src/e-util/e-attachment-tree-view.c b/src/e-util/e-attachment-tree-view.c
index 8d19eb5..79aed5f 100644
--- a/src/e-util/e-attachment-tree-view.c
+++ b/src/e-util/e-attachment-tree-view.c
@@ -382,8 +382,11 @@ static gboolean
attachment_tree_view_popup_menu (GtkWidget *widget)
{
EAttachmentView *view = E_ATTACHMENT_VIEW (widget);
+ GtkWidget *menu;
- e_attachment_view_show_popup_menu (view, NULL, NULL, NULL);
+ e_attachment_view_update_actions (view);
+ menu = e_attachment_view_get_popup_menu (view);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
return TRUE;
}
diff --git a/src/e-util/e-attachment-view.c b/src/e-util/e-attachment-view.c
index 61b6c2d..43f3b86 100644
--- a/src/e-util/e-attachment-view.c
+++ b/src/e-util/e-attachment-view.c
@@ -1213,6 +1213,7 @@ e_attachment_view_button_press_event (EAttachmentView *view,
{
EAttachmentViewPrivate *priv;
GtkTreePath *path;
+ GtkWidget *menu;
gboolean editable;
gboolean handled = FALSE;
gboolean path_is_selected = FALSE;
@@ -1280,8 +1281,9 @@ e_attachment_view_button_press_event (EAttachmentView *view,
* popup menu when right-clicking on an attachment,
* but editable views can show the menu any time. */
if (path != NULL || editable) {
- e_attachment_view_show_popup_menu (
- view, event, NULL, NULL);
+ e_attachment_view_update_actions (view);
+ menu = e_attachment_view_get_popup_menu (view);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), (const GdkEvent *) event);
handled = TRUE;
}
}
@@ -1876,30 +1878,6 @@ e_attachment_view_get_ui_manager (EAttachmentView *view)
}
void
-e_attachment_view_show_popup_menu (EAttachmentView *view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data)
-{
- GtkWidget *menu;
-
- g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
-
- e_attachment_view_update_actions (view);
-
- menu = e_attachment_view_get_popup_menu (view);
-
- if (event != NULL)
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, event->button, event->time);
- else
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, func,
- user_data, 0, gtk_get_current_event_time ());
-}
-
-void
e_attachment_view_update_actions (EAttachmentView *view)
{
g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
diff --git a/src/e-util/e-attachment-view.h b/src/e-util/e-attachment-view.h
index 51a4efb..98744c9 100644
--- a/src/e-util/e-attachment-view.h
+++ b/src/e-util/e-attachment-view.h
@@ -230,11 +230,6 @@ GtkWidget * e_attachment_view_get_popup_menu
(EAttachmentView *view);
GtkUIManager * e_attachment_view_get_ui_manager
(EAttachmentView *view);
-void e_attachment_view_show_popup_menu
- (EAttachmentView *view,
- GdkEventButton *event,
- GtkMenuPositionFunc func,
- gpointer user_data);
void e_attachment_view_update_actions
(EAttachmentView *view);
diff --git a/src/e-util/e-calendar-item.c b/src/e-util/e-calendar-item.c
index d70a0bb..2333218 100644
--- a/src/e-util/e-calendar-item.c
+++ b/src/e-util/e-calendar-item.c
@@ -194,11 +194,6 @@ static void e_calendar_item_show_popup_menu (ECalendarItem *calitem,
static void e_calendar_item_on_menu_item_activate
(GtkWidget *menuitem,
ECalendarItem *calitem);
-static void e_calendar_item_position_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
static void e_calendar_item_date_range_changed
(ECalendarItem *calitem);
static void e_calendar_item_queue_signal_emission
@@ -3674,8 +3669,6 @@ e_calendar_item_show_popup_menu (ECalendarItem *calitem,
gint year, month;
const gchar *name;
gchar buffer[64];
- guint event_button = 0;
- guint32 event_time;
menu = gtk_menu_new ();
@@ -3722,15 +3715,9 @@ e_calendar_item_show_popup_menu (ECalendarItem *calitem,
menu, "deactivate",
G_CALLBACK (deactivate_menu_cb), NULL);
- gdk_event_get_button (button_event, &event_button);
- event_time = gdk_event_get_time (button_event);
-
canvas_widget = GTK_WIDGET (calitem->canvas_item.canvas);
gtk_menu_attach_to_widget (GTK_MENU (menu), canvas_widget, NULL);
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL,
- e_calendar_item_position_menu, calitem,
- event_button, event_time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), button_event);
}
static void
@@ -3757,30 +3744,6 @@ e_calendar_item_on_menu_item_activate (GtkWidget *menuitem,
e_calendar_item_set_first_month_with_emit (calitem, year, month, TRUE);
}
-static void
-e_calendar_item_position_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkRequisition requisition;
- gint screen_width, screen_height;
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
-
- *x -= (gtk_widget_get_direction(GTK_WIDGET(menu)) == GTK_TEXT_DIR_RTL)
- ? requisition.width - 2
- : 2;
- *y -= requisition.height / 2;
-
- screen_width = gdk_screen_width ();
- screen_height = gdk_screen_height ();
-
- *x = CLAMP (*x, 0, screen_width - requisition.width);
- *y = CLAMP (*y, 0, screen_height - requisition.height);
-}
-
/* Sets the function to call to get the colors to use for a particular day. */
void
e_calendar_item_set_style_callback (ECalendarItem *calitem,
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 34edc4c..94cf59c 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -492,8 +492,7 @@ html_editor_spell_languages_changed (EHTMLEditor *editor)
typedef struct _ContextMenuData {
GWeakRef *editor_weakref; /* EHTMLEditor * */
EContentEditorNodeFlags flags;
- guint button;
- guint32 time;
+ GdkEvent *event;
} ContextMenuData;
static void
@@ -502,6 +501,7 @@ context_menu_data_free (gpointer ptr)
ContextMenuData *cmd = ptr;
if (cmd) {
+ g_clear_pointer (&cmd->event, gdk_event_free);
e_weak_ref_free (cmd->editor_weakref);
g_free (cmd);
}
@@ -526,8 +526,7 @@ html_editor_show_context_menu_idle_cb (gpointer user_data)
if (!gtk_menu_get_attach_widget (GTK_MENU (menu)))
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (editor), NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
- GTK_WIDGET (e_html_editor_get_content_editor (editor)), cmd->button, cmd->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), cmd->event);
g_object_unref (editor);
}
@@ -548,11 +547,7 @@ html_editor_context_menu_requested_cb (EContentEditor *cnt_editor,
cmd = g_new0 (ContextMenuData, 1);
cmd->editor_weakref = e_weak_ref_new (editor);
cmd->flags = flags;
-
- if (!event || !gdk_event_get_button (event, &cmd->button))
- cmd->button = 0;
-
- cmd->time = event ? gdk_event_get_time (event) : gtk_get_current_event_time ();
+ cmd->event = gdk_event_copy (event);
g_idle_add_full (G_PRIORITY_LOW, html_editor_show_context_menu_idle_cb,
cmd, context_menu_data_free);
diff --git a/src/e-util/e-name-selector-list.c b/src/e-util/e-name-selector-list.c
index 548c6d3..53ffb12 100644
--- a/src/e-util/e-name-selector-list.c
+++ b/src/e-util/e-name-selector-list.c
@@ -495,7 +495,7 @@ enl_tree_button_press_event (GtkWidget *widget,
g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivate), list);
list->priv->menu = menu;
gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, gtk_get_current_event_time
());
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), (const GdkEvent *) event);
email_num = e_destination_get_email_num (destination);
diff --git a/src/e-util/e-table-header-item.c b/src/e-util/e-table-header-item.c
index 4b16d44..d43f088 100644
--- a/src/e-util/e-table-header-item.c
+++ b/src/e-util/e-table-header-item.c
@@ -1710,14 +1710,10 @@ ethi_header_context_menu (ETableHeaderItem *ethi,
gboolean ascending = TRUE;
gdouble event_x_win = 0;
gdouble event_y_win = 0;
- guint event_button = 0;
- guint32 event_time;
d (g_print ("ethi_header_context_menu: \n"));
- gdk_event_get_button (button_event, &event_button);
gdk_event_get_coords (button_event, &event_x_win, &event_y_win);
- event_time = gdk_event_get_time (button_event);
info->ethi = ethi;
info->col = ethi_find_col_by_x (ethi, event_x_win);
@@ -1811,10 +1807,7 @@ ethi_header_context_menu (ETableHeaderItem *ethi,
gtk_menu_attach_to_widget (GTK_MENU (popup),
GTK_WIDGET (ethi->parent.canvas),
NULL);
- gtk_menu_popup (
- GTK_MENU (popup),
- NULL, NULL, NULL, NULL,
- event_button, event_time);
+ gtk_menu_popup_at_pointer (popup, button_event);
}
static void
@@ -2118,10 +2111,7 @@ ethi_event (GnomeCanvasItem *item,
gtk_menu_attach_to_widget (GTK_MENU (popup),
GTK_WIDGET (canvas),
NULL);
- gtk_menu_popup (
- GTK_MENU (popup),
- NULL, NULL, NULL, NULL,
- 0, GDK_CURRENT_TIME);
+ gtk_menu_popup_at_pointer (popup, event);
} else if (event_keyval == GDK_KEY_space) {
ETableCol *ecol;
diff --git a/src/e-util/e-text.c b/src/e-util/e-text.c
index 38b5e73..df58522 100644
--- a/src/e-util/e-text.c
+++ b/src/e-util/e-text.c
@@ -2046,29 +2046,6 @@ popup_menu_detach (GtkWidget *attach_widget,
}
static void
-popup_menu_placement_cb (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- EText *text = E_TEXT (user_data);
- GnomeCanvasItem *item = &text->item;
- GnomeCanvas *parent = item->canvas;
-
- if (parent) {
- GdkWindow *window;
-
- window = gtk_widget_get_window (GTK_WIDGET (parent));
- gdk_window_get_origin (window, x, y);
- *x += item->x1 + text->width / 2;
- *y += item->y1 + text->height / 2;
- }
-
- return;
-}
-
-static void
popup_targets_received (GtkClipboard *clipboard,
GtkSelectionData *data,
gpointer user_data)
@@ -2080,10 +2057,9 @@ popup_targets_received (GtkClipboard *clipboard,
GtkWidget *popup_menu = gtk_menu_new ();
GtkWidget *menuitem, *submenu;
guint event_button = 0;
- guint32 event_time;
+ GdkRectangle rect;
gdk_event_get_button (event, &event_button);
- event_time = gdk_event_get_time (event);
g_free (closure);
@@ -2166,17 +2142,20 @@ popup_targets_received (GtkClipboard *clipboard,
popup_menu);
/* If invoked by S-F10 key binding, button will be 0. */
- if (event_button == 0) {
- gtk_menu_popup (
- GTK_MENU (popup_menu), NULL, NULL,
- popup_menu_placement_cb, (gpointer) text,
- event_button, GDK_CURRENT_TIME);
- } else {
- gtk_menu_popup (
- GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL,
- event_button, event_time);
- }
+ if (event_button == 0 && text->item.canvas) {
+ rect.x = text->item.x1;
+ rect.y = text->item.y1;
+ rect.width = text->width;
+ rect.height = text->height;
+
+ gtk_menu_popup_at_rect (GTK_MENU (popup_menu),
+ gtk_widget_get_window (GTK_WIDGET (text->item.canvas)),
+ &rect,
+ GDK_GRAVITY_CENTER,
+ GDK_GRAVITY_NORTH_WEST,
+ event);
+ } else
+ gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), event);
g_object_unref (text);
gdk_event_free (event);
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index ff9a3f6..54a26b6 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -3261,7 +3261,6 @@ e_web_view_show_popup_menu (EWebView *web_view,
GdkEvent *event)
{
GtkWidget *menu;
- guint button;
g_return_if_fail (E_IS_WEB_VIEW (web_view));
@@ -3269,12 +3268,7 @@ e_web_view_show_popup_menu (EWebView *web_view,
menu = e_web_view_get_popup_menu (web_view);
- if (!event || !gdk_event_get_button (event, &button))
- button = 0;
-
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, NULL, NULL,
- button, event ? gdk_event_get_time (event) : gtk_get_current_event_time ());
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), event);
}
/**
diff --git a/src/mail/e-mail-browser.c b/src/mail/e-mail-browser.c
index f87ff6d..1928ae4 100644
--- a/src/mail/e-mail-browser.c
+++ b/src/mail/e-mail-browser.c
@@ -329,7 +329,6 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
EWebView *web_view;
GtkMenu *menu;
guint32 state;
- guint button;
if (uri != NULL)
return FALSE;
@@ -345,12 +344,7 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
state = e_mail_reader_check_state (reader);
e_mail_reader_update_actions (reader, state);
- if (!event || !gdk_event_get_button (event, &button))
- button = 0;
-
- gtk_menu_popup (
- menu, NULL, NULL, NULL, NULL,
- button, event ? gdk_event_get_time (event) : gtk_get_current_event_time ());
+ gtk_menu_popup_at_pointer (menu, event);
return TRUE;
}
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index cb4c661..f9befc8 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -87,8 +87,6 @@ struct _EMailDisplayPrivate {
guint web_extension_headers_collapsed_signal_id;
guint web_extension_mail_part_appeared_signal_id;
-
- GtkAllocation attachment_popup_position;
};
enum {
@@ -1004,50 +1002,6 @@ mail_display_attachment_menu_deactivate_cb (GtkMenuShell *menu,
}
static void
-mail_display_attachment_menu_position_cb (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkRequisition menu_requisition;
- GtkTextDirection direction;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkScreen *screen;
- GdkWindow *window;
- GtkWidget *widget;
- EMailDisplay *display = user_data;
- gint monitor_num;
-
- g_return_if_fail (E_IS_MAIL_DISPLAY (display));
-
- widget = GTK_WIDGET (display);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL);
-
- window = gtk_widget_get_parent_window (widget);
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- allocation = display->priv->attachment_popup_position;
-
- gdk_window_get_origin (window, x, y);
- *x += allocation.x;
- *y += allocation.y + allocation.height;
-
- direction = gtk_widget_get_direction (widget);
- if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (allocation.width - menu_requisition.width, 0);
- else if (menu_requisition.width > allocation.width)
- *x -= menu_requisition.width - allocation.width;
-
- *push_in = FALSE;
-}
-
-static void
mail_display_attachment_select_path (EAttachmentView *view,
EAttachment *attachment)
{
@@ -1099,13 +1053,24 @@ mail_display_attachment_menu_clicked_cb (EWebView *web_view,
G_CALLBACK (mail_display_attachment_menu_deactivate_cb), display);
mail_display_attachment_select_path (view, attachment);
- display->priv->attachment_popup_position = *element_position;
-
mail_display_attachment_inline_update_actions (display);
gtk_action_group_set_visible (display->priv->attachment_inline_group, TRUE);
- e_attachment_view_show_popup_menu (view, NULL,
- mail_display_attachment_menu_position_cb, display);
+ e_attachment_view_update_actions (view);
+ popup_menu = e_attachment_view_get_popup_menu (view);
+
+ g_object_set (GTK_MENU (popup_menu),
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
+
+ gtk_menu_popup_at_rect (GTK_MENU (popup_menu),
+ gtk_widget_get_parent_window (GTK_WIDGET (display)),
+ element_position,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
}
g_clear_object (&attachment);
diff --git a/src/mail/e-mail-reader.c b/src/mail/e-mail-reader.c
index ce2df97..c2ad8f7 100644
--- a/src/mail/e-mail-reader.c
+++ b/src/mail/e-mail-reader.c
@@ -5234,59 +5234,6 @@ e_mail_reader_get_from_mails (EMailDisplay *mail_display)
}
static void
-e_mail_reader_remote_content_menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkRequisition menu_requisition;
- GtkTextDirection direction;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkScreen *screen;
- GdkWindow *window;
- GtkWidget *widget = user_data;
- gint monitor_num;
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL);
-
- window = gtk_widget_get_parent_window (widget);
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gdk_window_get_origin (window, x, y);
- *x += allocation.x;
- *y += allocation.y;
-
- direction = gtk_widget_get_direction (widget);
- if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (allocation.width - menu_requisition.width, 0);
- else if (menu_requisition.width > allocation.width)
- *x -= menu_requisition.width - allocation.width;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- if ((*y + allocation.height +
- menu_requisition.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_requisition.height) >= monitor.y)
- *y -= menu_requisition.height;
- else if (monitor.y + monitor.height -
- (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_requisition.height;
-
- *push_in = FALSE;
-}
-
-static void
e_mail_reader_remote_content_menu_deactivate_cb (GtkMenuShell *popup_menu,
GtkToggleButton *toggle_button)
{
@@ -5453,14 +5400,18 @@ e_mail_reader_show_remote_content_popup (EMailReader *reader,
gtk_widget_show_all (popup_menu);
gtk_menu_attach_to_widget (GTK_MENU (popup_menu), box, NULL);
- if (event)
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- e_mail_reader_remote_content_menu_position,
- box, event->button, event->time);
- else
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- e_mail_reader_remote_content_menu_position,
- box, 0, gtk_get_current_event_time ());
+
+ g_object_set (popup_menu,
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
+
+ gtk_menu_popup_at_widget (GTK_MENU (popup_menu),
+ box,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (const GdkEvent *) event);
}
}
diff --git a/src/mail/em-subscription-editor.c b/src/mail/em-subscription-editor.c
index c7027b0..d228626 100644
--- a/src/mail/em-subscription-editor.c
+++ b/src/mail/em-subscription-editor.c
@@ -583,48 +583,6 @@ subscription_editor_create_menu_item (const gchar *label,
return item;
}
-static void
-position_below_widget_cb (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer under_widget)
-{
- GtkRequisition menu_requisition;
- GtkTextDirection direction;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkScreen *screen;
- GdkWindow *window;
- GtkWidget *widget;
- gint monitor_num;
-
- widget = under_widget;
- gtk_widget_get_preferred_size (
- GTK_WIDGET (menu), &menu_requisition, NULL);
-
- window = gtk_widget_get_parent_window (widget);
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gdk_window_get_origin (window, x, y);
- *x += allocation.x;
- *y += allocation.y + 2 + gtk_widget_get_allocated_height (under_widget);
-
- direction = gtk_widget_get_direction (widget);
- if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (allocation.width - menu_requisition.width, 0);
- else if (menu_requisition.width > allocation.width)
- *x -= menu_requisition.width - allocation.width;
-
- *push_in = FALSE;
-}
-
static TreeRowData *
subscription_editor_tree_row_data_from_iter (GtkTreeView *tree_view,
GtkTreeModel *model,
@@ -875,11 +833,18 @@ subscription_editor_subscribe_popup_cb (EMSubscriptionEditor *editor)
editor));
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (editor), NULL);
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL,
- position_below_widget_cb,
- editor->priv->subscribe_button,
- 0, gtk_get_current_event_time ());
+
+ g_object_set (menu,
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
+
+ gtk_menu_popup_at_widget (GTK_MENU (menu),
+ editor->priv->subscribe_button,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
}
static void
@@ -990,11 +955,18 @@ subscription_editor_unsubscribe_popup_cb (EMSubscriptionEditor *editor)
editor));
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (editor), NULL);
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL,
- position_below_widget_cb,
- editor->priv->unsubscribe_button,
- 0, gtk_get_current_event_time ());
+
+ g_object_set (menu,
+ "anchor-hints", (GDK_ANCHOR_FLIP_Y |
+ GDK_ANCHOR_SLIDE |
+ GDK_ANCHOR_RESIZE),
+ NULL);
+
+ gtk_menu_popup_at_widget (GTK_MENU (menu),
+ editor->priv->unsubscribe_button,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
}
static void
diff --git a/src/modules/calendar/e-calendar-preferences.c b/src/modules/calendar/e-calendar-preferences.c
index 4283bfc..5183ee8 100644
--- a/src/modules/calendar/e-calendar-preferences.c
+++ b/src/modules/calendar/e-calendar-preferences.c
@@ -402,9 +402,7 @@ day_second_zone_clicked (GtkWidget *widget,
gtk_widget_show_all (menu);
gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
- gtk_menu_popup (
- GTK_MENU (menu), NULL, NULL, NULL, NULL,
- 0, gtk_get_current_event_time ());
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
}
static void
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index d39dff0..b3abae3 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -340,7 +340,6 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
EMailReader *reader;
EMailView *mail_view;
GtkMenu *menu;
- guint button;
if (uri != NULL)
return FALSE;
@@ -358,12 +357,7 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
shell_view = E_SHELL_VIEW (mail_shell_view);
e_shell_view_update_actions (shell_view);
- if (!event || !gdk_event_get_button (event, &button))
- button = 0;
-
- gtk_menu_popup (
- menu, NULL, NULL, NULL, NULL,
- button, event ? gdk_event_get_time (event) : gtk_get_current_event_time ());
+ gtk_menu_popup_at_pointer (menu, event);
return TRUE;
}
diff --git a/src/shell/e-shell-view.c b/src/shell/e-shell-view.c
index cfb3c25..f8b1fd4 100644
--- a/src/shell/e-shell-view.c
+++ b/src/shell/e-shell-view.c
@@ -1907,8 +1907,6 @@ e_shell_view_show_popup_menu (EShellView *shell_view,
{
EShellWindow *shell_window;
GtkWidget *menu;
- guint event_button = 0;
- guint32 event_time;
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
@@ -1918,21 +1916,12 @@ e_shell_view_show_popup_menu (EShellView *shell_view,
menu = e_shell_window_get_managed_widget (shell_window, widget_path);
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
- if (button_event != NULL) {
- gdk_event_get_button (button_event, &event_button);
- event_time = gdk_event_get_time (button_event);
- } else {
- event_time = gtk_get_current_event_time ();
- }
-
if (!gtk_menu_get_attach_widget (GTK_MENU (menu)))
gtk_menu_attach_to_widget (GTK_MENU (menu),
GTK_WIDGET (shell_window),
NULL);
- gtk_menu_popup (
- GTK_MENU (menu),
- NULL, NULL, NULL, NULL,
- event_button, event_time);
+
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), button_event);
return menu;
}
diff --git a/src/smime/gui/certificate-manager.c b/src/smime/gui/certificate-manager.c
index f1ede89..bb6d3b9 100644
--- a/src/smime/gui/certificate-manager.c
+++ b/src/smime/gui/certificate-manager.c
@@ -367,18 +367,18 @@ treeview_header_clicked (GtkWidget *widget,
{
GtkMenu *menu = user_data;
guint event_button = 0;
- guint32 event_time;
gdk_event_get_button (button_event, &event_button);
- event_time = gdk_event_get_time (button_event);
if (event_button != 3)
return FALSE;
gtk_widget_show_all (GTK_WIDGET (menu));
+
if (!gtk_menu_get_attach_widget (menu))
gtk_menu_attach_to_widget (menu, widget, NULL);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button, event_time);
+
+ gtk_menu_popup_at_pointer (menu, button_event);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]