mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-24 15:12:32 +01:00
wmaker: moved calculation of internal offset in handleDockMove outside the loop
As pointed by the "checkpatch.pl" script, one line was too long in respect of the coding style. This line contains the calculation of an offset when storing a value in an array, as this offset is a constant during all the loop, this patch is calculating the offset only once before the loop and then uses this result, which should make the code faster (although gcc may already optimise this kind of things), makes it compliant with coding style, and takes the opportunity to explain the reasons behind this offset. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
5881d1a8ba
commit
c3ba9aeba3
14
src/dock.c
14
src/dock.c
@@ -3835,12 +3835,24 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event)
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
if (dock->type == WM_DRAWER) {
|
||||
Window wins[dock->icon_count];
|
||||
int offset_index;
|
||||
|
||||
/*
|
||||
* When the dock is on the Right side, the index of the icons are negative to
|
||||
* reflect the fact that they are placed on the other side of the dock; we use
|
||||
* an offset here so we can have an always positive index for the storage in
|
||||
* the 'wins' array.
|
||||
*/
|
||||
if (dock->on_right_side)
|
||||
offset_index = dock->icon_count - 1;
|
||||
else
|
||||
offset_index = 0;
|
||||
|
||||
for (i = 0; i < dock->max_icons; i++) {
|
||||
tmpaicon = dock->icon_array[i];
|
||||
if (tmpaicon == NULL)
|
||||
continue;
|
||||
wins[ tmpaicon->xindex + (dock->on_right_side ? dock->icon_count - 1 : 0) ] = tmpaicon->icon->core->window;
|
||||
wins[tmpaicon->xindex + offset_index] = tmpaicon->icon->core->window;
|
||||
}
|
||||
slide_windows(wins, dock->icon_count,
|
||||
(dock->on_right_side ? x - (dock->icon_count - 1) * ICON_SIZE : x),
|
||||
|
||||
Reference in New Issue
Block a user