Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Mon, 06 Mar 2023 18:31:58 UTC Commit: 599567eb2ed6382c0e17565b3eefe9f819c0e18e https://github.com/geany/geany-osx/commit/599567eb2ed6382c0e17565b3eefe9f819...
Log Message: ----------- Patch various problems in geanylua to make it compile and run as a macOS app bundle
Modified Paths: -------------- geany.modules geany_patches/06-geany-plugins_geanylua_link_against_statically_built_liblua.patch geany_patches/07-geany_plugins_geanylua_make_lib_data_directories_relocatable.patch geany_patches/08-geany_plugins_geanylua_remove_x11_dependency.patch
Modified: geany.modules 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -158,11 +158,14 @@ checkoutdir="geany-plugins-git" revision="master"> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/01-geany_plugins_spellcheck_relocation.patch" strip="1" /> + <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/06-geany-plugins_geanylua_link_against_statically_built_liblua.patch" strip="1" /> + <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/07-geany_plugins_geanylua_make_lib_data_directories_relocatable.patch" strip="1" /> <!-- TODO: remove once merged upstream --> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/02-geany_plugins_vimode_height.patch" strip="1" /> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/03-geany_plugins_vimode_eol_eof_fix.patch" strip="1" /> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/04-geany_plugins_vimode_caret_fix.patch" strip="1" /> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/05-geany_plugins_vimode_numlock_fix.patch" strip="1" /> + <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/08-geany_plugins_geanylua_remove_x11_dependency.patch" strip="1" /> </branch> <dependencies> <dep package="geany-git" />
Modified: geany_patches/06-geany-plugins_geanylua_link_against_statically_built_liblua.patch 54 lines changed, 54 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,54 @@ +From b6b9cd9b0e8e0a70200341486f0fb497b7104f0d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jir=CC=8Ci=CC=81=20Techet?= techet@gmail.com +Date: Mon, 6 Mar 2023 19:09:16 +0100 +Subject: [PATCH] Link geanylua against statically built liblua library + +--- + build/geanylua.m4 | 16 ---------------- + geanylua/Makefile.am | 3 +++ + 2 files changed, 3 insertions(+), 16 deletions(-) + +diff --git a/build/geanylua.m4 b/build/geanylua.m4 +index 1f1eaf67..ec2d1a82 100644 +--- a/build/geanylua.m4 ++++ b/build/geanylua.m4 +@@ -2,22 +2,6 @@ AC_DEFUN([GP_CHECK_GEANYLUA], + [ + GP_ARG_DISABLE([GeanyLua], [auto]) + +- AC_ARG_WITH([lua-pkg], +- AC_HELP_STRING([--with-lua-pkg=ARG], +- [name of Lua pkg-config script [[default=lua5.1]]]), +- [LUA_PKG_NAME=${withval%.pc}], +- [LUA_PKG_NAME=lua5.1 +- +- for L in lua5.1 lua51 lua-5.1 lua; do +- PKG_CHECK_EXISTS([$L], +- [LUA_PKG_NAME=$L]; break,[]) +- done]) +- +- LUA_VERSION=5.1 +- LUA_VERSION_BOUNDARY=5.2 +- GP_CHECK_PLUGIN_DEPS([GeanyLua], [LUA], +- [${LUA_PKG_NAME} >= ${LUA_VERSION} +- ${LUA_PKG_NAME} < ${LUA_VERSION_BOUNDARY}]) + GP_CHECK_PLUGIN_DEPS([GeanyLua], [GMODULE], [gmodule-2.0]) + GP_COMMIT_PLUGIN_STATUS([GeanyLua]) + +diff --git a/geanylua/Makefile.am b/geanylua/Makefile.am +index 6a8b055a..c4c3a9e5 100644 +--- a/geanylua/Makefile.am ++++ b/geanylua/Makefile.am +@@ -5,6 +5,9 @@ plugin = geanylua + + EXTRA_DIST += util + ++LUA_CFLAGS=-I ${PREFIX}/include/ ++LUA_LIBS=${PREFIX}/lib/liblua.a ++ + geanyplugins_LTLIBRARIES = geanylua.la + geanyluadir = $(pkglibdir)/geanylua + geanylua_LTLIBRARIES = libgeanylua.la +-- +2.37.5 +
Modified: geany_patches/07-geany_plugins_geanylua_make_lib_data_directories_relocatable.patch 41 lines changed, 41 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,41 @@ +From 58842897c67d57771eaa9ae8dafd2af276cd056c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jir=CC=8Ci=CC=81=20Techet?= techet@gmail.com +Date: Mon, 6 Mar 2023 19:14:10 +0100 +Subject: [PATCH] Make lib and data directories of geanylua relocatable + +--- + geanylua/geanylua.c | 3 +++ + geanylua/glspi_init.c | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/geanylua/geanylua.c b/geanylua/geanylua.c +index e9a2f1aa..045e83f5 100644 +--- a/geanylua/geanylua.c ++++ b/geanylua/geanylua.c +@@ -136,6 +136,9 @@ static gchar *get_lib_dir(void) + g_free(install_dir); + return result; + #else ++ gchar *prefix_dir = g_build_filename(g_getenv("GTK_PATH"), "lib", NULL); ++ if (g_file_test(prefix_dir, G_FILE_TEST_IS_DIR)) ++ return prefix_dir; + return g_strdup(LIBDIR); + #endif + } +diff --git a/geanylua/glspi_init.c b/geanylua/glspi_init.c +index f48b8678..b5e26b75 100644 +--- a/geanylua/glspi_init.c ++++ b/geanylua/glspi_init.c +@@ -398,6 +398,9 @@ static gchar *get_data_dir(void) + g_free(install_dir); + return result; + #else ++ gchar *prefix_dir = g_build_filename(g_getenv("GTK_PATH"), "share", NULL); ++ if (g_file_test(prefix_dir, G_FILE_TEST_IS_DIR)) ++ return prefix_dir; + return g_strdup(GEANYPLUGINS_DATADIR); + #endif + } +-- +2.37.5 +
Modified: geany_patches/08-geany_plugins_geanylua_remove_x11_dependency.patch 269 lines changed, 269 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,269 @@ +From b061ff8aa1ef04402905339ad655043564d07207 Mon Sep 17 00:00:00 2001 +From: xiota github@mentalfossa.com +Date: Sun, 5 Mar 2023 17:53:10 -0800 +Subject: [PATCH 1/2] GeanyLua: Fix geany.keygrab * Make platform agnostic * + Fix infinite loop * Update documentation + +--- + geanylua/docs/geanylua-ref.html | 57 +++++----- + geanylua/glspi_app.c | 188 +++++++++----------------------- + 2 files changed, 78 insertions(+), 167 deletions(-) + +diff --git a/geanylua/glspi_app.c b/geanylua/glspi_app.c +index 14d2e780..e5a7b48c 100644 +--- a/geanylua/glspi_app.c ++++ b/geanylua/glspi_app.c +@@ -439,170 +439,82 @@ static gint glspi_launch(lua_State* L) + } + + +-static guint My_Shift_L=0; +-static guint My_Shift_R=0; +-static guint My_Control_L=0; +-static guint My_Control_R=0; +-static guint My_Alt_L=0; +-static guint My_Alt_R=0; +- +- +-#ifndef G_OS_WIN32 +- +-#include <X11/Xlib.h> +-#include <X11/keysym.h> +- +- +-#define IsShift ( (My_Shift_L == ev->xkey.keycode) || (My_Shift_R == ev->xkey.keycode) ) +- +-#define IsCtrl ( (My_Control_L == ev->xkey.keycode) || (My_Control_R == ev->xkey.keycode) ) +-#define IsAlt ( (My_Alt_L == ev->xkey.keycode) || (My_Alt_R == ev->xkey.keycode) ) +- +-#define IsCtrlAlt ( IsCtrl || IsAlt ) +- + typedef struct _KeyGrabData { +-gchar *prompt; +-GdkKeymapKey km; ++ gboolean keypress; ++ guint keyval; + } _KeyGrabData; + + +-static GdkFilterReturn keygrab_cb(GdkXEvent *xevent, GdkEvent *event, gpointer data) ++static gboolean keygrab_cb(GtkWidget *widget, GdkEventKey *ev, gpointer data) + { +- XEvent*ev = (XEvent*) xevent; +- GdkKeymapKey *km = (GdkKeymapKey*) data; +- switch (ev->type) { +- case KeyPress:{ +- if (IsShift) { +- km->level=1; +- } else { +- if (!IsCtrlAlt) km->group=1; /* Flag to know we have keydown before keyup */ +- } +- return GDK_FILTER_REMOVE; +- } +- case KeyRelease:{ +- if (IsShift) { +- km->level=0; +- } else { +- if ((km->group==1)&&(!IsCtrlAlt)) { /* OK, we already got our keydown */ +- km->group=2; +- km->level=(ev->xkey.state & ShiftMask)?1:0; +- km->keycode=ev->xkey.keycode; +- } +- } +- return GDK_FILTER_REMOVE; +- } +- default:{} +- } +- return GDK_FILTER_CONTINUE; +-} ++ _KeyGrabData *km = (_KeyGrabData*) data; + +-#define dosleep() g_usleep(1) ++ if (ev->keyval == 0) { ++ return FALSE; ++ } + +-#else +-#include <windows.h> +-#define dosleep() Sleep(1) ++ km->keyval = ev->keyval; ++ km->keypress = TRUE; ++ return TRUE; ++} + +-#define IsShift ( (My_Shift_L == msg->wParam) || (My_Shift_R == msg->wParam) ) + +-#define IsCtrl ( (My_Control_L == msg->wParam) || (My_Control_R == msg->wParam) ) +-#define IsAlt ( (My_Alt_L == msg->wParam) || (My_Alt_R == msg->wParam) ) ++static gint glspi_keygrab(lua_State* L) ++{ ++ GeanyDocument *doc = NULL; ++ const gchar *prompt = NULL; ++ static gulong keygrab_cb_handle = 0; + +-#define IsCtrlAlt ( IsCtrl || IsAlt ) + ++ _KeyGrabData km; ++ km.keypress = FALSE; ++ km.keyval = 0; + +-static GdkFilterReturn keygrab_cb(GdkXEvent *xevent, GdkEvent *event, gpointer data) +-{ +- MSG*msg = (MSG*) xevent; +- GdkKeymapKey *km = (GdkKeymapKey*) data; +- switch (msg->message) { +- case WM_KEYDOWN:{ +- if (IsShift) { +- km->level=1; +- } else { +- if (!IsCtrlAlt) km->group=1; /* Flag to know we have keydown before keyup */ +- } +- return GDK_FILTER_REMOVE; +- } +- case WM_KEYUP:{ +- if (IsShift) { +- km->level=0; +- } else { +- if ((km->group==1)&&(!IsCtrlAlt)) { /* OK, we already got our keydown */ +- km->group=2; +- km->level=HIBYTE(GetKeyState(VK_SHIFT))?1:0; +- km->keycode=msg->wParam; +- } +- } +- return GDK_FILTER_REMOVE; ++ /* get prompt, if exists */ ++ if (lua_gettop(L) > 0) { ++ if (!lua_isstring(L, 1)) { ++ return FAIL_STRING_ARG(1); + } +- default:{} ++ prompt = lua_tostring(L,1); ++ doc = document_get_current(); + } +- return GDK_FILTER_CONTINUE; +-} +- + +-#endif +- +- +-#include <gdk/gdkkeysyms.h> +-static gint init_key(guint keyval){ +- GdkKeymapKey *kmk=NULL; +- GdkKeymap *gdk_key_map=gdk_keymap_get_default(); +- gint n_keys=0; +- gint rv=0; +- if (gdk_keymap_get_entries_for_keyval(gdk_key_map,keyval,&kmk,&n_keys)) { +- rv=kmk[0].keycode; +- g_free(kmk); ++ /* show prompt in tooltip */ ++ if (prompt && doc && doc->is_valid ) { ++ gint fvl = scintilla_send_message(doc->editor->sci, SCI_GETFIRSTVISIBLELINE, 0, 0); ++ gint pos = sci_get_position_from_line(doc->editor->sci, fvl+1); ++ scintilla_send_message(doc->editor->sci, SCI_CALLTIPSHOW, pos+3, (sptr_t) prompt); + } +- return rv; +-} +- +-#define InitKey(code,value) if (!code) { code=init_key(value); } + +-static gint glspi_keygrab(lua_State* L) +-{ +- GeanyDocument*doc=NULL; +- const gchar*prompt=NULL; +- GdkKeymapKey km={0,0,0}; +- GdkKeymap *gdk_key_map; +- km.keycode=0; +- km.group=0; /* Note: we hijack this field to use as a flag for first keydown. */ +- km.level=0; +- InitKey(My_Shift_L, GDK_Shift_L); +- InitKey(My_Shift_R, GDK_Shift_R); +- InitKey(My_Control_L, GDK_Control_L); +- InitKey(My_Control_R, GDK_Control_R); +- InitKey(My_Alt_L, GDK_Alt_L); +- InitKey(My_Alt_R, GDK_Alt_R); +- if (lua_gettop(L)>0) { +- if (!lua_isstring(L,1)) {return FAIL_STRING_ARG(1); } +- prompt=lua_tostring(L,1); +- doc=document_get_current(); ++ /* callback to handle keypress ++ only one keygrab callback can be running at a time, otherwise geanylua will hang ++ */ ++ if (!keygrab_cb_handle) { ++ keygrab_cb_handle = g_signal_connect(main_widgets->window, "key-press-event", G_CALLBACK(keygrab_cb), &km); ++ } else { ++ lua_pushnil(L); ++ return 1; + } + +- if (prompt && doc && doc->is_valid ) { +- gint fvl=scintilla_send_message(doc->editor->sci,SCI_GETFIRSTVISIBLELINE, 0,0); +- gint pos=sci_get_position_from_line(doc->editor->sci, fvl+1); +- scintilla_send_message(doc->editor->sci,SCI_CALLTIPSHOW,pos+3, (sptr_t)prompt); +- } +- gdk_window_add_filter(gtk_widget_get_window(main_widgets->window), keygrab_cb, &km); +- do { ++ /* wait for keypress */ ++ while (!km.keypress) { + while (gtk_events_pending()) { +- if (km.group==2) { break; } ++ if (km.keypress) { ++ break; ++ } + gtk_main_iteration(); + } +- if (km.group==2) { break; } +- dosleep(); +- } while (km.group!=2); ++ } ++ ++ /* clear callback */ ++ g_clear_signal_handler(&keygrab_cb_handle, main_widgets->window); + +- gdk_window_remove_filter(gtk_widget_get_window(main_widgets->window), keygrab_cb, &km); ++ /* clear tooltip */ + if (prompt && doc && doc->is_valid) { +- sci_send_command(doc->editor->sci, SCI_CALLTIPCANCEL); ++ sci_send_command(doc->editor->sci, SCI_CALLTIPCANCEL); + } +- km.group=0; /* reset the hijacked flag before passing to GDK */ +- gdk_key_map = gdk_keymap_get_default(); +- lua_pushstring(L, gdk_keyval_name(gdk_keymap_lookup_key(gdk_key_map, &km))); + ++ lua_pushstring(L, gdk_keyval_name(km.keyval)); + return 1; + } + +-- +2.37.5 + + +From 3c2e16a9d5834b1f153a2557ac819386481a9c2e Mon Sep 17 00:00:00 2001 +From: xiota github@mentalfossa.com +Date: Sun, 5 Mar 2023 18:13:57 -0800 +Subject: [PATCH 2/2] Use g_signal_handler_disconnect instead of + g_clear_signal_handler + +--- + geanylua/glspi_app.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/geanylua/glspi_app.c b/geanylua/glspi_app.c +index e5a7b48c..d21f8ba6 100644 +--- a/geanylua/glspi_app.c ++++ b/geanylua/glspi_app.c +@@ -506,8 +506,9 @@ static gint glspi_keygrab(lua_State* L) + } + } + +- /* clear callback */ +- g_clear_signal_handler(&keygrab_cb_handle, main_widgets->window); ++ /* remove callback and clear handle */ ++ g_signal_handler_disconnect(main_widgets->window, keygrab_cb_handle); ++ keygrab_cb_handle = 0; + + /* clear tooltip */ + if (prompt && doc && doc->is_valid) { +-- +2.37.5 +
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).