mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
wmaker: remove one level of pointers for the function SlideWindows
The function does not need to be passed a array of pointer to windows because it does not change content of the pointers. It is more efficient to directly use an array of windows as the parameter, and simpler also. As 'SlideWindow' is also concerned, it can be simplified and turned into an inlinable function so the compiler can optimise it. Took opportunity to de-CamelCase the name of the functions to comply with the project's coding style. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
8fa16bef00
commit
784f6794e5
@@ -1843,7 +1843,7 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll)
|
|||||||
if (aicon->x_pos != X || aicon->y_pos != Y) {
|
if (aicon->x_pos != X || aicon->y_pos != Y) {
|
||||||
#ifdef USE_ANIMATIONS
|
#ifdef USE_ANIMATIONS
|
||||||
if (!wPreferences.no_animations)
|
if (!wPreferences.no_animations)
|
||||||
SlideWindow(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, X, Y);
|
slide_window(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, X, Y);
|
||||||
#endif /* USE_ANIMATIONS */
|
#endif /* USE_ANIMATIONS */
|
||||||
}
|
}
|
||||||
wAppIconMove(aicon, X, Y);
|
wAppIconMove(aicon, X, Y);
|
||||||
|
|||||||
@@ -967,7 +967,7 @@ Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event)
|
|||||||
|
|
||||||
Bool docked = False;
|
Bool docked = False;
|
||||||
if (ondock) {
|
if (ondock) {
|
||||||
SlideWindow(icon->core->window, x, y, shad_x, shad_y);
|
slide_window(icon->core->window, x, y, shad_x, shad_y);
|
||||||
XUnmapWindow(dpy, scr->dock_shadow);
|
XUnmapWindow(dpy, scr->dock_shadow);
|
||||||
if (originalDock == NULL) { // docking an undocked appicon
|
if (originalDock == NULL) { // docking an undocked appicon
|
||||||
docked = wDockAttachIcon(lastDock, aicon, ix, iy, False);
|
docked = wDockAttachIcon(lastDock, aicon, ix, iy, False);
|
||||||
@@ -980,7 +980,7 @@ Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event)
|
|||||||
// Also fill the gap left in the drawer
|
// Also fill the gap left in the drawer
|
||||||
wDrawerFillTheGap(lastDock, aicon, False);
|
wDrawerFillTheGap(lastDock, aicon, False);
|
||||||
}
|
}
|
||||||
SlideWindow(icon->core->window, x, y, oldX, oldY);
|
slide_window(icon->core->window, x, y, oldX, oldY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // moving a docked appicon to a dock
|
else { // moving a docked appicon to a dock
|
||||||
@@ -1016,7 +1016,7 @@ Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event)
|
|||||||
// Trust the appicon is inserted at exactly the same place, so its oldX/oldY are consistent with its "new" location?
|
// Trust the appicon is inserted at exactly the same place, so its oldX/oldY are consistent with its "new" location?
|
||||||
}
|
}
|
||||||
|
|
||||||
SlideWindow(icon->core->window, x, y, oldX, oldY);
|
slide_window(icon->core->window, x, y, oldX, oldY);
|
||||||
wDockReattachIcon(originalDock, aicon, aicon->xindex, aicon->yindex);
|
wDockReattachIcon(originalDock, aicon, aicon->xindex, aicon->yindex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
14
src/dock.c
14
src/dock.c
@@ -3271,7 +3271,7 @@ void wDockTrackWindowLaunch(WDock *dock, Window window)
|
|||||||
XMapWindow(dpy, aicon->icon->core->window);
|
XMapWindow(dpy, aicon->icon->core->window);
|
||||||
aicon->launching = 1;
|
aicon->launching = 1;
|
||||||
wAppIconPaint(aicon);
|
wAppIconPaint(aicon);
|
||||||
SlideWindow(aicon->icon->core->window, x0, y0, icon->x_pos, icon->y_pos);
|
slide_window(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);
|
||||||
}
|
}
|
||||||
@@ -3834,15 +3834,15 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event)
|
|||||||
break;
|
break;
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
if (dock->type == WM_DRAWER) {
|
if (dock->type == WM_DRAWER) {
|
||||||
Window *wins[dock->icon_count];
|
Window wins[dock->icon_count];
|
||||||
|
|
||||||
for (i = 0; i < dock->max_icons; i++) {
|
for (i = 0; i < dock->max_icons; i++) {
|
||||||
tmpaicon = dock->icon_array[i];
|
tmpaicon = dock->icon_array[i];
|
||||||
if (tmpaicon == NULL)
|
if (tmpaicon == NULL)
|
||||||
continue;
|
continue;
|
||||||
wins[ tmpaicon->xindex + (dock->on_right_side ? dock->icon_count - 1 : 0) ] = &tmpaicon->icon->core->window;
|
wins[ tmpaicon->xindex + (dock->on_right_side ? dock->icon_count - 1 : 0) ] = tmpaicon->icon->core->window;
|
||||||
}
|
}
|
||||||
SlideWindows(wins, dock->icon_count,
|
slide_windows(wins, dock->icon_count,
|
||||||
(dock->on_right_side ? x - (dock->icon_count - 1) * ICON_SIZE : x),
|
(dock->on_right_side ? x - (dock->icon_count - 1) * ICON_SIZE : x),
|
||||||
y,
|
y,
|
||||||
(dock->on_right_side ? shad_x - (dock->icon_count - 1) * ICON_SIZE : shad_x),
|
(dock->on_right_side ? shad_x - (dock->icon_count - 1) * ICON_SIZE : shad_x),
|
||||||
@@ -4665,7 +4665,7 @@ void wSlideAppicons(WAppIcon **appicons, int n, int to_the_left)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int leftmost = -1, min_index = 9999, from_x = -1; // leftmost and from_x initialized to avoid warning
|
int leftmost = -1, min_index = 9999, from_x = -1; // leftmost and from_x initialized to avoid warning
|
||||||
Window *wins[n];
|
Window wins[n];
|
||||||
WAppIcon *aicon;
|
WAppIcon *aicon;
|
||||||
|
|
||||||
if (n < 1)
|
if (n < 1)
|
||||||
@@ -4684,10 +4684,10 @@ void wSlideAppicons(WAppIcon **appicons, int n, int to_the_left)
|
|||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
aicon = appicons[i];
|
aicon = appicons[i];
|
||||||
wins[aicon->xindex - min_index] = &aicon->icon->core->window;
|
wins[aicon->xindex - min_index] = aicon->icon->core->window;
|
||||||
}
|
}
|
||||||
aicon = appicons[leftmost];
|
aicon = appicons[leftmost];
|
||||||
SlideWindows(wins, n, from_x, aicon->y_pos, aicon->x_pos, aicon->y_pos);
|
slide_windows(wins, n, from_x, aicon->y_pos, aicon->x_pos, aicon->y_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
14
src/misc.c
14
src/misc.c
@@ -145,7 +145,7 @@ void move_window(Window win, int from_x, int from_y, int to_x, int to_y)
|
|||||||
if (wPreferences.no_animations)
|
if (wPreferences.no_animations)
|
||||||
XMoveWindow(dpy, win, to_x, to_y);
|
XMoveWindow(dpy, win, to_x, to_y);
|
||||||
else
|
else
|
||||||
SlideWindow(win, from_x, from_y, to_x, to_y);
|
slide_window(win, from_x, from_y, to_x, to_y);
|
||||||
#else
|
#else
|
||||||
XMoveWindow(dpy, win, to_x, to_y);
|
XMoveWindow(dpy, win, to_x, to_y);
|
||||||
|
|
||||||
@@ -155,16 +155,10 @@ void move_window(Window win, int from_x, int from_y, int to_x, int to_y)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y)
|
|
||||||
{
|
|
||||||
Window *wins[1] = { &win };
|
|
||||||
SlideWindows(wins, 1, from_x, from_y, to_x, to_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wins is an array of Window, sorted from left to right, the first is
|
/* wins is an array of Window, sorted from left to right, the first is
|
||||||
* going to be moved from (from_x,from_y) to (to_x,to_y) and the
|
* going to be moved from (from_x,from_y) to (to_x,to_y) and the
|
||||||
* following windows are going to be offset by (ICON_SIZE*i,0) */
|
* following windows are going to be offset by (ICON_SIZE*i,0) */
|
||||||
void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int to_y)
|
void slide_windows(Window wins[], int n, int from_x, int from_y, int to_x, int to_y)
|
||||||
{
|
{
|
||||||
time_t time0 = time(NULL);
|
time_t time0 = time(NULL);
|
||||||
float dx, dy, x = from_x, y = from_y, px, py;
|
float dx, dy, x = from_x, y = from_y, px, py;
|
||||||
@@ -243,7 +237,7 @@ void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int t
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
XMoveWindow(dpy, *wins[i], (int)x + i * ICON_SIZE, (int)y);
|
XMoveWindow(dpy, wins[i], (int)x + i * ICON_SIZE, (int)y);
|
||||||
}
|
}
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
if (slide_delay > 0) {
|
if (slide_delay > 0) {
|
||||||
@@ -255,7 +249,7 @@ void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int t
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
XMoveWindow(dpy, *wins[i], to_x + i * ICON_SIZE, to_y);
|
XMoveWindow(dpy, wins[i], to_x + i * ICON_SIZE, to_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
XSync(dpy, 0);
|
XSync(dpy, 0);
|
||||||
|
|||||||
@@ -30,10 +30,14 @@ Bool wGetIconName(Display *dpy, Window win, char **iconname);
|
|||||||
Bool UpdateDomainFile(WDDomain * domain);
|
Bool UpdateDomainFile(WDDomain * domain);
|
||||||
|
|
||||||
void move_window(Window win, int from_x, int from_y, int to_x, int to_y);
|
void move_window(Window win, int from_x, int from_y, int to_x, int to_y);
|
||||||
void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y);
|
void slide_windows(Window wins[], int n, int from_x, int from_y, int to_x, int to_y);
|
||||||
void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int to_y);
|
|
||||||
void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where);
|
void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where);
|
||||||
|
|
||||||
|
static inline void slide_window(Window win, int from_x, int from_y, int to_x, int to_y)
|
||||||
|
{
|
||||||
|
slide_windows(&win, 1, from_x, from_y, to_x, to_y);
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper is a 'wmsetbg' subprocess with sets the background for the current workspace */
|
/* Helper is a 'wmsetbg' subprocess with sets the background for the current workspace */
|
||||||
Bool start_bg_helper(WScreen *scr);
|
Bool start_bg_helper(WScreen *scr);
|
||||||
void SendHelperMessage(WScreen *scr, char type, int workspace, const char *msg);
|
void SendHelperMessage(WScreen *scr, char type, int workspace, const char *msg);
|
||||||
|
|||||||
@@ -96,17 +96,17 @@ void wWorkspaceMapUpdate(WScreen *scr)
|
|||||||
static void workspace_map_slide(WWorkspaceMap *wsmap)
|
static void workspace_map_slide(WWorkspaceMap *wsmap)
|
||||||
{
|
{
|
||||||
if (wsmap->edge == WD_TOP)
|
if (wsmap->edge == WD_TOP)
|
||||||
SlideWindow(WMWidgetXID(wsmap->win), 0, -1 * wsmap->wsheight, wsmap->xcount, wsmap->ycount);
|
slide_window(WMWidgetXID(wsmap->win), 0, -1 * wsmap->wsheight, wsmap->xcount, wsmap->ycount);
|
||||||
else
|
else
|
||||||
SlideWindow(WMWidgetXID(wsmap->win), 0, wsmap->scr->scr_height, wsmap->xcount, wsmap->ycount);
|
slide_window(WMWidgetXID(wsmap->win), 0, wsmap->scr->scr_height, wsmap->xcount, wsmap->ycount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void workspace_map_unslide(WWorkspaceMap *wsmap)
|
static void workspace_map_unslide(WWorkspaceMap *wsmap)
|
||||||
{
|
{
|
||||||
if (wsmap->edge == WD_TOP)
|
if (wsmap->edge == WD_TOP)
|
||||||
SlideWindow(WMWidgetXID(wsmap->win), wsmap->xcount, wsmap->ycount, 0, -1 * wsmap->wsheight);
|
slide_window(WMWidgetXID(wsmap->win), wsmap->xcount, wsmap->ycount, 0, -1 * wsmap->wsheight);
|
||||||
else
|
else
|
||||||
SlideWindow(WMWidgetXID(wsmap->win), wsmap->xcount, wsmap->ycount, 0, wsmap->scr->scr_height);
|
slide_window(WMWidgetXID(wsmap->win), wsmap->xcount, wsmap->ycount, 0, wsmap->scr->scr_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void workspace_map_destroy(WWorkspaceMap *wsmap)
|
static void workspace_map_destroy(WWorkspaceMap *wsmap)
|
||||||
|
|||||||
Reference in New Issue
Block a user