[RFC patch v2] compositor: add map() to the shell plugin interface
Pekka Paalanen
ppaalanen at gmail.com
Wed Nov 9 04:22:25 PST 2011
wlsc_shell::attach() call did not provide any direct indication whether
this attach request is the first one for a surface and therefore will
map the surface on screen. On map, the shell may want to change the
initial positioning or stacking of the surface.
Add wlsc_shell::map() call.
This change will help implement screen locking. While locked, the shell
can move the newly mapped surface to another (off-screen) list on map()
to prevent it from getting input or being painted.
wlsc_surface_damage_below(), called from surface_attach() via
wlsc_surface_configure(), will not work as intended, if the surface is
moved to an off-screen list in map().
Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
Changes in v2:
Always insert the surface to compositor->surface_list first, because
wlsc_surface_damage_below() assumes that for checking if the surface
is the last in the list. map() does not need to insert it.
Call map() only after configuring the surface.
Moved the background fixup from attach() to map().
compositor/compositor.c | 8 +++++++-
compositor/compositor.h | 1 +
compositor/meego-tablet-shell.c | 11 +++++++----
compositor/shell.c | 19 +++++++++++++++----
4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 53b282a..a1acd30 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -1094,8 +1094,10 @@ 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;
+ int ismap = 0;
if (es->buffer) {
wlsc_buffer_post_release(es->buffer);
@@ -1109,6 +1111,7 @@ surface_attach(struct wl_client *client,
if (es->visual == WLSC_NONE_VISUAL) {
wl_list_insert(&es->compositor->surface_list, &es->link);
+ ismap = 1;
repick = 1;
}
@@ -1121,7 +1124,10 @@ surface_attach(struct wl_client *client,
wlsc_buffer_attach(buffer, &es->surface);
- es->compositor->shell->attach(es->compositor->shell, es);
+ if (ismap)
+ shell->map(shell, es);
+
+ shell->attach(shell, es);
if (repick)
wlsc_compositor_repick(es->compositor);
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 421b80e..998d8c3 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -163,6 +163,7 @@ struct wlsc_shell {
struct wlsc_surface *es,
struct wlsc_input_device *device, uint32_t time);
void (*lock)(struct wlsc_shell *shell);
+ void (*map)(struct wlsc_shell *shell, struct wlsc_surface *surface);
void (*attach)(struct wlsc_shell *shell, struct wlsc_surface *surface);
void (*set_selection_focus)(struct wlsc_shell *shell,
struct wl_selection *selection,
diff --git a/compositor/meego-tablet-shell.c b/compositor/meego-tablet-shell.c
index 35b9775..886d404 100644
--- a/compositor/meego-tablet-shell.c
+++ b/compositor/meego-tablet-shell.c
@@ -201,14 +201,16 @@ 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)
{
+}
+
+static void
+meego_tablet_shell_map(struct wlsc_shell *base,
+ struct wlsc_surface *surface)
+{
struct meego_tablet_shell *shell =
container_of(base, struct meego_tablet_shell, shell);
@@ -679,6 +681,7 @@ shell_init(struct wlsc_compositor *compositor)
compositor->shell = &shell->shell;
shell->shell.lock = meego_tablet_shell_lock;
+ shell->shell.map = meego_tablet_shell_map;
shell->shell.attach = meego_tablet_shell_attach;
shell->shell.set_selection_focus =
meego_tablet_shell_set_selection_focus;
diff --git a/compositor/shell.c b/compositor/shell.c
index ed2637d..4a62b0b 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -919,17 +919,27 @@ lock(struct wlsc_shell *shell)
}
static void
-attach(struct wlsc_shell *base, struct wlsc_surface *es)
+map(struct wlsc_shell *base, struct wlsc_surface *es)
{
struct wl_shell *shell = container_of(base, struct wl_shell, shell);
struct wlsc_compositor *compositor = shell->compositor;
if (es == shell->background) {
+ /* move background to the bottom */
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;
+ }
+}
+
+static void
+attach(struct wlsc_shell *base, struct wlsc_surface *es)
+{
+ if (es->map_type == WLSC_SURFACE_MAP_FULLSCREEN) {
+ struct wlsc_mode *current = es->fullscreen_output->current;
+
+ /* center fullscreen surfaces to the output */
+ es->x = (current->width - es->width) / 2;
+ es->y = (current->height - es->height) / 2;
}
}
@@ -1032,6 +1042,7 @@ shell_init(struct wlsc_compositor *ec)
shell->compositor = ec;
shell->shell.activate = activate;
shell->shell.lock = lock;
+ shell->shell.map = map;
shell->shell.attach = attach;
shell->shell.set_selection_focus = wlsc_selection_set_focus;
--
1.7.3.4
More information about the wayland-devel
mailing list