Files
absinthe/src/output.c
T

63 lines
2.1 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)
{
struct absinthe_output *output = wl_container_of(listener, output, frame);
struct wlr_scene *scene = output->server->scene;
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(scene, output->wlr_output);
wlr_scene_output_commit(scene_output, NULL);
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_scene_output_send_frame_done(scene_output, &now);
}
void output_request_state(struct wl_listener *listener, void *data)
{
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);
}
void output_destroy(struct wl_listener *listener, void *data)
{
struct absinthe_output *output = wl_container_of(listener, output, request_state);
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-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
{
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-01-11 22:38:28 +07:00
wlr_output_layout_get_box(server->output_layout, output->wlr_output, &output->geometry);
2026-01-04 18:07:28 +07:00
}
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)
{
struct absinthe_output *output;
int32_t cursor_x = server->cursor->x;
int32_t cursor_y = server->cursor->y;
2026-01-04 18:07:28 +07:00
wl_list_for_each(output, &server->outputs, link) {
2026-01-11 22:38:28 +07:00
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;
if (cursor_in_output_x && cursor_in_output_y) {
server->focused_output = output;
break;
}
2026-01-04 18:07:28 +07:00
}
}
2026-01-11 22:38:28 +07:00