commit: 29cf9b2036dbe2b5449f3dd03df1ece5a61efacd
parent 2432e695a0c7fa8d450ccd7c6d67735c05edb4f4
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 2 Dec 2020 05:41:18 +0100
Move function-wide comments right before their signature
Diffstat:
2 files changed, 17 insertions(+), 25 deletions(-)
diff --git a/commands.c b/commands.c
@@ -22,10 +22,10 @@ spawn(const Arg *arg)
}
}
+/* Note: this function only deals with keyboard focus. */
void
focus_view(struct inaban_view *view, struct wlr_surface *surface)
{
- /* Note: this function only deals with keyboard focus. */
if(view == NULL) return;
struct inaban_server *server = view->server;
struct wlr_seat *seat = server->seat;
diff --git a/inaban.c b/inaban.c
@@ -18,8 +18,7 @@
struct inaban_server server = {0};
-/* This event is raised when a modifier key, such as shift or alt, is pressed.
- * We simply communicate this to the client. */
+/* event raised when a modifier key, such as shift or alt, is pressed. */
static void
keyboard_handle_modifiers(struct wl_listener *listener, void *data)
{
@@ -37,7 +36,7 @@ keyboard_handle_modifiers(struct wl_listener *listener, void *data)
&keyboard->device->keyboard->modifiers);
}
-/* This event is raised when a key is pressed or released. */
+/* event raised when a key is pressed or released. */
static void
keyboard_handle_key(struct wl_listener *listener, void *data)
{
@@ -117,11 +116,10 @@ server_new_pointer(struct inaban_server *server, struct wlr_input_device *device
wlr_cursor_attach_input_device(server->cursor, device);
}
+/* event raised by the backend when a new input device becomes available */
static void
server_new_input(struct wl_listener *listener, void *data)
{
- /* This event is raised by the backend when a new input device becomes
- * available. */
struct inaban_server *server = wl_container_of(listener, server, new_input);
struct wlr_input_device *device = data;
switch(device->type)
@@ -139,19 +137,14 @@ server_new_input(struct wl_listener *listener, void *data)
wlr_seat_set_capabilities(server->seat, caps);
}
+/* event raised by the seat when a client provides a cursor image */
static void
seat_request_cursor(struct wl_listener *listener, void *data)
{
struct inaban_server *server = wl_container_of(listener, server, request_cursor);
- /* This event is rasied by the seat when a client provides a cursor image */
struct wlr_seat_pointer_request_set_cursor_event *event = data;
struct wlr_seat_client *focused_client = server->seat->pointer_state.focused_client;
- /* This can be sent by any client, so we check to make sure this one is
- * actually has pointer focus first. */
- /* Once we've vetted the client, we can tell the cursor to use the
- * provided surface as the cursor image. It will set the hardware cursor
- * on the output that it's currently on and continue to do so as the
- * cursor moves between outputs. */
+
if(focused_client == event->seat_client)
wlr_cursor_set_surface(server->cursor, event->surface, event->hotspot_x, event->hotspot_y);
}
@@ -189,6 +182,8 @@ view_at(struct inaban_view *view,
return false;
}
+/* iterates over all of our surfaces and attempts to find one under the cursor,
+ * relies on server->views being ordered from top-to-bottom */
static struct inaban_view *
desktop_view_at(struct inaban_server *server,
double lx,
@@ -197,8 +192,6 @@ desktop_view_at(struct inaban_server *server,
double *sx,
double *sy)
{
- /* This iterates over all of our surfaces and attempts to find one under the
- * cursor. This relies on server->views being ordered from top-to-bottom. */
struct inaban_view *view;
wl_list_for_each(view, &server->views, link)
{
@@ -320,10 +313,10 @@ server_cursor_frame(struct wl_listener *listener, void *data)
wlr_seat_pointer_notify_frame(server->seat);
}
+/* called for every surface that needs to be rendered */
static void
render_surface(struct wlr_surface *surface, int sx, int sy, void *data)
{
- /* This function is called for every surface that needs to be rendered. */
struct render_data *rdata = data;
struct inaban_view *view = rdata->view;
struct wlr_output *output = rdata->output;
@@ -377,12 +370,12 @@ render_surface(struct wlr_surface *surface, int sx, int sy, void *data)
wlr_surface_send_frame_done(surface, rdata->when);
}
+/* called every time an output is ready to display a frame,
+ * generally at the output's refresh rate (e.g. 60Hz). */
static void
output_frame(struct wl_listener *listener, void *data)
{
(void)data;
- /* This function is called every time an output is ready to display a frame,
- * generally at the output's refresh rate (e.g. 60Hz). */
struct inaban_output *output = wl_container_of(listener, output, frame);
struct wlr_renderer *renderer = output->server->renderer;
@@ -431,11 +424,10 @@ output_frame(struct wl_listener *listener, void *data)
wlr_output_commit(output->wlr_output);
}
+/* raised by the backend when a new output (aka display/monitor) becomes available */
static void
server_new_output(struct wl_listener *listener, void *data)
{
- /* This event is rasied by the backend when a new output (aka a display or
- * monitor) becomes available. */
struct inaban_server *server = wl_container_of(listener, server, new_output);
struct wlr_output *wlr_output = data;
@@ -471,30 +463,30 @@ server_new_output(struct wl_listener *listener, void *data)
wlr_output_create_global(wlr_output);
}
+/* Called when the surface is mapped, or ready to display on-screen. */
static void
xdg_surface_map(struct wl_listener *listener, void *data)
{
(void)data;
- /* Called when the surface is mapped, or ready to display on-screen. */
struct inaban_view *view = wl_container_of(listener, view, map);
view->mapped = true;
focus_view(view, view->xdg_surface->surface);
}
+/* Called when the surface is unmapped, and should no longer be shown. */
static void
xdg_surface_unmap(struct wl_listener *listener, void *data)
{
(void)data;
- /* Called when the surface is unmapped, and should no longer be shown. */
struct inaban_view *view = wl_container_of(listener, view, unmap);
view->mapped = false;
}
+/* Called when the surface is destroyed and should never be shown again. */
static void
xdg_surface_destroy(struct wl_listener *listener, void *data)
{
(void)data;
- /* Called when the surface is destroyed and should never be shown again. */
struct inaban_view *view = wl_container_of(listener, view, destroy);
wl_list_remove(&view->link);
free(view);
@@ -507,11 +499,11 @@ xdg_deny_request(struct wl_listener *listener, void *data)
(void)data;
}
+/* raised when wlr_xdg_shell receives a new xdg surface from a client,
+ * either a toplevel (application window) or popup. */
static void
server_new_xdg_surface(struct wl_listener *listener, void *data)
{
- /* This event is raised when wlr_xdg_shell receives a new xdg surface from a
- * client, either a toplevel (application window) or popup. */
struct inaban_server *server = wl_container_of(listener, server, new_xdg_surface);
struct wlr_xdg_surface *xdg_surface = data;
if(xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) return;