summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-11-09 12:07:35 -0500
committerKristian Høgsberg <krh@bitplanet.net>2011-11-09 12:07:35 -0500
commit32e24cc628eb8705099e392425c500ac36204379 (patch)
tree0b3e32056b067cba60dc4e3f05dbbd4d26d1b104
parent63ff706c0e00f9e583f5c8a4b220981772a62658 (diff)
compositor: Split shell->attach into map and configure
The shell module only needs to deal with attach when it's either the initial attach or when the attach changes the size of the surface. In case of initial attach, the shell needs to pick a position for the surface and a place in the surface stack. We split this case out as a new shell->map callback. The other case is split into the shell->configure callback, where the shell may adjust the surface position or reject the new size.
-rw-r--r--compositor/compositor.c22
-rw-r--r--compositor/compositor.h6
-rw-r--r--compositor/meego-tablet-shell.c23
-rw-r--r--compositor/shell.c36
4 files changed, 56 insertions, 31 deletions
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 53b282a..e3e8bdf 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -1094,8 +1094,8 @@ surface_attach(struct wl_client *client,
struct wl_resource *buffer_resource, int32_t x, int32_t y)
{
struct wlsc_surface *es = resource->data;
+ struct wlsc_shell *shell = es->compositor->shell;
struct wl_buffer *buffer = buffer_resource->data;
- int repick = 0;
if (es->buffer) {
wlsc_buffer_post_release(es->buffer);
@@ -1108,23 +1108,15 @@ surface_attach(struct wl_client *client,
&es->buffer_destroy_listener.link);
if (es->visual == WLSC_NONE_VISUAL) {
- wl_list_insert(&es->compositor->surface_list, &es->link);
- repick = 1;
- }
-
- if (x != 0 || y != 0 ||
- es->width != buffer->width || es->height != buffer->height) {
- wlsc_surface_configure(es, es->x + x, es->y + y,
- buffer->width, buffer->height);
- repick = 1;
+ shell->map(shell, es, buffer->width, buffer->height);
+ } else if (x != 0 || y != 0 ||
+ es->width != buffer->width ||
+ es->height != buffer->height) {
+ shell->configure(shell, es, es->x + x, es->y + y,
+ buffer->width, buffer->height);
}
wlsc_buffer_attach(buffer, &es->surface);
-
- es->compositor->shell->attach(es->compositor->shell, es);
-
- if (repick)
- wlsc_compositor_repick(es->compositor);
}
static void
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 421b80e..1cde1d9 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -163,7 +163,11 @@ struct wlsc_shell {
struct wlsc_surface *es,
struct wlsc_input_device *device, uint32_t time);
void (*lock)(struct wlsc_shell *shell);
- void (*attach)(struct wlsc_shell *shell, struct wlsc_surface *surface);
+ void (*map)(struct wlsc_shell *shell, struct wlsc_surface *surface,
+ int32_t width, int32_t height);
+ void (*configure)(struct wlsc_shell *shell,
+ struct wlsc_surface *surface,
+ int32_t x, int32_t y, int32_t width, int32_t height);
void (*set_selection_focus)(struct wlsc_shell *shell,
struct wl_selection *selection,
struct wl_surface *surface, uint32_t time);
diff --git a/compositor/meego-tablet-shell.c b/compositor/meego-tablet-shell.c
index 35b9775..f829f58 100644
--- a/compositor/meego-tablet-shell.c
+++ b/compositor/meego-tablet-shell.c
@@ -201,13 +201,9 @@ meego_tablet_zoom_run(struct meego_tablet_shell *shell,
return zoom;
}
-/* FIXME: We should be handling map, not attach... Map is when the
- * surface becomes visible, which is what we want to catch. Attach
- * will happen whenever the surface changes. */
-
static void
-meego_tablet_shell_attach(struct wlsc_shell *base,
- struct wlsc_surface *surface)
+meego_tablet_shell_map(struct wlsc_shell *base, struct wlsc_surface *surface,
+ int32_t width, int32_t height)
{
struct meego_tablet_shell *shell =
container_of(base, struct meego_tablet_shell, shell);
@@ -234,6 +230,18 @@ meego_tablet_shell_attach(struct wlsc_shell *base,
shell->current_client->surface = surface;
meego_tablet_zoom_run(shell, surface, 0.3, 1.0);
}
+
+ wl_list_insert(&shell->compositor->surface_list, &surface->link);
+ wlsc_surface_configure(surface, surface->x, surface->y, width, height);
+}
+
+static void
+meego_tablet_shell_configure(struct wlsc_shell *base,
+ struct wlsc_surface *surface,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ wlsc_surface_configure(surface, x, y, width, height);
}
static void
@@ -679,7 +687,8 @@ shell_init(struct wlsc_compositor *compositor)
compositor->shell = &shell->shell;
shell->shell.lock = meego_tablet_shell_lock;
- shell->shell.attach = meego_tablet_shell_attach;
+ shell->shell.map = meego_tablet_shell_map;
+ shell->shell.configure = meego_tablet_shell_configure;
shell->shell.set_selection_focus =
meego_tablet_shell_set_selection_focus;
launch_ux_daemon(shell);
diff --git a/compositor/shell.c b/compositor/shell.c
index ed2637d..e012482 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -919,18 +919,37 @@ lock(struct wlsc_shell *shell)
}
static void
-attach(struct wlsc_shell *base, struct wlsc_surface *es)
+map(struct wlsc_shell *base,
+ struct wlsc_surface *surface, int32_t width, int32_t height)
{
struct wl_shell *shell = container_of(base, struct wl_shell, shell);
struct wlsc_compositor *compositor = shell->compositor;
- if (es == shell->background) {
- wl_list_remove(&es->link);
- wl_list_insert(compositor->surface_list.prev, &es->link);
- } else if (es->map_type == WLSC_SURFACE_MAP_FULLSCREEN) {
- es->x = (es->fullscreen_output->current->width - es->width) / 2;
- es->y = (es->fullscreen_output->current->height - es->height) / 2;
+ /* Map background at the bottom of the stack, panel on top,
+ everything else just below panel. */
+ if (surface == shell->background)
+ wl_list_insert(compositor->surface_list.prev, &surface->link);
+ else if (surface == shell->panel)
+ wl_list_insert(&compositor->surface_list, &surface->link);
+ else
+ wl_list_insert(&shell->panel->link, &surface->link);
+
+ wlsc_surface_configure(surface, surface->x, surface->y, width, height);
+}
+
+static void
+configure(struct wlsc_shell *shell, struct wlsc_surface *surface,
+ int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ struct wlsc_mode *current;
+
+ if (surface->map_type == WLSC_SURFACE_MAP_FULLSCREEN) {
+ current = surface->fullscreen_output->current;
+ x = (current->width - surface->width) / 2;
+ y = (current->height - surface->height) / 2;
}
+
+ wlsc_surface_configure(surface, x, y, width, height);
}
static void
@@ -1032,7 +1051,8 @@ shell_init(struct wlsc_compositor *ec)
shell->compositor = ec;
shell->shell.activate = activate;
shell->shell.lock = lock;
- shell->shell.attach = attach;
+ shell->shell.map = map;
+ shell->shell.configure = configure;
shell->shell.set_selection_focus = wlsc_selection_set_focus;
if (wl_display_add_global(ec->wl_display, &wl_shell_interface,