From 76d7872299ec8acf5fb3d65c72597a4a682fb52b Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Sun, 28 Aug 2016 16:50:55 -0400 Subject: * Make sure the button event started and ended on the close image before we dismiss the notification --- src/notification-menuitem.c | 14 ++++++++++---- src/notification-menuitem.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/notification-menuitem.c b/src/notification-menuitem.c index 3240de1..b8ddd07 100644 --- a/src/notification-menuitem.c +++ b/src/notification-menuitem.c @@ -75,6 +75,8 @@ notification_menuitem_init(NotificationMenuItem *self) { self->priv = NOTIFICATION_MENUITEM_GET_PRIVATE(self); + self->priv->pressed_close_image = FALSE; + self->priv->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); self->priv->label = gtk_label_new(NULL); @@ -193,11 +195,13 @@ notification_menuitem_button_press(GtkWidget *widget, GdkEventButton *event) g_return_val_if_fail(IS_NOTIFICATION_MENUITEM(widget), FALSE); NotificationMenuItem *self = NOTIFICATION_MENUITEM(widget); - GtkWidget *label = self->priv->label; /* The context menu breaks everything so disable it for now */ - if (event->button == GDK_BUTTON_PRIMARY && widget_contains_event(label, event)) { - gtk_widget_event(label, (GdkEvent *)event); + if (event->button == GDK_BUTTON_PRIMARY && widget_contains_event(self->priv->label, event)) { + gtk_widget_event(self->priv->label, (GdkEvent *)event); + } + else if (widget_contains_event(self->priv->close_image, event)) { + self->priv->pressed_close_image = TRUE; } return TRUE; } @@ -218,7 +222,8 @@ notification_menuitem_button_release(GtkWidget *widget, GdkEventButton *event) NotificationMenuItem *self = NOTIFICATION_MENUITEM(widget); if (widget_contains_event(self->priv->close_image, event)) { - g_signal_emit(NOTIFICATION_MENUITEM(widget), notification_menuitem_signals[CLICKED], 0, event->button); + if (self->priv->pressed_close_image) + g_signal_emit(NOTIFICATION_MENUITEM(widget), notification_menuitem_signals[CLICKED], 0, event->button); } else { /* The context menu breaks everything so disable it for now */ @@ -226,6 +231,7 @@ notification_menuitem_button_release(GtkWidget *widget, GdkEventButton *event) gtk_widget_event(self->priv->label, (GdkEvent *)event); } } + self->priv->pressed_close_image = FALSE; return TRUE; } diff --git a/src/notification-menuitem.h b/src/notification-menuitem.h index c44c105..2aa051e 100644 --- a/src/notification-menuitem.h +++ b/src/notification-menuitem.h @@ -37,6 +37,8 @@ struct _NotificationMenuItemPrivate { GtkWidget *close_image; GtkWidget *hbox; GtkWidget *label; + + gboolean pressed_close_image; }; #define NOTIFICATION_MENUITEM_GET_PRIVATE(o) \ -- cgit v1.2.3