The original type was not as safe as it looked like to be, and led
to more memory usage than necessary.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
It is bad practice to define the prototype of an external function
inside a source file that wants to use it.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
It is dangerous to define an extern variable locally because the
compiler is not able to ensure proper type definition, but including
the header that defines it allows a safer situation.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The whole changeImage() function in switchpanel.c is a no-op if
wPreferences.swtileImage is set to None because the panel isn't actually
drawn in that case. As a consequence there are no images to change.
As well as being logically incorrect the existing code causes a segfault
if the user has the SwitchPanelImages preference set to None because
changeImage() would attempt to access the icons and images arrays which
are only initialised in wInitSwitchPanel() when swtileImage has a value.
Bug report and diagnosis by Juan Giordana, Gabriel Vlasiu and Christophe
Curis.
There is a dedicaded floating point modulo operator that does a
better job (faster, no precision loss), so we use it instead of the
complicated formula that uses type conversions.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
For this case we happen to already have the same variable as integer
type, so it is better to use them directly for computation.
Please note that the floating point variables do not contain more
precision in this use case, otherwise the change would not be
transparent.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Compilation will not work if the header is missing, so make sure
it is present and compilable first. This can highligh sooner if
a user forgot to install the corresponding dev package.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Took the opportunity to rewrite the check using autoconf macros
to generate a more compatible configure script.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The function contained an internal statement that would have
discarded the const attribute, but as this statement is actually
useless it have been simply removed.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Because we have to use some X functions marked as deprecated to
ensure portability, we prefer to hide the warnings from standard
users, and keep them only for dev team.
[crm: Add -Wno-deprecated-declarations too]
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
To ensure proper behaviour with X servers that do not support the
Xkb extension, implemented call to the fall-back legacy function
to the other places where it is being used, to ensure proper
behaviour in any case.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The original code was assuming that the Xkb extension is available
everywhere, which is not the case. This resulted in all modifiers
to be seen as NoSymbol, thus the empty list.
Now we initialize properly the Xkb extension at the start of the
program, and provide a work-around with the historical function in
the case the ext would not be available.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Apparently, there is some exceptional case when the 'Mouse Grab
Modifier' list can be empty, in which case the program would
crash.
This patch makes sure the program will not crash (that's a bad
behaviour), but does not solve the empty list case
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As reported by clang, the format used was %hi which is expecting
a short-typed argument, but the parameters are actually defined
as ints in the structure, so use only %i.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As reported by Iain Patterson, the clang compiler is (by default)
strictier on having clean C syntax. A few structure definition
did not comply, now they do.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Using an unspecified prototype function for a callback is calling
for problem. Added an explicit prototype for the 2 callback
functions in WDefaultEntry, and fixed the functions used to match
it. The new code should be a lot safer.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This attribute for functions was not standard until recently, so
there are a few different possible syntax. With this patch, the
configure script will search for the proper syntax, and define what
is needed to have the attribute compile correctly.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
If the function was called more than once with different usernames
it would always return the path for the user on the first call,
which is not what would be expected.
Furthermore, if the function succeeds it allocated memory to save
this path but it was never freed.
The good thing is that the use case for this function is so rare
that it is improbable it was ever called, which explains why it
was never seen.
The new code always behaves as expected, and does not allocate
memory anymore to avoid wasting time and memory for such small
things, which is acceptable because this function is local.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The previous method was to use a custom install procedure, which
is a bit complex when automake can handle this for us, and as a
side effect it made 'distcheck' fail on uninstall procedure check.
The new method is to use a simple conditional and autoconf/automake
will do all the work for us.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
wMaximizeWindow() was previously rewritten and simplified.
Unfortunately the rewrite introduced a regression with windows which
were horizontally maximized or Maximusized, whereby they would be too
small after the maximization.
The bug is easy to see by opening a standard 80x24 terminal and hitting
the maximize horizontally shortcut. The terminal shrinks to 21 lines.
Pressing the shortcut key again correctly restores it to 80x24.
The fix is to refrain from shrinking the final window height, which is
done to account for its frame border and titlebar, for the affected
maximization styles.
Explicitly match a Return keypress in the switchpanel, so that the
currently selected window is focused without the keypress event being
handled elsewhere.
Pressing Return to commit the window selection is intuitive but other
shortcuts may bind Return. Any keypress not explicitly handled in the
switchpanel code will be passed through to other shortcut processing.
If, for example, alt+return were mapped to Select Window and the
switchpanel is open, pressing return while holding alt would both commit
the window change AND select the window, which is not intuitive.
If the new preference SwitchPanelOnlyOpen is set to YES, pressing
alt-tab or similar shortcut will only open the panel without
automatically switching to the next window. Shortcuts will continue to
function normally once the panel is open.
Users can enable the new preference if they find themselves regularly
opening the switchpanel just to visualise which windows are open, or to
initiate same-class cycling.
The default value of the new preference is NO. Behaviour is unchanged
unless the preference is explicitly enabled with the following command:
$ wdwrite WindowMaker SwitchPanelOnlyOpen YES
Keep an array of flags to remember if icons are supposed to be selected
and/or dimmed, and don't redraw any which are already in the correct
state.
Originally I didn't think the benefit of doing this was worth the effort
but future commits will call changeImage() more often so cutting down on
unnecessary redraws suddenly became more useful.
The Workspaces entry in the main menu allows to rename workspaces by
clicking on the workspace name while pressing the Ctrl key.
However since commit 63219247c6 ("Added shortcut to switch to last used workspace")
there is one more entry before the workspace name list, and that leads to
picking a wrong name to rename -- clicking on the first workspace asks to
rename the second workspace and so forth. Trying to rename the last workspace
leads to a segfault.
This happens because there is an explicit offset in the current code (- 2)
to account for the "non-workspace" entries in the menu. If one adds one
more entry that offset should be changed too (this is a prime example
of fragile code leading to bugs).
The file funcs.h is removed. A new file osdep.h is created to hold
the definition for all osdep_*c files.
The files .c has been adjusted to include the right header files,
removing funcs.h, including osdep.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
The file switchmenu.h includes the function prototypes for switchmenu.c.
The prototypes included were moved from funcs.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
The file winmenu.h includes the function prototypes for winmenu.c.
The prototypes included were moved from funcs.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
The file monitor.h includes the function prototypes for monitor.c.
The prototypes included were moved from funcs.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
The file event.h includes the function prototypes for event.c.
The prototypes included were moved from funcs.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
The file cycling.h includes the function prototypes for cycling.c.
The prototypes included were moved from funcs.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
The file startup.h includes the function prototypes for startup.c.
The prototypes included were moved from funcs.h.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>