mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
output-layout: take wl_display in constructor
The output layout creates and destroys wl_output globals. We will soon need the wl_display to do so.
This commit is contained in:
parent
63792b38e4
commit
6a7463bb8e
6 changed files with 22 additions and 9 deletions
|
@ -221,7 +221,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
wlr_compositor_create(server.wl_display, 5, server.renderer);
|
||||
|
||||
server.output_layout = wlr_output_layout_create();
|
||||
server.output_layout = wlr_output_layout_create(server.wl_display);
|
||||
|
||||
wl_list_init(&server.outputs);
|
||||
server.new_output.notify = server_handle_new_output;
|
||||
|
|
|
@ -273,7 +273,7 @@ int main(int argc, char *argv[]) {
|
|||
.display = display,
|
||||
};
|
||||
|
||||
state.layout = wlr_output_layout_create();
|
||||
state.layout = wlr_output_layout_create(display);
|
||||
clock_gettime(CLOCK_MONOTONIC, &state.ts_last);
|
||||
|
||||
struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
|
@ -303,5 +303,4 @@ int main(int argc, char *argv[]) {
|
|||
wlr_texture_destroy(state.cat_texture);
|
||||
|
||||
wl_display_destroy(state.display);
|
||||
wlr_output_layout_destroy(state.layout);
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ int main(int argc, char *argv[]) {
|
|||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
state.cursor = wlr_cursor_create();
|
||||
state.layout = wlr_output_layout_create();
|
||||
state.layout = wlr_output_layout_create(display);
|
||||
wlr_cursor_attach_output_layout(state.cursor, state.layout);
|
||||
//wlr_cursor_map_to_region(state.cursor, state.config->cursor.mapped_box);
|
||||
wl_list_init(&state.devices);
|
||||
|
@ -415,5 +415,4 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
wlr_xcursor_manager_destroy(state.xcursor_manager);
|
||||
wlr_cursor_destroy(state.cursor);
|
||||
wlr_output_layout_destroy(state.layout);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ struct wlr_box;
|
|||
*/
|
||||
struct wlr_output_layout {
|
||||
struct wl_list outputs;
|
||||
struct wl_display *display;
|
||||
|
||||
struct {
|
||||
struct wl_signal add; // struct wlr_output_layout_output
|
||||
|
@ -34,6 +35,10 @@ struct wlr_output_layout {
|
|||
} events;
|
||||
|
||||
void *data;
|
||||
|
||||
// private state
|
||||
|
||||
struct wl_listener display_destroy;
|
||||
};
|
||||
|
||||
struct wlr_output_layout_output {
|
||||
|
@ -57,7 +62,7 @@ struct wlr_output_layout_output {
|
|||
struct wl_listener commit;
|
||||
};
|
||||
|
||||
struct wlr_output_layout *wlr_output_layout_create(void);
|
||||
struct wlr_output_layout *wlr_output_layout_create(struct wl_display *display);
|
||||
|
||||
void wlr_output_layout_destroy(struct wlr_output_layout *layout);
|
||||
|
||||
|
|
|
@ -891,7 +891,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
/* Creates an output layout, which a wlroots utility for working with an
|
||||
* arrangement of screens in a physical layout. */
|
||||
server.output_layout = wlr_output_layout_create();
|
||||
server.output_layout = wlr_output_layout_create(server.wl_display);
|
||||
|
||||
/* Configure a listener to be notified when new outputs are available on the
|
||||
* backend. */
|
||||
|
@ -1007,7 +1007,6 @@ int main(int argc, char *argv[]) {
|
|||
wl_display_destroy_clients(server.wl_display);
|
||||
wlr_scene_node_destroy(&server.scene->tree.node);
|
||||
wlr_xcursor_manager_destroy(server.cursor_mgr);
|
||||
wlr_output_layout_destroy(server.output_layout);
|
||||
wl_display_destroy(server.wl_display);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,17 +9,27 @@
|
|||
|
||||
static const struct wlr_addon_interface addon_impl;
|
||||
|
||||
struct wlr_output_layout *wlr_output_layout_create(void) {
|
||||
static void output_layout_handle_display_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_output_layout *layout = wl_container_of(listener, layout, display_destroy);
|
||||
wlr_output_layout_destroy(layout);
|
||||
}
|
||||
|
||||
struct wlr_output_layout *wlr_output_layout_create(struct wl_display *display) {
|
||||
struct wlr_output_layout *layout = calloc(1, sizeof(*layout));
|
||||
if (layout == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
wl_list_init(&layout->outputs);
|
||||
layout->display = display;
|
||||
|
||||
wl_signal_init(&layout->events.add);
|
||||
wl_signal_init(&layout->events.change);
|
||||
wl_signal_init(&layout->events.destroy);
|
||||
|
||||
layout->display_destroy.notify = output_layout_handle_display_destroy;
|
||||
wl_display_add_destroy_listener(display, &layout->display_destroy);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
@ -45,6 +55,7 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) {
|
|||
output_layout_output_destroy(l_output);
|
||||
}
|
||||
|
||||
wl_list_remove(&layout->display_destroy.link);
|
||||
free(layout);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue