compositor: call configure on surfaces with a null buffer too
This way the shell can know when a surface has been unmapped by
checking the value returned by weston_surface_is_mapped(surface).
The configure handlers have now width and height parameters, so
they do not need anymore to check manually the buffer size.
If a surface's buffer is NULL the width and height passed to the
configure are both 0.
Configure is now only called after an attach. The variable
weston_surface.pending.newly_attached is set to 1 on attach, and
after the configure call is reset to 0.
diff --git a/src/shell.c b/src/shell.c
index 6573038..3da5321 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1636,7 +1636,7 @@
}
static void
-black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy);
+black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height);
static struct weston_surface *
create_black_surface(struct weston_compositor *ec,
@@ -2032,7 +2032,7 @@
}
static void
-shell_surface_configure(struct weston_surface *, int32_t, int32_t);
+shell_surface_configure(struct weston_surface *, int32_t, int32_t, int32_t, int32_t);
static struct shell_surface *
get_shell_surface(struct weston_surface *surface)
@@ -2193,10 +2193,13 @@
}
static void
-configure_static_surface(struct weston_surface *es, struct weston_layer *layer)
+configure_static_surface(struct weston_surface *es, struct weston_layer *layer, int32_t width, int32_t height)
{
struct weston_surface *s, *next;
+ if (width == 0)
+ return;
+
wl_list_for_each_safe(s, next, &layer->surface_list, layer_link) {
if (s->output == es->output && s != es) {
weston_surface_unmap(s);
@@ -2204,9 +2207,7 @@
}
}
- weston_surface_configure(es, es->output->x, es->output->y,
- weston_surface_buffer_width(es),
- weston_surface_buffer_height(es));
+ weston_surface_configure(es, es->output->x, es->output->y, width, height);
if (wl_list_empty(&es->layer_link)) {
wl_list_insert(&layer->surface_list, &es->layer_link);
@@ -2215,11 +2216,11 @@
}
static void
-background_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+background_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
struct desktop_shell *shell = es->private;
- configure_static_surface(es, &shell->background_layer);
+ configure_static_surface(es, &shell->background_layer, width, height);
}
static void
@@ -2248,11 +2249,11 @@
}
static void
-panel_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+panel_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
struct desktop_shell *shell = es->private;
- configure_static_surface(es, &shell->panel_layer);
+ configure_static_surface(es, &shell->panel_layer, width, height);
}
static void
@@ -2281,10 +2282,13 @@
}
static void
-lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
+lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
struct desktop_shell *shell = surface->private;
+ if (width == 0)
+ return;
+
center_on_output(surface, get_default_output(shell->compositor));
if (!weston_surface_is_mapped(surface)) {
@@ -2738,7 +2742,7 @@
/* no-op func for checking black surface */
static void
-black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
}
@@ -3178,14 +3182,16 @@
}
static void
-shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
struct shell_surface *shsurf = get_shell_surface(es);
struct desktop_shell *shell = shsurf->shell;
- int32_t width = weston_surface_buffer_width(es);
- int32_t height = weston_surface_buffer_height(es);
+
int type_changed = 0;
+ if (width == 0)
+ return;
+
if (shsurf->next_type != SHELL_SURFACE_NONE &&
shsurf->type != shsurf->next_type) {
set_surface_type(shsurf);
@@ -3298,10 +3304,13 @@
}
static void
-screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
+screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
struct desktop_shell *shell = surface->private;
+ if (width == 0)
+ return;
+
/* XXX: starting weston-screensaver beforehand does not work */
if (!shell->locked)
return;
@@ -3369,13 +3378,14 @@
}
static void
-input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
+input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
{
struct weston_mode *mode;
- int32_t width = weston_surface_buffer_width(surface);
- int32_t height = weston_surface_buffer_height(surface);
float x, y;
+ if (width == 0)
+ return;
+
if (!weston_surface_is_mapped(surface))
return;