head 1.1; access; symbols; locks; strict; comment @# @; 1.1 date 2003.02.10.19.53.47; author swiergot; state Exp; branches; next ; desc @@ 1.1 log @- Added X_func_dynload.diff patch that makes it possible to dynamically load X11 stuff on demand. - Added patch-4_6_0-exe-first.diff patch that makes it possible to place exe files first just after directories in a panel. - Added src_option_c_PANEL_OPTIONS_bug.diff that fixes a small bug. - Note: this combination of patches hasn't been tested yet. @ text @diff -rup mc-4.6.0/aclocal.m4 mc-4.6.0-mod/aclocal.m4 --- mc-4.6.0/aclocal.m4 2003-02-05 19:08:57.000000000 +0100 +++ mc-4.6.0-mod/aclocal.m4 2003-02-09 19:21:40.000000000 +0100 @@@@ -3881,3 +3881,35 @@@@ AC_DEFUN([AM_LC_MESSAGES], fi ]) +dnl +dnl Check whether the g_module_* family of functions works +dnl on this system. +dnl +AC_DEFUN([AC_G_MODULE_SUPPORTED], [ +av_g_module_supported=no +AC_MSG_CHECKING([if g_module_* family of functions works]) +ac_save_CFLAGS="$CFLAGS" +ac_save_LIBS="$LIBS" +CFLAGS="$CFLAGS $GLIB_CFLAGS" +LIBS="$GLIB_LIBS $LIBS" +AC_TRY_RUN([ +#include + +int main () +{ + int ret = g_module_supported () ? 0 : 1; + return ret; +} +],[ +AC_DEFINE(HAVE_WORKING_GMODULE, 1, + [Define if we have working gmodule library]) +av_g_module_supported=yes +],[ +av_g_module_supported=no +],[ +av_g_module_supported=no +]) +CFLAGS="$ac_save_CFLAGS" +LIBS="$ac_save_LIBS" +AC_MSG_RESULT([$av_g_module_supported]) +]) diff -rup mc-4.6.0/config.h.in mc-4.6.0-mod/config.h.in --- mc-4.6.0/config.h.in 2003-02-05 19:09:02.000000000 +0100 +++ mc-4.6.0-mod/config.h.in 2003-02-09 18:28:18.000000000 +0100 @@@@ -668,4 +668,7 @@@@ /* Define to `int' if does not define. */ #undef umode_t +/* Define if we can use gmodule functionality */ +#undef HAVE_WORKING_GMODULE + #include diff -rup mc-4.6.0/configure.in mc-4.6.0-mod/configure.in --- mc-4.6.0/configure.in 2003-02-05 19:03:56.000000000 +0100 +++ mc-4.6.0-mod/configure.in 2003-02-09 19:25:45.000000000 +0100 @@@@ -38,8 +38,25 @@@@ if test "x$glib_found" = "xno" ; then AC_ARG_VAR([GLIB_CONFIG], [Path to glib-config (version 1.2.x only)]) AM_PATH_GLIB(1.2.6,,[AC_MSG_ERROR([Test for glib failed. GNU Midnight Commander requires glib 1.2.6 or above.])]) + save_GLIB_CFLAGS="$GLIB_CFLAGS" + save_GLIB_LIBS="$GLIB_LIBS" + AM_PATH_GLIB(1.2.6,,[gmodule_found=no],[gmodule]) +else + save_GLIB_CFLAGS="$GLIB_CFLAGS" + save_GLIB_LIBS="$GLIB_LIBS" + PKG_CHECK_MODULES(GLIB, [gmodule-2.0], , [gmodule_found=no]) fi +if test "x$gmodule_found" = "xno" ; then + GLIB_CFLAGS="$save_GLIB_CFLAGS" + GLIB_LIBS="$save_GLIB_LIBS" +else + AC_G_MODULE_SUPPORTED + if test "x$av_g_module_supported" = "xno" ; then + GLIB_CFLAGS="$save_GLIB_CFLAGS" + GLIB_LIBS="$save_GLIB_LIBS" + fi +fi AC_HEADER_MAJOR AC_C_CONST @@@@ -214,7 +231,9 @@@@ if test "x$no_x" = xyes; then textmode_x11_support="no" else CPPFLAGS="$CPPFLAGS $X_CFLAGS" - MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS" + if test "x$av_g_module_supported" = "xno" ; then + MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS" + fi AC_DEFINE(HAVE_TEXTMODE_X11_SUPPORT, 1, [Define to enable getting events from X Window System]) textmode_x11_support="yes" diff -rup mc-4.6.0/src/key.c mc-4.6.0-mod/src/key.c --- mc-4.6.0/src/key.c 2003-01-27 23:37:56.000000000 +0100 +++ mc-4.6.0-mod/src/key.c 2003-02-09 19:17:50.000000000 +0100 @@@@ -41,6 +41,9 @@@@ #include "../vfs/vfs.h" #ifdef HAVE_TEXTMODE_X11_SUPPORT +#ifdef HAVE_WORKING_GMODULE +#include +#endif /* HAVE_WORKING_GMODULE */ #include #endif @@@@ -247,6 +250,30 @@@@ define_sequences (key_define_t *kd) } #ifdef HAVE_TEXTMODE_X11_SUPPORT +#ifdef HAVE_WORKING_GMODULE +#define MODULE_DEFAULT_PREFIX "lib" +#if GLIB_CHECK_VERSION(2,0,0) +# define MODULE_DEFAULT_SUFFIX "." G_MODULE_SUFFIX +#else /* glib < 2.x.x */ +# ifndef __CYGWIN__ +# define MODULE_DEFAULT_SUFFIX ".so" +# else /* __CYGWIN__ */ +# define MODULE_DEFAULT_SUFFIX ".dll" +# endif +#endif + +#define MODX11_DEFAULT_NAME MODULE_DEFAULT_PREFIX "X11" MODULE_DEFAULT_SUFFIX + +typedef Display * (* XOPENDISPLAY) (_Xconst char *); +typedef int (* XCLOSEDISPLAY) (Display *); +typedef Bool (* XQUERYPOINTER) (Display *, Window, Window *, Window*, + int *, int *, int *, int *, unsigned int *); + +static GModule *x11_module; +static XOPENDISPLAY func_XOpenDisplay; +static XCLOSEDISPLAY func_XCloseDisplay; +static XQUERYPOINTER func_XQueryPointer; +#endif /* HAVE_WORKING_GMODULE */ static Display *x11_display; static Window x11_window; #endif /* HAVE_TEXTMODE_X11_SUPPORT */ @@@@ -255,6 +282,9 @@@@ static Window x11_window; calls any define_sequence */ void init_key (void) { +#if defined(HAVE_TEXTMODE_X11_SUPPORT) && defined(HAVE_WORKING_GMODULE) + gchar *x11_module_fname; +#endif /* HAVE_TEXTMODE_X11_SUPPORT && HAVE_WORKING_GMODULE */ char *term = (char *) getenv ("TERM"); /* This has to be the first define_sequence */ @@@@ -290,9 +320,32 @@@@ void init_key (void) #endif /* __QNX__ */ #ifdef HAVE_TEXTMODE_X11_SUPPORT +#ifdef HAVE_WORKING_GMODULE + x11_module_fname = g_module_build_path (NULL, "X11"); + if (x11_module_fname == NULL) + x11_module_fname = g_strdup (MODX11_DEFAULT_NAME); + + if (x11_module_fname != NULL) { + x11_module = g_module_open (x11_module_fname, G_MODULE_BIND_LAZY); + g_free (x11_module_fname); + if (x11_module != NULL) { + if (g_module_symbol (x11_module, "XOpenDisplay", + (gpointer *) &func_XOpenDisplay) && + g_module_symbol (x11_module, "XCloseDisplay", + (gpointer *) &func_XCloseDisplay) && + g_module_symbol (x11_module, "XQueryPointer", + (gpointer *) &func_XQueryPointer)) { + x11_display = (*func_XOpenDisplay) (0); + if (x11_display) + x11_window = DefaultRootWindow (x11_display); + } + } + } +#else x11_display = XOpenDisplay (0); if (x11_display) x11_window = DefaultRootWindow (x11_display); +#endif /* HAVE_WORKING_GMODULE */ #endif /* HAVE_TEXTMODE_X11_SUPPORT */ } @@@@ -1049,8 +1102,13 @@@@ get_modifier (void) int win_x, win_y; unsigned int mask; +#ifdef HAVE_WORKING_GMODULE + (*func_XQueryPointer) (x11_display, x11_window, &root, &child, + &root_x, &root_y, &win_x, &win_y, &mask); +#else XQueryPointer (x11_display, x11_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); +#endif /* HAVE_WORKING_GMODULE */ if (mask & ShiftMask) result |= KEY_M_SHIFT; @@@@ -1105,7 +1163,14 @@@@ void done_key () s_dispose (select_list); #ifdef HAVE_TEXTMODE_X11_SUPPORT +#ifdef HAVE_WORKING_GMODULE + if (x11_display) + (*func_XCloseDisplay) (x11_display); + if (x11_module != NULL) + g_module_close (x11_module); +#else if (x11_display) XCloseDisplay (x11_display); +#endif /* HAVE_WORKING_GMODULE */ #endif /* HAVE_TEXTMODE_X11_SUPPORT */ } @ .