After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 722554 - A number of improvements for remote actions
A number of improvements for remote actions
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 647105 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-01-19 17:24 UTC by Giovanni Campagna
Modified: 2014-08-01 09:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkActionMuxer: implement GRemoteActionGroup (6.26 KB, patch)
2014-01-19 17:24 UTC, Giovanni Campagna
rejected Details | Review
GtkMenuTrackerItem: make use of GRemoteActionGroup (3.30 KB, patch)
2014-01-19 17:24 UTC, Giovanni Campagna
rejected Details | Review
RemoteMenu: adjust to GtkMenuTrackerItem change (974 bytes, patch)
2014-01-19 17:24 UTC, Giovanni Campagna
rejected Details | Review
ShellApp: implement open_new_window and request_quit using GActionGroup (7.88 KB, patch)
2014-01-19 17:24 UTC, Giovanni Campagna
rejected Details | Review
AppDisplay: don't show a "New Window" menu item if not possible (3.50 KB, patch)
2014-01-19 17:24 UTC, Giovanni Campagna
reviewed Details | Review
AppDisplay: don't show a "New Window" menu item if not possible (4.74 KB, patch)
2014-02-13 21:33 UTC, Giovanni Campagna
committed Details | Review
ShellApp: remove impossible check (1.02 KB, patch)
2014-02-13 21:33 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2014-01-19 17:24:14 UTC
See patches, but mostly
- passing timestamps around correctly
- proper quitting of apps that survive deleting all windows
- the ability for apps to have multiple windows but still
  present one in Activate()
- the ability for apps to say they don't ever use multiple windows
  (and thus showing "New window" in the popup menu is bogus)

Note: the names "new-window" and "quit" for the actions were
already standardized in GTK+ by the recent gtk-quartz work.
Comment 1 Giovanni Campagna 2014-01-19 17:24:17 UTC
Created attachment 266662 [details] [review]
GtkActionMuxer: implement GRemoteActionGroup

If we insert a GRemoteActionGroup in the muxer, it makes sense
that the interface is exposed outside so that the platform data
can be sent togheter with the activation.
Comment 2 Giovanni Campagna 2014-01-19 17:24:21 UTC
Created attachment 266663 [details] [review]
GtkMenuTrackerItem: make use of GRemoteActionGroup

When paired to a GtkActionMuxer, pass down the timestamp of the
action in the form of platform data.
The timestamp must come from an outside source (usually,
shell_global_get_current_time ()), so the API is changed.
Comment 3 Giovanni Campagna 2014-01-19 17:24:26 UTC
Created attachment 266664 [details] [review]
RemoteMenu: adjust to GtkMenuTrackerItem change

Pass down the event time.
Comment 4 Giovanni Campagna 2014-01-19 17:24:31 UTC
Created attachment 266665 [details] [review]
ShellApp: implement open_new_window and request_quit using GActionGroup

Reserve the action names "app.new-window" and "app.quit" as well known
names for the standard actions, and use them (when available)
instead of the X/launcher fallback.
The advantage of this is that the application can support
a new window action even if its Activate method would present
the most recent window, and that "Quit" would really quit the
application, even in face of inactivity timeouts or background
services.
Comment 5 Giovanni Campagna 2014-01-19 17:24:39 UTC
Created attachment 266666 [details] [review]
AppDisplay: don't show a "New Window" menu item if not possible

If the application reports itself as single window, not show a
"New window" item that doesn't actually open a new window.
Comment 6 Jasper St. Pierre (not reading bugmail) 2014-01-19 17:38:55 UTC
Review of attachment 266663 [details] [review]:

This needs to go upstream.
Comment 7 Jasper St. Pierre (not reading bugmail) 2014-01-19 17:39:22 UTC
Review of attachment 266662 [details] [review]:

Same with this.
Comment 8 Giovanni Campagna 2014-01-19 17:39:58 UTC
They are going upstream, see bug 722553.
Comment 9 Jasper St. Pierre (not reading bugmail) 2014-01-19 17:47:48 UTC
Review of attachment 266664 [details] [review]:

Merge this with the patch that changes GtkMenuTrackerItem so bisect doesn't break.
Comment 10 Jasper St. Pierre (not reading bugmail) 2014-01-19 17:51:34 UTC
Review of attachment 266666 [details] [review]:

::: src/shell-app.c
@@ +744,3 @@
+  /* Check if the desktop file says anything about the behavior of Activate()... */
+  return !g_desktop_app_info_get_boolean (G_DESKTOP_APP_INFO (app->info),
+                                          "X-GNOME-SingleWindow");

Do any applications set this, or is this just a convention you invented? If the latter, this doesn't really help us right now, since no desktop files will set this to TRUE. Perhaps better heuristics would be "if the app supports app.activate, but not app.new-window, then we know it's single-window", which should cover most of our single-window apps already without modifying .desktop files.
Comment 11 Jasper St. Pierre (not reading bugmail) 2014-01-19 17:53:28 UTC
Review of attachment 266665 [details] [review]:

::: src/shell-app.c
@@ +657,3 @@
 
+static GVariant *
+get_platform_data (void)

I'd love to see this shared with gtkmenutrackeritem.c but not going to care about it too much. We already reimplement this in notificationDaemon.js, too.

::: tests/interactive/gapplication.js
@@ +29,2 @@
 function main() {
+    GLib.set_prgname('test-gapplication');

Any reason for this?
Comment 12 Giovanni Campagna 2014-01-19 18:05:04 UTC
(In reply to comment #10)
> Review of attachment 266666 [details] [review]:
> 
> ::: src/shell-app.c
> @@ +744,3 @@
> +  /* Check if the desktop file says anything about the behavior of
> Activate()... */
> +  return !g_desktop_app_info_get_boolean (G_DESKTOP_APP_INFO (app->info),
> +                                          "X-GNOME-SingleWindow");
> 
> Do any applications set this, or is this just a convention you invented? If the
> latter, this doesn't really help us right now, since no desktop files will set
> this to TRUE. Perhaps better heuristics would be "if the app supports
> app.activate, but not app.new-window, then we know it's single-window", which
> should cover most of our single-window apps already without modifying .desktop
> files.

It's something I invented, and I hoped to send a notice to d-d-l to at least cover our apps. It's a very small desktop file change, and the default is conservative.

The issue is, some apps open a new window if you call Activate (or the equivalent for apps that don't use fdo.Application), just present the old one. Some of the apps in the first group have also a separate new-window action.
The other part of the issue is that, beside a small subset of apps, we don't call Activate() directly. Instead, we spawn the launcher binary and let the app do it's thing. Which means that using the ability to call Activate (that is, DBusActivatable=true) is not a good heuristics to know if that Activate means new window or not.
Additionally, switching to DBus activation is a lot harder than adding the SingleWindow boolean (you need to rename the desktop file, to provide a DBus service file and to work properly in service mode), so I expect that many more app authors will be willing to add the flag (like they did with UsesNotifications).

(In reply to comment #11)
> ::: tests/interactive/gapplication.js
> @@ +29,2 @@
>  function main() {
> +    GLib.set_prgname('test-gapplication');
> 
> Any reason for this?

Heh, it was an old patch I had lying around, and I rewrote it but kept the tests. I don't remember actually.
Comment 13 Jasper St. Pierre (not reading bugmail) 2014-01-19 18:08:12 UTC
(In reply to comment #12)
> The issue is, some apps open a new window if you call Activate (or the
> equivalent for apps that don't use fdo.Application), just present the old one.
> Some of the apps in the first group have also a separate new-window action.
> The other part of the issue is that, beside a small subset of apps, we don't
> call Activate() directly. Instead, we spawn the launcher binary and let the app
> do it's thing. Which means that using the ability to call Activate (that is,
> DBusActivatable=true) is not a good heuristics to know if that Activate means
> new window or not.

Erm, I just picked an action at random that our apps can be expected to implement. I wasn't suggesting calling "app.activate" at all. How about "supports app.quit but not app.new-window"?
Comment 14 Giovanni Campagna 2014-01-19 18:10:17 UTC
(In reply to comment #13)
> 
> Erm, I just picked an action at random that our apps can be expected to
> implement. I wasn't suggesting calling "app.activate" at all. How about
> "supports app.quit but not app.new-window"?

I don't get it, why would app.quit be relevant to app.new-window?
Comment 15 Jasper St. Pierre (not reading bugmail) 2014-01-19 18:29:52 UTC
(In reply to comment #14)
> I don't get it, why would app.quit be relevant to app.new-window?

We're trying to detect whether an app can open a new window.. If we see that there's an action called "app.quit", we can guess that the app implements all the actions it cares about. So, we can make a pretty educated guess that if "app.new-window" isn't implemented, the app is a single-instance app.

For an application doesn't use GApplication, e.g. Firefox, there's no muxer, so we just take a guess that it supports "New Window" through spawning the process again.

For an application that uses GApplication but doesn't implement any actions, we don't see either "app.quit" or "app.new-window", so we just take a guess that it supports "New Window" through Activate() or spawning the process again.

For an application that uses GApplication but only implements "app.quit", e.g. Documents, we see that "app.quit" exists but "app.new-window" doesn't, so we can assume that it can't support "New Window".

For an application that uses GApplication and supports "app.new-window", we know it supports "New Window".
Comment 16 Giovanni Campagna 2014-02-13 21:33:32 UTC
Created attachment 269074 [details] [review]
AppDisplay: don't show a "New Window" menu item if not possible

If the application reports itself as single window (through
an explicit indication in the desktop file or some heuristics),
not show a "New window" item that doesn't actually open a new window.
Comment 17 Giovanni Campagna 2014-02-13 21:33:37 UTC
Created attachment 269075 [details] [review]
ShellApp: remove impossible check

The action muxer is created and destroyed with the running state,
it can never be NULL.
Comment 18 Giovanni Campagna 2014-02-13 21:37:26 UTC
Review of attachment 266664 [details] [review]:

Gtk+ wants to solve this differently.
Comment 19 Florian Müllner 2014-02-13 21:38:13 UTC
Review of attachment 269075 [details] [review]:

::: src/shell-app.c
@@ +586,3 @@
         }
 
+      g_assert (app->running_state->muxer);

Maybe just assert on app->running_state? As noted, muxer is created with running_state anyway, and we catch a segfault if running_state is indeed unset (well, not that an assert makes much of a difference from a user's POV ...)
Comment 20 Giovanni Campagna 2014-02-13 21:38:57 UTC
Review of attachment 266665 [details] [review]:

Ok, I'm going to reject this, because don't doing startup notification regresses the ability to launch an app on a specific desktop.
As for request_quit(), it's only used for legacy apps, so there is little point in a GtkApplication code path there.
Comment 21 Jasper St. Pierre (not reading bugmail) 2014-02-13 21:40:52 UTC
Review of attachment 269075 [details] [review]:

Yep, looks correct.
Comment 22 Florian Müllner 2014-02-13 22:02:57 UTC
Review of attachment 269074 [details] [review]:

::: src/shell-app.c
@@ +726,3 @@
+
+     We don't consider non-unique GtkApplications here to handle cases like
+     evince, which don't export a new-window action because each window is in

Maybe it's late, but I don't see how any of the conditions below has anything to do with uniqueness?
Comment 23 Jasper St. Pierre (not reading bugmail) 2014-02-13 22:08:06 UTC
Review of attachment 269074 [details] [review]:

It still doesn't implement my suggestions from before.
Comment 24 Giovanni Campagna 2014-02-17 19:46:34 UTC
Comment on attachment 269075 [details] [review]
ShellApp: remove impossible check

Attachment 269075 [details] pushed as d555fd7 - ShellApp: remove impossible check
Comment 25 Giovanni Campagna 2014-08-01 09:44:19 UTC
(In reply to comment #22)
> Review of attachment 269074 [details] [review]:
> 
> ::: src/shell-app.c
> @@ +726,3 @@
> +
> +     We don't consider non-unique GtkApplications here to handle cases like
> +     evince, which don't export a new-window action because each window is in
> 
> Maybe it's late, but I don't see how any of the conditions below has anything
> to do with uniqueness?

A non-unique gtkapplication has a null gtk-application-id (which is the well-known dbus name). A non gtkapplication is not unique by definition.

There were no really negative comments (sorry Jasper but looking at app.quit is not a useful suggestion in addition to simple gtkapplication), and we had duplicates, so I'm going to push and close this one.
Comment 26 Giovanni Campagna 2014-08-01 09:46:18 UTC
Attachment 269074 [details] pushed as 3182aba - AppDisplay: don't show a "New Window" menu item if not possible
Comment 27 Giovanni Campagna 2014-08-01 09:46:59 UTC
*** Bug 647105 has been marked as a duplicate of this bug. ***