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 756844 - Don't use new-window GAction to check for dash entry "New Window"
Don't use new-window GAction to check for dash entry "New Window"
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
triaged
: 759881 788406 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-10-20 07:26 UTC by Carlos Soriano
Modified: 2018-11-25 16:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
shell-app: don't use new window for app actions (2.62 KB, patch)
2015-10-20 07:27 UTC, Carlos Soriano
none Details | Review
shell-app: don't use new window for app actions (2.66 KB, patch)
2015-10-20 08:52 UTC, Carlos Soriano
none Details | Review
app: Consider "new-window" action for opening new windows (3.62 KB, patch)
2016-09-22 17:11 UTC, Florian Müllner
none Details | Review

Description Carlos Soriano 2015-10-20 07:26:09 UTC
See patch
Comment 1 Carlos Soriano 2015-10-20 07:27:07 UTC
Created attachment 313725 [details] [review]
shell-app: don't use new window for app actions

We were assuming that if a GApplication implements a GAction called
"new-window" it can manage new windows.
Probably that's true. However, instead of activating this action
through the dbus method, we just activated the application, which
in case of GApplications I would say most of the times means present
the current window, instead of creating a new window.
Gnome shell was activating the application instead of calling the dbus
method supposedly because needs the start notification.
In conclusion this guessing can be more confusing than anything, and
instead applications can make accessible explicit actions through the
desktop file.

So instead of adding a new dash menu entry with a "New Window" operation
when the application implements a new-window GAction, check its desktop
file actions and call them directly.

Note that in the patch we check for the desktop file actions to determine
if it can manage new windows and then in AppDisplay we check for it not
being there, so in the current state of Gnome Shell this code is useless,
however it keeps the logic.
Comment 2 Carlos Soriano 2015-10-20 07:28:06 UTC
Review of attachment 313725 [details] [review]:

forgot to check for strv == NULL, I will update patch in a few hours.
Comment 3 Carlos Soriano 2015-10-20 08:52:46 UTC
Created attachment 313727 [details] [review]
shell-app: don't use new window for app actions

We were assuming that if a GApplication implements a GAction called
"new-window" it can manage new windows.
Probably that's true. However, instead of activating this action
through the dbus method, we just activated the application, which
in case of GApplications I would say most of the times means present
the current window, instead of creating a new window.
Gnome shell was activating the application instead of calling the dbus
method supposedly because needs the start notification.
In conclusion this guessing can be more confusing than anything, and
instead applications can make accessible explicit actions through the
desktop file.

So instead of adding a new dash menu entry with a "New Window" operation
when the application implements a new-window GAction, check its desktop
file actions and call them directly.

Note that in the patch we check for the desktop file actions to determine
if it can manage new windows and then in AppDisplay we check for it not
being there, so in the current state of Gnome Shell this code is useless,
however it keeps the logic.
Comment 4 Jasper St. Pierre (not reading bugmail) 2015-10-20 15:46:55 UTC
Review of attachment 313727 [details] [review]:

Why not have it activate the new-action GAction in that case?
Comment 5 Carlos Soriano 2015-10-20 16:10:08 UTC
(In reply to Jasper St. Pierre from comment #4)
> Review of attachment 313727 [details] [review] [review]:
> 
> Why not have it activate the new-action GAction in that case?

https://git.gnome.org/browse/gnome-shell/tree/src/shell-app.c#n554

I put my thought about that in the commit message. Not sure that comment is longer valid tbh...
Comment 6 Jasper St. Pierre (not reading bugmail) 2015-10-20 16:33:17 UTC
ActivateAction is definitely allowed to have startup-notification stuff go through, I think. I know there's a platform_data in there precisely for that reason.

You might have to use the _TIME hack though.
Comment 7 Giovanni Campagna 2015-10-20 19:34:13 UTC
(In reply to Jasper St. Pierre from comment #6)
> ActivateAction is definitely allowed to have startup-notification stuff go
> through, I think. I know there's a platform_data in there precisely for that
> reason.
> 
> You might have to use the _TIME hack though.

Yes, but you and Ryan NAK'd the patch to support that, back when that code was added.

As for the logic itself, I think it should be reversed.
can_open_new_window() means "If I launch the app again, a new window will appear".
If we assume that a desktop action called new-window means that fdo.Application.Activate() calls present(), then can_open_new_window() should return false, and the "New Window" menu item will be provided by the desktop actions code. Because in theory can_open_new_window() should be true if and only if open_new_window() will open a new window, and if new-window is there, that's most likely not to be the case.
Alternatively, new-window should be hooked up to open_new_window(), which would fix the "drag icon to workspace to start app" - but that would require a lot more startup notification than just _TIME to handle workspaces properly.
(And ideally we should rely less on x11-only startup notification and more on new mutter API for the apps that we start ourselves, but nobody is writing that)
Comment 8 Giovanni Campagna 2015-10-20 19:39:04 UTC
Oh, another thing to mention:

The logic in can_open_new_window() says that running GApplications without a new-window can't open a new window - this is to handle single window apps like gnome-documents or gnome-photos.
But with your patch, all multi window GApplications that don't have a new-window desktop action (because they DTRT in Activate()) will also fall in that case, unless they override it with desktop file key or add a new-window desktop action and associated command line option. This seems suboptimal to me.
Comment 9 Florian Müllner 2015-10-21 13:52:18 UTC
(In reply to Giovanni Campagna from comment #7)
> As for the logic itself, I think it should be reversed.
> can_open_new_window() means "If I launch the app again, a new window will
> appear".

This is not what the name implies though, so if we go with this, we should rename it (activate_opens_new_window() or something). However IMHO "this app can open a new window by this particular mean" doesn't sound like something we should expose users to.


> Alternatively, new-window should be hooked up to open_new_window()

I think this is the best option for context menu and modifier-click. A 'new-window' action is a clear sign that the app can open new windows, and users can reasonably expect those options to be available in that case - it's unlikely for an app to have the action and not expose it anywhere in the UI.

However DND is indeed an issue (though I'm pretty sure I've seen it break with multi-window apps' Activate() as well). If we go that route anyway, we should probably exclude apps whose 'new-window' action is not parameterless - I haven't seen any apps doing that, but an unfortunately named "Open in new window" context menu action isn't unthinkable.
Comment 10 Florian Müllner 2015-12-26 18:20:51 UTC
*** Bug 759881 has been marked as a duplicate of this bug. ***
Comment 11 Florian Müllner 2016-09-22 17:11:03 UTC
Created attachment 336099 [details] [review]
app: Consider "new-window" action for opening new windows

While can_open_new_window() uses some elaborate heuristics to predict
whether an application can open multiple windows, open_new_window()
will always simply relaunch the application. This is often the best
we can do, but when an application provides a "new-window" action in
its .desktop file or on the bus, it is much more likely to work as
expected than blindly activating the app and hoping for a particular
behavior.
Comment 12 Giovanni Campagna 2016-09-22 17:26:52 UTC
Review of attachment 336099 [details] [review]:

::: src/shell-app.c
@@ +567,3 @@
+   * that we can activate on the bus - the muxer will add startup notification
+   * information to the platform data, so this should work just as well as
+   * desktop actions.

Except it won't.

It will add timestamp, but it will not trigger full startup notification, and therefore it will lose the workspace information.
Comment 13 Florian Müllner 2016-09-22 17:44:07 UTC
(In reply to Giovanni Campagna from comment #12)
> It will add timestamp, but it will not trigger full startup notification,
> and therefore it will lose the workspace information.

Mmmh, right. Not sure I care too much to be honest though - opening a new window on a particular workspace already breaks more often than not, and it seems like the lesser evil when compared to not actually opening a new window at all. In particular as dragging a launcher to a workspace is a relatively obscure feature when compared to a context menu (ctrl- and middle-click are admittedly fairly obscure as well though).
Comment 14 Giovanni Campagna 2016-09-22 19:07:15 UTC
It would also be missing the feedback (mouse cursor, app menu spinner) part of startup notification though.
Comment 15 Carlos Soriano 2016-09-22 19:20:45 UTC
(In reply to Giovanni Campagna from comment #14)
> It would also be missing the feedback (mouse cursor, app menu spinner) part
> of startup notification though.

The same as if the user creates a new window inside the app no? So that wouldn't be a major problem I think.

I think either we just don't assume there is a new window if the desktop action is not explicitly set breaking most of current applications, or we do this...
Comment 16 Giovanni Campagna 2016-09-22 19:38:03 UTC
(In reply to Carlos Soriano from comment #15)
> (In reply to Giovanni Campagna from comment #14)
> > It would also be missing the feedback (mouse cursor, app menu spinner) part
> > of startup notification though.
> 
> The same as if the user creates a new window inside the app no? So that
> wouldn't be a major problem I think.
> 
> I think either we just don't assume there is a new window if the desktop
> action is not explicitly set breaking most of current applications, or we do
> this...

Well why are multi-window applications not opening a new window when Activate()'d?

The only one I know broken is evolution, but others (most importantly browsers and terminals) should work fine.

No wait. I checked and gedit is broken too, because it opens a new tab instead of a new window.

But both gedit and evolution have a New Window desktop action, so the brokenness does not apply to them.
Comment 17 Carlos Soriano 2016-09-22 20:06:00 UTC
Nautilus. We have a --new-window command line for that. Usually we always want to focus the window that has a directory opened rather than always opening a new window. We only open a new window if the directory is not opened in any window, and, if explicitly set with --new-window or with the new-window action in the desktop file.

I honestly don't know why we should open a new window in activate(), if we already can set desktop actions that explicitly do that, no?
Comment 18 Giovanni Campagna 2016-09-22 21:06:48 UTC
(In reply to Carlos Soriano from comment #17)
> I honestly don't know why we should open a new window in activate(), if we
> already can set desktop actions that explicitly do that, no?

Yeah, my point is more about apps that have a new-window action when running, but not a new-window action in the desktop files, because those would follow the path with no startup notification.
Comment 19 Florian Müllner 2016-09-23 16:49:12 UTC
(In reply to Giovanni Campagna from comment #14)
> It would also be missing the feedback (mouse cursor, app menu spinner) part
> of startup notification though.

There is no app menu spinner when the app is already running, no matter what method is used to open a new window.


(In reply to Giovanni Campagna from comment #18)
> Yeah, my point is more about apps that have a new-window action when
> running, but not a new-window action in the desktop files, because those
> would follow the path with no startup notification.

Right now the 'new-window' action is always ignored though by anything that calls open_new_window() instead of explicitly using the desktop action. We should at the very least fix that.

I still think that consistency (app menu -> "New window": opens a new window; context menu -> "New window": maybe opens a new window, who knows?) is more important than possible glitches. We can recommend that apps with a 'new-window' action expose it in their .desktop file in the short-term (and should probably do that independent from the outcome of this discussion). In the long-term, we should really try to make actions work nicer with startup notifications, otherwise we'll always end up with cases that don't work as expected and that cannot be worked around by making assumptions in gnome-shell (like opening a window from an action in the app menu or a notification button)
Comment 20 jeremy9856 2017-02-23 07:32:54 UTC
Is there something that prevent to commit the patch ?
Comment 21 André Klapper 2017-02-23 08:58:40 UTC
See previous comments (such as comment 12 and onwards).
Comment 22 Florian Müllner 2017-10-01 20:15:53 UTC
*** Bug 788406 has been marked as a duplicate of this bug. ***
Comment 23 Florian Müllner 2018-06-08 22:25:13 UTC
(In reply to Florian Müllner from comment #13)
> (In reply to Giovanni Campagna from comment #12)
> > It will add timestamp, but it will not trigger full startup notification,
> > and therefore it will lose the workspace information.
> 
> Mmmh, right.

Actually, calling Activate on a remote instance adds the exact same platform data as calling ActivateAction. That is, the workspace information is already ignored for running (GtkApplication) apps unless I'm overlooking something - if that's the case, then the patch doesn't actually regress anything, it just doesn't fix that particular issue.
Comment 24 António Fernandes 2018-11-25 16:46:47 UTC
For the record, the patch from comment #11 has been republished, reviewed, and merged in https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/44

I'm not sure if this should remain open because of the startup-notification concerns
Comment 25 Florian Müllner 2018-11-25 16:49:50 UTC
Right, this bug should have been closed then - thanks for the reminder.