Well, keep going with a flag if you think it is better, I don't mind,
but don't forget about movew/joinw/swapw.
On Sat, Jan 07, 2017 at 10:08:33PM +0000, Thomas Adam wrote:
> On Sat, Jan 07, 2017 at 03:47:29PM +0000, Nicholas Marriott wrote:
> > If we want the flag to only be 1 if the window is linked across
> > sessions, not if it is linked twice into a single session, you will also
> > need to clear the flag when a window is joined or moved from session B
> > into a session A where it already exists (assuming it is not already
> > linked into another session C).
> >
> > Wouldn't something like this work and be a lot easier?
> >
> > s = TAILQ_FIRST(&w->winlinks)->session;
> > TAILQ_FOREACH(wl, &w->winlinks, wentry) {
> > if (wl->session != s)
> > return (1);
> > }
> > return (0);
>
> Possibly. To me, a flag is easier since it's consistent with the other types
> happening on a window. However, if you want to go down this route, you'll
> need to also consider session groups though. Perhaps something like the
> attached?
>
> Kindly,
> Thomas
> diff --git a/session.c b/session.c
> index d89bc6a0..e8bee15d 100644
> --- a/session.c
> +++ b/session.c
> @@ -425,10 +425,23 @@ int
> session_is_linked(struct session *s, struct window *w)
> {
> struct session_group *sg;
> + struct session *s1;
> + struct winlink *wl;
>
> - if ((sg = session_group_find(s)) != NULL)
> - return (w->references != session_group_count(sg));
> - return (w->references != 1);
> + TAILQ_FOREACH(wl, &w->winlinks, wentry) {
> + if ((sg = session_group_find(s)) != NULL) {
> + TAILQ_FOREACH(s1, &sg->sessions, gentry) {
> + if (s == s1)
> + continue;
> + if (wl->session != s1 && wl->session != s)
> + return (1);
> + }
> + } else {
> + if (wl->session != s)
> + return (1);
> + }
> + }
> + return (0);
> }
>
> static struct winlink *
--
You received this message because you are subscribed to the Google Groups
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.