1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 12:00:31 +01:00
Commit Graph

3817 Commits

Author SHA1 Message Date
John D Pell
7e1cdf2d59 Add definition of directory names used for building paths in common header
The organisation of the file tree for storing application files depends on
a number of directories with a specific name.
This patch puts these names in the generated "config-paths.h" so they can
be shared between WINGs and WindowMaker, and could be user-configured in
the future.
2021-08-10 09:42:43 +01:00
Christophe CURIS
43f0474013 WINGs: Properly mark 'const' more 'char*' in the public API
Because the previous patch brought a (welcome) change in the public API,
seize the opportunity to go further in the improvement.
2021-08-10 09:42:43 +01:00
John D Pell
a079544647 WINGs: Properly mark 'const' some 'char*' in the public API
Update all the callers in our code to deal with the const qualifier
where the compiler reports an issue.
2021-08-10 09:42:43 +01:00
John D Pell
03ec24502d WMaker: Fix logical-not operator in framewin.c
As reported by clang, (!wPreferences.new_style == TS_NEW) inverts the
"wPreferences.new_style" and not the whole expression. Use the appropriate
comparison operator to avoid misunderstanding.
2021-08-10 09:42:43 +01:00
John D Pell
5c90ed9d2d WPrefs: Use wdefaultspathfordomain() to build path to the root menu file
For the Menu edition tab, when building the path to the file that contains
the menu data, rely on wdefaultspathfordomain instead of constructing the
path with many hard-coded names.
2021-08-10 09:42:43 +01:00
John D Pell
735651df55 WMaker: Use wdefaultspathfordomain() to get path for Defaults directory
Instead of constructing path to user's defaults directory with hard-coded
names, just query wdefaultspathfordomain with a blank domain: this returns
the equivalent of "~/GNUstep/Defaults/", yet avoiding problems related to
duplicating strings.
2021-08-10 09:42:43 +01:00
John D Pell
bfab769065 WINGs: Improve search path logic in WMPathForResourceOfType
The man page says environment variables are used, and if they don't exist
it falls back to defaults, yet this was not true in WINGS.

This changes implements the checks for the default paths used when the env
variables are not defined; these default paths have been fixed (+lib) to
match the GNUstep layout ('fhs'), expect for the very last path which keeps
the legacy layout.

For the user Apps folder, rely on wusergnusteppath() (~/GNUstep) to build
the path.

The previous code was only partially functional as the hard-coded paths
did not exist in any of GNUstep standard file system layout and the
GNUSTEP_*_ROOT environment variables were not provided by GNUstep for a
while. This means it would never work no matter how environment variables
were set when using layouts: 'debian', 'fhs', 'next', 'Apple', 'mac',
'fhs-system', or 'standalone'.
2021-08-10 09:42:43 +01:00
John D Pell
c060477d57 WINGs: Simplify use of HAVE_SECURE_GETENV
Define the macro GETENV(x) instead of sprinkling code with #ifdef HAVE_SECURE_GETENV
everytime we want to use it.
2021-08-10 09:42:43 +01:00
Torrance, Douglas
75f133285f Fix segfault in color picker
Previously, we released the color well's color even if it was the same
as the new color.  This eventually resulted in a segfault when calling
WMPaintColorSwatch because we tried calling XFillRectangle with no
display.

We fix this by only releasing/updating the color well's if it differs
from the new color.
2021-06-29 22:32:31 +01:00
Torrance, Douglas
a6ec6a30a3 Use wmkdirhier instead of mkdir to create color config directory
Otherwise, if ~/GNUstep/Library doesn't already exist, then creating
~/GNUstep/Library/Colors will fail.
2021-06-29 22:32:31 +01:00
Christophe CURIS
6afa419b01 Website: Create script to update the list of man pages in the index
It is a good idea to have an Index web page with the list of the man pages
available, but there is a risk to have it outdated, so there is a script to
take care of this for us.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-06-20 22:28:19 +01:00
Christophe CURIS
a2bf67f54c Website: Create script to generate the HTML version of the man pages
When running the 'make website' command, it will call groff to convert the
man pages into HTML and post-process them to get them in the style of the
site, then place them in the Website Git Repository.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-06-20 22:28:19 +01:00
Christophe CURIS
351e05dca9 Configure: Add a maintainer option to prepare generation of HTML for the website
When the new configure option '--with-web-repo' is used, the new target
'make website' becomes available and will generate HTML pages to be placed
in the Homepage Repository.

This patch does not generate any content yet but it prepares the skeleton
to handle everything.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-06-05 23:54:15 +01:00
Christophe CURIS
ae78e88eef Repair compilation when Pango support is enabled
It seems there have been changes in the way Pango's header files are
installed in recent versions, probably to allow having multiple versions
together on a system.

Because one public header from WINGs has to include Pango's header, we must
include the search path provided by Pango into our WINGs search path that
are returned by pkg-config (the .pc file).

They are then also added to WindowMaker and WPrefs which use the header but
can't rely on the path from the .pc file which has not been installed yet.

Reported-by: Carlos R. Mafra <crmafra@gmail.com>
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-29 23:55:10 +01:00
Christophe CURIS
f049635fa5 Configure: Rewrite the detection for Pango library
Make use of the standard macro for PKG_CONFIG; the default behaviour is now
to use Pango if present, instead of requiring explicit user request, yet
still not making it mandatory.

The detection code was moved to a macro to keep the configure.ac script
(relatively) small, and consistent with what is done for most other libs.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-29 20:15:09 +01:00
Doug Torrance
4221e30bd2 Convert WPrefs.app/po/README from iso-8859-1 to utf-8 2021-05-25 22:12:23 -04:00
Doug Torrance
71558f4ce3 Convert WindowMaker/README from iso-8859-1 to utf-8 2021-05-25 22:10:15 -04:00
Doug Torrance
4b61081353 Convert po/README from iso-8859-1 to utf-8 2021-05-25 22:05:30 -04:00
Christophe CURIS
4138c57631 Configure: Rewrite the macro for checking Xft2 version
The original macro used over-complicated things, like:
 - useless uses of 'eval',
 - split AC_CACHE_CHECK construct (AC_MSG_CHECKING + AC_CACHE_VAL +
AC_MSG_RESULT)
 - dubious variable name (CPPFLAGS_old, which is not the "old" value but
the "saved" value for a temporary change)
 - variable CPPFLAGS was changed at wrong hierarchy level
 - calculate the integer value for XFT_VERSION in m4 instead generating
shell commands that had to do it on user side
 - indentation was missing

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-22 20:00:41 +01:00
Christophe CURIS
0bbb122b94 Configure: Rewrite detection for Xft2 to properly use PKG_CONFIG macro
The goal is to use standard macros, which make code easier to maintain
(smaller, more consistent). We still keep the legacy "xfg-config" method
because we don't want to drop support for old hardware/software.

A side effect is the change in the name of the variables for the makefile,
but this goes in favour of consistency.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-22 20:00:41 +01:00
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
fbec3a728f wmaker: Do not allocate memory for a temporary string for the Window Shortcut menu
When creating the list of possible shortcut for windows to populate the
window menu, a temporary buffer was allocated to hold that string.

As this allocation participates to memory fragmentation, this patch makes
use of storage on the stack instead which is also faster.

Took opportunity to include the shortcut number (%i) in the string to be
translated, because it is unlikely that adding that number at the end of
the string is right in all languages. Updated french translation because
it is the only one I am confident with.

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
0ac6827a9b wmmenugen: Fix memory leaks when parsing menu in wmconfig format
As reported by Coverity (CID #50181, #50182 and #50183) the strings allocated by parse_wmconfig_line were not freed after use.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
f030ab7664 wmmenugen: Fix memory leaks in XDG menu generation when getting locale-dependant name
As reported by Coverity as CID #50142, #50143, #50144 and #50145, all the
strings allocated by 'parse_locale' were never freed.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
2a8fc1df9a wmmenugen: Fix memory leak when parsing names for menus in XDG format
As reported by Coverity (CID #50146), if the function getLocalizedStringValue
returns without matching the entry, the storage for the entry's locale was
leaked.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
296456f361 wmmenugen: Fix memory leak when parsing categories in an XDG menu
Reported by Coverity (CID #50147)

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
8e47ca8e62 WPrefs: Add check for invalid OPEN_MENU/EXEC in PL-Menu to avoid potential crash
As reported by Coverity (CID #50047, #50048), if the proplist is incorrect
and has an OPEN_MENU or (SH)EXEC command without its arguments, we did
dereference a NULL pointer.
Now we simply return the NULL value, appropriate to have the caller of the
function issue a message.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
29cf48b934 WPrefs: Provide fall-back colour in the case of colour name not found
As reported by Coverity (CID #331571), we did not check the return value of
the call to XParseColor. If the function is given a colour name that it
does not know, we would return an uninitialised colour.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
816fa00625 WUtil: Make sure wmalloc/wrealloc won't fail because of the abort handler
As pointed by Coverity (#50074), despite the expected behaviour that
'wmalloc' should never return NULL, it may still happen if an abort handler
set by user (with wsetabort) does not call exit() as expected. In such
case we make sure the NULL pointer dereference does not happen inside
WINGs code because we assume it is a known user choice.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
6ebec0bb9f WUtil: Fix non-closed file handle in WMWritePropListToFile
As reported by Coverity (CID #50129), in case of error during the write
operation, the failure path does include close of the file handle. In
addition to the resource leak, this may be a problem if the application
were to make a second try on the same file.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
7c50721747 WPrefs: Fix memory leak in Expert tab
As reported by Coverity (CID #331553), we leak the allocated string
returned by 'WMGetTextFieldText'

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
4559cbbccc WPrefs: Fix memory leak in the Menu tab
As reported by Coverity (CID #331559), the call to 'wfindfile' replaces
the value for variable 'path' but we did not free its previous content.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
e828e1c074 Fix use-after-free error in wIconStore reported by Coverity
The function always returns the filename where the icon have been saved,
but in the case where the save operation failed we would free the memory
for that file name, yet still return this pointer like if it were valid.

Took opportunity to remove redundant free(path) which is done a couple
lines later, because redundancy is a source of problem for code
maintenance.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
97a9300aa4 Fix memory leak reported by Coverity
As reported in CID #331577, we re-use the variable 'tmp' without freeing
the previously allocated pointer.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
fd56152202 WPrefs: fix memory leak and potential buffer overflow
Coverity pointed that the "text" returned by WMGetTextFieldText was never
freed (CID #331578, because WMSetTextFieldText does its own copy, it does
not take the pointer as-is).

By looking at the code, there is also a potential buffer overflow because
the buffer alloc'd for "value" is sized for the exact number of digits
before increase, but the +delta can make the number use more digits so we
may write past the end of original buffer.
We write to a stack-allocated one, so it does not cost anything and does
not participates to memory fragmentation.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
58862300f9 WINGs: Fix invalid handling of Blue in the HSV conversion in ColorPanel widget
Because of a minor bug, when pure blue was chosen in RGB in the ColorPanel,
the conversion to HSV would mistreat it as white and resets its hue,
leading to possible user annoyance.
2021-05-18 17:49:17 +01:00
Christophe CURIS
1612d2f345 WINGs: increase temporary buffer to silence a gcc warning
The code limits the integer number to 0..359 so we need 4 bytes to store
that, but that require too complex flow processing for compilers to deduce
it.

It does not cost to increase the temporary buffer to the minimum size
requested by GCC, so let's do this, because spurious warnings can
potentially divert us from more important ones.

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
Christophe CURIS
8aecba27d1 Fix usage of float constant reported by gcc
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Christophe CURIS
fc63d72032 WINGs: Fix incorrect use of macro USE_PANGO in installed header
The header "WINGsP.h" needs different behaviour depending on whether the
support for Pango was enabled or not. But the related macro USE_PANGO is
defined by WindowMaker's configure, and after this header have been
installed the macro is no more valid.

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

As a side effect of being now generated, the include paths in the makefile
have been updated to include build-dir too, because for users doing an
out-of-tree build the generated file (that is used during compilation) is
placed in the build-dir.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2021-05-18 17:49:17 +01:00
Xander
eb2a9d97a2 Make dock dots scalable
This patch makes the three dots in the dock change their size when bigger icon size is used.
The logic here is such that the dots are scaled only when a certain icon size is reached;
for instance, the dots will remain unchanged if icon size is less than 128x128 px, and will
be twice as big if it's set to a value from 128x128 to 184x184 px. The get_dot_mult() func
calculates and returns the scale multiplier. In the draw_dot() func, XDrawLine() and
XDrawPoint() were replaced with XFillRectangle() because those funcs do not allow their
result to be scalable. This patch does not require additional icon size values (those bigger
than 96x96 px) to exist, but makes no use without them.
2021-05-07 18:03:19 +01:00