From 7c338b16b6778fba40d52a1a9d07e01d99b3cb9a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 2 Feb 2006 14:40:59 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 1 + config.h.in | 3 ++ configure | 128 ++++++++++++++++++++++++++++++++++++++++++---- configure.ac | 32 ++++++++---- src/rxvttoolkit.C | 60 +++++++++++++++++----- src/rxvttoolkit.h | 2 +- 6 files changed, 193 insertions(+), 33 deletions(-) diff --git a/Changes b/Changes index 95f48f0a..ebcbc28b 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ TODO: xim "how to" faq entry - +option now really sets the option to default, instead of using the resource value. - options that require an argument now really _require_ an argument. + - force refresh of XA_RESOURCE_STRING on virtual reconnect. - return exit status 2 in urxvtc when urxvtd couldn't be contacted. - the linux yield hack is back, now using usleep, and enabled only on __linux__. diff --git a/config.h.in b/config.h.in index 32d7316d..674f1759 100644 --- a/config.h.in +++ b/config.h.in @@ -402,6 +402,9 @@ /* Define if your XIMCallback specifies XIC as first type. */ #undef XIMCB_PROTO_BROKEN +/* Define ONLY iff Xlib.h supports it */ +#undef XLIB_ILLEGAL_ACCESS + /* Define if you want to have sexy-looking background pixmaps. Needs libXpm */ #undef XPM_BACKGROUND diff --git a/configure b/configure index bdb40761..f5666bb3 100755 --- a/configure +++ b/configure @@ -3291,12 +3291,6 @@ fi LINKER=$LINKER -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - if test -z "$orig_CXXFLAGS"; then if test x$GCC = xyes && test "x$GXX" = xyes; then CXXFLAGS="-g -O3 -fno-threadsafe-statics -fno-enforce-eh-specs" @@ -7340,6 +7334,72 @@ fi LIBS=$ac_save_LIBS CFLAGS=$ac_save_CFLAGS +echo "$as_me:$LINENO: checking for XLIB_ILLEGAL_ACCESS" >&5 +echo $ECHO_N "checking for XLIB_ILLEGAL_ACCESS... $ECHO_C" >&6 +if test "${rxvt_xlib_illegal_access+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#define XLIB_ILLEGAL_ACCESS +#include + +int +main () +{ + + Display *dpy; + dpy->xdefaults = (char *)0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + rxvt_xlib_illegal_access=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +rxvt_xlib_illegal_access=no + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $rxvt_xlib_illegal_access" >&5 +echo "${ECHO_T}$rxvt_xlib_illegal_access" >&6 +if test x$rxvt_xlib_illegal_access = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define XLIB_ILLEGAL_ACCESS 1 +_ACEOF + +fi echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 @@ -13214,16 +13274,62 @@ fi + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ + + PerlInterpreter *perl = perl_alloc (); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + rxvt_perl_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +rxvt_perl_link=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test x$support_perl = xyes; then support_frills=yes fi -CFLAGS=${CFLAGS--O} -LDFLAGS=${LDFLAGS--O} - -CPPFLAGS="$CPPFLAGS" - diff --git a/configure.ac b/configure.ac index 39b517c3..52c966d0 100644 --- a/configure.ac +++ b/configure.ac @@ -47,7 +47,7 @@ if test x$GCC = xyes && test x$GXX = xyes; then LIBS="$LIBS -lsupc++" LINKER="$CC" AC_LINK_IFELSE( - [AC_LANG_PROGRAM([struct test { }; void f() try { throw new test; } catch (...) { throw; }])], + [AC_LANG_PROGRAM([struct test { }; void f() try { throw new test; } catch (...) { throw; }],[])], [AC_MSG_RESULT(ok)], [ AC_MSG_RESULT([no, making everything bigger and slower]) @@ -59,14 +59,13 @@ if test x$GCC = xyes && test x$GXX = xyes; then fi AC_SUBST(LINKER,[$LINKER]) -AC_LANG(C++) dnl# -------------------------------------------------------------------------- dnl# Supply default CXXFLAGS, if not specified by `CXXFLAGS=flags ./configure' dnl# if test -z "$orig_CXXFLAGS"; then if test x$GCC = xyes && test "x$GXX" = xyes; then CXXFLAGS="-g -O3 -fno-threadsafe-statics -fno-enforce-eh-specs" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [], [CXXFLAGS="-g -O3"]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [], [CXXFLAGS="-g -O3"]) else CXXFLAGS="-O" fi @@ -534,6 +533,20 @@ fi LIBS=$ac_save_LIBS CFLAGS=$ac_save_CFLAGS +AC_CACHE_CHECK([for XLIB_ILLEGAL_ACCESS], rxvt_xlib_illegal_access, +[AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +#define XLIB_ILLEGAL_ACCESS +#include + ],[ + Display *dpy; + dpy->xdefaults = (char *)0; + ])], + [rxvt_xlib_illegal_access=yes],[rxvt_xlib_illegal_access=no] +)]) +if test x$rxvt_xlib_illegal_access = xyes; then + AC_DEFINE(XLIB_ILLEGAL_ACCESS, 1, Define ONLY iff Xlib.h supports it) +fi AC_C_CONST AC_C_INLINE @@ -879,16 +892,17 @@ AC_SUBST(PERL) AC_SUBST(IF_PERL) AC_SUBST(PERL_O) + AC_TRY_LINK([ +#include +#include +#include +],[ + PerlInterpreter *perl = perl_alloc (); +],[rxvt_perl_link=yes],[rxvt_perl_link=no]) if test x$support_perl = xyes; then support_frills=yes fi -dnl> AC_CHECK_FUNCS(gettimeofday putenv select socket) - -CFLAGS=${CFLAGS--O} -LDFLAGS=${LDFLAGS--O} - -CPPFLAGS="$CPPFLAGS" AC_SUBST(DEBUG) AC_SUBST(DINCLUDE) AC_SUBST(CFLAGS) diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C index 06ad759d..8e5ce55a 100644 --- a/src/rxvttoolkit.C +++ b/src/rxvttoolkit.C @@ -179,7 +179,7 @@ rxvt_xim::ref_init () { display = GET_R->display; //HACK: TODO - xim = XOpenIM (display->display, NULL, NULL, NULL); + xim = XOpenIM (display->display, 0, 0, 0); if (!xim) return false; @@ -188,7 +188,7 @@ rxvt_xim::ref_init () ximcallback.client_data = (XPointer)this; ximcallback.callback = im_destroy_cb; - XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL); + XSetIMValues (xim, XNDestroyCallback, &ximcallback, 0); return true; } @@ -250,7 +250,7 @@ rxvt_display::rxvt_display (const char *id) } XrmDatabase -rxvt_display::get_resources () +rxvt_display::get_resources (bool refresh) { char *homedir = (char *)getenv ("HOME"); char fname[1024]; @@ -259,9 +259,7 @@ rxvt_display::get_resources () * get resources using the X library function */ char *displayResource, *xe; - XrmDatabase database, rdb1; - - database = NULL; + XrmDatabase rdb1, database = 0; // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20 @@ -281,9 +279,42 @@ rxvt_display::get_resources () // 4. User's defaults file. /* Get any Xserver defaults */ - displayResource = XResourceManagerString (display); + if (refresh) + { + // fucking xlib keeps a copy of the rm string + Atom actual_type; + int actual_format; + unsigned long nitems, nremaining; + char *val = 0; + +#if XLIB_ILLEGAL_ACCESS + if (display->xdefaults) + XFree (display->xdefaults); +#endif - if (displayResource != NULL) + if (XGetWindowProperty (display, root, XA_RESOURCE_MANAGER, + 0L, 100000000L, False, + XA_STRING, &actual_type, &actual_format, + &nitems, &nremaining, + (unsigned char **)&val) == Success + && actual_type == XA_STRING + && actual_format == 8) + displayResource = val; + else + { + displayResource = 0; + if (val) + XFree(val); + } + +#if XLIB_ILLEGAL_ACCESS + display->xdefaults = displayResource; +#endif + } + else + displayResource = XResourceManagerString (display); + + if (displayResource) { if ((rdb1 = XrmGetStringDatabase (displayResource))) XrmMergeDatabases (rdb1, &database); @@ -296,10 +327,15 @@ rxvt_display::get_resources () XrmMergeDatabases (rdb1, &database); } +#if !XLIB_ILLEGAL_ACCESS + if (refresh && displayResource) + XFree (displayResource); +#endif + /* Get screen specific resources */ displayResource = XScreenResourceString (ScreenOfDisplay (display, screen)); - if (displayResource != NULL) + if (displayResource) { if ((rdb1 = XrmGetStringDatabase (displayResource))) /* Merge with screen-independent resources */ @@ -350,13 +386,13 @@ bool rxvt_display::ref_init () if (!display) return false; - screen = DefaultScreen (display); + screen = DefaultScreen (display); root = DefaultRootWindow (display); assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); XInternAtoms (display, (char **)xa_names, NUM_XA, False, xa); - XrmSetDatabase (display, get_resources ()); + XrmSetDatabase (display, get_resources (false)); #ifdef POINTER_BLANK XColor blackcolour; @@ -399,7 +435,7 @@ rxvt_display::ref_next () // TODO: somehow check wether the database files/resources changed // before affording re-loading/parsing XrmDestroyDatabase (XrmGetDatabase (display)); - XrmSetDatabase (display, get_resources ()); + XrmSetDatabase (display, get_resources (true)); } rxvt_display::~rxvt_display () diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h index 9908ca75..d5c63aef 100644 --- a/src/rxvttoolkit.h +++ b/src/rxvttoolkit.h @@ -160,7 +160,7 @@ struct rxvt_display : refcounted { #endif rxvt_display (const char *id); - XrmDatabase get_resources (); + XrmDatabase get_resources (bool refresh); bool ref_init (); void ref_next (); ~rxvt_display (); -- 2.34.1