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) 1997-2003 Alfredo K. Kojima
* Copyright (c) 1998-2003 Dan Pascu * Copyright (c) 1998-2003 Dan Pascu
* Copyright (c) 2014 Window Maker Team
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -60,12 +61,12 @@ static struct {
int steps; int steps;
int delay; int delay;
} shadePars[5] = { } shadePars[5] = {
{ { SHADE_STEPS_UF, SHADE_DELAY_UF },
SHADE_STEPS_UF, SHADE_DELAY_UF}, { { SHADE_STEPS_F, SHADE_DELAY_F },
SHADE_STEPS_F, SHADE_DELAY_F}, { { SHADE_STEPS_M, SHADE_DELAY_M },
SHADE_STEPS_M, SHADE_DELAY_M}, { { SHADE_STEPS_S, SHADE_DELAY_S },
SHADE_STEPS_S, SHADE_DELAY_S}, { { SHADE_STEPS_US, SHADE_DELAY_US }
SHADE_STEPS_US, SHADE_DELAY_US}}; };
#define UNSHADE 0 #define UNSHADE 0
#define SHADE 1 #define SHADE 1
@@ -84,7 +85,8 @@ static int compareTimes(Time t1, Time t2)
#ifdef ANIMATIONS #ifdef ANIMATIONS
static void shade_animate(WWindow *wwin, Bool what); static void shade_animate(WWindow *wwin, Bool what);
#else #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 * This function is empty on purpose, so tell the compiler
* to not warn about parameters being not used * to not warn about parameters being not used
@@ -97,13 +99,13 @@ static inline void shade_animate(WWindow *wwin, Bool what) {
/* /*
*---------------------------------------------------------------------- *----------------------------------------------------------------------
* wSetFocusTo-- * wSetFocusTo--
* Changes the window focus to the one passed as argument. * Changes the window focus to the one passed as argument.
* If the window to focus is not already focused, it will be brought * If the window to focus is not already focused, it will be brought
* to the head of the list of windows. Previously focused window is * to the head of the list of windows. Previously focused window is
* unfocused. * unfocused.
* *
* Side effects: * Side effects:
* Window list may be reordered and the window focus is changed. * Window list may be reordered and the window focus is changed.
* *
*---------------------------------------------------------------------- *----------------------------------------------------------------------
*/ */
@@ -291,9 +293,9 @@ void wUnshadeWindow(WWindow *wwin)
static void save_old_geometry(WWindow *wwin, int directions) static void save_old_geometry(WWindow *wwin, int directions)
{ {
/* never been saved? */ /* never been saved? */
if (! wwin->old_geometry.width) if (!wwin->old_geometry.width)
directions |= SAVE_GEOMETRY_X | SAVE_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; directions |= SAVE_GEOMETRY_Y | SAVE_GEOMETRY_HEIGHT;
if (directions & SAVE_GEOMETRY_X) if (directions & SAVE_GEOMETRY_X)
@@ -391,9 +393,8 @@ void wMaximizeWindow(WWindow *wwin, int directions)
/* Only save directions, not kbd or xinerama hints */ /* Only save directions, not kbd or xinerama hints */
directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS); 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; usableArea = totalArea;
}
half_scr_width = (usableArea.x2 - usableArea.x1)/2; half_scr_width = (usableArea.x2 - usableArea.x1)/2;
half_scr_height = (usableArea.y2 - usableArea.y1)/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); remember_geometry(wwin, &orig.left, &orig.top, &orig.width, &orig.height);
orig.bottom = orig.top + orig.height; orig.bottom = orig.top + orig.height;
orig.right = orig.left + orig.width; orig.right = orig.left + orig.width;
} } else
else
set_window_coords(wwin, &orig); set_window_coords(wwin, &orig);
/* Try to fully maximize first, then readjust later */ /* 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_x = new.left;
*new_y = new.top; *new_y = new.top;
/* xcalc needs -7 here, but other apps don't */ /* 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; *new_width = new.right - new.left;
} }
@@ -735,11 +735,10 @@ void wUnfullscreenWindow(WWindow *wwin)
wwin->flags.fullscreen = False; wwin->flags.fullscreen = False;
if (WFLAGP(wwin, sunken)) { if (WFLAGP(wwin, sunken))
ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
} else if (WFLAGP(wwin, floating)) { else if (WFLAGP(wwin, floating))
ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
}
wWindowConfigure(wwin, wwin->bfs_geometry.x, wwin->bfs_geometry.y, wWindowConfigure(wwin, wwin->bfs_geometry.x, wwin->bfs_geometry.y,
wwin->bfs_geometry.width, wwin->bfs_geometry.height); 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]); XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
}
XFlush(dpy); XFlush(dpy);
wusleep(MINIATURIZE_ANIMATION_DELAY_Z); 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]); XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
}
XUngrabServer(dpy); 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) if (style == WIS_NONE)
return; return;
if (style == WIS_RANDOM) { if (style == WIS_RANDOM)
style = rand() % 3; style = rand() % 3;
}
switch (style) { switch (style) {
case WIS_TWIST: case WIS_TWIST:
@@ -994,11 +990,10 @@ static void unmapTransientsFor(WWindow *wwin)
&& (tmp->flags.mapped || wwin->screen_ptr->flags.startup || tmp->flags.shaded)) { && (tmp->flags.mapped || wwin->screen_ptr->flags.startup || tmp->flags.shaded)) {
unmapTransientsFor(tmp); unmapTransientsFor(tmp);
tmp->flags.miniaturized = 1; tmp->flags.miniaturized = 1;
if (!tmp->flags.shaded) { if (!tmp->flags.shaded)
wWindowUnmap(tmp); wWindowUnmap(tmp);
} else { else
XUnmapWindow(dpy, tmp->frame->core->window); XUnmapWindow(dpy, tmp->frame->core->window);
}
/* /*
if (!tmp->flags.shaded) if (!tmp->flags.shaded)
*/ */
@@ -1021,11 +1016,10 @@ static void mapTransientsFor(WWindow *wwin)
&& tmp->icon == NULL) { && tmp->icon == NULL) {
mapTransientsFor(tmp); mapTransientsFor(tmp);
tmp->flags.miniaturized = 0; tmp->flags.miniaturized = 0;
if (!tmp->flags.shaded) { if (!tmp->flags.shaded)
wWindowMap(tmp); wWindowMap(tmp);
} else { else
XMapWindow(dpy, tmp->frame->core->window); XMapWindow(dpy, tmp->frame->core->window);
}
tmp->flags.semi_focused = 0; tmp->flags.semi_focused = 0;
/* /*
if (!tmp->flags.shaded) if (!tmp->flags.shaded)
@@ -1038,7 +1032,7 @@ static void mapTransientsFor(WWindow *wwin)
} }
} }
static WWindow *recursiveTransientFor(WWindow * wwin) static WWindow *recursiveTransientFor(WWindow *wwin)
{ {
int i; int i;
@@ -1062,33 +1056,32 @@ static WWindow *recursiveTransientFor(WWindow * wwin)
static int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *ih) static int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *ih)
{ {
if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations if (wwin->screen_ptr->flags.startup || wPreferences.no_animations
&& !wwin->flags.skip_next_animation && wwin->icon != NULL) { || wwin->flags.skip_next_animation || wwin->icon == NULL)
if (!wPreferences.disable_miniwindows return 0;
&& !wwin->flags.net_handle_icon) {
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; *ix = wwin->icon_x;
*iy = wwin->icon_y; *iy = wwin->icon_y;
*iw = wwin->icon->core->width; *iw = wwin->icon_w;
*ih = wwin->icon->core->height; *ih = wwin->icon_h;
} else { } else {
if (wwin->flags.net_handle_icon) { *ix = 0;
*ix = wwin->icon_x; *iy = 0;
*iy = wwin->icon_y; *iw = wwin->screen_ptr->scr_width;
*iw = wwin->icon_w; *ih = wwin->screen_ptr->scr_height;
*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; return 1;
} }
void wIconifyWindow(WWindow * wwin) void wIconifyWindow(WWindow *wwin)
{ {
XWindowAttributes attribs; XWindowAttributes attribs;
int present; int present;
@@ -1181,10 +1174,9 @@ void wIconifyWindow(WWindow * wwin)
flushExpose(); flushExpose();
#ifdef ANIMATIONS #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, animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y,
wwin->frame->core->width, wwin->frame->core->height, ix, iy, iw, ih); wwin->frame->core->width, wwin->frame->core->height, ix, iy, iw, ih);
}
#endif #endif
} }
@@ -1231,9 +1223,8 @@ void wIconifyWindow(WWindow * wwin)
ProcessPendingEvents(); ProcessPendingEvents();
/* the window can disappear while ProcessPendingEvents() runs */ /* the window can disappear while ProcessPendingEvents() runs */
if (!wWindowFor(clientwin)) { if (!wWindowFor(clientwin))
return; return;
}
} }
#endif #endif
} }
@@ -1302,11 +1293,10 @@ void wDeiconifyWindow(WWindow *wwin)
if (!netwm_hidden) { if (!netwm_hidden) {
#ifdef ANIMATIONS #ifdef ANIMATIONS
int ix, iy, iw, ih; 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, animateResize(wwin->screen_ptr, ix, iy, iw, ih,
wwin->frame_x, wwin->frame_y, wwin->frame_x, wwin->frame_y,
wwin->frame->core->width, wwin->frame->core->height); wwin->frame->core->width, wwin->frame->core->height);
}
#endif #endif
wwin->flags.skip_next_animation = 0; wwin->flags.skip_next_animation = 0;
XGrabServer(dpy); XGrabServer(dpy);
@@ -1375,9 +1365,8 @@ static void hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int a
return; return;
} }
if (wwin->flags.inspector_open) { if (wwin->flags.inspector_open)
wHideInspectorForWindow(wwin); wHideInspectorForWindow(wwin);
}
wwin->flags.hidden = 1; wwin->flags.hidden = 1;
wWindowUnmap(wwin); wWindowUnmap(wwin);
@@ -1517,9 +1506,8 @@ void wHideApplication(WApplication *wapp)
while (wlist) { while (wlist) {
if (wlist->main_window == wapp->main_window) { if (wlist->main_window == wapp->main_window) {
if (wlist->flags.focused) { if (wlist->flags.focused)
hadfocus = 1; hadfocus = 1;
}
if (wapp->app_icon) { if (wapp->app_icon) {
hideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos, hideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
wapp->app_icon->y_pos, wlist, animate); 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; wwin->flags.mapped = 1;
wRaiseFrame(wwin->frame->core); wRaiseFrame(wwin->frame->core);
} }
if (wwin->flags.inspector_open) { if (wwin->flags.inspector_open)
wUnhideInspectorForWindow(wwin); wUnhideInspectorForWindow(wwin);
}
WMPostNotificationName(WMNChangedState, wwin, "hide"); WMPostNotificationName(WMNChangedState, wwin, "hide");
} }
@@ -1624,9 +1611,8 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
int x, y; int x, y;
PlaceIcon(scr, &x, &y, wGetHeadForWindow(wlist)); 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); XMoveWindow(dpy, wlist->icon->core->window, x, y);
}
wlist->icon_x = x; wlist->icon_x = x;
wlist->icon_y = y; wlist->icon_y = y;
XMapWindow(dpy, wlist->icon->core->window); XMapWindow(dpy, wlist->icon->core->window);
@@ -1637,9 +1623,8 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
if (bringToCurrentWS) if (bringToCurrentWS)
wWindowChangeWorkspace(wlist, w_global.workspace.current); wWindowChangeWorkspace(wlist, w_global.workspace.current);
wlist->flags.hidden = 0; wlist->flags.hidden = 0;
if (miniwindows && wlist->frame->workspace == w_global.workspace.current) { if (miniwindows && wlist->frame->workspace == w_global.workspace.current)
wDeiconifyWindow(wlist); wDeiconifyWindow(wlist);
}
WMPostNotificationName(WMNChangedState, wlist, "hide"); WMPostNotificationName(WMNChangedState, wlist, "hide");
} else if (wlist->flags.shaded) { } else if (wlist->flags.shaded) {
if (bringToCurrentWS) if (bringToCurrentWS)
@@ -1648,9 +1633,8 @@ void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurren
wRaiseFrame(wlist->frame->core); wRaiseFrame(wlist->frame->core);
if (wlist->frame->workspace == w_global.workspace.current) { if (wlist->frame->workspace == w_global.workspace.current) {
XMapWindow(dpy, wlist->frame->core->window); XMapWindow(dpy, wlist->frame->core->window);
if (miniwindows) { if (miniwindows)
wUnshadeWindow(wlist); wUnshadeWindow(wlist);
}
} }
WMPostNotificationName(WMNChangedState, wlist, "hide"); WMPostNotificationName(WMNChangedState, wlist, "hide");
} else if (wlist->flags.hidden) { } else if (wlist->flags.hidden) {
@@ -1804,12 +1788,12 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll)
} }
#define X ((wPreferences.icon_yard & IY_VERT) \ #define X ((wPreferences.icon_yard & IY_VERT) \
? vars[head].xo + vars[head].xs*(vars[head].si*isize) \ ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
: vars[head].xo + vars[head].xs*(vars[head].pi*isize)) : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
#define Y ((wPreferences.icon_yard & IY_VERT) \ #define Y ((wPreferences.icon_yard & IY_VERT) \
? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \ ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
: vars[head].yo + vars[head].ys*(vars[head].si*isize)) : vars[head].yo + vars[head].ys*(vars[head].si*isize))
/* arrange application icons */ /* arrange application icons */
aicon = w_global.app_icon_list; aicon = w_global.app_icon_list;
@@ -1867,9 +1851,8 @@ void wArrangeIcons(WScreen *scr, Bool arrangeAll)
} }
} }
} }
if (arrangeAll) { if (arrangeAll)
wwin->flags.icon_moved = 0; wwin->flags.icon_moved = 0;
}
/* we reversed the order, so we use next */ /* we reversed the order, so we use next */
wwin = wwin->next; wwin = wwin->next;
} }
@@ -1888,9 +1871,8 @@ void wSelectWindow(WWindow *wwin, Bool flag)
else else
XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel); 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); XSetWindowBorderWidth(dpy, wwin->frame->core->window, wwin->screen_ptr->frame_border_width);
}
if (!scr->selected_windows) if (!scr->selected_windows)
scr->selected_windows = WMCreateArray(4); scr->selected_windows = WMCreateArray(4);
@@ -1909,13 +1891,11 @@ void wSelectWindow(WWindow *wwin, Bool flag)
XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_border_pixel); 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); XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0);
}
if (scr->selected_windows) { if (scr->selected_windows)
WMRemoveFromArray(scr->selected_windows, wwin); WMRemoveFromArray(scr->selected_windows, wwin);
}
} }
} }
@@ -1959,7 +1939,7 @@ static void shade_animate(WWindow *wwin, Bool what)
if (wwin->flags.skip_next_animation || wPreferences.no_animations) if (wwin->flags.skip_next_animation || wPreferences.no_animations)
return; return;
switch(what) { switch (what) {
case SHADE: case SHADE:
if (!wwin->screen_ptr->flags.startup) { if (!wwin->screen_ptr->flags.startup) {
/* do the shading animation */ /* do the shading animation */
@@ -1977,11 +1957,10 @@ static void shade_animate(WWindow *wwin, Bool what)
if (time(NULL) - time0 > MAX_ANIMATION_TIME) if (time(NULL) - time0 > MAX_ANIMATION_TIME)
break; break;
if (SHADE_DELAY > 0) { if (SHADE_DELAY > 0)
wusleep(SHADE_DELAY * 1000L); wusleep(SHADE_DELAY * 1000L);
} else { else
wusleep(10); wusleep(10);
}
h -= s; h -= s;
y -= s; y -= s;
} }
@@ -2002,11 +1981,10 @@ static void shade_animate(WWindow *wwin, Bool what)
XResizeWindow(dpy, wwin->frame->core->window, w, h); XResizeWindow(dpy, wwin->frame->core->window, w, h);
XMoveWindow(dpy, wwin->client_win, 0, y); XMoveWindow(dpy, wwin->client_win, 0, y);
XFlush(dpy); XFlush(dpy);
if (SHADE_DELAY > 0) { if (SHADE_DELAY > 0)
wusleep(SHADE_DELAY * 2000L / 3); wusleep(SHADE_DELAY * 2000L / 3);
} else { else
wusleep(10); wusleep(10);
}
h += s; h += s;
y += s; y += s;