summaryrefslogtreecommitdiff
path: root/src/FvwmIvyRelay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/FvwmIvyRelay.c')
-rwxr-xr-xsrc/FvwmIvyRelay.c152
1 files changed, 152 insertions, 0 deletions
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 <chatty@free.fr>
+ *
+ * $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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#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;
+}