Allow a Multiple instances to become Unique
Needs RevisionPublic

Authored by tcanabrava on Oct 30 2019, 11:56 PM.

Details

Reviewers
adridg
dfaure
Summary

This fixes an issue with konsole when launched as Multiple Applications
but once you typed --new-tab (that forces Unique instance by default)
So, if you use a Unique instance it will attache to one that was created
via Multiple. I'm unsure if this is the correct approach, but seems
sensible enough

Diff Detail

Repository
R271 KDBusAddons
Branch
multiple_to_unique
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 18378
Build 18396: arc lint + arc unit
tcanabrava created this revision.Oct 30 2019, 11:56 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 30 2019, 11:56 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
tcanabrava requested review of this revision.Oct 30 2019, 11:56 PM

Put this on invent maybe?

adridg accepted this revision.Oct 31 2019, 8:31 PM
adridg added a subscriber: adridg.

This has been applied to FreeBSD ports because it works. +1 (with the other konsole patch that is on invent).

This revision is now accepted and ready to land.Oct 31 2019, 8:31 PM

I don't follow this patch.

Say I'm starting a unique app (like org.kde.PlasmaShell)

If another bus name already exists, which with the same prefix (such as "org.kde.PlasmaShellasdfasdf") then my new unique app will try to register as "org.kde.PlasmaShellasdfasdf" even though we know for sure that that name is already used by someone else?

Now you (@davidedmundson ) mention it, yeah .. I've only tested positively, to see if konsole then does what I want. You're right that this could have surprising effects when multiple unique applications share a prefix (e.g. org.kde.plasma.something and org.kde.plasma.somethingentirelydifferent). There would have to be a closer check to find "this is really an instance of the intended application" and not have accidents with startsWith().

Yes, that's exactly what would happen, I think I just need to verify if the name would be the same as the name minus the uuid. because if you open an app on ::Multiple and later the same app on ::Unique, merging them seems sane.

I think I just need to verify if the name would be the same as the name minus the uuid. because if you open an app on ::Multiple and later the same app on ::Unique, merging them seems sane.

Could you link your konsole patch, I don't yet see why we would want our now unique konsole to use a different path to normal.

tcanabrava added a subscriber: GB_2.Nov 1 2019, 3:02 PM

https://invent.kde.org/kde/konsole/merge_requests/45

But it’s not related to this path, it’s just another bug

dfaure requested changes to this revision.Nov 3 2019, 7:01 PM
dfaure added a subscriber: dfaure.

Same reservations as davidedmundson.
Furthermore this would break talking to dbus-activated unique apps, too, since they wouldn't register with the expected service name.
-2 from me.

This revision now requires changes to proceed.Nov 3 2019, 7:01 PM

im Open to redo the patch but I don’t see the problems you guys see. The
only thing this patch does is to quit early if you trigger a unique
application *after* a multiple one has been spawned.

See:
Konsole (register as multiple)
Konsole —new-tab (register as single)

But instead of adding a tab to the old, multiple, instance - it opens a new
window instead.

I’ve tested with multiple single ones, and mixing singles with multiples So
I don’t understand why you say it would break anything.

Also, is there anything that I can do to fix this konsole bug I explained
any other way?

If I read the patch correctly, then running a multi-instance app (konsole-1234) and then running it as unique will lead to konsole-1234 instead of the expected konsole.
Worse, if there was a completely unrelated konsolesettings application running, then konsole would try to register as konsolesettings instead of konsole.
In other words, at least this should be startsWith(d->serviceName + '-'), right?

Point taken, I’ll rework the patch for a regexp of servicenane + ‘-‘ + pid,
this will fix your second point.
About your first point, do you think it’s a problem?

Just speculating, if an app opens as multiple and then another instance
tries to open as unique, it should reuse the existing one or merge?

I did not try to change the registered name as actually nothing happens
when a second instance of an unique app opens, it silently closes - so in a
way I did not registered an unique application as name - pid, I just passed
the arguments to the currently opened ::multiple application, and quit.

Just speculating, if an app opens as multiple and then another instance tries to open as unique, it should reuse the existing one or merge?

With a konsole state of mind, I can see how this would possibly make sense indeed.
But it would break DBus-activation of unique applications (if it is ever possible to start one of those as "multiple").

When you make a call to "org.kde.kmail" and kmail or kontact isn't running, then the org.kde.kmail.service file installed into the DBus services directory leads to DBus activation, i.e. this starts kmail, which then registers as org.kde.kmail (as expected!), which allows the DBus call to proceed.
If instead, it would register as org.kde.kmail-1234 because there happens to be such a name on the bus already, then the call would fail.

I admit that I don't know of an application which supports both Multiple and Unique, and which also provides a dbus service file for the activation feature.
But this scenario makes me wonder if the magic that you have in mind should be in konsole itself instead of kdbusaddons, to avoid affecting other applications.

I'm open to counter-arguments and counter-examples. Actually, do we know of any other app than konsole which supports both Multiple and Unique modes?

I'm open to counter-arguments and counter-examples. Actually, do we know of any other app than konsole which supports both Multiple and Unique modes?

I would prefer to have only one mode. Tab & Split drag 'n drop only work in Single Instances, so if someone opens two uniques, and try to drag and drop... failure and probably open bug requests.
but also if something freezes konsole, or if I'm developing konsole inside konsole and I want to open a new instance of it, I want it really to be unique.