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

1023 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Doug Torrance
a17d131da3 Remove apostrophes from instances of possessive "its".
I noticed one instance of this while looking at the code the other day,
and after a quick grep, realized it happened a *lot*!  One of the many
frustrating things about the English language is that we use apostrophes
to make pretty much everything possessive *except* the pronoun "it".
In that case, we use "its".  "It's" is reserved for the contraction
meaning "it is" or "it has".
2020-04-09 09:05:50 +01:00
Rodolfo García Peñas (kix)
95561fba08 wtextfield.c: Removed multiple warnings
This patch removes the implicit-fallthrough warnings for GCC7. Just add the FALLTHRU comment.
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
a0b223263e wtext.c Remove warnings
This patch removes the FALLTHRU warnings in wtext.c. Only includes the comments for GCC7.

wtext.c: In function ‘handleActionEvents’:
wtext.c:2508:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (event->xbutton.button == Button2) {
      ^
wtext.c:2547:2: note: here
  case ButtonRelease:
  ^~~~
wtext.c: In function ‘handleTextKeyPress’:
wtext.c:2307:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
   *buffer = '\n';
   ~~~~~~~~^~~~~~
wtext.c:2308:2: note: here
  default:
  ^~~~~~~

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)
2555413838 wruler.c Remove format-truncation warning
This patch removes the format-truncation error. The warning is because c has size of 3, but using "%d" is not possible to store the value.

wruler.c: In function ‘paintRuler.part.0’:
wruler.c:184:28: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 3 [-Wformat-truncation=]
    snprintf(c, sizeof(c), "%d", ++j);
                            ^~
wruler.c:184:27: note: directive argument in the range [1, 2147483647]
    snprintf(c, sizeof(c), "%d", ++j);
                           ^~~~
wruler.c:184:4: note: ‘snprintf’ output between 2 and 11 bytes into a destination of size 3
    snprintf(c, sizeof(c), "%d", ++j);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The value "j" is the result of "m < w". w is the result of rPtr->view->size.width - rPtr->margins.left;, and both variables are unsigned int. So the value for w is an unsigned int and m is related to i. m cannot be greater of unsigned int.

	i = j = m = 0;
	w = rPtr->view->size.width - rPtr->margins.left;
	while (m < w) {
		XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
			  rPtr->fgGC, rPtr->margins.left + m, 23, rPtr->margins.left + m, marks[i % 8] + 23);
		if (i != 0 && i % 8 == 0) {
			snprintf(c, sizeof(c), "%hu", ++j);
			WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
				     rPtr->font, rPtr->margins.left + 2 + m, 26, c, 2);
		}
		m = (++i) * 10;
	}

The printf modifier should be unsigned int.

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)
3e3f06a7be widgets.c Removes implicit-fallthrough warning
This patch removes this warning:

widgets.c: In function `renderPixmap':
widgets.c:385:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
     if (mask)
        ^
widgets.c:388:4: note: here
    case '.':
    ^~~~

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)
1f80c82091 wcolorpanel.c Removed hsbInit warnings
This patch removes these warnings in the hsbInit function.

wcolorpanel.c: In function ‘hsbInit’:
wcolorpanel.c:3456:16: warning: ‘%u’ directive writing between 1 and 5 bytes into a region of size 4 [-Wformat-overflow=]
  sprintf(tmp, "%d", value[0]);
                ^~
wcolorpanel.c:3456:15: note: directive argument in the range [0, 65535]
  sprintf(tmp, "%d", value[0]);
               ^~~~
wcolorpanel.c:3456:2: note: ‘sprintf’ output between 2 and 6 bytes into a destination of size 4
  sprintf(tmp, "%d", value[0]);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

The problem is that the hue variable in the RHSVColor struct. This variable is not an integer, is a shor variable, so using the printf using the "%d" modifier spects an integer. Using a "%hu" prints a unsigned short value.

typedef struct RHSVColor {
    unsigned short hue;	       /* 0-359 */
    unsigned char saturation;      /* 0-255 */
    unsigned char value;	       /* 0-255 */
} RHSVColor;
2019-06-20 22:04:31 +01:00
Rodolfo García Peñas (kix)
fb5f6c30c0 wcolorpanel.c: Remove warning in rgbIntToChar
This patch removes this warning. The default case should not be used.

wcolorpanel.c: In function ‘rgbIntToChar’:
wcolorpanel.c:2392:2: warning: ‘format’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  sprintf(tmp, format, value[1]);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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)
972d85610a wcolorpanel.c Avoid compiler warning
This patch removes this warning. The patch adds a switch case that never should happend.

wcolorpanel.c: In function ‘rgbInit’:
wcolorpanel.c:3403:2: warning: ‘format’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  sprintf(tmp, format, panel->color.rgb.green);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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)
f0f95165e4 WINGs/selection.c Removed compiler warning
This patch removes this warning:

selection.c:265:64: warning: cast between incompatible function types from ‘int (*)(void *)’ to ‘void (*)(void *)’ [-Wcast-function-type]
  wdata = WMCreateDataWithBytesNoCopy((void *) data, len * bpi, (WMFreeDataProc *) XFree);

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2019-06-20 22:04:31 +01:00
Tim Taenny
5ab9b7c6be Renamed the ScaleX/Y macros and their local variables
The names of the macros and the local variables that they use
have been changed to make them less "user-space" like.

    ScaleX -> WMScaleX
    ScaleY -> WMScaleY
    fw     -> wmScaleWidth
    fh     -> wmScaleHeight
2019-06-19 18:06:53 +01:00
Tim Taenny
1e490f8233 Adjusted scale factors in ScaleX and ScaleY macros
The scale factors in the macros were based on the assumption that
the default font size was 11. But the actual default font size is
12. This value is specified as DEFAULT_FONT_SIZE in
WINGS/configuration.c.
2019-06-19 18:06:53 +01:00
Tim Taenny
ba3df2599d Use fixed font size in original WMCreate*Panel functions
Instead of just assuming that the size of the system font has not
been changed by the user, the WMCreateAlertPanel,
WMCreateInputPanel and WMCreateGenericPanel functions now use a
fixed default font size of 12, so that changing the system font's
size in WPrefs.app does not break the fixed layouts of these panels.
("12" is specified as DEFAULT_FONT_SIZE in WINGS/configuration.c)
2019-06-19 18:06:53 +01:00
Tim Taenny
c803218ed1 New functions for the creation of scaled panels (WMCreateScaled*Panel)
To prevent breaking applications depending on the static layout
behavior of the WMCreateAlertPanel and WMCreateInputPanel functions
in WINGs, the scaling functionality has been moved to the new
functions WMCreateScaledAlertPanel and WMCreateScaledInputPanel.

The system dialogs (wMessageDialog, wExitDialog, etc.) now use the
new functions, thus keeping the improved layout introduced in the
previous patches.
2019-06-19 18:06:53 +01:00
Tim Taenny
f9236c8d20 Improved layout of the Input Panels
Instead of relying on static pixel values for position and size of
the widgets, the input panels now scale their widgets based on the
selected system font size.
2019-06-12 23:42:27 +01:00
Tim Taenny
26bb94a8e7 Improved layout of the Alert Panels
Instead of relying on static pixel values for position and size of
the widgets, the alert panels now scale their widgets based on the
selected system font size.
2019-06-12 23:42:27 +01:00
Tim Taenny
b185d46286 Added ScaleX and ScaleY macros to WINGs
To reduce code duplication the ScaleX and ScaleY macros have been
moved to WUtil.h. Along with the function WMGetScaleBaseFromSystemFont
these macros can be used in all panels to scale the widgets based on
the current system font size instead of giving fixed pixel sizes which
messes up the panels if a larger system font is selected in WPrefs.

Use the macros in the following way:

    instead of   WMResizeWidget(widget, 128, 64);
                 WMMoveWidget(widget, 32, 32);

    use          int fw, fh;
                 WMGetScaleBaseFromSystemFont(scr->wmscreen, &fw, &fh);
                 WMResizeWidget(widget, ScaleX(128), ScaleY(64));
                 WMMoveWidget(widget, ScaleX(32), ScaleY(32));
2019-06-12 23:42:27 +01:00
Christophe CURIS
8606ae9a83 WINGs: simplify code
It looks like the original code was expecting the side effect of specifying
a length in the %d to smartly truncate the number, which it does not.
The new code has the same behaviour without extra complexity.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2019-02-22 16:08:36 +00:00
Doug Torrance
738a78b3e2 Replace GNUSTEP_USER_ROOT environment variable with WMAKER_USER_ROOT
As reported in Debian bug #922284 [1]:

    As evident from the prefix, GNUSTEP_USER_ROOT is a GNUstep variable and
    Window Maker should not set it.  Furthemore, it has been deprecated for
    12 years already.  As of gnustep-make/2.7.0-4 the GNUstep build system
    is configured in strict v2 mode which makes it impossible to compile
    GNUstep software.  In a terminal started from a Window Maker session:

    yavor@aneto:/tmp/gorm.app-1.2.24$ make
    This is gnustep-make 2.7.0. Type 'make print-gnustep-make-help' for help.
    Running in gnustep-make version 2 strict mode.
    rm -f InterfaceBuilder; \
    ln -s GormLib InterfaceBuilder
    /usr/share/GNUstep/Makefiles/config-noarch.make:121: *** GNUSTEP_USER_ROOT
    is obsolete.  Stop.

    It is also impossible to build gnustep-make from pristine upstream
    source:

    yavor@aneto:/tmp$ wget -q
      ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.7.0.tar.gz
    yavor@aneto:/tmp$ tar xzf gnustep-make-2.7.0.tar.gz
    yavor@aneto:/tmp$ cd gnustep-make-2.7.0/
    yavor@aneto:/tmp/gnustep-make-2.7.0$ ./configure
    ...
    yavor@aneto:/tmp/gnustep-make-2.7.0$ make
    config-noarch.make:121: *** GNUSTEP_USER_ROOT is obsolete.  Stop.

    Note that the majority of GNUstep users use Window Maker as their window
    manager and many of them build GNUstep software from source, mostly
    because of the GNUstep Objective-C runtime which depends on Clang
    (Debian packages use GCC and the GCC/GNU runtime).

Our solution is to replace the GNUSTEP_USER_ROOT environment variable with our
own environment variable, WMAKER_USER_ROOT.  This is documented in NEWS.

[1] https://bugs.debian.org/922284
2019-02-17 18:44:33 +00:00
Doug Torrance
6f195b18fc WINGs: WMIsPL* functions return False if proplist is null.
Previously, calls to WMIsPLString, WMIsPLData, WMIsPLArray, and
WMIsPLDictionary would result in a segfault if the argument was null.
This could happen, e.g., if we are checking which type of proplist
was just parsed from a file, but the parsing failed.

These functions now return False in this case.
2017-08-19 11:14:38 +01:00
Doug Torrance
83f0b764e6 WINGs: Set widget background pixmaps before realization.
Previously, when WMSetWidgetBackgroundPixmap() was called prior to
WMRealizeWidget(), no background pixmap was actually set.

This is because while the CWBackPixmap bit is correctly set to 1, the
CWBackPixel bit remains set to 1.  When XCreateWindow() is finally
called during realization, the background pixel takes precendence over the
background pixmap.

We fix this by setting CWBackPixel to 0 when setting CWBackPixmap to 1 and
vice versa.
2017-03-22 09:26:24 +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
Doug Torrance
6fa1c0c009 configure: Add option to specify global defaults directory.
Previously, this was only (partially) possible by redefining the macro
GLOBAL_DEFAULTS_SUBDIR.  This told Window Maker to look for the global
config files in a particular subdirectory of SYSCONFDIR.

However:
* This is undocumented.
* GLOBAL_DEFAULTS_SUBDIR is ignored when installing the config files.  They
  are always installed to SYSCONFDIR/WindowMaker.

To solve these issues, we add a "--with-defsdatadir" option to configure
which allows a user to specify the global defaults directory.
2017-03-10 10:20:58 +00:00
6e4698fe11 Fixed couple of compilator warning and removed unused macros. 2017-02-25 10:19:52 +00:00
Alwin
7fa14a0137 Translations: Frisian language files updated
New entries were translated, and a lot improved.
2016-01-21 13:10:43 -05:00
Amadeusz Sławiński
49e94f9747 Allow using numpad Enter key in dialogs for confirmation
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2015-07-27 18:00:39 +01:00
Alwin
eb1c06d704 New translation into Frisian for Window Maker
This is a complete translation into the Frisian language, mainly
done by translating it from the Dutch language files already in
Window Maker.
2015-06-14 19:36:24 +01:00
Christophe CURIS
ae9cb306ef WINGs: fix non-portable int conversion for printf in font panel size handling
The original code assumed that the (void *) type could be safely converted
to an integer for the printf use, but it is not that simple, as pointed by
gcc when compiling on 32-bits platforms, where pointers do not match
anymore the long (%li) size.

The new code now do the conversions by the rules, so the compiler knows
what is happening and printf always gets the 'int' it expects.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-06-13 11:03:59 -06:00
Christophe CURIS
35068ba2d2 WINGs: ran spell checker on the NEWS file
The command used was:
  aspell --lang=en_GB check WINGs/NEWS

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-06-13 11:03:58 -06:00
Christophe CURIS
1c191f0e66 WINGs: Updated news with the API changes that occured between 0.95.6 and 0.95.7
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-06-13 11:03:58 -06:00
Christophe CURIS
d28edde23e Added some explicit conversion to double precision
When the result of the operation is expected to use double precision, this
patchs adds an explicit conversion to that type to tell the compiler that
this is what we want, and not an unexpected side effect.

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
Alwin
81e51182e5 Translations: Dutch language files updated
New entries were translated, a few improved.
2015-05-18 13:43:34 +01:00
Christophe CURIS
976083f5b9 WINGs: create a new type of Tri-State Switch Button (to doc)
There are some times when we need a Switch Button (aka CheckBox) with more
than 2 states, generally to express check/uncheck/leave-as-is.

This patch extends the Button widget to support the new WBTTriState type,
similar to the existing WBTSwitch except it supports a 3rd state which is
reported to application as '-1'.

The implementation was done in order to not break the binary API. The
version have been incremented in the WINGs header to reflect the change,
but not the version in the 'configure.ac' because that have already been
done in commit c6e323e75d for the next Window Maker release.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-05-15 17:44:50 +01:00
Alwin
495e82fc9a WINGs: trivial fixes in text strings
Fixing typos and/or inconsistencies in error messages. Some
backports for the Dutch .po file.

Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
2015-04-28 09:06:33 -04:00