1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

wIconChangeTitle rewritten

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.

The functions that uses wIconChangeTitle (at client.c, icon.c and
wmspec.c) uses always the value set by wNETWMGetIconName() first,
else, the value set by wGetIconName(). This is the reason for the
flag net_has_icon_title. Now the flag can be removed.
This commit is contained in:
Rodolfo García Peñas (kix)
2013-04-08 19:40:58 +02:00
committed by Carlos R. Mafra
parent fa27215fcc
commit 6aa43d356c
5 changed files with 17 additions and 23 deletions

View File

@@ -322,16 +322,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);
}
/* Title has changed, update the icon title */
if (wwin->icon) {
wIconChangeTitle(wwin->icon, wwin);
wIconPaint(wwin->icon);
}
break;

View File

@@ -134,12 +134,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;
set_icon_image_from_database(icon, wwin->wm_instance, wwin->wm_class, NULL);
@@ -305,13 +300,19 @@ 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 title */
if (icon->icon_name != NULL)
XFree(icon->icon_name);
icon->icon_name = new_title;
wIconPaint(icon);
/* Set the new one, using two methods */
icon->icon_name = wNETWMGetIconName(wwin->client_win);
if (!icon->icon_name)
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
}
RImage *wIconValidateIconSize(RImage *icon, int max_size)

View File

@@ -61,7 +61,7 @@ void wIconDestroy(WIcon *icon);
void wIconPaint(WIcon *icon);
void wIconUpdate(WIcon *icon);
void wIconSelect(WIcon *icon);
void wIconChangeTitle(WIcon *icon, char *new_title);
void wIconChangeTitle(WIcon *icon, WWindow *wwin);
void update_icon_pixmap(WIcon *icon);
Bool wIconChangeImageFile(WIcon *icon, char *file);

View File

@@ -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

View File

@@ -1470,8 +1470,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) {
updateIconImage(wwin);