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

2559 Commits

Author SHA1 Message Date
Christophe CURIS
e7c8ac76ea WINGs: Added 'const' attribute to functions in wapplication, wappresource, wcolor, wfont, wpixmap
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
af403073f0 Fixed memory leak due to non-freed property list structure
The history is actually loaded from a file into a property list that
is then converted to an array. The intermediate property list was
not freed, which led to memory leak.

It looks like it was a tentative of optimisation to avoid duplicating
an already allocated string and re-use the pointer instead, but this
means it is not possible to free the original container as it would
free the string too.

There is a better way to do this, but it requires an API change on the
WUtil library so it is left for a future improvment.
2013-05-08 15:05:00 +01:00
Christophe CURIS
5a5216ffb9 Changed method to limit the number of History entries loaded
The previous code limited the number of entries that were read into
the history array, but the user is expecting a maximum on the
number of entries displayed. This can make a little difference in
two cases:
 - if there are duplicate entries (dups are checked for and removed)
 - if some entries are not strings (unlikely, but not impossible)

The new code just stops adding history entries when the user
specified count is reached.
2013-05-08 15:05:00 +01:00
Christophe CURIS
bcee010082 Added a few 'const' to filename parameters for History functions
Name of file is, as usual, a read-only parameter.
2013-05-08 15:05:00 +01:00
Christophe CURIS
ea19294b70 Fixed memory leak due to non-freed temporary PropList
When menus are read in the PropList format, they are loaded into a
temporary PropList object, which is parsed into the internal menu
structure, and the PropList object is no more used. There were two
cases where this temp object was not freed.
2013-05-08 15:05:00 +01:00
Christophe CURIS
0004d38ef8 WPrefs: Added const attribute to statically stored strings
Now that the function handling the configuration dictionnary are
const correct, the key stored in static array can be given the const
attribute.
2013-05-08 15:05:00 +01:00
Christophe CURIS
8517f3dcef WPrefs: Added the proper 'const' attribute to the dictionnary functions
A common argument to all these functions is the name of the key to
operate on, and this name is never modified by the functions. Marking
it as const reflects this, and can allow compiler to generate better
results thanks to this info.
2013-05-08 15:05:00 +01:00
Iain Patterson
022421e879 Documentation on the new switchpanel behaviour.
Describe Group*Key and StrictWindozeCycling in the NEWS file.
2013-05-08 14:57:23 +01:00
Christophe CURIS
9ab6368b33 WUtil: Increased version number for the library
The addition of the const attributes is actually an API change, so
we have to reflect this for the next official release.

Because the change on 'wusergnusteppath' may impact users of the API,
we won't only change REVISION like it was done for WRaster lib.
2013-05-04 16:25:44 +01:00
Christophe CURIS
033e3eaa54 WUtil: Rewrote 'wusergnusteppath' to be more efficient
The first optimisation is to compute only once the path, and then
always re-use the value which did not change anyway.
The second optimisation is to avoid a lot of excessive function
calls, including alloc+free that are not necessary and participate
in memory fragmentation.
2013-05-04 16:25:44 +01:00
Christophe CURIS
a18fd7cd69 Fixed const correctness in functions using 'wusergnusteppath'
The change introduced in previous commit for const correctness has
a small impact on WindowMaker's code, this patch fixes all the new
warnings.
2013-05-04 16:25:44 +01:00
Christophe CURIS
cd1c55d63c WUtil: Changed declaration of 'wusergnusteppath' to return a CONST string
According to the way its value is being used everywhere, that is
what would be expected, so let's make it official.

Please note that this may introduce warnings on user code using
this function ("...discard const...") but that's an opportunity
for them to check that their code is not doing anything wrong.
2013-05-04 16:25:44 +01:00
Christophe CURIS
fd02f5f083 WUtil: Fixed risky code for de-escaping of strings
The internal function 'unescapestr' is used to transform strings which
may contain escape sequences (\x) into their plain representation.

There are a few cases where the function can misbehave (typically parse
after the end of string, thus writing past the end of the reserved
result area) which can be a source of problem later. The new code
should be safer.
2013-05-04 16:25:44 +01:00
Christophe CURIS
f386e34d29 WUtil: Fixed wrong type recast
The previous syntax used an explicit cast to remove the CONST
attribute, but the right way is to keep the attribute and store
the result in a variable which is defined properly.
2013-05-04 16:25:44 +01:00
Christophe CURIS
32ecd4ee58 WUtil: Avoid unnecessary strdup + free
It is not good for memory fragmentation to duplicate a string and
then free the original; changed code to only keep originaly allocated
string.
2013-05-04 16:25:44 +01:00
Christophe CURIS
98e3c7e347 WUtil: Added comment about values returned by API functions
This is mainly to be consistent with what's done in the rest of
the file, but it is better to have it there that nowhere at all
anyway...
2013-05-04 16:25:44 +01:00
Christophe CURIS
74c17bffae WUtil: Added 'const' attribute to all remaining functions where applicable
This makes the WUtil API as much const-correct as possible for
the arguments being given to its functions.

This does not make it totally correct as it does not changes the
const-ness on returned values because the goal of this patch is
to make no visible change to existing program that would use this
library.
2013-05-04 16:16:19 +01:00
Christophe CURIS
d40fa69b92 WUtil: Added 'const' attribute to the filename on WM(Read|Write)PropList*
Note that the argument is also stored as-is in the PLData structure
but only for debugging purpose (warning display to user), hence the
choice to not duplicate it. As a side effect, it was 'const'-ified
too to reflect that.
2013-05-04 16:16:18 +01:00
Christophe CURIS
ea9d3e643f WUtil: Added 'const' attribute to parameters for file related API
As a side note, in 'wfindfileinlist' the first argument should be:
  const char * const *path_list

However, due to limited support for const in plain C, that would
introduce warnings in user code. For compatibility issues, this
was not implemented.
2013-05-04 16:16:18 +01:00
Christophe CURIS
bbf84eb0e8 WUtil: Added 'const' attribute on non-modified arguments to functions
A number of functions do not actually modify the strings given as
parameter, but only read or duplicate it. In this case it is a good
practice to mark that parameter as pointer-to-const to let the
compiler known about it, to be able to perform appropriate
optimisations.
2013-05-04 16:16:18 +01:00
Christophe CURIS
ac89706859 WRaster: Bugfix, added missing 'const' to RLoad* functions
Prototype of function changed in commit
  d1e1c13fa3
but two of them were not updated in the source.

Thanks to Rodolfo García Peñas for taking the time to test and report.
2013-05-03 08:17:26 +01:00
Christophe CURIS
602fbc9ee4 Added missing headers to the list of source files of the project
This is needed in order to have all the expected files in the
archive of sources when using:
  make dist
2013-05-03 07:16:10 +01:00
Christophe CURIS
9a895dcda5 Increased library's revision to reflect API updates
The addition of 'const' to parameters of library's functions is an
API change, although this will break neither the binary interface
nor the compilation of program using the library; the other changes
also have no impact on the compiled library object.
2013-05-02 20:48:45 +01:00
Christophe CURIS
9e4253f670 Added the last missing 'const' attributes to function parameters 2013-05-02 20:48:45 +01:00
Christophe CURIS
0bf6297a32 Added 'const' attribute on non-modified arguments for color handling functions
These functions have both an input and an output color, marked the
input color as const to help distinguish.
2013-05-02 20:48:45 +01:00
Christophe CURIS
8f7d4b7751 Added 'const' attribute on non-modified arguments for drawing functions
All these functions expects agruments like color or list-of-points
that should not be modified (and are not) by the function; added
the corresponding qualifier to reflect that.
2013-05-02 20:48:45 +01:00
Christophe CURIS
d1e1c13fa3 Added 'const' attribute to the file name parameter to load/save
This name is not modified by the callee functions (and it should
not be anyway), so let's make it official in the internal functions
2013-05-02 20:48:45 +01:00
Christophe CURIS
225c99a6ca Converted #define into an Enum for image format number
An enum is always a better idea as it allows the compiler to do
some checks, and as this info is internal only to the WRLib it
will not change the API.
2013-05-02 20:48:45 +01:00
Christophe CURIS
268ead4eca Moved the function to Save image also into the internal header 2013-05-02 20:48:45 +01:00
Christophe CURIS
883cda48e3 Moved declaration of format-specific image Load functions to dedicated header
The functions are declared in different files but they were called
in another file which re-declared the prototypes. This is dangerous
as it can lead to misaligned prototypes when functions changes.

They are now grouped in the library internal header 'imgformat.h'
2013-05-02 20:48:45 +01:00
Christophe CURIS
cacc04d4a2 Move the list of keyboard shortcut texts into the array of their config keyword
The config-file-keyword was defined in an array, but the user displayed
string was defined at another place, thus requiring special care when
modifying the list, to keep the same number of entries, in the same
order, ...

This was an open call for subtle bugs, so the keyword and user string
are now at a single place, making updates on the list easier and the
GUI generation code smaller.
2013-05-02 20:48:10 +01:00
Iain Patterson
94777b9715 Support for same-class cycling in open switchpanel.
If the switchpanel was opened with either FocusNextKey or FocusPrevKey
shortcut, and the user presses GroupNextKey or GroupPrevKey, skip over
windows of a different class when cycling through windows in the
switchpanel.

In the case where the switchpanel was opened with FocusNextKey or
FocusPrevKey initially, the check can be skipped because all the
available choices are necessarily of the same class already.
2013-05-02 20:41:07 +01:00
Iain Patterson
8cb6a78726 Correct check for modifier in class-specific cycle.
The hasModifier flag was set if the FocusNextKey or FocusPrevKey
shortcuts had modifiers, depending on which shortcut was used to open
the switchpanel.

The switchpanel can also be opened with the GroupNextKey or GroupPrevKey
shortcuts, so we should account for those when setting hasModifier.
2013-05-02 20:41:07 +01:00
Iain Patterson
6fb2b13ec7 Added sameWindowClass().
Avoid code duplication by moving check for windows of the same WM_CLASS
to the new function sameWindowClass().
2013-05-02 20:41:07 +01:00
Iain Patterson
90675a6f04 Set StrictWindozeCycle by default.
Window Maker's behaviour changes when StrictWindozeCycle is active.  As
a rule we try not to set the default value of new options such that they
would change the behaviour expected by users.

In this case, however, the switchpanel was not working as intended.
Users who prefer the old method can set StrictWindozeCycle off with

  wdwrite WindowMaker StrictWindozeCycle NO
2013-05-02 20:41:07 +01:00
Iain Patterson
c9937f6f6a Fix StartWindozeCycle() shift key behaviour.
As the name implies, StartWindozeCycle() cycles windows in the same way
that a popular commercially-available operating system does.  However
Window Maker's handling of the shift key in the switchpanel does not
currently mirror that of its commercial counterpart.

In the popular operating system:

  Holding alt and shift then pressing and releasing tab will highlight
  the previous window in the switcher.

  Releasing shift with alt still held will not close the switcher.

  The window change is commited when alt is released.

In Window Maker:

  Holding alt and shift then pressing and releasing tab will highlight
  the previous window in the switchpanel.

  Releasing shift with alt still held will close the switchpanel and commit
  the window change.

This patch adds the StrictWindozeCycle boolean preference.  When it is
set to YES the switchpanel will remain open as long as alt is held even
if shift is pressed and released.
2013-05-02 20:41:07 +01:00
Rodolfo García Peñas (kix)
29a5267485 icon_update_pixmap default moved to bottom
The default case is moved to the bottom of the switch case.

The default case should be removed, because the icon has always
a right value, because the icon creation always uses a real value:

kix@debian:~/src/wmaker/wmaker-crm/src$ grep wAppIconCreateForDock *c
appicon.c:WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
dock.c:         btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP);
dock.c:         btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMDock", TILE_NORMAL);
dock.c:         btn = wAppIconCreateForDock(scr, NULL, name, "WMDrawer", TILE_DRAWER);
dock.c: aicon = wAppIconCreateForDock(scr, command, winstance, wclass, TILE_NORMAL);
(1)dock.c:                         aicon = wAppIconCreateForDock(dock->screen_ptr, NULL,
kix@debian:~/src/wmaker/wmaker-crm/src$
kix@debian:~/src/wmaker/wmaker-crm/src$ grep TILE_ *c | grep -v ICON_TILE_SIZE
***[2]appicon.c:              tile = TILE_CLIP;
dock.c:         btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP);
dock.c:         btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMDock", TILE_NORMAL);
dock.c:         btn = wAppIconCreateForDock(scr, NULL, name, "WMDrawer", TILE_DRAWER);
dock.c: aicon = wAppIconCreateForDock(scr, command, winstance, wclass, TILE_NORMAL);
(2)dock.c:                                                       wm_instance, wm_class, TILE_NORMAL);
***[3]icon.c: icon->tile_type = TILE_NORMAL;
icon.c: case TILE_NORMAL:
icon.c: case TILE_CLIP:
icon.c: case TILE_DRAWER:
kix@debian:~/src/wmaker/wmaker-crm/src$ grep tile_type *c
icon.c: icon->tile_type = TILE_NORMAL;
***[1]icon.c: icon->tile_type = tile;
icon.c: switch (icon->tile_type) {
icon.c:         wwarning("Unknown tile type: %d.\n", icon->tile_type);
kix@debian:~/src/wmaker/wmaker-crm/src$

There are only three cases without value (asterisk in the line start) set
as preprocessor variable. (1) and (2) is the same call. These are the three cases:

Case [1]:

-------------8<--------------
WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
{
        WIcon *icon;

        icon = icon_create_core(scr, 0, 0);
        icon->tile_type = tile;
-------------8<--------------

Calls to icon_create_for_dock, is only call in appicon.c:

-------------8<--------------
kix@debian:~/src/wmaker/wmaker-crm/src$ grep icon_create_for_dock *c
appicon.c:      aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile);
icon.c:WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
kix@debian:~/src/wmaker/wmaker-crm/src$
-------------8<--------------

The call:

-------------8<--------------
WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
{
[snip]
        if (strcmp(wm_class, "WMDock") == 0 && wPreferences.flags.clip_merged_in_dock)
                tile = TILE_CLIP;
        aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile);
-------------8<--------------

And the calls to wAppIconCreateForDock() are checked before.

The case [2] is just the line:

-------------8<--------------
WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile)
{
[snip]
        if (strcmp(wm_class, "WMDock") == 0 && wPreferences.flags.clip_merged_in_dock)
***             tile = TILE_CLIP;
        aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile);
-------------8<--------------

Then, is sure too.

The case [3] is:

-------------8<--------------
WIcon *icon_create_for_wwindow(WWindow *wwin)
{
[snip]
        icon->tile_type = TILE_NORMAL;
-------------8<--------------

All windows have TILE_NORMAL.

Then, all cases are secure.
2013-04-17 10:23:10 +01:00
Rodolfo García Peñas (kix)
41da1b30db New file misc.h
This is the new file misc.h, with the function prototypes for misc.c.
This file is created using misc.c and removing the prototypes from funcs.h
2013-04-17 10:13:25 +01:00
Iain Patterson
25b5ca2566 Compiler food.
WMMergePLDictionaries() and WMSubtractPLDictionaries() are declared to
return WMPropList * but are set to call the wassertr macro when their
arguments do not pass a sanity check.  The wassertr macro eventually
calls return with no return value, triggering a compiler warning if
-Wreturn-type is used.

Change wassertr to wassertrv and force a return of NULL in the error
case.
2013-04-16 00:47:10 +01:00
Renan Traba
729886ef52 WPrefs: fix missing drawer image in Makefile.am 2013-04-12 09:54:58 +01:00
Carlos R. Mafra
f863dafef1 WPrefs: Avoid crash when config file does not contain wmdrawer settings
When first using the wmdrawer panel of WPrefs the settings

ClipAutoexpandDelay
ClipAutocollapseDelay
ClipAutoraiseDelay
ClipAutolowerDelay

are not yet saved in the user's config file and 'value' ends up
being undefined in showData() leading to a crash in adjustButtonSelectionBasedOnValue().

This patch is a workaround to make it possible to choose the config values for the
first time using WPrefs.
2013-04-12 02:52:41 +01:00
Carlos R. Mafra
311255a646 Fix compilation from merge conflict 2013-04-12 02:20:54 +01:00
Carlos R. Mafra
529ee0bd21 Merge branch 'wmdrawer' into next 2013-04-12 02:14:41 +01:00
Daniel Déchelotte
878a57d7b2 Add option to merge the workspace-switching functionality into the dock
The dock will have the up-right and down-left arrows to change workspaces and
the clip will be disabled. That is, if option ClipMergedInDock is set to yes in
GNUstep/Defaults/WindowMaker.
[not thoroughly tested]
2013-04-12 02:14:10 +01:00
Daniel Déchelotte
36bed6a77e Wrap appicons when dock is moved up and down
Add WrapAppiconsInDock option to control that behaviour (default: YES)
2013-04-12 02:14:10 +01:00
Daniel Déchelotte
3c628d50d2 Allow appicons above the dock
Previous, even the "anchor tile" of the dock could be moved down, it was
not possible to dock anything above it.
2013-04-12 02:14:10 +01:00
Daniel Déchelotte
5e004d5f11 Real-time dock left-right swapping
No more ghost dock when switching sides: the real swap happens
immediately, you can still adjust vertically afterwards. Removed two
functions in superfluous that are no longer used
2013-04-12 02:14:10 +01:00
Daniel Déchelotte
cf5fdca63d WPrefs: adds possibility to disable drawers from Docks panel 2013-04-12 02:14:10 +01:00
Daniel Déchelotte
e14e6b3da8 Add drawers to wmaker!
Drawers are horizontal docks, and they can themselves only live in the dock

To use them, right click on the dock or a docked appicon and select "Add
a drawer". Then move appicons into the drawer (drag them with the
mouse). You may change the icon of the drawer. By default, drawers
auto-expand and -collapse, and auto-raise/lower. This can be customized
in the same way as for the clip.

Set DisableDrawers to YES in G/D/WindowMaker if you do not want to see
the menu entry to add a drawer.

Just discovered this bug: the auto-attract icon functionality will not
work (to be precise, it crashes WM!) if the clip is disabled
(NoClip=YES). Will fix shortly, of course.
2013-04-12 02:14:10 +01:00
Daniel Déchelotte
707ce34a5e Added a SlideWindows function to handle horizontally-aligned array of windows
The existing SlideWindow() function is changed to call SlideWindows() with an array of 1 window
2013-04-12 02:14:10 +01:00