This is an automated email from the git hooks/post-receive script.

git pushed a commit to reference refs/pull/124/head
in repository efl.

View the commit online.

commit f9b343adcfde0a5a34b899a2d3413952cf92eb25
Author: Swagtoy <[email protected]>
AuthorDate: Mon May 11 19:29:15 2026 -0400

    sdl: handle window close events
    
    I don't think this is correct yet, as SDL also tries to close the last
    window on it's own, sending the SDL_QUIT event. I think later we will
    want to not do this. Either way, this lets us close individual
    windows like those in Elementary test.
    
    I don't think I'm closing up correctly yet however, as in Elementary
    Test this works, but in Evisum i cannot seem to open the old windows
    that i closed again... nor did I even see it try to initialize.
    
    Signed-off-by: Swagtoy <[email protected]>
---
 src/lib/ecore_sdl/Ecore_Sdl.h                      |  1 +
 src/lib/ecore_sdl/ecore_sdl.c                      | 26 +++++++---
 .../ecore_evas/engines/sdl/ecore_evas_sdl.c        | 57 ++++++++++++++--------
 3 files changed, 57 insertions(+), 27 deletions(-)

diff --git a/src/lib/ecore_sdl/Ecore_Sdl.h b/src/lib/ecore_sdl/Ecore_Sdl.h
index c110f14f3d..c126ff165a 100644
--- a/src/lib/ecore_sdl/Ecore_Sdl.h
+++ b/src/lib/ecore_sdl/Ecore_Sdl.h
@@ -40,6 +40,7 @@ EAPI extern int ECORE_SDL_EVENT_GOT_FOCUS;
 EAPI extern int ECORE_SDL_EVENT_LOST_FOCUS;
 EAPI extern int ECORE_SDL_EVENT_RESIZE;
 EAPI extern int ECORE_SDL_EVENT_EXPOSE;
+EAPI extern int ECORE_SDL_EVENT_WINDOW_CLOSE;
 
 typedef struct _Ecore_Sdl_Event_Video_Resize Ecore_Sdl_Event_Video_Resize;
 struct _Ecore_Sdl_Event_Video_Resize
diff --git a/src/lib/ecore_sdl/ecore_sdl.c b/src/lib/ecore_sdl/ecore_sdl.c
index fe3dcb3143..42581db1e8 100644
--- a/src/lib/ecore_sdl/ecore_sdl.c
+++ b/src/lib/ecore_sdl/ecore_sdl.c
@@ -26,6 +26,7 @@ EAPI int ECORE_SDL_EVENT_GOT_FOCUS = 0;
 EAPI int ECORE_SDL_EVENT_LOST_FOCUS = 0;
 EAPI int ECORE_SDL_EVENT_RESIZE = 0;
 EAPI int ECORE_SDL_EVENT_EXPOSE = 0;
+EAPI int ECORE_SDL_EVENT_WINDOW_CLOSE = 0;
 
 static int _ecore_sdl_init_count = 0;
 static Eina_Rbtree *repeat = NULL;
@@ -78,10 +79,11 @@ ecore_sdl_init(const char *name EINA_UNUSED)
 
    SDL_Init(SDL_INIT_EVENTS);
 
-   ECORE_SDL_EVENT_GOT_FOCUS  = ecore_event_type_new();
-   ECORE_SDL_EVENT_LOST_FOCUS = ecore_event_type_new();
-   ECORE_SDL_EVENT_RESIZE     = ecore_event_type_new();
-   ECORE_SDL_EVENT_EXPOSE     = ecore_event_type_new();
+   ECORE_SDL_EVENT_GOT_FOCUS    = ecore_event_type_new();
+   ECORE_SDL_EVENT_LOST_FOCUS   = ecore_event_type_new();
+   ECORE_SDL_EVENT_RESIZE       = ecore_event_type_new();
+   ECORE_SDL_EVENT_EXPOSE       = ecore_event_type_new();
+   ECORE_SDL_EVENT_WINDOW_CLOSE = ecore_event_type_new();
 
    return _ecore_sdl_init_count;
 }
@@ -103,7 +105,8 @@ ecore_sdl_shutdown(void)
    ecore_event_type_flush(ECORE_SDL_EVENT_GOT_FOCUS,
                           ECORE_SDL_EVENT_LOST_FOCUS,
                           ECORE_SDL_EVENT_RESIZE,
-                          ECORE_SDL_EVENT_EXPOSE);
+                          ECORE_SDL_EVENT_EXPOSE,
+                          ECORE_SDL_EVENT_WINDOW_CLOSE);
 
    ecore_event_shutdown();
    eina_log_domain_unregister(_ecore_sdl_log_dom);
@@ -262,6 +265,17 @@ ecore_sdl_feed_events(void)
              ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
              break;
           }
+          case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
+          {
+               Ecore_Sdl_Event_Window *ev;
+
+               ev = calloc(1, sizeof (Ecore_Sdl_Event_Window));
+               ev->windowID = event.window.windowID;
+
+               ecore_event_add(ECORE_SDL_EVENT_WINDOW_CLOSE, ev, NULL, NULL);
+               break;
+          }
+          // fallthrough
           case SDL_EVENT_QUIT:
              ecore_main_loop_quit();
              break;
@@ -313,7 +327,7 @@ ecore_sdl_feed_events(void)
              break;
           }
 
-           case SDL_EVENT_WINDOW_RESIZED:
+          case SDL_EVENT_WINDOW_RESIZED:
             {
                Ecore_Sdl_Event_Video_Resize *ev;
 
diff --git a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
index 1f48912630..8059efb9bf 100644
--- a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
+++ b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
@@ -52,9 +52,7 @@ struct _Ecore_Evas_SDL_Switch_Data
 
 static int                      _ecore_evas_init_count = 0;
 
-static Ecore_Event_Handler      *ecore_evas_event_handlers[4] = {
-   NULL, NULL, NULL, NULL
-};
+static Ecore_Event_Handler      *ecore_evas_event_handlers[6] = { NULL };
 
 static Ecore_Poller             *ecore_evas_event;
 
@@ -150,12 +148,28 @@ _ecore_evas_sdl_event(void *data EINA_UNUSED)
    return ECORE_CALLBACK_RENEW;
 }
 
+static Eina_Bool
+_ecore_evas_sdl_event_window_close(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{ printf("%s\n", __FUNCTION__);
+   Ecore_Sdl_Event_Window *ev = event;
+   Ecore_Evas *ee;
+   Ecore_Evas_SDL_Switch_Data *swd;
+   ee = _ecore_evas_sdl_match(ev->windowID);
+   if (!ee)
+     return ECORE_CALLBACK_PASS_ON;
+
+   swd = (Ecore_Evas_SDL_Switch_Data*) (ee + 1);
+   ecore_event_window_unregister(ev->windowID);
+   SDL_DestroyWindow(swd->w);
+   ee->prop.window     = 0;
+   swd->w = NULL;
+   return ECORE_CALLBACK_RENEW;
+}
+
 static int
 _ecore_evas_sdl_init(void* data, int w EINA_UNUSED, int h EINA_UNUSED)
 { printf("%s\n", __FUNCTION__);
    _ecore_evas_init_count++;
-   if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
-
    // this is pretty bad: poller? and set poll time? pol time is meant to be
    // adjustable for things like polling battery state, or amoutn of spare
    // memory etc.
@@ -163,6 +177,8 @@ _ecore_evas_sdl_init(void* data, int w EINA_UNUSED, int h EINA_UNUSED)
    // to whoever wrote the above comment: agreed!
    ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_sdl_event, data);
    ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006);
+   // XXX: would be above this, but we need the poller for each instance because this sucks
+   if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
 
    ecore_event_evas_init();
 
@@ -170,6 +186,7 @@ _ecore_evas_sdl_init(void* data, int w EINA_UNUSED, int h EINA_UNUSED)
    ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_SDL_EVENT_LOST_FOCUS, _ecore_evas_sdl_event_lost_focus, NULL);
    ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_SDL_EVENT_RESIZE, _ecore_evas_sdl_event_video_resize, NULL);
    ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_SDL_EVENT_EXPOSE, _ecore_evas_sdl_event_video_expose, NULL);
+   ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_SDL_EVENT_WINDOW_CLOSE, _ecore_evas_sdl_event_window_close, data);
 
    return _ecore_evas_init_count;
 }
@@ -188,7 +205,6 @@ _ecore_evas_sdl_shutdown(void)
         ecore_poller_del(ecore_evas_event);
         ecore_evas_event = NULL;
      }
-   if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
    return _ecore_evas_init_count;
 }
 
@@ -203,6 +219,7 @@ _ecore_evas_sdl_free(Ecore_Evas *ee)
 
    _ecore_evas_sdl_shutdown();
    ecore_sdl_shutdown();
+
 }
 
 static void
@@ -352,7 +369,7 @@ static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
 
 static Ecore_Evas*
 _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fullscreen, int hwsurface, int noframe EINA_UNUSED, int alpha)
-{
+{ printf("[ INITIALIZATION OF EVAS SDL3 ]\n");
    Ecore_Evas_SDL_Switch_Data *swd;
    Ecore_Evas *ee;
    Eina_Bool gl = EINA_FALSE;
@@ -381,23 +398,21 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fu
    if (w < 1) w = 1;
    if (h < 1) h = 1;
    ee->visible = 1;
-   ee->req.w = w;
-   ee->req.h = h;
-   ee->w = w;
-   ee->h = h;
+   ee->w = ee->req.w = w;
+   ee->h = ee->req.h = h;
 
-   ee->prop.max.w = 0;
-   ee->prop.max.h = 0;
-   ee->prop.layer = 0;
+   ee->prop.max.w      = 0;
+   ee->prop.max.h      = 0;
+   ee->prop.layer      = 0;
    ee->prop.borderless = EINA_TRUE;
-   ee->prop.override = EINA_TRUE;
-   ee->prop.maximized = EINA_TRUE;
+   ee->prop.override   = EINA_TRUE;
+   ee->prop.maximized  = EINA_TRUE;
    ee->prop.fullscreen = fullscreen;
-   ee->prop.withdrawn = EINA_TRUE;
-   ee->prop.sticky = EINA_FALSE;
-   ee->prop.window = 0;
-   ee->alpha = alpha;
-   ee->prop.hwsurface = hwsurface;
+   ee->prop.withdrawn  = EINA_TRUE;
+   ee->prop.sticky     = EINA_FALSE;
+   ee->prop.window     = 0;
+   ee->alpha           = alpha;
+   ee->prop.hwsurface  = hwsurface;
    /* init evas here */
    if (!ecore_evas_evas_new(ee, w, h))
      {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to