Re: Problem with xfig

2012-11-25 Thread BALATON Zoltan

On Sun, 25 Nov 2012, Rodolfo García Peñas wrote:

I am not sure if the testing application is working.
The application only show a dock (miniwindow) with a
white square inside.

kix@osaka:~/src/wmaker/wmaker-crm/src$ /home/kix/wmicontest
Opened display :1
XCreateSimpleWindow returned: 341
XCreateSimpleWindow returned: 342
XMapWindow returned: 1


Read it before you run it! Press enter to move on to the next step when 
it opens a window. You can try to minimise it. Then press enter again (in 
the terminal you've started it from) to finish.



If I run it with the lines commented, then the application
doesn't have the white square.


That means it would break apps which display something in their appicon. 
Did you try dockapps? (The white square is the icon window.)


Regards,
BALATON Zoltan

Re: Problem with xfig

2012-11-25 Thread Rodolfo García Peñas
On Sun, 25 Nov 2012, BALATON Zoltan escribió:

> On Sun, 25 Nov 2012, Rodolfo García Peñas wrote:
> >I am not sure if the testing application is working.
> >The application only show a dock (miniwindow) with a
> >white square inside.
> >
> >kix@osaka:~/src/wmaker/wmaker-crm/src$ /home/kix/wmicontest
> >Opened display :1
> >XCreateSimpleWindow returned: 341
> >XCreateSimpleWindow returned: 342
> >XMapWindow returned: 1
> 
> Read it before you run it! Press enter to move on to the next step
> when it opens a window. You can try to minimise it. Then press enter
> again (in the terminal you've started it from) to finish.
> 
> >If I run it with the lines commented, then the application
> >doesn't have the white square.
> 
> That means it would break apps which display something in their
> appicon. Did you try dockapps? (The white square is the icon
> window.)

The problem is because the "icon->icon_win == None". See the wIconUpdate 
function at [1]. This function is different than the next branch, I did a lot 
of changes, but the idea is the same. See the flow with the removed lines:

icon_create_for_wwindow
set_icon_for_window: wIconUpdate
wIconUpdate icon 0x936cd0
wwin 0x93f000 flag 0
wIconUpdate:get_rimage_icon_from_user_icon 4 icon 0x936cd0
wIconUpdate icon 0x936cd0
wwin 0x93f000 flag 0
wIconUpdate:get_rimage_icon_from_user_icon 4 icon 0x936cd0

Or with the lines (original code/next code):

icon_create_for_wwindow
set_icon_for_window: wIconUpdate
wIconUpdate icon 0x19bfd30
wwin 0x19c1a90 flag 0
wIconUpdate:get_rimage_icon_from_icon_win 2 icon 0x19bfd30
wIconUpdate icon 0x19bfd30
wwin 0x19c1a90 flag 0
wIconUpdate:get_rimage_icon_from_icon_win 2 icon 0x19bfd30

If I remove the lines, then "icon->icon_win == None", and then jump to the 
default icon. Else, get the icon from the wm_hints/net_icon_image.

About your question about dockapps, they are fine here. Why?

Dockapps works in a extrange way. The try to get the image for their dock. If 
the image is found, then, they set the image, else, set the wmaker default 
image. Whats happend if the application is running, then, the application 
background is set to the tile background (grey/blue/...), and the put the 
application inside the icon. But it the application is not running, the icon 
for the application is painted. If you click on the dockapp, the icon image is 
removed, the background is set and the application is put inside the icon.

Regards,
kix

[1]
void wIconUpdate(WIcon *icon, RImage *image)
{
WWindow *wwin = NULL;
printf("wIconUpdate icon %p\n", icon);

if (image) {
icon->file_image = image;
} else {
if (icon && icon->owner)
wwin = icon->owner;

if (wwin)
printf("wwin %p flag %d\n", wwin, WFLAGP(wwin, 
always_user_icon));

if (wwin && WFLAGP(wwin, always_user_icon)) {
/* Forced use user_icon */
printf("wIconUpdate:get_rimage_icon_from_user_icon 1 
icon %p\n", icon);
get_rimage_icon_from_user_icon(icon);
} else if (icon->icon_win != None) {
/* Free the icon info */
unset_icon_image(icon);

/* Get the Pixmap from the WIcon's Window */
printf("wIconUpdate:get_rimage_icon_from_icon_win 2 
icon %p\n", icon);
icon->file_image = get_rimage_icon_from_icon_win(icon);
} else if (wwin && wwin->net_icon_image) {
/* Remove the icon image */
unset_icon_image(icon);

/* Get the icon from wwin->net_icon_image.
 * wwin->net_icon_image is NULL only if no icon was
 * found. Then, return the default image */
printf("wIconUpdate:get_window_image_def 3 icon %p\n", 
icon);
icon->file_image = get_window_image_def(wwin);
} else {
/* Get the Pixmap from the user */
printf("wIconUpdate:get_rimage_icon_from_user_icon 4 
icon %p\n", icon);
get_rimage_icon_from_user_icon(icon);
}
}

update_icon_pixmap(icon);
}



-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 01/36] get_rimage_icon_from_x11() removed

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function get_rimage_icon_from_x11() set the window icon image
in the icon. This function is used only once and their code is so
small (only two code lines).

This patch removes the function and moves the code to wIconUpdate.
---
 src/icon.c |   18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 13a0c94..d2c8d10 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -64,7 +64,6 @@ static void set_dockapp_in_icon(WIcon *icon);
 static void get_rimage_icon_from_icon_win(WIcon *icon);
 static void get_rimage_icon_from_user_icon(WIcon *icon);
 static void get_rimage_icon_from_default_icon(WIcon *icon);
-static void get_rimage_icon_from_x11(WIcon *icon);
 
 static void icon_update_pixmap(WIcon *icon, RImage *image);
 static void unset_icon_image(WIcon *icon);
@@ -612,8 +611,12 @@ void wIconUpdate(WIcon *icon, RImage *image)
/* Get the Pixmap from the WIcon */
get_rimage_icon_from_icon_win(icon);
} else if (wwin && wwin->net_icon_image) {
-   /* Use _NET_WM_ICON icon */
-   get_rimage_icon_from_x11(icon);
+   /* Remove the icon image */
+   unset_icon_image(icon);
+
+   /* Set the new icon image, use _NET_WM_ICON icon
+* (same icon that the window) */
+   icon->file_image = RRetainImage(wwin->net_icon_image);
} else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & 
IconPixmapHint)) {
/* Get the Pixmap from the wm_hints, else, from the 
user */
unset_icon_image(icon);
@@ -656,15 +659,6 @@ void update_icon_pixmap(WIcon *icon)
wIconPaint(icon);
 }
 
-static void get_rimage_icon_from_x11(WIcon *icon)
-{
-   /* Remove the icon image */
-   unset_icon_image(icon);
-
-   /* Set the new icon image */
-   icon->file_image = RRetainImage(icon->owner->net_icon_image);
-}
-
 static void get_rimage_icon_from_user_icon(WIcon *icon)
 {
if (icon->file_image)
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 02/36] get_rimage_icon_from_default_icon() returns image

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function get_rimage_icon_from_default_icon() now returns the
RImage instead assign it to the icon file.

This option is better because this function can be used in other
functions to have always image in the icon.
---
 src/icon.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index d2c8d10..906dbb2 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -63,7 +63,7 @@ static WIcon *icon_create_core(WScreen *scr, int coord_x, int 
coord_y);
 static void set_dockapp_in_icon(WIcon *icon);
 static void get_rimage_icon_from_icon_win(WIcon *icon);
 static void get_rimage_icon_from_user_icon(WIcon *icon);
-static void get_rimage_icon_from_default_icon(WIcon *icon);
+static RImage *get_rimage_icon_from_default_icon(WIcon *icon);
 
 static void icon_update_pixmap(WIcon *icon, RImage *image);
 static void unset_icon_image(WIcon *icon);
@@ -664,10 +664,13 @@ static void get_rimage_icon_from_user_icon(WIcon *icon)
if (icon->file_image)
return;
 
-   get_rimage_icon_from_default_icon(icon);
+   /* Remove the icon image */
+   unset_icon_image(icon);
+
+   icon->file_image = get_rimage_icon_from_default_icon(icon);
 }
 
-static void get_rimage_icon_from_default_icon(WIcon *icon)
+static RImage *get_rimage_icon_from_default_icon(WIcon *icon)
 {
WScreen *scr = icon->core->screen_ptr;
 
@@ -675,11 +678,8 @@ static void get_rimage_icon_from_default_icon(WIcon *icon)
if (!scr->def_icon_rimage)
scr->def_icon_rimage = get_default_image(scr);
 
-   /* Remove the icon image */
-   unset_icon_image(icon);
-
/* Set the new icon image */
-   icon->file_image = RRetainImage(scr->def_icon_rimage);
+   return RRetainImage(scr->def_icon_rimage);
 }
 
 /* Get the RImage from the WIcon of the WWindow */
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 00/36] Icon changes

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

Hi,

first, sorry for this too many patches. I know I should send less patches 
together.

I will try to show the main ideas for the patches, All of them has a lot 
information, I spent more time with the commit documentation. Some patches 
could be rebased, some of them are splitted for better understanding, and other 
because I wrote the patch, I found a better way, then I create other patch, but 
I didn't rebase both patches (24 and 26 are an example) because I did that way. 
Feel free to rebase some of them.

I will describe some ideas later, but the main idea is faster code, less calls 
in the application creation flow. After these patches, to create an icon we use 
about 4 functions and 4 calls, before these patches, we use about the same 
functions (4,5), but about 12 calls.

I tested the patches, now all is ok here. But please, test the patches.

Main ideas:

1. Less wIconUpdate calls

wIconUpdate function is used to change the image for an icon. This function was 
used more times than we need. We should call this function when the icon image 
change or when we don't know if the image change. Else, should be replaced by 
wIconPaint (only paints and change the title) or update_icon_pixmap(icon) if we 
need recreate the pixmap. update_icon_pixmap(icon) will call wIconPaint()

To do it, I re-wrote some functions to return the RImage. Like:

0001-get_rimage_icon_from_x11-removed.patch
0002-get_rimage_icon_from_default_icon-returns-image.patch
0003-get_rimage_icon_from_icon_win-default-image.patch
0004-get_rimage_icon_from_icon_win-returns-image.patch

This is one of the most important ideas of these patches, and some patches to 
remove wIconUpdate are:

0012-icon_create_for_dock-without-wIconUpdate.patch
0015-create_appicon_from_dock-without-wIconUpdate.patch
0017-Dock-operations-don-t-need-wIconUpdate.patch
0018-removeAppIconFor-without-wIconUpdate.patch
0021-wIconUpdate-uses-get_window_image_def.patch
0022-Remove-wIconUpdate-wm_hints-dead-code.patch
0029-tileObserver-refresh-with-the-same-image.patch
0019-wClientCheckProperty-uses-updateIconImage.patch
0020-Icon-creation-for-wwindow-moved-to-a-function.patch

Then the code is faster and we have better possibilities, like create the icon 
in one step

0014-Aplication-creates-appicon-in-one-step.patch

2. Simplify function arguments

Some functions receives as argument an object, but only needs one thing. Is 
better send only the thing needed than the big object. For example, in th patch 
0005-get_rimage_icon_from_default_icon-WScreen-argument.patch, I changed WIcon 
by WScreen:

-static RImage *get_rimage_icon_from_default_icon(WIcon *icon);
+static RImage *get_rimage_icon_from_default_icon(WScreen *scr);

Then is possible use this function for code without icons. I used this idea 
with 0006-wm_hints-functions-argument-adjust.patch too.

3. Window images clear

We have two types of images, window image (net_icon_image) and icon image 
(WIcon->icon). I created some functions to get the window image using all 
possible methods and return the value using only one call. There are some 
patches with this code, like:

0007-Window-image-functions.patch
0008-Window-image-includes-wm_hints.patch
0011-wIconStore-already-includes-wm_hints-image.patch
0030-New-function-update_net_icon_image.patch

4. Updated the winspector, to get the right icons. I think now all icons work 
fine in winspector.c.

0009-winspector-applySettings-uses-get_window_image_from_.patch
0010-winspector-applySettings-include-all-client-images.patch
0035-wDefaultUpdateIcons-uses-wIconUpdate.patch

5. Clean code and remove dup code. When I wrote some code I clean the near 
functions. I send these clean patches as independent patches, but are not a 
deep clean.

0013-Icon-file-checking-and-dialog-function.patch
0023-Removed-get_rimage_icon_from_wm_hints.patch
0025-wGetIconName-False-block-moved-up.patch
0033-winspector.c-save-and-apply-Settings-code-clean.patch
0034-Set-the-right-icon-on-winspector-save.patch
0036-winspector.c-code-clean.patch

Now all windows have their own icon, not just when minimize it. Now we can 
change the icon in winspector.c, with the window open or minimized.

0031-WWindow-has-always-icon-Remove-wIconDestroy.patch
0032-WWindow-always-has-icon-Add-WIcon.patch

6. Some bugs. Other problems are resolved in the patches I did, not as 
independent patches. More info in the commit doc.

0016-Avoid-crash-in-icon-move-without-command.patch

7. Issues, not bugs:

0024-wIconChangeTitle-rewritten.patch
0026-wIconChangeTitle-rewrited.patch
0027-All-dockapps-have-bave-background.patch
0028-Dockapps-don-t-have-title.patch


Best regards,
kix
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 04/36] get_rimage_icon_from_icon_win() returns image

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function get_rimage_icon_from_icon_win() now returns a image
instead set the icon image.
---
 src/icon.c |   17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index e979a6f..df2f96c 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -61,7 +61,7 @@ static void miniwindowDblClick(WObjDescriptor * desc, XEvent 
* event);
 static WIcon *icon_create_core(WScreen *scr, int coord_x, int coord_y);
 
 static void set_dockapp_in_icon(WIcon *icon);
-static void get_rimage_icon_from_icon_win(WIcon *icon);
+static RImage *get_rimage_icon_from_icon_win(WIcon *icon);
 static void get_rimage_icon_from_user_icon(WIcon *icon);
 static RImage *get_rimage_icon_from_default_icon(WIcon *icon);
 
@@ -608,8 +608,11 @@ void wIconUpdate(WIcon *icon, RImage *image)
/* Forced use user_icon */
get_rimage_icon_from_user_icon(icon);
} else if (icon->icon_win != None) {
-   /* Get the Pixmap from the WIcon */
-   get_rimage_icon_from_icon_win(icon);
+   /* Free the icon info */
+   unset_icon_image(icon);
+
+   /* Get the Pixmap from the WIcon's Window */
+   icon->file_image = get_rimage_icon_from_icon_win(icon);
} else if (wwin && wwin->net_icon_image) {
/* Remove the icon image */
unset_icon_image(icon);
@@ -683,7 +686,7 @@ static RImage *get_rimage_icon_from_default_icon(WIcon 
*icon)
 }
 
 /* Get the RImage from the WIcon of the WWindow */
-static void get_rimage_icon_from_icon_win(WIcon *icon)
+static RImage *get_rimage_icon_from_icon_win(WIcon *icon)
 {
RImage *image;
 
@@ -693,11 +696,7 @@ static void get_rimage_icon_from_icon_win(WIcon *icon)
if (!image)
image = get_rimage_icon_from_default_icon(icon);
 
-   /* Free the icon info */
-   unset_icon_image(icon);
-
-   /* Set the new info */
-   icon->file_image = image;
+   return image;
 }
 
 /* Set the dockapp in the WIcon */
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 05/36] get_rimage_icon_from_default_icon WScreen argument

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

get_rimage_icon_from_default_icon() needs an screen to return the
default icon.

Is better use the WScreen than the icon, because if we don't have
an icon, we can still get the default icon using only the WScreen.
---
 src/icon.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index df2f96c..51dcd41 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -63,7 +63,7 @@ static WIcon *icon_create_core(WScreen *scr, int coord_x, int 
coord_y);
 static void set_dockapp_in_icon(WIcon *icon);
 static RImage *get_rimage_icon_from_icon_win(WIcon *icon);
 static void get_rimage_icon_from_user_icon(WIcon *icon);
-static RImage *get_rimage_icon_from_default_icon(WIcon *icon);
+static RImage *get_rimage_icon_from_default_icon(WScreen *scr);
 
 static void icon_update_pixmap(WIcon *icon, RImage *image);
 static void unset_icon_image(WIcon *icon);
@@ -670,13 +670,11 @@ static void get_rimage_icon_from_user_icon(WIcon *icon)
/* Remove the icon image */
unset_icon_image(icon);
 
-   icon->file_image = get_rimage_icon_from_default_icon(icon);
+   icon->file_image = 
get_rimage_icon_from_default_icon(icon->core->screen_ptr);
 }
 
-static RImage *get_rimage_icon_from_default_icon(WIcon *icon)
+static RImage *get_rimage_icon_from_default_icon(WScreen *scr)
 {
-   WScreen *scr = icon->core->screen_ptr;
-
/* If the icon don't have image, we should use the default image. */
if (!scr->def_icon_rimage)
scr->def_icon_rimage = get_default_image(scr);
@@ -694,7 +692,7 @@ static RImage *get_rimage_icon_from_icon_win(WIcon *icon)
image = get_window_image_from_x11(icon->icon_win);
 
if (!image)
-   image = get_rimage_icon_from_default_icon(icon);
+   image = 
get_rimage_icon_from_default_icon(icon->core->screen_ptr);
 
return image;
 }
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 03/36] get_rimage_icon_from_icon_win() default image

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function get_rimage_icon_from_icon_win() now returns the default
image if the window image (_wm_net_icon) is not provided by the
application.

Now get_rimage_icon_from_icon_win() always returns an image.
---
 src/icon.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/icon.c b/src/icon.c
index 906dbb2..e979a6f 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -690,6 +690,9 @@ static void get_rimage_icon_from_icon_win(WIcon *icon)
/* Create the new RImage */
image = get_window_image_from_x11(icon->icon_win);
 
+   if (!image)
+   image = get_rimage_icon_from_default_icon(icon);
+
/* Free the icon info */
unset_icon_image(icon);
 
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 06/36] wm_hints functions argument adjust

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The functions get_wwindow_image_from_wmhints() and
get_rimage_icon_from_wm_hints() uses now argument more strict.

get_rimage_icon_from_wm_hints:
-RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
+RImage *get_rimage_icon_from_wm_hints(WWindow *wwin)

This function returns the image from window, so the argument should
be Window or WWindow. In this case is better WWindow, because we can
use WScreen or other arguments.

get_wwindow_image_from_wmhints:
-static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
+static RImage *get_wwindow_image_from_wm_hints(WWindow *wwin)

The function get_wwindow_image_from_wmhints, renamed to
get_wwindow_image_from_wm_hints to hold the same pattern name that
get_rimage_icon_from_wm_hints, only needs the WWindow to get the
RImage, so now the interface is easier.
---
 src/icon.c |   15 +++
 src/icon.h |2 +-
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 51dcd41..ce97b26 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -463,13 +463,13 @@ static char *get_icon_cache_path(void)
return NULL;
 }
 
-static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
+static RImage *get_wwindow_image_from_wm_hints(WWindow *wwin)
 {
RImage *image = NULL;
XWMHints *hints = wwin->wm_hints;
 
if (hints && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 
None)
-   image = 
RCreateImageFromDrawable(icon->core->screen_ptr->rcontext,
+   image = RCreateImageFromDrawable(wwin->screen_ptr->rcontext,
 hints->icon_pixmap,
 (hints->flags & IconMaskHint)
 ? hints->icon_mask : None);
@@ -519,7 +519,7 @@ char *wIconStore(WIcon * icon)
if (wwin->net_icon_image)
image = RRetainImage(wwin->net_icon_image);
else
-   image = get_wwindow_image_from_wmhints(wwin, icon);
+   image = get_wwindow_image_from_wm_hints(wwin);
 
if (!image) {
wfree(path);
@@ -623,7 +623,7 @@ void wIconUpdate(WIcon *icon, RImage *image)
} else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & 
IconPixmapHint)) {
/* Get the Pixmap from the wm_hints, else, from the 
user */
unset_icon_image(icon);
-   icon->file_image = get_rimage_icon_from_wm_hints(icon);
+   icon->file_image = get_rimage_icon_from_wm_hints(wwin);
if (!icon->file_image)
get_rimage_icon_from_user_icon(icon);
} else {
@@ -741,18 +741,17 @@ static void set_dockapp_in_icon(WIcon *icon)
 }
 
 /* Get the RImage from the XWindow wm_hints */
-RImage *get_rimage_icon_from_wm_hints(WIcon *icon)
+RImage *get_rimage_icon_from_wm_hints(WWindow *wwin)
 {
RImage *image = NULL;
unsigned int w, h, d;
-   WWindow *wwin = icon->owner;
 
if (!getSize(wwin->wm_hints->icon_pixmap, &w, &h, &d)) {
-   icon->owner->wm_hints->flags &= ~IconPixmapHint;
+   wwin->wm_hints->flags &= ~IconPixmapHint;
return NULL;
}
 
-   image = get_wwindow_image_from_wmhints(wwin, icon);
+   image = get_wwindow_image_from_wm_hints(wwin);
if (!image)
return NULL;
 
diff --git a/src/icon.h b/src/icon.h
index c2a6b09..696a20d 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -66,7 +66,7 @@ void update_icon_pixmap(WIcon *icon);
 Bool wIconChangeImageFile(WIcon *icon, char *file);
 
 RImage *wIconValidateIconSize(RImage *icon, int max_size);
-RImage *get_rimage_icon_from_wm_hints(WIcon *icon);
+RImage *get_rimage_icon_from_wm_hints(WWindow *wwin);
 
 char *wIconStore(WIcon *icon);
 char *get_name_for_instance_class(char *wm_instance, char *wm_class);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 07/36] Window image functions

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

This patch create two new functions:

static RImage *get_window_image(WWindow *wwin);
static RImage *get_window_image_def(WWindow *wwin);

The function get_window_image() creates an image using these methods:
 a) Get the window image from the client, using the "net_wm_icon" image
 b) If not found, use the wm_hints image

This aim of this function is set the window image (wwin->net_icon_image)
but don't set the default image, so net_icon_image could be NULL. The
reason is because we don't want to save the default icon in the disk,
only "real" icons.

The function get_window_image_def() returns the icon stored at
wwin->net_icon_image, but if the image is NULL, then returns the default
icon.

The aim of get_window_image_def() is show an icon always to the user.

This patch also needs to set as public these functions:

+RImage *get_wwindow_image_from_wm_hints(WWindow *wwin);
+RImage *get_rimage_from_default(WScreen *scr);

And the function get_rimage_icon_from_default_icon() is renamed to
get_rimage_from_default() because this function returns the default image,
and don't have (needs/provides) an icon, only the an image (yes, can be used
in a WIcon, but is a image).
---
 src/icon.c   |9 -
 src/icon.h   |2 ++
 src/wmspec.c |   34 ++
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index ce97b26..8ee69ca 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -63,7 +63,6 @@ static WIcon *icon_create_core(WScreen *scr, int coord_x, int 
coord_y);
 static void set_dockapp_in_icon(WIcon *icon);
 static RImage *get_rimage_icon_from_icon_win(WIcon *icon);
 static void get_rimage_icon_from_user_icon(WIcon *icon);
-static RImage *get_rimage_icon_from_default_icon(WScreen *scr);
 
 static void icon_update_pixmap(WIcon *icon, RImage *image);
 static void unset_icon_image(WIcon *icon);
@@ -463,7 +462,7 @@ static char *get_icon_cache_path(void)
return NULL;
 }
 
-static RImage *get_wwindow_image_from_wm_hints(WWindow *wwin)
+RImage *get_wwindow_image_from_wm_hints(WWindow *wwin)
 {
RImage *image = NULL;
XWMHints *hints = wwin->wm_hints;
@@ -670,10 +669,10 @@ static void get_rimage_icon_from_user_icon(WIcon *icon)
/* Remove the icon image */
unset_icon_image(icon);
 
-   icon->file_image = 
get_rimage_icon_from_default_icon(icon->core->screen_ptr);
+   icon->file_image = get_rimage_from_default(icon->core->screen_ptr);
 }
 
-static RImage *get_rimage_icon_from_default_icon(WScreen *scr)
+RImage *get_rimage_from_default(WScreen *scr)
 {
/* If the icon don't have image, we should use the default image. */
if (!scr->def_icon_rimage)
@@ -692,7 +691,7 @@ static RImage *get_rimage_icon_from_icon_win(WIcon *icon)
image = get_window_image_from_x11(icon->icon_win);
 
if (!image)
-   image = 
get_rimage_icon_from_default_icon(icon->core->screen_ptr);
+   image = get_rimage_from_default(icon->core->screen_ptr);
 
return image;
 }
diff --git a/src/icon.h b/src/icon.h
index 696a20d..5d2c7d1 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -67,6 +67,8 @@ Bool wIconChangeImageFile(WIcon *icon, char *file);
 
 RImage *wIconValidateIconSize(RImage *icon, int max_size);
 RImage *get_rimage_icon_from_wm_hints(WWindow *wwin);
+RImage *get_wwindow_image_from_wm_hints(WWindow *wwin);
+RImage *get_rimage_from_default(WScreen *scr);
 
 char *wIconStore(WIcon *icon);
 char *get_name_for_instance_class(char *wm_instance, char *wm_class);
diff --git a/src/wmspec.c b/src/wmspec.c
index c758f0a..3ad4f6e 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -231,6 +231,9 @@ static void updateCurrentWorkspace(WScreen *scr);
 static void updateWorkspaceCount(WScreen *scr);
 static void wNETWMShowingDesktop(WScreen *scr, Bool show);
 
+static RImage *get_window_image(WWindow *wwin);
+static RImage *get_window_image_def(WWindow *wwin);
+
 typedef struct NetData {
WScreen *scr;
WReservedArea *strut;
@@ -420,6 +423,37 @@ static RImage *makeRImageFromARGBData(unsigned long *data)
return image;
 }
 
+static RImage *get_window_image(WWindow *wwin)
+{
+   RImage *image = NULL;
+
+   /* First, get the image from the client (net_wm_icon) */
+   image = get_window_image_from_x11(wwin->client_win);
+
+   /* If no image, get the image from the window hints */
+   if (!image)
+   image = get_wwindow_image_from_wm_hints(wwin);
+
+   if (image)
+   image = wIconValidateIconSize(image, wPreferences.icon_size);
+
+   /* If no image, don't return the default image
+* is better to control if we found the image and
+* for example, don't save the default icon as cache */
+   return image;
+}
+
+static RImage *get_window_image_def(WWindow *wwin)
+{
+   /* The window image is stored at window->net_icon_image
+* because get_window_image() sets it there, return it 

[PATCH 08/36] Window image includes wm_hints

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The window image includes now the image provided by wm_hints
if the client don't provides the wm_net_icon image.

This is because get_window_image has the image provided by
the previous get_window_image_from_x11() but, if is NULL,
the image provided by get_wwindow_image_from_wm_hints()

This is the change:

-   /* Save the icon in the X11 icon */
-   wwin->net_icon_image = get_window_image_from_x11(wwin->client_win);
+   /* Save the client image as window image */
+   wwin->net_icon_image = get_window_image(wwin);
---
 src/wmspec.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/wmspec.c b/src/wmspec.c
index 3ad4f6e..d80e24f 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -494,8 +494,8 @@ static void updateIconImage(WWindow *wwin)
if (wwin->net_icon_image)
RReleaseImage(wwin->net_icon_image);
 
-   /* Save the icon in the X11 icon */
-   wwin->net_icon_image = get_window_image_from_x11(wwin->client_win);
+   /* Save the client image as window image */
+   wwin->net_icon_image = get_window_image(wwin);
 
/* Refresh the Window Icon */
if (wwin->icon)
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 09/36] winspector applySettings uses get_window_image_from_x11

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The winspector applySettings function uses now the function
get_window_image_from_x11() to get the icon image. This is because
the icon stored in the appicon is not the icon supplied by the
application, is the icon selected for the application using the
function wIconUpdate.
---
 src/winspector.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index d3f49d0..3e6fe1f 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -793,13 +793,13 @@ static void applySettings(WMButton *button, 
InspectorPanel *panel)
if (wapp->app_icon)
wIconChangeImageFile(wapp->app_icon->icon, 
file);
} else {
-   /* Change App Icon image */
-   if (wapp->app_icon)
-   wIconUpdate(wapp->app_icon->icon, 
get_rimage_icon_from_wm_hints(wapp->app_icon->icon));
-
/* Change icon image if the app is minimized */
if (wwin->icon)
-   wIconUpdate(wwin->icon, 
get_rimage_icon_from_wm_hints(wwin->icon));
+   wIconUpdate(wwin->icon, 
get_window_image_from_x11(wwin->client_win));
+
+   /* Change App Icon image */
+   if (wapp->app_icon)
+   wIconUpdate(wapp->app_icon->icon, 
get_window_image_from_x11(wwin->client_win));
}
 
if (file)
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 15/36] create_appicon_from_dock without wIconUpdate

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function create_appicon_from_dock() reads the app_icon form the
docks or the clip appicons. If the icon is found, the icon has the
right image, therefore we don't need update it.

Therefore, the wIconUpdate() function can be removed from the function
create_appicon_from_dock().
---
 src/appicon.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 9f416ad..4c5fb86 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -997,10 +997,8 @@ static void create_appicon_from_dock(WWindow *wwin, 
WApplication *wapp, Window m
if (mainw->wm_hints && (mainw->wm_hints->flags & 
IconWindowHint))
wapp->app_icon->icon->icon_win = 
mainw->wm_hints->icon_window;
 
-   /* Update the icon images */
-   wIconUpdate(wapp->app_icon->icon, NULL);
-
-   /* Paint it */
+   /* We don't need update the image, because the
+* image stored in the dock is perfect. Simply, paint it */
wAppIconPaint(wapp->app_icon);
save_appicon(wapp->app_icon, True);
}
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 11/36] wIconStore already includes wm_hints image

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function wIconStore stores the image of net_icon_image, but
if the image doesn't exits, save the image provided by wm_hints.

  if (wwin->net_icon_image)
 image = RRetainImage(wwin->net_icon_image);
  else
 image = get_wwindow_image_from_wm_hints(wwin);

But now, the net_icon_image is created using:

wwin->net_icon_image = get_window_image(wwin);

And the function get_window_image() is:

static RImage *get_window_image(WWindow *wwin)
{
RImage *image = NULL;

/* First, get the image from the client (net_wm_icon) */
image = get_window_image_from_x11(wwin->client_win);

/* If no image, get the image from the window hints */
if (!image)
image = get_wwindow_image_from_wm_hints(wwin);

/* If no image, don't return the default image
 * is better to control if we found the image and
 * for example, don't save the default icon as cache */
return image;
}

Therefore, the image is included and the else block is not needed.
---
 src/icon.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 8ee69ca..abb2056 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -517,8 +517,6 @@ char *wIconStore(WIcon * icon)
 
if (wwin->net_icon_image)
image = RRetainImage(wwin->net_icon_image);
-   else
-   image = get_wwindow_image_from_wm_hints(wwin);
 
if (!image) {
wfree(path);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 34/36] Set the right icon on winspector save

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

When we click on save settings, we call wIconUpdate() / wIconChangeImageFile()
(wIconChangeImageFile() calls wIconUpdate() at the end). Then wIconUpdate()
try to select the correct icon.

We must set the flag always_user_icon in the main_window, because wIconUpdate()
try to find the flag for the application (appicon) there. Else, in the line:

if (wwin && WFLAGP(wwin, always_user_icon)) {

of wIconUpdate, the flag is "0", then jump to the option "get_window_image_def"
---
 src/winspector.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/winspector.c b/src/winspector.c
index 8071a46..f0513a4 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -677,7 +677,10 @@ static void applySettings(WMButton *button, InspectorPanel 
*panel)
 #ifdef XKB_BUTTON_HINT
WSETUFLAG(wwin, no_language_button, 
WMGetButtonSelected(panel->moreChk[11]));
 #endif
+   /* Set the window flag always_user_icon, used by the window's icon */
WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));
+   /* Set the main window flag always_user_icon, used by the application 
appicon */
+   WSETUFLAG(wapp->main_window_desc, always_user_icon, 
WMGetButtonSelected(panel->alwChk));
 
if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
wUnshadeWindow(wwin);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 20/36] Icon creation for wwindow moved to a function

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The icon creation for the function icon_create_for_wwindow() is
moved to the new function icon_create_for_wwindow().

No more changes in this commit, only code moving.
---
 src/icon.c |   31 +--
 src/icon.h |1 +
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index ec1db7f..6ef8474 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -111,7 +111,6 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
 {
WScreen *scr = wwin->screen_ptr;
WIcon *icon;
-   char *file;
 
icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y);
 
@@ -139,17 +138,10 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
else
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
 
-   /* Get the application icon, default included */
-   file = get_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, 
True);
-   if (file) {
-   icon->file = wstrdup(file);
-   icon->file_image = get_rimage_from_file(scr, icon->file, 
wPreferences.icon_size);
-   wfree(file);
-   }
-
icon->tile_type = TILE_NORMAL;
 
-   wIconUpdate(icon, NULL);
+   /* Get the application icon, default included */
+   set_icon_for_window(wwin, icon);
 
WMAddNotificationObserver(appearanceObserver, icon, 
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, 
WNIconTileSettingsChanged, icon);
@@ -909,3 +901,22 @@ static void miniwindowMouseDown(WObjDescriptor * desc, 
XEvent * event)
}
}
 }
+
+void set_icon_for_window(WWindow *wwin, WIcon *icon)
+{
+   WScreen *scr = NULL;
+   char *file = NULL;
+
+   if (!wwin || !icon)
+   return;
+
+   scr = wwin->screen_ptr;
+   file = get_icon_filename(scr, wwin->wm_instance, wwin->wm_class, NULL, 
True);
+   if (file) {
+   icon->file = wstrdup(file);
+   icon->file_image = get_rimage_from_file(scr, icon->file, 
wPreferences.icon_size);
+   wfree(file);
+   }
+
+   wIconUpdate(icon, NULL);
+}
diff --git a/src/icon.h b/src/icon.h
index 5d2c7d1..abe3038 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -62,6 +62,7 @@ void wIconUpdate(WIcon *icon, RImage *image);
 void wIconSelect(WIcon *icon);
 void wIconChangeTitle(WIcon *icon, char *new_title);
 void update_icon_pixmap(WIcon *icon);
+void set_icon_for_window(WWindow *wwin, WIcon *icon);
 
 Bool wIconChangeImageFile(WIcon *icon, char *file);
 
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 14/36] Aplication creates appicon in one step

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function wApplicationCreate() calls makeAppIconFor() to create
and save the appicon. All stuff appicon related is in appicon.c,
inside the function makeAppIconFor().

To do it, the function makeAppIconFor() must include the WApplication
and the WWindow structs.

This patch moves the code from wApplicationCreate() to makeAppIconFor()
and include the new WWindow argument at makeAppIconFor().
---
 src/appicon.c |   13 ++---
 src/appicon.h |3 +--
 src/application.c |   15 +++
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 902559c..9f416ad 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -71,6 +71,7 @@ static void wApplicationSaveIconPathFor(char *iconPath, char 
*wm_instance, char
 static WAppIcon *wAppIconCreate(WWindow * leader_win);
 static void add_to_appicon_list(WScreen *scr, WAppIcon *appicon);
 static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon);
+static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window 
main_window);
 
 /* This function is used if the application is a .app. It checks if it has an 
icon in it
  * like for example /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
@@ -143,19 +144,25 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char 
*command, char *wm_instance,
return aicon;
 }
 
-void makeAppIconFor(WApplication *wapp)
+void makeAppIconFor(WApplication *wapp, WWindow *wwin)
 {
+   /* First try to create an icon from the dock or clip */
+   create_appicon_from_dock(wwin, wapp, wapp->main_window);
+
/* If app_icon, work is done, return */
if (wapp->app_icon)
return;
 
-   /* Create the icon */
+   /* In case it was not found in the dock, make it from scratch. */
wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
wIconUpdate(wapp->app_icon->icon, NULL);
 
/* Now, paint the icon */
if (!WFLAGP(wapp->main_window_desc, no_appicon))
paint_app_icon(wapp);
+
+   /* Save the app_icon in a file */
+   save_appicon(wapp->app_icon, False);
 }
 
 void unpaint_app_icon(WApplication *wapp)
@@ -957,7 +964,7 @@ static WAppIcon *findDockIconFor(WDock *dock, Window 
main_window)
return aicon;
 }
 
-void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window 
main_window)
+static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window 
main_window)
 {
WScreen *scr = wwin->screen_ptr;
wapp->app_icon = NULL;
diff --git a/src/appicon.h b/src/appicon.h
index 6f72c8e..c00a538 100644
--- a/src/appicon.h
+++ b/src/appicon.h
@@ -72,11 +72,10 @@ typedef struct WAppIcon {
 WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
char *wm_class, int tile);
 
-void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window 
main_window);
 void wAppIconDestroy(WAppIcon *aicon);
 void wAppIconPaint(WAppIcon *aicon);
 void wAppIconMove(WAppIcon *aicon, int x, int y);
-void makeAppIconFor(WApplication * wapp);
+void makeAppIconFor(WApplication *wapp, WWindow *wwin);
 void removeAppIconFor(WApplication * wapp);
 void save_appicon(WAppIcon *aicon, Bool dock);
 void paint_app_icon(WApplication *wapp);
diff --git a/src/application.c b/src/application.c
index b52a35f..0860e7a 100644
--- a/src/application.c
+++ b/src/application.c
@@ -77,7 +77,7 @@ WApplication *wApplicationOf(Window window)
return wapp;
 }
 
-WApplication *wApplicationCreate(WWindow * wwin)
+WApplication *wApplicationCreate(WWindow *wwin)
 {
WScreen *scr = wwin->screen_ptr;
Window main_window = wwin->main_window;
@@ -141,17 +141,8 @@ WApplication *wApplicationCreate(WWindow * wwin)
/* application descriptor */
XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp);
 
-   /* First try to create an icon from the dock or clip */
-   create_appicon_from_dock(wwin, wapp, main_window);
-
-   /*
-* In case it was not found in the dock, make it from scratch.
-* Note: makeAppIconFor() returns early if wapp->app_icon exists
-*/
-   makeAppIconFor(wapp);
-
-   /* Save the app_icon in a file */
-   save_appicon(wapp->app_icon, False);
+   /* Create and save the application icon */
+   makeAppIconFor(wapp, wwin);
 
return wapp;
 }
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 26/36] wIconChangeTitle rewrited

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function wIconChangeTitle() now changes the icon title name
doing the full work (except painting it).

The function receives now the icon to change the name and the
wwindow with the new name. The function checks if icon and the
window exists.

Then, try to get the name using wNETWMGetIconName(), if not found
then try to read it from wGetIconName(). Then the icon has the new
name and the function returns.

This is better because:

1. We don't need a flag to know if the window got the name
   using the wNETWMGetIconName function. Now call this function
   always.

2. We do the same work in all calls to the wIconChangeTitle()
   function.
---
 src/client.c |   14 --
 src/icon.c   |   22 +++---
 src/icon.h   |2 +-
 src/window.h |1 -
 src/wmspec.c |4 ++--
 5 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/src/client.c b/src/client.c
index 2ae1e48..70791ee 100644
--- a/src/client.c
+++ b/src/client.c
@@ -331,16 +331,10 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent 
* event)
break;
 
case XA_WM_ICON_NAME:
-   if (!wwin->flags.net_has_icon_title) {
-   if (!wwin->icon)
-   break;
-   else {
-   char *new_title;
-
-   /* icon title was changed */
-   wGetIconName(dpy, wwin->client_win, &new_title);
-   wIconChangeTitle(wwin->icon, new_title);
-   }
+   /* icon title was changed */
+   if (wwin->icon) {
+   wIconChangeTitle(wwin->icon, wwin);
+   wIconPaint(wwin->icon);
}
break;
 
diff --git a/src/icon.c b/src/icon.c
index 0aa29b8..b20ab4f 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -132,11 +132,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
icon->show_title = 1;
 #endif
 
-   icon->icon_name = wNETWMGetIconName(wwin->client_win);
-   if (icon->icon_name)
-   wwin->flags.net_has_icon_title = 1;
-   else
-   wGetIconName(dpy, wwin->client_win, &icon->icon_name);
+   wIconChangeTitle(icon, wwin);
 
icon->tile_type = TILE_NORMAL;
 
@@ -333,17 +329,21 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
icon->pixmap = pixmap;
 }
 
-void wIconChangeTitle(WIcon *icon, char *new_title)
+void wIconChangeTitle(WIcon *icon, WWindow *wwin)
 {
+   if (!icon || !wwin)
+   return;
+
+   /* Remove the previous icon name */
if (icon->icon_name != NULL)
XFree(icon->icon_name);
 
-   icon->icon_name = new_title;
+   /* Set the new one */
+   icon->icon_name = wNETWMGetIconName(wwin->client_win);
 
-   /* If the title change, then we must re-create the icon with
-* the new title, but we can still continue with the same icon
-* therefore, we need only re-paint with the new title. */
-   wIconPaint(icon);
+   /* If not set, then try with wGetIconName */
+   if (!icon->icon_name)
+   wGetIconName(dpy, wwin->client_win, &icon->icon_name);
 }
 
 RImage *wIconValidateIconSize(RImage *icon, int max_size)
diff --git a/src/icon.h b/src/icon.h
index 099f592..d59ca94 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -60,7 +60,7 @@ void wIconDestroy(WIcon *icon);
 void wIconPaint(WIcon *icon);
 void wIconUpdate(WIcon *icon, RImage *image);
 void wIconSelect(WIcon *icon);
-void wIconChangeTitle(WIcon *icon, char *new_title);
+void wIconChangeTitle(WIcon *icon, WWindow *wwin);
 void update_icon_pixmap(WIcon *icon);
 void set_icon_for_window(WWindow *wwin, WIcon *icon);
 
diff --git a/src/window.h b/src/window.h
index c4148a3..4a3b81c 100644
--- a/src/window.h
+++ b/src/window.h
@@ -282,7 +282,6 @@ typedef struct WWindow {
unsigned int net_handle_icon:1;
unsigned int net_show_desktop:1;
unsigned int net_has_title:1;   /* use netwm version of WM_NAME 
*/
-   unsigned int net_has_icon_title:1;
} flags;/* state of the window */
 
struct WIcon *icon; /* Window icon when miminized
diff --git a/src/wmspec.c b/src/wmspec.c
index c0600c5..4f0d4a8 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -1498,8 +1498,8 @@ void wNETWMCheckClientHintChange(WWindow *wwin, 
XPropertyEvent *event)
wfree(name);
} else if (event->atom == net_wm_icon_name) {
if (wwin->icon) {
-   char *name = wNETWMGetIconName(wwin->client_win);
-   wIconChangeTitle(wwin->icon, name);
+   wIconChangeTitle(wwin->icon, wwin);
+   wIconPaint(wwin->icon);
}
} else if (event->atom == net_wm_icon) {
update

[PATCH 31/36] WWindow has always icon - Remove wIconDestroy

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

This patch removes the wIconDestroy and the window always has icon.
This patch doesn't create the icon at the window creation! so yet
WWindow icon could be null.

This patch also adds this bug when the window is removed:

wmaker(RemoveFromStackList(stacking.c:567)): \
warning: RemoveFromStackingList(): window not in list

Because the stacking is not updated correctly.
---
 src/actions.c |6 +-
 src/wmspec.c  |   16 +---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index a79de8a..e1e6aaa 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1318,12 +1318,8 @@ void wDeiconifyWindow(WWindow *wwin)
}
 
if (!wPreferences.disable_miniwindows && wwin->icon != NULL
-   && !wwin->flags.net_handle_icon) {
+   && !wwin->flags.net_handle_icon)
RemoveFromStackList(wwin->icon->core);
-   /*removeIconGrabs(wwin->icon); */
-   wIconDestroy(wwin->icon);
-   wwin->icon = NULL;
-   }
 
if (!netwm_hidden) {
XUngrabServer(dpy);
diff --git a/src/wmspec.c b/src/wmspec.c
index 28efc20..d620855 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -1090,18 +1090,6 @@ static void doStateAtom(WWindow *wwin, Atom state, int 
set, Bool init)
}
 }
 
-static void removeIcon(WWindow *wwin)
-{
-   if (wwin->icon == NULL)
-   return;
-   if (wwin->flags.miniaturized && wwin->icon->mapped) {
-   XUnmapWindow(dpy, wwin->icon->core->window);
-   RemoveFromStackList(wwin->icon->core);
-   wIconDestroy(wwin->icon);
-   wwin->icon = NULL;
-   }
-}
-
 static Bool handleWindowType(WWindow *wwin, Atom type, int *layer)
 {
Bool ret = True;
@@ -1319,9 +1307,7 @@ static Bool updateNetIconInfo(WWindow *wwin)
}
 
if (wwin->flags.miniaturized && old_state != 
wwin->flags.net_handle_icon) {
-   if (wwin->flags.net_handle_icon) {
-   removeIcon(wwin);
-   } else {
+   if (!wwin->flags.net_handle_icon) {
wwin->flags.miniaturized = False;
wwin->flags.skip_next_animation = True;
wIconifyWindow(wwin);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 12/36] icon_create_for_dock without wIconUpdate

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function icon_create_for_wwindow() don't need call wIconUpdate,
because the flow is always the same:

1. icon_create_for_wwindow() set the icon
2. icon_create_for_wwindow calls wIconUpdate.
3. wIconUpdate always call get_rimage_icon_from_user_icon(). This is because
   the icon doesn't have window, therefore the if always select this function
   as the first option in the if (if (wwin && WFLAGP(wwin, always_user_icon)))
   or using the "else".

This patch also changes the Boolean value for default icon, as is explained as
comment in the source:

+ /* Docks have two cases:
+  * 1. If the dock is a application launcher, the WDomain database is used
+  *to find the icon in the CachePixmap. The stored image is painted in
+  *the dock. Therefore default icon is not recommended.
+  * 2. If the dock is a docked application (appdock), then the dock
+  *painted doesn't need icon, because icon_create_for_wwindow() will be
+  *called later. So we can think that we don't need icon here.
+  * The problem is if the dock is a application launcher, but the icon is
+  * not found (removed, configuration error,...) then the dock doesn't have
+  * icon and is transparent.
+  * Therefore, the best option is use the default icon for the dock.
+  * icon_create_for_wwindow will override the image with the application. */

This change doesn't change the behavior, because before the change, with the
value set to False, when wIconUpdate was called, it calls
get_rimage_icon_from_user_icon() (see the flow above):

static void get_rimage_icon_from_user_icon(WIcon *icon)
{
if (icon->file_image)
return;

/* Remove the icon image */
unset_icon_image(icon);

icon->file_image = get_rimage_from_default(icon->core->screen_ptr);
}

Because is NULL, the icon->file_image is set to the default icon.

With this patch, icon->file_image has set already the default icon, therefore
wIconUpdate doesn't do nothing (multiple function calls without changes),
except call update_icon_pixmap(icon);

Therefore, wIconUpdate can be removed and replaced by update_icon_pixmap(icon)
at icon_create_for_dock().
---
 src/icon.c |   21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index abb2056..ec1db7f 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -163,18 +163,29 @@ WIcon *icon_create_for_dock(WScreen *scr, char *command, 
char *wm_instance, char
char *file = NULL;
 
icon = icon_create_core(scr, 0, 0);
+   icon->tile_type = tile;
 
-   /* Search the icon using instance and class, without default icon */
-   file = get_icon_filename(scr, wm_instance, wm_class, command, False);
+   /* Docks have two cases:
+* 1. If the dock is a application launcher, the WDomain database is 
used
+*to find the icon in the CachePixmap. The stored image is painted 
in
+*the dock. Therefore default icon is not recommended.
+* 2. If the dock is a docked application (appdock), then the dock
+*painted doesn't need icon, because icon_create_for_wwindow() will 
be
+*called later. So we can think that we don't need icon here.
+* The problem is if the dock is a application launcher, but the icon is
+* not found (removed, configuration error,...) then the dock doesn't 
have
+* icon and is transparent.
+* Therefore, the best option is use the default icon for the dock.
+* icon_create_for_wwindow will override the image with the 
application. */
+   file = get_icon_filename(scr, wm_instance, wm_class, command, True);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(scr, icon->file, 
wPreferences.icon_size);
wfree(file);
}
 
-   icon->tile_type = tile;
-
-   wIconUpdate(icon, NULL);
+   /* Create the pixmap using icon->file_image */
+   update_icon_pixmap(icon);
 
WMAddNotificationObserver(appearanceObserver, icon, 
WNIconAppearanceSettingsChanged, icon);
WMAddNotificationObserver(tileObserver, icon, 
WNIconTileSettingsChanged, icon);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 19/36] wClientCheckProperty uses updateIconImage

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function wClientCheckProperty() updates the icon using the function
updateIconImage() at wmspec.c (no is non static).

The code is the same, with two exceptions:

1. Now updates net_icon_image (window image) too. IMO the old code should do
   it, but it didn't. IMO was a mistake.
2. Now, the code

-   if (wwin->flags.miniaturized && wwin->icon) {
-   wIconUpdate(wwin->icon, NULL);
-   }

is in wmspec.c

-   if (wwin->icon) {
-   wIconUpdate(wwin->icon, NULL);
-   }

Really, it old code was wrong, because with the current code, the wwin->icon 
exists
only if the miniwindow exists, therefore, this code (old code)

-   if (wwin->flags.miniaturized && wwin->icon) {

is "if (1 && 1)" or "if (0 && 0), if the wwin->icon exists is minimized, else,
it doesn't exists.

Therefore, the code is better and solves two issues.
---
 src/client.c |   19 ---
 src/wmspec.c |2 +-
 src/wmspec.h |1 +
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/client.c b/src/client.c
index 975adb1..2ae1e48 100644
--- a/src/client.c
+++ b/src/client.c
@@ -477,27 +477,16 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent 
* event)
 
if (wwin->wm_hints) {
/* update icon */
-   if ((wwin->wm_hints->flags & IconPixmapHint)
-   || (wwin->wm_hints->flags & IconWindowHint)) {
-   WApplication *wapp;
-
-   if (wwin->flags.miniaturized && wwin->icon) {
-   wIconUpdate(wwin->icon, NULL);
-   }
-   wapp = wApplicationOf(wwin->main_window);
-   if (wapp && wapp->app_icon) {
-   wIconUpdate(wapp->app_icon->icon, NULL);
-   wAppIconPaint(wapp->app_icon);
-   }
-   }
+   if ((wwin->wm_hints->flags & IconPixmapHint) ||
+   (wwin->wm_hints->flags & IconWindowHint))
+   updateIconImage(wwin);
 
if (wwin->wm_hints->flags & UrgencyHint)
wwin->flags.urgent = 1;
else
wwin->flags.urgent = 0;
+

wAppBounceWhileUrgent(wApplicationOf(wwin->main_window));
-   /*} else if (wwin->fake_group!=NULL) {
-   wwin->group_id = wwin->fake_group->leader; */
} else {
wwin->group_id = None;
}
diff --git a/src/wmspec.c b/src/wmspec.c
index a261ef9..c0600c5 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -485,7 +485,7 @@ RImage *get_window_image_from_x11(Window window)
return image;
 }
 
-static void updateIconImage(WWindow *wwin)
+void updateIconImage(WWindow *wwin)
 {
/* Remove the icon image from X11 */
if (wwin->net_icon_image)
diff --git a/src/wmspec.h b/src/wmspec.h
index 7fecf67..e0e5adb 100644
--- a/src/wmspec.h
+++ b/src/wmspec.h
@@ -45,6 +45,7 @@ char *wNETWMGetIconName(Window window);
 char *wNETWMGetWindowName(Window window);
 void wNETFrameExtents(WWindow *wwin);
 void wNETCleanupFrameExtents(WWindow *wwin);
+void updateIconImage(WWindow *wwin);
 RImage *get_window_image_from_x11(Window window);
 RImage *get_window_image(WWindow *wwin);
 RImage *get_window_image_def(WWindow *wwin);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 29/36] tileObserver refresh with the same image

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The tileObserver() function doesn't need change the icon image,
because the icon image doesn't change with tile changes.
---
 src/icon.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/icon.c b/src/icon.c
index 620a1db..1cf3888 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -91,7 +91,8 @@ static void tileObserver(void *self, WMNotification *notif)
 {
WIcon *icon = (WIcon *) self;
 
-   wIconUpdate(icon, NULL);
+   /* Repaint the icon, use the same image */
+   update_icon_pixmap(icon);
 
XClearArea(dpy, icon->core->window, 0, 0, 1, 1, True);
 }
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 28/36] Dockapps don't have title

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The dockapps don't have title, so this code must be removed.
The title height is 0 then and the variable title_height can
be removed.
---
 src/icon.c |   10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index a21ebed..620a1db 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -692,9 +692,7 @@ static void set_dockapp_in_icon(WIcon *icon)
 {
XWindowAttributes attr;
WScreen *scr = icon->core->screen_ptr;
-   int title_height = WMFontHeight(scr->icon_title_font);
unsigned int w, h, d;
-   int theight = 0;
 
/* Reparent the dock application to the icon */
 
@@ -705,19 +703,13 @@ static void set_dockapp_in_icon(WIcon *icon)
/* Paint the docked application background */
XSetWindowBackgroundPixmap(dpy, icon->core->window, 
scr->icon_tile_pixmap);
 
-   /* Set extra space for title */
-   if (icon->show_title && (h + title_height < wPreferences.icon_size)) {
-   theight = title_height;
-   drawIconTitle(scr, icon->pixmap, theight);
-}
-
/* Set the icon border */
XSetWindowBorderWidth(dpy, icon->icon_win, 0);
 
/* Put the dock application in the icon */
XReparentWindow(dpy, icon->icon_win, icon->core->window,
(wPreferences.icon_size - w) / 2,
-   theight + (wPreferences.icon_size - h - theight) / 2);
+   (wPreferences.icon_size - h) / 2);
 
/* Show it and save */
XMapWindow(dpy, icon->icon_win);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 25/36] wGetIconName False block moved up

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The False return part of the if is moved up, then the lines at the
True block are shorter.

This patch also add some curly brackets.
---
 src/misc.c |   29 -
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/misc.c b/src/misc.c
index 9922ea2..13170ea 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -94,22 +94,25 @@ Bool wGetIconName(Display *dpy, Window win, char **iconname)
char **list;
int num;
 
-   if (XGetWMIconName(dpy, win, &text_prop) != 0 && text_prop.value && 
text_prop.nitems > 0) {
-   if (text_prop.encoding == XA_STRING)
+   if ((XGetWMIconName(dpy, win, &text_prop) == 0) || (text_prop.value && 
text_prop.nitems <= 0)) {
+   *iconname = NULL;
+   return False;
+   }
+
+   if (text_prop.encoding == XA_STRING) {
+   *iconname = (char *)text_prop.value;
+   } else {
+   text_prop.nitems = strlen((char *)text_prop.value);
+   if (XmbTextPropertyToTextList(dpy, &text_prop, &list, &num) >= 
Success && num > 0 && *list) {
+   XFree(text_prop.value);
+   *iconname = wstrdup(*list);
+   XFreeStringList(list);
+   } else {
*iconname = (char *)text_prop.value;
-   else {
-   text_prop.nitems = strlen((char *)text_prop.value);
-   if (XmbTextPropertyToTextList(dpy, &text_prop, &list, 
&num) >= Success && num > 0 && *list) {
-   XFree(text_prop.value);
-   *iconname = wstrdup(*list);
-   XFreeStringList(list);
-   } else
-   *iconname = (char *)text_prop.value;
}
-   return True;
}
-   *iconname = NULL;
-   return False;
+
+   return True;
 }
 
 static void eatExpose(void)
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 23/36] Removed get_rimage_icon_from_wm_hints

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function get_rimage_icon_from_wm_hints is not used anymore,
so can be removed.
---
 src/icon.c |   21 -
 src/icon.h |1 -
 2 files changed, 22 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 80631cb..ab0e690 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -735,27 +735,6 @@ static void set_dockapp_in_icon(WIcon *icon)
  None, wCursor[WCUR_ARROW]);
 }
 
-/* Get the RImage from the XWindow wm_hints */
-RImage *get_rimage_icon_from_wm_hints(WWindow *wwin)
-{
-   RImage *image = NULL;
-   unsigned int w, h, d;
-
-   if (!getSize(wwin->wm_hints->icon_pixmap, &w, &h, &d)) {
-   wwin->wm_hints->flags &= ~IconPixmapHint;
-   return NULL;
-   }
-
-   image = get_wwindow_image_from_wm_hints(wwin);
-   if (!image)
-   return NULL;
-
-   /* Resize the icon to the wPreferences.icon_size size */
-   image = wIconValidateIconSize(image, wPreferences.icon_size);
-
-   return image;
-}
-
 void wIconPaint(WIcon *icon)
 {
WScreen *scr = icon->core->screen_ptr;
diff --git a/src/icon.h b/src/icon.h
index abe3038..099f592 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -67,7 +67,6 @@ void set_icon_for_window(WWindow *wwin, WIcon *icon);
 Bool wIconChangeImageFile(WIcon *icon, char *file);
 
 RImage *wIconValidateIconSize(RImage *icon, int max_size);
-RImage *get_rimage_icon_from_wm_hints(WWindow *wwin);
 RImage *get_wwindow_image_from_wm_hints(WWindow *wwin);
 RImage *get_rimage_from_default(WScreen *scr);
 
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 17/36] Dock operations don't need wIconUpdate

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The dock operations don't need wIconUpdate because the icon image
exists and is ok. For example, when we move a dock from the clip
to the dock, the icon attached to the dock has icon, and that icon
can be used in the clip, we don't need refresh it.

We need paint it in the screen, including the shadow, but this
operation is done in wAppIconPaint, so we don't need replace
wIconUpdate with wIconPaint, we can remove wIconUpdate.

Of course, the code is now faster, because the icon is only painted
one time, and the image is not selected again.

Some comments about this patch:

1. update_icon flag:

The icon update flag:

-   /* Update the icon images */
-   if (update_icon)
-   wIconUpdate(icon->icon, NULL);
-

Is used to know if we need update or not the icon. Because we don't
need udpate it in any case, the update_icon flag can be removed.

2. shadow flag:

The update_icon removed was used mostly because the shadow flag is
set, then, the icon must be re-painted. The shadow flag is still used,
but is painted using wAppIconPaint(), so there are no problems.

3. Function wDockAttachIcon:

This function don't uses the update_icon flag, so the function can drop
this argument.

-Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, \
 Bool update_icon)
+Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y)
---
 src/appicon.c |   10 --
 src/dock.c|   47 +--
 src/dock.h|2 +-
 3 files changed, 14 insertions(+), 45 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index 4c5fb86..f254944 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -201,7 +201,6 @@ void paint_app_icon(WApplication *wapp)
WScreen *scr = wapp->main_window_desc->screen_ptr;
WDock *clip = scr->workspaces[scr->current_workspace]->clip;
int x = 0, y = 0;
-   Bool update_icon = False;
 
if (!wapp || !wapp->app_icon)
return;
@@ -215,11 +214,10 @@ void paint_app_icon(WApplication *wapp)
 
if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
wapp->app_icon->attracted = 1;
-   if (!icon->shadowed) {
+   if (!icon->shadowed)
icon->shadowed = 1;
-   update_icon = True;
-   }
-   wDockAttachIcon(clip, wapp->app_icon, x, y, update_icon);
+
+   wDockAttachIcon(clip, wapp->app_icon, x, y);
} else {
/* We must know if the icon is painted in the screen,
 * because if painted, then PlaceIcon will return the next
@@ -863,7 +861,7 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event)
/* icon is trying to be docked */
SlideWindow(icon->core->window, x, y, shad_x, 
shad_y);
XUnmapWindow(dpy, scr->dock_shadow);
-   docked = wDockAttachIcon(scr->last_dock, aicon, 
ix, iy, False);
+   docked = wDockAttachIcon(scr->last_dock, aicon, 
ix, iy);
if (scr->last_dock->auto_collapse)
collapsed = 0;
 
diff --git a/src/dock.c b/src/dock.c
index f503e14..24164de 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -540,9 +540,6 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry 
*entry)
if (aicon->icon->shadowed) {
aicon->icon->shadowed = 0;
 
-   /* Update the icon images */
-   wIconUpdate(aicon->icon, NULL);
-
/* Paint it */
wAppIconPaint(aicon);
}
@@ -582,7 +579,6 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry 
*entry)
WDock *clip;
WAppIcon *aicon;
int x, y, x_pos, y_pos;
-   Bool update_icon = False;
 
assert(entry->clientdata != NULL);
clip = clickedIcon->dock;
@@ -597,11 +593,10 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry 
*entry)
move_window(aicon->icon->core->window, 
aicon->x_pos, aicon->y_pos, x_pos, y_pos);
 
aicon->attracted = 1;
-   if (!aicon->icon->shadowed) {
+   if (!aicon->icon->shadowed)
aicon->icon->shadowed = 1;
-   update_icon = True;
-   }
-   wDockAttachIcon(clip, aicon, x, y, update_icon);
+
+   wDockAttachIcon(clip, aicon, x, y);
if (clip->collapsed || !clip->mapped)
XUnmapWindow(dpy, aicon->icon->core->window);
}
@@ -1851,18 +1846,14 @@ int wDockReceiveDNDDrop(WScreen *scr, XEvent 

[PATCH 16/36] Avoid crash in icon move without command

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

This patch avoid a crash when moving an icon without command.
To reproduce the problem:

1. Launch an application, for example xeyes, with appicon.
2. Move the appicon to the clip.
3. Close the application.
4. Edit the appicon in the clip, and empty the commands fields.
5. Move the appicon from the clip to the dock. -> Crash.

The crash happends because the appicon don't have command AND
the application is not running, therefore "wwin" is NULL.

This patch test if the application is running (the icon has wwin),
before get the command from the application.
---
 src/dock.c |   24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/dock.c b/src/dock.c
index 6e2e0e3..f503e14 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -1855,18 +1855,21 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int 
x, int y, Bool update_icon
 {
WWindow *wwin;
Bool lupdate_icon = False;
+   char *command = NULL;
int index;
 
-   wwin = icon->icon->owner;
icon->editing = 0;
 
if (update_icon)
lupdate_icon = True;
 
if (icon->command == NULL) {
-   char *command;
+   /* Try to get the command for the window, if it is running! */
+   if (icon->icon->owner) {
+   wwin = icon->icon->owner;
+   command = GetCommandForWindow(wwin->client_win);
+   }
 
-   command = GetCommandForWindow(wwin->client_win);
if (command) {
icon->command = command;
} else {
@@ -1986,18 +1989,18 @@ static void reattachIcon(WDock *dock, WAppIcon *icon, 
int x, int y)
 static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int 
x, int y)
 {
WWindow *wwin;
-   char *command;
+   char *command = NULL;
int index;
Bool update_icon = False;
 
+   /* Check if no move needed, we're already there */
if (src == dest)
-   return True;/* No move needed, we're already there */
+   return True;
 
+   /* Check if destination exists */
if (dest == NULL)
return False;
 
-   wwin = icon->icon->owner;
-
/*
 * For the moment we can't do this if we move icons in Clip from one
 * workspace to other, because if we move two or more icons without
@@ -2005,7 +2008,12 @@ static Bool moveIconBetweenDocks(WDock *src, WDock 
*dest, WAppIcon *icon, int x,
 * moved icons it applies. -Dan
 */
if ((dest->type == WM_DOCK /*|| dest->keep_attracted */ ) && 
icon->command == NULL) {
-   command = GetCommandForWindow(wwin->client_win);
+   /* Try to get the command for the window, if it is running! */
+   if (icon->icon->owner) {
+   wwin = icon->icon->owner;
+   command = GetCommandForWindow(wwin->client_win);
+   }
+
if (command) {
icon->command = command;
} else {
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 24/36] wIconChangeTitle rewritten

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function wIconChangeTitle is rewritten. Changes are:

1. Changed flag removed.

The changed flag check if:

* new_title == NULL and the icon->icon_name not.
* new_title is not NULL and the icon->icon name yes.

This can be used if the title is created or removed, not changed.
For example, if we lauch "xterm" it show in the title the current
path. If we change the path, the title changes, but changed is
0, because:

new_title != NULL and icon->icon_name != NULL.

You can check this issue with this steps:

1. Open a xterm (or other app that changes the title)
2. Type in the xterm "sleep 5; cd /"
3. Minimize the xterm and see the title. 5 seconds later, it change

Without this patch, in step 3, the icon title doesn't change.

2. wIconUpdate removed

The function wIconChangeTitle() function calls wIconUpdate() or
wIconPaint() depending of changed. In both cases the icon->file_image
doesn't change, only the icon title, so we can use the same image
and we don't need update it. Because the variable changed is removed,
we can use wIconPaint() here.
---
 src/icon.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index ab0e690..0aa29b8 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -335,20 +335,15 @@ static void icon_update_pixmap(WIcon *icon, RImage *image)
 
 void wIconChangeTitle(WIcon *icon, char *new_title)
 {
-   int changed;
-
-   changed = (new_title == NULL && icon->icon_name != NULL) ||
- (new_title != NULL && icon->icon_name == NULL);
-
if (icon->icon_name != NULL)
XFree(icon->icon_name);
 
icon->icon_name = new_title;
 
-   if (changed)
-   wIconUpdate(icon, NULL);
-   else
-   wIconPaint(icon);
+   /* If the title change, then we must re-create the icon with
+* the new title, but we can still continue with the same icon
+* therefore, we need only re-paint with the new title. */
+   wIconPaint(icon);
 }
 
 RImage *wIconValidateIconSize(RImage *icon, int max_size)
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 27/36] All dockapps have bave background

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

This if is wrong. A dock app has background always.
OTOH, background and title could be compatible.
---
 src/icon.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index b20ab4f..a21ebed 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -702,12 +702,13 @@ static void set_dockapp_in_icon(WIcon *icon)
 * and show in the correct position */
getSize(icon->icon_win, &w, &h, &d);
 
+   /* Paint the docked application background */
+   XSetWindowBackgroundPixmap(dpy, icon->core->window, 
scr->icon_tile_pixmap);
+
/* Set extra space for title */
if (icon->show_title && (h + title_height < wPreferences.icon_size)) {
theight = title_height;
drawIconTitle(scr, icon->pixmap, theight);
-   } else {
-XSetWindowBackgroundPixmap(dpy, icon->core->window, 
scr->icon_tile_pixmap);
 }
 
/* Set the icon border */
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 33/36] winspector.c save and apply Settings code clean

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

This patch removes some empty lines, some curly brackets and
moves some variable declaration to the start of the function.
Changes are cosmetic.
---
 src/winspector.c |  106 --
 1 file changed, 39 insertions(+), 67 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 99bcd3a..8071a46 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -373,21 +373,18 @@ static int getBool(WMPropList *value)
 {
char *val;
 
-   if (!WMIsPLString(value)) {
+   if (!WMIsPLString(value))
return 0;
-   }
-   if (!(val = WMGetFromPLString(value))) {
+
+   if (!(val = WMGetFromPLString(value)))
return 0;
-   }
 
if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' 
|| val[0] == 't' || val[0] == '1'))
|| (strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) {
-
return 1;
} else if ((val[1] == '\0'
&& (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' || 
val[0] == 'f' || val[0] == '0'))
   || (strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") 
== 0)) {
-
return 0;
} else {
wwarning(_("can't convert \"%s\" to boolean"), val);
@@ -398,39 +395,31 @@ static int getBool(WMPropList *value)
 #define UPDATE_DEFAULTS1
 #define IS_BOOLEAN 2
 
-/*
- *  Will insert the attribute = value; pair in window's list,
+/* Will insert the attribute = value; pair in window's list,
  * if it's different from the defaults.
- *  Defaults means either defaults database, or attributes saved
+ * Defaults means either defaults database, or attributes saved
  * for the default window "*". This is to let one revert options that are
- * global because they were saved for all windows ("*").
- *
- */
-
+ * global because they were saved for all windows ("*"). */
 static int
 insertAttribute(WMPropList *dict, WMPropList *window, WMPropList *attr, 
WMPropList *value, int flags)
 {
WMPropList *def_win, *def_value = NULL;
-   int update = 0;
-   int modified = 0;
+   int update = 0, modified = 0;
 
if (!(flags & UPDATE_DEFAULTS) && dict) {
-   if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL) 
{
+   if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL)
def_value = WMGetFromPLDictionary(def_win, attr);
-   }
}
 
/* If we could not find defaults in database, fall to hardcoded values.
-* Also this is true if we save defaults for all windows
-*/
+* Also this is true if we save defaults for all windows */
if (!def_value)
def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
 
-   if ((flags & IS_BOOLEAN))
+   if (flags & IS_BOOLEAN)
update = (getBool(value) != getBool(def_value));
-   else {
+   else
update = !WMIsPropListEqualTo(value, def_value);
-   }
 
if (update) {
WMPutInPLDictionary(window, attr, value);
@@ -444,34 +433,32 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
 {
WWindow *wwin = panel->inspected;
WDDomain *db = WDWindowAttributes;
-   WMPropList *dict = db->dictionary;
-   WMPropList *winDic, *appDic, *value, *key, *key2;
-   char *icon_file;
-   int flags = 0;
+   WMPropList *dict = NULL;
+   WMPropList *winDic, *appDic, *value, *key = NULL, *key2;
+   char *icon_file, *buf1, *buf2;
+   int flags = 0, i = 0;
int different = 0, different2 = 0;
 
/* Save will apply the changes and save them */
applySettings(panel->applyBtn, panel);
 
-   if (WMGetButtonSelected(panel->instRb) != 0)
+   if (WMGetButtonSelected(panel->instRb) != 0) {
key = WMCreatePLString(wwin->wm_instance);
-   else if (WMGetButtonSelected(panel->clsRb) != 0)
+   } else if (WMGetButtonSelected(panel->clsRb) != 0) {
key = WMCreatePLString(wwin->wm_class);
-   else if (WMGetButtonSelected(panel->bothRb) != 0) {
-   char *buffer;
-
-   buffer = StrConcatDot(wwin->wm_instance, wwin->wm_class);
-   key = WMCreatePLString(buffer);
-   wfree(buffer);
+   } else if (WMGetButtonSelected(panel->bothRb) != 0) {
+   buf1 = StrConcatDot(wwin->wm_instance, wwin->wm_class);
+   key = WMCreatePLString(buf1);
+   wfree(buf1);
} else if (WMGetButtonSelected(panel->defaultRb) != 0) {
key = WMRetainPropList(AnyWindow);
flags = UPDATE_DEFAULTS;
-   } else
-   key = NULL;
+   }
 
if (!key)
return;
 
+   dict = db->dictionary;
if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL);
   

[PATCH 30/36] New function update_net_icon_image

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The new helper function update_net_icon_image() changes the window
net_icon_image.

I splitted this image creation from updateIconImage() to better
understanding.
---
 src/wmspec.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/wmspec.c b/src/wmspec.c
index 4f0d4a8..28efc20 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -231,6 +231,8 @@ static void updateCurrentWorkspace(WScreen *scr);
 static void updateWorkspaceCount(WScreen *scr);
 static void wNETWMShowingDesktop(WScreen *scr, Bool show);
 
+static void update_net_icon_image(WWindow *wwin);
+
 typedef struct NetData {
WScreen *scr;
WReservedArea *strut;
@@ -485,7 +487,8 @@ RImage *get_window_image_from_x11(Window window)
return image;
 }
 
-void updateIconImage(WWindow *wwin)
+/* This function refresh the net_icon_image, used by the window */
+static void update_net_icon_image(WWindow *wwin)
 {
/* Remove the icon image from X11 */
if (wwin->net_icon_image)
@@ -493,6 +496,12 @@ void updateIconImage(WWindow *wwin)
 
/* Save the client image as window image */
wwin->net_icon_image = get_window_image(wwin);
+}
+
+void updateIconImage(WWindow *wwin)
+{
+   /* Update the icon image used by the windows */
+   update_net_icon_image(wwin);
 
/* Refresh the Window Icon */
if (wwin->icon)
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 35/36] wDefaultUpdateIcons uses wIconUpdate

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The icons are right set in the wwin->icon and wapp->app_icon,
so we don't need search the icon and then set it before call
wIconUpdate. Just, call wIconUpdate with NULL as icon.

The change about remove "wwin->flags.miniaturized" is because
after the patches to include icon in all windows, not only the
minianturized, then we must change the icon in all windows.

-   if (wwin->icon && wwin->flags.miniaturized) {
-   /* Get the application icon, default included */
-   file = wDefaultGetIconFile(wwin->wm_instance, wwin->wm_class, True);
-   if ((file && wwin->icon->file && strcmp(file, wwin->icon->file) != 0)
-|| (file && !wwin->icon->file))
- wIconChangeImageFile(wwin->icon, file);
-   }
+   if (wwin->icon)
+ wIconUpdate(wwin->icon, NULL);
---
 src/defaults.c |   21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/defaults.c b/src/defaults.c
index e8c33e0..4316450 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -1124,30 +1124,21 @@ void wDefaultUpdateIcons(WScreen *scr)
 {
WAppIcon *aicon = scr->app_icon_list;
WWindow *wwin = scr->focused_window;
-   char *file;
 
+   /* All windows have appicon */
while (aicon) {
-   /* Get the application icon, default included */
-   file = wDefaultGetIconFile(aicon->wm_instance, aicon->wm_class, 
True);
-   if ((file && aicon->icon->file && strcmp(file, 
aicon->icon->file) != 0)
-   || (file && !aicon->icon->file)) {
-   wIconChangeImageFile(aicon->icon, file);
-   wAppIconPaint(aicon);
-   }
+   wIconUpdate(aicon->icon, NULL);
+   wAppIconPaint(aicon);
aicon = aicon->next;
}
 
if (!wPreferences.flags.noclip)
wClipIconPaint(scr->clip_icon);
 
+   /* All windows have icon */
while (wwin) {
-   if (wwin->icon && wwin->flags.miniaturized) {
-   /* Get the application icon, default included */
-   file = wDefaultGetIconFile(wwin->wm_instance, 
wwin->wm_class, True);
-   if ((file && wwin->icon->file && strcmp(file, 
wwin->icon->file) != 0)
-   || (file && !wwin->icon->file))
-   wIconChangeImageFile(wwin->icon, file);
-   }
+   if (wwin->icon)
+   wIconUpdate(wwin->icon, NULL);
wwin = wwin->prev;
}
 }
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 10/36] winspector applySettings include all client images

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function applySettings() at winspector window includes all
the client possible images:

The image form the client wm_net_icon (get_window_image_from_x11()),
else, the image form the wm_hints (get_wwindow_image_from_wm_hints())
These images are stored at wwin->net_icon_image.

But if is NULL, applySettings uses get_window_image and
not get_window_image_def, because they call wIconUpdate and
if get_window_image() returns NULL, the icon is provided by wIconUpdate
and could be not the default icon.
---
 src/winspector.c |4 ++--
 src/wmspec.c |7 ++-
 src/wmspec.h |2 ++
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 3e6fe1f..bbbefd1 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -795,11 +795,11 @@ static void applySettings(WMButton *button, 
InspectorPanel *panel)
} else {
/* Change icon image if the app is minimized */
if (wwin->icon)
-   wIconUpdate(wwin->icon, 
get_window_image_from_x11(wwin->client_win));
+   wIconUpdate(wwin->icon, get_window_image(wwin));
 
/* Change App Icon image */
if (wapp->app_icon)
-   wIconUpdate(wapp->app_icon->icon, 
get_window_image_from_x11(wwin->client_win));
+   wIconUpdate(wapp->app_icon->icon, 
get_window_image(wwin));
}
 
if (file)
diff --git a/src/wmspec.c b/src/wmspec.c
index d80e24f..a261ef9 100644
--- a/src/wmspec.c
+++ b/src/wmspec.c
@@ -231,9 +231,6 @@ static void updateCurrentWorkspace(WScreen *scr);
 static void updateWorkspaceCount(WScreen *scr);
 static void wNETWMShowingDesktop(WScreen *scr, Bool show);
 
-static RImage *get_window_image(WWindow *wwin);
-static RImage *get_window_image_def(WWindow *wwin);
-
 typedef struct NetData {
WScreen *scr;
WReservedArea *strut;
@@ -423,7 +420,7 @@ static RImage *makeRImageFromARGBData(unsigned long *data)
return image;
 }
 
-static RImage *get_window_image(WWindow *wwin)
+RImage *get_window_image(WWindow *wwin)
 {
RImage *image = NULL;
 
@@ -440,7 +437,7 @@ static RImage *get_window_image(WWindow *wwin)
return image;
 }
 
-static RImage *get_window_image_def(WWindow *wwin)
+RImage *get_window_image_def(WWindow *wwin)
 {
/* The window image is stored at window->net_icon_image
 * because get_window_image() sets it there, return it */
diff --git a/src/wmspec.h b/src/wmspec.h
index 5bb26f0..7fecf67 100644
--- a/src/wmspec.h
+++ b/src/wmspec.h
@@ -46,4 +46,6 @@ char *wNETWMGetWindowName(Window window);
 void wNETFrameExtents(WWindow *wwin);
 void wNETCleanupFrameExtents(WWindow *wwin);
 RImage *get_window_image_from_x11(Window window);
+RImage *get_window_image(WWindow *wwin);
+RImage *get_window_image_def(WWindow *wwin);
 #endif
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 32/36] WWindow always has icon - Add WIcon

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

Now WWindow always has window because is created when the window
is created.

We need set the X-Position for the window, because else is placed
at 0,0. Then we set it with XMoveWindow.
---
 src/actions.c |9 ++---
 src/window.c  |9 +
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index e1e6aaa..5f9d01e 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1082,7 +1082,7 @@ static WWindow *recursiveTransientFor(WWindow * wwin)
return wwin;
 }
 
-void wIconifyWindow(WWindow * wwin)
+void wIconifyWindow(WWindow *wwin)
 {
XWindowAttributes attribs;
int present;
@@ -1114,7 +1114,8 @@ void wIconifyWindow(WWindow * wwin)
if (!wwin->flags.icon_moved)
PlaceIcon(wwin->screen_ptr, &wwin->icon_x, 
&wwin->icon_y, wGetHeadForWindow(wwin));
 
-   wwin->icon = icon_create_for_wwindow(wwin);
+   /* Update the icon pixmap */
+   update_icon_pixmap(wwin->icon);
wwin->icon->mapped = 1;
}
 
@@ -1170,8 +1171,10 @@ void wIconifyWindow(WWindow * wwin)
 
if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
if (wwin->screen_ptr->current_workspace == 
wwin->frame->workspace ||
-   IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)
+   IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons) {
XMapWindow(dpy, wwin->icon->core->window);
+   XMoveWindow(dpy, wwin->icon->core->window, 
wwin->icon_x, wwin->icon_y);
+   }
 
AddToStackList(wwin->icon->core);
wLowerFrame(wwin->icon->core);
diff --git a/src/window.c b/src/window.c
index 1cb384a..ac36b1c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -819,6 +819,7 @@ WWindow *wManageWindow(WScreen *scr, Window window)
if (WFLAGP(wwin, start_maximized) && IS_RESIZABLE(wwin))
wwin->flags.maximized = MAX_VERTICAL | MAX_HORIZONTAL;
 
+   /* FIXME: Remove this line? */
wNETWMCheckInitialClientState(wwin);
 
/* apply previous state if it exists and we're in startup */
@@ -1357,6 +1358,14 @@ WWindow *wManageWindow(WScreen *scr, Window window)
wwin = NULL;
}
 
+   if (wwin) {
+   /* Create the icon for the window */
+   wwin->icon = icon_create_for_wwindow(wwin);
+
+   /* Create the window icon */
+   wwin->net_icon_image = 
get_window_image_from_x11(wwin->client_win);
+   }
+
return wwin;
 }
 
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 21/36] wIconUpdate uses get_window_image_def

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function wIconUpdate reads the icon from the client's window
icon image. This was set previously in wwin->net_icon_image by
get_window_image(), and this function is used always the icon change.
So, wwin->net_icon_image has always the icon image provided by the
client, except if the client doesn't provide image, then is NULL.

The function get_window_image_def() provides the net_icon_image, but
if is NULL, then provides the default icon image.
---
 src/icon.c |   19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index 6ef8474..e8ec87f 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -613,19 +613,18 @@ void wIconUpdate(WIcon *icon, RImage *image)
 
/* Get the Pixmap from the WIcon's Window */
icon->file_image = get_rimage_icon_from_icon_win(icon);
-   } else if (wwin && wwin->net_icon_image) {
+   } else if ((wwin && wwin->net_icon_image) ||
+  ((wwin && wwin->wm_hints &&
+   (wwin->wm_hints->flags & IconPixmapHint {
/* Remove the icon image */
unset_icon_image(icon);
 
-   /* Set the new icon image, use _NET_WM_ICON icon
-* (same icon that the window) */
-   icon->file_image = RRetainImage(wwin->net_icon_image);
-   } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & 
IconPixmapHint)) {
-   /* Get the Pixmap from the wm_hints, else, from the 
user */
-   unset_icon_image(icon);
-   icon->file_image = get_rimage_icon_from_wm_hints(wwin);
-   if (!icon->file_image)
-   get_rimage_icon_from_user_icon(icon);
+   /* Get the icon from wwin->net_icon_image.
+* wwin->net_icon_image is NULL only if no icon was
+* found. Then, the second part of the if is always
+* false '((wwin && wwin->wm_hints &&
+*  (wwin->wm_hints->flags & IconPixmapHint))' */
+   icon->file_image = get_window_image_def(wwin);
} else {
/* Get the Pixmap from the user */
get_rimage_icon_from_user_icon(icon);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 13/36] Icon file checking and dialog function

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The new function check_image_filepath(), checks if the file argument
exists in the disk and if the icon doesn't exist, show a dialog to
the user. Else return the full path for the file.

This new function replaces the ugly/dup code at winspector.c and
dockedapp.c, doing the code more clean.

The code at winspector.c is easy to see the change, but in dockedapp.c
is more difficult. The idea in dockedapp.c is first check if the file
exists in the disk, then call wIconChangeImageFile(). Because we know
the file exists, wIconChangeImageFile() doesn't return error.

Before this patch the code at dockedapp.c was more difficult to see and
had a problem. Function calls wIconChangeImageFile() to change the icon,
and allow to the user "Ignore" the error and set an incorrect file path
for the icon.

This patch also removes some curly brackets not needed and "if 0"
deactivated code in winspector.c and removes the variable "done"
because is not used (is set to 1 and the value is always 1) and
some empty lines at dockedapp.c
---
 src/dialog.c |   19 +++
 src/dialog.h |3 ++-
 src/dockedapp.c  |   42 +++---
 src/winspector.c |   20 ++--
 4 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/src/dialog.c b/src/dialog.c
index 6964495..fdfa44e 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -1607,3 +1607,22 @@ int wShowCrashingDialogPanel(int whatSig)
 
return action;
 }
+
+char *check_image_filepath(WScreen *scr, char *file)
+{
+   char *msg = NULL, *path = NULL;
+   int len = strlen(file) + 64;
+
+   if (!file)
+   return NULL;
+
+   path = FindImage(wPreferences.icon_path, file);
+   if (path)
+   return path;
+
+   msg = wmalloc(len);
+   snprintf(msg, len, _("Could not select specified icon file: %s"), file);
+   wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL);
+   wfree(msg);
+   return NULL;
+}
diff --git a/src/dialog.h b/src/dialog.h
index 530bd26..a48b34d 100644
--- a/src/dialog.h
+++ b/src/dialog.h
@@ -40,9 +40,10 @@ int wExitDialog(WScreen *scr, char *title, char *message, 
char *defBtn,
 
 Bool wIconChooserDialog(WScreen *scr, char **file, char *instance, char 
*class);
 
+char *check_image_filepath(WScreen *scr, char *file);
+
 void wShowInfoPanel(WScreen *scr);
 void wShowLegalPanel(WScreen *scr);
 int wShowCrashingDialogPanel(int whatSig);
 
-
 #endif
diff --git a/src/dockedapp.c b/src/dockedapp.c
index 6c6d1f0..bead77f 100644
--- a/src/dockedapp.c
+++ b/src/dockedapp.c
@@ -149,9 +149,9 @@ static void chooseIconCallback(WMWidget * self, void 
*clientData)
 static void panelBtnCallback(WMWidget * self, void *data)
 {
WMButton *btn = self;
+   WAppIcon *aicon = NULL;
AppSettingsPanel *panel = (AppSettingsPanel *) data;
-   char *text;
-   int done = 1;
+   char *text = NULL, *path = NULL;
 
if (panel->okBtn == btn) {
text = WMGetTextFieldText(panel->iconField);
@@ -160,30 +160,20 @@ static void panelBtnCallback(WMWidget * self, void *data)
text = NULL;
}
 
-   if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
-   char *buf;
-   int len = strlen(text) + 64;
-
-   buf = wmalloc(len);
-   snprintf(buf, len, _("Could not open specified icon 
file: %s"), text);
-   if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), 
buf,
-  _("OK"), _("Ignore"), NULL) == 
WAPRDefault) {
-   if (text)
-   wfree(text);
-   wfree(buf);
-   return;
-   }
-   wfree(buf);
-   } else {
-   WAppIcon *aicon = panel->editedIcon;
+   path = check_image_filepath(panel->wwin->screen_ptr, text);
+   if (!path)
+   return;
 
-   if (aicon == aicon->icon->core->screen_ptr->clip_icon)
-   wClipIconPaint(aicon);
-   else
-   wAppIconPaint(aicon);
+   wIconChangeImageFile(panel->editedIcon->icon, text);
+
+   aicon = panel->editedIcon;
+   if (aicon == aicon->icon->core->screen_ptr->clip_icon)
+   wClipIconPaint(aicon);
+   else
+   wAppIconPaint(aicon);
+
+   wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, 
aicon->wm_class, text);
 
-   wDefaultChangeIcon(panel->wwin->screen_ptr, 
aicon->wm_instance, aicon->wm_class, text);
-   }
if (text)
wfree(text);
 
@@ -205,12 +195,10 @@ st

[PATCH 22/36] Remove wIconUpdate wm_hints dead code

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The code removed in wIconUpdate() is never used, because net_icon_image
has always image except if the client doesn't have image. Because
net_icon_image uses wm_hints to get the image (and wm_net_icon), if
net_icon_image is false, then the removed part of the "if" is false too.
---
 src/icon.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/icon.c b/src/icon.c
index e8ec87f..80631cb 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -613,17 +613,13 @@ void wIconUpdate(WIcon *icon, RImage *image)
 
/* Get the Pixmap from the WIcon's Window */
icon->file_image = get_rimage_icon_from_icon_win(icon);
-   } else if ((wwin && wwin->net_icon_image) ||
-  ((wwin && wwin->wm_hints &&
-   (wwin->wm_hints->flags & IconPixmapHint {
+   } else if (wwin && wwin->net_icon_image) {
/* Remove the icon image */
unset_icon_image(icon);
 
/* Get the icon from wwin->net_icon_image.
 * wwin->net_icon_image is NULL only if no icon was
-* found. Then, the second part of the if is always
-* false '((wwin && wwin->wm_hints &&
-*  (wwin->wm_hints->flags & IconPixmapHint))' */
+* found. Then, return the default image */
icon->file_image = get_window_image_def(wwin);
} else {
/* Get the Pixmap from the user */
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 18/36] removeAppIconFor without wIconUpdate

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

The function removeAppIconFor() removes the application icon. Is used
when the application is closed. If the application has appicon painted
in the screen, and is docked, removeAppIconFor() needs repaint the icon.

But, the icon was there, was previously set, and is correct, therefore,
we don't need call wIconUpdate() and reassign a new icon, we only need
re-paint the icon.
---
 src/appicon.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index f254944..5e58f2e 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -250,6 +250,7 @@ void removeAppIconFor(WApplication *wapp)
 
if (wPreferences.highlight_active_app)
wIconSetHighlited(wapp->app_icon->icon, False);
+
if (wapp->app_icon->docked && !wapp->app_icon->attracted) {
wapp->app_icon->running = 0;
/* since we keep it, we don't care if it was attracted or not */
@@ -260,10 +261,7 @@ void removeAppIconFor(WApplication *wapp)
wapp->app_icon->icon->owner = NULL;
wapp->app_icon->icon->icon_win = None;
 
-   /* Update the icon images */
-   wIconUpdate(wapp->app_icon->icon, NULL);
-
-   /* Paint it */
+   /* The image is ok, only re-paint it */
wAppIconPaint(wapp->app_icon);
} else if (wapp->app_icon->docked) {
wapp->app_icon->running = 0;
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


[PATCH 36/36] winspector.c code clean

2012-11-25 Thread kix
From: "Rodolfo García Peñas (kix)" 

This patch only removes son curly brackets and add some extra empty lines.
---
 src/defaults.c |   21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/defaults.c b/src/defaults.c
index 4316450..14bde27 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -867,17 +867,15 @@ void wReadStaticDefaults(WMPropList * dict)
else
plvalue = NULL;
 
-   if (!plvalue) {
-   /* no default in the DB. Use builtin default */
+   /* no default in the DB. Use builtin default */
+   if (!plvalue)
plvalue = entry->plvalue;
-   }
 
if (plvalue) {
/* convert data */
(*entry->convert) (NULL, entry, plvalue, entry->addr, 
&tdata);
-   if (entry->update) {
+   if (entry->update)
(*entry->update) (NULL, entry, tdata, 
entry->extra_data);
-   }
}
}
 }
@@ -951,9 +949,10 @@ void wDefaultsCheckDomains(void* arg)
dict = shared_dict;
shared_dict = NULL;
}
-   if (WDWindowAttributes->dictionary) {
+
+   if (WDWindowAttributes->dictionary)

WMReleasePropList(WDWindowAttributes->dictionary);
-   }
+
WDWindowAttributes->dictionary = dict;
for (i = 0; i < wScreenCount; i++) {
scr = wScreenWithNumber(i);
@@ -970,10 +969,10 @@ void wDefaultsCheckDomains(void* arg)
} else {
wwarning(_("could not load domain %s from user defaults 
database"), "WMWindowAttributes");
}
+
WDWindowAttributes->timestamp = stbuf.st_mtime;
-   if (shared_dict) {
+   if (shared_dict)
WMReleasePropList(shared_dict);
-   }
}
 
if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < 
stbuf.st_mtime) {
@@ -985,9 +984,9 @@ void wDefaultsCheckDomains(void* arg)
wwarning(_("Domain %s (%s) of defaults database 
is corrupted!"),
 "WMRootMenu", WDRootMenu->path);
} else {
-   if (WDRootMenu->dictionary) {
+   if (WDRootMenu->dictionary)

WMReleasePropList(WDRootMenu->dictionary);
-   }
+
WDRootMenu->dictionary = dict;
wDefaultsMergeGlobalMenus(WDRootMenu);
}
-- 
1.7.10.4


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


Re: Problem with xfig

2012-11-25 Thread BALATON Zoltan

On Sun, 25 Nov 2012, Rodolfo García Peñas wrote:
The problem is because the "icon->icon_win == None". See the wIconUpdate 
function at [1]. This function is different than the next branch, I did 
a lot of changes, but the idea is the same. See the flow with the 
removed lines:


icon_create_for_wwindow
set_icon_for_window: wIconUpdate
wIconUpdate icon 0x936cd0
wwin 0x93f000 flag 0
wIconUpdate:get_rimage_icon_from_user_icon 4 icon 0x936cd0
wIconUpdate icon 0x936cd0
wwin 0x93f000 flag 0
wIconUpdate:get_rimage_icon_from_user_icon 4 icon 0x936cd0

Or with the lines (original code/next code):

icon_create_for_wwindow
set_icon_for_window: wIconUpdate
wIconUpdate icon 0x19bfd30
wwin 0x19c1a90 flag 0
wIconUpdate:get_rimage_icon_from_icon_win 2 icon 0x19bfd30
wIconUpdate icon 0x19bfd30
wwin 0x19c1a90 flag 0
wIconUpdate:get_rimage_icon_from_icon_win 2 icon 0x19bfd30

If I remove the lines, then "icon->icon_win == None", and then jump to 
the default icon. Else, get the icon from the wm_hints/net_icon_image.


I didn't understand a word from this but I hope you understand and know 
what you are doing. Just make sure that the test application still works 
the same after your changes please.



About your question about dockapps, they are fine here. Why?


I was asking because they work the same as the test case I've sent (start 
in withdrawn state and use their window as an icon window).


Dockapps works in a extrange way. The try to get the image for their 
dock. If the image is found, then, they set the image, else, set the 
wmaker default image. Whats happend if the application is running, then, 
the application background is set to the tile background 
(grey/blue/...), and the put the application inside the icon. But it the 
application is not running, the icon for the application is painted. If 
you click on the dockapp, the icon image is removed, the background is 
set and the application is put inside the icon.


What if the dockapp is not yet docked but started from the command line?

Regards,
BALATON Zoltan

Re: Problem with xfig

2012-11-25 Thread Rodolfo García Peñas
On Sun, 25 Nov 2012, BALATON Zoltan escribió:

> On Sun, 25 Nov 2012, Rodolfo García Peñas wrote:
> >The problem is because the "icon->icon_win == None". See the
> >wIconUpdate function at [1]. This function is different than the
> >next branch, I did a lot of changes, but the idea is the same. See
> >the flow with the removed lines:
> >
> >icon_create_for_wwindow
> >set_icon_for_window: wIconUpdate
> >wIconUpdate icon 0x936cd0
> >wwin 0x93f000 flag 0
> >wIconUpdate:get_rimage_icon_from_user_icon 4 icon 0x936cd0
> >wIconUpdate icon 0x936cd0
> >wwin 0x93f000 flag 0
> >wIconUpdate:get_rimage_icon_from_user_icon 4 icon 0x936cd0
> >
> >Or with the lines (original code/next code):
> >
> >icon_create_for_wwindow
> >set_icon_for_window: wIconUpdate
> >wIconUpdate icon 0x19bfd30
> >wwin 0x19c1a90 flag 0
> >wIconUpdate:get_rimage_icon_from_icon_win 2 icon 0x19bfd30
> >wIconUpdate icon 0x19bfd30
> >wwin 0x19c1a90 flag 0
> >wIconUpdate:get_rimage_icon_from_icon_win 2 icon 0x19bfd30
> >
> >If I remove the lines, then "icon->icon_win == None", and then
> >jump to the default icon. Else, get the icon from the
> >wm_hints/net_icon_image.
> 
> I didn't understand a word from this but I hope you understand and
> know what you are doing. Just make sure that the test application
> still works the same after your changes please.

I added some printfs in some functions to see the flow when an icon is created.
The function wIconUpdate, at icon.c, changes the file_image of the icon, using 
different methods (from file, from wm_hints,...). If we removes the lines, the 
flow is different.

I don't have nothing in mind. No changes. I only see that the problem is that 
or something related to these code lines. They changes how the application 
changes try to find the icon.

> >About your question about dockapps, they are fine here. Why?
> 
> I was asking because they work the same as the test case I've sent
> (start in withdrawn state and use their window as an icon window).

Ok, I don't know.

> >Dockapps works in a extrange way. The try to get the image for
> >their dock. If the image is found, then, they set the image, else,
> >set the wmaker default image. Whats happend if the application is
> >running, then, the application background is set to the tile
> >background (grey/blue/...), and the put the application inside the
> >icon. But it the application is not running, the icon for the
> >application is painted. If you click on the dockapp, the icon
> >image is removed, the background is set and the application is put
> >inside the icon.
> 
> What if the dockapp is not yet docked but started from the command line?

The normal flow in wmaker is that the application is standar, with a appicon. 
Is a normal application. When you move the appicon to the dockthen the 
functions about docking adds the icon to the dock. Then set the icons,..

> Regards,
> BALATON Zoltan

Thanks for your reply. But I don't know what to do now.

Best regards,
kix

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.


Re: Problem with xfig

2012-11-25 Thread BALATON Zoltan

On Mon, 26 Nov 2012, Rodolfo García Peñas wrote:

Thanks for your reply. But I don't know what to do now.


I don't know either. Are there any problems you know about that should be 
fixed or everything is fixed now? I've lost track.


Regards,
BALATON Zoltan

Re: Problem with xfig

2012-11-25 Thread Rodolfo García Peñas
On Mon, 26 Nov 2012, BALATON Zoltan escribió:

> On Mon, 26 Nov 2012, Rodolfo García Peñas wrote:
> >Thanks for your reply. But I don't know what to do now.
> 
> I don't know either. Are there any problems you know about that
> should be fixed or everything is fixed now? I've lost track.

No, is not fixed and I don't know how to fix it. Is only that these lines I 
commented, are the difference between icon and not icon, but I don't know how 
they impact in the code.

Regards,
kix
 
> Regards,
> BALATON Zoltan


-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.