1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00
Commit Graph

326 Commits

Author SHA1 Message Date
Christophe CURIS
0e274dc979 WRaster: Fix incorrect use of macro USE_XSHM in installed header
The header "wraster.h" needs different behaviour depending on whether the
support for X Shared Memory extension was enabled or not; but the related
macro USE_XSHM is defined by WindowMaker's configure. After this header
have been installed, the macro is no more useable.

This patch makes the "wraster.h" a generated file, so it will be different
depending on USE_XSHM, but will not make use of the macro itself.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:50:43 +01:00
Christophe CURIS
4dfb0dd059 WRaster: Create french translation to have at least one
The translation check would complain because it does not find any '.po'
files, so I am providing one translation.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
bcb53700d6 WRaster: Improve error messages to provide useful information to user
The original error messages tended to be a bit sparse, now they try to be
a little bit more helpful, and translatable in user's language.

In xutil.c:122, took opportunity fix a problem because calling 'perror'
after other function which are likely to have changed the errno is likely
to provide a wrong error string.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
e5f7ef23a6 WRaster: Made a few messages translatable
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
70f89fd9c5 WRaster: Add initialisation for locale support
Because the library does not have an initialisation function, we need to
rely on an automatic called-on-load mechanism, which is provided through
a compiler attribute 'constructor'.

However, as the project aims to still compile on old hard/software, we
include a check in 'configure' to ensure it works, and if not use the
legacy solution.

Note: Because we introduce a new DEFINE, the 'config.h.in' needs to be
regenerated, otherwise you may get a compilation error in wrlib. This is
done by re-running './autogen.sh'

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
19202fd2db WRaster: Create header for i18n helper functions
This patch is just adding a single header, but because it also modifies
all the C files to add the #include, it was made as a patch on its own to
ease review.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
aadd694a6b WRaster: Create structure to make the library translatable
The library did not propose the mechanisms to be translated, this patch is
creating the structure in autoconf/automake and the translation directory
so its messages can be also translated.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
944bb49997 wrlib: Add compiler attributes to the API functions
With proper attributes, the compiler is able to do some extra checks on
user side to make code safer and/or better optimised.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
f2cd2c9f03 WRaster: Properly set file's mtime in the cache when loading an image
The library maintains a cache to not reload a file that was previously
loaded. In order to still reload an image in case its file would have
changed in the meantime, the cache saves the file's modification time.

As reported by Coverity (CID #331576) the 'stat' function was not on the
execution path the first time an image is loaded, which means the cache
information is populated with junk data. This could lead to an image not
being reloaded for example.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
d125f80dee WRaster: Stop parsing number in PPM file if invalid syntax is found
When the function 'pm_getuint' is reading a number, it prints an error
message if it encounters a non-digit number, yet it still enters the
processing loop which will cause an invalid number to be calculated.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
920c6d16b1 wraster: Remove duplicate code
Duplicating things makes maintenance error-prone, which is not a good idea.
In case the abort procedure would need an update, it would be easy then
to forget some place, leading to leaks, if not worse.

Beside, goto is not as bad as academics would like people to believe, when
it is used correctly (and this case is one of them).
The name for the label was given an explicit meaning to make code easy to
understand.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Doug Torrance
3022edd060 wrlib: Fix typo in macro containing ImageMagick version
It's USE_MAGICK, not USE_MAGIC.  Also, we wrap the if/else statement
in an ifdef.  This doesn't really affect anything since load_magick.c
won't be compiled if USE_MAGICK is undefined because of an if statement
in the Makefile.  But in the off chance that it is somehow, then we will
try to load a nonexistent version 6 header file since USE_MAGICK will
be interprested as 0 and 0 < 7 is true.
2020-04-19 07:58:28 +01:00
Doug Torrance
dfa92906c0 wrlib: Compile with either ImageMagick 6 and 7
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
2020-04-18 19:49:25 +01:00
Doug Torrance
54a24ab6f7 Remove trailing whitespace.
Also, the script is a one-liner, stolen from [1]:

ack --print0 -l '[ \t]+$' | xargs -0 -n1 perl -pi -e 's/[ \t]+$//'

[1]
https://stackoverflow.com/questions/149057/how-to-remove-trailing-whitespace-of-all-files-recursively
2020-04-09 14:28:09 +01:00
David Maciejak
a215869067 wrlib: Fixed warning msg using libpng
Call png_set_interlace_handling() to get rid of the warning message "libpng warning: Interlace handling should be turned on when using png_read_image"
2020-03-27 09:00:37 +00:00
Rodolfo García Peñas (kix)
6a044fe5ae load_jpeg.c Return NULL
The image is NULL, we can return NULL here.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
6dd1498f7c load_jpeg.c Style
This patch is just coding style. Removes some empty lines,...

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
090b761fde load_jpeg.c Removed dead code
This patch removes the code not used. Because the if block
check that buffer[0] is NULL, then, we don't need check it
again inside.

Image is not used yet, so is NULL. We can return NULL.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
49db946aa2 load_jpeg.c Clean code
This patch returns NULL, because the variable image is not used yet.

The patch also removes three lines:

- buffer[0] = NULL;       /* Initialize pointer to avoid spurious free in cleanup code */
  RErrorCode = RERR_BADIMAGEFILE;
  jpeg_destroy_decompress(&cinfo);
  fclose(file);
- if (buffer[0])
-    free(buffer[0]);

buffer is a local variable. The malloc is not used yet. So:

- We set the value to NULL, then check if is null to call free(). So the free()
  call is never used. We can remove the last too lines.
- We don't need set now to NULL, because the variable is empty (the
  initializated (or not) value is not used, and is destroyed as local variable
  when we returns, just one line later.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
a2cc89dd3d load_jpeg.c Removed goto
This patch removes the goto call. I copied the code after the bye: label and
I paste it in the goto-calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
bf644338e4 gradient.c Removed implicit-fallthrough warnings
This patch adds the comments to remove the warnings.

gradient.c: In function ‘renderGradientWidth’:
gradient.c:162:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
   *ptr++ = b;
   ~~~~~~~^~~
gradient.c:163:2: note: here
  case 2:
  ^~~~
gradient.c:166:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
   *ptr++ = b;
   ~~~~~~~^~~
gradient.c:167:2: note: here
  case 1:
  ^~~~

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Christophe CURIS
e2cfed3377 Do not stop compilation if library Xmu is not found
We use only 1 function from this library, and it is in a case that should
be rare nowadays: displays with indexed color.
This commit makes it acceptable to compile if the library is missing.
2019-05-04 14:50:48 +01:00
Stig-Ørjan Smelror
1dace5699f Drop support for Imagemagick version < 7
Had to do a few modifications to get WM to build with Imagemagick 7.

Attached is the diff from the latest git checkout.

Cheers,
Stig
2019-02-12 19:14:01 +00:00
Doug Torrance
cea5f6107c WINGs/wrlib: Remove deprecated get-*-flags scripts.
These have been replaced by pkg-config.  Christophe left a note in January
2015 to remove them, and this time has now passed.
2017-03-12 00:12:18 +00:00
Christophe CURIS
325dc85891 wrlib: fixed gcc version needed for deprecated attribute support
The support for a custom message in the attribute 'deprecated' have been
added only from gcc 4.5.0 and not 4.0, so the check was updated accordingly
to avoid compilation error with version 4.0 to 4.4.

Reported-by: Josip Deanovic <djosip+news@linuxpages.net>
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-06-19 21:11:52 +01:00
Christophe CURIS
177c5095e9 WRaster: fix unused variable warning when XShm extention is not enabled
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-06-13 11:03:59 -06:00
Christophe CURIS
b64d9e6be0 wrlib: changed Gamma Correction calculation to use single-precision float
The original code was using double precision floating point to perform the
color corrections for the creation of the standard colormap. This precision
is not necessary because color coding is 16 bits anyway, and on some
architecture the double precision comes with a cost.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-05-24 23:25:57 +01:00
Christophe CURIS
79a95d7173 Fixed floating point constants defined as double but expected as float
To preserve the accuracy of the operation, the C standard request that the
mathematical operation is performed using double precision, but in many
case this is not necessary so this patch fixes a few constants to avoid
that conversion.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-05-24 23:25:57 +01:00
Christophe CURIS
ba8cd2abe4 Handle NULL pointer as good as possible (Coverity #50099)
As pointed by Coverity, in the "Configuration" panel of WPrefs there are
some images loaded, but if the images cannot be loaded correctly then the
returned NULL pointer can crash the application as it is dereferenced in
further function calls.

To solve this case, this patch is adding a NULL pointer check in the
functions RScaleImage (wrlib) and WMCreatePixmapFromRImage (WINGs), so both
can accept that NULL pointer to also return NULL, which means the existing
check for "icon == NULL" in the WPrefs code will be useful.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-04-25 07:53:06 -04:00
Christophe CURIS
efdb29762d wrlib: mark the script 'get-wraster-flags' as deprecated
This script should have been removed a long time ago, in favour of
pkg-config which has to be present anyway to compile Window Maker.

This patch makes the script print a warning about it, and now calls itself
pkg-config, instead of being generated; the man page was also updated
accordingly (and spell-checked).

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-04-18 19:31:10 +01:00
Christophe CURIS
d458304610 wrlib: generate automatically the list of symbols to keep from the API header
Instead of having to maintain manually the map file for LD with the list of
symbols that we want to keep in the WRaster library (the purpose is to hide
internal symbols), this patch implements a script that parses the public
API header and extracts automatically the list of names that are supposed
to be visible to the user.

The goal is to reduce possible human errors, like for example the function
RCombineAlpha that was forgotten from the list, yet still keep the map file
feature which is considered a good practice (it reduces the risk for name
clash and the risk of mis-use of internal stuff from the library).

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-01-05 15:28:44 +00:00
Christophe CURIS
4799df5506 replaced all local definitions of PI by a single one
For code maintainability, it is better to have a single definition of the
constant than many ones dispatched in many places. In addition, we try to
count on the constant M_PI that can be defined by the header <math.h> if
possible because it may have the best accuracy for the platform.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-12-10 10:19:19 +00:00
David Maciejak
fa4d50a0ca wrlib: Merge some duplicate code when allocating color
This patch is adding a static function named allocateColor to merge
some duplicate code.
2014-12-10 10:19:18 +00:00
Christophe CURIS
47ac986b53 Make sub-directories visible the automake's "dist*" targets
We have a few directories with source codes that we tell configure to
prepare, but we do not actually want them built during normal operations
(tests and examples only).

However, there are some special targets brought by automake which still
need to see them, so this patch adds these directories to the list, but
only for these rules, we keep them unvisited by the normal build process.

The wanted side effect of this is that now "make distcheck" works untill
the end as expectable.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-12-07 09:52:21 +00:00
Christophe CURIS
7d09b2c04f wrlib: add support for release 5.1.0 of the libgif
As reported by Andrew, the compilation of the WRaster broke because
there was an API change in libgif v5.1 versus the v5.0 (something had been
forgotten for DGifCloseFile to be easily used in wrappers for dynamic
languages).

Now, if we have detected that we're in 5.x release, we use the GIFLIB_MINOR
macro to see what the function prototype is (this macro was introduced only
in 4.1.6 so we cannot fully rely on it to detect the version of the
library).

The possible error code is not used because at the place we use the
function we would not be able do do anything more meaningful with it.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-11-02 13:08:59 +01:00
Milan Čermák
1748a18380 wrlib: fix usage of deprecated attribute for gcc 3.x
It seems that the argument to the attribute 'deprecated' is a novelty of
gcc 4.x, the attribute introduced in gcc 3.x did not take any parameter.

As Solaris 10 is providing gcc 3.4.3, this patch updates the detection in
the public API header to make it compile properly.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-11-02 13:08:59 +01:00
David Maciejak
88d9deea83 wrlib: merge gradient duplicate code
This patch is adding a new static function named renderGradientWidth
to factorize some code.

Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
2014-11-02 12:50:02 +01:00
David Maciejak
1e06e1e29b wrlib: remove duplicate code from xpm support
This patch is removing the duplicate code by
using functions create_rimage_xpm and is_xpm_error
previously created.
2014-08-26 17:55:34 +01:00
David Maciejak
4005557bb3 wrlib: add merged code for xpm support in 2 distinct functions
This patch is adding some merged code in
create_rimage_from_xpm and is_xpm_error fonctions.
2014-08-26 17:55:34 +01:00
David Maciejak
fe177c6966 wrlib: fix RCreateImageFromDrawable error log msg
This patch is fixing the name of the function from the log message.
2014-07-27 10:07:28 -06:00
David Maciejak
d0bb7ae0c8 wrlib/tests: fix testgrad memory leak
cppcheck is reporting:
[wrlib/tests/testgrad.c:148]: (error) Memory leak: color_name

but seems some other variables were never freed.
This patch is cleaning them property.
2014-07-27 09:41:38 -06:00
Christophe CURIS
16045a6be4 Increment versions of libraries for next release due to public API Changes
WRaster:
- new function 'RShutdown'
- removed flag 'optimize_for_speed' from RContext
- new functions '...(operate_xxx)', '...(flip_image)'

WUtil:
- new function 'wutil_shutdown'
- new macro 'wlengthof'

WINGs:
- new function 'WMReleaseApplication'
- new function 'WMCreateScaledBlendedPixmapFromFile'

(And maybe a few more I missed)

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-20 15:31:57 +01:00
Christophe CURIS
9740c02403 wrlib: re-introduce the optimize_for_speed flag for binary compatibility
The commit #d1f9b801 removed it because the code behind it is actually
useless, unfortunately removing the flag itself from the structure is
breaking the compatibility of the API.

To avoid problems, this patch re-introduces the flag in the structure, but
not the code behind it so it is useless, and adds an attribute so that gcc
will report its use as deprecated, to help application migration.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-20 15:31:57 +01:00
Christophe CURIS
654dcfeb28 wrlib: merged both R*FlipImage function into one for the public API
It is generally not a good idea to have an API with a high number of
functions because it adds complexity for user and for maintainability,
so both function have been "merged" into a single RFlipImage with
a parameter to specify what flip is expected.

As a bonus, the function can perform both flips at once if wanted.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-06 01:07:55 +01:00
Christophe CURIS
cd29983e03 wrlib: do not create an alpha channel if the original image did not have it in RFlipImage
As it does not cost anything in the current code to not add this channel,
it is then probably a good idea to keep the output image with the same
format as the input image, this avoid wasting +33% of memory for something
that may be at best unused and at worst will induce extra cost when
manipulating the image.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-06 01:07:55 +01:00
Christophe CURIS
f2dea1b840 wrlib: code refactoring in RFlipImage functions
Instead of calling all variables with variants of 'image', changed
the name to reflect what image it is about for clarity.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-06 01:07:55 +01:00
Christophe CURIS
f85066a19e wrlib: move fixed angle rotation code to dedicated functions
The function RRotateImage contains code to handle efficiently the 4 simple
angles 0, 90, 180 and 270 degrees, which makes it a long function.

This patch separate the code for the different cases into dedicated
functions so the main function's code ends up being simple (aka: easier to
understand/review/maintain).

As a side effect, the function for the 180 degree function is not static
because it can be reused to flip an image both horizontally and vertically.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-07-06 01:07:55 +01:00
Christophe CURIS
a772f2797d wrlib: add explicit type definition in API to allow compiler Type Checks (3/3)
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.

This patch adds the type for the gradient style for RRender*Gradient.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-06-15 19:45:20 +01:00
Christophe CURIS
bc4084e679 wrlib: add explicit type definition in API to allow compiler Type Checks (2/3)
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.

This patch adds the types for the drawing operations used by the functions
who drawing shapes into an RImage.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-06-15 19:45:20 +01:00
Christophe CURIS
eb3f0b12f8 wrlib: add explicit type definition in API to allow compiler Type Checks (1/3)
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.

This patch adds types for the configuration fields in the RContextAttributes
structure.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-06-15 19:45:20 +01:00