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

80 Commits

Author SHA1 Message Date
David Maciejak
e2ecfbfd54 Coverity: fix wcolorpanel uninitialized scalar value 2023-03-02 17:04:48 +00:00
John D Pell
bd38778bef Use wuserdatapath() everytime it is applicable
Replace calls to wusergnusteppath() which just append "/Library" by calls
to wuserdatapath().
Take opportunity to replace hardcoded "/WindowMaker" directories with
the existing PACKAGE_TARNAME macro (which comes from autotools).

The choice of 'TARNAME' is because it meant to be used in filename, thus
less likely to have problematic characters than PACKAGE_NAME (meant for
display purpose) and PACKAGE which is there for historical reason.
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
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
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
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
6e4698fe11 Fixed couple of compilator warning and removed unused macros. 2017-02-25 10:19:52 +00:00
Christophe CURIS
032f6587d9 WINGs: remove useless function call in WColorPanel (Coverity #109617)
As reported by Coverity, the function 'customSetPalette' is making a call
to 'WMGetPopUpButtonSelectedItem', but this function does nothing to the
widget but only return a value, which is not used at all, so this patch
removes the call to the function.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-04-25 07:53:06 -04: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
Christophe CURIS
1d0f02f5ca remove a few unused constant for size of buffers
As pointed by gcc, a few constants which contain sizes for buffers are not
used anywhere in the code. This is probably due to code cleanup, where
these buffers have been removed or where size is automatically calculated
by using 'sizeof' instead to reduce risk of bugs.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-12-10 10:19:19 +00:00
Christophe CURIS
3bf2978e63 WINGs: remove macro ABS_SHIFT from the wcolorpanel code
This macro was define a *very* long time ago, in commit
  d98f1fa645
but was not used at that time, and have never been used anywhere since
then.

As the macro does not look like a good idea for performance anyway, get rid
of it before anyone could get tempted to use it.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-12-10 10:19:19 +00:00
Doug Torrance
fc35dfd277 WINGs: Fix decimal/hexadecimal conversion bug in color panel.
In particular, the values were only being converted when the RGB slider was used
to pick the color.  If another tool was used, e.g., the magnifying glass, th e
value was assumed to be decimal, even if hexadecimal was selected.
2014-11-02 13:14:54 +01:00
Alwin
bec572ea8b Make two text strings translatable
Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
2014-11-02 12:50:02 +01:00
Christophe CURIS
ecbee34f3a Removed definitions of dangerous macro RETRY that does not work as expected
This macro supposes that the called lib function clears the 'errno'
variable on success which is not the case. The macro was (luckily) not
used in these file yet, by removing it we make sure it won't happen.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-06-16 20:00:09 +01:00
Christophe CURIS
21c891e669 WINGs: fix possible NULL pointer dereference in WMFreeColorPanel (Coverity #50189)
As pointed by Coverity, the code was checking for NULL pointer to avoid
misbehaviour, but it actually dereferenced the pointer beforehand so the
crash would still happen.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-05-18 23:01:43 +01:00
Christophe CURIS
47b801021c WINGs: fix memory leak in WColorPanel (Coverity #50102, #50103, #50104 and #50133)
As reported by Coverity, the function 'WMGetTextFieldText' allocates memory
to generate the result string, so it has to be freed.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-05-18 23:01:43 +01:00
Christophe CURIS
39181154ab WINGs: changed use of 'if' on panel->rgbState into a switch
This allow compiler to raise a warning in case a new value would be added
to the enum; it also change order in the check so that WMGetButtonSelected
will be called only once, only for the case of interest.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2014-05-18 23:00:15 +01:00
Doug Torrance
a325624b4a WINGs: Option for decimal or hexadecimal RGB colors
The RGB panel of the WINGs color panel lists the red, green, and blue values as
base 10 numbers.  However, hexadecimal numbers are very common when dealing with
RGB colors.  This patch adds two radio buttons at the bottom of the RGB panel
to allow users to choose their preferred number system.

For version 2 of the patch:

Based on Cristophe's suggestions regarding the new decimal/hexadecimal RGB color
feature introduced in commit 83d8ad6, this patch changes rgbState from an int
to an enum, converts some if statements to switches, and changes from atoi to
strtol for the base 10 string conversion.

In addition, the "hexadecimal" text was too wide for the default size of its
radio button for some fonts, so both radio buttons are now resized to fit the
width of the panel.
2014-05-17 15:59:47 +01:00
Rodolfo García Peñas (kix)
3b97d33d0a WINGS: removed compiler warnings.
This patch removes compiler warnings.
2014-02-13 08:55:47 +00:00
Christophe CURIS
26c64933e0 WINGs: Added a few missing const attributes
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2013-12-30 18:11:06 +00:00
Christophe CURIS
6184c955e7 Code refactoring: replaced macro 'SHAPE' by 'USE_XSHAPE' for consistency
The usual way to define a macro in is to name macro with 'USE_xxx' when
they are used to enable a feature 'xxx'

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2013-12-30 18:11:06 +00:00
Christophe CURIS
330fc85e56 Remove some unnecessary code related to XShape usage
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2013-12-30 18:11:05 +00:00
Christophe CURIS
ea74fe8871 WINGs: Marked args as unused for compiler in event callback code
The WINGs toolkit dispatch events on widgets using callbacks, which means
having a fixed argument list for the handling function.

It is then correct to not use all the arguments, so this patch adds the
appropriate stuff to avoid a false report from compiler.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2013-10-19 18:01:36 -03:00
Christophe CURIS
fed1bf4de3 WINGs: Marked args as unused for compiler in Notification callback code
The mechanism of Notifications in the WINGs toolkit is relying on
callbacks to dispatch notifications, which means having a fixed argument
list for the handling function.

It is then correct to not use all the arguments, so this patch adds the
appropriate stuff to avoid a false report from compiler.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2013-10-19 18:01:36 -03:00
Christophe CURIS
fb3d9e65a6 WINGs: Added 'static' attribute to local functions in wcolorpanel
These 4 functions are local to the file so we make this official.
2013-05-09 16:56:28 +01:00
Christophe CURIS
a1119f8dd3 WINGs: Added 'const' attribute to functions in wbrowser, wcolorpanel, wfilepanel and wfontpanel
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Carlos R. Mafra
e1453087f5 WINGs: Rename copy_file() to wcopy_file()
...in order to avoid clashes that happen during compilation of
wmakerconf.

This is a new function in WINGs, so renaming it at this point is
not a big deal.

Thanks to Rodolfo García for the heads up.
2012-01-31 12:23:54 +00:00
Carlos R. Mafra
89bf263410 WINGs: Replace fetchFile() by copy_file() in wcolorpanel.c
Now that copy_file() is in libWUtil, use it instead of fetchFile(),
which can be removed from wcolorpanel.c.
2012-01-15 14:31:52 +00:00
Carlos R. Mafra
14643408e8 WINGs: Make fetchFile() more similar to copyFile() from getstyle.c
The idea is to use the fetchFile() in getstyle.c and in wcolorpanel.c
instead of using two very similar functions.

In order to do that, let's move the most generic one (fetchFile()) to
libWUtils, and this is the first step.
2012-01-15 14:23:12 +00:00
Christophe CURIS
e01d14abe4 Fix possible missing NUL at end of string
There are were a few uses of 'strncpy' that could lead to a missing NUL,
resulting in possible garbage being displayed. As suggested by Tamas,
use 'wstrlcpy' instead
2011-08-08 19:11:22 +02:00
Tamas TEVESZ
f65b99e615 Remove warnings
* Remove assigned but not used variables (GCC 4.6)
* Bump _XOPEN_SOURCE to 600, ridding of FreeBSD warnings (this probably need
  to be tweaked on a per-implementation basis as problems arise)
2011-03-24 16:19:52 +01:00
Tamas TEVESZ
94a0c7b42f Fix some double newlines
Just a couple that woud now print double (or several more) newlines.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:30 +02:00
Tamas TEVESZ
1f21919809 Remove wsyserrorwithcode, rename wsyserror to werror
wsyserrorwithcode - Not used, no point either.
wsyserror->werror - qualifying "error" with a "type" hardly makes
sense if there are not at least two "type"s. There are not. Safe trip.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:30 +02:00
Tamas TEVESZ
a71a604ab1 WINGs: Make wmalloc() intialize allocated memory to 0
- Accordingly remove individual memsets, for now from WINGs only.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:29 +02:00
Tamas TEVESZ
62f4eff7ae Add missing initializers 2010-04-12 11:56:00 +02:00
Tamas TEVESZ
71aa4f2884 Switch file ops to stdio
- Does away with the O_BINARY abomination
- as a byproduct, plugs an fd leak in wcolorpanel.c:fetchFile()
- sprinkle some fsync()s to files that have been written to (this
  needs to be done everywhere)

+ fix brown paper bag thinko in configure.ac
2010-03-27 10:31:13 +01:00
Nicolas Bonifas
391d5de79e 2 open() statements were not matched with close() statements in function fetchFile 2009-12-06 13:58:24 +01:00
Vladimir Nadvornik
108127f0b5 Miscellaneous fixes from OpenSuse
These are some of the fixes sent to the wmaker-dev list by
Vladimir Nadvornik, with minor modifications to address Dan
Pascu's concerns.

Original-post: http://lists.windowmaker.info/dev/msg00293.html
2009-08-27 16:34:44 +02:00
Carlos R. Mafra
688a56e8ab Change to the linux kernel coding style
for arq in `git ls-files *.c`; do
    echo $arq;
    indent -linux -l115 $arq;
    done

The different line break at 115 columns is because
I use a widescreen monitor :-)
2009-08-20 00:59:40 +02:00
dan
577b3ee949 Removed WINGs' dependency on rgb.txt (from X11).
This fixes issues with locating the file which is being stored on different
locations depending on the X server release/version
2006-04-26 20:28:24 +00:00
dan
6830b05716 changed indentation to use spaces only 2004-10-12 21:28:27 +00:00
dan
dd1ccd2fd6 - enabled the use of SHAPE extension in the color panel. without it the
magnifying glass captured image was shifted and unusable
- removed some comments left in the code for later reviewal
2002-12-01 05:49:13 +00:00
dan
c0442b1c59 - WMGetTextDefaultColor() won't retain the returned color anymore, and you
shouldn't release it. It is just a reference to the internal WMText color.
  This should make all the functions returning colors from widgets behave
  consistently
2002-11-30 03:00:34 +00:00
dan
1e92274495 - Updated WINGs/NEWS with info about hw the API changed how how things
are affected. Fixes for old code too.
- Double buffering in WMList. All widgets or apps using WMList and
  having user drawing porcedures in place will inherit this double
  buffering automatically too.
- New functions in WINGs: WMGetColorAlpha(), WMIsAAFont()
- Misc code cleanups in WINGs and src/dialog.c
2002-10-16 04:05:45 +00:00
dan
a2b404b5b3 - API change in WINGs for WMDraw*String().
WMDrawString() and WMDrawImageString() now take WMColor instead of GC as
  arguments. WMDrawImageString() receives 2 colors (text & background).
  This is to allow easy extension for Xft/Xrender and hide X low level details
- Added alpha channel to WMColor. 2 new functions also:
  WMCreateRGBAColor() and WMSetColorAlpha()
- Miscelaneous code cleanups in wtext.c
- Removed obsoleted acconfig.h and implemented its functionality using
  AC_DEFINE and AC_DEFINE_UNQUOTED as autoconf 2.5x recommends.
  This will definitely enforce the need to use autoconf 2.5x
2002-10-08 08:26:06 +00:00
dan
92b012e800 patch to add binary mode on opening files (for Windows+Cygwin compatibility). 2002-09-15 20:37:41 +00:00
dan
af287fb8eb - added strcasecmp() to WINGs (only on systems that don't have it)
- removed some redundant includes of ../src/config.h where wconfig.h
  is also included
2001-11-17 04:26:08 +00:00