Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Dec 30, 2024
1 parent 3fe29c7 commit d0edd84
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 10 deletions.
1 change: 1 addition & 0 deletions fvwm/module_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ void CMD_ModuleSynchronous(F_CMD_ARGS)
token = PeekToken(next, &next);
if (token)
{
free(expect);
expect = fxstrdup(token);
}
action = next;
Expand Down
46 changes: 37 additions & 9 deletions libs/mcomms.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,51 @@
*/

#include <stdio.h>
#include <stdint.h>

#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;
}
44 changes: 44 additions & 0 deletions libs/mcomms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef FVWMLIB_MCOMMS_H
#define FVWMLIB_MCOMMS_H

#include <stdbool.h>

#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
3 changes: 2 additions & 1 deletion modules/FvwmIdent/FvwmIdent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit d0edd84

Please sign in to comment.