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:
committed by
Carlos R. Mafra
parent
fa27215fcc
commit
6aa43d356c
14
src/client.c
14
src/client.c
@@ -322,16 +322,10 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case XA_WM_ICON_NAME:
|
case XA_WM_ICON_NAME:
|
||||||
if (!wwin->flags.net_has_icon_title) {
|
/* Title has changed, update the icon title */
|
||||||
if (!wwin->icon)
|
if (wwin->icon) {
|
||||||
break;
|
wIconChangeTitle(wwin->icon, wwin);
|
||||||
else {
|
wIconPaint(wwin->icon);
|
||||||
char *new_title;
|
|
||||||
|
|
||||||
/* icon title was changed */
|
|
||||||
wGetIconName(dpy, wwin->client_win, &new_title);
|
|
||||||
wIconChangeTitle(wwin->icon, new_title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
19
src/icon.c
19
src/icon.c
@@ -134,12 +134,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin)
|
|||||||
icon->show_title = 1;
|
icon->show_title = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
icon->icon_name = wNETWMGetIconName(wwin->client_win);
|
wIconChangeTitle(icon, wwin);
|
||||||
if (icon->icon_name)
|
|
||||||
wwin->flags.net_has_icon_title = 1;
|
|
||||||
else
|
|
||||||
wGetIconName(dpy, wwin->client_win, &icon->icon_name);
|
|
||||||
|
|
||||||
icon->tile_type = TILE_NORMAL;
|
icon->tile_type = TILE_NORMAL;
|
||||||
|
|
||||||
set_icon_image_from_database(icon, wwin->wm_instance, wwin->wm_class, NULL);
|
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;
|
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)
|
if (icon->icon_name != NULL)
|
||||||
XFree(icon->icon_name);
|
XFree(icon->icon_name);
|
||||||
|
|
||||||
icon->icon_name = new_title;
|
/* Set the new one, using two methods */
|
||||||
wIconPaint(icon);
|
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)
|
RImage *wIconValidateIconSize(RImage *icon, int max_size)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void wIconDestroy(WIcon *icon);
|
|||||||
void wIconPaint(WIcon *icon);
|
void wIconPaint(WIcon *icon);
|
||||||
void wIconUpdate(WIcon *icon);
|
void wIconUpdate(WIcon *icon);
|
||||||
void wIconSelect(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);
|
void update_icon_pixmap(WIcon *icon);
|
||||||
|
|
||||||
Bool wIconChangeImageFile(WIcon *icon, char *file);
|
Bool wIconChangeImageFile(WIcon *icon, char *file);
|
||||||
|
|||||||
@@ -282,7 +282,6 @@ typedef struct WWindow {
|
|||||||
unsigned int net_handle_icon:1;
|
unsigned int net_handle_icon:1;
|
||||||
unsigned int net_show_desktop:1;
|
unsigned int net_show_desktop:1;
|
||||||
unsigned int net_has_title:1; /* use netwm version of WM_NAME */
|
unsigned int net_has_title:1; /* use netwm version of WM_NAME */
|
||||||
unsigned int net_has_icon_title:1;
|
|
||||||
} flags; /* state of the window */
|
} flags; /* state of the window */
|
||||||
|
|
||||||
struct WIcon *icon; /* Window icon when miminized
|
struct WIcon *icon; /* Window icon when miminized
|
||||||
|
|||||||
@@ -1470,8 +1470,8 @@ void wNETWMCheckClientHintChange(WWindow *wwin, XPropertyEvent *event)
|
|||||||
wfree(name);
|
wfree(name);
|
||||||
} else if (event->atom == net_wm_icon_name) {
|
} else if (event->atom == net_wm_icon_name) {
|
||||||
if (wwin->icon) {
|
if (wwin->icon) {
|
||||||
char *name = wNETWMGetIconName(wwin->client_win);
|
wIconChangeTitle(wwin->icon, wwin);
|
||||||
wIconChangeTitle(wwin->icon, name);
|
wIconPaint(wwin->icon);
|
||||||
}
|
}
|
||||||
} else if (event->atom == net_wm_icon) {
|
} else if (event->atom == net_wm_icon) {
|
||||||
updateIconImage(wwin);
|
updateIconImage(wwin);
|
||||||
|
|||||||
Reference in New Issue
Block a user