1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

wmaker: update src/action.c coding style

This patch is updating the coding style based on checkpatch output
and as suggested by Rodolfo it also inverts the condition test
in getAnimationGeometry fct to return earlier when possible.
This commit is contained in:
David Maciejak
2014-08-25 11:42:39 +07:00
committed by Carlos R. Mafra
parent 9cb4388180
commit 556b0d77a1

View File

@@ -4,6 +4,7 @@
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
* Copyright (c) 1998-2003 Dan Pascu
* Copyright (c) 2014 Window Maker Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -60,12 +61,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 +85,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
@@ -391,9 +393,8 @@ void wMaximizeWindow(WWindow *wwin, int directions)
/* Only save directions, not kbd or xinerama hints */
directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
if (WFLAGP(wwin, full_maximize)) {
if (WFLAGP(wwin, full_maximize))
usableArea = totalArea;
}
half_scr_width = (usableArea.x2 - usableArea.x1)/2;
half_scr_height = (usableArea.y2 - usableArea.y1)/2;
@@ -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 */
@@ -665,7 +665,7 @@ static void find_Maximus_geometry(WWindow *wwin, WArea usableArea, int *new_x, i
*new_x = new.left;
*new_y = new.top;
/* xcalc needs -7 here, but other apps don't */
*new_height = new.bottom - new.top - adjust_height - 1;;
*new_height = new.bottom - new.top - adjust_height - 1;
*new_width = new.right - new.left;
}
@@ -735,11 +735,10 @@ void wUnfullscreenWindow(WWindow *wwin)
wwin->flags.fullscreen = False;
if (WFLAGP(wwin, sunken)) {
if (WFLAGP(wwin, sunken))
ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
} else if (WFLAGP(wwin, floating)) {
else if (WFLAGP(wwin, floating))
ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
}
wWindowConfigure(wwin, wwin->bfs_geometry.x, wwin->bfs_geometry.y,
wwin->bfs_geometry.width, wwin->bfs_geometry.height);
@@ -926,15 +925,13 @@ static void animateResizeZoom(WScreen *scr, int x, int y, int w, int h, int fx,
}
}
for (j = 0; j < FRAMES; j++) {
for (j = 0; j < FRAMES; j++)
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
}
XFlush(dpy);
wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
for (j = 0; j < FRAMES; j++) {
for (j = 0; j < FRAMES; j++)
XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
}
XUngrabServer(dpy);
}
@@ -949,9 +946,8 @@ void animateResize(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int
if (style == WIS_NONE)
return;
if (style == WIS_RANDOM) {
if (style == WIS_RANDOM)
style = rand() % 3;
}
switch (style) {
case WIS_TWIST:
@@ -994,11 +990,10 @@ static void unmapTransientsFor(WWindow *wwin)
&& (tmp->flags.mapped || wwin->screen_ptr->flags.startup || tmp->flags.shaded)) {
unmapTransientsFor(tmp);
tmp->flags.miniaturized = 1;
if (!tmp->flags.shaded) {
if (!tmp->flags.shaded)
wWindowUnmap(tmp);
} else {
else
XUnmapWindow(dpy, tmp->frame->core->window);
}
/*
if (!tmp->flags.shaded)
*/
@@ -1021,11 +1016,10 @@ static void mapTransientsFor(WWindow *wwin)
&& tmp->icon == NULL) {
mapTransientsFor(tmp);
tmp->flags.miniaturized = 0;
if (!tmp->flags.shaded) {
if (!tmp->flags.shaded)
wWindowMap(tmp);
} else {
else
XMapWindow(dpy, tmp->frame->core->window);
}
tmp->flags.semi_focused = 0;
/*
if (!tmp->flags.shaded)
@@ -1062,10 +1056,11 @@ static WWindow *recursiveTransientFor(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) {
if (wwin->screen_ptr->flags.startup || wPreferences.no_animations
|| wwin->flags.skip_next_animation || wwin->icon == NULL)
return 0;
if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
*ix = wwin->icon_x;
*iy = wwin->icon_y;
*iw = wwin->icon->core->width;
@@ -1085,8 +1080,6 @@ static int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *i
}
return 1;
}
return 0;
}
void wIconifyWindow(WWindow *wwin)
{
@@ -1181,10 +1174,9 @@ void wIconifyWindow(WWindow * wwin)
flushExpose();
#ifdef ANIMATIONS
if (getAnimationGeometry(wwin, &ix, &iy, &iw, &ih)) {
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);
}
#endif
}
@@ -1231,10 +1223,9 @@ void wIconifyWindow(WWindow * wwin)
ProcessPendingEvents();
/* the window can disappear while ProcessPendingEvents() runs */
if (!wWindowFor(clientwin)) {
if (!wWindowFor(clientwin))
return;
}
}
#endif
}
@@ -1302,11 +1293,10 @@ void wDeiconifyWindow(WWindow *wwin)
if (!netwm_hidden) {
#ifdef ANIMATIONS
int ix, iy, iw, ih;
if (getAnimationGeometry(wwin, &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
wwin->flags.skip_next_animation = 0;
XGrabServer(dpy);
@@ -1375,9 +1365,8 @@ static void hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int a
return;
}
if (wwin->flags.inspector_open) {
if (wwin->flags.inspector_open)
wHideInspectorForWindow(wwin);
}
wwin->flags.hidden = 1;
wWindowUnmap(wwin);
@@ -1517,9 +1506,8 @@ void wHideApplication(WApplication *wapp)
while (wlist) {
if (wlist->main_window == wapp->main_window) {
if (wlist->flags.focused) {
if (wlist->flags.focused)
hadfocus = 1;
}
if (wapp->app_icon) {
hideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
wapp->app_icon->y_pos, wlist, animate);
@@ -1580,9 +1568,8 @@ static void unhideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int
wwin->flags.mapped = 1;
wRaiseFrame(wwin->frame->core);
}
if (wwin->flags.inspector_open) {
if (wwin->flags.inspector_open)
wUnhideInspectorForWindow(wwin);
}
WMPostNotificationName(WMNChangedState, wwin, "hide");
}
@@ -1624,9 +1611,8 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
int x, y;
PlaceIcon(scr, &x, &y, wGetHeadForWindow(wlist));
if (wlist->icon_x != x || wlist->icon_y != y) {
if (wlist->icon_x != x || wlist->icon_y != y)
XMoveWindow(dpy, wlist->icon->core->window, x, y);
}
wlist->icon_x = x;
wlist->icon_y = y;
XMapWindow(dpy, wlist->icon->core->window);
@@ -1637,9 +1623,8 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
if (bringToCurrentWS)
wWindowChangeWorkspace(wlist, w_global.workspace.current);
wlist->flags.hidden = 0;
if (miniwindows && wlist->frame->workspace == w_global.workspace.current) {
if (miniwindows && wlist->frame->workspace == w_global.workspace.current)
wDeiconifyWindow(wlist);
}
WMPostNotificationName(WMNChangedState, wlist, "hide");
} else if (wlist->flags.shaded) {
if (bringToCurrentWS)
@@ -1648,10 +1633,9 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
wRaiseFrame(wlist->frame->core);
if (wlist->frame->workspace == w_global.workspace.current) {
XMapWindow(dpy, wlist->frame->core->window);
if (miniwindows) {
if (miniwindows)
wUnshadeWindow(wlist);
}
}
WMPostNotificationName(WMNChangedState, wlist, "hide");
} else if (wlist->flags.hidden) {
unhideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
@@ -1867,9 +1851,8 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll)
}
}
}
if (arrangeAll) {
if (arrangeAll)
wwin->flags.icon_moved = 0;
}
/* we reversed the order, so we use next */
wwin = wwin->next;
}
@@ -1888,9 +1871,8 @@ void wSelectWindow(WWindow *wwin, Bool flag)
else
XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel);
if (!HAS_BORDER(wwin)) {
if (!HAS_BORDER(wwin))
XSetWindowBorderWidth(dpy, wwin->frame->core->window, wwin->screen_ptr->frame_border_width);
}
if (!scr->selected_windows)
scr->selected_windows = WMCreateArray(4);
@@ -1909,15 +1891,13 @@ void wSelectWindow(WWindow *wwin, Bool flag)
XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_border_pixel);
}
if (!HAS_BORDER(wwin)) {
if (!HAS_BORDER(wwin))
XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0);
}
if (scr->selected_windows) {
if (scr->selected_windows)
WMRemoveFromArray(scr->selected_windows, wwin);
}
}
}
void wMakeWindowVisible(WWindow *wwin)
{
@@ -1977,11 +1957,10 @@ static void shade_animate(WWindow *wwin, Bool what)
if (time(NULL) - time0 > MAX_ANIMATION_TIME)
break;
if (SHADE_DELAY > 0) {
if (SHADE_DELAY > 0)
wusleep(SHADE_DELAY * 1000L);
} else {
else
wusleep(10);
}
h -= s;
y -= s;
}
@@ -2002,11 +1981,10 @@ static void shade_animate(WWindow *wwin, Bool what)
XResizeWindow(dpy, wwin->frame->core->window, w, h);
XMoveWindow(dpy, wwin->client_win, 0, y);
XFlush(dpy);
if (SHADE_DELAY > 0) {
if (SHADE_DELAY > 0)
wusleep(SHADE_DELAY * 2000L / 3);
} else {
else
wusleep(10);
}
h += s;
y += s;