mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
csd: use wayl_win_subsurface_new/destroy()
This commit is contained in:
parent
9d362158e3
commit
587f04f2e1
5 changed files with 39 additions and 29 deletions
4
quirks.c
4
quirks.c
|
|
@ -52,7 +52,7 @@ quirk_weston_csd_on(struct terminal *term)
|
|||
return;
|
||||
|
||||
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
|
||||
quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[i]);
|
||||
quirk_weston_subsurface_desync_on(term->window->csd.surface[i].sub);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -64,7 +64,7 @@ quirk_weston_csd_off(struct terminal *term)
|
|||
return;
|
||||
|
||||
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
|
||||
quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[i]);
|
||||
quirk_weston_subsurface_desync_off(term->window->csd.surface[i].sub);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
10
render.c
10
render.c
|
|
@ -1409,7 +1409,7 @@ render_csd_title(struct terminal *term)
|
|||
xassert(term->window->use_csd == CSD_YES);
|
||||
|
||||
struct csd_data info = get_csd_data(term, CSD_SURF_TITLE);
|
||||
struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE];
|
||||
struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE].surf;
|
||||
|
||||
xassert(info.width > 0 && info.height > 0);
|
||||
|
||||
|
|
@ -1440,7 +1440,7 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx)
|
|||
xassert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM);
|
||||
|
||||
struct csd_data info = get_csd_data(term, surf_idx);
|
||||
struct wl_surface *surf = term->window->csd.surface[surf_idx];
|
||||
struct wl_surface *surf = term->window->csd.surface[surf_idx].surf;
|
||||
|
||||
if (info.width == 0 || info.height == 0)
|
||||
return;
|
||||
|
|
@ -1609,7 +1609,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx)
|
|||
xassert(surf_idx >= CSD_SURF_MINIMIZE && surf_idx <= CSD_SURF_CLOSE);
|
||||
|
||||
struct csd_data info = get_csd_data(term, surf_idx);
|
||||
struct wl_surface *surf = term->window->csd.surface[surf_idx];
|
||||
struct wl_surface *surf = term->window->csd.surface[surf_idx].surf;
|
||||
|
||||
if (info.width == 0 || info.height == 0)
|
||||
return;
|
||||
|
|
@ -1696,8 +1696,8 @@ render_csd(struct terminal *term)
|
|||
const int width = info.width;
|
||||
const int height = info.height;
|
||||
|
||||
struct wl_surface *surf = term->window->csd.surface[i];
|
||||
struct wl_subsurface *sub = term->window->csd.sub_surface[i];
|
||||
struct wl_surface *surf = term->window->csd.surface[i].surf;
|
||||
struct wl_subsurface *sub = term->window->csd.surface[i].sub;
|
||||
|
||||
xassert(surf != NULL);
|
||||
xassert(sub != NULL);
|
||||
|
|
|
|||
16
terminal.c
16
terminal.c
|
|
@ -2827,21 +2827,21 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface)
|
|||
return TERM_SURF_SCROLLBACK_INDICATOR;
|
||||
else if (surface == term->window->render_timer_surface)
|
||||
return TERM_SURF_RENDER_TIMER;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_TITLE])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surf)
|
||||
return TERM_SURF_TITLE;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_LEFT])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_LEFT].surf)
|
||||
return TERM_SURF_BORDER_LEFT;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_RIGHT])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_RIGHT].surf)
|
||||
return TERM_SURF_BORDER_RIGHT;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_TOP])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_TOP].surf)
|
||||
return TERM_SURF_BORDER_TOP;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM].surf)
|
||||
return TERM_SURF_BORDER_BOTTOM;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE].surf)
|
||||
return TERM_SURF_BUTTON_MINIMIZE;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE].surf)
|
||||
return TERM_SURF_BUTTON_MAXIMIZE;
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_CLOSE])
|
||||
else if (surface == term->window->csd.surface[CSD_SURF_CLOSE].surf)
|
||||
return TERM_SURF_BUTTON_CLOSE;
|
||||
else {
|
||||
tll_foreach(term->window->urls, it) {
|
||||
|
|
|
|||
35
wayland.c
35
wayland.c
|
|
@ -39,6 +39,20 @@ csd_instantiate(struct wl_window *win)
|
|||
struct wayland *wayl = win->term->wl;
|
||||
xassert(wayl != NULL);
|
||||
|
||||
for (size_t i = 0; i < CSD_SURF_MINIMIZE; i++) {
|
||||
bool ret = wayl_win_subsurface_new(win, &win->csd.surface[i]);
|
||||
xassert(ret);
|
||||
}
|
||||
|
||||
for (size_t i = CSD_SURF_MINIMIZE; i < CSD_SURF_COUNT; i++) {
|
||||
bool ret = wayl_win_subsurface_new_with_custom_parent(
|
||||
win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i]);
|
||||
xassert(ret);
|
||||
}
|
||||
|
||||
/* TODO: we need the to commit? */
|
||||
|
||||
#if 0
|
||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
||||
xassert(win->csd.surface[i] == NULL);
|
||||
xassert(win->csd.sub_surface[i] == NULL);
|
||||
|
|
@ -55,20 +69,14 @@ csd_instantiate(struct wl_window *win)
|
|||
wl_surface_set_user_data(win->csd.surface[i], win);
|
||||
wl_surface_commit(win->csd.surface[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
csd_destroy(struct wl_window *win)
|
||||
{
|
||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
||||
if (win->csd.sub_surface[i] != NULL)
|
||||
wl_subsurface_destroy(win->csd.sub_surface[i]);
|
||||
if (win->csd.surface[i] != NULL)
|
||||
wl_surface_destroy(win->csd.surface[i]);
|
||||
|
||||
win->csd.surface[i] = NULL;
|
||||
win->csd.sub_surface[i] = NULL;
|
||||
}
|
||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++)
|
||||
wayl_win_subsurface_destroy(&win->csd.surface[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1414,9 +1422,9 @@ wayl_win_destroy(struct wl_window *win)
|
|||
|
||||
/* CSD */
|
||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
||||
if (win->csd.surface[i] != NULL) {
|
||||
wl_surface_attach(win->csd.surface[i], NULL, 0, 0);
|
||||
wl_surface_commit(win->csd.surface[i]);
|
||||
if (win->csd.surface[i].surf != NULL) {
|
||||
wl_surface_attach(win->csd.surface[i].surf, NULL, 0, 0);
|
||||
wl_surface_commit(win->csd.surface[i].surf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1613,4 +1621,7 @@ wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf)
|
|||
wl_subsurface_destroy(surf->sub);
|
||||
if (surf->surf != NULL)
|
||||
wl_surface_destroy(surf->surf);
|
||||
|
||||
surf->surf = NULL;
|
||||
surf->sub = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,8 +372,7 @@ struct wl_window {
|
|||
enum {CSD_UNKNOWN, CSD_NO, CSD_YES } use_csd;
|
||||
|
||||
struct {
|
||||
struct wl_surface *surface[CSD_SURF_COUNT];
|
||||
struct wl_subsurface *sub_surface[CSD_SURF_COUNT];
|
||||
struct wl_surf_subsurf surface[CSD_SURF_COUNT];
|
||||
int move_timeout_fd;
|
||||
uint32_t serial;
|
||||
} csd;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue