diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01ddd90 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +aclocal.m4 +autom4te.cache +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +install-sh +missing +mkinstalldirs +stamp-h +stamp-h.in +depcomp +stamp-h1 + +Makefile +Makefile.in +.deps + +FvwmKb +*.o diff --git a/TODO b/TODO index e1345e3..d930f10 100644 --- a/TODO +++ b/TODO @@ -3,12 +3,10 @@ This file is a part of FvwmKb. Copyright (C) 1999 Alexander Vorobiev $Id: TODO,v 1.1.1.1 1999/04/16 14:55:26 sparrow Exp $ -* Add an ability to accept messages from Fvwm to change locked group - - so it will be possible to change group from menu or clicking - titlebar button - * Make man page * Add more pixmaps * Add support for other window managers + +* Add suport for autoconf-ing fvwm modules dir diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..82808f9 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh +WANT_AUTOMAKE=1.8 +export WANT_AUTOMAKE +aclocal \ +&& autoheader \ +&& automake -a \ +&& autoheader \ +&& autoconf \ +&& ./configure "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..1149343 --- /dev/null +++ b/configure.ac @@ -0,0 +1,82 @@ +dnl This file is a part of FvwmKb. +dnl Copyright (C) 1999 Alexander Vorobiev +dnl $Id: configure.in,v 1.4 1999/10/26 20:28:03 sparrow Exp $ + +AC_INIT([FvwmKb],[0.3.2-git],[hacker@klever.net]) +AC_CONFIG_SRCDIR([src/FvwmKb.cpp]) +AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE([dist-bzip2]) + +AC_MSG_CHECKING([for fvwm module install directory]) +AC_ARG_WITH(moduledir, + [ --with-moduledir=DIR directory in which fvwm modules are installed ], + [ case "$withval" in + no) + AC_MSG_ERROR(Can not disable moduledir.) + ;; + yes) + ;; + *) + val="$withval" + ;; + esac ]) + +FVWM_MODULEDIR="$val" +AC_MSG_RESULT($FVWM_MODULEDIR) +AC_SUBST(FVWM_MODULEDIR) + +dnl Checks for programs. +AC_LANG_CPLUSPLUS +AC_PROG_CXX +AC_PROG_CXXCPP +AC_PROG_INSTALL + +dnl Checks for libraries. +AC_CHECK_LIB(stdc++, main) + +AC_PATH_X +AC_PATH_XTRA +CFLAGS="$X_CFLAGS" +LDFLAGS="$X_LDFLAGS $X_LIBS" + +AC_CHECK_LIB(X11, XkbOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS") +x_cflags="$X_CFLAGS" +x_ldflags="$X_LDFLAGS $X_LIBS" + +if test -z "$x_includes"; then + x_includes="/usr/include" +fi + +AC_SUBST(x_cflags) +AC_SUBST(x_includes) +AC_SUBST(x_ldflags) +AC_SUBST(x_libs) + +dnl Checks for header files. +AC_CHECK_HEADERS(errno.h stdio.h fcntl.h unistd.h limits.h X11/XKBlib.h) +AC_CHECK_HEADERS(sys/time.h signal.h) +AC_CHECK_HEADERS(hash_map) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +AC_MSG_CHECKING([for debug flag]) +dodebug=false +AC_ARG_ENABLE([debug], + AC_HELP_STRING([--enable-debug],[enable debugging code]), + [ test "${enableval}" != "no" && dodebug=true ] +) +AC_MSG_RESULT([$dodebug]) +AH_TEMPLATE(DEBUG,[ Turning on debugging code ]) +if ${dodebug} ; then + AC_DEFINE_UNQUOTED([DEBUG],[1]) +fi + +AC_CONFIG_FILES([ + Makefile + src/Makefile + doc/Makefile + pixmaps/Makefile +]) +AC_OUTPUT diff --git a/src/FvwmKb.cpp b/src/FvwmKb.cpp index 9e7baa9..73b2382 100644 --- a/src/FvwmKb.cpp +++ b/src/FvwmKb.cpp @@ -21,7 +21,9 @@ // Boston, MA 02111-1307 USA -#include +#include +#include +using namespace __gnu_cxx; #include "FvwmKb.h" #include "messages.h" #include "ex.h" @@ -49,7 +51,7 @@ int main(int argc, char **argv) try { // set up connection - Fvwm fvwm(argv[1], argv[2], M_FOCUS_CHANGE | M_DESTROY_WINDOW); + Fvwm fvwm(argv[1], argv[2], M_FOCUS_CHANGE | M_DESTROY_WINDOW | M_STRING); #ifdef DEBUG fprintf(stderr,"fvwm initialized ok\n", argv[1], argv[2]); @@ -191,9 +193,27 @@ int main(int argc, char **argv) } }; break; + case evString: + if(ev.strString.find("ToggleGroup")) { + // FIXME: At the very beginning ev.windows means nothing + if(ev.window != fvwm_no_app_window) { + XkbGetState(dpy, XkbUseCoreKbd, &xkbstate); + XkbLockGroup(dpy,XkbUseCoreKbd, xkbstate.locked_group^1); + XkbGetState(dpy, XkbUseCoreKbd, &xkbstate); + WinRecordPtr = WinGroup.find(ev.window); + if(WinRecordPtr != WinGroup.end()) { + WinGroup[ev.window] = xkbstate.locked_group; + fvwm.ChangeXkbDecor(xkbstate.locked_group); + last_group = xkbstate.locked_group; + } + } + }else{ + fprintf(stderr, "unknown string received from fvwm: %s\n", ev.strString.c_str()); + } + break; default: - fprintf(stderr, "unknown event for window: %ul\n", ev.window); + //fprintf(stderr, "unknown event for window: %ul\n", ev.window); break; }; diff --git a/src/wm.cpp b/src/wm.cpp index d6973d1..d2f8de5 100644 --- a/src/wm.cpp +++ b/src/wm.cpp @@ -22,6 +22,7 @@ #include +#include #include "FvwmKb.h" #include "messages.h" #include "ex.h" @@ -54,7 +55,7 @@ Fvwm::Fvwm(char *sfd, char *rfd, unsigned long mask) #ifdef DEBUG fprintf(stderr,"message mask sent ok\n"); #endif // DEBUG - + SendPacket("NOP FINISHED STARTUP",0); } Bool Fvwm::PeekEvent(void) @@ -93,7 +94,7 @@ void Fvwm::ReadEvent(wmEvent *ev) readexactE(recfd, header, FVWM_HEADER_SIZE * sizeof(unsigned long)); #ifdef DEBUG - fprintf(stderr,"header: [0] = %ul; [1] = %ul; [2] = %ul\n", + fprintf(stderr,"header: [0] = 0x%08lX ; [1] = %lu; [2] = %lu\n", header[0], header[1], header[2]); #endif // DEBUG @@ -112,7 +113,19 @@ void Fvwm::ReadEvent(wmEvent *ev) ev->window = Window(body[0]); }; break; - default: + case M_STRING: { + static unsigned long body[sizeof(unsigned long)*256]; // Max body size + if(header[1]>=256) + // FIXME: Wrong exception to throw + throw FvwmUnknownMessageTypeEx(header[0]); + else{ + memset(body,0,sizeof(body)); + readexactE(recfd,body,(header[1]-4)*sizeof(unsigned long)); + ev->type = evString; + ev->strString = (const char*)body; + } + }; + break; throw FvwmUnknownMessageTypeEx(header[0]); }; } @@ -135,7 +148,7 @@ void Fvwm::ChangeXkbDecor(XkbGroup group) // source - http://www.fvwm.org/mod_m2f_communication.html // It might be better to rewrite this function accumulating an entire packet // in some intermediate buffer (as real SendText does). -void Fvwm::SendPacket(char *message, Window window) +void Fvwm::SendPacket(char *message, unsigned long window) { if (message == NULL) return; @@ -148,16 +161,16 @@ void Fvwm::SendPacket(char *message, Window window) writeexactE(sendfd, &window, sizeof(window)); #ifdef DEBUG - fprintf(stderr,"window id %ul sent\n", window); + fprintf(stderr,"window id %lu sent\n", window); #endif // DEBUG - size_t len=strlen(message); // calc the length of the message + unsigned long len=strlen(message); // calc the length of the message writeexactE(sendfd, &len, sizeof(len)); // send the message length writeexactE(sendfd, message, len); // send the message itself // send a 1, indicating that this module will keep going // a 0 would mean that this module is done - int flag = 1; + unsigned long flag = 1; writeexactE(sendfd, &flag, sizeof(flag)); } diff --git a/src/wm.h b/src/wm.h index c16ea08..4b584d7 100644 --- a/src/wm.h +++ b/src/wm.h @@ -32,12 +32,15 @@ // generic way though as we have to pass wm-specific arguments. // generic interface to wm events -enum wmEventType { evFocusWindow, // window is focused - evDestroyWindow }; // window is destroyed +enum wmEventType { evUnknown, + evFocusWindow, // window is focused + evDestroyWindow, + evString }; // window is destroyed struct wmEvent { wmEventType type; Window window; + std::string strString; }; @@ -59,6 +62,7 @@ public: // input focus #define M_DESTROY_WINDOW ((unsigned long)(1<<7)) // The window has just // been destroyed +#define M_STRING ((unsigned long)(1<<22)) // String has been sent to module #define FVWM_HEADER_SIZE 3 // fvwm message header size // without starting flag