Please, don't apply this patch yet. I found a mistake.
Thanks. kix On Fri, 30 Mar 2012, Rodolfo García Peñas escribió: > > From 9cbb4c57f352f107f0dd2e0a980f26430adeacb4 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]> > Date: Fri, 30 Mar 2012 16:46:30 +0200 > Subject: [PATCH 5/5] WindowMaker: net_icon_image replaced by WIcon > > The wwindow struct has two icons; net_icon_image and icon. The net_icon_image > is used in some parts of the code, like switchpanel. Is created when the > window is created by the X-Server. The icon is used in other parts, like > appicon,... > > Now, this commit join the functionality of net_icon_image and icon in icon, > the switchpanel, appicon,... using the same icon. > --- > src/application.c | 5 ++--- > src/icon.c | 20 +++++++++++++++----- > src/switchpanel.c | 10 +++++----- > src/window.c | 2 -- > src/window.h | 1 - > src/wmspec.c | 18 +++++++++--------- > src/wmspec.h | 1 + > 7 files changed, 32 insertions(+), 25 deletions(-) > > diff --git a/src/application.c b/src/application.c > index 94eec74..a0b8182 100644 > --- a/src/application.c > +++ b/src/application.c > @@ -259,9 +259,6 @@ WApplication *wApplicationCreate(WWindow * wwin) > } > > wapp->main_window_desc->fake_group = wwin->fake_group; > - wapp->main_window_desc->net_icon_image = > RRetainImage(wwin->net_icon_image); > - > - extractIcon(wapp->main_window_desc); > > leader = wWindowFor(main_window); > if (leader) > @@ -353,6 +350,8 @@ WApplication *wApplicationCreate(WWindow * wwin) > char *tmp, *path; > struct stat dummy; > > + extractIcon(wapp->main_window_desc); > + > tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, > wapp->app_icon->wm_class, True); > > /* If the icon was saved by us from the client supplied icon, > but is > diff --git a/src/icon.c b/src/icon.c > index f32b372..f1f46ee 100644 > --- a/src/icon.c > +++ b/src/icon.c > @@ -157,8 +157,18 @@ WIcon *wIconCreate(WWindow * wwin) > #else > icon->show_title = 1; > #endif > - icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size, False); > + /* Search the icon, without default icon included (see False parameter) > */ > + icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size, True); > > + /* If no icon found in the config files, get it from X11 */ > + if (!icon->file_image) > + icon->file_image = get_wwindow_image_from_x11(wwin); > + > + /* If no icon found, Search it but now WITH default icon (see False > parameter) */ > + if (!icon->file_image) > + icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size, False); > + > + /* Search the icon, but not the default App icon */ > file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, > False); > if (file) > icon->file = wstrdup(file); > @@ -482,8 +492,8 @@ char *wIconStore(WIcon * icon) > if (!path) > return NULL; > > - if (wwin->net_icon_image) { > - image = RRetainImage(wwin->net_icon_image); > + if (wwin->icon && wwin->icon->file_image) { > + image = RRetainImage(wwin->icon->file_image); > } else if (wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint) > && wwin->wm_hints->icon_pixmap != None) { > image = > RCreateImageFromDrawable(icon->core->screen_ptr->rcontext, > @@ -572,9 +582,9 @@ void wIconUpdate(WIcon * icon) > } else if (icon->icon_win != None) { > /* Get the Pixmap from the WIcon */ > get_pixmap_icon_from_icon_win(icon); > - } else if (wwin && wwin->net_icon_image) { > + } else if (wwin && wwin->icon && wwin->icon->file_image) { > /* Use _NET_WM_ICON icon */ > - icon->pixmap = makeIcon(scr, wwin->net_icon_image, > icon->show_title, > + icon->pixmap = makeIcon(scr, wwin->icon->file_image, > icon->show_title, > icon->shadowed, > icon->tile_type, icon->highlighted); > } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & > IconPixmapHint)) { > /* Get the Pixmap from the wm_hints, else, from the user */ > diff --git a/src/switchpanel.c b/src/switchpanel.c > index d2eb0a6..6fc6d6b 100644 > --- a/src/switchpanel.c > +++ b/src/switchpanel.c > @@ -32,6 +32,7 @@ > #include "switchpanel.h" > #include "funcs.h" > #include "xinerama.h" > +#include "icon.h" > > extern Atom _XA_WM_IGNORE_FOCUS_EVENTS; > > @@ -172,12 +173,11 @@ static void addIconForWindow(WSwitchPanel * panel, > WMWidget * parent, WWindow * > WMResizeWidget(icon, ICON_TILE_SIZE, ICON_TILE_SIZE); > WMMoveWidget(icon, x, y); > > - if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image) > - image = RRetainImage(wwin->net_icon_image); > + /* The image is set when the icon is created, then, read it */ > + if (!WFLAGP(wwin, always_user_icon) && wwin->icon && > wwin->icon->file_image) > + image = RRetainImage(wwin->icon->file_image); > > - // Make this use a caching thing. When there are many windows, > - // it's very likely that most of them are instances of the same thing, > - // so caching them should get performance acceptable in these cases. > + /* If something is wrong, then, read the icon from the config files */ > if (!image) > image = wDefaultGetImage(panel->scr, wwin->wm_instance, > wwin->wm_class, ICON_TILE_SIZE, False); > > diff --git a/src/window.c b/src/window.c > index 7bc30be..7910530 100644 > --- a/src/window.c > +++ b/src/window.c > @@ -239,8 +239,6 @@ void wWindowDestroy(WWindow *wwin) > if (wPreferences.auto_arrange_icons) > wArrangeIcons(wwin->screen_ptr, True); > } > - if (wwin->net_icon_image) > - RReleaseImage(wwin->net_icon_image); > > wrelease(wwin); > } > diff --git a/src/window.h b/src/window.h > index edebe80..30fc564 100644 > --- a/src/window.h > +++ b/src/window.h > @@ -301,7 +301,6 @@ typedef struct WWindow { > struct WIcon *icon; /* icon info for the window */ > int icon_x, icon_y; /* position of the icon */ > int icon_w, icon_h; > - RImage *net_icon_image; > Atom type; > } WWindow; > > diff --git a/src/wmspec.c b/src/wmspec.c > index 9456841..6c2a3b0 100644 > --- a/src/wmspec.c > +++ b/src/wmspec.c > @@ -413,7 +413,7 @@ static RImage *makeRImageFromARGBData(unsigned long *data) > return image; > } > > -static RImage *get_wwindow_image_from_x11(WWindow *wwin) > +RImage *get_wwindow_image_from_x11(WWindow *wwin) > { > RImage *image; > Atom type; > @@ -448,16 +448,16 @@ static RImage *get_wwindow_image_from_x11(WWindow *wwin) > > static void updateIconImage(WWindow *wwin) > { > - /* Remove the icon image from X11 */ > - if (wwin->net_icon_image) > - RReleaseImage(wwin->net_icon_image); > - > - /* Save the icon in the X11 icon */ > - wwin->net_icon_image = get_wwindow_image_from_x11(wwin); > + /* If the WIcon don't exits, create it */ > + if (!wwin->icon) { > + wwin->icon = wIconCreate(wwin); > + wwin->icon->core->descriptor.parent_type = WCLASS_APPICON; > + wwin->icon->core->descriptor.parent = wwin->icon; > + AddToStackList(wwin->icon->core); > + } > > /* Refresh the Window Icon */ > - if (wwin->icon) > - wIconUpdate(wwin->icon); > + wIconUpdate(wwin->icon); > > /* Refresh the application icon */ > WApplication *app = wApplicationOf(wwin->main_window); > diff --git a/src/wmspec.h b/src/wmspec.h > index 71f8ee0..d963da2 100644 > --- a/src/wmspec.h > +++ b/src/wmspec.h > @@ -44,4 +44,5 @@ int wNETWMGetPidForWindow(Window window); > int wNETWMGetCurrentDesktopFromHint(WScreen *scr); > char *wNETWMGetIconName(Window window); > char *wNETWMGetWindowName(Window window); > +RImage *get_wwindow_image_from_x11(WWindow *wwin); > #endif > -- > 1.7.9.1 > > -- > ||// //\\// Rodolfo "kix" Garcia > ||\\// //\\ http://www.kix.es/ > From 9cbb4c57f352f107f0dd2e0a980f26430adeacb4 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]> > Date: Fri, 30 Mar 2012 16:46:30 +0200 > Subject: [PATCH 5/5] WindowMaker: net_icon_image replaced by WIcon > > The wwindow struct has two icons; net_icon_image and icon. The net_icon_image > is used in some parts of the code, like switchpanel. Is created when the > window is created by the X-Server. The icon is used in other parts, like > appicon,... > > Now, this commit join the functionality of net_icon_image and icon in icon, > the switchpanel, appicon,... using the same icon. > --- > src/application.c | 5 ++--- > src/icon.c | 20 +++++++++++++++----- > src/switchpanel.c | 10 +++++----- > src/window.c | 2 -- > src/window.h | 1 - > src/wmspec.c | 18 +++++++++--------- > src/wmspec.h | 1 + > 7 files changed, 32 insertions(+), 25 deletions(-) > > diff --git a/src/application.c b/src/application.c > index 94eec74..a0b8182 100644 > --- a/src/application.c > +++ b/src/application.c > @@ -259,9 +259,6 @@ WApplication *wApplicationCreate(WWindow * wwin) > } > > wapp->main_window_desc->fake_group = wwin->fake_group; > - wapp->main_window_desc->net_icon_image = > RRetainImage(wwin->net_icon_image); > - > - extractIcon(wapp->main_window_desc); > > leader = wWindowFor(main_window); > if (leader) > @@ -353,6 +350,8 @@ WApplication *wApplicationCreate(WWindow * wwin) > char *tmp, *path; > struct stat dummy; > > + extractIcon(wapp->main_window_desc); > + > tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, > wapp->app_icon->wm_class, True); > > /* If the icon was saved by us from the client supplied icon, > but is > diff --git a/src/icon.c b/src/icon.c > index f32b372..f1f46ee 100644 > --- a/src/icon.c > +++ b/src/icon.c > @@ -157,8 +157,18 @@ WIcon *wIconCreate(WWindow * wwin) > #else > icon->show_title = 1; > #endif > - icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size, False); > + /* Search the icon, without default icon included (see False parameter) > */ > + icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size, True); > > + /* If no icon found in the config files, get it from X11 */ > + if (!icon->file_image) > + icon->file_image = get_wwindow_image_from_x11(wwin); > + > + /* If no icon found, Search it but now WITH default icon (see False > parameter) */ > + if (!icon->file_image) > + icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size, False); > + > + /* Search the icon, but not the default App icon */ > file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, > False); > if (file) > icon->file = wstrdup(file); > @@ -482,8 +492,8 @@ char *wIconStore(WIcon * icon) > if (!path) > return NULL; > > - if (wwin->net_icon_image) { > - image = RRetainImage(wwin->net_icon_image); > + if (wwin->icon && wwin->icon->file_image) { > + image = RRetainImage(wwin->icon->file_image); > } else if (wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint) > && wwin->wm_hints->icon_pixmap != None) { > image = > RCreateImageFromDrawable(icon->core->screen_ptr->rcontext, > @@ -572,9 +582,9 @@ void wIconUpdate(WIcon * icon) > } else if (icon->icon_win != None) { > /* Get the Pixmap from the WIcon */ > get_pixmap_icon_from_icon_win(icon); > - } else if (wwin && wwin->net_icon_image) { > + } else if (wwin && wwin->icon && wwin->icon->file_image) { > /* Use _NET_WM_ICON icon */ > - icon->pixmap = makeIcon(scr, wwin->net_icon_image, > icon->show_title, > + icon->pixmap = makeIcon(scr, wwin->icon->file_image, > icon->show_title, > icon->shadowed, > icon->tile_type, icon->highlighted); > } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & > IconPixmapHint)) { > /* Get the Pixmap from the wm_hints, else, from the user */ > diff --git a/src/switchpanel.c b/src/switchpanel.c > index d2eb0a6..6fc6d6b 100644 > --- a/src/switchpanel.c > +++ b/src/switchpanel.c > @@ -32,6 +32,7 @@ > #include "switchpanel.h" > #include "funcs.h" > #include "xinerama.h" > +#include "icon.h" > > extern Atom _XA_WM_IGNORE_FOCUS_EVENTS; > > @@ -172,12 +173,11 @@ static void addIconForWindow(WSwitchPanel * panel, > WMWidget * parent, WWindow * > WMResizeWidget(icon, ICON_TILE_SIZE, ICON_TILE_SIZE); > WMMoveWidget(icon, x, y); > > - if (!WFLAGP(wwin, always_user_icon) && wwin->net_icon_image) > - image = RRetainImage(wwin->net_icon_image); > + /* The image is set when the icon is created, then, read it */ > + if (!WFLAGP(wwin, always_user_icon) && wwin->icon && > wwin->icon->file_image) > + image = RRetainImage(wwin->icon->file_image); > > - // Make this use a caching thing. When there are many windows, > - // it's very likely that most of them are instances of the same thing, > - // so caching them should get performance acceptable in these cases. > + /* If something is wrong, then, read the icon from the config files */ > if (!image) > image = wDefaultGetImage(panel->scr, wwin->wm_instance, > wwin->wm_class, ICON_TILE_SIZE, False); > > diff --git a/src/window.c b/src/window.c > index 7bc30be..7910530 100644 > --- a/src/window.c > +++ b/src/window.c > @@ -239,8 +239,6 @@ void wWindowDestroy(WWindow *wwin) > if (wPreferences.auto_arrange_icons) > wArrangeIcons(wwin->screen_ptr, True); > } > - if (wwin->net_icon_image) > - RReleaseImage(wwin->net_icon_image); > > wrelease(wwin); > } > diff --git a/src/window.h b/src/window.h > index edebe80..30fc564 100644 > --- a/src/window.h > +++ b/src/window.h > @@ -301,7 +301,6 @@ typedef struct WWindow { > struct WIcon *icon; /* icon info for the window */ > int icon_x, icon_y; /* position of the icon */ > int icon_w, icon_h; > - RImage *net_icon_image; > Atom type; > } WWindow; > > diff --git a/src/wmspec.c b/src/wmspec.c > index 9456841..6c2a3b0 100644 > --- a/src/wmspec.c > +++ b/src/wmspec.c > @@ -413,7 +413,7 @@ static RImage *makeRImageFromARGBData(unsigned long *data) > return image; > } > > -static RImage *get_wwindow_image_from_x11(WWindow *wwin) > +RImage *get_wwindow_image_from_x11(WWindow *wwin) > { > RImage *image; > Atom type; > @@ -448,16 +448,16 @@ static RImage *get_wwindow_image_from_x11(WWindow *wwin) > > static void updateIconImage(WWindow *wwin) > { > - /* Remove the icon image from X11 */ > - if (wwin->net_icon_image) > - RReleaseImage(wwin->net_icon_image); > - > - /* Save the icon in the X11 icon */ > - wwin->net_icon_image = get_wwindow_image_from_x11(wwin); > + /* If the WIcon don't exits, create it */ > + if (!wwin->icon) { > + wwin->icon = wIconCreate(wwin); > + wwin->icon->core->descriptor.parent_type = WCLASS_APPICON; > + wwin->icon->core->descriptor.parent = wwin->icon; > + AddToStackList(wwin->icon->core); > + } > > /* Refresh the Window Icon */ > - if (wwin->icon) > - wIconUpdate(wwin->icon); > + wIconUpdate(wwin->icon); > > /* Refresh the application icon */ > WApplication *app = wApplicationOf(wwin->main_window); > diff --git a/src/wmspec.h b/src/wmspec.h > index 71f8ee0..d963da2 100644 > --- a/src/wmspec.h > +++ b/src/wmspec.h > @@ -44,4 +44,5 @@ int wNETWMGetPidForWindow(Window window); > int wNETWMGetCurrentDesktopFromHint(WScreen *scr); > char *wNETWMGetIconName(Window window); > char *wNETWMGetWindowName(Window window); > +RImage *get_wwindow_image_from_x11(WWindow *wwin); > #endif > -- > 1.7.9.1 > -- ||// //\\// Rodolfo "kix" Garcia ||\\// //\\ http://www.kix.es/ -- To unsubscribe, send mail to [email protected].
