blob: 4287b48ebeba836abb69e0835c49d02529a508d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 <saffron.h>
#include <wpe/webkit.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_egl.h>
#include <SDL3/SDL_opengles2.h>
// 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
|