[Geany-devel] [PATCH] Open files in Geany at the same workspace

Colomban Wendling lists.ban at xxxxx
Tue Sep 28 14:47:44 UTC 2010


Hi,

Le 15/09/2010 19:07, Nick Treleaven a écrit :
> On Thu, 9 Sep 2010 20:12:18 +1000
> Erik de Castro Lopo <mle+tools at mega-nerd.com> wrote:
> 
>> Attached is a version of this patch updated to apply cleanly against
>> SVN HEAD.
> 
> Thanks, applied. This is a great improvement IMO :)
I run this patch now, and I don't link the behavior it brings. I
personally use one single desktop for editing code source, but sometimes
want to open files from another desktop in the "default" Geany instance.

So I would like to get the old behavior back. I see 2 solutions:
1) remove this patch;
2) add an option to choose whether we want one instance per workspace or
not.

I think nobody wants solution 1, so let's forget about it and
investigate a bit solution 2. Looking a bit at the code, I see three
possible solutions:

1) in ui_get_current_workspace() (ui_utils.c, line 2476), return always
the same value if the per-workspace option is not checked. Not sure
whether 0 is a good value since it is the ID of the first desktop, but
I'd think we don't care since it is a preference.
The only way I see it may get confusing is if the option gets enabled
while the first instance is not in workspace 0, and then a new Geany
gets launched from desktop 0. In this case, no new instance is launched
since it already exists, even if not launched from desktop 0.
But this is the same if the Geany's window changes workspace after it
has been launched (but this is a bug IMO).

2) in socket_init() (socket.c, around line 288), add the _wsX suffix to
the socket file only if the per-workspace option is checked.
This has similar flaw than solution 1: if the option gets activated and
another instance get launched, it won't see the already running one
(since the existing socket would be geany_socket_HOSTNAME_DISPLAY and
not geany_socket_HOSTNAME_DISPLAY_wsWORKSPACE.

3) this is the most complicated but also the one that seems to have the
less flaws: still add workspace suffix, but when checking if there is a
running instance to which send the requests, ignore that workspace
information if the pre-workspace option is not checked. It needs to list
the available socket(s), and then select the one we want (probably the
first or the one closets to the current desktop), but it fixes flaws I
see in both methods 1) and 2).


This said, I would personally choose method 1: it is the simplest one
ant it is probably enough. I thing it isn't really a problem if the
behavior is a little odd when the preference was just toggled.

So, what do you think? I can write a patch for one of these solutions
(especially 1 that is really easy :p), or another if somebody has a
better idea :)

Regards,
Colomban



PS: offtopic: don't the new instance ran with -i also have a socket
file!? I can't see them neither in /tmp nor in ~/.config/geany...



More information about the Devel mailing list