Skip to content

Commit

Permalink
xapp-status-icon.c: Keep an account of button presses so an orphan
Browse files Browse the repository at this point in the history
release doesn't activate or pop up a menu.

This happens in a situation where activating one icon (button press)
causes the icon to be removed, causing the subsequent button release
to be received by the adjacent icon, potentially activating its menu.
  • Loading branch information
mtwebster committed Nov 19, 2019
1 parent 3483223 commit 4c20196
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions libxapp/xapp-status-icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ typedef struct
guint listener_id;

gint fail_counter;
gboolean have_button_press;
} XAppStatusIconPrivate;

struct _XAppStatusIcon
Expand Down Expand Up @@ -316,6 +317,8 @@ handle_click_method (XAppStatusIconInterface *skeleton,
}
}

icon->priv->have_button_press = TRUE;

g_signal_emit (icon, signals[BUTTON_PRESS], 0,
x, y,
button,
Expand All @@ -333,23 +336,28 @@ handle_click_method (XAppStatusIconInterface *skeleton,
g_dbus_method_invocation_get_sender (invocation),
x, y, button_to_str (button), _time, panel_position_to_str (panel_position));

GtkWidget *menu_to_use = get_menu_to_use (icon, button);

if (menu_to_use)
if (icon->priv->have_button_press)
{
popup_native_icon_menu (icon,
GTK_MENU (menu_to_use),
x, y,
button,
_time,
panel_position);
GtkWidget *menu_to_use = get_menu_to_use (icon, button);

if (menu_to_use)
{
popup_native_icon_menu (icon,
GTK_MENU (menu_to_use),
x, y,
button,
_time,
panel_position);
}

g_signal_emit (icon, signals[BUTTON_RELEASE], 0,
x, y,
button,
_time,
panel_position);
}

g_signal_emit (icon, signals[BUTTON_RELEASE], 0,
x, y,
button,
_time,
panel_position);
icon->priv->have_button_press = FALSE;

xapp_status_icon_interface_complete_button_release (skeleton,
invocation);
Expand Down Expand Up @@ -481,6 +489,8 @@ on_gtk_status_icon_button_press (GtkStatusIcon *status_icon,
&y,
&orientation);

icon->priv->have_button_press = TRUE;

g_signal_emit (icon, signals[BUTTON_PRESS], 0,
x, y,
button,
Expand Down Expand Up @@ -542,6 +552,8 @@ on_gtk_status_icon_button_release (GtkStatusIcon *status_icon,
&y,
&orientation);

icon->priv->have_button_press = FALSE;

g_signal_emit (icon, signals[BUTTON_RELEASE], 0,
x, y,
button,
Expand Down

0 comments on commit 4c20196

Please sign in to comment.