Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implements the ioncore-goto-hop alternative #375

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions ioncore/focus.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,52 @@ static void region_focuslist_deinit(WRegion *reg)
}


/*EXTL_DOC
* Go to and return to a previously active region, hop style
* You can go count back in -1, or 1 direction.
*
* Note that this function is asynchronous; the region will not
* actually have received the focus when this function returns.
*/
EXTL_EXPORT
WRegion *ioncore_goto_hop(int count, int direction)
{
WRegion *next;

if(ioncore_g.focuslist==NULL)
return NULL;

/* We're trying to access the focus list from lua (likely from the UI). I
* thus force any pending focuslist updates to complete now */
region_focuslist_awaiting_insertion_trigger();

/* Find the nth region on focus history list that isn't currently
* active.
*/
if (direction > 0) {
for(next=ioncore_g.focuslist->active_next;
next!=NULL;
next=next->active_next){

if(!REGION_IS_ACTIVE(next) && --count <= 0)
break;
}
} else {
for(next=ioncore_g.focuslist->active_prev;
next!=NULL;
next=next->active_prev){

if(!REGION_IS_ACTIVE(next) && --count <= 0)
break;
}
}

if(next!=NULL)
region_goto(next);

return next;
}

/*EXTL_DOC
* Go to and return to a previously active region (if any).
*
Expand Down
1 change: 1 addition & 0 deletions ioncore/focus.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern void region_focuslist_move_after(WRegion *reg, WRegion *after);
extern void region_focus_deinit(WRegion *reg);

extern WRegion *ioncore_goto_previous();
extern WRegion *ioncore_goto_hop(int count, int direction);

/* Handlers to this hook should take WRegion* as parameter. */
extern WHook *region_do_warp_alt;
Expand Down