mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
search: move wayland surface variables into the term struct
This commit is contained in:
parent
66912cbfb5
commit
44a353a7f7
3 changed files with 49 additions and 34 deletions
20
main.c
20
main.c
|
|
@ -1019,12 +1019,6 @@ out:
|
|||
if (term.wl.xdg_output_manager != NULL)
|
||||
zxdg_output_manager_v1_destroy(term.wl.xdg_output_manager);
|
||||
|
||||
if (term.render.frame_callback != NULL)
|
||||
wl_callback_destroy(term.render.frame_callback);
|
||||
if (term.wl.xdg_toplevel != NULL)
|
||||
xdg_toplevel_destroy(term.wl.xdg_toplevel);
|
||||
if (term.wl.xdg_surface != NULL)
|
||||
xdg_surface_destroy(term.wl.xdg_surface);
|
||||
free(term.wl.pointer.theme_name);
|
||||
if (term.wl.pointer.theme != NULL)
|
||||
wl_cursor_theme_destroy(term.wl.pointer.theme);
|
||||
|
|
@ -1054,10 +1048,20 @@ out:
|
|||
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.wl.surface != NULL)
|
||||
wl_surface_destroy(term.wl.surface);
|
||||
if (term.wl.search_sub_surface != NULL)
|
||||
wl_subsurface_destroy(term.wl.search_sub_surface);
|
||||
if (term.wl.search_surface != NULL)
|
||||
wl_surface_destroy(term.wl.search_surface);
|
||||
if (term.render.frame_callback != NULL)
|
||||
wl_callback_destroy(term.render.frame_callback);
|
||||
if (term.wl.xdg_toplevel != NULL)
|
||||
xdg_toplevel_destroy(term.wl.xdg_toplevel);
|
||||
if (term.wl.xdg_surface != NULL)
|
||||
xdg_surface_destroy(term.wl.xdg_surface);
|
||||
if (term.wl.shell != NULL)
|
||||
xdg_wm_base_destroy(term.wl.shell);
|
||||
if (term.wl.surface != NULL)
|
||||
wl_surface_destroy(term.wl.surface);
|
||||
if (term.wl.shm != NULL)
|
||||
wl_shm_destroy(term.wl.shm);
|
||||
if (term.wl.compositor != NULL)
|
||||
|
|
|
|||
47
search.c
47
search.c
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
|
||||
static struct wl_surface *wl_surf;
|
||||
static struct wl_subsurface *sub_surf;
|
||||
|
||||
|
||||
static inline pixman_color_t
|
||||
|
|
@ -42,7 +40,7 @@ color_hex_to_pixman(uint32_t color)
|
|||
static void
|
||||
render(struct terminal *term)
|
||||
{
|
||||
assert(sub_surf != NULL);
|
||||
assert(term->wl.search_sub_surface != NULL);
|
||||
|
||||
/* TODO: at least sway allows the subsurface to extend outside the
|
||||
* main window. Do we want that? */
|
||||
|
|
@ -84,24 +82,25 @@ render(struct terminal *term)
|
|||
LOG_INFO("match length: %zu", term->search.match_len);
|
||||
|
||||
wl_subsurface_set_position(
|
||||
sub_surf, term->width - width - margin, term->height - height - margin);
|
||||
term->wl.search_sub_surface,
|
||||
term->width - width - margin, term->height - height - margin);
|
||||
|
||||
wl_surface_damage_buffer(wl_surf, 0, 0, width, height);
|
||||
wl_surface_attach(wl_surf, buf->wl_buf, 0, 0);
|
||||
wl_surface_set_buffer_scale(wl_surf, scale);
|
||||
wl_surface_commit(wl_surf);
|
||||
wl_surface_damage_buffer(term->wl.search_surface, 0, 0, width, height);
|
||||
wl_surface_attach(term->wl.search_surface, buf->wl_buf, 0, 0);
|
||||
wl_surface_set_buffer_scale(term->wl.search_surface, scale);
|
||||
wl_surface_commit(term->wl.search_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
search_cancel_keep_selection(struct terminal *term)
|
||||
{
|
||||
if (sub_surf != NULL) {
|
||||
wl_subsurface_destroy(sub_surf);
|
||||
sub_surf = NULL;
|
||||
if (term->wl.search_sub_surface != NULL) {
|
||||
wl_subsurface_destroy(term->wl.search_sub_surface);
|
||||
term->wl.search_sub_surface = NULL;
|
||||
}
|
||||
if (wl_surf != NULL) {
|
||||
wl_surface_destroy(wl_surf);
|
||||
wl_surf = NULL;
|
||||
if (term->wl.search_surface != NULL) {
|
||||
wl_surface_destroy(term->wl.search_surface);
|
||||
term->wl.search_surface = NULL;
|
||||
}
|
||||
|
||||
free(term->search.buf);
|
||||
|
|
@ -127,23 +126,23 @@ search_begin(struct terminal *term)
|
|||
term->search.view_followed_offset = term->grid->view == term->grid->offset;
|
||||
term->is_searching = true;
|
||||
|
||||
wl_surf = wl_compositor_create_surface(term->wl.compositor);
|
||||
if (wl_surf != NULL) {
|
||||
sub_surf = wl_subcompositor_get_subsurface(
|
||||
term->wl.sub_compositor, wl_surf, term->wl.surface);
|
||||
term->wl.search_surface = wl_compositor_create_surface(term->wl.compositor);
|
||||
if (term->wl.search_surface != NULL) {
|
||||
term->wl.search_sub_surface = wl_subcompositor_get_subsurface(
|
||||
term->wl.sub_compositor, term->wl.search_surface, term->wl.surface);
|
||||
|
||||
if (sub_surf != NULL) {
|
||||
if (term->wl.search_sub_surface != NULL) {
|
||||
/* Sub-surface updates may occur without updating the main
|
||||
* window */
|
||||
wl_subsurface_set_desync(sub_surf);
|
||||
wl_subsurface_set_desync(term->wl.search_sub_surface);
|
||||
}
|
||||
}
|
||||
|
||||
if (wl_surf == NULL || sub_surf == NULL) {
|
||||
if (term->wl.search_surface == NULL || term->wl.search_sub_surface == NULL) {
|
||||
LOG_ERR("failed to create sub-surface for search box");
|
||||
if (wl_surf != NULL)
|
||||
wl_surface_destroy(wl_surf);
|
||||
assert(sub_surf == NULL);
|
||||
if (term->wl.search_surface != NULL)
|
||||
wl_surface_destroy(term->wl.search_surface);
|
||||
assert(term->wl.search_sub_surface == NULL);
|
||||
}
|
||||
|
||||
render(term);
|
||||
|
|
|
|||
16
terminal.h
16
terminal.h
|
|
@ -42,15 +42,19 @@ struct wayland {
|
|||
struct wl_registry *registry;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_subcompositor *sub_compositor;
|
||||
struct wl_surface *surface;
|
||||
struct wl_shm *shm;
|
||||
|
||||
struct wl_seat *seat;
|
||||
struct wl_keyboard *keyboard;
|
||||
struct zxdg_output_manager_v1 *xdg_output_manager;
|
||||
|
||||
/* Clipboard */
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
struct wl_data_device *data_device;
|
||||
struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager;
|
||||
struct zwp_primary_selection_device_v1 *primary_selection_device;
|
||||
struct wl_keyboard *keyboard;
|
||||
|
||||
/* Cursor */
|
||||
struct {
|
||||
struct wl_pointer *pointer;
|
||||
uint32_t serial;
|
||||
|
|
@ -61,9 +65,17 @@ struct wayland {
|
|||
int size;
|
||||
char *theme_name;
|
||||
} pointer;
|
||||
|
||||
/* Main window */
|
||||
struct wl_surface *surface;
|
||||
struct xdg_wm_base *shell;
|
||||
struct xdg_surface *xdg_surface;
|
||||
struct xdg_toplevel *xdg_toplevel;
|
||||
|
||||
/* Scrollback search */
|
||||
struct wl_surface *search_surface;
|
||||
struct wl_subsurface *search_sub_surface;
|
||||
|
||||
bool have_argb8888;
|
||||
tll(struct monitor) monitors; /* All available outputs */
|
||||
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue