diff options
author | mathias <mathias> | 2004-12-21 23:42:09 (GMT) |
---|---|---|
committer | mathias <mathias> | 2004-12-21 23:42:09 (GMT) |
commit | bc7c988561f79edb03b2ece80bb4ba0c8c73fc2e (patch) | |
tree | a48f394504f8b44cdab668ef69daf054c178500c | |
parent | 7e41a1494a65ecdb05c7a34c274693cbd950647f (diff) | |
download | fluxbox_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.am | 2 | ||||
-rw-r--r-- | acinclude.m4 | 233 | ||||
-rw-r--r-- | configure.in | 26 | ||||
-rw-r--r-- | src/FbTk/App.cc | 9 | ||||
-rw-r--r-- | src/FbTk/Font.cc | 11 | ||||
-rw-r--r-- | src/FbTk/Font.hh | 19 | ||||
-rw-r--r-- | src/FbTk/Image.cc | 45 | ||||
-rw-r--r-- | src/FbTk/Image.hh | 7 | ||||
-rw-r--r-- | src/FbTk/ImageImlib2.cc | 147 | ||||
-rw-r--r-- | src/FbTk/ImageImlib2.hh | 39 | ||||
-rw-r--r-- | src/FbTk/Makefile.am | 6 | ||||
-rw-r--r-- | src/fluxbox.cc | 3 | ||||
-rw-r--r-- | src/main.cc | 5 | ||||
-rw-r--r-- | xft.m4 | 97 |
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 @@ | |||
3 | SUBDIRS = data doc nls src util | 3 | SUBDIRS = data doc nls src util |
4 | MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in | 4 | MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in |
5 | ACLOCAL_AMFLAGS = -I . | 5 | ACLOCAL_AMFLAGS = -I . |
6 | EXTRA_DIST = xft.m4 | 6 | EXTRA_DIST = acinclude.m4 |
7 | 7 | ||
8 | uninstall-local: | 8 | uninstall-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 @@ | |||
1 | dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
2 | dnl | ||
3 | dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS | ||
4 | dnl | ||
5 | dnl The script must support `--cflags' and `--libs' args. | ||
6 | dnl If MINIMUM-VERSION is specified, the script must also support the | ||
7 | dnl `--version' arg. | ||
8 | dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given, | ||
9 | dnl it must also support `--prefix' and `--exec-prefix'. | ||
10 | dnl (In other words, it must be like gtk-config.) | ||
11 | dnl | ||
12 | dnl For example: | ||
13 | dnl | ||
14 | dnl AC_PATH_GENERIC(Foo, 1.0.0) | ||
15 | dnl | ||
16 | dnl would run `foo-config --version' and check that it is at least 1.0.0 | ||
17 | dnl | ||
18 | dnl If so, the following would then be defined: | ||
19 | dnl | ||
20 | dnl FOO_CFLAGS to `foo-config --cflags` | ||
21 | dnl FOO_LIBS to `foo-config --libs` | ||
22 | dnl | ||
23 | dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK) | ||
24 | dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount) | ||
25 | dnl | ||
26 | dnl @author Angus Lees <gusl@cse.unsw.edu.au> | ||
27 | dnl @version $Id: ac_path_generic.m4,v 1.1.1.1 2001/07/26 00:46:28 guidod Exp $ | ||
28 | |||
29 | AC_DEFUN([AC_PATH_GENERIC], | ||
30 | [dnl | ||
31 | dnl we're going to need uppercase, lowercase and user-friendly versions of the | ||
32 | dnl string `LIBRARY' | ||
33 | pushdef([UP], translit([$1], [a-z], [A-Z]))dnl | ||
34 | pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl | ||
35 | |||
36 | dnl | ||
37 | dnl Get the cflags and libraries from the LIBRARY-config script | ||
38 | dnl | ||
39 | AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)], | ||
40 | DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="") | ||
41 | AC_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]]]) | ||
159 | AC_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]]]) | ||
169 | AC_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 | ||
176 | fi | ||
177 | |||
178 | if 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 | ||
183 | fi | ||
184 | |||
185 | AC_PATH_PROG(PKG_CONFIG, pkg-config, no) | ||
186 | if test "x$PKG_CONFIG" = "xno" ; then | ||
187 | ifelse([$2], , :, [$2]) | ||
188 | else | ||
189 | XFT_CFLAGS=`$PKG_CONFIG $xftconf_args --cflags xft` | ||
190 | XFT_LIBS=`$PKG_CONFIG $xftconf_args --libs xft` | ||
191 | ifelse([$1], , :, [$1]) | ||
192 | fi | ||
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 | ||
198 | AC_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 | |||
214 | if 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 | ) | ||
224 | else | ||
225 | AC_MSG_RESULT(no) | ||
226 | [$3] | ||
227 | fi | ||
228 | |||
229 | CFLAGS="$CFLAGS $XFT_CFLAGS" | ||
230 | CXXFLAGS="$CXXFLAGS $XFT_CFLAGS" | ||
231 | LIBS="$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 | ||
427 | AM_CONDITIONAL(XPM, test x$XPM = xtrue) | 427 | AM_CONDITIONAL(XPM, test x$XPM = xtrue) |
428 | 428 | ||
429 | IMLIB2=false | ||
430 | AC_MSG_CHECKING([whether to have Imlib2 (pixmap themes) support]) | ||
431 | AC_ARG_ENABLE(imlib2, | ||
432 | [ --enable-imlib2 Imlib2 (pixmap themes) support [default=no]]) | ||
433 | |||
434 | if 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 | ]) | ||
448 | else | ||
449 | AC_MSG_RESULT([no]) | ||
450 | fi | ||
451 | |||
452 | AM_CONDITIONAL(IMLIB2, test x$IMLIB2 = xtrue) | ||
453 | |||
454 | |||
429 | AC_MSG_CHECKING([whether to have Xmb (multibyte font, utf-8) support]) | 455 | AC_MSG_CHECKING([whether to have Xmb (multibyte font, utf-8) support]) |
430 | AC_ARG_ENABLE( | 456 | AC_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 | ||
54 | App::~App() { | 59 | App::~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 { | |||
229 | bool Font::m_multibyte = false; | 229 | bool Font::m_multibyte = false; |
230 | bool Font::m_utf8mode = false; | 230 | bool Font::m_utf8mode = false; |
231 | 231 | ||
232 | // some initialisation for using fonts | 232 | |
233 | void fontInit() { | 233 | void Font::init() { |
234 | setlocale(LC_CTYPE, ""); | 234 | // must be set before the first XFontSet is created |
235 | setlocale(LC_CTYPE, ""); | ||
236 | } | ||
237 | |||
238 | void Font::shutdown() { | ||
239 | |||
235 | } | 240 | } |
236 | 241 | ||
237 | Font::Font(const char *name, bool antialias): | 242 | 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 @@ | |||
40 | 40 | ||
41 | namespace FbTk { | 41 | namespace FbTk { |
42 | 42 | ||
43 | void fontInit(); | ||
44 | |||
45 | class FontImp; | 43 | class FontImp; |
46 | class FbDrawable; | 44 | class FbDrawable; |
47 | 45 | ||
@@ -51,6 +49,19 @@ class FbDrawable; | |||
51 | class Font { | 49 | class Font { |
52 | public: | 50 | public: |
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> | ||
37 | using namespace std; | 42 | using namespace std; |
38 | 43 | ||
39 | namespace FbTk { | 44 | namespace FbTk { |
@@ -41,13 +46,41 @@ namespace FbTk { | |||
41 | Image::ImageMap Image::s_image_map; | 46 | Image::ImageMap Image::s_image_map; |
42 | Image::StringList Image::s_search_paths; | 47 | Image::StringList Image::s_search_paths; |
43 | 48 | ||
44 | PixmapWithMask *Image::load(const std::string &filename, int screen_num) { | ||
45 | 49 | ||
50 | void 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 | |||
61 | void 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 | |||
82 | PixmapWithMask *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 |
37 | class Image { | 37 | class Image { |
38 | public: | 38 | public: |
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 | |||
34 | namespace { | ||
35 | |||
36 | typedef std::map<int, Imlib_Context> ScreenImlibContextContainer; | ||
37 | typedef ScreenImlibContextContainer::iterator ScreenImlibContext; | ||
38 | |||
39 | ScreenImlibContextContainer contexts; | ||
40 | |||
41 | }; // anon namespace | ||
42 | |||
43 | |||
44 | namespace FbTk { | ||
45 | |||
46 | ImageImlib2::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 | |||
75 | ImageImlib2::~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 | |||
84 | PixmapWithMask *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" | ||
28 | namespace FbTk { | ||
29 | |||
30 | class ImageImlib2: public ImageBase { | ||
31 | public: | ||
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 | |||
11 | if XPM | 11 | if XPM |
12 | xpm_SOURCE= ImageXPM.hh ImageXPM.cc | 12 | xpm_SOURCE= ImageXPM.hh ImageXPM.cc |
13 | endif | 13 | endif |
14 | if IMLIB2 | ||
15 | imlib2_SOURCE= ImageImlib2.hh ImageImlib2.cc | ||
16 | endif | ||
14 | 17 | ||
15 | libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ | 18 | libFbTk_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 |
@@ -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]]]) | ||
23 | AC_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]]]) | ||
33 | AC_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 | ||
40 | fi | ||
41 | |||
42 | if 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 | ||
47 | fi | ||
48 | |||
49 | AC_PATH_PROG(PKG_CONFIG, pkg-config, no) | ||
50 | if test "x$PKG_CONFIG" = "xno" ; then | ||
51 | ifelse([$2], , :, [$2]) | ||
52 | else | ||
53 | XFT_CFLAGS=`$PKG_CONFIG $xftconf_args --cflags xft` | ||
54 | XFT_LIBS=`$PKG_CONFIG $xftconf_args --libs xft` | ||
55 | ifelse([$1], , :, [$1]) | ||
56 | fi | ||
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 | ||
62 | AC_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 | |||
78 | if 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 | ) | ||
88 | else | ||
89 | AC_MSG_RESULT(no) | ||
90 | [$3] | ||
91 | fi | ||
92 | |||
93 | CFLAGS="$CFLAGS $XFT_CFLAGS" | ||
94 | CXXFLAGS="$CXXFLAGS $XFT_CFLAGS" | ||
95 | LIBS="$LIBS $XFT_LIBS" | ||
96 | |||
97 | ]) | ||