This patch is merging some duplicate code related to animation position (I also fixed most of the errors reported by checkpatch).
---
src/actions.c | 110 ++++++++++++++++++++++++++--------------------------------
1 file changed, 50 insertions(+), 60 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index ae326a1..8a5ff82 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -60,12 +60,12 @@ static struct {
int steps;
int delay;
} shadePars[5] = {
- {
- SHADE_STEPS_UF, SHADE_DELAY_UF}, {
- SHADE_STEPS_F, SHADE_DELAY_F}, {
- SHADE_STEPS_M, SHADE_DELAY_M}, {
- SHADE_STEPS_S, SHADE_DELAY_S}, {
-SHADE_STEPS_US, SHADE_DELAY_US}};
+ { SHADE_STEPS_UF, SHADE_DELAY_UF },
+ { SHADE_STEPS_F, SHADE_DELAY_F },
+ { SHADE_STEPS_M, SHADE_DELAY_M },
+ { SHADE_STEPS_S, SHADE_DELAY_S },
+ { SHADE_STEPS_US, SHADE_DELAY_US }
+};
#define UNSHADE 0
#define SHADE 1
@@ -84,7 +84,8 @@ static int compareTimes(Time t1, Time t2)
#ifdef ANIMATIONS
static void shade_animate(WWindow *wwin, Bool what);
#else
-static inline void shade_animate(WWindow *wwin, Bool what) {
+static inline void shade_animate(WWindow *wwin, Bool what)
+{
/*
* This function is empty on purpose, so tell the compiler
* to not warn about parameters being not used
@@ -291,9 +292,9 @@ void wUnshadeWindow(WWindow *wwin)
static void save_old_geometry(WWindow *wwin, int directions)
{
/* never been saved? */
- if (! wwin->old_geometry.width)
+ if (!wwin->old_geometry.width)
directions |= SAVE_GEOMETRY_X | SAVE_GEOMETRY_WIDTH;
- if (! wwin->old_geometry.height)
+ if (!wwin->old_geometry.height)
directions |= SAVE_GEOMETRY_Y | SAVE_GEOMETRY_HEIGHT;
if (directions & SAVE_GEOMETRY_X)
@@ -584,8 +585,7 @@ static void find_Maximus_geometry(WWindow *wwin,
WArea usableArea, int *new_x, i
remember_geometry(wwin, &orig.left, &orig.top, &orig.width, &orig.height);
orig.bottom = orig.top + orig.height;
orig.right = orig.left + orig.width;
- }
- else
+ } else
set_window_coords(wwin, &orig);
/* Try to fully maximize first, then readjust later */
@@ -862,6 +862,7 @@ animateResizeTwist(WScreen *scr, int x, int y, int
w, int h, int fx, int fy, int
points[3].y = cy + sin(angle + a + WM_PI) * d;
points[4].x = cx + cos(angle - a) * d;
points[4].y = cy + sin(angle - a) * d;
+
XGrabServer(dpy);
XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
XFlush(dpy);
@@ -1038,7 +1039,7 @@ static void mapTransientsFor(WWindow *wwin)
}
}
-static WWindow *recursiveTransientFor(WWindow * wwin)
+static WWindow *recursiveTransientFor(WWindow *wwin)
{
int i;
@@ -1060,7 +1061,35 @@ static WWindow *recursiveTransientFor(WWindow * wwin)
return wwin;
}
-void wIconifyWindow(WWindow * wwin)
+static int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int
*iw, int *ih)
+{
+ if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations
+ && !wwin->flags.skip_next_animation && wwin->icon != NULL) {
+ if (!wPreferences.disable_miniwindows
+ && !wwin->flags.net_handle_icon) {
+ *ix = wwin->icon_x;
+ *iy = wwin->icon_y;
+ *iw = wwin->icon->core->width;
+ *ih = wwin->icon->core->height;
+ } else {
+ if (wwin->flags.net_handle_icon) {
+ *ix = wwin->icon_x;
+ *iy = wwin->icon_y;
+ *iw = wwin->icon_w;
+ *ih = wwin->icon_h;
+ } else {
+ *ix = 0;
+ *iy = 0;
+ *iw = wwin->screen_ptr->scr_width;
+ *ih = wwin->screen_ptr->scr_height;
+ }
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void wIconifyWindow(WWindow *wwin)
{
XWindowAttributes attribs;
int present;
@@ -1137,6 +1166,9 @@ void wIconifyWindow(WWindow * wwin)
unmapTransientsFor(wwin);
if (present) {
+#ifdef ANIMATIONS
+ int ix, iy, iw, ih;
+#endif
XUngrabPointer(dpy, CurrentTime);
wWindowUnmap(wwin);
/* let all Expose events arrive so that we can repaint
@@ -1150,28 +1182,7 @@ void wIconifyWindow(WWindow * wwin)
flushExpose();
#ifdef ANIMATIONS
- if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation
- && !wPreferences.no_animations) {
- int ix, iy, iw, ih;
-
- if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
- ix = wwin->icon_x;
- iy = wwin->icon_y;
- iw = wwin->icon->core->width;
- ih = wwin->icon->core->height;
- } else {
- if (wwin->flags.net_handle_icon) {
- ix = wwin->icon_x;
- iy = wwin->icon_y;
- iw = wwin->icon_w;
- ih = wwin->icon_h;
- } else {
- ix = 0;
- iy = 0;
- iw = wwin->screen_ptr->scr_width;
- ih = wwin->screen_ptr->scr_height;
- }
- }
+ if (getAnimationGeometry(wwin, &ix, &iy, &iw, &ih)) {
animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y,
wwin->frame->core->width, wwin->frame->core->height, ix, iy, iw, ih);
}
@@ -1291,34 +1302,13 @@ void wDeiconifyWindow(WWindow *wwin)
/* if the window is in another workspace, do it silently */
if (!netwm_hidden) {
#ifdef ANIMATIONS
- if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations
- && !wwin->flags.skip_next_animation && wwin->icon != NULL) {
- int ix, iy, iw, ih;
-
- if (!wPreferences.disable_miniwindows
- && !wwin->flags.net_handle_icon) {
- ix = wwin->icon_x;
- iy = wwin->icon_y;
- iw = wwin->icon->core->width;
- ih = wwin->icon->core->height;
- } else {
- if (wwin->flags.net_handle_icon) {
- ix = wwin->icon_x;
- iy = wwin->icon_y;
- iw = wwin->icon_w;
- ih = wwin->icon_h;
- } else {
- ix = 0;
- iy = 0;
- iw = wwin->screen_ptr->scr_width;
- ih = wwin->screen_ptr->scr_height;
- }
- }
+ int ix, iy, iw, ih;
+ if (getAnimationGeometry(wwin, &ix, &iy, &iw, &ih)) {
animateResize(wwin->screen_ptr, ix, iy, iw, ih,
wwin->frame_x, wwin->frame_y,
wwin->frame->core->width, wwin->frame->core->height);
}
-#endif /* ANIMATIONS */
+#endif
wwin->flags.skip_next_animation = 0;
XGrabServer(dpy);
if (!wwin->flags.shaded)
@@ -1970,7 +1960,7 @@ static void shade_animate(WWindow *wwin, Bool what)
if (wwin->flags.skip_next_animation || wPreferences.no_animations)
return;
- switch(what) {
+ switch (what) {
case SHADE:
if (!wwin->screen_ptr->flags.startup) {
/* do the shading animation */
--
1.8.3.2
0001-wmaker-src-action.c-merge-duplicate-code.patch
Description: Binary data
