Closed Bug 726479 Opened 13 years ago Closed 5 years ago

Change startup notification code to use GTK APIs

Categories

(Core :: Widget: Gtk, defect, P3)

Other Branch
x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: karlt, Assigned: rmader)

References

(Blocks 1 open bug)

Details

(Whiteboard: tpi:+)

Attachments

(2 files)

SetUserTimeAndStartupIDForActivatedWindow in gtk2/nsWindow.cpp contains code for setting the focus timestamp and stopping the startup notification animation, after use of the remote protocol. The code is currently not built by default, possibly because of the dependency on libstartup-notification-1.so.0 that this would add. Since GTK+-2.12, GTK+ offers the necessary apis. https://bugzilla.gnome.org/show_bug.cgi?id=347375 Switching to the GTK APIs will mean this code can be enabled by default without any extra dependency. Although running Mozilla builds is only supported against GTK+-2.12 or newer, they are built against GTK+-2.10. That means Mozilla builds currently can't be linked against the gtk_window_set_startup_id symbol. Until bug 713802 is fixed, setting the startup-id property may be simpler than finding gtk_window_set_startup_id at runtime.
Blocks: wayland
See Also: → 1286482
Blocks: 1074246
Priority: -- → P3
Whiteboard: tpi:+
Attachment #8837452 - Flags: review?(karlt)
Comment on attachment 8837452 [details] Bug 726479 - Use GTK's support for startup notifications https://reviewboard.mozilla.org/r/112572/#review115316 That's for looking at this. It will be nice to remove all this boilerplate. However, this patch is changing behavior, and I assume that is not intentional. ::: widget/gtk/nsWindow.cpp (Diff revision 1) > - if (sn_launchee_context_get_id_has_timestamp(ctx)) { > - gdk_x11_window_set_user_time(gdkWindow, > - sn_launchee_context_get_timestamp(ctx)); > - } > - > - sn_launchee_context_setup_window(ctx, gdk_x11_window_get_xid(gdkWindow)); gdk_notify_startup_complete_with_id() won't set the window user-time or startup id for us, but merely indicates that the application has started. (It doesn't know the window.) The user-time is required to make the app work with focus-stealing prevention when the window is shown. I'm guessing the window manager may wish to use the startup id property. gtk_window_set_startup_id() will set these appropriately. (It is safe to assume this function is available now.) Call that before gdk_notify_startup_complete_with_id() to keep the order the same.
Attachment #8837452 - Flags: review?(karlt)
Looks like we don't need the gdk_notify_startup_complete_with_id() because gtk_window_set_startup_id() calls it, even on GTK2: https://github.com/GNOME/gtk/blob/gtk-2-24/gtk/gtkwindow.c#L1565
Comment on attachment 8837452 [details] Bug 726479 - Use GTK's support for startup notifications https://reviewboard.mozilla.org/r/112572/#review118070 (In reply to iofelben from comment #4) > Looks like we don't need the gdk_notify_startup_complete_with_id() because > gtk_window_set_startup_id() calls it, even on GTK2: > https://github.com/GNOME/gtk/blob/gtk-2-24/gtk/gtkwindow.c#L1565 But only when !disable_startup_notification and there is http://searchfox.org/mozilla-central/rev/31b6089ce26fa76459642765115605d50a6c67b4/toolkit/xre/nsAppRunner.cpp#3869 Perhaps that can be removed now?
Attachment #8837452 - Flags: review?(karlt)
Comment on attachment 8837452 [details] Bug 726479 - Use GTK's support for startup notifications https://reviewboard.mozilla.org/r/112572/#review118070 But if only doing that, then showing a GTK dialog (e.g. save as, or print) even long after startup would gdk_notify_startup_complete(), which would broadcast a startup message using the id in the environment again. I suspect the SetDesktopStartupID() call from nsAppRunner.cpp can be removed and GDK will use the id in the environment for the first window shown (whether it be a Gecko window or not). Removing gtk_window_set_auto_startup_notification(false) will have the advantage of broadcasting the startup message even when the profilemanager is shown.
Comment on attachment 8837452 [details] Bug 726479 - Use GTK's support for startup notifications https://reviewboard.mozilla.org/r/112572/#review118094 ::: widget/gtk/nsWindow.cpp:1309 (Diff revision 2) > // This will become obsolete when new GTK APIs are widely supported, > // as described here: http://bugzilla.gnome.org/show_bug.cgi?id=347375 Can you remove this comment, please?
I ran into some weird behavior after creating a custom application launcher for Firefox Nightly which included "StartupNotify=true" (which seems to be the default on modern Linux desktop apps). If I read this bug correctly, "StartupNotify=true" is currently not supported on official builds from Mozilla?
Yes, official builds still don't have --enable-startup-notification AFAIK.

GTK2 support has been dropped from FF for a while now, so I gave this a try and it still applies almost cleanly and seems to work quite nicely. No loading spinner when launching the Wayland backend, immediately shows up in the alt-tab swither - great! iofelben, mind rebasing this so we can finally land it? If not, I can do so instead.

Flags: needinfo?(iofelben)

(In reply to robert.mader from comment #11)

GTK2 support has been dropped from FF for a while now, so I gave this a try and it still applies almost cleanly and seems to work quite nicely. No loading spinner when launching the Wayland backend, immediately shows up in the alt-tab swither - great! iofelben, mind rebasing this so we can finally land it? If not, I can do so instead.

Karl, are you ok to land this?

Flags: needinfo?(karlt)

(In reply to Martin Stránský [:stransky] from comment #12)

Karl, are you ok to land this?

The changes requested in comments 6 to 8 need to be made to https://hg.mozilla.org/mozreview/gecko/rev/c8f74d891198eaa04a4bb0706dafa8fac8c9530d before that can land.

Flags: needinfo?(karlt)
Flags: needinfo?(iofelben)
Assignee: nobody → robert.mader
Status: NEW → ASSIGNED
Pushed by apavel@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f9cf5980bce9 Use GTK's support for startup notifications, r=karlt

Right...ah...I hope it was ok to checkin so late in the cycle?

(In reply to robert.mader from comment #16)

Right...ah...I hope it was ok to checkin so late in the cycle?

I think it's ok, it may be committed to 74.

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74

Firefox 73.0 patched with this works well.

If anyone from dists packaging interested, I recommend applying patch a top of 73! :)

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: