more style changes

This commit is contained in:
Christopher Jeffrey 2012-09-13 10:12:54 -05:00
parent 5bcbf87f32
commit 0064894bf6
2 changed files with 43 additions and 23 deletions

View File

@ -710,9 +710,9 @@ long determine_evmask(Display *dpy, Window wid, enum win_evmode_t mode) {
if (WIN_EVMODE_FRAME == mode || find_win(dpy, wid)) { if (WIN_EVMODE_FRAME == mode || find_win(dpy, wid)) {
evmask |= PropertyChangeMask; evmask |= PropertyChangeMask;
if (track_focus) if (track_focus) evmask |= FocusChangeMask;
evmask |= FocusChangeMask;
} }
if (WIN_EVMODE_CLIENT == mode || find_client_win(dpy, wid)) { if (WIN_EVMODE_CLIENT == mode || find_client_win(dpy, wid)) {
evmask |= PropertyChangeMask; evmask |= PropertyChangeMask;
} }
@ -739,7 +739,8 @@ find_win(Display *dpy, Window id) {
* @param w window ID * @param w window ID
* @return struct _win object of the found window, NULL if not found * @return struct _win object of the found window, NULL if not found
*/ */
win *find_toplevel(Display *dpy, Window id) { static win *
find_toplevel(Display *dpy, Window id) {
win *w; win *w;
for (w = list; w; w = w->next) { for (w = list; w; w = w->next) {
@ -757,7 +758,8 @@ win *find_toplevel(Display *dpy, Window id) {
* @param w window ID * @param w window ID
* @return struct _win object of the found window, NULL if not found * @return struct _win object of the found window, NULL if not found
*/ */
win *find_toplevel2(Display *dpy, Window wid) { static win *
find_toplevel2(Display *dpy, Window wid) {
win *w = NULL; win *w = NULL;
// We traverse through its ancestors to find out the frame // We traverse through its ancestors to find out the frame
@ -776,8 +778,8 @@ win *find_toplevel2(Display *dpy, Window wid) {
break; break;
} }
if (tchildren) if (tchildren) XFree(tchildren);
XFree(tchildren);
wid = parent; wid = parent;
} }
@ -791,7 +793,8 @@ win *find_toplevel2(Display *dpy, Window wid) {
* @param dpy display to use * @param dpy display to use
* @return struct _win of currently focused window, NULL if not found * @return struct _win of currently focused window, NULL if not found
*/ */
win *recheck_focus(Display *dpy) { static win *
recheck_focus(Display *dpy) {
// Determine the currently focused window so we can apply appropriate // Determine the currently focused window so we can apply appropriate
// opacity on it // opacity on it
Window wid = 0; Window wid = 0;
@ -801,8 +804,9 @@ win *recheck_focus(Display *dpy) {
XGetInputFocus(dpy, &wid, &revert_to); XGetInputFocus(dpy, &wid, &revert_to);
// Fallback to the old method if find_toplevel() fails // Fallback to the old method if find_toplevel() fails
if (!(w = find_toplevel(dpy, wid))) if (!(w = find_toplevel(dpy, wid))) {
w = find_toplevel2(dpy, wid); w = find_toplevel2(dpy, wid);
}
// And we set the focus state and opacity here // And we set the focus state and opacity here
if (w) { if (w) {
@ -964,21 +968,25 @@ border_size(Display *dpy, win *w) {
return border; return border;
} }
Window find_client_win(Display *dpy, Window w) { static Window
if (win_has_attr(dpy, w, atom_client_attr)) find_client_win(Display *dpy, Window w) {
if (win_has_attr(dpy, w, atom_client_attr)) {
return w; return w;
}
Window *children; Window *children;
unsigned int nchildren; unsigned int nchildren;
unsigned int i; unsigned int i;
Window ret = 0; Window ret = 0;
if(!win_get_children(dpy, w, &children, &nchildren)) if (!win_get_children(dpy, w, &children, &nchildren)) {
return 0; return 0;
}
for (i = 0; i < nchildren; ++i) for (i = 0; i < nchildren; ++i) {
if ((ret = find_client_win(dpy, children[i]))) if ((ret = find_client_win(dpy, children[i])))
break; break;
}
XFree(children); XFree(children);
@ -1471,8 +1479,9 @@ map_win(Display *dpy, Window id,
* XSelectInput() is called too late. We have to recheck the focused * XSelectInput() is called too late. We have to recheck the focused
* window here. * window here.
*/ */
if (track_focus) if (track_focus) {
recheck_focus(dpy); recheck_focus(dpy);
}
calc_opacity(dpy, w, True); calc_opacity(dpy, w, True);
calc_dim(dpy, w); calc_dim(dpy, w);
@ -1804,10 +1813,11 @@ add_win(Display *dpy, Window id, Window prev, Bool override_redirect) {
Window cw = find_client_win(dpy, new->id); Window cw = find_client_win(dpy, new->id);
if (cw) { if (cw) {
new->client_win = cw; new->client_win = cw;
if (frame_opacity) if (frame_opacity) {
get_frame_extents(dpy, cw, get_frame_extents(dpy, cw,
&new->left_width, &new->right_width, &new->left_width, &new->right_width,
&new->top_width, &new->bottom_width); &new->top_width, &new->bottom_width);
}
XSelectInput(dpy, cw, determine_evmask(dpy, id, WIN_EVMODE_CLIENT)); XSelectInput(dpy, cw, determine_evmask(dpy, id, WIN_EVMODE_CLIENT));
} }
} }
@ -3019,8 +3029,9 @@ main(int argc, char **argv) {
XFree(children); XFree(children);
if (track_focus) if (track_focus) {
recheck_focus(dpy); recheck_focus(dpy);
}
XUngrabServer(dpy); XUngrabServer(dpy);

View File

@ -257,7 +257,8 @@ print_timestamp(void) {
* @param atom atom of attribute to check * @param atom atom of attribute to check
* @return 1 if it has the attribute, 0 otherwise * @return 1 if it has the attribute, 0 otherwise
*/ */
static inline Bool win_has_attr(Display *dpy, Window w, Atom atom) { static inline Bool
win_has_attr(Display *dpy, Window w, Atom atom) {
Atom type = None; Atom type = None;
int format; int format;
unsigned long nitems, after; unsigned long nitems, after;
@ -266,8 +267,7 @@ static inline Bool win_has_attr(Display *dpy, Window w, Atom atom) {
if (Success == XGetWindowProperty(dpy, w, atom, 0, 0, False, if (Success == XGetWindowProperty(dpy, w, atom, 0, 0, False,
AnyPropertyType, &type, &format, &nitems, &after, &data)) { AnyPropertyType, &type, &format, &nitems, &after, &data)) {
XFree(data); XFree(data);
if (type) if (type) return True;
return True;
} }
return False; return False;
@ -282,7 +282,8 @@ static inline Bool win_has_attr(Display *dpy, Window w, Atom atom) {
* @param nchildren [out] number of children * @param nchildren [out] number of children
* @return 1 if successful, 0 otherwise * @return 1 if successful, 0 otherwise
*/ */
static inline Bool win_get_children(Display *dpy, Window w, static inline Bool
win_get_children(Display *dpy, Window w,
Window **children, unsigned *nchildren) { Window **children, unsigned *nchildren) {
Window troot, tparent; Window troot, tparent;
@ -361,6 +362,12 @@ find_win(Display *dpy, Window id);
static win * static win *
find_toplevel(Display *dpy, Window id); find_toplevel(Display *dpy, Window id);
static win *
find_toplevel2(Display *dpy, Window wid);
static win *
recheck_focus(Display *dpy);
static Picture static Picture
root_tile_f(Display *dpy); root_tile_f(Display *dpy);
@ -373,9 +380,11 @@ win_extents(Display *dpy, win *w);
static XserverRegion static XserverRegion
border_size(Display *dpy, win *w); border_size(Display *dpy, win *w);
Window find_client_win(Display *dpy, Window w); static Window
find_client_win(Display *dpy, Window w);
Window find_client_win2(Display *dpy, Window w); static Window
find_client_win2(Display *dpy, Window w);
static void static void
get_frame_extents(Display *dpy, Window w, get_frame_extents(Display *dpy, Window w,