From 3fe29c7313e0aec8b20b01ab05b152c360bc3e29 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Tue, 29 Oct 2024 19:22:26 +0000 Subject: [PATCH 1/2] meson: add mpack as a core dependency Needed for upcoming fvwm <-> module comm changes. --- .github/workflows/ccpp.yml | 4 ++-- configure.ac | 23 +++++++++++++++++++++++ libs/Makefile.am | 4 ++++ libs/mcomms.c | 35 +++++++++++++++++++++++++++++++++++ libs/meson.build | 6 ++++++ meson.build | 7 +++++++ meson.options | 6 ++++++ modules/FvwmIdent/FvwmIdent.c | 8 +++++++- 8 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 libs/mcomms.c diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index dcc73133c..44695ef2a 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -37,7 +37,7 @@ jobs: export CC_LD=lld fi export CC=${{ matrix.compiler }} - ./autogen.sh && ./configure --enable-mandoc --enable-golang && make -j + ./autogen.sh && ./configure --enable-mandoc --enable-golang --enable-mpack && make -j fi if [ "${{ matrix.build-system }}" = "meson" ]; then if [ "${{ matrix.compiler }}" = "gcc" ]; then @@ -46,7 +46,7 @@ jobs: export CC_LD=lld fi export CC=${{ matrix.compiler }} - meson setup builddir -Dhtmldoc=true -Dmandoc=true && ninja -C builddir + meson setup builddir -Dhtmldoc=true -Dmandoc=true -Dmcomms=true && ninja -C builddir fi notification: diff --git a/configure.ac b/configure.ac index d07760925..c2fc950dc 100644 --- a/configure.ac +++ b/configure.ac @@ -94,6 +94,21 @@ fi AM_CONDITIONAL([FVWM_BUILD_GOLANG], [test x"$with_golang" = xyes]) AC_SUBST(GO) +# mpack +problem_mpack="" +AH_TEMPLATE([HAVE_MPACK], [Define MPACK]) +AC_ARG_ENABLE(mpack, + AS_HELP_STRING([--enable-mpack],[enable mpack module comms]), + [ if test x"$enableval" = "xyes"; then + with_mpack="yes" + else + with_mpack="no" + problem_mpack=": Explicitly disabled" + fi ], + [ with_mpack="no" ] +) + + #!!! PERL="" REQUIRED_PERL_VERSION=5.004 @@ -745,6 +760,13 @@ fi AC_SUBST(png_LIBS) AC_SUBST(png_CFLAGS) +yes_to_mpack="no" +if test "$with_mpack" = "yes"; then + PKG_CHECK_MODULES([mpack], [mpack], [yes_to_mpack="yes"], []) +fi + +AM_CONDITIONAL([HAVE_MPACK], [test x"$yes_to_mpack" = xyes]) + # ********* rsvg rsvg_min_version=2.13.92 AH_TEMPLATE([HAVE_RSVG], [Define if librsvg library is used.]) @@ -1508,6 +1530,7 @@ Fvwm3 Configuration: With XPM image support? $with_xpm$problem_xpm With Xrender image support? $with_xrender$problem_xrender With Golang support? $with_golang$problem_golang + With mpack support? $with_mpack$problem_mpack Build man pages? $with_mandoc$problem_mandoc Build html man pages? $with_htmldoc$problem_htmldoc diff --git a/libs/Makefile.am b/libs/Makefile.am index 848fa3fdd..eb8fd64e1 100644 --- a/libs/Makefile.am +++ b/libs/Makefile.am @@ -38,6 +38,10 @@ else libfvwm3_a_SOURCES += strlcpy.h strlcat.h strlcpy.c strlcat.c endif +if HAVE_MPACK +libfvwm3_a_SOURCES += mcomms.c mcomms.h +endif + libfvwm3_a_LIBADD = @LIBOBJS@ AM_CPPFLAGS = -I$(top_srcdir) $(xpm_CFLAGS) $(Xft_CFLAGS) $(X_CFLAGS) \ diff --git a/libs/mcomms.c b/libs/mcomms.c new file mode 100644 index 000000000..4c3b39aa7 --- /dev/null +++ b/libs/mcomms.c @@ -0,0 +1,35 @@ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see: + */ + +#include + +#include "config.h" +#include "log.h" +#include "mcomms.h" + +const char *m_register[] = { + "new_window" +}; + +bool +m_register_interest(int *fd, const char *type, ...) +{ + va_list ap; + + va_start(ap, type); + vfprintf(stderr, type, ap); + va_end(ap); + + return true; +} diff --git a/libs/meson.build b/libs/meson.build index 13d8a4dde..f5d2b7f78 100644 --- a/libs/meson.build +++ b/libs/meson.build @@ -63,6 +63,12 @@ string_sources = files( 'strlcpy.c', ) +if (mpack.found()) + libfvwm3_sources += files( + 'mcomms.c' + ) +endif + # We don't build the string sources on macOS # We probably could check for target_system, but nobody is cross-compiling _to_ macOS if not (host_machine.system() == 'darwin') diff --git a/meson.build b/meson.build index 3c91ec906..a134e91a6 100644 --- a/meson.build +++ b/meson.build @@ -197,6 +197,13 @@ foreach rd : all_req_deps all_found_deps += this_dep endforeach +mpack = dependency('mpack', required: get_option('mcomms')) +if mpack.found() + all_found_deps += mpack + summary_depvals += {'mpack': mpack} + conf.set10('HAVE_MPACK', true) +endif + xext = dependency('xext', required: true) all_found_deps += xext summary_depvals += {'xext': xext} diff --git a/meson.options b/meson.options index 17823077b..717a4c09e 100644 --- a/meson.options +++ b/meson.options @@ -57,6 +57,12 @@ option( value: false, description: 'Enable generation of man pages', ) +option( + 'mcomms', + type: 'boolean', + value: false, + description: 'Enable new module comms', +) option('nls', type: 'feature', value: 'auto', description: 'Enable NLS') option('png', type: 'feature', value: 'auto', description: 'Enable png support') option( diff --git a/modules/FvwmIdent/FvwmIdent.c b/modules/FvwmIdent/FvwmIdent.c index f60ef65da..1a9c8197b 100644 --- a/modules/FvwmIdent/FvwmIdent.c +++ b/modules/FvwmIdent/FvwmIdent.c @@ -55,6 +55,10 @@ #include "libs/XError.h" #include "libs/log.h" +#ifdef HAVE_MPACK +#include "libs/mcomms.h" +#endif + #include "FvwmIdent.h" static RETSIGTYPE TerminateHandler(int); @@ -213,7 +217,9 @@ int main(int argc, char **argv) InitGetConfigLine(fd, mname); GetConfigLine(fd,&tline); - +#ifdef HAVE_MPACK + m_register_interest(fd, "new_window", "this", "that"); +#endif while (tline != (char *)0) { if (strlen(tline) <= 1) From d0edd84cd587ee7b41c338d53f36f7f60757d2db Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Thu, 31 Oct 2024 22:54:07 +0000 Subject: [PATCH 2/2] 1 --- fvwm/module_list.c | 1 + libs/mcomms.c | 46 ++++++++++++++++++++++++++++------- libs/mcomms.h | 44 +++++++++++++++++++++++++++++++++ modules/FvwmIdent/FvwmIdent.c | 3 ++- 4 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 libs/mcomms.h diff --git a/fvwm/module_list.c b/fvwm/module_list.c index 6b0d38092..2c3dc9efd 100644 --- a/fvwm/module_list.c +++ b/fvwm/module_list.c @@ -1120,6 +1120,7 @@ void CMD_ModuleSynchronous(F_CMD_ARGS) token = PeekToken(next, &next); if (token) { + free(expect); expect = fxstrdup(token); } action = next; diff --git a/libs/mcomms.c b/libs/mcomms.c index 4c3b39aa7..0f4b0e95e 100644 --- a/libs/mcomms.c +++ b/libs/mcomms.c @@ -13,23 +13,51 @@ */ #include +#include #include "config.h" #include "log.h" +#include "safemalloc.h" #include "mcomms.h" -const char *m_register[] = { - "new_window" +uint64_t m_find_bit(const char *); + +static const struct { + uint64_t bits; + const char *name; +} all_mcomm_types[] = { + { MCOMMS_NEW_WINDOW, "new-window" }, + { 0, NULL }, }; -bool -m_register_interest(int *fd, const char *type, ...) +uint64_t +m_find_bit(const char *name) +{ + int i = 0; + + for (i = 0; all_mcomm_types[i].name != NULL; i++) { + if (strcmp(all_mcomm_types[i].name, name) == 0) { + return all_mcomm_types[i].bits; + } + } + fprintf(stderr, "%s: Invalid module interest: %s\n", __func__, name); + return 0; +} + +uint64_t +m_register_interest(int *fd, const char *me) { - va_list ap; + char *me1; + const char *component; + uint64_t m_bits = 0; + + if (me == NULL) + return 0; + me1 = fxstrdup(me); - va_start(ap, type); - vfprintf(stderr, type, ap); - va_end(ap); + while ((component = strsep(&me1, " ")) != NULL) + m_bits |= m_find_bit(component); - return true; + free(me1); + return m_bits; } diff --git a/libs/mcomms.h b/libs/mcomms.h new file mode 100644 index 000000000..65466f4a8 --- /dev/null +++ b/libs/mcomms.h @@ -0,0 +1,44 @@ +#ifndef FVWMLIB_MCOMMS_H +#define FVWMLIB_MCOMMS_H + +#include + +#define MCOMMS_NEW_WINDOW 0x0000000000000001ULL +#define MCOMMS_ALL 0xffffffffffffffffULL + +struct m_add_window { + char *window; + int title_height; + int border_width; + + struct { + int window; + int x; + int y; + int width; + int height; + } frame; + + struct { + int base_width; + int base_height; + int inc_width; + int inc_height; + int orig_inc_width; + int orig_inc_height; + int min_width; + int min_height; + int max_width; + int max_height; + } hints; + + struct { + int layer; + int desktop; + int window_type; + } ewmh; +}; + +uint64_t m_register_interest(int *, const char *); + +#endif diff --git a/modules/FvwmIdent/FvwmIdent.c b/modules/FvwmIdent/FvwmIdent.c index 1a9c8197b..d351e96af 100644 --- a/modules/FvwmIdent/FvwmIdent.c +++ b/modules/FvwmIdent/FvwmIdent.c @@ -218,7 +218,8 @@ int main(int argc, char **argv) InitGetConfigLine(fd, mname); GetConfigLine(fd,&tline); #ifdef HAVE_MPACK - m_register_interest(fd, "new_window", "this", "that"); + fprintf(stderr, "GOT: %lu\n", + m_register_interest(fd, "new-window this that the-other")); #endif while (tline != (char *)0) {