make_gtk_getlibgtk_public.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: deepak1556 <[email protected]>
  3. Date: Thu, 7 Apr 2022 20:30:16 +0900
  4. Subject: Make gtk::GetLibGtk and gtk::GetLibGdkPixbuf public
  5. Allows embedders to get a handle to the gtk and
  6. gdk_pixbuf libraries already loaded in the process.
  7. diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc
  8. index d196e304a43191b6dc82f25b0b4bf24d242edb3c..85d618efa0574b00fc0cb1e5bde5ed725b2a90ab 100644
  9. --- a/ui/gtk/gtk_compat.cc
  10. +++ b/ui/gtk/gtk_compat.cc
  11. @@ -66,11 +66,6 @@ void* GetLibGio() {
  12. return libgio;
  13. }
  14. -void* GetLibGdkPixbuf() {
  15. - static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0");
  16. - return libgdk_pixbuf;
  17. -}
  18. -
  19. void* GetLibGdk3() {
  20. static void* libgdk3 = DlOpen("libgdk-3.so.0");
  21. return libgdk3;
  22. @@ -86,12 +81,6 @@ void* GetLibGtk4(bool check = true) {
  23. return libgtk4;
  24. }
  25. -void* GetLibGtk() {
  26. - if (GtkCheckVersion(4))
  27. - return GetLibGtk4();
  28. - return GetLibGtk3();
  29. -}
  30. -
  31. bool LoadGtk3() {
  32. if (!GetLibGtk3(false))
  33. return false;
  34. @@ -134,6 +123,17 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) {
  35. } // namespace
  36. +void* GetLibGdkPixbuf() {
  37. + static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0");
  38. + return libgdk_pixbuf;
  39. +}
  40. +
  41. +void* GetLibGtk() {
  42. + if (GtkCheckVersion(4))
  43. + return GetLibGtk4();
  44. + return GetLibGtk3();
  45. +}
  46. +
  47. bool LoadGtk() {
  48. static bool loaded = LoadGtkImpl();
  49. return loaded;
  50. diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h
  51. index 409e385fc952662c9887d9a810bb3c547c5be282..1518b681f98b3bc051aed74713a23c016c7b755e 100644
  52. --- a/ui/gtk/gtk_compat.h
  53. +++ b/ui/gtk/gtk_compat.h
  54. @@ -40,6 +40,12 @@ using SkColor = uint32_t;
  55. namespace gtk {
  56. +// Get handle to the currently loaded gdk_pixbuf library in the process.
  57. +void* GetLibGdkPixbuf();
  58. +
  59. +// Get handle to the currently loaded gtk library in the process.
  60. +void* GetLibGtk();
  61. +
  62. // Loads libgtk and related libraries and returns true on success.
  63. bool LoadGtk();