]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view.c: rename+simplify focus_view()
authorJohan Malm <jgm323@gmail.com>
Sat, 16 May 2020 11:18:00 +0000 (12:18 +0100)
committerJohan Malm <jgm323@gmail.com>
Sat, 16 May 2020 11:18:00 +0000 (12:18 +0100)
labwc.h
server.c
view.c
xdg.c
xwl.c

diff --git a/labwc.h b/labwc.h
index 9051016069a24a6139320f81258fcb2fd13b28a0..871589f7ab81cfedae00c6a1f478b7f1edd95a7e 100644 (file)
--- a/labwc.h
+++ b/labwc.h
@@ -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);
index a2dda7991d454ebf7601cb8f16bf741d721b539d..3ec0a831b724df50324430f530916a7acbb0e24e 100644 (file)
--- a/server.c
+++ b/server.c
@@ -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);
diff --git a/view.c b/view.c
index c62eafacabf2b7ff2641c6789f93e939002443a0..bd355279ff5a002585fd638930aed48531f0b8b4 100644 (file)
--- a/view.c
+++ b/view.c
@@ -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;
        }
@@ -202,7 +201,7 @@ void begin_interactive(struct view *view, enum cursor_mode mode, uint32_t edges)
 }
 
 static bool _view_at(struct view *view, double lx, double ly,
-                   struct wlr_surface **surface, double *sx, double *sy)
+                    struct wlr_surface **surface, double *sx, double *sy)
 {
        /*
         * XDG toplevels may have nested surfaces, such as popup windows for
diff --git a/xdg.c b/xdg.c
index 94a8f51b20ba57df26f116ef7e14576d08760c97..8234eb9092a11ae5aa362af3e2c4d830f006a316 100644 (file)
--- a/xdg.c
+++ b/xdg.c
@@ -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)
diff --git a/xwl.c b/xwl.c
index 39e357631798fe17d7377d5a5f723700f394334f..9294377d841eb81dc9879982cb6e2577fb7ffcc4 100644 (file)
--- a/xwl.c
+++ b/xwl.c
@@ -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)