mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
desktop: focus next 'mapped' view on minimize
This commit is contained in:
parent
b46fa5e006
commit
3c90cb7945
4 changed files with 36 additions and 4 deletions
|
|
@ -207,6 +207,7 @@ void desktop_focus_view(struct view *view);
|
|||
* Note: If current==NULL, the list's second view is returned
|
||||
*/
|
||||
struct view *desktop_next_view(struct server *server, struct view *current);
|
||||
void desktop_focus_next_mapped_view(struct view *current);
|
||||
struct view *desktop_view_at(struct server *server, double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx,
|
||||
double *sy, int *view_area);
|
||||
|
|
|
|||
|
|
@ -77,8 +77,10 @@ static void focus_view(struct view *view)
|
|||
|
||||
void desktop_focus_view(struct view *view)
|
||||
{
|
||||
if (!view)
|
||||
if (!view) {
|
||||
seat_focus_surface(NULL);
|
||||
return;
|
||||
}
|
||||
if (view->minimized)
|
||||
view_unminimize(view); /* this will unmap+focus */
|
||||
else if (view->mapped)
|
||||
|
|
@ -100,7 +102,7 @@ static bool isfocusable(struct view *view)
|
|||
return (view->mapped || view->minimized);
|
||||
}
|
||||
|
||||
static int has_focusable_view(struct wl_list *wl_list)
|
||||
static bool has_focusable_view(struct wl_list *wl_list)
|
||||
{
|
||||
struct view *view;
|
||||
wl_list_for_each (view, wl_list, link) {
|
||||
|
|
@ -131,6 +133,35 @@ struct view *desktop_next_view(struct server *server, struct view *current)
|
|||
return view;
|
||||
}
|
||||
|
||||
static bool has_mapped_view(struct wl_list *wl_list)
|
||||
{
|
||||
struct view *view;
|
||||
wl_list_for_each (view, wl_list, link) {
|
||||
if (view->mapped)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct view *desktop_next_mapped_view(struct view *current)
|
||||
{
|
||||
BUG_ON(!current);
|
||||
struct server *server = current->server;
|
||||
if (!has_mapped_view(&server->views))
|
||||
return NULL;
|
||||
struct view *view = first_view(server);
|
||||
do {
|
||||
view = wl_container_of(view->link.next, view, link);
|
||||
} while (&view->link == &server->views || !view->mapped);
|
||||
return view;
|
||||
}
|
||||
void desktop_focus_next_mapped_view(struct view *current)
|
||||
{
|
||||
BUG_ON(!current);
|
||||
struct view *view = desktop_next_mapped_view(current);
|
||||
desktop_focus_view(view);
|
||||
}
|
||||
|
||||
static bool _view_at(struct view *view, double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx, double *sy)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ static void xdg_toplevel_view_unmap(struct view *view)
|
|||
{
|
||||
view->mapped = false;
|
||||
wl_list_remove(&view->commit.link);
|
||||
desktop_focus_view(desktop_next_view(view->server, view));
|
||||
desktop_focus_next_mapped_view(view);
|
||||
}
|
||||
|
||||
static const struct view_impl xdg_toplevel_view_impl = {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ static void unmap(struct view *view)
|
|||
{
|
||||
view->mapped = false;
|
||||
wl_list_remove(&view->commit.link);
|
||||
desktop_focus_view(desktop_next_view(view->server, view));
|
||||
desktop_focus_next_mapped_view(view);
|
||||
}
|
||||
|
||||
static const struct view_impl xwl_view_impl = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue