Files
absinthe/src/output.c
T

76 lines
2.2 KiB
C
Raw Normal View History

2026-01-02 22:53:34 +07:00
#include <stdlib.h>
2026-01-08 22:44:24 +07:00
#include <wlr/util/log.h>
2026-01-02 22:53:34 +07:00
#include "types.h"
void output_frame(struct wl_listener *listener, void *data)
{
2026-04-26 14:31:03 +07:00
UNUSED(data);
2026-04-25 14:09:14 +07:00
struct absinthe_output *output = wl_container_of(listener, output, frame);
struct wlr_scene *scene = output->server->scene;
2026-01-02 22:53:34 +07:00
2026-04-25 14:09:14 +07:00
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(scene, output->wlr_output);
2026-01-02 22:53:34 +07:00
2026-04-25 14:09:14 +07:00
struct absinthe_toplevel *toplevel;
wl_list_for_each(toplevel, &output->server->toplevels, link)
{
2026-04-23 10:47:42 +07:00
if (toplevel->resizing && toplevel->output == output)
goto skip;
}
2026-04-25 14:09:14 +07:00
wlr_scene_output_commit(scene_output, NULL);
2026-01-02 22:53:34 +07:00
2026-04-23 10:47:42 +07:00
skip:
2026-04-25 14:09:14 +07:00
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_scene_output_send_frame_done(scene_output, &now);
2026-01-02 22:53:34 +07:00
}
void output_request_state(struct wl_listener *listener, void *data)
{
2026-04-25 14:09:14 +07:00
struct absinthe_output *output = wl_container_of(listener, output, request_state);
const struct wlr_output_event_request_state *event = data;
wlr_output_commit_state(output->wlr_output, event->state);
2026-01-02 22:53:34 +07:00
}
void output_destroy(struct wl_listener *listener, void *data)
{
2026-04-26 14:31:03 +07:00
UNUSED(data);
2026-04-25 14:09:14 +07:00
struct absinthe_output *output = wl_container_of(listener, output, request_state);
2026-01-02 22:53:34 +07:00
2026-04-25 14:09:14 +07:00
wl_list_remove(&output->frame.link);
wl_list_remove(&output->request_state.link);
wl_list_remove(&output->destroy.link);
wl_list_remove(&output->link);
free(output);
2026-01-02 22:53:34 +07:00
}
2026-01-04 18:07:28 +07:00
2026-01-11 22:38:28 +07:00
void outputs_update(struct wl_listener *listener, void *data)
2026-01-04 18:07:28 +07:00
{
2026-04-26 14:31:03 +07:00
UNUSED(data);
2026-04-25 14:09:14 +07:00
struct absinthe_server *server = wl_container_of(listener, server, output_layout_change);
struct absinthe_output *output;
wl_list_for_each(output, &server->outputs, link)
{
2026-04-25 14:09:14 +07:00
wlr_output_layout_get_box(server->output_layout, output->wlr_output, &output->geometry);
}
2026-01-11 22:38:28 +07:00
}
2026-01-04 18:07:28 +07:00
2026-01-11 22:38:28 +07:00
void update_focused_output(struct absinthe_server *server)
{
2026-04-25 14:09:14 +07:00
struct absinthe_output *output;
int32_t cursor_x = server->cursor->x;
int32_t cursor_y = server->cursor->y;
wl_list_for_each(output, &server->outputs, link)
{
bool cursor_in_output_x =
cursor_x >= output->geometry.x && cursor_x <= output->geometry.x + output->geometry.width;
bool cursor_in_output_y =
cursor_y >= output->geometry.y && cursor_y <= output->geometry.y + output->geometry.height;
2026-04-25 14:09:14 +07:00
if (cursor_in_output_x && cursor_in_output_y) {
server->focused_output = output;
break;
}
}
2026-01-04 18:07:28 +07:00
}