wmaker-crm.git
11 years agoBrief documentation on wAppIconFor() and wWindowFor().
Iain Patterson [Tue, 30 Oct 2012 16:10:14 +0000 (30 09:10 -0700)]
Brief documentation on wAppIconFor() and wWindowFor().

Brief comment on what wAppIconFor() and wWindowFor() do, as it
may not be immediately obvious.

Given a raw X11 Window they will find the AppIcon (or WWindow,
respectively) associated with that window.  Thus they can map an
X11 object to a Window Maker internal object.

11 years agoAppIcon helper functions.
Iain Patterson [Mon, 29 Oct 2012 22:35:56 +0000 (29 15:35 -0700)]
AppIcon helper functions.

Create wAppIconFor() and wAppIconTouchesHead() to match wWindowFor()
and wWindowTouchesHead().  These functions will allow us to locate the
window and head associated with a particular app icon or dock icon.

11 years agoPartially support _NET_WM_STRUT_PARTIAL.
Iain Patterson [Fri, 26 Oct 2012 18:40:55 +0000 (26 11:40 -0700)]
Partially support _NET_WM_STRUT_PARTIAL.

Window Maker already supports the _NET_WM_STRUT property as described
in the EWMH spec.  We respect client-provided struts and avoid placing
or maximizing windows over those areas.  An example is that we don't
try to place or maximize windows where they would be obscured by an
always-on-top gnome-panel.

_NET_WM_STRUT is now deprecated and redefined as a special case of
_NET_WM_STRUT_PARTIAL, which allows variable strut widths.  A panel at
the bottom of the screen, for example, does not have to reserve the
whole width as a strut if it does not fill 100% of the screen width.
By default the XFCE bottom panel does not extend the whole width of
the screen, for instance.

Our method for restricting parts of the screen from placement doesn't
have a way to account for struts which are not 100% tall or 100% wide,
so until now we have ignored partial struts.  In the case of the XFCE
panel mentioned above, the result is that a window may maximize
underneath the panel and be obscured.

As a partial hackaround we now query windows for _NET_WM_STRUT_PARTIAL
but throw away the start and end co-ordinates, assuming instead that
the struts are full-width/full-height.  This trades off a small amount
of wasted placement space to avoid the case where windows can be
partially obscured by panels, which can be particularly annoying if
the panel is at the top and the victim's titlebar becomes hidden.

11 years agoDebian configuration file error
Rodolfo García Peñas (kix) [Thu, 25 Oct 2012 21:44:56 +0000 (25 23:44 +0200)]
Debian configuration file error

This patch removes the extra commas in the configuration file
WindowMaker.

This bug was created in the commit 0e995bbf6ea91d8ff18009ce29219a171d92c808
but no debian packages were released.

11 years agoremove_wwindowstate name changed
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 22:00:01 +0000 (24 00:00 +0200)]
remove_wwindowstate name changed

The function remove_wwindowstate is now remove_wwindowstate. This was
proposed by Christophe and Carlos:

- - -
On 2012-10-09 01:09, Carlos R. Mafra wrote:
> On Tue,  9 Oct 2012 at  0:58:19 +0200, Christophe wrote:
> you name the function "remove_*", which makes think that it would
> remove the entry from the list, but the function does not do that, it
> just frees the memory, so it may have been better called "free_" (or
> maybe "release_")?
>

Good point, release_ makes more sense to me.
- - -

11 years agoChanged get_default_icon_rimage function name
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 22:00:00 +0000 (24 00:00 +0200)]
Changed get_default_icon_rimage function name

The function get_default_icon_rimage name is not correct, because
the function doesn't return the default icon rimage, returns the
rimage from a file name. So the correct function name should be
get_rimage_from_file.

11 years agoNew helper function get_pixmap_icon_from_default_icon
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:59 +0000 (23 23:59 +0200)]
New helper function get_pixmap_icon_from_default_icon

The new helper function get_pixmap_icon_from_default_icon search
the default icon in the disk and return it.

Now get_pixmap_icon_from_user_icon() returns do the work about
search the user icon, and the work about default icon is splitted
in the function get_pixmap_icon_from_user_icon.

11 years agoFunction makeIcon removed
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:58 +0000 (23 23:59 +0200)]
Function makeIcon removed

The function makeIcon is only used in icon_update_pixmap(), so
both functions can be joined. Now the function icon_update_pixmap()
includes the contents of makeIcon.

11 years agoBetter default icon management
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:57 +0000 (23 23:59 +0200)]
Better default icon management

This patch replaces the Pixmap icons from screen.h with only one
RImage. This image is not processed yet, therefore could be used
for icons with title or without it (replacing def_ticon_pixmap and
def_icon_pixmap variables).

Now the code is better because the Pixmap is generated and saved in
the icon structure.

See that before this patch, the icon->pixmap was set to None!!
With this patch, the icon->pixmap is saved, using the common
method used in the other functions to create Pixmaps, the function
icon_update_pixmap().

11 years agoNew helper function get_default_image
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:56 +0000 (23 23:59 +0200)]
New helper function get_default_image

The new function get_default_image creates a RImage with the default
icon. Now the function get_pixmap_icon_from_user_icon() is more clear
and show that, first try to get the user selected image, if not set,
then it gets the default icon.

11 years agodeclare get_pixmap_icon_from_* as static functions
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:55 +0000 (23 23:59 +0200)]
declare get_pixmap_icon_from_* as static functions

The functions:

void get_pixmap_icon_from_icon_win(WIcon *icon);
int get_pixmap_icon_from_wm_hints(WIcon *icon);
void get_pixmap_icon_from_user_icon(WIcon *icon);

should be static, because are only used in icon.c

11 years agoNew icon_update_pixmap helper function
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:54 +0000 (23 23:59 +0200)]
New icon_update_pixmap helper function

The function icon_update_pixmap updates the WIcon's pixmap,
using the values in the WIcon struct.

This function provices a clear function to update the icon,
using only the icon, and the new image to set. This option is
better than using "makeIcon" function, with a lot of arguments.

This patch also changes the variable name "icon" to "image",
because is type rimage and then both functions uses the same name.

11 years agoget_pixmap_icon_from_wm_hints removed extra arguments
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:53 +0000 (23 23:59 +0200)]
get_pixmap_icon_from_wm_hints removed extra arguments

The function get_pixmap_icon_from_wm_hints has two extra arguments
(WScreen and WWindow) not needed, because these arguments can be
accessed using the argument WIcon.

This function removes them in the function definition and provides
them in the function code.

11 years agoget_pixmap_icon_from_user_icon extra argument removed
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:52 +0000 (23 23:59 +0200)]
get_pixmap_icon_from_user_icon extra argument removed

The function get_pixmap_icon_from_user_icon uses the argument
scr (WScreen) that is not needed, because the argument is in the
struct WIcon, the other function argument.

This patch removes the argument WScreen and provides it in the function
using WIcon.

11 years agowmspec code clean - style
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:51 +0000 (23 23:59 +0200)]
wmspec code clean - style

This patch do these changes:

1. Removes the extra curly brackets
2. Add curly brackets if needed (code style)
3. Removes spaces in the function prototypes/declaration
   I think this is the best moment to do it, all together
   in a style clean patch.
4. Moves variable definition with the same type to the same line

11 years agowNETWMCheckClientHintChange should be void
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:50 +0000 (23 23:59 +0200)]
wNETWMCheckClientHintChange should be void

The function wNETWMCheckClientHintChange returns a Bool,
but this value is never used, son can be removed.

This function now is void.

kix@osaka:~/src/wmaker/wmaker-crm-tosnd/src$ grep wNETWMCheckClientHintChange *.[ch]
client.c:                       wNETWMCheckClientHintChange(wwin, event);
wmspec.c:Bool wNETWMCheckClientHintChange(WWindow * wwin, XPropertyEvent * event)
wmspec.h:Bool wNETWMCheckClientHintChange(WWindow *wwin, XPropertyEvent *event);

11 years agowNETWMCheckClientHints should be void
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:49 +0000 (23 23:59 +0200)]
wNETWMCheckClientHints should be void

The function wNETWMCheckClientHints returns a Boolean, but
this value is never used, so can be removed.

This patch removes the boolean returned, the variable hasState,
and so some parts of the function changes.
The patch also moves some variable definition to the same line:
one type, one line.

11 years agoCode not needed at wWindowSetupInitialAttributes
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:48 +0000 (23 23:59 +0200)]
Code not needed at wWindowSetupInitialAttributes

The variable "check" is always False, so the if (!False) is always
True and the function wNETWMCheckClientHints is always called.

The variable check is not used anymore, so the variable check
can be removed.

11 years agowNETWMCheckInitialClientState is now void
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:47 +0000 (23 23:59 +0200)]
wNETWMCheckInitialClientState is now void

The function wNETWMCheckInitialClientState returns a Bool,
but this value is never used, so the function can be void.

kix@osaka:~/src/wmaker/wmaker-crm-tosnd/src$ grep wNETWMCheckInitialClientState *.[ch]
window.c:       wNETWMCheckInitialClientState(wwin);
wmspec.c:Bool wNETWMCheckInitialClientState(WWindow * wwin)
wmspec.c:       wmessage("wNETWMCheckInitialClientState");
wmspec.h:Bool wNETWMCheckInitialClientState(WWindow *wwin);
kix@osaka:~/src/wmaker/wmaker-crm-tosnd/src$

11 years agowNETWMShowingDesktop is now static
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:59:46 +0000 (23 23:59 +0200)]
wNETWMShowingDesktop is now static

The function wNETWMShowingDesktop is only used at wmspec.c, so
can be static.

11 years agoMake debug statement print function name
Rodolfo García Peñas (kix) [Tue, 23 Oct 2012 21:58:56 +0000 (23 23:58 +0200)]
Make debug statement print function name

The wmessage function returns "enter" in two functions, so is
not possible to know the function that sends the message.

It is better to replace it with the function name.

11 years agoRevert "Fixed incorrect attributes for XCreateWindow's attributes"
Carlos R. Mafra [Thu, 25 Oct 2012 23:21:39 +0000 (26 00:21 +0100)]
Revert "Fixed incorrect attributes for XCreateWindow's attributes"

This reverts commit 824255b1ae225394dc093c193082cfb7186e3eda.

According to Iain Patterson:

  This patch breaks the frame extents stuff I submitted recently. With
the patch and compton set to draw semi-opaque frame extents what
actually happens is no window decorations are drawn and a bunch of
BadDrawable errors are spewed to the console.

  After reverting the patch everything works again.

11 years agoFixed incorrect attributes for XCreateWindow's attributes
Christophe CURIS [Wed, 10 Oct 2012 21:07:53 +0000 (10 23:07 +0200)]
Fixed incorrect attributes for XCreateWindow's attributes

The code was setting some values in the window's attribute structure
which were not being used (missing the corresponding vmask flag) and
was setting some vmask bits without setting the corresponding
value in the structure.

11 years agoFixed possible null pointer dereference
Christophe CURIS [Mon, 8 Oct 2012 23:19:15 +0000 (9 01:19 +0200)]
Fixed possible null pointer dereference

The new function 'unpaint_app_icon' checks its argument 'wapp' aginst NULL,
however it does dereference the pointer beforehand, which will end up in
a crash if the null-pointer case occurs.

11 years agoFixed crash when changing icon to non-existent file
Christophe CURIS [Mon, 8 Oct 2012 22:20:44 +0000 (9 00:20 +0200)]
Fixed crash when changing icon to non-existent file

As found by Rodolfo, a crash could happen when changing an icon to
a non-existent file. From his report:

Steps To Reproduce
1. Open the Settings box, for example for WMDock. (Right click on WMDock, Settings).
2. In the "Icon Image" field, write some characters. For example "asdfasdfasd".
3. Click in "OK". You get "Could not open specified icon file: GNUstep.tiffasdfasdfasd"
4. Hit in "OK"
5. Repeat 2,3,4 some times (sometimes 1, sometimes 2, sometimes 10).

The problem came from freeing the previous icon but not updating
the pointer, so if the new file did not exist it ended up with a
fake-looking icon being used, hence possible crash.

BTS: http://www.kix.es/mantis/view.php?id=1

11 years agoIcon creation in only one function
Rodolfo García Peñas (kix) [Mon, 8 Oct 2012 03:43:22 +0000 (8 05:43 +0200)]
Icon creation in only one function

This patch avoids the icon creation in winspector.c and adds the
ability of creating + paiting and unpainting instead of destroying the icon.

Now the icon is always created by wApplicationCreate and the icon
exists while the application is runnning. If the user doesn't want
an appicon the winspector.c will not remove the icon, it will only
not paint it on the screen. But the icon is still created.

Probably the most difficult part in this code is how to handle the
icons in the iconlist. We must include the icon in the iconlist when
it is painted, not when it is created. And it must be removed when it
is unpainted.

We can check if the icon is in the iconlist if icon->next AND icon->prev
are null, else it is on the applist. If it is included we must not
paint it again because the function PlaceIcon() will calculate a new
icon place in the screen including the icon!, then a hole is painted.

11 years agowcore set vmask in one step
Rodolfo García Peñas (kix) [Sat, 6 Oct 2012 16:18:43 +0000 (6 18:18 +0200)]
wcore set vmask in one step

This patch set the vmask in one line.

- vmask = CWBorderPixel | CWCursor | CWEventMask | CWOverrideRedirect;
- vmask |= CWColormap;

Is similar to:

+ vmask = CWBorderPixel | CWCursor | CWEventMask | CWOverrideRedirect | CWColormap;

And vmask is not used between the two original lines, therefore we can do the
initialization in only one line.

11 years agowmcore code clean
Rodolfo García Peñas (kix) [Sat, 6 Oct 2012 15:58:52 +0000 (6 17:58 +0200)]
wmcore code clean

This patch changes spaces with tabs, make the comments shorter and removes
some old comments.

11 years agoNew helper function remove_wwindowstate()
Rodolfo García Peñas (kix) [Sat, 6 Oct 2012 13:15:51 +0000 (6 15:15 +0200)]
New helper function remove_wwindowstate()

The common code in the functions wWindowDeleteSavedState and
wWindowDeleteSavedStatesForPID is moved to a new function remove_wwindowstate.

11 years agoIcon: Make icon_create_for_* be more similar
Rodolfo García Peñas (kix) [Tue, 2 Oct 2012 21:22:10 +0000 (2 23:22 +0200)]
Icon: Make icon_create_for_* be more similar

The contents for searching the icon in wAppIconCreateForDock()
are moved to icon_create_for_dock().

Now wAppIconCreateForDock() and wAppIconCreate() do the same work and
icon_create_for_dock() and icon_create_for_wwindow() do the same work too.

The procedure to create the icon is similar in both functions.

Now wAppIconCreateForDock, needs more arguments (command, instance and class).

11 years agowIcon* functions renamed
Rodolfo García Peñas (kix) [Mon, 1 Oct 2012 21:53:06 +0000 (1 23:53 +0200)]
wIcon* functions renamed

These functiosn were renamed:

wIconCreateCore to icon_create_core
wIconCreateWithIconFile to icon_create_for_dock
wIconCreate to icon_create_for_wwindow

11 years agowAppIconCreateForDockm, changed variable WAppIcon name
Rodolfo García Peñas (kix) [Mon, 1 Oct 2012 21:37:20 +0000 (1 23:37 +0200)]
wAppIconCreateForDockm, changed variable WAppIcon name

The variable "dicon" is now named "aicon", the same name that
the WAppIcon variable used in wAppIconCreate.

Some clean code more, like spaces in function arguments.

11 years agoRemove call to wIconUpdate() from wAppIconCreate()
Rodolfo García Peñas (kix) [Mon, 1 Oct 2012 21:39:44 +0000 (1 23:39 +0200)]
Remove call to wIconUpdate() from wAppIconCreate()

Remove the call to wIconUpdate() in wAppIconCreate() and place it in
makeAppIconFor() since wAppIconCreate() is only used in that function
and icon update or icon painting is not icon creation.

Now the function wAppIconCreate() only creates the app_icon.

11 years agowIconCreate: get the icon file name first
Rodolfo García Peñas (kix) [Mon, 1 Oct 2012 21:19:01 +0000 (1 23:19 +0200)]
wIconCreate: get the icon file name first

The function wIconCreate search the icon image calling wDefaultGetIconFile.
wDefaultGetIconFile search first the icon file name and then search the
image using the icon file name. wDefaultGetIconFile returns the icon image
to wIconCreate, then wIconCreate search the file name (again).

Is better that wIconCreate search first the file name, and then get
the image using the file name.

11 years agoIcon: Replace code by call to helper function in wIconCreateWithIconFile
Rodolfo García Peñas (kix) [Mon, 1 Oct 2012 20:49:30 +0000 (1 22:49 +0200)]
Icon: Replace code by call to helper function in wIconCreateWithIconFile

Code in the function wIconCreateWithIconFile does the same task as
get_default_icon_rimage(), therefore replace it with a call to that
function.

It is the code to get the image file (rimage) using the file name.

11 years agoRemoved block in restore_icon_state
Rodolfo García Peñas (kix) [Tue, 2 Oct 2012 21:19:26 +0000 (2 23:19 +0200)]
Removed block in restore_icon_state

The block inside restore_icon_state is not needed, so can be removed.

There are no changes with or without the block (variables scope,...).

11 years agoCoding style cleanup in dock.c
Rodolfo García Peñas (kix) [Tue, 2 Oct 2012 21:07:07 +0000 (2 23:07 +0200)]
Coding style cleanup in dock.c

This patch reviews the code style in dock.c, removing some
curly brackets not needed and adding other where needed.

This patch removes some lines commented and some extra lines for
better understanding.

11 years agoCode style cleanup in framewin.c
Rodolfo García Peñas (kix) [Tue, 2 Oct 2012 20:16:18 +0000 (2 22:16 +0200)]
Code style cleanup in framewin.c

This patch reviews the code style in framewin.c, removing some
curly brackets not needed.

This patch also removes some commented-out lines.

11 years agoRemove _NET_FRAME_EXTENTS on shutdown.
Iain Patterson [Fri, 14 Sep 2012 14:31:14 +0000 (14 15:31 +0100)]
Remove _NET_FRAME_EXTENTS on shutdown.

After we exit there are no window decorations therefore frame extents
are meaningless.

We could be left with parts of the window being the wrong opacity if the
property is left intact and a compositing manager configured to draw
decorations with a different opacity to the rest of the window is still
running.

Remove the _NET_FRAME_EXTENTS property from all windows when we shut
down to prevent windows from being drawn incorrectly after we're gone.

11 years agoDebian 0.95.3-20120909-1 version
Rodolfo García Peñas (kix) [Mon, 16 Jul 2012 05:58:47 +0000 (16 07:58 +0200)]
Debian 0.95.3-20120909-1 version

This is not a final version, is only a version for developers.

This version includes compatibility with debconf 9.
This version will be modified to change the libwutil2 symbols
to a new upstream version, probably 0.95.4.

11 years agoFixed invalid argument to popen in readMenuPipe().
Iain Patterson [Sat, 25 Aug 2012 09:28:04 +0000 (25 10:28 +0100)]
Fixed invalid argument to popen in readMenuPipe().

We were passing "rb" to popen(), which was failing with EINVAL with the
result that generated menus were not displayed.

11 years agoDraw window borders with correct colormap.
Iain Patterson [Sat, 25 Aug 2012 08:59:03 +0000 (25 09:59 +0100)]
Draw window borders with correct colormap.

Using window-supplied depth, visual and colormap information has the
side effect of causing window borders to be draw using inconsistent
colormap entries.  Allocate entries from each window's colormap when
drawing its border.

Force setting the border when the window is first created so it's
guaranteed to be drawn in a consistent state.

11 years ago_NET_FRAME_EXTENTS fixes.
Iain Patterson [Fri, 24 Aug 2012 16:59:30 +0000 (24 17:59 +0100)]
_NET_FRAME_EXTENTS fixes.

Recalculate frame extents when the titlebar, resize bar or border are
enabled/disabled.

Account for border when calculating top and bottom frame extents.

Quoth I,

> I've just seen that _NET_FRAME_EXTENTS isn't updated when
> disabling or enabling the titlebar, resizebar and border of a window,
> so that needs to be fixed.

  The attached patch fixes _NET_FRAME_EXTENTS not updating when using
the inspector to disable or enable the titlebar, resizebar or border.
It also fixes not taking the border width into account when
calculating the top and bottom extents.

  With the patch the window's border is drawn for 32bpp urxvt windows
with compton.  The border still isn't black, however.  That's because
the border is taken from the screen's colormap rather than the
window's.  I'll have a fix for that soon.

11 years agoAllow windows to specify their own depth.
Iain Patterson [Mon, 20 Aug 2012 14:18:21 +0000 (20 15:18 +0100)]
Allow windows to specify their own depth.

Accept windows' depth, visual and colormap instead of always using those
of the root window.  Internal windows such as menus behave as before.

In conjunction with a compositing manager on a display supporting the
RENDER extension windows can now manage their own opacity.

I wrote the patch after reading the FAQ for urxvt, which says,
regarding transparency support:

"3. Use an ARGB visual:

  urxvt -depth 32 -fg grey90 -bg rgba:0000/0000/4444/cccc

This requires XFT support, and the support of your X-server. If that
doesn't work for you, blame Xorg and Keith Packard. ARGB visuals
aren't there yet, no matter what they claim. Rxvt-Unicode contains the
necessary bugfixes and workarounds for Xft and Xlib to make it work,
but that doesn't mean that your WM has the required kludges in place."

  In conjunction with a compositing manager (I tested compton) it does
work and urxvt draws a semi-transparent background with fully opaque
foreground text and scrollbars; much prettier than applying a blanket
transparency value over the whole window with the compositing manager.
Other application windows I tested were, as expected, drawn the same
as before.

  I verified that urxvt is drawn in the same way when using xfwm4
(with builtin compositing).  Since Window Maker doesn't (at time of
writing) have its own compositing manager I should clarify that one is
required to see any benefit from this patch.

  Whether or not this feature is useful for any application other than
urxvt I don't know, though I assume that an application which chose an
ARGB visual in the same way would be able to draw itself prettily.

  On a display without RENDER things work just as they do without the
patch.  I have, however, only been able to test on a fairly standard
TrueColor display supporting multiple colour depths with 24bpp being
the default.  Testing with more ... exotic ... display types would
probably be advisable.

11 years agomenuparser.c code clean
Rodolfo García Peñas (kix) [Thu, 19 Jul 2012 22:58:12 +0000 (20 00:58 +0200)]
menuparser.c code clean

This patch do this changes:

1. Change (add/remove) blank lines
2. Join some if's in only one
3. Change c++ comments to c comments (// -> /* */)
4. Add / remove curly brackets if needed
5. Change spaces (add/remove) & set correct indentation

11 years agoMenu parser: remove d-quotes around title of entry
Christophe CURIS [Tue, 17 Jul 2012 22:19:55 +0000 (18 00:19 +0200)]
Menu parser: remove d-quotes around title of entry

When a menu entry contains a space, it is necessary to enclose it
in simple or double quotes; these were not removed and so would
appear in the menu.

11 years agoMenu parser: added boundary checks in the path-gen for #include file search
Christophe CURIS [Tue, 17 Jul 2012 22:02:22 +0000 (18 00:02 +0200)]
Menu parser: added boundary checks in the path-gen for #include file search

When generating the full path+name of file to search for a file
being #included, it was generated in a buffer that's supposedly
large enough (MAXLINE > 2*PATH_MAX). However, this limit has a few
issues (PATH_MAX seem to be able to be bigger, and worse: we can't
be sure we're given longer args).

The code was rewrote to natively include boundary checks so we're
sure we won't overflow the buffer. A few strncpy have been removed
because in this case they tend to make things harder to write.

11 years agoMenu parser: fix possible infinite loop when loading menu file
Christophe CURIS [Tue, 17 Jul 2012 21:43:37 +0000 (17 23:43 +0200)]
Menu parser: fix possible infinite loop when loading menu file

When a #include is used, the file is searched in many places; when
the file was searched in the ':'-separated list of path it could
led to infinite loop if the list contained more than one path and
that the file was not found in the first path, the ':' separator
was not properly passed over.

11 years agoFixed warning in Debian's wrapper script for wmaker
Christophe CURIS [Wed, 18 Jul 2012 21:23:50 +0000 (18 23:23 +0200)]
Fixed warning in Debian's wrapper script for wmaker

The Debian script for WindowMaker generates some warnings on startup
due to 'find' being cautious about its options, updated them to be
in line with expectations.

11 years agoRemove dup code in wAppIconCreateForDock
Rodolfo García Peñas (kix) [Tue, 17 Jul 2012 21:28:45 +0000 (17 23:28 +0200)]
Remove dup code in wAppIconCreateForDock

Some code in wAppIconCreateForDock() is duplicated with the function
get_default_icon_filename(). It can be removed.

11 years agonoDefault changed to default_icon
Rodolfo García Peñas (kix) [Tue, 17 Jul 2012 20:55:37 +0000 (17 22:55 +0200)]
noDefault changed to default_icon

The functions wDefaultGetIconFile(), get_default_icon_filename() and
get_generic_value() use the argument noDefault in order to avoid searching the
default icon. This double negation is difficult to read though. This patch
changes it to be True if the default icon should be included or false if not.

This patch changes the noDefault argument to default_icon, then the
True is now False and False is True.

The main change is at get_generic_value():

-       /* Search the default icon name - See noDefault argument! */
-       if (!value && !noDefault) {
+       /* Search the default icon name - See default_icon argument! */
+       if (!value && default_icon) {

Because the functions wDefaultGetIconFile() and get_default_icon_filename()
mainly forwards the noDefault argument to get_generic_value().

11 years agoFormat string bug in WMenuParserError
Rodolfo García Peñas (kix) [Mon, 16 Jul 2012 18:27:10 +0000 (16 20:27 +0200)]
Format string bug in WMenuParserError

There is a format string (FS) bug in the function WMenuParserError.

It is the tipical FS bug, like printf(a) instead of printf("%s", a);

See http://en.wikipedia.org/wiki/Uncontrolled_format_string for more info.

11 years agoget_wwindow_image_from_x11 icon resize
Rodolfo García Peñas (kix) [Sun, 15 Jul 2012 19:31:14 +0000 (15 21:31 +0200)]
get_wwindow_image_from_x11 icon resize

The icon size should be set when the icon is created. Therefore the icon size
for net_icon_image should be set at get_wwindow_image_from_x11(), function that
creates the image.

11 years agoRemoved scaleDownIfNeeded function (dup code)
Rodolfo García Peñas (kix) [Sun, 15 Jul 2012 19:28:00 +0000 (15 21:28 +0200)]
Removed scaleDownIfNeeded function (dup code)

The function scaleDownIfNeeded's code is duplicated with the code of
wIconValidateIconSize(), then this function can be removed. The icon
size in the switchpanel should be ~48 pixels, to allow the frame around
the icon. Then, we always should resize the icon to this size. The standard
icon size is specified in WPreferences.icon_size (usually 64 pixels).

11 years agoRemoved WScreen argument in wIconValidateIconSize
Rodolfo García Peñas (kix) [Sun, 15 Jul 2012 19:25:05 +0000 (15 21:25 +0200)]
Removed WScreen argument in wIconValidateIconSize

This patch removes the argument WScreen in wIconValidateIconSize,
because is not used.

11 years agoFixed wrong re-generation of 'config-paths.h' file
Christophe CURIS [Sun, 15 Jul 2012 17:12:58 +0000 (15 19:12 +0200)]
Fixed wrong re-generation of 'config-paths.h' file

There was a slight error in the generation of this this which led
it to grow in size everytime the Makefile is regenerated.

11 years agoSmall cleanup in Git's ignore file
Christophe CURIS [Sun, 15 Jul 2012 16:32:35 +0000 (15 18:32 +0200)]
Small cleanup in Git's ignore file

11 years agoAdded some comments and spaces in Git's ignore file
Christophe CURIS [Sun, 15 Jul 2012 16:21:08 +0000 (15 18:21 +0200)]
Added some comments and spaces in Git's ignore file

It helps to understand why a file is present in this file, which
in turn can help to understand where a file comes from and it makes
updates to the file easier

11 years agoBetter icon scale
Rodolfo García Peñas (kix) [Sun, 15 Jul 2012 13:25:10 +0000 (15 15:25 +0200)]
Better icon scale

The icons should be scaled if their size is "max_size - ~3 pixels".
Tipically, max_size is 64 pixels. With the current wIconValidateIconSize
the max size for an icon is "64 pixels", then the icon don't have border
and is ugly. This problem is in the dock icons and in the switchpanel.

The new wIconValidateIconSize function don't use the fixel value of 64
pixels, uses the argument max_size to get the final icon size. The icon
is scaled holding the aspect ratio and reserve ~2 or ~3 pixels to hold
left space to the icon border. Now the icon is inside the icon space,
with border.

This patch removes the preprocessor option of DONT_SCALE_ICONS, because
all the icons should be scaled if needed, to hold a beatiful interface.

11 years agoswitchpanel default icon removed
Rodolfo García Peñas (kix) [Sun, 15 Jul 2012 09:10:40 +0000 (15 11:10 +0200)]
switchpanel default icon removed

The default icon (defIcon) is never used because the function wDefaultGetImage
always returns a icon (it searches the default icon). So we can remove the
defIcon variable, its creation and remove code.

11 years agoNew function create_default_icon
Rodolfo García Peñas (kix) [Sat, 14 Jul 2012 10:07:45 +0000 (14 12:07 +0200)]
New function create_default_icon

The function create_default_icon sets the panel's default icon. This
is interesting to have a "cache" icon and don't search the default
icon more than one time if the icons don't have icon associated.

The code of create_default_icon was included in the addIconForWindow()
function, this patch only moves it to get a better (clear) code.

11 years agoswitchpanel.c code clean
Rodolfo García Peñas (kix) [Sat, 14 Jul 2012 09:55:59 +0000 (14 11:55 +0200)]
switchpanel.c code clean

Some code clean in the file switchpanel.c, like spaces, curly brackets,
tabs, join ifs,...

11 years agoWPrefs: XKeycodeToKeysym deprecated function
Rodolfo García Peñas (kix) [Sun, 15 Jul 2012 08:54:44 +0000 (15 10:54 +0200)]
WPrefs: XKeycodeToKeysym deprecated function

The function XKeycodeToKeysym is deprecated and should be replaced
by XkbKeycodeToKeysym.

11 years agoRemove dependency to CPP: removed stuff related to CPP calls
Christophe CURIS [Sat, 23 Jun 2012 17:49:52 +0000 (23 19:49 +0200)]
Remove dependency to CPP: removed stuff related to CPP calls

Now that the built-in parser has support for all the feature of CPP
being used by WindowMaker's default menu, we can remove the stuff
related to calling CPP:
 - code for preparing and running CPP;
 - compile-time option to de-activate the call to CPP;
 - command-line option

11 years agoRemove dependency to CPP: add support for conditional directives
Christophe CURIS [Sat, 23 Jun 2012 16:18:31 +0000 (23 18:18 +0200)]
Remove dependency to CPP: add support for conditional directives

It is now possible to use #ifdef/#ifndef to exclude some part of the
file. The implementation uses a stack to track conditionals so it is
possible to use nested constructs.

11 years agoRemove dependency to CPP: added pre-defined macros
Christophe CURIS [Sat, 23 Jun 2012 13:21:43 +0000 (23 15:21 +0200)]
Remove dependency to CPP: added pre-defined macros

A number of macros are pre-defined by WindowMaker for CPP in the
function 'MakeCPPArgs', they are now available in the internal
parser too. CPP also had some predefined macros, a subset of them
have been added.
The definition have been split in two parts:
 - the macro that are dependant on WindowMaker parameters are
defined by WindowMaker (src/rootmenu.c)
 - those that are independant, which can be defined by the parser
itself (WINGs/menuparser_macros.c)

11 years agoRemove dependency to CPP: support for #define macros
Christophe CURIS [Fri, 22 Jun 2012 22:25:38 +0000 (23 00:25 +0200)]
Remove dependency to CPP: support for #define macros

This adds support for defining new macros, with or without parameters, which
when found afterwards in the text are replaced by their definition.
The complex analysis for arguments replacement is done at macro definition
time, so it is done only once and the macro expansion will be fast.
The macro-related functions have been placed in their own file because it is
quite a complex task and we do not want filesize to explode, it is always
better to keep things human-sized.

11 years agoRemove dependency to CPP: support for #include directive
Christophe CURIS [Sun, 17 Jun 2012 22:49:53 +0000 (18 00:49 +0200)]
Remove dependency to CPP: support for #include directive

The parser is prepared to handle '#' directives, starting with file
inclusion. The search path for the file are taken from what was
actually given to CPP. There is an arbitrary limit to the inclusion
nesting, which is actually not a design limitation but a security
to avoid infinite include loops.

11 years agoRemove dependency to CPP: new parser that handles comments
Christophe CURIS [Sun, 17 Jun 2012 21:56:34 +0000 (17 23:56 +0200)]
Remove dependency to CPP: new parser that handles comments

Wrote a new parsing code that is able to skip over comments.
Note that because CPP is still active, you will not see any
effect unless you disable CPP pre-processing.

11 years agoRemove dependency to CPP: add function to report problems while parsing
Christophe CURIS [Sun, 8 Jul 2012 00:12:36 +0000 (8 02:12 +0200)]
Remove dependency to CPP: add function to report problems while parsing

The default function used so far provides informations not so useful
to user, like wmaker's source file, line number and function; it
also cannot provide the line number from the parsed file because cpp
messes this information.

With this dedicated function we try to provide useful things which
are being tracked by the parser internally, like valid line number
and the name of the file being read (which can be convenient in the
case of #include, for which we may also be able to provide the
inclusion tree!)

11 years agoRemove dependency to CPP: merged 'getLine' and 'separateline' into a single function...
Christophe CURIS [Sat, 7 Jul 2012 23:24:03 +0000 (8 01:24 +0200)]
Remove dependency to CPP: merged 'getLine' and 'separateline' into a single function call

From caller point of view, the two function have been merged into a
single function in the API. This will be needed by the advanced
parser that will have to not separate the concept of a 'line' and
the concept of 'content' (due to empty/comment lines, multi-line
comments, long lines split with '\')

11 years agoRemove dependency to CPP: create structure to keep info of file being parsed
Christophe CURIS [Sun, 8 Jul 2012 12:20:24 +0000 (8 14:20 +0200)]
Remove dependency to CPP: create structure to keep info of file being parsed

All the information related to the file being parsed are stored in
a single place. The content of this structure is not visible to
caller to avoid messing the content; the parsing will be handled as
methods to this object.

Please note that all functions visible as part of the parser's API
are using the CamelCaseNotation to be consistent with the rest of
the API; however all internal functions use the non_camel_case_syntax
to follow the coding style set by Carlos for the project.

11 years agoRemove dependency to CPP: Moving parser functions to a dedicated file
Christophe CURIS [Sun, 8 Jul 2012 12:04:44 +0000 (8 14:04 +0200)]
Remove dependency to CPP: Moving parser functions to a dedicated file

Due to the tasks to take in charge, the internal parser will grow in
size to support basic CPP feature, so it is a good idea to start by
moving the current functions into a dedicated file.

11 years agoRemove dup code from getWindowMakerIconImage()
Rodolfo García Peñas (kix) [Tue, 3 Jul 2012 10:43:02 +0000 (3 12:43 +0200)]
Remove dup code from getWindowMakerIconImage()

The code to find the icon in the function getWindowMakerIconImage()
is duplicated, because it is the same code as in get_default_icon_filename()

This patch includes the prototypes of get_default_icon_filename()
and get_default_icon_rimage() in defaults.h, so these functions
can be used in other files.

11 years agowDefaultGetImage splitted
Rodolfo García Peñas (kix) [Tue, 3 Jul 2012 10:00:47 +0000 (3 12:00 +0200)]
wDefaultGetImage splitted

The function wDefaultGetImage() is splitted in two:

1. get_default_icon_filename(): This function returns the full
   path of an icon. The function searches the icon in the database
   using instance and class.
2. get_default_icon_rimage(): This function returns the RImage for
   a given image path (full path). This function validates the icon
   size, so the icon is fully usable.

The function get_default_icon_filename() now adds the .app icons in the
search (using wApplicationExtractDirPackIcon()). To do it, the command
should be included, because this function searches '"command".app' icons.
Setting the command to NULL, this case is not used.

To do it we need the function wApplicationExtractDirPackIcon() defined
at appicon.c, so we need set the function as non-static and provide their
prototype in appicon.h.

This patch also includes an extra pointer check at wDefaultGetStartWorkspace
to make sure that WDWindowAttributes exists.

11 years agoRemove unused argument from wDefaultFillAttributes()
Rodolfo García Peñas (kix) [Tue, 3 Jul 2012 09:47:15 +0000 (3 11:47 +0200)]
Remove unused argument from wDefaultFillAttributes()

The function wDefaultFillAttributes() doesn't use the argument WScreen,
so it can be removed.

11 years agoRemove unused argument from wDefaultGetIconFile()
Rodolfo García Peñas (kix) [Tue, 3 Jul 2012 09:42:39 +0000 (3 11:42 +0200)]
Remove unused argument from wDefaultGetIconFile()

The function wDefaultGetIconFile() doesn't use the argument WScreen,
so it can be removed.

11 years agoRemove unused argument from init_wdefaults()
Rodolfo García Peñas (kix) [Tue, 3 Jul 2012 09:37:56 +0000 (3 11:37 +0200)]
Remove unused argument from init_wdefaults()

The function init_wdefaults() doesn't use the argument WScreen,
so it can be removed.

11 years agoSupport _NET_FRAME_EXTENTS.
Iain Patterson [Wed, 4 Jul 2012 07:31:39 +0000 (4 08:31 +0100)]
Support _NET_FRAME_EXTENTS.

This patch adds support for the _NET_FRAME_EXTENTS property as
described in the EWMH spec.  With it I was able to use the compton
compositing manager to draw fully opaque windows with semi-transparent
titlebars and resizebars.

Set the _NET_FRAME_EXTENTS property based on border widths and
titlebar/resizebar heights.

The EWMH spec says:

"_NET_FRAME_EXTENTS, left, right, top, bottom, CARDINAL[4]/32

The Window Manager MUST set _NET_FRAME_EXTENTS to the extents of the
window's frame.  left, right, top and bottom are widths of the
respective borders added by the Window Manager."

11 years agoMore (un)maximize tweaks.
Iain Patterson [Tue, 26 Jun 2012 15:20:43 +0000 (26 16:20 +0100)]
More (un)maximize tweaks.

Update the saved X co-ordinate of a window which was moved when
maximized (only) vertically so that unmaximizing the window restores
its dimensions without warping it back to its previous X position.
Similarly update the saved Y co-ordinate of a window which was
moved when maximized (only) horizontally.

Handle Maximus as a special case.  We remember the Maximusized X and Y
co-ordinates then adjust the restored co-ordinates relative to the
delta between the window's position just after Maximusizing and its
position just before restoring.  So for example if a window is
Maximusized, moved 100 pixels to the left and restored, it will end
up 100 pixels left of its original geometry.

Also fix "jumping window" bug reported by Christian Wittmer:

This "jumping window" happens only when you
1) open new xterm (STRG +n)
2) current position is (+64, +0)
3) maximize window vertically
4) undo maximizing
5) move window to the right or left (up or down as you like)
I moved right to (+450, +0)
6) maximize vertically again
7) and undo maximizing
8) window jumps back to (+64, ..) position

If you move a new opened window to a new position (e.g. +200, +200)
and then start with "3)". window is jumping back "+200, +200"

11 years agoRemove unused stuff from session.h
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 21:39:57 +0000 (25 23:39 +0200)]
Remove unused stuff from session.h

The struct WSessionData is not used and the function wSessionGetStateFor
is only defined, remove them.

11 years agowindow.h: Remove unused variables from WWindow struct
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 21:06:31 +0000 (25 23:06 +0200)]
window.h: Remove unused variables from WWindow struct

The variables waiting_save_ack, dragged_while_fmaximized,
buttons_dont_fit, rebuild_texture and needs_full_repaint are not used,
so they can be removed.

11 years agoVariables user_changed_* can be removed
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 19:56:19 +0000 (25 21:56 +0200)]
Variables user_changed_* can be removed

The variables user_changed_ are set but their values are not checked/used
in the code, so they can be removed.

11 years agoRemove never-set variable net_state_from_client
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 19:53:23 +0000 (25 21:53 +0200)]
Remove never-set variable net_state_from_client

Even though net_state_from_client was never being set, it was
being tested inside a

if (!wwin->flags.net_state_from_client)

which according to testing was always being true (probably because gcc
initializes it to zero). But this situation is confusing, so it's
better to remove the if() test altogether as that is the intention
if net_state_from_client is not explicitly set (which it isn't in
the current wmaker source).

This situation is analogous to:

[mafra@Pilar:c]$ cat init.c

int main(void)
{
int a;

if (!a)
printf("No a = %d\n", a);
        return 0;
}
[mafra@Pilar:c]$ ./init
No a = 0

11 years agoRemove unused variable wm_name_changed
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 19:51:47 +0000 (25 21:51 +0200)]
Remove unused variable wm_name_changed

wm_name_changed is not used and can be removed.

11 years agoRemove unused wWindowCanReceiveFocus()
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 19:50:04 +0000 (25 21:50 +0200)]
Remove unused wWindowCanReceiveFocus()

The function wWindowCanReceiveFocus() is not used, remove it.

11 years agoRemove unused variables from WSessionData struct
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 19:47:56 +0000 (25 21:47 +0200)]
Remove unused variables from WSessionData struct

The variables user_changed_width and user_changed_height are not used,
so they can be safely removed.

11 years agoNew colormap header file and remove unused functions
Rodolfo García Peñas (kix) [Mon, 25 Jun 2012 11:29:35 +0000 (25 13:29 +0200)]
New colormap header file and remove unused functions

The functions related to colormap are moved from funcs.h to the new
file colormap.h. These files are included where needed.

The functions wColormapInstallRoot and wColormapUninstallRoot are
removed, because they are not used.

11 years agoNew move_window function
Rodolfo García Peñas (kix) [Fri, 22 Jun 2012 15:35:03 +0000 (22 17:35 +0200)]
New move_window function

11 years agoAdd helper functions for appicon list management
Rodolfo García Peñas (kix) [Fri, 22 Jun 2012 14:39:46 +0000 (22 16:39 +0200)]
Add helper functions for appicon list management

New functions

static void add_to_appicon_list()
static void remove_from_appicon_list()

to add or remove appicons from the app_icon_list, making the code easier
to follow.

11 years agowmaker.inst: Remove test for LITE and KDE message
Carlos R. Mafra [Sun, 24 Jun 2012 22:07:39 +0000 (24 23:07 +0100)]
wmaker.inst: Remove test for LITE and KDE message

LITE was removed in fe736e849c9 ("Remove LITE config option"), but
the check for it in wmaker.inst was missed.

Furthermore, remove confusing message about wmaker being configured for KDE.

11 years agoMoving header functions to main.h
Rodolfo García Peñas (kix) [Sun, 24 Jun 2012 10:35:24 +0000 (24 12:35 +0200)]
Moving header functions to main.h

The functions of main.c should be included in main.h, not in funcs.h.
This patch adds the main.h file and moves the function prototypes to
this file.

The not needed "include funcs.h" are removed.

11 years agoXKeycodeToKeysym deprecated function
Rodolfo García Peñas (kix) [Sun, 24 Jun 2012 09:11:46 +0000 (24 11:11 +0200)]
XKeycodeToKeysym deprecated function

The function XKeycodeToKeysym is deprecated and should be replaced
by XkbKeycodeToKeysym.

11 years agorootmenu header file updated
Rodolfo García Peñas (kix) [Sun, 24 Jun 2012 08:48:22 +0000 (24 10:48 +0200)]
rootmenu header file updated

The contents of the rootmenu.h file are not used and can be removed,
but the prototypes of rootmenu.c are in funcs.h and should be moved
to the correct (rootmenu.h) file.

11 years agoAddress 'may be used uninitialized' warnings
Carlos R. Mafra [Sat, 23 Jun 2012 16:32:42 +0000 (23 17:32 +0100)]
Address 'may be used uninitialized' warnings

Making all in src
  CC     actions.o
actions.c: In function ‘wMaximizeWindow’:
actions.c:421:14: warning: ‘maximus_height’ may be used uninitialized in this function [-Wuninitialized]
actions.c:440:29: warning: ‘maximus_width’ may be used uninitialized in this function [-Wuninitialized]
actions.c:442:35: warning: ‘maximus_y’ may be used uninitialized in this function [-Wuninitialized]
actions.c:454:18: warning: ‘maximus_x’ may be used uninitialized in this function [-Wuninitialized]
  CCLD   wmaker

These warnings were harmless because they were at a point where
find_Maximus_geometry() had already been called. So let's simply initialize
them to zero to silence gcc.

11 years agoRemove code duplication in winmenu.c
Rodolfo García Peñas (kix) [Sat, 23 Jun 2012 11:05:30 +0000 (23 13:05 +0200)]
Remove code duplication in winmenu.c

There are some code duplication in winmenu.c. Two new functions,

- open_window_menu_core
- prepare_menu_position

Join the common code and then the duplicated code can be removed.

11 years agoAddress unprototyped call in dock.c
Carlos R. Mafra [Sat, 23 Jun 2012 11:04:29 +0000 (23 12:04 +0100)]
Address unprototyped call in dock.c

Create a header file dockedapp.h to address a long-standing warning
which pollutes the compilation output with --enable-silent-rules:

Making all in src
  CC     dock.o
dock.c: In function ‘wDockDetach’:
dock.c:2118:3: warning: call to function ‘DestroyDockAppSettingsPanel’ without a real prototype [-Wunprototyped-calls]
dock.c:65:13: note: ‘DestroyDockAppSettingsPanel’ was declared here
  CCLD   wmaker

11 years agoicon.c code cleanup
Rodolfo García Peñas (kix) [Sat, 23 Jun 2012 10:19:31 +0000 (23 12:19 +0200)]
icon.c code cleanup

11 years agoCleanup superfluous.c a bit
Rodolfo García Peñas (kix) [Sat, 23 Jun 2012 09:42:26 +0000 (23 11:42 +0200)]
Cleanup superfluous.c a bit

The superfluous.[ch] files have a few minor issues, this patch addresses some of them:

- Move the defines to the top of the superfluous.c file
- Include the ifdef NORMAL_ICON_KABOOM inside the DoKaboom() function
  because the DoKaboom is used without the NORMAL_ICON_KABOOM ifdef in
  other files.
- Include the ifdef WINDOW_BIRTH_ZOOM inside the DoWindowBirth() function,
  therefore the function don't needs to be defined twice (with and whitout
  WINDOW_BIRTH_ZOOM define.
- Now the functions are defined in superfluous.h and the externs are not
  needed.
  - We need include the dock.h in the superflous.h because is used by the
    definition of MakeGhostDock().
  - We need include the superfluous.h in window.c (removing the extern)

11 years agoCorrect window shading logic.
Iain Patterson [Fri, 22 Jun 2012 16:03:59 +0000 (22 17:03 +0100)]
Correct window shading logic.

Fons Adriaensen reported that:

> WM's 'unshade' seems to use multiple Expose events [...] even when
> all animations and 'superfluous effects' are disabled.

Typo in shade_animate() could cause windows to be animated when the
no_animations preference was set. With this patch I see fewer
XMoveWindow() calls and quicker shading.