summaryrefslogtreecommitdiff
path: root/gtk3-stackrpms/gtk3-nocsd/gtk3-nocsd-gh-c64505268575e60322de682ea751660eba8d0e71.patch
diff options
context:
space:
mode:
Diffstat (limited to 'gtk3-stackrpms/gtk3-nocsd/gtk3-nocsd-gh-c64505268575e60322de682ea751660eba8d0e71.patch')
-rw-r--r--gtk3-stackrpms/gtk3-nocsd/gtk3-nocsd-gh-c64505268575e60322de682ea751660eba8d0e71.patch95
1 files changed, 95 insertions, 0 deletions
diff --git a/gtk3-stackrpms/gtk3-nocsd/gtk3-nocsd-gh-c64505268575e60322de682ea751660eba8d0e71.patch b/gtk3-stackrpms/gtk3-nocsd/gtk3-nocsd-gh-c64505268575e60322de682ea751660eba8d0e71.patch
new file mode 100644
index 0000000..782699f
--- /dev/null
+++ b/gtk3-stackrpms/gtk3-nocsd/gtk3-nocsd-gh-c64505268575e60322de682ea751660eba8d0e71.patch
@@ -0,0 +1,95 @@
+From c64505268575e60322de682ea751660eba8d0e71 Mon Sep 17 00:00:00 2001
+From: Christian Seiler <christian@iwakd.de>
+Date: Wed, 1 Jun 2016 07:50:38 +0000
+Subject: [PATCH] Only cache gtk version check result if Gtk is loaded
+
+If in a dynamical program (e.g. using python-gi) Glib is loaded before
+Gtk, then the Gtk version check is executed before Gtk is even loaded,
+returning FALSE and caching it. This will not disable CSD if Gtk is
+loaded later. To circumvent this, cache the value only if we know that
+Gtk is loaded.
+
+Fixes github issue #16.
+---
+ ChangeLog | 7 +++++++
+ gtk3-nocsd.c | 27 ++++++++++++++++++++++-----
+ 2 files changed, 29 insertions(+), 5 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 2f98771..53cbd33 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,6 +1,13 @@
+ gtk3-nocsd ChangeLog
+ ====================
+
++New in version 4 (unreleased)
++-----------------------------
++
++ * Support python-gi again by not caching the result of the version
++ check if Gtk is not yet loaded. (python-gi loads Glib before it
++ loads Gtk.)
++
+ New in version 3
+ ----------------
+
+diff --git a/gtk3-nocsd.c b/gtk3-nocsd.c
+index 08844c6..804fbd5 100644
+--- a/gtk3-nocsd.c
++++ b/gtk3-nocsd.c
+@@ -374,7 +374,7 @@ static void static_g_log(const gchar *log_domain, GLogLevelFlags log_level, cons
+ va_end (args);
+ }
+
+-static gboolean is_gtk_version_larger_or_equal(guint major, guint minor, guint micro) {
++static gboolean is_gtk_version_larger_or_equal2(guint major, guint minor, guint micro, int* gtk_loaded) {
+ static gtk_check_version_t orig_func = NULL;
+ if(!orig_func)
+ orig_func = (gtk_check_version_t)find_orig_function(0, GTK_LIBRARY, "gtk_check_version");
+@@ -388,9 +388,19 @@ static gboolean is_gtk_version_larger_or_equal(guint major, guint minor, guint m
+ * will give us a reference to gtk_check_version. But since
+ * that symbol is compatible with gtk3, this doesn't hurt.
+ */
+- if (orig_func)
++ if (orig_func) {
++ if (gtk_loaded)
++ *gtk_loaded = TRUE;
+ return (orig_func(major, minor, micro) == NULL);
+- return FALSE;
++ } else {
++ if (gtk_loaded)
++ *gtk_loaded = FALSE;
++ return FALSE;
++ }
++}
++
++static gboolean is_gtk_version_larger_or_equal(guint major, guint minor, guint micro) {
++ return is_gtk_version_larger_or_equal2(major, minor, micro, NULL);
+ }
+
+ static gboolean are_csd_disabled() {
+@@ -408,15 +418,22 @@ static gboolean is_compatible_gtk_version() {
+ * memory barriers. */
+ static volatile gboolean checked = FALSE;
+ static volatile gboolean compatible = FALSE;
++ int gtk_loaded = FALSE;
+
+ if(G_UNLIKELY(!checked)) {
+- if (!is_gtk_version_larger_or_equal(3, 10, 0)) {
++ if (!is_gtk_version_larger_or_equal2(3, 10, 0, &gtk_loaded)) {
+ /* CSD was introduced there */
+ compatible = FALSE;
+ } else {
+ compatible = TRUE;
+ }
+- checked = TRUE;
++ /* If in a dynamical program (e.g. using python-gi) Glib is loaded before
++ * Gtk, then the Gtk version check is executed before Gtk is even loaded,
++ * returning FALSE and caching it. This will not disable CSD if Gtk is
++ * loaded later. To circumvent this, cache the value only if we know that
++ * Gtk is loaded. */
++ if (gtk_loaded)
++ checked = TRUE;
+ }
+
+ return compatible;
bgstack15