From a1f114ffa61bd1f1db7f8c2735c76b8241a535b2 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 11 Jul 2000 14:46:32 +0000 Subject: The first version --- src/FvwmIvyRelay.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 28 ++++++++++ src/README | 5 ++ 3 files changed, 185 insertions(+) create mode 100755 src/FvwmIvyRelay.c create mode 100644 src/Makefile create mode 100644 src/README diff --git a/src/FvwmIvyRelay.c b/src/FvwmIvyRelay.c new file mode 100755 index 0000000..bc6096f --- /dev/null +++ b/src/FvwmIvyRelay.c @@ -0,0 +1,152 @@ +/* + * FvwmIvyRelay, a relay between Fvwm2 and an Ivy bus + * + * Copyright (C) 2000 + * Stéphane Chatty + * + * Main and only file + * + * Authors: Stéphane Chatty + * + * $Id$ + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U +SA. + * + */ + + +#include +#include +#include +#include +#include + +#include "module.h" + +#include "ivyloop.h" +#include "ivysocket.h" +#include "ivy.h" +#include "timer.h" + + +void +HandleInPipe (Channel channel, HANDLE fd, void *data) +{ + unsigned long *b; + unsigned long header[HEADER_SIZE]; + + if (ReadFvwmPacket(fd, header, &b) > 0) { + char buf [1024]; + switch (header[1]) { + case M_NEW_PAGE: + sprintf (buf, "Page id=%d x=%d y=%d maxx=%d maxy=%d", + b[2], b[0], b[1], b[3], b[4]); + break; + case M_NEW_DESK: + sprintf (buf, "ChangedDesk id=%d", b[0]); + break; + case M_CONFIGURE_WINDOW: + case M_ADD_WINDOW: + sprintf (buf, "%s Window id=%d x=%d y=%d w=%d h=%d desk=%d", + (header[1] == M_ADD_WINDOW) ? "New" : "Configured", + b[0], b[3], b[4], b[5], b[6], b[7]); + break; + case M_RAISE_WINDOW: + sprintf (buf, "Raised Window id=%d", b[0]); + break; + case M_LOWER_WINDOW: + sprintf (buf, "Lower Window id=%d", b[0]); + break; + case M_DESTROY_WINDOW: + sprintf (buf, "Destroyed Window id=%d", b[0]); + break; + case M_FOCUS_CHANGE: + case M_ICONIFY: + case M_DEICONIFY: + case M_WINDOW_NAME: + case M_ICON_NAME: + case M_RES_CLASS: + case M_RES_NAME: + case M_END_WINDOWLIST: + case M_ICON_LOCATION: + case M_MAP: + case M_ERROR: + case M_CONFIG_INFO: + case M_END_CONFIG_INFO: + case M_ICON_FILE: + case M_DEFAULTICON: + case M_STRING: + case M_MINI_ICON: + case M_WINDOWSHADE: + case M_DEWINDOWSHADE: + case M_LOCKONSEND: + case M_SENDCONFIG: + case MAX_MESSAGES: + default: + sprintf (buf, "UNKNOWN"); + } + IvySendMsg ("FVWM::0 %s", buf); + free (b); + } +} + +void +DeadPipe (int flag) +{ + exit (flag); +} + +void +callback (IvyClientPtr app, void *user_data, int argc, char **argv) +{ + SendText (user_data, argv[0], 0); +} + +int +main (int argc, char *argv[]) +{ + int c; + int in, out; + int timer_test = 0; + char busbuf [1024] = ""; + const char* bus = 0; + + if (argc < 6) { + fprintf (stderr, "%s should only be called by fvwm2!\n", argv[0]); + exit (1); + } + in = atoi (argv[2]); + out = atoi (argv[1]); + + while ((c = getopt(argc, argv, "d:b:w:t")) != EOF) + switch (c) { + case 'b': + strcpy (busbuf, optarg); + bus = busbuf; + break; + } + + + IvyInit ("IVY2FVWM", "IVY2FVWM READY", 0, 0, 0, 0); + IvyChannelSetUp (in, 0, 0, HandleInPipe); + IvyStart (bus); + + SetMessageMask (&out, 0x00ffffff); /* a bit brutal and approximate? */ + IvyBindMsg (callback, &out, "FVWM (.*)"); + + IvyMainLoop (0); + return 0; +} diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..cf71f5e --- /dev/null +++ b/src/Makefile @@ -0,0 +1,28 @@ +# +# Ivy - FVWM2 interface +# +# Copyright (C) 2000 +# Stéphane Chatty +# +# Makefile +# +# Authors: Stéphane Chatty +# +# $Id$ +# +# Please refer to file version.h for the +# copyright notice regarding this software +# + + +CC=gcc +CFLAGS = -g +OBJ = FvwmIvyRelay.o + +.c.o: + $(CC) $(CFLAGS) -c $*.c + +all: FvwmIvyRelay + +FvwmIvyRelay: FvwmIvyRelay.o + $(CC) $(CFLAGS) -o FvwmIvyRelay FvwmIvyRelay.o -L. -livy -lfvwm diff --git a/src/README b/src/README new file mode 100644 index 0000000..a0ade9c --- /dev/null +++ b/src/README @@ -0,0 +1,5 @@ +To compile, FvwmIvyRelay needs libfvwm.a and module.h that come +with Fvwm2. Unfortunately, there does not appear to be a fvwm2-devel +package. Consequently, one needs to compile Fvwm2, get the appropriate files, +put them here, and then compile FvwmIvyRelay. + -- cgit v1.1