diff --git a/v2/internal/frontend/desktop/linux/frontend.go b/v2/internal/frontend/desktop/linux/frontend.go index 484f8e28e..252fb7c6a 100644 --- a/v2/internal/frontend/desktop/linux/frontend.go +++ b/v2/internal/frontend/desktop/linux/frontend.go @@ -18,7 +18,6 @@ static inline void processDispatchID(gpointer id) { static void gtkDispatch(int id) { g_idle_add((GSourceFunc)processDispatchID, GINT_TO_POINTER(id)); } - */ import "C" import ( @@ -205,6 +204,7 @@ func (f *Frontend) WindowSetRGBA(col *options.RGBA) { if col == nil { return } + f.mainWindow.SetRGBA(col.R, col.G, col.B, col.A) } func (f *Frontend) Quit() { @@ -365,8 +365,11 @@ func (f *Frontend) processRequest(request unsafe.Pointer) { defer C.free(unsafe.Pointer(cContent)) cMimeType := C.CString(mimeType) defer C.free(unsafe.Pointer(cMimeType)) - cLen := C.long(len(content)) - stream := C.g_memory_input_stream_new_from_data(unsafe.Pointer(C.g_strdup(cContent)), cLen, C.g_free) + cLen := C.long(C.strlen(cContent)) + stream := C.g_memory_input_stream_new_from_data( + unsafe.Pointer(C.g_strdup(cContent)), + cLen, + (*[0]byte)(C.g_free)) C.webkit_uri_scheme_request_finish(req, stream, cLen, cMimeType) C.g_object_unref(C.gpointer(stream)) } diff --git a/v2/internal/frontend/desktop/linux/window.go b/v2/internal/frontend/desktop/linux/window.go index 385ff4988..74053f78c 100644 --- a/v2/internal/frontend/desktop/linux/window.go +++ b/v2/internal/frontend/desktop/linux/window.go @@ -380,6 +380,19 @@ GtkFileFilter* newFileFilter() { return result; } +typedef struct RGBAOptions { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + void *webview; +} RGBAOptions; + +void setRGBA(gpointer* data) { + RGBAOptions* options = (RGBAOptions*)data; + GdkRGBA colour = {options->r / 255.0, options->g / 255.0, options->b / 255.0, options->a / 255.0}; + webkit_web_view_set_background_color(WEBKIT_WEB_VIEW(options->webview), &colour); +} */ import "C" import ( @@ -446,6 +459,10 @@ func NewWindow(appoptions *options.App, debug bool) *Window { C.devtoolsEnabled(unsafe.Pointer(webview), C.int(1)) } + // Set background colour + RGBA := appoptions.RGBA + result.SetRGBA(RGBA.R, RGBA.G, RGBA.B, RGBA.A) + // Setup window result.SetKeepAbove(appoptions.AlwaysOnTop) result.SetResizable(!appoptions.DisableResize) @@ -557,17 +574,15 @@ func (w *Window) IsFullScreen() bool { } func (w *Window) SetRGBA(r uint8, g uint8, b uint8, a uint8) { - //C.SetRGBA(w.context, C.int(r), C.int(g), C.int(b), C.int(a)) -} + data := C.RGBAOptions{ + r: C.uchar(r), + g: C.uchar(g), + b: C.uchar(b), + a: C.uchar(a), + webview: w.webview, + } + C.ExecuteOnMainThread(C.setRGBA, C.gpointer(&data)) -//func (w *Window) SetApplicationMenu(inMenu *menu.Menu) { -// //mainMenu := NewNSMenu(w.context, "") -// //processMenu(mainMenu, inMenu) -// //C.SetAsApplicationMenu(w.context, mainMenu.nsmenu) -//} - -func (w *Window) UpdateApplicationMenu() { - //C.UpdateApplicationMenu(w.context) } func (w *Window) Run() {