aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathias <mathias>2004-12-21 23:42:09 (GMT)
committermathias <mathias>2004-12-21 23:42:09 (GMT)
commitbc7c988561f79edb03b2ece80bb4ba0c8c73fc2e (patch)
treea48f394504f8b44cdab668ef69daf054c178500c
parent7e41a1494a65ecdb05c7a34c274693cbd950647f (diff)
downloadfluxbox_pavel-bc7c988561f79edb03b2ece80bb4ba0c8c73fc2e.zip
fluxbox_pavel-bc7c988561f79edb03b2ece80bb4ba0c8c73fc2e.tar.bz2
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
-rw-r--r--Makefile.am2
-rw-r--r--acinclude.m4233
-rw-r--r--configure.in26
-rw-r--r--src/FbTk/App.cc9
-rw-r--r--src/FbTk/Font.cc11
-rw-r--r--src/FbTk/Font.hh19
-rw-r--r--src/FbTk/Image.cc45
-rw-r--r--src/FbTk/Image.hh7
-rw-r--r--src/FbTk/ImageImlib2.cc147
-rw-r--r--src/FbTk/ImageImlib2.hh39
-rw-r--r--src/FbTk/Makefile.am6
-rw-r--r--src/fluxbox.cc3
-rw-r--r--src/main.cc5
-rw-r--r--xft.m497
14 files changed, 532 insertions, 117 deletions
diff --git a/Makefile.am b/Makefile.am
index cb2672e..281f789 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@
3SUBDIRS = data doc nls src util 3SUBDIRS = data doc nls src util
4MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in 4MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
5ACLOCAL_AMFLAGS = -I . 5ACLOCAL_AMFLAGS = -I .
6EXTRA_DIST = xft.m4 6EXTRA_DIST = acinclude.m4
7 7
8uninstall-local: 8uninstall-local:
9 rmdir $(pkgdatadir) 9 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 @@
1dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2dnl
3dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS
4dnl
5dnl The script must support `--cflags' and `--libs' args.
6dnl If MINIMUM-VERSION is specified, the script must also support the
7dnl `--version' arg.
8dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given,
9dnl it must also support `--prefix' and `--exec-prefix'.
10dnl (In other words, it must be like gtk-config.)
11dnl
12dnl For example:
13dnl
14dnl AC_PATH_GENERIC(Foo, 1.0.0)
15dnl
16dnl would run `foo-config --version' and check that it is at least 1.0.0
17dnl
18dnl If so, the following would then be defined:
19dnl
20dnl FOO_CFLAGS to `foo-config --cflags`
21dnl FOO_LIBS to `foo-config --libs`
22dnl
23dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK)
24dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount)
25dnl
26dnl @author Angus Lees <gusl@cse.unsw.edu.au>
27dnl @version $Id: ac_path_generic.m4,v 1.1.1.1 2001/07/26 00:46:28 guidod Exp $
28
29AC_DEFUN([AC_PATH_GENERIC],
30[dnl
31dnl we're going to need uppercase, lowercase and user-friendly versions of the
32dnl string `LIBRARY'
33pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
34pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
35
36dnl
37dnl Get the cflags and libraries from the LIBRARY-config script
38dnl
39AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)],
40 DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
41AC_ARG_WITH(DOWN-exec-prefix,[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)],
42 DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
43
44 if test x$DOWN[]_config_exec_prefix != x ; then
45 DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
46 if test x${UP[]_CONFIG+set} != xset ; then
47 UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
48 fi
49 fi
50 if test x$DOWN[]_config_prefix != x ; then
51 DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
52 if test x${UP[]_CONFIG+set} != xset ; then
53 UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
54 fi
55 fi
56
57 AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no)
58 ifelse([$2], ,
59 AC_MSG_CHECKING(for $1),
60 AC_MSG_CHECKING(for $1 - version >= $2)
61 )
62 no_[]DOWN=""
63 if test "$UP[]_CONFIG" = "no" ; then
64 no_[]DOWN=yes
65 else
66 UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
67 UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
68 ifelse([$2], , ,[
69 DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \
70 --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
71 DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \
72 --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
73 DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \
74 --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
75 DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])"
76 DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])"
77 DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])"
78
79 # Compare wanted version to what config script returned.
80 # If I knew what library was being run, i'd probably also compile
81 # a test program at this point (which also extracted and tested
82 # the version in some library-specific way)
83 if test "$DOWN[]_config_major_version" -lt \
84 "$DOWN[]_wanted_major_version" \
85 -o \( "$DOWN[]_config_major_version" -eq \
86 "$DOWN[]_wanted_major_version" \
87 -a "$DOWN[]_config_minor_version" -lt \
88 "$DOWN[]_wanted_minor_version" \) \
89 -o \( "$DOWN[]_config_major_version" -eq \
90 "$DOWN[]_wanted_major_version" \
91 -a "$DOWN[]_config_minor_version" -eq \
92 "$DOWN[]_wanted_minor_version" \
93 -a "$DOWN[]_config_micro_version" -lt \
94 "$DOWN[]_wanted_micro_version" \) ; then
95 # older version found
96 no_[]DOWN=yes
97 echo -n "*** An old version of $1 "
98 echo -n "($DOWN[]_config_major_version"
99 echo -n ".$DOWN[]_config_minor_version"
100 echo ".$DOWN[]_config_micro_version) was found."
101 echo -n "*** You need a version of $1 newer than "
102 echo -n "$DOWN[]_wanted_major_version"
103 echo -n ".$DOWN[]_wanted_minor_version"
104 echo ".$DOWN[]_wanted_micro_version."
105 echo "***"
106 echo "*** If you have already installed a sufficiently new version, this error"
107 echo "*** probably means that the wrong copy of the DOWN-config shell script is"
108 echo "*** being found. The easiest way to fix this is to remove the old version"
109 echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the"
110 echo "*** correct copy of DOWN-config. (In this case, you will have to"
111 echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
112 echo "*** so that the correct libraries are found at run-time)"
113 fi
114 ])
115 fi
116 if test "x$no_[]DOWN" = x ; then
117 AC_MSG_RESULT(yes)
118 ifelse([$3], , :, [$3])
119 else
120 AC_MSG_RESULT(no)
121 if test "$UP[]_CONFIG" = "no" ; then
122 echo "*** The DOWN-config script installed by $1 could not be found"
123 echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in"
124 echo "*** your path, or set the UP[]_CONFIG environment variable to the"
125 echo "*** full path to DOWN-config."
126 fi
127 UP[]_CFLAGS=""
128 UP[]_LIBS=""
129 ifelse([$4], , :, [$4])
130 fi
131 AC_SUBST(UP[]_CFLAGS)
132 AC_SUBST(UP[]_LIBS)
133
134 popdef([UP])
135 popdef([DOWN])
136])
137# xft.m4
138# Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
139
140# Permission is hereby granted, free of charge, to any person obtaining a
141# copy of this software and associated documentation files (the "Software"),
142# to deal in the Software without restriction, including without limitation
143# the rights to use, copy, modify, merge, publish, distribute, sublicense,
144# and/or sell copies of the Software, and to permit persons to whom the
145# Software is furnished to do so, subject to the following conditions:
146
147# The above copyright notice and this permission notice shall be included in
148# all copies or substantial portions of the Software.
149
150# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
153# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
154# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
155# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
156# DEALINGS IN THE SOFTWARE.
157
158# AM_PATH_XFT1([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
159AC_DEFUN([AM_PATH_XFT1],
160[
161 AC_CHECK_LIB(Xft, XftFontOpen,
162 XFT_LIBS="-lXft"
163 [$1],
164 [$2]
165 )
166])
167
168# AM_PATH_XFT2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
169AC_DEFUN([AM_PATH_XFT2],
170[
171 if test x$pkg_exec_prefix != x ; then
172 xft_args="$xft_args --exec-prefix=$pkg_exec_prefix"
173 if test x${PKG_CONFIG+set} != xset ; then
174 PKG_CONFIG=$pkg_exec_prefix/bin/pkg-config
175 fi
176fi
177
178if test x$xft_prefix != x ; then
179 xft_args="$xft_args --prefix=$xft_prefix"
180 if test x${PKG_CONFIG+set} != xset ; then
181 PKG_CONFIG=$xft_prefix/bin/pkg-config
182 fi
183fi
184
185AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
186if test "x$PKG_CONFIG" = "xno" ; then
187 ifelse([$2], , :, [$2])
188else
189 XFT_CFLAGS=`$PKG_CONFIG $xftconf_args --cflags xft`
190 XFT_LIBS=`$PKG_CONFIG $xftconf_args --libs xft`
191 ifelse([$1], , :, [$1])
192fi
193
194])
195
196# AM_PATH_XFT(default-value, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
197# Test for Xft, and define XFT_CFLAGS and XFT_LIBS
198AC_DEFUN([AM_PATH_XFT],
199[
200 AC_ARG_WITH(xft-prefix,[ --with-xft-prefix=path Prefix where Xft is installed (optional)],
201 xft_prefix="$withval", xft_prefix="")
202 AC_ARG_WITH(pkg-exec-prefix,[ --with-pkg-exec-prefix=path Exec prefix where pkg-config is installed (optional)],
203 pkg_exec_prefix="$withval", pkg_exec_prefix="")
204 AC_ARG_ENABLE(xft, [ --enable-xft Xft (antialias) support (default=$1)],
205 if test "x$enableval" = "xyes"; then
206 TRY_XFT=yes
207 else
208 TRY_XFT=no
209 fi
210 ,
211 TRY_XFT=$1
212 )
213
214if test "x$TRY_XFT" = "xyes"; then
215 AC_MSG_RESULT(yes)
216 AM_PATH_XFT2(
217 [$2],
218 # xft2 failed: try xft1
219 AM_PATH_XFT1(
220 [$2],
221 [$3]
222 AC_MSG_RESULT([Cant find Xft libraries! Disabling Xft]))
223 )
224else
225 AC_MSG_RESULT(no)
226 [$3]
227fi
228
229CFLAGS="$CFLAGS $XFT_CFLAGS"
230CXXFLAGS="$CXXFLAGS $XFT_CFLAGS"
231LIBS="$LIBS $XFT_LIBS"
232
233])
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(
426 426
427AM_CONDITIONAL(XPM, test x$XPM = xtrue) 427AM_CONDITIONAL(XPM, test x$XPM = xtrue)
428 428
429IMLIB2=false
430AC_MSG_CHECKING([whether to have Imlib2 (pixmap themes) support])
431AC_ARG_ENABLE(imlib2,
432[ --enable-imlib2 Imlib2 (pixmap themes) support [default=no]])
433
434if test "x$enableval" = "xyes"; then
435 AC_MSG_RESULT([yes])
436 AC_PATH_GENERIC(imlib2, 1.0.0,
437 [
438 IMLIB2=true
439 AC_DEFINE(HAVE_IMLIB2, [], [Imlib2 support])
440 IMLIB2_LIBS=`imlib2-config --libs`
441 IMLIB2_CFLAGS=`imlib2-config --cflags`
442 LIBS="$LIBS $IMLIB2_LIBS"
443 CXXFLAGS="$CXXFLAGS $IMLIB2_CFLAGS"
444 ],
445 [
446 AC_MSG_RESULT(no)
447 ])
448else
449 AC_MSG_RESULT([no])
450fi
451
452AM_CONDITIONAL(IMLIB2, test x$IMLIB2 = xtrue)
453
454
429AC_MSG_CHECKING([whether to have Xmb (multibyte font, utf-8) support]) 455AC_MSG_CHECKING([whether to have Xmb (multibyte font, utf-8) support])
430AC_ARG_ENABLE( 456AC_ARG_ENABLE(
431 xmb, 457 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 @@
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22#include "App.hh" 22#include "App.hh"
23#include "Font.hh"
24#include "Image.hh"
23 25
24#include "EventManager.hh" 26#include "EventManager.hh"
25 27
@@ -49,10 +51,17 @@ App::App(const char *displayname):m_done(false), m_display(0) {
49 if (displayname != 0 && displayname[0] == '\0') 51 if (displayname != 0 && displayname[0] == '\0')
50 displayname = 0; 52 displayname = 0;
51 m_display = XOpenDisplay(displayname); 53 m_display = XOpenDisplay(displayname);
54
55 Font::init();
56 Image::init();
52} 57}
53 58
54App::~App() { 59App::~App() {
55 if (m_display != 0) { 60 if (m_display != 0) {
61
62 Font::shutdown();
63 Image::shutdown();
64
56 XCloseDisplay(m_display); 65 XCloseDisplay(m_display);
57 m_display = 0; 66 m_display = 0;
58 } 67 }
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 {
229bool Font::m_multibyte = false; 229bool Font::m_multibyte = false;
230bool Font::m_utf8mode = false; 230bool Font::m_utf8mode = false;
231 231
232// some initialisation for using fonts 232
233void fontInit() { 233void Font::init() {
234 setlocale(LC_CTYPE, ""); 234 // must be set before the first XFontSet is created
235 setlocale(LC_CTYPE, "");
236}
237
238void Font::shutdown() {
239
235} 240}
236 241
237Font::Font(const char *name, bool antialias): 242Font::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 @@
40 40
41namespace FbTk { 41namespace FbTk {
42 42
43void fontInit();
44
45class FontImp; 43class FontImp;
46class FbDrawable; 44class FbDrawable;
47 45
@@ -51,6 +49,19 @@ class FbDrawable;
51class Font { 49class Font {
52public: 50public:
53 51
52 /// called at FbTk::App creation time, initializes some stuff
53 static void init();
54
55 /// called at FbTk::App destruction time, cleans up what was inited first
56 static void shutdown();
57
58 /// @return true if multibyte is enabled, else false
59 static bool multibyte() { return m_multibyte; }
60 /// @return true if utf-8 mode is enabled, else false
61 static bool utf8() { return m_utf8mode; }
62
63
64
54 Font(const char *name=0, bool antialias = false); 65 Font(const char *name=0, bool antialias = false);
55 virtual ~Font(); 66 virtual ~Font();
56 /** 67 /**
@@ -60,10 +71,6 @@ public:
60 */ 71 */
61 bool load(const std::string &name); 72 bool load(const std::string &name);
62 73
63 /// @return true if multibyte is enabled, else false
64 static bool multibyte() { return m_multibyte; }
65 /// @return true if utf-8 mode is enabled, else false
66 static bool utf8() { return m_utf8mode; }
67 void setAntialias(bool flag); 74 void setAntialias(bool flag);
68 inline void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); } 75 inline void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); }
69 inline void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); } 76 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 @@
1// Image.cc for FbTk - Fluxbox ToolKit 1// Image.cc for FbTk - Fluxbox ToolKit
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
@@ -30,10 +30,15 @@
30 30
31#ifdef HAVE_XPM 31#ifdef HAVE_XPM
32#include "ImageXPM.hh" 32#include "ImageXPM.hh"
33#endif /// HAVE_XPM 33#endif // HAVE_XPM
34
35#ifdef HAVE_IMLIB2
36#include "ImageImlib2.hh"
37#endif // HAVE_IMLIB2
34 38
35#include <list> 39#include <list>
36#include <iostream> 40#include <iostream>
41#include <set>
37using namespace std; 42using namespace std;
38 43
39namespace FbTk { 44namespace FbTk {
@@ -41,13 +46,41 @@ namespace FbTk {
41Image::ImageMap Image::s_image_map; 46Image::ImageMap Image::s_image_map;
42Image::StringList Image::s_search_paths; 47Image::StringList Image::s_search_paths;
43 48
44PixmapWithMask *Image::load(const std::string &filename, int screen_num) {
45 49
50void Image::init() {
51
52// create imagehandlers for their extensions
46#ifdef HAVE_XPM 53#ifdef HAVE_XPM
47 // we must do this because static linkage with libFbTk will not init 54 new ImageXPM();
48 // a static autoreg variable for it
49 static ImageXPM xpm;
50#endif // HAVE_XPM 55#endif // HAVE_XPM
56#ifdef HAVE_IMLIB2
57 new ImageImlib2();
58#endif // HAVE_IMLIB2
59}
60
61void Image::shutdown() {
62
63 std::set<ImageBase*> handlers;
64
65 // one imagehandler could be registered
66 // for more than one type
67 ImageMap::iterator it = s_image_map.begin();
68 ImageMap::iterator it_end = s_image_map.end();
69 for (; it != it_end; it++)
70 handlers.insert(it->second);
71
72 // free the unique handlers
73 std::set<ImageBase*>::iterator handler_it = handlers.begin();
74 std::set<ImageBase*>::iterator handler_it_end = handlers.end();
75 for(; handler_it != handler_it_end; handler_it++) {
76 delete (*handler_it);
77 }
78
79 s_image_map.clear();
80}
81
82PixmapWithMask *Image::load(const std::string &filename, int screen_num) {
83
51 84
52 if (filename == "") 85 if (filename == "")
53 return false; 86 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;
36/// loads images 36/// loads images
37class Image { 37class Image {
38public: 38public:
39
40 /// called at FbTk::App creation time, init some internal stuff
41 static void init();
42
43 /// called at FbTk:App destruction time, frees stuff allocated by init()
44 static void shutdown();
45
39 /// @return an instance of PixmapWithMask on success, 0 on failure 46 /// @return an instance of PixmapWithMask on success, 0 on failure
40 static PixmapWithMask *load(const std::string &filename, int screen_num); 47 static PixmapWithMask *load(const std::string &filename, int screen_num);
41 /// for register file type and imagebase 48 /// 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 @@
1// ImageImlib2.cc for FbTk - Fluxbox ToolKit
2// Copyright (c) 2004 Mathias Gumz <akira at fluxbox dot org>
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: $
23
24#include "ImageImlib2.hh"
25
26#include "App.hh"
27#include "PixmapWithMask.hh"
28
29#include <X11/xpm.h>
30
31#include <Imlib2.h>
32#include <map>
33
34namespace {
35
36typedef std::map<int, Imlib_Context> ScreenImlibContextContainer;
37typedef ScreenImlibContextContainer::iterator ScreenImlibContext;
38
39ScreenImlibContextContainer contexts;
40
41}; // anon namespace
42
43
44namespace FbTk {
45
46ImageImlib2::ImageImlib2() {
47
48 // lets have a 2mb cache inside imlib, holds
49 // uncompressed images
50 imlib_set_cache_size(2048 * 1024);
51
52 // TODO: this are the potential candidates,
53 // choose only sane ones. open for discussion
54 char* format_list[] = {
55 "PNG", // pngloader
56 "JPEG", "JPG", "JFI", "JFIF", // jpegloader
57// "TIFF", "TIF", // tiffloader
58 "PNM", "PPM", "PGM", "PBM", "PAM", // pnmloader
59// "TGA", // tgaloader
60// "IFF", "ILBM", "LBM", // lbmloader
61// "GIF", // gifloader
62// "ARGB", "AGR", // argbloader
63// "BMP", // bmploader
64// "BZ2", // bzloader
65// "GZ", // gzloader
66 NULL
67 };
68
69 char** format = NULL;
70 for(format = format_list; *format != NULL; format++) {
71 Image::registerType(*format, *this);
72 }
73}
74
75ImageImlib2::~ImageImlib2() {
76 ScreenImlibContext it = contexts.begin();
77 ScreenImlibContext it_end = contexts.end();
78 for (; it != it_end; it++) {
79 imlib_context_free(it->second);
80 }
81 contexts.clear();
82}
83
84PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) const {
85
86 Display *dpy = FbTk::App::instance()->display();
87
88 // init imlib2 if needed, the settings for each screen may differ
89 ScreenImlibContext screen_context = contexts.find(screen_num);
90 if (screen_context == contexts.end()) {
91
92 Imlib_Context new_context = imlib_context_new();
93 imlib_context_push(new_context);
94
95 imlib_context_set_display(dpy);
96 imlib_context_set_drawable(RootWindow(dpy, screen_num));
97 imlib_context_set_colormap(DefaultColormap(dpy, screen_num));
98 imlib_context_set_visual(DefaultVisual(dpy, screen_num));
99
100 imlib_context_pop();
101
102 contexts[screen_num] = new_context;
103 screen_context = contexts.find(screen_num);
104 }
105
106 if (screen_context == contexts.end()) {
107#ifdef DEBUG
108 cerr << "ImageImlib2::load: error, couldnt find a valid Imlib_Context.\n";
109#endif // DEBUG
110 return 0;
111 }
112
113 // now load the stuff
114 Imlib_Context context = screen_context->second;
115 imlib_context_push(context);
116 Imlib_Image image = imlib_load_image_immediately(filename.c_str());
117 if (image) { // loading was ok
118 imlib_context_set_image(image);
119
120 Pixmap pm = 0, mask = 0;
121 imlib_render_pixmaps_for_whole_image(&pm, &mask);
122
123 // pm and mask belong to imlib, so we have to copy them
124 FbPixmap fbpm;
125 FbPixmap fbmask;
126
127 fbpm.copy(pm);
128 fbmask.copy(mask);
129
130 // mark pm and mask as freeable in imlib
131 imlib_free_image();
132 imlib_free_pixmap_and_mask(pm);
133
134 imlib_context_pop();
135
136 PixmapWithMask* result = new PixmapWithMask();
137 result->pixmap() = fbpm;
138 result->mask() = fbmask;
139 return result;
140 }
141
142 // loading failure
143 imlib_context_pop();
144 return 0;
145}
146
147} // 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 @@
1// ImageImlib2.hh for FbTk - Fluxbox ToolKit
2// Copyright (c) 2004 Mathias Gumz (akira at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id:$
23
24#ifndef FBTK_IMAGEIMLIB2_HH
25#define FBTK_IMAGEIMLIB2_HH
26
27#include "Image.hh"
28namespace FbTk {
29
30class ImageImlib2: public ImageBase {
31public:
32 ImageImlib2();
33 ~ImageImlib2();
34 PixmapWithMask *load(const std::string &filename, int screen_num) const;
35};
36
37} // end namespace FbTk
38
39#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
11if XPM 11if XPM
12xpm_SOURCE= ImageXPM.hh ImageXPM.cc 12xpm_SOURCE= ImageXPM.hh ImageXPM.cc
13endif 13endif
14if IMLIB2
15imlib2_SOURCE= ImageImlib2.hh ImageImlib2.cc
16endif
14 17
15libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ 18libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \
16 FileUtil.hh FileUtil.cc \ 19 FileUtil.hh FileUtil.cc \
@@ -48,4 +51,5 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \
48 MenuIcon.hh MenuIcon.cc \ 51 MenuIcon.hh MenuIcon.cc \
49 ${xpm_SOURCE} \ 52 ${xpm_SOURCE} \
50 ${xft_SOURCE} \ 53 ${xft_SOURCE} \
51 ${xmb_SOURCE} 54 ${xmb_SOURCE} \
55 ${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
244 "Error message when no X display appears to exist")); 244 "Error message when no X display appears to exist"));
245 } 245 }
246 246
247 FbTk::fontInit();
248
249 Display *disp = FbTk::App::instance()->display(); 247 Display *disp = FbTk::App::instance()->display();
250 // For KDE dock applets 248 // For KDE dock applets
251 // KDE v1.x 249 // KDE v1.x
@@ -1369,7 +1367,6 @@ void Fluxbox::shutdown() {
1369 m_screen_list.end(), mem_fun(&BScreen::shutdown)); 1367 m_screen_list.end(), mem_fun(&BScreen::shutdown));
1370 1368
1371 sync(false); 1369 sync(false);
1372
1373} 1370}
1374 1371
1375/// saves resources 1372/// 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) {
106#endif // HAVE_XPM 106#endif // HAVE_XPM
107 "XPM"<<endl<< 107 "XPM"<<endl<<
108 108
109#ifndef HAVE_IMLIB2
110 NOT<<
111#endif // HAVE_IMLIB2
112 "IMLIB2"<<endl<<
113
109#ifndef USE_GNOME 114#ifndef USE_GNOME
110 NOT<< 115 NOT<<
111#endif // USE_GNOME 116#endif // USE_GNOME
diff --git a/xft.m4 b/xft.m4
deleted file mode 100644
index 7264e97..0000000
--- a/xft.m4
+++ /dev/null
@@ -1,97 +0,0 @@
1# xft.m4
2# Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
3
4# Permission is hereby granted, free of charge, to any person obtaining a
5# copy of this software and associated documentation files (the "Software"),
6# to deal in the Software without restriction, including without limitation
7# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8# and/or sell copies of the Software, and to permit persons to whom the
9# Software is furnished to do so, subject to the following conditions:
10
11# The above copyright notice and this permission notice shall be included in
12# all copies or substantial portions of the Software.
13
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20# DEALINGS IN THE SOFTWARE.
21
22# AM_PATH_XFT1([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
23AC_DEFUN([AM_PATH_XFT1],
24[
25 AC_CHECK_LIB(Xft, XftFontOpen,
26 XFT_LIBS="-lXft"
27 [$1],
28 [$2]
29 )
30])
31
32# AM_PATH_XFT2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
33AC_DEFUN([AM_PATH_XFT2],
34[
35 if test x$pkg_exec_prefix != x ; then
36 xft_args="$xft_args --exec-prefix=$pkg_exec_prefix"
37 if test x${PKG_CONFIG+set} != xset ; then
38 PKG_CONFIG=$pkg_exec_prefix/bin/pkg-config
39 fi
40fi
41
42if test x$xft_prefix != x ; then
43 xft_args="$xft_args --prefix=$xft_prefix"
44 if test x${PKG_CONFIG+set} != xset ; then
45 PKG_CONFIG=$xft_prefix/bin/pkg-config
46 fi
47fi
48
49AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
50if test "x$PKG_CONFIG" = "xno" ; then
51 ifelse([$2], , :, [$2])
52else
53 XFT_CFLAGS=`$PKG_CONFIG $xftconf_args --cflags xft`
54 XFT_LIBS=`$PKG_CONFIG $xftconf_args --libs xft`
55 ifelse([$1], , :, [$1])
56fi
57
58])
59
60# AM_PATH_XFT(default-value, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
61# Test for Xft, and define XFT_CFLAGS and XFT_LIBS
62AC_DEFUN([AM_PATH_XFT],
63[
64 AC_ARG_WITH(xft-prefix,[ --with-xft-prefix=path Prefix where Xft is installed (optional)],
65 xft_prefix="$withval", xft_prefix="")
66 AC_ARG_WITH(pkg-exec-prefix,[ --with-pkg-exec-prefix=path Exec prefix where pkg-config is installed (optional)],
67 pkg_exec_prefix="$withval", pkg_exec_prefix="")
68 AC_ARG_ENABLE(xft, [ --enable-xft Xft (antialias) support (default=$1)],
69 if test "x$enableval" = "xyes"; then
70 TRY_XFT=yes
71 else
72 TRY_XFT=no
73 fi
74 ,
75 TRY_XFT=$1
76 )
77
78if test "x$TRY_XFT" = "xyes"; then
79 AC_MSG_RESULT(yes)
80 AM_PATH_XFT2(
81 [$2],
82 # xft2 failed: try xft1
83 AM_PATH_XFT1(
84 [$2],
85 [$3]
86 AC_MSG_RESULT([Cant find Xft libraries! Disabling Xft]))
87 )
88else
89 AC_MSG_RESULT(no)
90 [$3]
91fi
92
93CFLAGS="$CFLAGS $XFT_CFLAGS"
94CXXFLAGS="$CXXFLAGS $XFT_CFLAGS"
95LIBS="$LIBS $XFT_LIBS"
96
97])