gtkwave: support darwin build

Import two upstream commits to fix compilation under darwin
This commit is contained in:
Jiajie Chen 2022-06-22 17:52:43 +08:00
parent 21caffdf42
commit 0aec6813da
3 changed files with 154 additions and 3 deletions

View File

@ -0,0 +1,40 @@
From 69a6ab80cf0908c2a44430c297932ef3659a1655 Mon Sep 17 00:00:00 2001
From: Jiajie Chen <c@jia.je>
Date: Wed, 22 Jun 2022 16:24:10 +0800
Subject: [PATCH 1/2] Fix detection of quartz in gdk-3.0 target
The GTK+3 built by Nix targets ``broadway quartz`` instead of only `quartz`,
thus the target check is wrong. The script is modified to look up `quartz` in a
loop. The variable name is renamed to `targets` in `gdk-3.0.pc` as well.
---
configure | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 628a80f..9cb88d5 100755
--- a/configure
+++ b/configure
@@ -7361,7 +7361,10 @@ $as_echo "yes" >&6; }
fi
GTK_VER=`$PKG_CONFIG gtk+-3.0 --modversion`
- _gdk_tgt=`$PKG_CONFIG --variable=target gdk-3.0`
+ # gdk-3.0 may have multiple targets e.g. "broadway quartz"
+ _gdk_tgts=`$PKG_CONFIG --variable=targets gdk-3.0`
+ for _gdk_tgt in $_gdk_tgts;
+ do
if test "x$_gdk_tgt" = xquartz; then
pkg_failed=no
@@ -7466,6 +7469,7 @@ fi
COCOA_GTK_LDFLAGS="-framework Cocoa -framework ApplicationServices"
fi
+ done
if test x$with_gconf = xyes; then
--
2.36.1

View File

@ -0,0 +1,101 @@
From 6045177a0d4753bb7a6a6ffc3f1a4a3e96129c6d Mon Sep 17 00:00:00 2001
From: Jiajie Chen <c@jia.je>
Date: Wed, 22 Jun 2022 17:03:29 +0800
Subject: [PATCH 2/2] Check GDK_WINDOWING_X11 macro when using GtkPlug
---
src/main.c | 5 +++++
src/twinwave.c | 12 ++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
index 81bf505..b89f629 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2080,10 +2080,15 @@ if(!GLOBALS->socket_xid)
#ifdef WAVE_USE_XID
else
{
+#ifdef GDK_WINDOWING_X11
GLOBALS->mainwindow = gtk_plug_new(GLOBALS->socket_xid);
gtk_widget_show(GLOBALS->mainwindow);
g_signal_connect(XXX_GTK_OBJECT(GLOBALS->mainwindow), "destroy", /* formerly was "destroy" */G_CALLBACK(plug_destroy),"Plug destroy");
+#else
+ fprintf(stderr, "GTKWAVE | GtkPlug widget is unavailable\n");
+ exit(1);
+#endif
}
#endif
}
diff --git a/src/twinwave.c b/src/twinwave.c
index 590c7f6..d5c60f2 100644
--- a/src/twinwave.c
+++ b/src/twinwave.c
@@ -143,15 +143,19 @@ if(GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default()))
use_embedded = 0;
}
#endif
+#if defined(__GTK_SOCKET_H__) && defined(GDK_WINDOWING_X11)
{
xsocket[0] = gtk_socket_new ();
xsocket[1] = gtk_socket_new ();
gtk_widget_show (xsocket[0]);
gtk_widget_show (xsocket[1]);
}
+#endif
+#if defined(__GTK_SOCKET_H__) && defined(GDK_WINDOWING_X11)
if(!twinwayland)
g_signal_connect(XXX_GTK_OBJECT(xsocket[0]), "plug-removed", G_CALLBACK(plug_removed), NULL);
+#endif
#if GTK_CHECK_VERSION(3,0,0)
main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
@@ -208,7 +212,7 @@ if(hMapFile != NULL)
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
sprintf(buf, "0+%08X", shmid);
-#ifdef MINGW_USE_XID
+#if defined(MINGW_USE_XID) && defined(__GTK_SOCKET_H__) && defined(GDK_WINDOWING_X11)
sprintf(buf2, "%x", gtk_socket_get_id (GTK_SOCKET(xsocket[0])));
#else
sprintf(buf2, "%x", 0);
@@ -279,7 +283,7 @@ if(hMapFile != NULL)
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
sprintf(buf, "1+%08X", shmid);
-#ifdef MINGW_USE_XID
+#if defined(MINGW_USE_XID) && defined(__GTK_SOCKET_H__) && defined(GDK_WINDOWING_X11)
sprintf(buf2, "%x", gtk_socket_get_id (GTK_SOCKET(xsocket[1])));
#else
sprintf(buf2, "%x", 0);
@@ -429,10 +433,12 @@ if(shmid >=0)
sprintf(buf, "0+%08X", shmid);
if(use_embedded)
{
+#if defined(__GTK_SOCKET_H__) && defined(GDK_WINDOWING_X11)
#ifdef MAC_INTEGRATION
sprintf(buf2, "%x", gtk_socket_get_id (GTK_SOCKET(xsocket[0])));
#else
sprintf(buf2, "%lx", (long)gtk_socket_get_id (GTK_SOCKET(xsocket[0])));
+#endif
#endif
}
else
@@ -467,10 +473,12 @@ if(shmid >=0)
sprintf(buf, "1+%08X", shmid);
if(use_embedded)
{
+#if defined(__GTK_SOCKET_H__) && defined(GDK_WINDOWING_X11)
#ifdef MAC_INTEGRATION
sprintf(buf2, "%x", gtk_socket_get_id (GTK_SOCKET(xsocket[1])));
#else
sprintf(buf2, "%lx", (long)gtk_socket_get_id (GTK_SOCKET(xsocket[1])));
+#endif
#endif
}
else
--
2.36.1

View File

@ -3,6 +3,7 @@
, glib
, gperf
, gtk3
, gtk-mac-integration
, judy
, lib
, pkg-config
@ -23,7 +24,16 @@ stdenv.mkDerivation rec {
};
nativeBuildInputs = [ pkg-config wrapGAppsHook ];
buildInputs = [ bzip2 glib gperf gtk3 judy tcl tk xz ];
buildInputs = [ bzip2 glib gperf gtk3 judy tcl tk xz ]
++ lib.optional stdenv.isDarwin gtk-mac-integration;
# fix compilation under Darwin
# remove these patches upon next release
# https://github.com/gtkwave/gtkwave/pull/136
patches = [
./0001-Fix-detection-of-quartz-in-gdk-3.0-target.patch
./0002-Check-GDK_WINDOWING_X11-macro-when-using-GtkPlug.patch
];
configureFlags = [
"--with-tcl=${tcl}/lib"
@ -36,7 +46,7 @@ stdenv.mkDerivation rec {
description = "VCD/Waveform viewer for Unix and Win32";
homepage = "http://gtkwave.sourceforge.net";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ thoughtpolice ];
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ thoughtpolice jiegec ];
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
}