aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-02-26 11:39:17 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-02-26 11:39:17 +0000
commit1e1b2043777511aedcaccf784ebac12bdecd866e (patch)
tree84d5be791c6f35b061f8eb07ab1f4664b1389cc9
parentwayland: decoration configure: no need to force a resize - just update the CSDs (diff)
csd: don't draw CSDs in fullscreen mode
-rw-r--r--render.c3
-rw-r--r--wayland.c88
-rw-r--r--wayland.h2
3 files changed, 51 insertions, 42 deletions
diff --git a/render.c b/render.c
index 7d15a384..3920ec90 100644
--- a/render.c
+++ b/render.c
@@ -671,6 +671,9 @@ render_csd(struct terminal *term)
break;
case CSD_YES: {
+ if (term->window->is_fullscreen)
+ return;
+
const int border_width = csd_border_size * term->scale;
const int title_height = csd_title_size * term->scale;
diff --git a/wayland.c b/wayland.c
index 9959081f..d875b3d7 100644
--- a/wayland.c
+++ b/wayland.c
@@ -37,6 +37,39 @@ static bool wayl_reload_cursor_theme(
struct wayland *wayl, struct terminal *term);
static void
+csd_instantiate(struct wl_window *win)
+{
+ struct wayland *wayl = win->term->wl;
+ assert(wayl != NULL);
+
+ for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
+ assert(win->csd.surface[i] == NULL);
+ assert(win->csd.sub_surface[i] == NULL);
+
+ win->csd.surface[i] = wl_compositor_create_surface(wayl->compositor);
+ win->csd.sub_surface[i] = wl_subcompositor_get_subsurface(
+ wayl->sub_compositor, win->csd.surface[i], win->surface);
+
+ wl_subsurface_set_sync(win->csd.sub_surface[i]);
+ wl_surface_commit(win->csd.surface[i]);
+ }
+}
+
+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;
+ }
+}
+
+static void
shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
{
struct wayland *wayl = data;
@@ -426,7 +459,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
int32_t width, int32_t height, struct wl_array *states)
{
bool is_activated = false;
- bool is_resizing = false;
+ bool is_fullscreen = false;
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
char state_str[2048];
@@ -447,16 +480,11 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
enum xdg_toplevel_state *state;
wl_array_for_each(state, states) {
switch (*state) {
- case XDG_TOPLEVEL_STATE_ACTIVATED:
- is_activated = true;
- break;
+ case XDG_TOPLEVEL_STATE_ACTIVATED: is_activated = true; break;
+ case XDG_TOPLEVEL_STATE_FULLSCREEN: is_fullscreen = true; break;
case XDG_TOPLEVEL_STATE_RESIZING:
- is_resizing = true;
- break;
-
case XDG_TOPLEVEL_STATE_MAXIMIZED:
- case XDG_TOPLEVEL_STATE_FULLSCREEN:
case XDG_TOPLEVEL_STATE_TILED_LEFT:
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
case XDG_TOPLEVEL_STATE_TILED_TOP:
@@ -495,7 +523,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
*/
struct wl_window *win = data;
- if (win->use_csd == CSD_YES && width != 0 && height != 0) {
+ if (!is_fullscreen && win->use_csd == CSD_YES && width != 0 && height != 0) {
/*
* The size received here is the *total* window size.
*
@@ -509,6 +537,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
}
win->configure.is_activated = is_activated;
+ win->configure.is_fullscreen = is_fullscreen;
win->configure.width = width;
win->configure.height = height;
}
@@ -538,6 +567,14 @@ xdg_surface_configure(void *data, struct xdg_surface *xdg_surface,
win->is_configured = true;
+ if (win->is_fullscreen != win->configure.is_fullscreen && win->use_csd == CSD_YES) {
+ if (win->configure.is_fullscreen)
+ csd_destroy(win);
+ else
+ csd_instantiate(win);
+ win->is_fullscreen = win->configure.is_fullscreen;
+ }
+
xdg_surface_ack_configure(xdg_surface, serial);
bool resized = render_resize(term, win->configure.width, win->configure.height);
@@ -561,39 +598,6 @@ static const struct xdg_surface_listener xdg_surface_listener = {
};
static void
-csd_instantiate(struct wl_window *win)
-{
- struct wayland *wayl = win->term->wl;
- assert(wayl != NULL);
-
- for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
- assert(win->csd.surface[i] == NULL);
- assert(win->csd.sub_surface[i] == NULL);
-
- win->csd.surface[i] = wl_compositor_create_surface(wayl->compositor);
- win->csd.sub_surface[i] = wl_subcompositor_get_subsurface(
- wayl->sub_compositor, win->csd.surface[i], win->surface);
-
- wl_subsurface_set_sync(win->csd.sub_surface[i]);
- wl_surface_commit(win->csd.surface[i]);
- }
-}
-
-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;
- }
-}
-
-static void
xdg_toplevel_decoration_configure(void *data,
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
uint32_t mode)
diff --git a/wayland.h b/wayland.h
index 617e8185..f7961552 100644
--- a/wayland.h
+++ b/wayland.h
@@ -111,8 +111,10 @@ struct wl_window {
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
bool is_configured;
+ bool is_fullscreen;
struct {
bool is_activated;
+ bool is_fullscreen;
int width;
int height;
} configure;