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

wAppIconPaint paint argument

The function wAppIconPaint has a new argument. This argument is used
to force an icon create if needed.
This commit is contained in:
Rodolfo García Peñas (kix)
2012-11-10 20:25:11 +01:00
committed by Carlos R. Mafra
parent a3078a5095
commit 33ebded4f9
11 changed files with 60 additions and 45 deletions

View File

@@ -1540,12 +1540,12 @@ void wHideApplication(WApplication *wapp)
wapp->flags.hidden = 1; wapp->flags.hidden = 1;
if (wPreferences.auto_arrange_icons) { if (wPreferences.auto_arrange_icons)
wArrangeIcons(scr, True); wArrangeIcons(scr, True);
}
#ifdef HIDDENDOT #ifdef HIDDENDOT
if (wapp->app_icon) if (wapp->app_icon)
wAppIconPaint(wapp->app_icon); wAppIconPaint(wapp->app_icon, False);
#endif #endif
} }
@@ -1669,11 +1669,11 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
wSetFocusTo(scr, focused); wSetFocusTo(scr, focused);
} }
wapp->last_focused = NULL; wapp->last_focused = NULL;
if (wPreferences.auto_arrange_icons) { if (wPreferences.auto_arrange_icons)
wArrangeIcons(scr, True); wArrangeIcons(scr, True);
}
#ifdef HIDDENDOT #ifdef HIDDENDOT
wAppIconPaint(wapp->app_icon); wAppIconPaint(wapp->app_icon, False);
#endif #endif
} }

View File

@@ -238,7 +238,7 @@ void paint_app_icon(WApplication *wapp)
wArrangeIcons(scr, True); wArrangeIcons(scr, True);
} }
void removeAppIconFor(WApplication * wapp) void removeAppIconFor(WApplication *wapp)
{ {
if (!wapp->app_icon) if (!wapp->app_icon)
return; return;
@@ -252,8 +252,7 @@ void removeAppIconFor(WApplication * wapp)
wapp->app_icon->pid = 0; wapp->app_icon->pid = 0;
wapp->app_icon->icon->owner = NULL; wapp->app_icon->icon->owner = NULL;
wapp->app_icon->icon->icon_win = None; wapp->app_icon->icon->icon_win = None;
wapp->app_icon->icon->force_paint = 1; wAppIconPaint(wapp->app_icon, True);
wAppIconPaint(wapp->app_icon);
} else if (wapp->app_icon->docked) { } else if (wapp->app_icon->docked) {
wapp->app_icon->running = 0; wapp->app_icon->running = 0;
wDockDetach(wapp->app_icon->dock, wapp->app_icon); wDockDetach(wapp->app_icon->dock, wapp->app_icon);
@@ -371,7 +370,7 @@ static void updateDockNumbers(WScreen * scr)
} }
#endif /* WS_INDICATOR */ #endif /* WS_INDICATOR */
void wAppIconPaint(WAppIcon * aicon) void wAppIconPaint(WAppIcon *aicon, Bool update_icon)
{ {
WApplication *wapp; WApplication *wapp;
WScreen *scr = aicon->icon->core->screen_ptr; WScreen *scr = aicon->icon->core->screen_ptr;
@@ -381,6 +380,9 @@ void wAppIconPaint(WAppIcon * aicon)
else else
wapp = NULL; wapp = NULL;
if (update_icon)
aicon->icon->force_paint = 1;
wIconPaint(aicon->icon); wIconPaint(aicon->icon);
# ifdef WS_INDICATOR # ifdef WS_INDICATOR
@@ -484,7 +486,7 @@ static void unhideHereCallback(WMenu * menu, WMenuEntry * entry)
wUnhideApplication(wapp, False, True); wUnhideApplication(wapp, False, True);
} }
static void setIconCallback(WMenu * menu, WMenuEntry * entry) static void setIconCallback(WMenu *menu, WMenuEntry *entry)
{ {
WAppIcon *icon = ((WApplication *) entry->clientdata)->app_icon; WAppIcon *icon = ((WApplication *) entry->clientdata)->app_icon;
char *file = NULL; char *file = NULL;
@@ -513,7 +515,9 @@ static void setIconCallback(WMenu * menu, WMenuEntry * entry)
_("Could not open specified icon file"), _("OK"), NULL, NULL); _("Could not open specified icon file"), _("OK"), NULL, NULL);
} else { } else {
wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file); wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file);
wAppIconPaint(icon); /* The image was updated previously at wIconChangeImageFile,
* so we don't need update it here again */
wAppIconPaint(icon, False);
} }
if (file) if (file)
wfree(file); wfree(file);
@@ -568,7 +572,7 @@ static void killCallback(WMenu * menu, WMenuEntry * entry)
WCHANGE_STATE(WSTATE_NORMAL); WCHANGE_STATE(WSTATE_NORMAL);
} }
static WMenu *createApplicationMenu(WScreen * scr) static WMenu *createApplicationMenu(WScreen *scr)
{ {
WMenu *menu; WMenu *menu;
@@ -619,12 +623,12 @@ static void openApplicationMenu(WApplication * wapp, int x, int y)
/******************************************************************/ /******************************************************************/
static void iconExpose(WObjDescriptor * desc, XEvent * event) static void iconExpose(WObjDescriptor *desc, XEvent *event)
{ {
wAppIconPaint(desc->parent); wAppIconPaint(desc->parent, False);
} }
static void iconDblClick(WObjDescriptor * desc, XEvent * event) static void iconDblClick(WObjDescriptor *desc, XEvent *event)
{ {
WAppIcon *aicon = desc->parent; WAppIcon *aicon = desc->parent;
WApplication *wapp; WApplication *wapp;
@@ -980,12 +984,11 @@ void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_win
WWindow *mainw = wapp->main_window_desc; WWindow *mainw = wapp->main_window_desc;
wapp->app_icon->running = 1; wapp->app_icon->running = 1;
wapp->app_icon->icon->force_paint = 1;
wapp->app_icon->icon->owner = mainw; wapp->app_icon->icon->owner = mainw;
if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint)) if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint))
wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window; wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window;
wAppIconPaint(wapp->app_icon); wAppIconPaint(wapp->app_icon, True);
save_appicon(wapp->app_icon, True); save_appicon(wapp->app_icon, True);
} }
} }

View File

@@ -74,7 +74,7 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window); void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, Window main_window);
void wAppIconDestroy(WAppIcon *aicon); void wAppIconDestroy(WAppIcon *aicon);
void wAppIconPaint(WAppIcon *aicon); void wAppIconPaint(WAppIcon *aicon, Bool update_icon);
void wAppIconMove(WAppIcon *aicon, int x, int y); void wAppIconMove(WAppIcon *aicon, int x, int y);
void makeAppIconFor(WApplication * wapp); void makeAppIconFor(WApplication * wapp);
void removeAppIconFor(WApplication * wapp); void removeAppIconFor(WApplication * wapp);

View File

@@ -215,7 +215,7 @@ void wApplicationActivate(WApplication *wapp)
#ifdef NEWAPPICON #ifdef NEWAPPICON
if (wapp->app_icon) { if (wapp->app_icon) {
wIconSetHighlited(wapp->app_icon->icon, True); wIconSetHighlited(wapp->app_icon->icon, True);
wAppIconPaint(wapp->app_icon); wAppIconPaint(wapp->app_icon, False);
} }
#endif #endif
} }
@@ -225,7 +225,7 @@ void wApplicationDeactivate(WApplication *wapp)
#ifdef NEWAPPICON #ifdef NEWAPPICON
if (wapp->app_icon) { if (wapp->app_icon) {
wIconSetHighlited(wapp->app_icon->icon, False); wIconSetHighlited(wapp->app_icon->icon, False);
wAppIconPaint(wapp->app_icon); wAppIconPaint(wapp->app_icon, False);
} }
#endif #endif
} }

View File

@@ -478,7 +478,9 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event)
wapp = wApplicationOf(wwin->main_window); wapp = wApplicationOf(wwin->main_window);
if (wapp && wapp->app_icon) { if (wapp && wapp->app_icon) {
wIconUpdate(wapp->app_icon->icon); wIconUpdate(wapp->app_icon->icon);
wAppIconPaint(wapp->app_icon); /* The icon was updated in wIconUpdate, so we don't
* need update it again here */
wAppIconPaint(wapp->app_icon, False);
} }
} }

View File

@@ -1118,7 +1118,7 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict)
} }
} }
void wDefaultUpdateIcons(WScreen * scr) void wDefaultUpdateIcons(WScreen *scr)
{ {
WAppIcon *aicon = scr->app_icon_list; WAppIcon *aicon = scr->app_icon_list;
WWindow *wwin = scr->focused_window; WWindow *wwin = scr->focused_window;
@@ -1130,7 +1130,9 @@ void wDefaultUpdateIcons(WScreen * scr)
if ((file && aicon->icon->file && strcmp(file, aicon->icon->file) != 0) if ((file && aicon->icon->file && strcmp(file, aicon->icon->file) != 0)
|| (file && !aicon->icon->file)) { || (file && !aicon->icon->file)) {
wIconChangeImageFile(aicon->icon, file); wIconChangeImageFile(aicon->icon, file);
wAppIconPaint(aicon); /* The image was updated previously at wIconChangeImageFile,
* so we don't need update it here again */
wAppIconPaint(aicon, False);
} }
aicon = aicon->next; aicon = aicon->next;
} }
@@ -1143,9 +1145,8 @@ void wDefaultUpdateIcons(WScreen * scr)
/* Get the application icon, default included */ /* Get the application icon, default included */
file = wDefaultGetIconFile(wwin->wm_instance, wwin->wm_class, True); file = wDefaultGetIconFile(wwin->wm_instance, wwin->wm_class, True);
if ((file && wwin->icon->file && strcmp(file, wwin->icon->file) != 0) if ((file && wwin->icon->file && strcmp(file, wwin->icon->file) != 0)
|| (file && !wwin->icon->file)) { || (file && !wwin->icon->file))
wIconChangeImageFile(wwin->icon, file); wIconChangeImageFile(wwin->icon, file);
}
} }
wwin = wwin->prev; wwin = wwin->prev;
} }

View File

@@ -538,8 +538,7 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry *entry)
aicon->attracted = 0; aicon->attracted = 0;
if (aicon->icon->shadowed) { if (aicon->icon->shadowed) {
aicon->icon->shadowed = 0; aicon->icon->shadowed = 0;
aicon->icon->force_paint = 1; wAppIconPaint(aicon, True);
wAppIconPaint(aicon);
} }
} }
save_appicon(aicon, True); save_appicon(aicon, True);
@@ -1149,7 +1148,7 @@ static void dockIconPaint(WAppIcon *btn)
if (btn == btn->icon->core->screen_ptr->clip_icon) { if (btn == btn->icon->core->screen_ptr->clip_icon) {
wClipIconPaint(btn); wClipIconPaint(btn);
} else { } else {
wAppIconPaint(btn); wAppIconPaint(btn, False);
save_appicon(btn, True); save_appicon(btn, True);
} }
} }
@@ -1849,13 +1848,14 @@ int wDockReceiveDNDDrop(WScreen *scr, XEvent *event)
Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon) Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon)
{ {
WWindow *wwin; WWindow *wwin;
Bool lupdate_icon = False;
int index; int index;
wwin = icon->icon->owner; wwin = icon->icon->owner;
icon->editing = 0; icon->editing = 0;
if (update_icon) if (update_icon)
icon->icon->force_paint = 1; lupdate_icon = True;
if (icon->command == NULL) { if (icon->command == NULL) {
char *command; char *command;
@@ -1886,7 +1886,7 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon
icon->attracted = 1; icon->attracted = 1;
if (!icon->icon->shadowed) { if (!icon->icon->shadowed) {
icon->icon->shadowed = 1; icon->icon->shadowed = 1;
icon->icon->force_paint = 1; lupdate_icon = True;
} }
} else { } else {
return False; return False;
@@ -1929,7 +1929,7 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon
MoveInStackListUnder(dock->icon_array[index - 1]->icon->core, icon->icon->core); MoveInStackListUnder(dock->icon_array[index - 1]->icon->core, icon->icon->core);
wAppIconMove(icon, icon->x_pos, icon->y_pos); wAppIconMove(icon, icon->x_pos, icon->y_pos);
wAppIconPaint(icon); wAppIconPaint(icon, lupdate_icon);
save_appicon(icon, True); save_appicon(icon, True);
if (wPreferences.auto_arrange_icons) if (wPreferences.auto_arrange_icons)
@@ -1974,6 +1974,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
WWindow *wwin; WWindow *wwin;
char *command; char *command;
int index; int index;
Bool update_icon = False;
if (src == dest) if (src == dest)
return True; /* No move needed, we're already there */ return True; /* No move needed, we're already there */
@@ -2054,7 +2055,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
icon->attracted = 0; icon->attracted = 0;
if (icon->icon->shadowed) { if (icon->icon->shadowed) {
icon->icon->shadowed = 0; icon->icon->shadowed = 0;
icon->icon->force_paint = 1; update_icon = True;
} }
save_appicon(icon, True); save_appicon(icon, True);
} }
@@ -2071,7 +2072,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
dest->icon_count++; dest->icon_count++;
MoveInStackListUnder(dest->icon_array[index - 1]->icon->core, icon->icon->core); MoveInStackListUnder(dest->icon_array[index - 1]->icon->core, icon->icon->core);
wAppIconPaint(icon); wAppIconPaint(icon, update_icon);
return True; return True;
} }
@@ -2079,6 +2080,7 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
void wDockDetach(WDock *dock, WAppIcon *icon) void wDockDetach(WDock *dock, WAppIcon *icon)
{ {
int index; int index;
Bool update_icon = False;
/* make the settings panel be closed */ /* make the settings panel be closed */
if (icon->panel) if (icon->panel)
@@ -2095,7 +2097,7 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
icon->auto_launch = 0; icon->auto_launch = 0;
if (icon->icon->shadowed) { if (icon->icon->shadowed) {
icon->icon->shadowed = 0; icon->icon->shadowed = 0;
icon->icon->force_paint = 1; update_icon = True;
} }
/* deselect the icon */ /* deselect the icon */
@@ -2142,7 +2144,7 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
ChangeStackingLevel(icon->icon->core, NORMAL_ICON_LEVEL); ChangeStackingLevel(icon->icon->core, NORMAL_ICON_LEVEL);
wAppIconPaint(icon); wAppIconPaint(icon, update_icon);
if (wPreferences.auto_arrange_icons) if (wPreferences.auto_arrange_icons)
wArrangeIcons(dock->screen_ptr, True); wArrangeIcons(dock->screen_ptr, True);
} }
@@ -2888,7 +2890,7 @@ void wDockTrackWindowLaunch(WDock *dock, Window window)
wLowerFrame(aicon->icon->core); wLowerFrame(aicon->icon->core);
XMapWindow(dpy, aicon->icon->core->window); XMapWindow(dpy, aicon->icon->core->window);
aicon->launching = 1; aicon->launching = 1;
wAppIconPaint(aicon); wAppIconPaint(aicon, False);
SlideWindow(aicon->icon->core->window, x0, y0, icon->x_pos, icon->y_pos); SlideWindow(aicon->icon->core->window, x0, y0, icon->x_pos, icon->y_pos);
XUnmapWindow(dpy, aicon->icon->core->window); XUnmapWindow(dpy, aicon->icon->core->window);
wAppIconDestroy(aicon); wAppIconDestroy(aicon);
@@ -3964,7 +3966,7 @@ int wClipMakeIconOmnipresent(WAppIcon *aicon, int omnipresent)
} }
} }
wAppIconPaint(aicon); wAppIconPaint(aicon, False);
return status; return status;
} }

View File

@@ -151,15 +151,15 @@ static void panelBtnCallback(WMWidget * self, void *data)
WMButton *btn = self; WMButton *btn = self;
AppSettingsPanel *panel = (AppSettingsPanel *) data; AppSettingsPanel *panel = (AppSettingsPanel *) data;
char *text; char *text;
int done; int done = 1;
done = 1;
if (panel->okBtn == btn) { if (panel->okBtn == btn) {
text = WMGetTextFieldText(panel->iconField); text = WMGetTextFieldText(panel->iconField);
if (text[0] == 0) { if (text[0] == 0) {
wfree(text); wfree(text);
text = NULL; text = NULL;
} }
if (!wIconChangeImageFile(panel->editedIcon->icon, text)) { if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
char *buf; char *buf;
int len = strlen(text) + 64; int len = strlen(text) + 64;
@@ -177,10 +177,12 @@ static void panelBtnCallback(WMWidget * self, void *data)
} else { } else {
WAppIcon *aicon = panel->editedIcon; WAppIcon *aicon = panel->editedIcon;
/* The image was updated in wIconChangeImageFile,
* so we don't need udpate it at wAppIconPaint */
if (aicon == aicon->icon->core->screen_ptr->clip_icon) if (aicon == aicon->icon->core->screen_ptr->clip_icon)
wClipIconPaint(aicon); wClipIconPaint(aicon);
else else
wAppIconPaint(aicon); wAppIconPaint(aicon, False);
wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, aicon->wm_class, text); wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, aicon->wm_class, text);
} }

View File

@@ -785,14 +785,18 @@ static void applySettings(WMButton *button, InspectorPanel *panel)
wfree(file); wfree(file);
file = NULL; file = NULL;
} }
wIconChangeImageFile(wapp->app_icon->icon, file); wIconChangeImageFile(wapp->app_icon->icon, file);
if (file) if (file)
wfree(file); wfree(file);
wAppIconPaint(wapp->app_icon);
/* The image was updated in wIconChangeImageFile,
* so we don't need udpate it at wAppIconPaint */
wAppIconPaint(wapp->app_icon, False);
} }
} }
wNETFrameExtents(wwin); wNETFrameExtents(wwin);
} }
static void revertSettings(WMButton *button, InspectorPanel *panel) static void revertSettings(WMButton *button, InspectorPanel *panel)

View File

@@ -474,7 +474,8 @@ static void updateIconImage(WWindow *wwin)
WApplication *app = wApplicationOf(wwin->main_window); WApplication *app = wApplicationOf(wwin->main_window);
if (app && app->app_icon) { if (app && app->app_icon) {
wIconUpdate(app->app_icon->icon); wIconUpdate(app->app_icon->icon);
wAppIconPaint(app->app_icon); /* Icon was updated in wIconUpdate, so we don't need update it again */
wAppIconPaint(app->app_icon, False);
} }
} }

View File

@@ -594,7 +594,7 @@ void wWorkspaceForceChange(WScreen * scr, int workspace)
wArrangeIcons(scr, False); wArrangeIcons(scr, False);
if (scr->dock) if (scr->dock)
wAppIconPaint(scr->dock->icon_array[0]); wAppIconPaint(scr->dock->icon_array[0], False);
if (scr->clip_icon) { if (scr->clip_icon) {
if (scr->workspaces[workspace]->clip->auto_collapse || if (scr->workspaces[workspace]->clip->auto_collapse ||