diff --git a/BUILD.gn b/BUILD.gn index fdd0419cf7587..f6f9c9413163b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -80,7 +80,10 @@ if (is_linux) { } generate_stubs("electron_gtk_stubs") { - sigs = [ "shell/browser/ui/electron_gtk.sigs" ] + sigs = [ + "shell/browser/ui/electron_gdk_pixbuf.sigs", + "shell/browser/ui/electron_gtk.sigs", + ] extra_header = "shell/browser/ui/electron_gtk.fragment" output_name = "electron_gtk_stubs" public_deps = [ "//ui/gtk:gtk_config" ] diff --git a/patches/chromium/make_gtk_getlibgtk_public.patch b/patches/chromium/make_gtk_getlibgtk_public.patch index bf195bbaba7d3..2c5ab1bc37625 100644 --- a/patches/chromium/make_gtk_getlibgtk_public.patch +++ b/patches/chromium/make_gtk_getlibgtk_public.patch @@ -1,16 +1,28 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 7 Apr 2022 20:30:16 +0900 -Subject: Make gtk::GetLibGtk public +Subject: Make gtk::GetLibGtk and gtk::GetLibGdkPixbuf public -Allows embedders to get a handle to the gtk library -already loaded in the process. +Allows embedders to get a handle to the gtk and +gdk_pixbuf libraries already loaded in the process. diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc -index 7104a0d5f4489c687f3cb9e63bc7cbef59d2fa62..f0b9ed834a3f7310da09377f0b2105cf635ffeb7 100644 +index 7104a0d5f4489c687f3cb9e63bc7cbef59d2fa62..7449c0b7bdb0cac7340cb73292e70e6aa0336657 100644 --- a/ui/gtk/gtk_compat.cc +++ b/ui/gtk/gtk_compat.cc -@@ -86,12 +86,6 @@ void* GetLibGtk4(bool check = true) { +@@ -66,11 +66,6 @@ void* GetLibGio() { + return libgio; + } + +-void* GetLibGdkPixbuf() { +- static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); +- return libgdk_pixbuf; +-} +- + void* GetLibGdk3() { + static void* libgdk3 = DlOpen("libgdk-3.so.0"); + return libgdk3; +@@ -86,12 +81,6 @@ void* GetLibGtk4(bool check = true) { return libgtk4; } @@ -23,10 +35,15 @@ index 7104a0d5f4489c687f3cb9e63bc7cbef59d2fa62..f0b9ed834a3f7310da09377f0b2105cf bool LoadGtk3() { if (!GetLibGtk3(false)) return false; -@@ -133,6 +127,12 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { +@@ -133,6 +122,17 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { } // namespace ++void* GetLibGdkPixbuf() { ++ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); ++ return libgdk_pixbuf; ++} ++ +void* GetLibGtk() { + if (GtkCheckVersion(4)) + return GetLibGtk4(); @@ -37,13 +54,16 @@ index 7104a0d5f4489c687f3cb9e63bc7cbef59d2fa62..f0b9ed834a3f7310da09377f0b2105cf static bool loaded = LoadGtkImpl(); return loaded; diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h -index 72981270fe26579211afcaf3c596a412f69f5fac..b5dbfde5b011d57d26960d245e0dc61cac9341e4 100644 +index 72981270fe26579211afcaf3c596a412f69f5fac..2ead29619e9f69f50699970546bf048686ca643f 100644 --- a/ui/gtk/gtk_compat.h +++ b/ui/gtk/gtk_compat.h -@@ -37,6 +37,9 @@ using SkColor = uint32_t; +@@ -37,6 +37,12 @@ using SkColor = uint32_t; namespace gtk { ++// Get handle to the currently loaded gdk_pixbuf library in the process. ++void* GetLibGdkPixbuf(); ++ +// Get handle to the currently loaded gtk library in the process. +void* GetLibGtk(); + diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index ad6509a7a3bcb..a27e5ee3fc0bc 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -375,6 +375,10 @@ void ElectronBrowserMainParts::ToolkitInitialized() { electron::UninitializeElectron_gtk(); } + electron::InitializeElectron_gdk_pixbuf(gtk::GetLibGdkPixbuf()); + CHECK(electron::IsElectron_gdk_pixbufInitialized()) + << "Failed to initialize libgdk_pixbuf-2.0.so.0"; + // Chromium does not respect GTK dark theme setting, but they may change // in future and this code might be no longer needed. Check the Chromium // issue to keep updated: diff --git a/shell/browser/ui/electron_gdk_pixbuf.sigs b/shell/browser/ui/electron_gdk_pixbuf.sigs new file mode 100644 index 0000000000000..c19eb4679265f --- /dev/null +++ b/shell/browser/ui/electron_gdk_pixbuf.sigs @@ -0,0 +1,3 @@ +GdkPixbuf* gdk_pixbuf_new(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height) +GdkPixbuf* gdk_pixbuf_scale_simple(const GdkPixbuf* src, int dest_width, int dest_height, GdkInterpType interp_type) +guchar* gdk_pixbuf_get_pixels(const GdkPixbuf* pixbuf) diff --git a/shell/browser/ui/electron_gtk.fragment b/shell/browser/ui/electron_gtk.fragment index 74a31b23585ac..677c382087029 100644 --- a/shell/browser/ui/electron_gtk.fragment +++ b/shell/browser/ui/electron_gtk.fragment @@ -1 +1,2 @@ -#include \ No newline at end of file +#include +#include diff --git a/shell/browser/ui/electron_gtk.sigs b/shell/browser/ui/electron_gtk.sigs index 451fc74a953d6..41f3890096e09 100644 --- a/shell/browser/ui/electron_gtk.sigs +++ b/shell/browser/ui/electron_gtk.sigs @@ -4,4 +4,4 @@ void gtk_native_dialog_show(GtkNativeDialog* self); void gtk_native_dialog_hide(GtkNativeDialog* self); gint gtk_native_dialog_run(GtkNativeDialog* self); void gtk_native_dialog_destroy(GtkNativeDialog* self); -GType gtk_native_dialog_get_type(void); \ No newline at end of file +GType gtk_native_dialog_get_type(void); diff --git a/shell/browser/ui/gtk_util.cc b/shell/browser/ui/gtk_util.cc index 3d279485cf505..7fc6154bf99f3 100644 --- a/shell/browser/ui/gtk_util.cc +++ b/shell/browser/ui/gtk_util.cc @@ -12,6 +12,7 @@ #include "base/no_destructor.h" #include "base/strings/string_number_conversions.h" +#include "electron/electron_gtk_stubs.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkUnPreMultiply.h" diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index 3efc453fc97bd..6266dad29ef51 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -11,6 +11,7 @@ #include "base/no_destructor.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "electron/electron_gtk_stubs.h" #include "shell/browser/browser.h" #include "shell/browser/native_window_observer.h" #include "shell/browser/native_window_views.h"