Skip to content

Commit

Permalink
Bug 1417846 - Part 2: Pass timeout=0 when requireInteraction=true r=s…
Browse files Browse the repository at this point in the history
…transky

Differential Revision: https://phabricator.services.mozilla.com/D199760
  • Loading branch information
saschanaz committed Jan 29, 2024
1 parent 3c7b666 commit 50b7f5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions toolkit/system/gnome/nsAlertsIconListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ nsAlertsIconListener::notify_notification_close_t
nsAlertsIconListener::notify_notification_close = nullptr;
nsAlertsIconListener::notify_notification_set_hint_t
nsAlertsIconListener::notify_notification_set_hint = nullptr;
nsAlertsIconListener::notify_notification_set_timeout_t
nsAlertsIconListener::notify_notification_set_timeout = nullptr;

static void notify_action_cb(NotifyNotification* notification, gchar* action,
gpointer user_data) {
Expand Down Expand Up @@ -125,6 +127,8 @@ nsAlertsIconListener::nsAlertsIconListener(nsSystemAlertsService* aBackend,
libNotifyHandle, "notify_notification_close");
notify_notification_set_hint = (notify_notification_set_hint_t)dlsym(
libNotifyHandle, "notify_notification_set_hint");
notify_notification_set_timeout = (notify_notification_set_timeout_t)dlsym(
libNotifyHandle, "notify_notification_set_timeout");
if (!notify_is_initted || !notify_init || !notify_get_server_caps ||
!notify_notification_new || !notify_notification_show ||
!notify_notification_set_icon_from_pixbuf ||
Expand Down Expand Up @@ -195,6 +199,11 @@ nsresult nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf) {
}
}

if (notify_notification_set_timeout && mAlertRequiresInteraction) {
constexpr gint kNotifyExpiresNever = 0;
notify_notification_set_timeout(mNotification, kNotifyExpiresNever);
}

// Fedora 10 calls NotifyNotification "closed" signal handlers with a
// different signature, so a marshaller is used instead of a C callback to
// get the user_data (this) in a parseable format. |closure| is created
Expand Down Expand Up @@ -320,6 +329,9 @@ nsresult nsAlertsIconListener::InitAlertAsync(nsIAlertNotification* aAlert,
rv = aAlert->GetSilent(&mAlertIsSilent);
NS_ENSURE_SUCCESS(rv, rv);

rv = aAlert->GetRequireInteraction(&mAlertRequiresInteraction);
NS_ENSURE_SUCCESS(rv, rv);

nsAutoString title;
rv = aAlert->GetTitle(title);
NS_ENSURE_SUCCESS(rv, rv);
Expand Down
3 changes: 3 additions & 0 deletions toolkit/system/gnome/nsAlertsIconListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class nsAlertsIconListener : public nsIAlertNotificationImageListener,
using notify_notification_close_t = bool (*)(void*, GError**);
using notify_notification_set_hint_t = void (*)(NotifyNotification*,
const char*, GVariant*);
using notify_notification_set_timeout_t = void (*)(NotifyNotification*, gint);

nsCOMPtr<nsICancelable> mIconRequest;
nsCString mAlertTitle;
Expand All @@ -78,6 +79,7 @@ class nsAlertsIconListener : public nsIAlertNotificationImageListener,

bool mAlertHasAction;
bool mAlertIsSilent;
bool mAlertRequiresInteraction;

static void* libNotifyHandle;
static bool libNotifyNotAvail;
Expand All @@ -91,6 +93,7 @@ class nsAlertsIconListener : public nsIAlertNotificationImageListener,
static notify_notification_add_action_t notify_notification_add_action;
static notify_notification_close_t notify_notification_close;
static notify_notification_set_hint_t notify_notification_set_hint;
static notify_notification_set_timeout_t notify_notification_set_timeout;
NotifyNotification* mNotification;
gulong mClosureHandler;

Expand Down

0 comments on commit 50b7f5a

Please sign in to comment.