From 42cb1291e3b86921a0e381dac64abd8a80019b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Fri, 22 Jun 2012 17:35:03 +0200 Subject: [PATCH] New move_window function --- src/actions.c | 18 ++++-------------- src/dock.c | 15 +++------------ src/funcs.h | 1 + src/misc.c | 12 ++++++++++++ 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/actions.c b/src/actions.c index 9617fb5c..16d93a6e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1767,9 +1767,8 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll) if (aicon->x_pos != X || aicon->y_pos != Y) { #ifdef ANIMATIONS - if (!wPreferences.no_animations) { + if (!wPreferences.no_animations) SlideWindow(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, X, Y); - } #endif /* ANIMATIONS */ } wAppIconMove(aicon, X, Y); @@ -1796,18 +1795,9 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll) head = wGetHeadForWindow(wwin); if (arrangeAll || !wwin->flags.icon_moved) { - if (wwin->icon_x != X || wwin->icon_y != Y) { -#ifdef ANIMATIONS - if (wPreferences.no_animations) { - XMoveWindow(dpy, wwin->icon->core->window, X, Y); - } else { - SlideWindow(wwin->icon->core->window, wwin->icon_x, - wwin->icon_y, X, Y); - } -#else - XMoveWindow(dpy, wwin->icon->core->window, X, Y); -#endif /* ANIMATIONS */ - } + if (wwin->icon_x != X || wwin->icon_y != Y) + move_window(wwin->icon->core->window, wwin->icon_x, wwin->icon_y, X, Y); + wwin->icon_x = X; wwin->icon_y = Y; diff --git a/src/dock.c b/src/dock.c index d5d5003f..05824d47 100644 --- a/src/dock.c +++ b/src/dock.c @@ -592,18 +592,9 @@ static void colectIconsCallback(WMenu *menu, WMenuEntry *entry) if (!aicon->docked && wDockFindFreeSlot(clip, &x, &y)) { x_pos = clip->x_pos + x * ICON_SIZE; y_pos = clip->y_pos + y * ICON_SIZE; - if (aicon->x_pos != x_pos || aicon->y_pos != y_pos) { -#ifdef ANIMATIONS - if (wPreferences.no_animations) { - XMoveWindow(dpy, aicon->icon->core->window, x_pos, y_pos); - } else { - SlideWindow(aicon->icon->core->window, - aicon->x_pos, aicon->y_pos, x_pos, y_pos); - } -#else - XMoveWindow(dpy, aicon->icon->core->window, x_pos, y_pos); -#endif /* ANIMATIONS */ - } + if (aicon->x_pos != x_pos || aicon->y_pos != y_pos) + move_window(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, x_pos, y_pos); + aicon->attracted = 1; if (!aicon->icon->shadowed) { aicon->icon->shadowed = 1; diff --git a/src/funcs.h b/src/funcs.h index ff6ee6c2..65ceb4a7 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -85,6 +85,7 @@ Bool UpdateDomainFile(WDDomain *domain); WWindow * NextToFocusAfter(WWindow *wwin); WWindow * NextToFocusBefore(WWindow *wwin); +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); RImage * wGetImageForWindowName(WScreen *scr, char *winstance, char *wclass); diff --git a/src/misc.c b/src/misc.c index 389ad00c..3353a632 100644 --- a/src/misc.c +++ b/src/misc.c @@ -247,6 +247,18 @@ static void eatExpose(void) } } +void move_window(Window win, int from_x, int from_y, int to_x, int to_y) +{ +#ifdef ANIMATIONS + if (wPreferences.no_animations) + XMoveWindow(dpy, win, to_x, to_y); + else + SlideWindow(win, from_x, from_y, to_x, to_y); +#else + XMoveWindow(dpy, win, to_x, to_y); +#endif +} + void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y) { time_t time0 = time(NULL);