mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
wayland: implement wayl_destroy()
This commit is contained in:
parent
0120c57ed5
commit
942ff566a2
4 changed files with 85 additions and 52 deletions
62
main.c
62
main.c
|
|
@ -1152,47 +1152,26 @@ out:
|
|||
shm_fini();
|
||||
|
||||
tll_free(term.window.on_outputs);
|
||||
tll_foreach(term.wl.monitors, it) {
|
||||
free(it->item.name);
|
||||
if (it->item.xdg != NULL)
|
||||
zxdg_output_v1_destroy(it->item.xdg);
|
||||
if (it->item.output != NULL)
|
||||
wl_output_destroy(it->item.output);
|
||||
tll_remove(term.wl.monitors, it);
|
||||
}
|
||||
|
||||
if (term.wl.xdg_output_manager != NULL)
|
||||
zxdg_output_manager_v1_destroy(term.wl.xdg_output_manager);
|
||||
|
||||
free(term.wl.pointer.theme_name);
|
||||
if (term.wl.pointer.theme != NULL)
|
||||
wl_cursor_theme_destroy(term.wl.pointer.theme);
|
||||
if (term.wl.pointer.pointer != NULL)
|
||||
wl_pointer_destroy(term.wl.pointer.pointer);
|
||||
if (term.wl.pointer.surface != NULL)
|
||||
wl_surface_destroy(term.wl.pointer.surface);
|
||||
if (term.wl.keyboard != NULL)
|
||||
wl_keyboard_destroy(term.wl.keyboard);
|
||||
if (term.selection.clipboard.data_source != NULL)
|
||||
wl_data_source_destroy(term.selection.clipboard.data_source);
|
||||
if (term.selection.clipboard.data_offer != NULL)
|
||||
wl_data_offer_destroy(term.selection.clipboard.data_offer);
|
||||
free(term.selection.clipboard.text);
|
||||
if (term.wl.data_device != NULL)
|
||||
wl_data_device_destroy(term.wl.data_device);
|
||||
if (term.wl.data_device_manager != NULL)
|
||||
wl_data_device_manager_destroy(term.wl.data_device_manager);
|
||||
if (term.selection.primary.data_source != NULL)
|
||||
zwp_primary_selection_source_v1_destroy(term.selection.primary.data_source);
|
||||
if (term.selection.primary.data_offer != NULL)
|
||||
zwp_primary_selection_offer_v1_destroy(term.selection.primary.data_offer);
|
||||
free(term.selection.primary.text);
|
||||
if (term.wl.primary_selection_device != NULL)
|
||||
zwp_primary_selection_device_v1_destroy(term.wl.primary_selection_device);
|
||||
if (term.wl.primary_selection_device_manager != NULL)
|
||||
zwp_primary_selection_device_manager_v1_destroy(term.wl.primary_selection_device_manager);
|
||||
if (term.wl.seat != NULL)
|
||||
wl_seat_destroy(term.wl.seat);
|
||||
if (term.kbd.xkb_compose_state != NULL)
|
||||
xkb_compose_state_unref(term.kbd.xkb_compose_state);
|
||||
if (term.kbd.xkb_compose_table != NULL)
|
||||
xkb_compose_table_unref(term.kbd.xkb_compose_table);
|
||||
if (term.kbd.xkb_keymap != NULL)
|
||||
xkb_keymap_unref(term.kbd.xkb_keymap);
|
||||
if (term.kbd.xkb_state != NULL)
|
||||
xkb_state_unref(term.kbd.xkb_state);
|
||||
if (term.kbd.xkb != NULL)
|
||||
xkb_context_unref(term.kbd.xkb);
|
||||
if (term.window.search_sub_surface != NULL)
|
||||
wl_subsurface_destroy(term.window.search_sub_surface);
|
||||
if (term.window.search_surface != NULL)
|
||||
|
|
@ -1211,26 +1190,7 @@ out:
|
|||
xdg_wm_base_destroy(term.window.shell);
|
||||
if (term.window.surface != NULL)
|
||||
wl_surface_destroy(term.window.surface);
|
||||
if (term.wl.shm != NULL)
|
||||
wl_shm_destroy(term.wl.shm);
|
||||
if (term.wl.sub_compositor != NULL)
|
||||
wl_subcompositor_destroy(term.wl.sub_compositor);
|
||||
if (term.wl.compositor != NULL)
|
||||
wl_compositor_destroy(term.wl.compositor);
|
||||
if (term.wl.registry != NULL)
|
||||
wl_registry_destroy(term.wl.registry);
|
||||
if (term.wl.display != NULL)
|
||||
wl_display_disconnect(term.wl.display);
|
||||
if (term.kbd.xkb_compose_state != NULL)
|
||||
xkb_compose_state_unref(term.kbd.xkb_compose_state);
|
||||
if (term.kbd.xkb_compose_table != NULL)
|
||||
xkb_compose_table_unref(term.kbd.xkb_compose_table);
|
||||
if (term.kbd.xkb_keymap != NULL)
|
||||
xkb_keymap_unref(term.kbd.xkb_keymap);
|
||||
if (term.kbd.xkb_state != NULL)
|
||||
xkb_state_unref(term.kbd.xkb_state);
|
||||
if (term.kbd.xkb != NULL)
|
||||
xkb_context_unref(term.kbd.xkb);
|
||||
wayl_destroy(&term.wl);
|
||||
|
||||
free(term.vt.osc.data);
|
||||
for (int row = 0; row < term.normal.num_rows; row++)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ executable(
|
|||
'tokenize.c', 'tokenize.h',
|
||||
'tllist.h',
|
||||
'vt.c', 'vt.h',
|
||||
'wayland.h',
|
||||
'wayland.c', 'wayland.h',
|
||||
wl_proto_src + wl_proto_headers, version,
|
||||
dependencies: [threads, math, freetype, fontconfig, pixman, wayland_client, wayland_cursor, xkb],
|
||||
install: true)
|
||||
|
|
|
|||
66
wayland.c
Normal file
66
wayland.c
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#include "wayland.h"
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-cursor.h>
|
||||
#include <xdg-shell.h>
|
||||
#include <xkbcommon/xkbcommon-compose.h>
|
||||
|
||||
#include <xdg-output-unstable-v1.h>
|
||||
#include <xdg-decoration-unstable-v1.h>
|
||||
|
||||
#define LOG_MODULE "wayland"
|
||||
#define LOG_ENABLE_DBG 0
|
||||
#include "log.h"
|
||||
|
||||
#include "tllist.h"
|
||||
|
||||
void
|
||||
wayl_init(struct wayland *wayl)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
wayl_destroy(struct wayland *wayl)
|
||||
{
|
||||
tll_foreach(wayl->monitors, it) {
|
||||
free(it->item.name);
|
||||
if (it->item.xdg != NULL)
|
||||
zxdg_output_v1_destroy(it->item.xdg);
|
||||
if (it->item.output != NULL)
|
||||
wl_output_destroy(it->item.output);
|
||||
tll_remove(wayl->monitors, it);
|
||||
}
|
||||
|
||||
if (wayl->xdg_output_manager != NULL)
|
||||
zxdg_output_manager_v1_destroy(wayl->xdg_output_manager);
|
||||
|
||||
free(wayl->pointer.theme_name);
|
||||
if (wayl->pointer.theme != NULL)
|
||||
wl_cursor_theme_destroy(wayl->pointer.theme);
|
||||
if (wayl->pointer.pointer != NULL)
|
||||
wl_pointer_destroy(wayl->pointer.pointer);
|
||||
if (wayl->pointer.surface != NULL)
|
||||
wl_surface_destroy(wayl->pointer.surface);
|
||||
if (wayl->keyboard != NULL)
|
||||
wl_keyboard_destroy(wayl->keyboard);
|
||||
if (wayl->data_device != NULL)
|
||||
wl_data_device_destroy(wayl->data_device);
|
||||
if (wayl->data_device_manager != NULL)
|
||||
wl_data_device_manager_destroy(wayl->data_device_manager);
|
||||
if (wayl->primary_selection_device != NULL)
|
||||
zwp_primary_selection_device_v1_destroy(wayl->primary_selection_device);
|
||||
if (wayl->primary_selection_device_manager != NULL)
|
||||
zwp_primary_selection_device_manager_v1_destroy(wayl->primary_selection_device_manager);
|
||||
if (wayl->seat != NULL)
|
||||
wl_seat_destroy(wayl->seat);
|
||||
if (wayl->shm != NULL)
|
||||
wl_shm_destroy(wayl->shm);
|
||||
if (wayl->sub_compositor != NULL)
|
||||
wl_subcompositor_destroy(wayl->sub_compositor);
|
||||
if (wayl->compositor != NULL)
|
||||
wl_compositor_destroy(wayl->compositor);
|
||||
if (wayl->registry != NULL)
|
||||
wl_registry_destroy(wayl->registry);
|
||||
if (wayl->display != NULL)
|
||||
wl_display_disconnect(wayl->display);
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <primary-selection-unstable-v1.h>
|
||||
|
||||
#include "tllist.h"
|
||||
|
||||
struct monitor {
|
||||
|
|
@ -72,3 +75,7 @@ struct wayland {
|
|||
bool have_argb8888;
|
||||
tll(struct monitor) monitors; /* All available outputs */
|
||||
};
|
||||
|
||||
/* TODO: return allocated pointer */
|
||||
void wayl_init(struct wayland *wayl);
|
||||
void wayl_destroy(struct wayland *wayl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue