Complete carve up of main.c

This commit is contained in:
Johan Malm 2019-12-27 22:34:00 +00:00
parent 657f90e09b
commit b5c307c32b
4 changed files with 206 additions and 203 deletions

26
view.c
View file

@ -1,5 +1,31 @@
#include "labwc.h"
static struct view *last_toplevel(struct server *server)
{
struct view *view;
wl_list_for_each_reverse (view, &server->views, link) {
if (!view->been_mapped) {
continue;
}
if (is_toplevel(view)) {
return view;
}
}
fprintf(stderr, "warn: found no toplevel view (%s)\n", __func__);
return NULL;
}
void view_focus_last_toplevel(struct server *server)
{
/* TODO: write view_nr_toplevel_views() */
if (wl_list_length(&server->views) < 2) {
return;
}
struct view *view = last_toplevel(server);
focus_view(view, view->surface);
}
static void activate_view(struct view *view)
{
if (view->type == LAB_XDG_SHELL_VIEW) {