From: "Rodolfo García Peñas (kix)" <[email protected]>
The dock operations don't need wIconUpdate because the icon image
exists and is ok. For example, when we move a dock from the clip
to the dock, the icon attached to the dock has icon, and that icon
can be used in the clip, we don't need refresh it.
We need paint it in the screen, including the shadow, but this
operation is done in wAppIconPaint, so we don't need replace
wIconUpdate with wIconPaint, we can remove wIconUpdate.
Of course, the code is now faster, because the icon is only painted
one time, and the image is not selected again.
Some comments about this patch:
1. update_icon flag:
The icon update flag:
- /* Update the icon images */
- if (update_icon)
- wIconUpdate(icon->icon, NULL);
-
Is used to know if we need update or not the icon. Because we don't
need udpate it in any case, the update_icon flag can be removed.
2. shadow flag:
The update_icon removed was used mostly because the shadow flag is
set, then, the icon must be re-painted. The shadow flag is still used,
but is painted using wAppIconPaint(), so there are no problems.
3. Function wDockAttachIcon:
This function don't uses the update_icon flag, so the function can drop
this argument.
-Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, \
Bool update_icon)
+Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y)
---
src/appicon.c | 10 ++++------
src/dock.c | 47 +++++++++--------------------------------------
src/dock.h | 2 +-
3 files changed, 14 insertions(+), 45 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 4c5fb86..f254944 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -201,7 +201,6 @@ void paint_app_icon(WApplication *wapp)
WScreen *scr = wapp->main_window_desc->screen_ptr;
WDock *clip = scr->workspaces[scr->current_workspace]->clip;
int x = 0, y = 0;
- Bool update_icon = False;
if (!wapp || !wapp->app_icon)
return;
@@ -215,11 +214,10 @@ void paint_app_icon(WApplication *wapp)
if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
wapp->app_icon->attracted = 1;
- if (!icon->shadowed) {
+ if (!icon->shadowed)
icon->shadowed = 1;
- update_icon = True;
- }
- wDockAttachIcon(clip, wapp->app_icon, x, y, update_icon);
+
+ wDockAttachIcon(clip, wapp->app_icon, x, y);
} else {
/* We must know if the icon is painted in the screen,
* because if painted, then PlaceIcon will return the next
@@ -863,7 +861,7 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event)
/* icon is trying to be docked */
SlideWindow(icon->core->window, x, y, shad_x,
shad_y);
XUnmapWindow(dpy, scr->dock_shadow);
- docked = wDockAttachIcon(scr->last_dock, aicon,
ix, iy, False);
+ docked = wDockAttachIcon(scr->last_dock, aicon,
ix, iy);
if (scr->last_dock->auto_collapse)
collapsed = 0;
diff --git a/src/dock.c b/src/dock.c
index f503e14..24164de 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -540,9 +540,6 @@ static void keepIconsCallback(WMenu *menu, WMenuEntry
*entry)
if (aicon->icon->shadowed) {
aicon->icon->shadowed = 0;
- /* Update the icon images */
- wIconUpdate(aicon->icon, NULL);
-
/* Paint it */
wAppIconPaint(aicon);
}
@@ -582,7 +579,6 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry
*entry)
WDock *clip;
WAppIcon *aicon;
int x, y, x_pos, y_pos;
- Bool update_icon = False;
assert(entry->clientdata != NULL);
clip = clickedIcon->dock;
@@ -597,11 +593,10 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry
*entry)
move_window(aicon->icon->core->window,
aicon->x_pos, aicon->y_pos, x_pos, y_pos);
aicon->attracted = 1;
- if (!aicon->icon->shadowed) {
+ if (!aicon->icon->shadowed)
aicon->icon->shadowed = 1;
- update_icon = True;
- }
- wDockAttachIcon(clip, aicon, x, y, update_icon);
+
+ wDockAttachIcon(clip, aicon, x, y);
if (clip->collapsed || !clip->mapped)
XUnmapWindow(dpy, aicon->icon->core->window);
}
@@ -1851,18 +1846,14 @@ int wDockReceiveDNDDrop(WScreen *scr, XEvent *event)
}
#endif /* XDND */
-Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool
update_icon)
+Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y)
{
WWindow *wwin;
- Bool lupdate_icon = False;
char *command = NULL;
int index;
icon->editing = 0;
- if (update_icon)
- lupdate_icon = True;
-
if (icon->command == NULL) {
/* Try to get the command for the window, if it is running! */
if (icon->icon->owner) {
@@ -1893,10 +1884,8 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x,
int y, Bool update_icon
*/
if (dock->type == WM_CLIP) {
icon->attracted = 1;
- if (!icon->icon->shadowed) {
+ if (!icon->icon->shadowed)
icon->icon->shadowed =
1;
- lupdate_icon = True;
- }
} else {
return False;
}
@@ -1939,10 +1928,6 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x,
int y, Bool update_icon
MoveInStackListUnder(dock->icon_array[index - 1]->icon->core,
icon->icon->core);
wAppIconMove(icon, icon->x_pos, icon->y_pos);
- /* Update the icon images */
- if (lupdate_icon)
- wIconUpdate(icon->icon, NULL);
-
/* Paint it */
wAppIconPaint(icon);
@@ -1991,7 +1976,6 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest,
WAppIcon *icon, int x,
WWindow *wwin;
char *command = NULL;
int index;
- Bool update_icon = False;
/* Check if no move needed, we're already there */
if (src == dest)
@@ -2075,10 +2059,9 @@ static Bool moveIconBetweenDocks(WDock *src, WDock
*dest, WAppIcon *icon, int x,
*/
if (icon->command && dest->type == WM_DOCK) {
icon->attracted = 0;
- if (icon->icon->shadowed) {
+ if (icon->icon->shadowed)
icon->icon->shadowed = 0;
- update_icon = True;
- }
+
save_appicon(icon, True);
}
@@ -2095,10 +2078,6 @@ static Bool moveIconBetweenDocks(WDock *src, WDock
*dest, WAppIcon *icon, int x,
MoveInStackListUnder(dest->icon_array[index - 1]->icon->core,
icon->icon->core);
- /* Update the icon images */
- if (update_icon)
- wIconUpdate(icon->icon, NULL);
-
/* Paint it */
wAppIconPaint(icon);
@@ -2108,25 +2087,21 @@ static Bool moveIconBetweenDocks(WDock *src, WDock
*dest, WAppIcon *icon, int x,
void wDockDetach(WDock *dock, WAppIcon *icon)
{
int index;
- Bool update_icon = False;
/* make the settings panel be closed */
if (icon->panel)
DestroyDockAppSettingsPanel(icon->panel);
/* This must be called before icon->dock is set to NULL.
- * Don't move it. -Dan
- */
+ * Don't move it. -Dan */
wClipMakeIconOmnipresent(icon, False);
icon->docked = 0;
icon->dock = NULL;
icon->attracted = 0;
icon->auto_launch = 0;
- if (icon->icon->shadowed) {
+ if (icon->icon->shadowed)
icon->icon->shadowed = 0;
- update_icon = True;
- }
/* deselect the icon */
if (icon->icon->selected)
@@ -2172,10 +2147,6 @@ void wDockDetach(WDock *dock, WAppIcon *icon)
ChangeStackingLevel(icon->icon->core, NORMAL_ICON_LEVEL);
- /* Update the icon images */
- if (update_icon)
- wIconUpdate(icon->icon, NULL);
-
/* Paint it */
wAppIconPaint(icon);
diff --git a/src/dock.h b/src/dock.h
index 08ae8de..be10095 100644
--- a/src/dock.h
+++ b/src/dock.h
@@ -79,7 +79,7 @@ void wDockRaise(WDock *dock);
void wDockRaiseLower(WDock *dock);
void wDockSaveState(WScreen *scr, WMPropList *old_state);
-Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool
update_icon);
+Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y);
Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y,
int *ret_x, int *ret_y, int redocking);
Bool wDockFindFreeSlot(WDock *dock, int *req_x, int *req_y);
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].