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 b0e7c05cedf3ef59246b7d54e61620240e796795
Author: Swagtoy <[email protected]>
AuthorDate: Thu May 14 02:29:03 2026 -0400

    ecore_evas_sdl: use ee->engine.data, don't abuse struct offset
    
    The old code did this but there is no purpose and it's a bit icky.
    
    Signed-off-by: Swagtoy <[email protected]>
---
 .../ecore_evas/engines/sdl/ecore_evas_sdl.c        | 60 +++++++++++-----------
 1 file changed, 30 insertions(+), 30 deletions(-)

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 644d218358..41b98219b7 100644
--- a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
+++ b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
@@ -40,14 +40,10 @@
 # define EMODAPI
 #endif
 
-typedef struct _Ecore_Evas_SDL_Switch_Data Ecore_Evas_SDL_Switch_Data;
-struct _Ecore_Evas_SDL_Switch_Data
+typedef struct _Ecore_Evas_SDL_Data Ecore_Evas_SDL_Data;
+struct _Ecore_Evas_SDL_Data
 {
-   SDL_Texture *pages[2];
-   SDL_Renderer *r;
    SDL_Window *w;
-
-   unsigned char current;
 };
 
 static int                      _ecore_evas_init_count = 0;
@@ -94,7 +90,6 @@ _ecore_evas_sdl_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED,
 {
    Ecore_Sdl_Event_Video_Resize *e;
    Ecore_Evas *ee;
-   int rmethod;
 
    e = event;
    ee = _ecore_evas_sdl_match(e->windowID);
@@ -136,13 +131,12 @@ static void
 _ecore_evas_sdl_post_render(Ecore_Evas *ee)
 {
    Evas_Engine_Info_Software_SDL *info = (Evas_Engine_Info_Software_SDL *) evas_engine_info_get(ee->evas);
-   Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*) (ee + 1);
-   // XXX: this is not sufficient at all
-   SDL_Surface *surface = SDL_GetWindowSurface(swd->w);
-   printf("surface: %d %d | other %d %d\n", surface->w, surface->h, info->surface->w, info->surface->h);
+   Ecore_Evas_SDL_Data *edata = ee->engine.data;
+
+   SDL_Surface *surface = SDL_GetWindowSurface(edata->w);
    if (!SDL_BlitSurface(info->surface, NULL, surface, NULL))
      ERR("Couldn't blit surface: %s", SDL_GetError());
-   if (!SDL_UpdateWindowSurface(swd->w))
+   if (!SDL_UpdateWindowSurface(edata->w))
      ERR("Couldn't update window surface: %s", SDL_GetError());
 
 }
@@ -181,7 +175,8 @@ _ecore_evas_sdl_init(void* data, int w EINA_UNUSED, int h EINA_UNUSED)
    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;
+   if (_ecore_evas_init_count > 1)
+     return _ecore_evas_init_count;
 
    ecore_event_evas_init();
 
@@ -214,10 +209,10 @@ _ecore_evas_sdl_shutdown(void)
 static void
 _ecore_evas_sdl_free(Ecore_Evas *ee)
 { printf("%s\n", __FUNCTION__);
-   Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*) (ee + 1);
+   Ecore_Evas_SDL_Data *edata = ee->engine.data;
 
-   ecore_event_window_unregister(SDL_GetWindowID(swd->w));
-   SDL_DestroyWindow(swd->w);
+   ecore_event_window_unregister(SDL_GetWindowID(edata->w));
+   SDL_DestroyWindow(edata->w);
 
    _ecore_evas_sdl_shutdown();
    ecore_sdl_shutdown();
@@ -226,7 +221,7 @@ _ecore_evas_sdl_free(Ecore_Evas *ee)
 static void
 _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
 { puts(__FUNCTION__);
-   Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
+   Ecore_Evas_SDL_Data *edata = ee->engine.data;
 
    if ((w == ee->w) && (h == ee->h))
      return;
@@ -235,7 +230,7 @@ _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
    ee->w = w;
    ee->h = h;
 
-   SDL_SetWindowSize(swd->w, w, h);
+   SDL_SetWindowSize(edata->w, w, h);
    evas_output_size_set(ee->evas, ee->w, ee->h);
    evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
    evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
@@ -270,8 +265,10 @@ _ecore_evas_show(Ecore_Evas *ee)
 static void
 _ecore_evas_title_set(Ecore_Evas *ee, const char *t)
 { printf("%s %s\n", __FUNCTION__, t);
-   Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
-   SDL_SetWindowTitle(swd->w, strfry(strdup(t ? t : "This code is really good")));
+   Ecore_Evas_SDL_Data *edata = ee->engine.data;
+   EINA_SAFETY_ON_FALSE_RETURN(t);
+
+   SDL_SetWindowTitle(edata->w, t);
 }
 
 static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
@@ -368,11 +365,12 @@ 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)
-{ printf("[ INITIALIZATION OF EVAS SDL3 ]\n");
-   Ecore_Evas_SDL_Switch_Data *swd;
+{
+   Ecore_Evas_SDL_Data *edata;
    Ecore_Evas *ee;
    Eina_Bool gl = EINA_FALSE;
 
+   // XXX
    if (!name)
      name = "(We shouldn't ever see this)";
 
@@ -384,11 +382,13 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h)
         return NULL;
      }
 
-   ee = calloc(1, sizeof(Ecore_Evas) + sizeof (Ecore_Evas_SDL_Switch_Data));
-   if (!ee) return NULL;
-   swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
+   ee = calloc(1, sizeof(Ecore_Evas));
+   if (!ee)
+     return NULL;
    ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
 
+   ee->engine.data = "" = calloc(1, sizeof(Ecore_Evas_SDL_Data));
+
    ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_sdl_engine_func;
 
    ee->driver = "sdl";
@@ -422,14 +422,14 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h)
    evas_output_method_set(ee->evas, rmethod);
    ee->can_async_render = gl ? EINA_FALSE : EINA_TRUE;
 
-   swd->w = SDL_CreateWindow(name, w, h, SDL_WINDOW_RESIZABLE);
-   if (!swd->w)
+   edata->w = SDL_CreateWindow(name, w, h, SDL_WINDOW_RESIZABLE);
+   if (!edata->w)
      {
         ERR("SDL_CreateWindow failed: %s", SDL_GetError());
         goto on_error;
      }
    // XXX error
-   SDL_Surface *surface = SDL_GetWindowSurface(swd->w);
+   SDL_Surface *surface = SDL_GetWindowSurface(edata->w);
 
    Evas_Engine_Info_Software_SDL *einfo = (Evas_Engine_Info_Software_SDL *) evas_engine_info_get(ee->evas);
    if (!einfo)
@@ -448,11 +448,11 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h)
    // XXX move to new function, split out from gl
 
    _ecore_evas_sdl_init(ee, w, h);
-   ee->prop.window = SDL_GetWindowID(swd->w);
+   ee->prop.window = SDL_GetWindowID(edata->w);
 
    ecore_evas_done(ee, EINA_FALSE);
 
-   SDL_SetPointerProperty(SDL_GetWindowProperties(swd->w), "_Ecore_Evas", ee);
+   SDL_SetPointerProperty(SDL_GetWindowProperties(edata->w), "_Ecore_Evas", ee);
 
    _ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
    return ee;

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

Reply via email to