[waffle] [PATCH 07/10] waffle: add full screen window request

Chad Versace chad.versace at intel.com
Thu Apr 9 15:48:41 PDT 2015


On Mon 30 Mar 2015, Frank Henigman wrote:
>You can now put WAFFLE_WINDOW_FULLSCREEN in the attribute list passed
>to waffle_window_create2() and get a full screen window.
>Only glx and x11_egl implemented so far.

I like the idea of WAFFLE_WINDOW_FULLSCREEN. Comments below.

>Signed-off-by: Frank Henigman <fjhenigman at google.com>
>---
> include/waffle/waffle.h        |  1 +
> src/waffle/api/waffle_window.c | 69 ++++++++++++++++++++++--------------------
> src/waffle/glx/glx_window.c    | 12 ++++++--
> src/waffle/xegl/xegl_window.c  | 13 ++++++--
> 4 files changed, 59 insertions(+), 36 deletions(-)
>
>diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
>index 297a487..df0218e 100644
>--- a/include/waffle/waffle.h
>+++ b/include/waffle/waffle.h
>@@ -172,6 +172,7 @@ enum waffle_enum {
>
>     WAFFLE_WINDOW_WIDTH                                         = 0x0310,
>     WAFFLE_WINDOW_HEIGHT                                        = 0x0311,
>+    WAFFLE_WINDOW_FULLSCREEN                                    = 0x0312,

wcore_enum_to_string must be taught about the new enum.

> };
>
> const char*
>diff --git a/src/waffle/api/waffle_window.c b/src/waffle/api/waffle_window.c
>index 9ab63ca..10004c0 100644
>--- a/src/waffle/api/waffle_window.c
>+++ b/src/waffle/api/waffle_window.c
>@@ -42,6 +42,7 @@ waffle_window_create2(
>     struct wcore_config *wc_config = wcore_config(config);
>     intptr_t *attrib_list_filtered = NULL;
>     intptr_t width = 0, height = 0;
>+    intptr_t unused;
>
>     const struct api_object *obj_list[] = {
>         wc_config ? &wc_config->api : NULL,
>@@ -53,38 +54,42 @@ waffle_window_create2(
>
>     attrib_list_filtered = wcore_attrib_list_copy(attrib_list);
>
>-    if (!wcore_attrib_list_pop(attrib_list_filtered,
>-                               WAFFLE_WINDOW_WIDTH, &width)) {
>-        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>-                     "required attribute WAFFLE_WINDOW_WIDTH is missing");
>-        goto done;
>-    }
>-
>-    if (!wcore_attrib_list_pop(attrib_list_filtered,
>-                               WAFFLE_WINDOW_HEIGHT, &height)) {
>-        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>-                     "required attribute WAFFLE_WINDOW_HEIGHT is missing");
>-        goto done;
>-    }
>-
>-    if (width <= 0) {
>-        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>-                     "WAFFLE_WINDOW_WIDTH is not positive");
>-        goto done;
>-    } else if (width > INT32_MAX) {
>-        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>-                     "WAFFLE_WINDOW_WIDTH is greater than INT32_MAX");
>-        goto done;
>-    }
>-
>-    if (height <= 0) {
>-        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>-                     "WAFFLE_WINDOW_HEIGHT is not positive");
>-        goto done;
>-    } else if (height > INT32_MAX) {
>-        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>-                     "WAFFLE_WINDOW_HEIGHT is greater than INT32_MAX");
>-        goto done;


>+    if (!wcore_attrib_list_get(attrib_list_filtered,
>+                               WAFFLE_WINDOW_FULLSCREEN, &unused)) {

Instead of ignoring the value of WAFFLE_WINDOW_FULLSCREEN, it should be a
boolean value whose default value is false, like WAFFLE_CONTEXT_DEBUG. The
waffle_config manpage says this about WAFFLE_CONTEXT_DEBUG,

    This attribute is optional and its default value is false(0).  Valid values
    are true(1), false(0), and WAFFLE_DONT_CARE.

and WAFFLE_WINDOW_FULLSCREEN should behave the same, like so:

    intptr_t fullscreen = 0;

    wcore_attrib_list_get(attrib_list_filtered,
                          WAFFLE_WINDOW_FULLSCREEN, &fullscreen);
    switch (fullscreen) {
    case 0:
    case 1:
        break;
    case WAFFLE_DONT_CARE:
        // Default is false.
        fullscreen = 0;
        break;
    default:
        // Same error message as in wcore_config_attrs.c.
        wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
             "WAFFLE_WINDOW_FULLSCREEN has bad value 0x%x. "
             "Must be true(1), false(0), or WAFFLE_DONT_CARE(-1)",
             fullscreen);
        goto done;
    }

>+
>+        if (!wcore_attrib_list_pop(attrib_list_filtered,
>+                                   WAFFLE_WINDOW_WIDTH, &width)) {
>+            wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>+                         "required attribute WAFFLE_WINDOW_WIDTH is missing");
>+            goto done;
>+        }

>+
>+        if (!wcore_attrib_list_pop(attrib_list_filtered,
>+                                   WAFFLE_WINDOW_HEIGHT, &height)) {
>+            wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>+                         "required attribute WAFFLE_WINDOW_HEIGHT is missing");
>+            goto done;
>+        }
>+
>+        if (width <= 0) {
>+            wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>+                         "WAFFLE_WINDOW_WIDTH is not positive");
>+            goto done;
>+        } else if (width > INT32_MAX) {
>+            wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>+                         "WAFFLE_WINDOW_WIDTH is greater than INT32_MAX");
>+            goto done;
>+        }
>+
>+        if (height <= 0) {
>+            wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>+                         "WAFFLE_WINDOW_HEIGHT is not positive");
>+            goto done;
>+        } else if (height > INT32_MAX) {
>+            wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
>+                         "WAFFLE_WINDOW_HEIGHT is greater than INT32_MAX");
>+            goto done;
>+        }
>     }
>
>     wc_self = api_platform->vtbl->window.create(api_platform,

Non-X11 platforms will reject WAFFLE_WINDOW_FULLSCREEN with the error message
"bad attribute 0x312", and the user has no way to dynamically query which
Waffle platforms support fullscreen and which don't. I really wish Waffle had
an API for capability queries. But since it doesn't, users will just need to know
when it's safe and when it isn't to request fullscreen.

Anyway... I approve of the way that this patch handles non-X11 platforms. I was
mostly just complaining to myself that I haven't yet written a query API.


More information about the waffle mailing list