view.c: rename+simplify focus_view()

This commit is contained in:
Johan Malm 2020-05-16 12:18:00 +01:00
parent 778e4e890b
commit 759fbe683b
5 changed files with 10 additions and 11 deletions

View file

@ -140,7 +140,7 @@ void xwl_surface_new(struct wl_listener *listener, void *data);
bool view_want_deco(struct view *view);
void view_focus_last_toplevel(struct server *server);
void focus_view(struct view *view, struct wlr_surface *surface);
void view_focus(struct view *view);
void view_focus_next_toplevel(struct view *current);
void begin_interactive(struct view *view, enum cursor_mode mode,
uint32_t edges);

View file

@ -362,7 +362,7 @@ void server_cursor_button(struct wl_listener *listener, void *data)
server->cursor_mode = TINYWL_CURSOR_PASSTHROUGH;
} else {
/* Focus that client if the button was _pressed_ */
focus_view(view, surface);
view_focus(view);
switch (view_area) {
case LAB_DECO_PART_TOP:
begin_interactive(view, TINYWL_CURSOR_MOVE, 0);

11
view.c
View file

@ -47,7 +47,7 @@ void view_focus_last_toplevel(struct server *server)
if (wl_list_length(&server->views) < 2)
return;
struct view *view = last_toplevel(server);
focus_view(view, view->surface);
view_focus(view);
}
static struct view *next_toplevel(struct view *current)
@ -65,7 +65,7 @@ void view_focus_next_toplevel(struct view *current)
{
struct view *view;
view = next_toplevel(current);
focus_view(view, view->surface);
view_focus(view);
}
static void move_to_front(struct view *view)
@ -105,18 +105,17 @@ static void set_activated(struct wlr_surface *s, bool activated)
}
}
/* FIXME: why have we got both view and surface here???? */
void focus_view(struct view *view, struct wlr_surface *surface)
void view_focus(struct view *view)
{
/* Note: this function only deals with keyboard focus. */
if (!view)
if (!view || !view->surface)
return;
struct server *server = view->server;
struct wlr_seat *seat = server->seat;
struct wlr_surface *prev_surface;
prev_surface = seat->keyboard_state.focused_surface;
if (prev_surface == surface) {
if (prev_surface == view->surface) {
/* Don't re-focus an already focused surface. */
return;
}

2
xdg.c
View file

@ -54,7 +54,7 @@ void xdg_surface_map(struct wl_listener *listener, void *data)
view->mapped = true;
view->been_mapped = true;
view->surface = view->xdg_surface->surface;
focus_view(view, view->xdg_surface->surface);
view_focus(view);
}
void xdg_surface_unmap(struct wl_listener *listener, void *data)

2
xwl.c
View file

@ -42,7 +42,7 @@ void xwl_surface_map(struct wl_listener *listener, void *data)
if (!view->been_mapped)
position(view);
view->been_mapped = true;
focus_view(view, view->xwayland_surface->surface);
view_focus(view);
}
void xwl_surface_unmap(struct wl_listener *listener, void *data)