Add hack to make apps lauched from e16 in window mode appear in the virtual

root in stead of the real root.


SVN revision: 25697
This commit is contained in:
Kim Woelders 2006-09-10 18:43:20 +00:00
parent 35c8f904df
commit 068aa3465e
6 changed files with 183 additions and 1 deletions

View File

@ -1,4 +1,4 @@
SUBDIRS = intl dox eesh epp src config themes man scripts misc po
SUBDIRS = intl dox eesh epp src lib config themes man scripts misc po
EXTRA_DIST = \
timestamp.h \

View File

@ -21,6 +21,8 @@ echo "Running autoconf"
autoconf || exit 1
echo "Running autoheader"
autoheader || exit 1
echo "Running libtoolize"
libtoolize --copy --automake || glibtoolize --automake || exit 1
echo "Running automake --add-missing"
automake --copy --add-missing || exit 1

View File

@ -50,6 +50,10 @@ AC_PROG_LN_S
AC_HEADER_STDC
AM_ENABLE_SHARED
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
AC_PATH_X
AC_PATH_XTRA
@ -113,11 +117,14 @@ else
fi
ENLIGHTENMENT_ROOT=`eval echo ${DATADIR}/e16`
ENLIGHTENMENT_BIN=`eval echo ${bindir}`
ENLIGHTENMENT_LIB=`eval echo ${libdir}`
AC_SUBST(ENLIGHTENMENT_ROOT)
AC_SUBST(ENLIGHTENMENT_BIN)
AC_SUBST(ENLIGHTENMENT_LIB)
AC_SUBST(LOCALEDIR)
AC_DEFINE_UNQUOTED(ENLIGHTENMENT_ROOT, "$ENLIGHTENMENT_ROOT", [The installation root directory])
AC_DEFINE_UNQUOTED(ENLIGHTENMENT_BIN, "$ENLIGHTENMENT_BIN", [The installation bin directory])
AC_DEFINE_UNQUOTED(ENLIGHTENMENT_LIB, "$ENLIGHTENMENT_LIB", [The installation lib directory])
AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [The installation locale directory])
if test "x$enable_sound" = "xyes"; then
@ -246,6 +253,18 @@ AC_CHECK_LIB(Fridge,mass_quantities_of_any_ale,, [
echo " We highly suggest that you rectify this situation immediately."
])
AC_ARG_ENABLE(roothacklib,
[ --enable-roothacklib build window mode helper library @<:@default=yes@:>@],,
enable_roothacklib=yes)
if test "x$enable_roothacklib" = "xyes"; then
AC_CHECK_LIB(dl, dlopen, DLOPEN_LIBS=-ldl, enable_roothacklib=no)
AC_SUBST(DLOPEN_LIBS)
fi
if test "x$enable_roothacklib" = "xyes"; then
AC_DEFINE(USE_ROOTHACKLIB, 1, [Use window mode helper library])
fi
AM_CONDITIONAL(BUILD_ROOTHACKLIB, test "x$enable_roothacklib" = "xyes")
AC_ARG_ENABLE(gcc-warnings,
[ --enable-gcc-warnings enable GCC compiler warnings @<:@default=no@:>@],,
enable_gcc_warnings=no)
@ -262,6 +281,7 @@ dox/Makefile
dox/E-docs/Makefile
eesh/Makefile
epp/Makefile
lib/Makefile
man/Makefile
config/Makefile
config/pix/Makefile
@ -295,6 +315,7 @@ echo " Zoom ......................... $enable_zoom"
echo " Xinerama ..................... $enable_xinerama"
echo " RandR ........................ $enable_xrandr"
echo " Composite .................... $enable_composite"
echo " Window mode helper library ... $enable_roothacklib"
echo
echo "Experimental options - DO NOT USE unless you know what you are doing"
echo " Compile with ecore/ecore_x ... $enable_ecore"

13
lib/Makefile.am Normal file
View File

@ -0,0 +1,13 @@
MAINTAINERCLEANFILES = Makefile.in
if BUILD_ROOTHACKLIB
lib_LTLIBRARIES = libe16_hack.la
libe16_hack_la_SOURCES = e16_hack.c
libe16_hack_la_LIBADD = $(DLOPEN_LIBS)
#libe16_hack_la_LDFLAGS = -version-info 0:0:0
libe16_hack_la_LDFLAGS = -avoid-version
endif

142
lib/e16_hack.c Normal file
View File

@ -0,0 +1,142 @@
/*
* Copyright (C) 2005-2006 Carsten Haitzler
* Copyright (C) 2006 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies of the Software, its documentation and marketing & publicity
* materials, and acknowledgment shall be given in the documentation, materials
* and software packages that this Software was used.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Basic hack mechanism (dlopen etc.) taken from e_hack.c in e17.
*/
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include "config.h"
/* dlopened xlib so we can find the symbols in the real xlib to call them */
static void *lib_xlib = NULL;
static Window root = None;
/* Find our root window */
static Window
MyRoot(Display * dpy)
{
char *s;
if (root != None)
return root;
root = DefaultRootWindow(dpy);
s = getenv("ENL_WM_ROOT");
if (!s)
return root;
sscanf(s, "%lx", &root);
return root;
}
/* XCreateWindow intercept hack */
Window
XCreateWindow(Display * display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
int depth,
unsigned int class,
Visual * visual,
unsigned long valuemask, XSetWindowAttributes * attributes)
{
static Window(*func)
(Display * display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
int depth,
unsigned int class,
Visual * visual,
unsigned long valuemask, XSetWindowAttributes * attributes) = NULL;
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
if (!func)
func = dlsym(lib_xlib, "XCreateWindow");
if (parent == DefaultRootWindow(display))
parent = MyRoot(display);
return (*func) (display, parent, x, y, width, height, border_width, depth,
class, visual, valuemask, attributes);
}
/* XCreateSimpleWindow intercept hack */
Window
XCreateSimpleWindow(Display * display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
unsigned long border, unsigned long background)
{
static Window(*func)
(Display * display,
Window parent,
int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width,
unsigned long border, unsigned long background) = NULL;
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
if (!func)
func = dlsym(lib_xlib, "XCreateSimpleWindow");
if (parent == DefaultRootWindow(display))
parent = MyRoot(display);
return (*func) (display, parent, x, y, width, height,
border_width, border, background);
}
/* XReparentWindow intercept hack */
int
XReparentWindow(Display * display, Window window, Window parent, int x, int y)
{
static int (*func)
(Display * display, Window window, Window parent, int x, int y) = NULL;
/* find the real Xlib and the real X function */
if (!lib_xlib)
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
if (!func)
func = dlsym(lib_xlib, "XReparentWindow");
if (parent == DefaultRootWindow(display))
parent = MyRoot(display);
return (*func) (display, window, parent, x, y);
}

View File

@ -53,6 +53,10 @@ execApplication(const char *params, int flags)
/* Set up env stuff */
if (flags & EXEC_SET_LANG)
LangExport();
#if USE_ROOTHACKLIB
if (Mode.wm.window)
Esetenv("LD_PRELOAD", ENLIGHTENMENT_LIB "/libe16_hack.so");
#endif
sh = usershell(getuid());