aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-12 10:39:25 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-17 20:48:07 +0000
commit587f04f2e1fd432993cecf75fe4ffd23c9b2b243 (patch)
treee473d3fbd6f5802add4ac50f10ac5c3bcd91663d
parenturl-mode: convert struct wl_url to use wayl_win_subsurface_new() (diff)
csd: use wayl_win_subsurface_new/destroy()
-rw-r--r--quirks.c4
-rw-r--r--render.c10
-rw-r--r--terminal.c16
-rw-r--r--wayland.c35
-rw-r--r--wayland.h3
5 files changed, 39 insertions, 29 deletions
diff --git a/quirks.c b/quirks.c
index f77b111d..539ad9d4 100644
--- a/quirks.c
+++ b/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
diff --git a/render.c b/render.c
index 4e5ec60f..c1a600ed 100644
--- a/render.c
+++ b/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);
diff --git a/terminal.c b/terminal.c
index 6c0827c6..42a5416e 100644
--- a/terminal.c
+++ b/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) {
diff --git a/wayland.c b/wayland.c
index 14cd0c85..6c74282a 100644
--- a/wayland.c
+++ b/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;
}
diff --git a/wayland.h b/wayland.h
index 5f4d8b76..15c9c3d9 100644
--- a/wayland.h
+++ b/wayland.h
@@ -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;