[PATCH 1/3] wrlib: Compile with either ImageMagick 6 and 7

2 views
Skip to first unread message

Doug Torrance

unread,
Apr 18, 2020, 2:28:56 PM4/18/20
to wmake...@googlegroups.com, Doug Torrance
We dropped ImageMagick 6 support in 0.95.9. However, ImageMagick 6 is
still widespread (e.g., ImageMagick 7 has not been packaged in Debian
yet), and upstream plans on maintaining it until at least 2028 [1].

In this patch, we detect the version of the MagickWand library installed
on the user's system and include the appropriate header file when
building wrlib.

Note: I've only tested this with ImageMagick 6, so I'd appreciate
confirmation that it works with ImageMagick 7.

[1] https://github.com/ImageMagick/ImageMagick6/blob/master/NEWS.txt
---
m4/wm_imgfmt_check.m4 | 10 +++++++---
wrlib/load_magick.c | 4 ++++
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/m4/wm_imgfmt_check.m4 b/m4/wm_imgfmt_check.m4
index b5adf6f4..2236e6cc 100644
--- a/m4/wm_imgfmt_check.m4
+++ b/m4/wm_imgfmt_check.m4
@@ -313,8 +313,12 @@ AS_IF([test "x$enable_magick" = "xno"],
dnl The library was found, check if header is available and compiles
wm_save_CFLAGS="$CFLAGS"
AS_IF([wm_fn_lib_try_compile "MagickWand/MagickWand.h" "MagickWand *wand;" "wand = NewMagickWand()" "$wm_cv_libchk_magick_cflags"],
- [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % $wm_cv_libchk_magick_libs"],
- [AC_MSG_ERROR([found MagickWand library but could not compile its header])])
+ [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % $wm_cv_libchk_magick_libs"
+ wm_cv_libchk_mgick_version=7],
+ [wm_fn_lib_try_compile "wand/magick_wand.h" "MagickWand *wand;" "wand = NewMagickWand()" "$wm_cv_libchk_magick_cflags"],
+ [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % $wm_cv_libchk_magick_libs"
+ wm_cv_libchk_magick_version=6],
+ [AC_MSG_ERROR([found MagickWand library but could not compile its header])])
CFLAGS="$wm_save_CFLAGS"])dnl
])
AS_IF([test "x$wm_cv_libchk_magick" = "xno"],
@@ -323,7 +327,7 @@ AS_IF([test "x$enable_magick" = "xno"],
[supported_gfx="$supported_gfx Magick"
MAGICKFLAGS=`echo "$wm_cv_libchk_magick" | sed -e 's, *%.*$,,' `
MAGICKLIBS=`echo "$wm_cv_libchk_magick" | sed -e 's,^.*% *,,' `
- AC_DEFINE([USE_MAGICK], [1],
+ AC_DEFINE_UNQUOTED([USE_MAGICK], [$wm_cv_libchk_magick_version],
[defined when MagickWand library with header was found])])
])
AM_CONDITIONAL([USE_MAGICK], [test "x$enable_magick" != "xno"])dnl
diff --git a/wrlib/load_magick.c b/wrlib/load_magick.c
index 1edbebc3..dbbfe92d 100644
--- a/wrlib/load_magick.c
+++ b/wrlib/load_magick.c
@@ -22,7 +22,11 @@

#include "config.h"

+#if USE_MAGIC < 7
+#include <wand/magick_wand.h>
+#else
#include <MagickWand/MagickWand.h>
+#endif

#include "wraster.h"
#include "imgformat.h"
--
2.20.1

Doug Torrance

unread,
Apr 18, 2020, 2:28:56 PM4/18/20
to wmake...@googlegroups.com, Doug Torrance
The abs() function should take an int as argument, but there were
several instances in the code where it was taking an unsigned int or a
double. In these case, we took one of the following approaches:

* If the argument was a double, use fabs() instead.
* If the argument was unsigned and was certainly going to be positive
(i.e,. no subtraction), then drop abs() altogether.
* If the argument was unsigned as result of adding or subtracting signed
and unsigned ints, then we cast all the unsigned ints to signed ints.
---
WPrefs.app/FontSimple.c | 3 ++-
src/menu.c | 4 ++--
src/moveres.c | 4 ++--
src/window.c | 4 ++--
src/xinerama.c | 8 ++++----
5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/WPrefs.app/FontSimple.c b/WPrefs.app/FontSimple.c
index eac0411c..2147b985 100644
--- a/WPrefs.app/FontSimple.c
+++ b/WPrefs.app/FontSimple.c
@@ -22,6 +22,7 @@
#include "WPrefs.h"
#include <unistd.h>
#include <fontconfig/fontconfig.h>
+#include <math.h>

/* workaround for older fontconfig, that doesn't define these constants */
#ifndef FC_WEIGHT_NORMAL
@@ -521,7 +522,7 @@ static void selectedOption(WMWidget * w, void *data)
WMListItem *item = WMGetListItem(panel->sizeL, i);
int distance;

- distance = abs(size - atoi(item->text));
+ distance = fabs(size - atoi(item->text));

if (i == 0 || distance < closest) {
closest = distance;
diff --git a/src/menu.c b/src/menu.c
index 6164e28f..ebdd2b43 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1436,7 +1436,7 @@ static void getScrollAmount(WMenu * menu, int *hamount, int *vamount)

} else if (xroot >= (rect.pos.x + rect.size.width - 2) && menuX2 > (rect.pos.x + rect.size.width - 1)) {
/* scroll to the left */
- *hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2 - rect.pos.x - rect.size.width - 1));
+ *hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2 - rect.pos.x - (int)rect.size.width - 1));

if (*hamount == 0)
*hamount = 1;
@@ -1450,7 +1450,7 @@ static void getScrollAmount(WMenu * menu, int *hamount, int *vamount)

} else if (yroot >= (rect.pos.y + rect.size.height - 2) && menuY2 > (rect.pos.y + rect.size.height - 1)) {
/* scroll up */
- *vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2 - rect.pos.y - rect.size.height - 2));
+ *vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2 - rect.pos.y - (int)rect.size.height - 2));

*vamount = -*vamount;
}
diff --git a/src/moveres.c b/src/moveres.c
index 9f7a91de..4e0d7deb 100644
--- a/src/moveres.c
+++ b/src/moveres.c
@@ -2002,8 +2002,8 @@ static int getResizeDirection(WWindow * wwin, int x, int y, int dy, int flags)
int ydir = (abs(y) < (wwin->client.height / 2)) ? UP : DOWN;

/* How much resize space is allowed */
- int spacew = abs(wwin->client.width / 3);
- int spaceh = abs(wwin->client.height / 3);
+ int spacew = wwin->client.width / 3;
+ int spaceh = wwin->client.height / 3;

/* Determine where x fits */
if ((abs(x) > wwin->client.width/2 - spacew/2) &&
diff --git a/src/window.c b/src/window.c
index 195c3e6a..a276f483 100644
--- a/src/window.c
+++ b/src/window.c
@@ -997,9 +997,9 @@ WWindow *wManageWindow(WScreen *scr, Window window)
int head;

x = transientOwner->frame_x +
- abs((transientOwner->frame->core->width - width) / 2) + offs;
+ abs(((int)transientOwner->frame->core->width - (int)width) / 2) + offs;
y = transientOwner->frame_y +
- abs((transientOwner->frame->core->height - height) / 3) + offs;
+ abs(((int)transientOwner->frame->core->height - (int)height) / 3) + offs;

/* limit transient windows to be inside their parent's head */
rect.pos.x = transientOwner->frame_x;
diff --git a/src/xinerama.c b/src/xinerama.c
index 483046c7..4c0beb2f 100644
--- a/src/xinerama.c
+++ b/src/xinerama.c
@@ -261,28 +261,28 @@ int wGetHeadRelativeToCurrentHead(WScreen *scr, int current_head, int direction)
case DIRECTION_LEFT:
if (rect->pos.x < crect.pos.x) {
found = 1;
- distance = abs((rect->pos.x + rect->size.width)
+ distance = abs((rect->pos.x + (int)rect->size.width)
- crect.pos.x) + abs(rect->pos.y + crect.pos.y);
}
break;
case DIRECTION_RIGHT:
if (rect->pos.x > crect.pos.x) {
found = 1;
- distance = abs((crect.pos.x + crect.size.width)
+ distance = abs((crect.pos.x + (int)crect.size.width)
- rect->pos.x) + abs(rect->pos.y + crect.pos.y);
}
break;
case DIRECTION_UP:
if (rect->pos.y < crect.pos.y) {
found = 1;
- distance = abs((rect->pos.y + rect->size.height)
+ distance = abs((rect->pos.y + (int)rect->size.height)
- crect.pos.y) + abs(rect->pos.x + crect.pos.x);
}
break;
case DIRECTION_DOWN:
if (rect->pos.y > crect.pos.y) {
found = 1;
- distance = abs((crect.pos.y + crect.size.height)
+ distance = abs((crect.pos.y + (int)crect.size.height)
- rect->pos.y) + abs(rect->pos.x + crect.pos.x);
}
break;
--
2.20.1

Doug Torrance

unread,
Apr 18, 2020, 2:28:57 PM4/18/20
to wmake...@googlegroups.com, Doug Torrance
---
debian/changelog | 7 +++++++
debian/wmaker-utils.manpages | 4 ++--
debian/wmaker.manpages | 28 ++++++++++++++--------------
3 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4736fde0..a3528020 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+wmaker (0.95.9-2) unstable; urgency=low
+
+ * Ship manpages from as-installed location (debian/tmp) instead of
+ sourcetree to make dh_missing output more useful.
+
+ -- Andreas Metzler <amet...@debian.org> Sat, 18 Apr 2020 11:30:41 +0200
+
wmaker (0.95.9-1) experimental; urgency=low

[ Doug Torrance ]
diff --git a/debian/wmaker-utils.manpages b/debian/wmaker-utils.manpages
index decf97d7..78ee7371 100644
--- a/debian/wmaker-utils.manpages
+++ b/debian/wmaker-utils.manpages
@@ -1,2 +1,2 @@
-doc/wxcopy.1
-doc/wxpaste.1
+usr/share/man/man1/wxcopy.1
+usr/share/man/man1/wxpaste.1
diff --git a/debian/wmaker.manpages b/debian/wmaker.manpages
index 05636567..72463b59 100644
--- a/debian/wmaker.manpages
+++ b/debian/wmaker.manpages
@@ -1,14 +1,14 @@
-doc/WPrefs.1
-doc/WindowMaker.1
-doc/geticonset.1
-doc/getstyle.1
-doc/seticons.1
-doc/setstyle.1
-doc/wdread.1
-doc/wdwrite.1
-doc/wmagnify.1
-doc/wmaker.1
-doc/wmgenmenu.1
-doc/wmiv.1
-doc/wmmenugen.1
-doc/wmsetbg.1
+usr/share/man/man1/geticonset.1
+usr/share/man/man1/getstyle.1
+usr/share/man/man1/seticons.1
+usr/share/man/man1/setstyle.1
+usr/share/man/man1/wdread.1
+usr/share/man/man1/wdwrite.1
+usr/share/man/man1/WindowMaker.1
+usr/share/man/man1/wmagnify.1
+usr/share/man/man1/wmaker.1
+usr/share/man/man1/wmgenmenu.1
+usr/share/man/man1/wmiv.1
+usr/share/man/man1/wmmenugen.1
+usr/share/man/man1/wmsetbg.1
+usr/share/man/man1/WPrefs.1
--
2.20.1

Reply all
Reply to author
Forward
0 new messages