Something is wrong in these three patches :-( Don't apply them yet.
Sorry kix On Fri, 06 Jul 2012, Rodolfo kix Garcia escribió: > > From 8cfd7a16e8a1ae0b91b28bad2ea2c1e5d47f4975 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]> > Date: Thu, 5 Jul 2012 21:39:37 +0200 > Subject: [PATCH 1/3] New wIconCreate_real function > > The functions wIconCreate and wIconCreateWithIcon hold the same > inteface (arguments), but now they call to the function wIconCreate_real, > that contains the common code and receives the needed arguments for both. > > The file name argument in wIconCreateWithIcon is replaced by > the instance and class, because the file name can be found later. > > Some extra things are added, like NULL initialization in some variables. > --- > src/appicon.c | 13 +------ > src/icon.c | 105 > ++++++++++++++++++++++++++++++--------------------------- > src/icon.h | 5 +-- > 3 files changed, 59 insertions(+), 64 deletions(-) > > diff --git a/src/appicon.c b/src/appicon.c > index 795b020..30f9b6a 100644 > --- a/src/appicon.c > +++ b/src/appicon.c > @@ -109,7 +109,6 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char > *path, char *wm_instance > WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char > *wm_instance, char *wm_class, int tile) > { > WAppIcon *dicon; > - char *path; > > dicon = wmalloc(sizeof(WAppIcon)); > wretain(dicon); > @@ -127,18 +126,8 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char > *command, char *wm_instance, > if (wm_instance) > dicon->wm_instance = wstrdup(wm_instance); > > - path = wDefaultGetIconFile(wm_instance, wm_class, True); > - if (!path && command) { > - wApplicationExtractDirPackIcon(scr, command, wm_instance, > wm_class); > - path = wDefaultGetIconFile(wm_instance, wm_class, False); > - } > - > - if (path) > - path = FindImage(wPreferences.icon_path, path); > + dicon->icon = wIconCreateWithIconFile(scr, wm_instance, wm_class, tile); > > - dicon->icon = wIconCreateWithIconFile(scr, path, tile); > - if (path) > - wfree(path); > #ifdef XDND > wXDNDMakeAwareness(dicon->icon->core->window); > #endif > diff --git a/src/icon.c b/src/icon.c > index 6537ece..cbee0d4 100644 > --- a/src/icon.c > +++ b/src/icon.c > @@ -58,6 +58,8 @@ static void miniwindowMouseDown(WObjDescriptor * desc, > XEvent * event); > static void miniwindowDblClick(WObjDescriptor * desc, XEvent * event); > > static WIcon *wIconCreateCore(WScreen *scr, int coord_x, int coord_y); > +static WIcon *wIconCreate_real(WWindow *wwin, WScreen *scr, char *command, > + char *instance, char *class, int tile_type); > > void get_pixmap_icon_from_icon_win(WIcon *icon); > int get_pixmap_icon_from_wm_hints(WScreen *scr, WWindow *wwin, WIcon *icon); > @@ -100,74 +102,74 @@ INLINE static void getSize(Drawable d, unsigned int *w, > unsigned int *h, unsigne > XGetGeometry(dpy, d, &rjunk, &xjunk, &yjunk, w, h, &bjunk, dep); > } > > -WIcon *wIconCreate(WWindow * wwin) > +WIcon *wIconCreate(WWindow *wwin) > { > - WScreen *scr = wwin->screen_ptr; > - WIcon *icon; > - char *file; > + return wIconCreate_real(wwin, wwin->screen_ptr, NULL, > + wwin->wm_instance, wwin->wm_class, TILE_NORMAL); > +} > > - icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y); > +WIcon *wIconCreateWithIconFile(WScreen *scr, char *instance, char *class, > + int tile_type) > +{ > + return wIconCreate_real(NULL, scr, NULL, instance, class, tile_type); > +} > > - icon->owner = wwin; > - if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) { > - if (wwin->client_win == wwin->main_window) { > - WApplication *wapp; > - /* do not let miniwindow steal app-icon's icon window */ > - wapp = wApplicationOf(wwin->client_win); > - if (!wapp || wapp->app_icon == NULL) > +static WIcon *wIconCreate_real(WWindow *wwin, WScreen *scr, char *command, > + char *instance, char *class, int tile_type) > +{ > + WIcon *icon; > + char *file = NULL; > + > + /* If we have wwindow, is a normal application, else is a dock */ > + if (wwin) { > + icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y); > + > + icon->owner = wwin; > + if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) > { > + if (wwin->client_win == wwin->main_window) { > + WApplication *wapp; > + /* do not let miniwindow steal app-icon's icon > window */ > + wapp = wApplicationOf(wwin->client_win); > + if (!wapp || wapp->app_icon == NULL) > + icon->icon_win = > wwin->wm_hints->icon_window; > + } else { > icon->icon_win = wwin->wm_hints->icon_window; > - } else { > - icon->icon_win = wwin->wm_hints->icon_window; > + } > } > - } > #ifdef NO_MINIWINDOW_TITLES > - icon->show_title = 0; > + icon->show_title = 0; > #else > - icon->show_title = 1; > + icon->show_title = 1; > #endif > - icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size); > + } else { > + icon = wIconCreateCore(scr, 0, 0); > + } > > - file = wDefaultGetIconFile(wwin->wm_instance, wwin->wm_class, False); > + /* Get the file name */ > + file = get_default_icon_filename(scr, instance, class, command, False); > if (file) > icon->file = wstrdup(file); > > - 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); > - > - icon->tile_type = TILE_NORMAL; > - > - wIconUpdate(icon); > - > - XFlush(dpy); > - > - WMAddNotificationObserver(appearanceObserver, icon, > WNIconAppearanceSettingsChanged, icon); > - WMAddNotificationObserver(tileObserver, icon, > WNIconTileSettingsChanged, icon); > - return icon; > -} > - > -WIcon *wIconCreateWithIconFile(WScreen * scr, char *iconfile, int tile) > -{ > - WIcon *icon; > - > - icon = wIconCreateCore(scr, 0, 0); > - > - if (iconfile) { > - icon->file_image = RLoadImage(scr->rcontext, iconfile, 0); > - if (!icon->file_image) > - wwarning(_("error loading image file \"%s\": %s"), > iconfile, RMessageForError(RErrorCode)); > - > - icon->file_image = wIconValidateIconSize(scr, icon->file_image, > wPreferences.icon_size); > + /* Load the icon using the file name */ > + icon->file_image = get_default_icon_rimage(scr, file, > wPreferences.icon_size); > + if (file) > + wfree(file); > > - icon->file = wstrdup(iconfile); > + /* Set the icon name */ > + if (wwin) { > + 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); > } > > - icon->tile_type = tile; > + icon->tile_type = tile_type; > > wIconUpdate(icon); > > + XFlush(dpy); > + > WMAddNotificationObserver(appearanceObserver, icon, > WNIconAppearanceSettingsChanged, icon); > WMAddNotificationObserver(tileObserver, icon, > WNIconTileSettingsChanged, icon); > > @@ -211,6 +213,9 @@ static WIcon *wIconCreateCore(WScreen *scr, int coord_x, > int coord_y) > icon->core->stacking->window_level = NORMAL_ICON_LEVEL; > icon->core->stacking->child_of = NULL; > > + icon->file = NULL; > + icon->file_image = NULL; > + > return icon; > } > > diff --git a/src/icon.h b/src/icon.h > index 62a1844..bdb56b5 100644 > --- a/src/icon.h > +++ b/src/icon.h > @@ -54,8 +54,9 @@ typedef struct WIcon { > * color */ > } WIcon; > > -WIcon * wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile); > -WIcon * wIconCreate(WWindow *wwin); > +WIcon *wIconCreateWithIconFile(WScreen *scr, char *instance, char *class, > + int tile_type); > +WIcon *wIconCreate(WWindow *wwin); > > void wIconDestroy(WIcon *icon); > void wIconPaint(WIcon *icon); > -- > 1.7.10 > > -- > ||// //\\// Rodolfo "kix" Garcia > ||\\// //\\ http://www.kix.es/ > From 8cfd7a16e8a1ae0b91b28bad2ea2c1e5d47f4975 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]> > Date: Thu, 5 Jul 2012 21:39:37 +0200 > Subject: [PATCH 1/3] New wIconCreate_real function > > The functions wIconCreate and wIconCreateWithIcon hold the same > inteface (arguments), but now they call to the function wIconCreate_real, > that contains the common code and receives the needed arguments for both. > > The file name argument in wIconCreateWithIcon is replaced by > the instance and class, because the file name can be found later. > > Some extra things are added, like NULL initialization in some variables. > --- > src/appicon.c | 13 +------ > src/icon.c | 105 > ++++++++++++++++++++++++++++++--------------------------- > src/icon.h | 5 +-- > 3 files changed, 59 insertions(+), 64 deletions(-) > > diff --git a/src/appicon.c b/src/appicon.c > index 795b020..30f9b6a 100644 > --- a/src/appicon.c > +++ b/src/appicon.c > @@ -109,7 +109,6 @@ void wApplicationExtractDirPackIcon(WScreen * scr, char > *path, char *wm_instance > WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char > *wm_instance, char *wm_class, int tile) > { > WAppIcon *dicon; > - char *path; > > dicon = wmalloc(sizeof(WAppIcon)); > wretain(dicon); > @@ -127,18 +126,8 @@ WAppIcon *wAppIconCreateForDock(WScreen * scr, char > *command, char *wm_instance, > if (wm_instance) > dicon->wm_instance = wstrdup(wm_instance); > > - path = wDefaultGetIconFile(wm_instance, wm_class, True); > - if (!path && command) { > - wApplicationExtractDirPackIcon(scr, command, wm_instance, > wm_class); > - path = wDefaultGetIconFile(wm_instance, wm_class, False); > - } > - > - if (path) > - path = FindImage(wPreferences.icon_path, path); > + dicon->icon = wIconCreateWithIconFile(scr, wm_instance, wm_class, tile); > > - dicon->icon = wIconCreateWithIconFile(scr, path, tile); > - if (path) > - wfree(path); > #ifdef XDND > wXDNDMakeAwareness(dicon->icon->core->window); > #endif > diff --git a/src/icon.c b/src/icon.c > index 6537ece..cbee0d4 100644 > --- a/src/icon.c > +++ b/src/icon.c > @@ -58,6 +58,8 @@ static void miniwindowMouseDown(WObjDescriptor * desc, > XEvent * event); > static void miniwindowDblClick(WObjDescriptor * desc, XEvent * event); > > static WIcon *wIconCreateCore(WScreen *scr, int coord_x, int coord_y); > +static WIcon *wIconCreate_real(WWindow *wwin, WScreen *scr, char *command, > + char *instance, char *class, int tile_type); > > void get_pixmap_icon_from_icon_win(WIcon *icon); > int get_pixmap_icon_from_wm_hints(WScreen *scr, WWindow *wwin, WIcon *icon); > @@ -100,74 +102,74 @@ INLINE static void getSize(Drawable d, unsigned int *w, > unsigned int *h, unsigne > XGetGeometry(dpy, d, &rjunk, &xjunk, &yjunk, w, h, &bjunk, dep); > } > > -WIcon *wIconCreate(WWindow * wwin) > +WIcon *wIconCreate(WWindow *wwin) > { > - WScreen *scr = wwin->screen_ptr; > - WIcon *icon; > - char *file; > + return wIconCreate_real(wwin, wwin->screen_ptr, NULL, > + wwin->wm_instance, wwin->wm_class, TILE_NORMAL); > +} > > - icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y); > +WIcon *wIconCreateWithIconFile(WScreen *scr, char *instance, char *class, > + int tile_type) > +{ > + return wIconCreate_real(NULL, scr, NULL, instance, class, tile_type); > +} > > - icon->owner = wwin; > - if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) { > - if (wwin->client_win == wwin->main_window) { > - WApplication *wapp; > - /* do not let miniwindow steal app-icon's icon window */ > - wapp = wApplicationOf(wwin->client_win); > - if (!wapp || wapp->app_icon == NULL) > +static WIcon *wIconCreate_real(WWindow *wwin, WScreen *scr, char *command, > + char *instance, char *class, int tile_type) > +{ > + WIcon *icon; > + char *file = NULL; > + > + /* If we have wwindow, is a normal application, else is a dock */ > + if (wwin) { > + icon = wIconCreateCore(scr, wwin->icon_x, wwin->icon_y); > + > + icon->owner = wwin; > + if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) > { > + if (wwin->client_win == wwin->main_window) { > + WApplication *wapp; > + /* do not let miniwindow steal app-icon's icon > window */ > + wapp = wApplicationOf(wwin->client_win); > + if (!wapp || wapp->app_icon == NULL) > + icon->icon_win = > wwin->wm_hints->icon_window; > + } else { > icon->icon_win = wwin->wm_hints->icon_window; > - } else { > - icon->icon_win = wwin->wm_hints->icon_window; > + } > } > - } > #ifdef NO_MINIWINDOW_TITLES > - icon->show_title = 0; > + icon->show_title = 0; > #else > - icon->show_title = 1; > + icon->show_title = 1; > #endif > - icon->file_image = wDefaultGetImage(scr, wwin->wm_instance, > wwin->wm_class, wPreferences.icon_size); > + } else { > + icon = wIconCreateCore(scr, 0, 0); > + } > > - file = wDefaultGetIconFile(wwin->wm_instance, wwin->wm_class, False); > + /* Get the file name */ > + file = get_default_icon_filename(scr, instance, class, command, False); > if (file) > icon->file = wstrdup(file); > > - 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); > - > - icon->tile_type = TILE_NORMAL; > - > - wIconUpdate(icon); > - > - XFlush(dpy); > - > - WMAddNotificationObserver(appearanceObserver, icon, > WNIconAppearanceSettingsChanged, icon); > - WMAddNotificationObserver(tileObserver, icon, > WNIconTileSettingsChanged, icon); > - return icon; > -} > - > -WIcon *wIconCreateWithIconFile(WScreen * scr, char *iconfile, int tile) > -{ > - WIcon *icon; > - > - icon = wIconCreateCore(scr, 0, 0); > - > - if (iconfile) { > - icon->file_image = RLoadImage(scr->rcontext, iconfile, 0); > - if (!icon->file_image) > - wwarning(_("error loading image file \"%s\": %s"), > iconfile, RMessageForError(RErrorCode)); > - > - icon->file_image = wIconValidateIconSize(scr, icon->file_image, > wPreferences.icon_size); > + /* Load the icon using the file name */ > + icon->file_image = get_default_icon_rimage(scr, file, > wPreferences.icon_size); > + if (file) > + wfree(file); > > - icon->file = wstrdup(iconfile); > + /* Set the icon name */ > + if (wwin) { > + 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); > } > > - icon->tile_type = tile; > + icon->tile_type = tile_type; > > wIconUpdate(icon); > > + XFlush(dpy); > + > WMAddNotificationObserver(appearanceObserver, icon, > WNIconAppearanceSettingsChanged, icon); > WMAddNotificationObserver(tileObserver, icon, > WNIconTileSettingsChanged, icon); > > @@ -211,6 +213,9 @@ static WIcon *wIconCreateCore(WScreen *scr, int coord_x, > int coord_y) > icon->core->stacking->window_level = NORMAL_ICON_LEVEL; > icon->core->stacking->child_of = NULL; > > + icon->file = NULL; > + icon->file_image = NULL; > + > return icon; > } > > diff --git a/src/icon.h b/src/icon.h > index 62a1844..bdb56b5 100644 > --- a/src/icon.h > +++ b/src/icon.h > @@ -54,8 +54,9 @@ typedef struct WIcon { > * color */ > } WIcon; > > -WIcon * wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile); > -WIcon * wIconCreate(WWindow *wwin); > +WIcon *wIconCreateWithIconFile(WScreen *scr, char *instance, char *class, > + int tile_type); > +WIcon *wIconCreate(WWindow *wwin); > > void wIconDestroy(WIcon *icon); > void wIconPaint(WIcon *icon); > -- > 1.7.10 > -- ||// //\\// Rodolfo "kix" Garcia ||\\// //\\ http://www.kix.es/ -- To unsubscribe, send mail to [email protected].
