Commit 0d094a074292c297aaf7fec0cba3ede4dedcc9a0

Thomas de Grivel 2023-12-03T20:09:02

fullscreen

diff --git a/libc3/window/cairo/types.h b/libc3/window/cairo/types.h
index 506ae02..7042c35 100644
--- a/libc3/window/cairo/types.h
+++ b/libc3/window/cairo/types.h
@@ -97,6 +97,7 @@ struct window_cairo {
   sw                    y;
   uw                    w;
   uw                    h;
+  bool                  fullscreen;
   f_window_cairo_button button;
   f_window_cairo_key    key;
   f_window_cairo_load   load;
diff --git a/libc3/window/sdl2/demo/window_sdl2_demo.c b/libc3/window/sdl2/demo/window_sdl2_demo.c
index 8bebd2f..722dc4b 100644
--- a/libc3/window/sdl2/demo/window_sdl2_demo.c
+++ b/libc3/window/sdl2/demo/window_sdl2_demo.c
@@ -73,6 +73,14 @@ bool window_sdl2_demo_key (s_window_sdl2 *window, SDL_Keysym *keysym)
   assert(keysym);
   (void) window;
   switch (keysym->sym) {
+  case SDLK_f:
+    if (! window->fullscreen)
+      SDL_SetWindowFullscreen(window->sdl_window,
+                              SDL_WINDOW_FULLSCREEN_DESKTOP);
+    else
+      SDL_SetWindowFullscreen(window->sdl_window, 0);
+    window->fullscreen = ! window->fullscreen;
+    return true;
   case SDLK_ESCAPE:
   case SDLK_q:
     g_c3_exit_code = 0;
diff --git a/libc3/window/sdl2/types.h b/libc3/window/sdl2/types.h
index 8eca1b2..eef4516 100644
--- a/libc3/window/sdl2/types.h
+++ b/libc3/window/sdl2/types.h
@@ -88,6 +88,7 @@ struct window_sdl2 {
   sw                   y;
   uw                   w;
   uw                   h;
+  bool                 fullscreen;
   f_window_sdl2_button button;
   f_window_sdl2_key    key;
   f_window_sdl2_load   load;
diff --git a/libc3/window/sdl2/window_sdl2.c b/libc3/window/sdl2/window_sdl2.c
index f363298..2c834de 100644
--- a/libc3/window/sdl2/window_sdl2.c
+++ b/libc3/window/sdl2/window_sdl2.c
@@ -29,6 +29,7 @@ s_window_sdl2 * window_sdl2_init (s_window_sdl2 *window,
   window->y = y;
   window->w = w;
   window->h = h;
+  window->fullscreen = false;
   window->button = window_sdl2_button_default;
   window->key = window_sdl2_key_default;
   window->load = window_sdl2_load_default;
diff --git a/libc3/window/types.h b/libc3/window/types.h
index e321dac..c2cb53d 100644
--- a/libc3/window/types.h
+++ b/libc3/window/types.h
@@ -52,6 +52,7 @@ struct window {
   sw              y;
   uw              w;
   uw              h;
+  bool            fullscreen;
   f_window_button button;
   f_window_key    key;
   f_window_load   load;