From: Juan Zhao <juan.j.z...@linux.intel.com>

update the surface and implementation in desktop-shell
 according to the protocol change for fullscreen.
in shell, mainly setting the flags and let the base compositor to
 do the real mode changing for fill action.
---
 clients/window.c        |    4 ++-
 compositor/compositor.c |   14 ++++++++++-
 compositor/compositor.h |   10 +++++++-
 compositor/shell.c      |   56 ++++++++++++++++++++++++++++++++--------------
 4 files changed, 63 insertions(+), 21 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index b031daa..90e0a32 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -770,12 +770,14 @@ window_get_resize_dx_dy(struct window *window, int *x, 
int *y)
 static void
 window_set_type(struct window *window)
 {
+       uint32_t fs_mode = WL_SHELL_SURFACE_FULLSCREEN_MOTHED_NONE;
+
        if (!window->shell_surface)
                return;
 
        switch (window->type) {
        case TYPE_FULLSCREEN:
-               wl_shell_surface_set_fullscreen(window->shell_surface);
+               wl_shell_surface_set_fullscreen(window->shell_surface, fs_mode, 
1);
                break;
        case TYPE_TOPLEVEL:
                wl_shell_surface_set_toplevel(window->shell_surface);
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 0fa9ed8..bef6867 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -227,7 +227,7 @@ wlsc_surface_create(struct wlsc_compositor *compositor,
        surface->height = height;
        surface->alpha = 255;
 
-       surface->fullscreen_output = NULL;
+       surface->fs_support.fs_method = WLSC_SURFACE_FULLSCREEN_NONE;
        surface->buffer = NULL;
        surface->output = NULL;
 
@@ -306,6 +306,16 @@ wlsc_surface_configure(struct wlsc_surface *surface,
                pixman_region32_init(&surface->opaque);
 }
 
+WL_EXPORT void
+wlsc_surface_center_on_output( struct wlsc_surface *surface,
+                              struct wlsc_output *output )
+{
+       struct wlsc_mode *mode = output->current;
+
+       surface->x = output->x + (mode->width - surface->width) / 2;
+       surface->y = output->y + (mode->height - surface->height) / 2;
+}
+
 WL_EXPORT uint32_t
 wlsc_compositor_get_time(void)
 {
@@ -787,7 +797,7 @@ wlsc_output_repaint(struct wlsc_output *output)
                /* We're drawing nothing, just let the damage accumulate */
                return;
 
-       if (es->fullscreen_output == output) {
+       if (es->fs_support.fullscreen_output == output) {
                if (es->width < output->current->width ||
                    es->height < output->current->height)
                        glClear(GL_COLOR_BUFFER_BIT);
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 4c011f0..9ba107d 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -32,6 +32,10 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 
+#define WLSC_SURFACE_FULLSCREEN_NONE 0
+#define WLSC_SURFACE_FULLSCREEN_FORCE 1
+#define WLSC_SURFACE_FULLSCREEN_FILL 2
+
 struct wlsc_matrix {
        GLfloat d[16];
 };
@@ -249,6 +253,11 @@ struct wlsc_surface {
        uint32_t alpha;
        uint32_t visual;
 
+       struct {
+               uint32_t fs_method;
+               struct wlsc_output *fullscreen_output;
+       } fs_support;
+
        /*
         * Which output to vsync this surface to.
         * Used to determine, whether to send or queue frame events.
@@ -256,7 +265,6 @@ struct wlsc_surface {
         */
        struct wlsc_output *output;
 
-       struct wlsc_output *fullscreen_output;
        struct wl_list frame_callback_list;
 
        EGLImageKHR image;
diff --git a/compositor/shell.c b/compositor/shell.c
index ee15ddf..94392cf 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -302,7 +302,7 @@ reset_shell_surface_type(struct shell_surface *surface)
        case SHELL_SURFACE_FULLSCREEN:
                surface->surface->x = surface->saved_x;
                surface->surface->y = surface->saved_y;
-               surface->surface->fullscreen_output = NULL;
+               surface->surface->fs_support.fullscreen_output = NULL;
                break;
        case SHELL_SURFACE_PANEL:
        case SHELL_SURFACE_BACKGROUND:
@@ -372,7 +372,8 @@ get_default_output(struct wlsc_compositor *compositor)
 
 static void
 shell_surface_set_fullscreen(struct wl_client *client,
-                            struct wl_resource *resource)
+                            struct wl_resource *resource,
+                            uint32_t flags, uint32_t isfullscreen)
 
 {
        struct shell_surface *shsurf = resource->data;
@@ -382,6 +383,10 @@ shell_surface_set_fullscreen(struct wl_client *client,
        if (reset_shell_surface_type(shsurf))
                return;
 
+       if(!isfullscreen)
+               return;
+
+
        /* FIXME: Fullscreen on first output */
        /* FIXME: Handle output going away */
        output = get_default_output(es->compositor);
@@ -391,9 +396,30 @@ shell_surface_set_fullscreen(struct wl_client *client,
        shsurf->saved_y = es->y;
        es->x = (output->current->width - es->width) / 2;
        es->y = (output->current->height - es->height) / 2;
-       es->fullscreen_output = output;
-       wlsc_surface_damage(es);
+       es->fs_support.fullscreen_output = output;
        shsurf->type = SHELL_SURFACE_FULLSCREEN;
+       switch(flags){
+               case WL_SHELL_SURFACE_FULLSCREEN_MOTHED_NONE:
+                       wlsc_surface_damage(es);
+                       es->fs_support.fs_method = WLSC_SURFACE_FULLSCREEN_NONE;
+                       break;
+               case WL_SHELL_SURFACE_FULLSCREEN_MOTHED_FORCE:
+                       es->x = 0;
+                       es->y = 0;
+                       wlsc_surface_damage(es);
+                       es->fs_support.fs_method =
+                                       WLSC_SURFACE_FULLSCREEN_FORCE;
+                       break;
+               case WL_SHELL_SURFACE_FULLSCREEN_MOTHED_FILL:
+                       wlsc_surface_damage(es);
+                       es->fs_support.fs_method = WLSC_SURFACE_FULLSCREEN_FILL;
+               default :
+                       fprintf(stderr,
+                               "unknown parameter for fullscreen support\n");
+                       break;
+       }
+       /*will do the real action on the map or paint function*/
+
 }
 
 static const struct wl_shell_surface_interface shell_surface_implementation = {
@@ -954,15 +980,6 @@ unlock(struct wlsc_shell *base)
 }
 
 static void
-center_on_output(struct wlsc_surface *surface, struct wlsc_output *output)
-{
-       struct wlsc_mode *mode = output->current;
-
-       surface->x = output->x + (mode->width - surface->width) / 2;
-       surface->y = output->y + (mode->height - surface->height) / 2;
-}
-
-static void
 map(struct wlsc_shell *base,
     struct wlsc_surface *surface, int32_t width, int32_t height)
 {
@@ -970,6 +987,7 @@ map(struct wlsc_shell *base,
        struct wlsc_compositor *compositor = shell->compositor;
        struct wl_list *list;
        struct shell_surface *shsurf;
+       struct wlsc_output *fs_output = surface->fs_support.fullscreen_output;
        enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
        int do_configure;
 
@@ -996,10 +1014,11 @@ map(struct wlsc_shell *base,
                break;
        case SHELL_SURFACE_SCREENSAVER:
        case SHELL_SURFACE_FULLSCREEN:
-               center_on_output(surface, surface->fullscreen_output);
+               wlsc_surface_set_fullscreen(fs_output, surface);
                break;
        case SHELL_SURFACE_LOCK:
-               center_on_output(surface, get_default_output(compositor));
+               wlsc_surface_center_on_output(surface,
+                                             get_default_output(compositor));
                break;
        default:
                ;
@@ -1077,6 +1096,9 @@ configure(struct wlsc_shell *base, struct wlsc_surface 
*surface,
        int do_configure = !shell->locked;
        enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
        struct shell_surface *shsurf;
+       struct wlsc_output *fs_output;
+
+       fs_output = surface->fs_support.fullscreen_output;
 
        shsurf = get_shell_surface(surface);
        if (shsurf)
@@ -1090,7 +1112,7 @@ configure(struct wlsc_shell *base, struct wlsc_surface 
*surface,
                do_configure = !do_configure;
                /* fall through */
        case SHELL_SURFACE_FULLSCREEN:
-               center_on_output(surface, surface->fullscreen_output);
+               wlsc_surface_center_on_output(surface, fs_output);
                break;
        default:
                break;
@@ -1194,7 +1216,7 @@ screensaver_set_surface(struct wl_client *client,
 
        surface->type = SHELL_SURFACE_SCREENSAVER;
 
-       surface->surface->fullscreen_output = output;
+       surface->surface->fs_support.fullscreen_output = output;
        surface->output = output;
        wl_list_insert(shell->screensaver.surfaces.prev, &surface->link);
 }
-- 
1.7.2.2

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to