// Copyright (C) 2026 Arslaan Pathan // This code contains excerpts from wpe-sdl-simple, which is released under MIT. // The original source code is available here: https://github.com/aperezdc/wpe-sdl-simple // See external_licenses/COPYING_wpe-sdl-simple.txt #ifndef SAFFRONWEBKIT_H #define SAFFRONWEBKIT_H #include "wpe/wpe-platform.h" #include #include #include #include #include // The web content area - view that renders to SDL struct _WPEViewSDL3 { WPEView parent; void* userdata; }; // Window/toplevel container that owns all the web views - tab/window manager struct _WPEToplevelSDL3 { WPEToplevel parent; WPEView *view; SDL_Texture *texture; }; // Manages EGL/SDL display - global WPE context struct _WPEDisplaySDL3 { WPEDisplay parent; SDL_InitFlags init_flags; SDL_Window *hidden_window; SDL_GLContext gl_context; EGLDisplay egl_display; PFNEGLDESTROYIMAGEKHRPROC destroyImage; PFNGLEGLIMAGETARGETTEXTURE2DOESPROC imageTargetTexture2DOES; }; typedef struct { GMainContext* main_context; WPEDisplay* display; } SFWKContext; typedef struct { SaffronWidget base; SFWKContext* context; SaffronWindow* window; // just for the GL context char* url; int w, h; struct { WPEToplevel* toplevel; WPEView* wpeview; WebKitWebView* wkwebview; gboolean initialized; } wpe; SDL_Renderer* renderer; } SFWKWebView; SFWKContext* sfwk_init(); // can return NULL! be careful! void sfwk_process_event(SFWKContext* context, SFWKWebView* webview, SDL_Event* event); // the user needs to attach this to a saffron_hook_sdl_all_events SFWKWebView* sfwk_webview_new(SFWKContext* context, const char* url, int w, int h); #endif