Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

MoveFocusAbs Patch #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

MoveFocusAbs Patch #7

wants to merge 1 commit into from

Conversation

TakeYourFreedom
Copy link
Contributor

And another patch. This one adds a function to focus a window directly: for example sarasock 'movefocusabs 0' focuses the master window, sarasock 'movefocusabs 2' the third window on the current desktop.
I will just send you all my changes as patches so you can decide if you want to incorporate them into the base or keep them as patches.

@gitluin
Copy link
Owner

gitluin commented May 6, 2020

void
movefocusabs(const Arg arg){
	int i = 0;
	client* c = NULL;

	if (!curmon->current || curmon->current->isfull)
		return;

	parser[WantInt](arg.s, &parg);

        if (parg.i < 0)
                return;

	for EACHCLIENT(curmon->head){
		if (ISVISIBLE(ic)){
			if (i == parg.i){
				c = ic;
                                break;
                        }

			i++;
		}
	}

	if (c && c != curmon->current){
		changecurrent(c, curmon, curmon->curdesk, 0);
		restack(curmon);
	}
}

I changed the if so that it properly checks for client presence. If a client is tagged to more than one desktop (i.e. ic->desks is not of the form 00001000) then the old test would fail. ISVISIBLE(ic) implies that ic is on curmon->curdesk, because curdesk should always coincide with ic->mon->seldesks. Also added a break to stop looping when we've found the proper client.

I also changed the parg.i >= 0 check so that the code is less indented. If you wanted to implement it in the opposite direction as well (i.e. movefocusabs -1 focuses the last client in the list, movefocusabs -2 focuses the second to last), obviously you could change this back.

I wouldn't directly copy-paste the code - I edited it in this comment and had trouble with spaces vs tabs, so there's currently a mixture...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants