From bc7c988561f79edb03b2ece80bb4ba0c8c73fc2e Mon Sep 17 00:00:00 2001 From: mathias Date: Tue, 21 Dec 2004 23:42:09 +0000 Subject: adds imlib2-support to fluxbox: allows us to load several imageformats besides xpm. to get imlib2 support in fluxbox one has to ./configure --enable-imblib2 default is disabled. a fluxbox-binary that supports imlib2 will have IMLIB2 in "fluxbox -info"-output explanation to the changed files: * xft.m4 -> acinclude.m4 + added ac_path_generic.m4 (from http://ac-archive.sourceforge.net/Miscellaneous/ac_path_generic.html) * configure.in, Makefile.am, src/FbTk/Makefile.am changed to handle imlib2-support * Font.cc/hh Image.cc/hh App.cc fluxbox.cc consistent way of init for global stuff for fonts and imagehandlers. * rest of changes just add the imlib2-code, pretty straightforward --- Makefile.am | 2 +- acinclude.m4 | 233 ++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 26 ++++++ src/FbTk/App.cc | 9 ++ src/FbTk/Font.cc | 11 ++- src/FbTk/Font.hh | 19 ++-- src/FbTk/Image.cc | 45 ++++++++-- src/FbTk/Image.hh | 7 ++ src/FbTk/ImageImlib2.cc | 147 ++++++++++++++++++++++++++++++ src/FbTk/ImageImlib2.hh | 39 ++++++++ src/FbTk/Makefile.am | 6 +- src/fluxbox.cc | 3 - src/main.cc | 5 ++ xft.m4 | 97 -------------------- 14 files changed, 532 insertions(+), 117 deletions(-) create mode 100644 acinclude.m4 create mode 100644 src/FbTk/ImageImlib2.cc create mode 100644 src/FbTk/ImageImlib2.hh delete mode 100644 xft.m4 diff --git a/Makefile.am b/Makefile.am index cb2672e..281f789 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = data doc nls src util MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in ACLOCAL_AMFLAGS = -I . -EXTRA_DIST = xft.m4 +EXTRA_DIST = acinclude.m4 uninstall-local: rmdir $(pkgdatadir) diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..a181dba --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,233 @@ +dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl +dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS +dnl +dnl The script must support `--cflags' and `--libs' args. +dnl If MINIMUM-VERSION is specified, the script must also support the +dnl `--version' arg. +dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given, +dnl it must also support `--prefix' and `--exec-prefix'. +dnl (In other words, it must be like gtk-config.) +dnl +dnl For example: +dnl +dnl AC_PATH_GENERIC(Foo, 1.0.0) +dnl +dnl would run `foo-config --version' and check that it is at least 1.0.0 +dnl +dnl If so, the following would then be defined: +dnl +dnl FOO_CFLAGS to `foo-config --cflags` +dnl FOO_LIBS to `foo-config --libs` +dnl +dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK) +dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount) +dnl +dnl @author Angus Lees +dnl @version $Id: ac_path_generic.m4,v 1.1.1.1 2001/07/26 00:46:28 guidod Exp $ + +AC_DEFUN([AC_PATH_GENERIC], +[dnl +dnl we're going to need uppercase, lowercase and user-friendly versions of the +dnl string `LIBRARY' +pushdef([UP], translit([$1], [a-z], [A-Z]))dnl +pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl + +dnl +dnl Get the cflags and libraries from the LIBRARY-config script +dnl +AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)], + DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="") +AC_ARG_WITH(DOWN-exec-prefix,[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)], + DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="") + + if test x$DOWN[]_config_exec_prefix != x ; then + DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix" + if test x${UP[]_CONFIG+set} != xset ; then + UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config + fi + fi + if test x$DOWN[]_config_prefix != x ; then + DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix" + if test x${UP[]_CONFIG+set} != xset ; then + UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config + fi + fi + + AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no) + ifelse([$2], , + AC_MSG_CHECKING(for $1), + AC_MSG_CHECKING(for $1 - version >= $2) + ) + no_[]DOWN="" + if test "$UP[]_CONFIG" = "no" ; then + no_[]DOWN=yes + else + UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`" + UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`" + ifelse([$2], , ,[ + DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \ + --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \ + --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \ + --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])" + DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])" + DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])" + + # Compare wanted version to what config script returned. + # If I knew what library was being run, i'd probably also compile + # a test program at this point (which also extracted and tested + # the version in some library-specific way) + if test "$DOWN[]_config_major_version" -lt \ + "$DOWN[]_wanted_major_version" \ + -o \( "$DOWN[]_config_major_version" -eq \ + "$DOWN[]_wanted_major_version" \ + -a "$DOWN[]_config_minor_version" -lt \ + "$DOWN[]_wanted_minor_version" \) \ + -o \( "$DOWN[]_config_major_version" -eq \ + "$DOWN[]_wanted_major_version" \ + -a "$DOWN[]_config_minor_version" -eq \ + "$DOWN[]_wanted_minor_version" \ + -a "$DOWN[]_config_micro_version" -lt \ + "$DOWN[]_wanted_micro_version" \) ; then + # older version found + no_[]DOWN=yes + echo -n "*** An old version of $1 " + echo -n "($DOWN[]_config_major_version" + echo -n ".$DOWN[]_config_minor_version" + echo ".$DOWN[]_config_micro_version) was found." + echo -n "*** You need a version of $1 newer than " + echo -n "$DOWN[]_wanted_major_version" + echo -n ".$DOWN[]_wanted_minor_version" + echo ".$DOWN[]_wanted_micro_version." + echo "***" + echo "*** If you have already installed a sufficiently new version, this error" + echo "*** probably means that the wrong copy of the DOWN-config shell script is" + echo "*** being found. The easiest way to fix this is to remove the old version" + echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the" + echo "*** correct copy of DOWN-config. (In this case, you will have to" + echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf" + echo "*** so that the correct libraries are found at run-time)" + fi + ]) + fi + if test "x$no_[]DOWN" = x ; then + AC_MSG_RESULT(yes) + ifelse([$3], , :, [$3]) + else + AC_MSG_RESULT(no) + if test "$UP[]_CONFIG" = "no" ; then + echo "*** The DOWN-config script installed by $1 could not be found" + echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the UP[]_CONFIG environment variable to the" + echo "*** full path to DOWN-config." + fi + UP[]_CFLAGS="" + UP[]_LIBS="" + ifelse([$4], , :, [$4]) + fi + AC_SUBST(UP[]_CFLAGS) + AC_SUBST(UP[]_LIBS) + + popdef([UP]) + popdef([DOWN]) +]) +# xft.m4 +# Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org) + +# 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 or substantial portions of the Software. + +# 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 OR COPYRIGHT HOLDERS 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. + +# AM_PATH_XFT1([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +AC_DEFUN([AM_PATH_XFT1], +[ + AC_CHECK_LIB(Xft, XftFontOpen, + XFT_LIBS="-lXft" + [$1], + [$2] + ) +]) + +# AM_PATH_XFT2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +AC_DEFUN([AM_PATH_XFT2], +[ + if test x$pkg_exec_prefix != x ; then + xft_args="$xft_args --exec-prefix=$pkg_exec_prefix" + if test x${PKG_CONFIG+set} != xset ; then + PKG_CONFIG=$pkg_exec_prefix/bin/pkg-config + fi +fi + +if test x$xft_prefix != x ; then + xft_args="$xft_args --prefix=$xft_prefix" + if test x${PKG_CONFIG+set} != xset ; then + PKG_CONFIG=$xft_prefix/bin/pkg-config + fi +fi + +AC_PATH_PROG(PKG_CONFIG, pkg-config, no) +if test "x$PKG_CONFIG" = "xno" ; then + ifelse([$2], , :, [$2]) +else + XFT_CFLAGS=`$PKG_CONFIG $xftconf_args --cflags xft` + XFT_LIBS=`$PKG_CONFIG $xftconf_args --libs xft` + ifelse([$1], , :, [$1]) +fi + +]) + +# AM_PATH_XFT(default-value, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +# Test for Xft, and define XFT_CFLAGS and XFT_LIBS +AC_DEFUN([AM_PATH_XFT], +[ + AC_ARG_WITH(xft-prefix,[ --with-xft-prefix=path Prefix where Xft is installed (optional)], + xft_prefix="$withval", xft_prefix="") + AC_ARG_WITH(pkg-exec-prefix,[ --with-pkg-exec-prefix=path Exec prefix where pkg-config is installed (optional)], + pkg_exec_prefix="$withval", pkg_exec_prefix="") + AC_ARG_ENABLE(xft, [ --enable-xft Xft (antialias) support (default=$1)], + if test "x$enableval" = "xyes"; then + TRY_XFT=yes + else + TRY_XFT=no + fi + , + TRY_XFT=$1 + ) + +if test "x$TRY_XFT" = "xyes"; then + AC_MSG_RESULT(yes) + AM_PATH_XFT2( + [$2], + # xft2 failed: try xft1 + AM_PATH_XFT1( + [$2], + [$3] + AC_MSG_RESULT([Cant find Xft libraries! Disabling Xft])) + ) +else + AC_MSG_RESULT(no) + [$3] +fi + +CFLAGS="$CFLAGS $XFT_CFLAGS" +CXXFLAGS="$CXXFLAGS $XFT_CFLAGS" +LIBS="$LIBS $XFT_LIBS" + +]) diff --git a/configure.in b/configure.in index d03429e..5fd74a9 100644 --- a/configure.in +++ b/configure.in @@ -426,6 +426,32 @@ AC_ARG_ENABLE( AM_CONDITIONAL(XPM, test x$XPM = xtrue) +IMLIB2=false +AC_MSG_CHECKING([whether to have Imlib2 (pixmap themes) support]) +AC_ARG_ENABLE(imlib2, +[ --enable-imlib2 Imlib2 (pixmap themes) support [default=no]]) + +if test "x$enableval" = "xyes"; then + AC_MSG_RESULT([yes]) + AC_PATH_GENERIC(imlib2, 1.0.0, + [ + IMLIB2=true + AC_DEFINE(HAVE_IMLIB2, [], [Imlib2 support]) + IMLIB2_LIBS=`imlib2-config --libs` + IMLIB2_CFLAGS=`imlib2-config --cflags` + LIBS="$LIBS $IMLIB2_LIBS" + CXXFLAGS="$CXXFLAGS $IMLIB2_CFLAGS" + ], + [ + AC_MSG_RESULT(no) + ]) +else + AC_MSG_RESULT([no]) +fi + +AM_CONDITIONAL(IMLIB2, test x$IMLIB2 = xtrue) + + AC_MSG_CHECKING([whether to have Xmb (multibyte font, utf-8) support]) AC_ARG_ENABLE( xmb, diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc index 2479944..c48ccb1 100644 --- a/src/FbTk/App.cc +++ b/src/FbTk/App.cc @@ -20,6 +20,8 @@ // DEALINGS IN THE SOFTWARE. #include "App.hh" +#include "Font.hh" +#include "Image.hh" #include "EventManager.hh" @@ -49,10 +51,17 @@ App::App(const char *displayname):m_done(false), m_display(0) { if (displayname != 0 && displayname[0] == '\0') displayname = 0; m_display = XOpenDisplay(displayname); + + Font::init(); + Image::init(); } App::~App() { if (m_display != 0) { + + Font::shutdown(); + Image::shutdown(); + XCloseDisplay(m_display); m_display = 0; } diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index e2e3dec..c7193f7 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc @@ -229,9 +229,14 @@ namespace FbTk { bool Font::m_multibyte = false; bool Font::m_utf8mode = false; -// some initialisation for using fonts -void fontInit() { - setlocale(LC_CTYPE, ""); + +void Font::init() { + // must be set before the first XFontSet is created + setlocale(LC_CTYPE, ""); +} + +void Font::shutdown() { + } Font::Font(const char *name, bool antialias): diff --git a/src/FbTk/Font.hh b/src/FbTk/Font.hh index d299848..f6742cb 100644 --- a/src/FbTk/Font.hh +++ b/src/FbTk/Font.hh @@ -40,8 +40,6 @@ namespace FbTk { -void fontInit(); - class FontImp; class FbDrawable; @@ -51,6 +49,19 @@ class FbDrawable; class Font { public: + /// called at FbTk::App creation time, initializes some stuff + static void init(); + + /// called at FbTk::App destruction time, cleans up what was inited first + static void shutdown(); + + /// @return true if multibyte is enabled, else false + static bool multibyte() { return m_multibyte; } + /// @return true if utf-8 mode is enabled, else false + static bool utf8() { return m_utf8mode; } + + + Font(const char *name=0, bool antialias = false); virtual ~Font(); /** @@ -60,10 +71,6 @@ public: */ bool load(const std::string &name); - /// @return true if multibyte is enabled, else false - static bool multibyte() { return m_multibyte; } - /// @return true if utf-8 mode is enabled, else false - static bool utf8() { return m_utf8mode; } void setAntialias(bool flag); inline void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); } inline void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); } diff --git a/src/FbTk/Image.cc b/src/FbTk/Image.cc index 1026a92..a7ff7e5 100644 --- a/src/FbTk/Image.cc +++ b/src/FbTk/Image.cc @@ -1,5 +1,5 @@ // Image.cc for FbTk - Fluxbox ToolKit -// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) +// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -30,10 +30,15 @@ #ifdef HAVE_XPM #include "ImageXPM.hh" -#endif /// HAVE_XPM +#endif // HAVE_XPM + +#ifdef HAVE_IMLIB2 +#include "ImageImlib2.hh" +#endif // HAVE_IMLIB2 #include #include +#include using namespace std; namespace FbTk { @@ -41,13 +46,41 @@ namespace FbTk { Image::ImageMap Image::s_image_map; Image::StringList Image::s_search_paths; -PixmapWithMask *Image::load(const std::string &filename, int screen_num) { +void Image::init() { + +// create imagehandlers for their extensions #ifdef HAVE_XPM - // we must do this because static linkage with libFbTk will not init - // a static autoreg variable for it - static ImageXPM xpm; + new ImageXPM(); #endif // HAVE_XPM +#ifdef HAVE_IMLIB2 + new ImageImlib2(); +#endif // HAVE_IMLIB2 +} + +void Image::shutdown() { + + std::set handlers; + + // one imagehandler could be registered + // for more than one type + ImageMap::iterator it = s_image_map.begin(); + ImageMap::iterator it_end = s_image_map.end(); + for (; it != it_end; it++) + handlers.insert(it->second); + + // free the unique handlers + std::set::iterator handler_it = handlers.begin(); + std::set::iterator handler_it_end = handlers.end(); + for(; handler_it != handler_it_end; handler_it++) { + delete (*handler_it); + } + + s_image_map.clear(); +} + +PixmapWithMask *Image::load(const std::string &filename, int screen_num) { + if (filename == "") return false; diff --git a/src/FbTk/Image.hh b/src/FbTk/Image.hh index 6e0bf53..eaa66ae 100644 --- a/src/FbTk/Image.hh +++ b/src/FbTk/Image.hh @@ -36,6 +36,13 @@ class PixmapWithMask; /// loads images class Image { public: + + /// called at FbTk::App creation time, init some internal stuff + static void init(); + + /// called at FbTk:App destruction time, frees stuff allocated by init() + static void shutdown(); + /// @return an instance of PixmapWithMask on success, 0 on failure static PixmapWithMask *load(const std::string &filename, int screen_num); /// for register file type and imagebase diff --git a/src/FbTk/ImageImlib2.cc b/src/FbTk/ImageImlib2.cc new file mode 100644 index 0000000..82079a3 --- /dev/null +++ b/src/FbTk/ImageImlib2.cc @@ -0,0 +1,147 @@ +// ImageImlib2.cc for FbTk - Fluxbox ToolKit +// Copyright (c) 2004 Mathias Gumz +// +// 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 or substantial portions of the Software. +// +// 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 OR COPYRIGHT HOLDERS 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. + +// $Id: $ + +#include "ImageImlib2.hh" + +#include "App.hh" +#include "PixmapWithMask.hh" + +#include + +#include +#include + +namespace { + +typedef std::map ScreenImlibContextContainer; +typedef ScreenImlibContextContainer::iterator ScreenImlibContext; + +ScreenImlibContextContainer contexts; + +}; // anon namespace + + +namespace FbTk { + +ImageImlib2::ImageImlib2() { + + // lets have a 2mb cache inside imlib, holds + // uncompressed images + imlib_set_cache_size(2048 * 1024); + + // TODO: this are the potential candidates, + // choose only sane ones. open for discussion + char* format_list[] = { + "PNG", // pngloader + "JPEG", "JPG", "JFI", "JFIF", // jpegloader +// "TIFF", "TIF", // tiffloader + "PNM", "PPM", "PGM", "PBM", "PAM", // pnmloader +// "TGA", // tgaloader +// "IFF", "ILBM", "LBM", // lbmloader +// "GIF", // gifloader +// "ARGB", "AGR", // argbloader +// "BMP", // bmploader +// "BZ2", // bzloader +// "GZ", // gzloader + NULL + }; + + char** format = NULL; + for(format = format_list; *format != NULL; format++) { + Image::registerType(*format, *this); + } +} + +ImageImlib2::~ImageImlib2() { + ScreenImlibContext it = contexts.begin(); + ScreenImlibContext it_end = contexts.end(); + for (; it != it_end; it++) { + imlib_context_free(it->second); + } + contexts.clear(); +} + +PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) const { + + Display *dpy = FbTk::App::instance()->display(); + + // init imlib2 if needed, the settings for each screen may differ + ScreenImlibContext screen_context = contexts.find(screen_num); + if (screen_context == contexts.end()) { + + Imlib_Context new_context = imlib_context_new(); + imlib_context_push(new_context); + + imlib_context_set_display(dpy); + imlib_context_set_drawable(RootWindow(dpy, screen_num)); + imlib_context_set_colormap(DefaultColormap(dpy, screen_num)); + imlib_context_set_visual(DefaultVisual(dpy, screen_num)); + + imlib_context_pop(); + + contexts[screen_num] = new_context; + screen_context = contexts.find(screen_num); + } + + if (screen_context == contexts.end()) { +#ifdef DEBUG + cerr << "ImageImlib2::load: error, couldnt find a valid Imlib_Context.\n"; +#endif // DEBUG + return 0; + } + + // now load the stuff + Imlib_Context context = screen_context->second; + imlib_context_push(context); + Imlib_Image image = imlib_load_image_immediately(filename.c_str()); + if (image) { // loading was ok + imlib_context_set_image(image); + + Pixmap pm = 0, mask = 0; + imlib_render_pixmaps_for_whole_image(&pm, &mask); + + // pm and mask belong to imlib, so we have to copy them + FbPixmap fbpm; + FbPixmap fbmask; + + fbpm.copy(pm); + fbmask.copy(mask); + + // mark pm and mask as freeable in imlib + imlib_free_image(); + imlib_free_pixmap_and_mask(pm); + + imlib_context_pop(); + + PixmapWithMask* result = new PixmapWithMask(); + result->pixmap() = fbpm; + result->mask() = fbmask; + return result; + } + + // loading failure + imlib_context_pop(); + return 0; +} + +} // end namespace FbTk diff --git a/src/FbTk/ImageImlib2.hh b/src/FbTk/ImageImlib2.hh new file mode 100644 index 0000000..85aca68 --- /dev/null +++ b/src/FbTk/ImageImlib2.hh @@ -0,0 +1,39 @@ +// ImageImlib2.hh for FbTk - Fluxbox ToolKit +// Copyright (c) 2004 Mathias Gumz (akira at fluxbox dot org) +// +// 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 or substantial portions of the Software. +// +// 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 OR COPYRIGHT HOLDERS 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. + +// $Id:$ + +#ifndef FBTK_IMAGEIMLIB2_HH +#define FBTK_IMAGEIMLIB2_HH + +#include "Image.hh" +namespace FbTk { + +class ImageImlib2: public ImageBase { +public: + ImageImlib2(); + ~ImageImlib2(); + PixmapWithMask *load(const std::string &filename, int screen_num) const; +}; + +} // end namespace FbTk + +#endif // FBTK_IMAGEIMLIB2_HH diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index be9b3ef..47ed58f 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -11,6 +11,9 @@ endif if XPM xpm_SOURCE= ImageXPM.hh ImageXPM.cc endif +if IMLIB2 +imlib2_SOURCE= ImageImlib2.hh ImageImlib2.cc +endif libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ FileUtil.hh FileUtil.cc \ @@ -48,4 +51,5 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ MenuIcon.hh MenuIcon.cc \ ${xpm_SOURCE} \ ${xft_SOURCE} \ - ${xmb_SOURCE} + ${xmb_SOURCE} \ + ${imlib2_SOURCE} diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 3d82eb5..19a0daa 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -244,8 +244,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile "Error message when no X display appears to exist")); } - FbTk::fontInit(); - Display *disp = FbTk::App::instance()->display(); // For KDE dock applets // KDE v1.x @@ -1369,7 +1367,6 @@ void Fluxbox::shutdown() { m_screen_list.end(), mem_fun(&BScreen::shutdown)); sync(false); - } /// saves resources diff --git a/src/main.cc b/src/main.cc index c91fb3f..b7fffc3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -106,6 +106,11 @@ void showInfo(ostream &ostr) { #endif // HAVE_XPM "XPM"<