mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Generalize output handling
This commit is contained in:
parent
15b1ce9e6c
commit
00931f2f8f
16 changed files with 407 additions and 444 deletions
31
wayland/types/wlr_output.c
Normal file
31
wayland/types/wlr_output.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-server.h>
|
||||
#include "wlr/wayland.h"
|
||||
#include "wlr/common/list.h"
|
||||
#include "wayland.h"
|
||||
|
||||
struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
|
||||
struct wlr_output_state *state) {
|
||||
struct wlr_output *output = calloc(1, sizeof(struct wlr_output));
|
||||
output->impl = impl;
|
||||
output->state = state;
|
||||
output->modes = list_create();
|
||||
wl_signal_init(&output->events.frame);
|
||||
return output;
|
||||
}
|
||||
|
||||
void wlr_output_free(struct wlr_output *output) {
|
||||
if (!output) return;
|
||||
if (output->make) free(output->make);
|
||||
if (output->model) free(output->model);
|
||||
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
|
||||
free(output->modes->items[i]);
|
||||
}
|
||||
list_free(output->modes);
|
||||
output->impl->destroy(output->state);
|
||||
free(output);
|
||||
}
|
||||
|
||||
bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode) {
|
||||
return output->impl->set_mode(output->state, mode);
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-client.h>
|
||||
#include "wlr/wayland.h"
|
||||
#include "wlr/common/list.h"
|
||||
|
||||
void wlr_wl_output_free(struct wlr_wl_output *output) {
|
||||
if (!output) return;
|
||||
if (output->wl_output) wl_output_destroy(output->wl_output);
|
||||
if (output->make) free(output->make);
|
||||
if (output->model) free(output->model);
|
||||
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
|
||||
free(output->modes->items[i]);
|
||||
}
|
||||
list_free(output->modes);
|
||||
free(output);
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <wayland-client.h>
|
||||
#include "wlr/wayland.h"
|
||||
#include "wlr/common/list.h"
|
||||
|
||||
void wlr_wl_seat_free(struct wlr_wl_seat *seat) {
|
||||
if (!seat) return;
|
||||
if (seat->wl_seat) wl_seat_destroy(seat->wl_seat);
|
||||
if (seat->name) free(seat->name);
|
||||
if (seat->keyboards) {
|
||||
// TODO: free children
|
||||
list_free(seat->keyboards);
|
||||
}
|
||||
if (seat->pointers) {
|
||||
// TODO: free children
|
||||
list_free(seat->keyboards);
|
||||
}
|
||||
free(seat);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue