From 95c3a91a092c0bf51ec4e70c46b92b70997be952 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Sat, 2 May 2026 18:29:13 +1200 Subject: shoot, i forgot to commit for the entirety of kiwihacks T_T --- include/saffronwebkit.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 include/saffronwebkit.h (limited to 'include') diff --git a/include/saffronwebkit.h b/include/saffronwebkit.h new file mode 100644 index 0000000..4287b48 --- /dev/null +++ b/include/saffronwebkit.h @@ -0,0 +1,62 @@ +// 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; + WPEToplevel* toplevel; + WPEView* wpeview; + WebKitWebView* wkwebview; + 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 -- cgit v1.2.3