stay consistent with code style
This commit is contained in:
parent
5112f91c48
commit
5bcbf87f32
130
src/compton.c
130
src/compton.c
|
@ -572,8 +572,9 @@ make_shadow(Display *dpy, double opacity,
|
||||||
0, sheight);
|
0, sheight);
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
for (y = ystart; y < yend; y++)
|
for (y = ystart; y < yend; y++) {
|
||||||
memset(&data[y * swidth + xstart], 0, xrange);
|
memset(&data[y * swidth + xstart], 0, xrange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ximage;
|
return ximage;
|
||||||
|
@ -1148,9 +1149,10 @@ paint_all(Display *dpy, XserverRegion region) {
|
||||||
None, root_buffer, 0, 0, 0, 0,
|
None, root_buffer, 0, 0, 0, 0,
|
||||||
x, y, wid, hei);
|
x, y, wid, hei);
|
||||||
|
|
||||||
if (w->dim)
|
if (w->dim) {
|
||||||
XRenderComposite(dpy, PictOpOver, dim_picture, None,
|
XRenderComposite(dpy, PictOpOver, dim_picture, None,
|
||||||
root_buffer, 0, 0, 0, 0, x, y, wid, hei);
|
root_buffer, 0, 0, 0, 0, x, y, wid, hei);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!w->border_clip) {
|
if (!w->border_clip) {
|
||||||
|
@ -1169,6 +1171,7 @@ paint_all(Display *dpy, XserverRegion region) {
|
||||||
|
|
||||||
XFixesSetPictureClipRegion(dpy,
|
XFixesSetPictureClipRegion(dpy,
|
||||||
root_buffer, 0, 0, region);
|
root_buffer, 0, 0, region);
|
||||||
|
|
||||||
paint_root(dpy);
|
paint_root(dpy);
|
||||||
|
|
||||||
for (w = t; w; w = w->prev_trans) {
|
for (w = t; w; w = w->prev_trans) {
|
||||||
|
@ -1250,9 +1253,10 @@ paint_all(Display *dpy, XserverRegion region) {
|
||||||
l, t, l, t, x + l, y + t, wid - l - r, hei - t - b);
|
l, t, l, t, x + l, y + t, wid - l - r, hei - t - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->dim)
|
if (w->dim) {
|
||||||
XRenderComposite(dpy, PictOpOver, dim_picture, None,
|
XRenderComposite(dpy, PictOpOver, dim_picture, None,
|
||||||
root_buffer, 0, 0, 0, 0, x, y, wid, hei);
|
root_buffer, 0, 0, 0, 0, x, y, wid, hei);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XFixesDestroyRegion(dpy, w->border_clip);
|
XFixesDestroyRegion(dpy, w->border_clip);
|
||||||
|
@ -1569,7 +1573,8 @@ unmap_win(Display *dpy, Window id, Bool fade) {
|
||||||
finish_unmap_win(dpy, w);
|
finish_unmap_win(dpy, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
opacity_t get_opacity_prop(Display *dpy, win *w, opacity_t def) {
|
static opacity_t
|
||||||
|
get_opacity_prop(Display *dpy, win *w, opacity_t def) {
|
||||||
Atom actual;
|
Atom actual;
|
||||||
int format;
|
int format;
|
||||||
unsigned long n, left;
|
unsigned long n, left;
|
||||||
|
@ -1635,13 +1640,14 @@ determine_mode(Display *dpy, win *w) {
|
||||||
add_damage_win(dpy, w);
|
add_damage_win(dpy, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_opacity(Display *dpy, win *w, opacity_t opacity) {
|
static void
|
||||||
|
set_opacity(Display *dpy, win *w, opacity_t opacity) {
|
||||||
// Do nothing if the opacity does not change
|
// Do nothing if the opacity does not change
|
||||||
if (w->opacity == opacity)
|
if (w->opacity == opacity) return;
|
||||||
return;
|
|
||||||
|
|
||||||
w->opacity = opacity;
|
w->opacity = opacity;
|
||||||
determine_mode(dpy, w);
|
determine_mode(dpy, w);
|
||||||
|
|
||||||
if (w->shadow) {
|
if (w->shadow) {
|
||||||
XRenderFreePicture(dpy, w->shadow);
|
XRenderFreePicture(dpy, w->shadow);
|
||||||
w->shadow = None;
|
w->shadow = None;
|
||||||
|
@ -1675,40 +1681,45 @@ void set_opacity(Display *dpy, win *w, opacity_t opacity) {
|
||||||
* @param refetch_prop whether _NET_WM_OPACITY of the window needs to be
|
* @param refetch_prop whether _NET_WM_OPACITY of the window needs to be
|
||||||
* refetched
|
* refetched
|
||||||
*/
|
*/
|
||||||
void calc_opacity(Display *dpy, win *w, Bool refetch_prop) {
|
static void
|
||||||
|
calc_opacity(Display *dpy, win *w, Bool refetch_prop) {
|
||||||
opacity_t opacity;
|
opacity_t opacity;
|
||||||
|
|
||||||
// Do nothing for unmapped window, calc_opacity() will be called
|
// Do nothing for unmapped window, calc_opacity() will be called
|
||||||
// when it's mapped
|
// when it's mapped
|
||||||
// I suppose I need not to check for IsUnviewable here?
|
// I suppose I need not to check for IsUnviewable here?
|
||||||
if (IsViewable != w->a.map_state)
|
if (IsViewable != w->a.map_state) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Do not refetch the opacity window attribute unless necessary, this
|
// Do not refetch the opacity window attribute unless necessary, this
|
||||||
// is probably an expensive operation in some cases
|
// is probably an expensive operation in some cases
|
||||||
if (refetch_prop)
|
if (refetch_prop) {
|
||||||
w->opacity_prop = get_opacity_prop(dpy, w, OPAQUE);
|
w->opacity_prop = get_opacity_prop(dpy, w, OPAQUE);
|
||||||
|
}
|
||||||
|
|
||||||
if (OPAQUE == (opacity = w->opacity_prop)) {
|
if (OPAQUE == (opacity = w->opacity_prop)) {
|
||||||
if (OPAQUE != win_type_opacity[w->window_type])
|
if (OPAQUE != win_type_opacity[w->window_type]) {
|
||||||
opacity = win_type_opacity[w->window_type] * OPAQUE;
|
opacity = win_type_opacity[w->window_type] * OPAQUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respect inactive_opacity in some cases
|
// Respect inactive_opacity in some cases
|
||||||
if (inactive_opacity && IS_NORMAL_WIN(w) && False == w->focused
|
if (inactive_opacity && IS_NORMAL_WIN(w) && False == w->focused
|
||||||
&& (OPAQUE == opacity || inactive_opacity_override))
|
&& (OPAQUE == opacity || inactive_opacity_override)) {
|
||||||
opacity = inactive_opacity;
|
opacity = inactive_opacity;
|
||||||
|
}
|
||||||
|
|
||||||
set_opacity(dpy, w, opacity);
|
set_opacity(dpy, w, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void calc_dim(Display *dpy, win *w) {
|
static void
|
||||||
|
calc_dim(Display *dpy, win *w) {
|
||||||
Bool dim;
|
Bool dim;
|
||||||
|
|
||||||
if (inactive_dim && IS_NORMAL_WIN(w) && !(w->focused))
|
if (inactive_dim && IS_NORMAL_WIN(w) && !(w->focused)) {
|
||||||
dim = True;
|
dim = True;
|
||||||
else
|
} else {
|
||||||
dim = False;
|
dim = False;
|
||||||
|
}
|
||||||
|
|
||||||
if (dim != w->dim) {
|
if (dim != w->dim) {
|
||||||
w->dim = dim;
|
w->dim = dim;
|
||||||
|
@ -1846,17 +1857,22 @@ restack_win(Display *dpy, win *w, Window new_above) {
|
||||||
Bool to_free;
|
Bool to_free;
|
||||||
win* c = list;
|
win* c = list;
|
||||||
|
|
||||||
printf("restack_win(%#010lx, %#010lx): Window stack modified. Current stack:\n", w->id, new_above);
|
printf("restack_win(%#010lx, %#010lx): "
|
||||||
|
"Window stack modified. Current stack:\n", w->id, new_above);
|
||||||
|
|
||||||
for (; c; c = c->next) {
|
for (; c; c = c->next) {
|
||||||
window_name = "(Failed to get title)";
|
window_name = "(Failed to get title)";
|
||||||
if (root == c->id)
|
|
||||||
|
if (root == c->id) {
|
||||||
window_name = "(Root window)";
|
window_name = "(Root window)";
|
||||||
else
|
} else {
|
||||||
to_free = window_get_name(c->id, &window_name);
|
to_free = window_get_name(c->id, &window_name);
|
||||||
|
}
|
||||||
|
|
||||||
desc = "";
|
desc = "";
|
||||||
if (c->destroyed)
|
if (c->destroyed) desc = "(D) ";
|
||||||
desc = "(D) ";
|
|
||||||
printf("%#010lx \"%s\" %s-> ", c->id, window_name, desc);
|
printf("%#010lx \"%s\" %s-> ", c->id, window_name, desc);
|
||||||
|
|
||||||
if (to_free) {
|
if (to_free) {
|
||||||
XFree(window_name);
|
XFree(window_name);
|
||||||
window_name = NULL;
|
window_name = NULL;
|
||||||
|
@ -1891,8 +1907,10 @@ configure_win(Display *dpy, XConfigureEvent *ce) {
|
||||||
w->queue_configure = *ce;
|
w->queue_configure = *ce;
|
||||||
restack_win(dpy, w, ce->above);
|
restack_win(dpy, w, ce->above);
|
||||||
} else {
|
} else {
|
||||||
if (!(w->need_configure))
|
if (!(w->need_configure)) {
|
||||||
restack_win(dpy, w, ce->above);
|
restack_win(dpy, w, ce->above);
|
||||||
|
}
|
||||||
|
|
||||||
w->need_configure = False;
|
w->need_configure = False;
|
||||||
|
|
||||||
#if CAN_DO_USABLE
|
#if CAN_DO_USABLE
|
||||||
|
@ -1900,8 +1918,9 @@ configure_win(Display *dpy, XConfigureEvent *ce) {
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
damage = XFixesCreateRegion(dpy, 0, 0);
|
damage = XFixesCreateRegion(dpy, 0, 0);
|
||||||
if (w->extents != None)
|
if (w->extents != None) {
|
||||||
XFixesCopyRegion(dpy, damage, w->extents);
|
XFixesCopyRegion(dpy, damage, w->extents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w->a.x = ce->x;
|
w->a.x = ce->x;
|
||||||
|
@ -2198,7 +2217,8 @@ expose_root(Display *dpy, Window root, XRectangle *rects, int nrects) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DEBUG_EVENTS) || defined(DEBUG_RESTACK)
|
#if defined(DEBUG_EVENTS) || defined(DEBUG_RESTACK)
|
||||||
static int window_get_name(Window w, char **name) {
|
static int
|
||||||
|
window_get_name(Window w, char **name) {
|
||||||
Atom prop = XInternAtom(dpy, "_NET_WM_NAME", False);
|
Atom prop = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
Atom utf8_type = XInternAtom(dpy, "UTF8_STRING", False);
|
Atom utf8_type = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
Atom actual_type;
|
Atom actual_type;
|
||||||
|
@ -2209,16 +2229,20 @@ static int window_get_name(Window w, char **name) {
|
||||||
Status ret;
|
Status ret;
|
||||||
|
|
||||||
set_ignore(dpy, NextRequest(dpy));
|
set_ignore(dpy, NextRequest(dpy));
|
||||||
|
|
||||||
if (Success != (ret = XGetWindowProperty(dpy, w, prop, 0L, (long) BUFSIZ,
|
if (Success != (ret = XGetWindowProperty(dpy, w, prop, 0L, (long) BUFSIZ,
|
||||||
False, utf8_type, &actual_type, &actual_format, &nitems,
|
False, utf8_type, &actual_type, &actual_format, &nitems,
|
||||||
&leftover, (unsigned char **) &data))) {
|
&leftover, (unsigned char **) &data))) {
|
||||||
if (BadWindow == ret)
|
if (BadWindow == ret) return 0;
|
||||||
return 0;
|
|
||||||
set_ignore(dpy, NextRequest(dpy));
|
set_ignore(dpy, NextRequest(dpy));
|
||||||
printf("Window %#010lx: _NET_WM_NAME unset, falling back to WM_NAME.\n", w);
|
printf("Window %#010lx: _NET_WM_NAME unset, falling back to WM_NAME.\n", w);
|
||||||
if (!XFetchName(dpy, w, &data))
|
|
||||||
|
if (!XFetchName(dpy, w, &data)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (actual_type == utf8_type && actual_format == 8)
|
// if (actual_type == utf8_type && actual_format == 8)
|
||||||
*name = (char *) data;
|
*name = (char *) data;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2264,9 +2288,13 @@ ev_name(XEvent *ev) {
|
||||||
if (ev->type == damage_event + XDamageNotify) {
|
if (ev->type == damage_event + XDamageNotify) {
|
||||||
return "Damage";
|
return "Damage";
|
||||||
}
|
}
|
||||||
if (shape_exists && ev->type == shape_event)
|
|
||||||
|
if (shape_exists && ev->type == shape_event) {
|
||||||
return "ShapeNotify";
|
return "ShapeNotify";
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(buf, "Event %d", ev->type);
|
sprintf(buf, "Event %d", ev->type);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2297,8 +2325,11 @@ ev_window(XEvent *ev) {
|
||||||
if (ev->type == damage_event + XDamageNotify) {
|
if (ev->type == damage_event + XDamageNotify) {
|
||||||
return ((XDamageNotifyEvent *)ev)->drawable;
|
return ((XDamageNotifyEvent *)ev)->drawable;
|
||||||
}
|
}
|
||||||
if (shape_exists && ev->type == shape_event)
|
|
||||||
|
if (shape_exists && ev->type == shape_event) {
|
||||||
return ((XShapeEvent *) ev)->window;
|
return ((XShapeEvent *) ev)->window;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2311,6 +2342,7 @@ ev_window(XEvent *ev) {
|
||||||
inline static void
|
inline static void
|
||||||
ev_focus_in(XFocusChangeEvent *ev) {
|
ev_focus_in(XFocusChangeEvent *ev) {
|
||||||
win *w = find_win(dpy, ev->window);
|
win *w = find_win(dpy, ev->window);
|
||||||
|
if (!w) return;
|
||||||
|
|
||||||
// To deal with events sent from windows just destroyed
|
// To deal with events sent from windows just destroyed
|
||||||
if (!w)
|
if (!w)
|
||||||
|
@ -2333,6 +2365,7 @@ ev_focus_out(XFocusChangeEvent *ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
win *w = find_win(dpy, ev->window);
|
win *w = find_win(dpy, ev->window);
|
||||||
|
if (!w) return;
|
||||||
|
|
||||||
// To deal with events sent from windows just destroyed
|
// To deal with events sent from windows just destroyed
|
||||||
if (!w)
|
if (!w)
|
||||||
|
@ -2351,7 +2384,10 @@ ev_create_notify(XCreateWindowEvent *ev) {
|
||||||
inline static void
|
inline static void
|
||||||
ev_configure_notify(XConfigureEvent *ev) {
|
ev_configure_notify(XConfigureEvent *ev) {
|
||||||
#ifdef DEBUG_EVENTS
|
#ifdef DEBUG_EVENTS
|
||||||
printf("{ send_event: %d, above: %#010lx, override_redirect: %d }\n", ev->send_event, ev->above, ev->override_redirect);
|
printf("{ send_event: %d, "
|
||||||
|
" above: %#010lx, "
|
||||||
|
" override_redirect: %d }\n",
|
||||||
|
ev->send_event, ev->above, ev->override_redirect);
|
||||||
#endif
|
#endif
|
||||||
configure_win(dpy, ev);
|
configure_win(dpy, ev);
|
||||||
}
|
}
|
||||||
|
@ -2454,8 +2490,10 @@ ev_damage_notify(XDamageNotifyEvent *ev) {
|
||||||
damage_win(dpy, ev);
|
damage_win(dpy, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ev_shape_notify(XShapeEvent *ev) {
|
inline static void
|
||||||
|
ev_shape_notify(XShapeEvent *ev) {
|
||||||
win *w = find_win(dpy, ev->window);
|
win *w = find_win(dpy, ev->window);
|
||||||
|
if (!w) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Empty border_size may indicated an
|
* Empty border_size may indicated an
|
||||||
|
@ -2472,12 +2510,10 @@ static void ev_shape_notify(XShapeEvent *ev) {
|
||||||
// Mark the new border_size as damaged
|
// Mark the new border_size as damaged
|
||||||
add_damage(dpy, copy_region(dpy, w->border_size));
|
add_damage(dpy, copy_region(dpy, w->border_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
ev_handle(XEvent *ev) {
|
ev_handle(XEvent *ev) {
|
||||||
|
|
||||||
#ifdef DEBUG_EVENTS
|
#ifdef DEBUG_EVENTS
|
||||||
Window w;
|
Window w;
|
||||||
char *window_name;
|
char *window_name;
|
||||||
|
@ -2491,17 +2527,21 @@ ev_handle(XEvent *ev) {
|
||||||
#ifdef DEBUG_EVENTS
|
#ifdef DEBUG_EVENTS
|
||||||
w = ev_window(ev);
|
w = ev_window(ev);
|
||||||
window_name = "(Failed to get title)";
|
window_name = "(Failed to get title)";
|
||||||
|
|
||||||
if (w) {
|
if (w) {
|
||||||
if (root == w)
|
if (root == w) {
|
||||||
window_name = "(Root window)";
|
window_name = "(Root window)";
|
||||||
else
|
} else {
|
||||||
to_free = (Bool) window_get_name(w, &window_name);
|
to_free = (Bool) window_get_name(w, &window_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev->type != damage_event + XDamageNotify) {
|
if (ev->type != damage_event + XDamageNotify) {
|
||||||
print_timestamp();
|
print_timestamp();
|
||||||
printf("event %10.10s serial %#010x window %#010lx \"%s\"\n",
|
printf("event %10.10s serial %#010x window %#010lx \"%s\"\n",
|
||||||
ev_name(ev), ev_serial(ev), w, window_name);
|
ev_name(ev), ev_serial(ev), w, window_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_free) {
|
if (to_free) {
|
||||||
XFree(window_name);
|
XFree(window_name);
|
||||||
window_name = NULL;
|
window_name = NULL;
|
||||||
|
@ -2611,8 +2651,7 @@ usage() {
|
||||||
"--inactive-opacity-override\n"
|
"--inactive-opacity-override\n"
|
||||||
" Inactive opacity set by -i overrides value of _NET_WM_OPACITY.\n"
|
" Inactive opacity set by -i overrides value of _NET_WM_OPACITY.\n"
|
||||||
"--inactive-dim value\n"
|
"--inactive-dim value\n"
|
||||||
" Dim inactive windows. (0.0 - 1.0, defaults to 0)\n"
|
" Dim inactive windows. (0.0 - 1.0, defaults to 0)\n");
|
||||||
);
|
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -2835,8 +2874,9 @@ main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
inactive_opacity = (normalize_d(atof(optarg)) * OPAQUE);
|
inactive_opacity = (normalize_d(atof(optarg)) * OPAQUE);
|
||||||
if (OPAQUE == inactive_opacity)
|
if (OPAQUE == inactive_opacity) {
|
||||||
inactive_opacity = 0;
|
inactive_opacity = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
frame_opacity = normalize_d(atof(optarg));
|
frame_opacity = normalize_d(atof(optarg));
|
||||||
|
@ -2871,8 +2911,9 @@ main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether we need to track focus changes
|
// Determine whether we need to track focus changes
|
||||||
if (inactive_opacity || inactive_dim)
|
if (inactive_opacity || inactive_dim) {
|
||||||
track_focus = True;
|
track_focus = True;
|
||||||
|
}
|
||||||
|
|
||||||
dpy = XOpenDisplay(display);
|
dpy = XOpenDisplay(display);
|
||||||
if (!dpy) {
|
if (!dpy) {
|
||||||
|
@ -2918,8 +2959,9 @@ main(int argc, char **argv) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!XShapeQueryExtension(dpy, &shape_event, &shape_error))
|
if (!XShapeQueryExtension(dpy, &shape_event, &shape_error)) {
|
||||||
shape_exists = False;
|
shape_exists = False;
|
||||||
|
}
|
||||||
|
|
||||||
register_cm(scr);
|
register_cm(scr);
|
||||||
|
|
||||||
|
@ -2943,15 +2985,17 @@ main(int argc, char **argv) {
|
||||||
|
|
||||||
// Generates another Picture for shadows if the color is modified by
|
// Generates another Picture for shadows if the color is modified by
|
||||||
// user
|
// user
|
||||||
if (!shadow_red && !shadow_green && !shadow_blue)
|
if (!shadow_red && !shadow_green && !shadow_blue) {
|
||||||
cshadow_picture = black_picture;
|
cshadow_picture = black_picture;
|
||||||
else
|
} else {
|
||||||
cshadow_picture = solid_picture(dpy, True, 1,
|
cshadow_picture = solid_picture(dpy, True, 1,
|
||||||
shadow_red, shadow_green, shadow_blue);
|
shadow_red, shadow_green, shadow_blue);
|
||||||
|
}
|
||||||
|
|
||||||
// Generates a picture for inactive_dim
|
// Generates a picture for inactive_dim
|
||||||
if (inactive_dim)
|
if (inactive_dim) {
|
||||||
dim_picture = solid_picture(dpy, True, inactive_dim, 0, 0, 0);
|
dim_picture = solid_picture(dpy, True, inactive_dim, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
all_damage = None;
|
all_damage = None;
|
||||||
clip_changed = True;
|
clip_changed = True;
|
||||||
|
|
|
@ -161,12 +161,10 @@ extern Atom atom_client_attr;
|
||||||
* @param max maximum value
|
* @param max maximum value
|
||||||
* @return normalized value
|
* @return normalized value
|
||||||
*/
|
*/
|
||||||
static inline double normalize_i_range(int i, int min, int max) {
|
static inline double
|
||||||
if (i > max)
|
normalize_i_range(int i, int min, int max) {
|
||||||
return max;
|
if (i > max) return max;
|
||||||
if (i < min)
|
if (i < min) return min;
|
||||||
return min;
|
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,12 +173,10 @@ static inline double normalize_i_range(int i, int min, int max) {
|
||||||
*
|
*
|
||||||
* @param d double value to normalize
|
* @param d double value to normalize
|
||||||
*/
|
*/
|
||||||
static inline double normalize_d(double d) {
|
static inline double
|
||||||
if (d > 1.0)
|
normalize_d(double d) {
|
||||||
return 1.0;
|
if (d > 1.0) return 1.0;
|
||||||
if (d < 0.0)
|
if (d < 0.0) return 0.0;
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,11 +187,12 @@ static inline double normalize_d(double d) {
|
||||||
* @param count amount of elements in the array
|
* @param count amount of elements in the array
|
||||||
* @param wid window ID to search for
|
* @param wid window ID to search for
|
||||||
*/
|
*/
|
||||||
static inline Bool array_wid_exists(const Window *arr,
|
static inline Bool
|
||||||
int count, Window wid) {
|
array_wid_exists(const Window *arr, int count, Window wid) {
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (arr[count] == wid)
|
if (arr[count] == wid) {
|
||||||
return True;
|
return True;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
|
@ -210,15 +207,17 @@ static inline Bool array_wid_exists(const Window *arr,
|
||||||
* Subtract the `struct timeval' values X and Y,
|
* Subtract the `struct timeval' values X and Y,
|
||||||
* storing the result in RESULT.
|
* storing the result in RESULT.
|
||||||
* Return 1 if the difference is negative, otherwise 0. */
|
* Return 1 if the difference is negative, otherwise 0. */
|
||||||
int timeval_subtract (result, x, y)
|
static int
|
||||||
struct timeval *result, *x, *y;
|
timeval_subtract(struct timeval *result,
|
||||||
{
|
struct timeval *x,
|
||||||
|
struct timeval *y) {
|
||||||
/* Perform the carry for the later subtraction by updating y. */
|
/* Perform the carry for the later subtraction by updating y. */
|
||||||
if (x->tv_usec < y->tv_usec) {
|
if (x->tv_usec < y->tv_usec) {
|
||||||
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
|
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
|
||||||
y->tv_usec -= 1000000 * nsec;
|
y->tv_usec -= 1000000 * nsec;
|
||||||
y->tv_sec += nsec;
|
y->tv_sec += nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x->tv_usec - y->tv_usec > 1000000) {
|
if (x->tv_usec - y->tv_usec > 1000000) {
|
||||||
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
|
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
|
||||||
y->tv_usec += 1000000 * nsec;
|
y->tv_usec += 1000000 * nsec;
|
||||||
|
@ -239,11 +238,11 @@ int timeval_subtract (result, x, y)
|
||||||
*
|
*
|
||||||
* Used for debugging.
|
* Used for debugging.
|
||||||
*/
|
*/
|
||||||
static inline void print_timestamp(void) {
|
static inline void
|
||||||
|
print_timestamp(void) {
|
||||||
struct timeval tm, diff;
|
struct timeval tm, diff;
|
||||||
|
|
||||||
if (gettimeofday(&tm, NULL))
|
if (gettimeofday(&tm, NULL)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
timeval_subtract(&diff, &tm, &time_start);
|
timeval_subtract(&diff, &tm, &time_start);
|
||||||
printf("[ %5ld.%02ld ] ", diff.tv_sec, diff.tv_usec / 10000);
|
printf("[ %5ld.%02ld ] ", diff.tv_sec, diff.tv_usec / 10000);
|
||||||
|
@ -416,7 +415,7 @@ unmap_callback(Display *dpy, win *w);
|
||||||
static void
|
static void
|
||||||
unmap_win(Display *dpy, Window id, Bool fade);
|
unmap_win(Display *dpy, Window id, Bool fade);
|
||||||
|
|
||||||
opacity_t
|
static opacity_t
|
||||||
get_opacity_prop(Display *dpy, win *w, opacity_t def);
|
get_opacity_prop(Display *dpy, win *w, opacity_t def);
|
||||||
|
|
||||||
static double
|
static double
|
||||||
|
@ -425,11 +424,14 @@ get_opacity_percent(Display *dpy, win *w);
|
||||||
static void
|
static void
|
||||||
determine_mode(Display *dpy, win *w);
|
determine_mode(Display *dpy, win *w);
|
||||||
|
|
||||||
void set_opacity(Display *dpy, win *w, opacity_t opacity);
|
static void
|
||||||
|
set_opacity(Display *dpy, win *w, opacity_t opacity);
|
||||||
|
|
||||||
void calc_opacity(Display *dpy, win *w, Bool refetch_prop);
|
static void
|
||||||
|
calc_opacity(Display *dpy, win *w, Bool refetch_prop);
|
||||||
|
|
||||||
void calc_dim(Display *dpy, win *w);
|
static void
|
||||||
|
calc_dim(Display *dpy, win *w);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_win(Display *dpy, Window id, Window prev, Bool override_redirect);
|
add_win(Display *dpy, Window id, Window prev, Bool override_redirect);
|
||||||
|
@ -464,7 +466,8 @@ static void
|
||||||
expose_root(Display *dpy, Window root, XRectangle *rects, int nrects);
|
expose_root(Display *dpy, Window root, XRectangle *rects, int nrects);
|
||||||
|
|
||||||
#if defined(DEBUG_EVENTS) || defined(DEBUG_RESTACK)
|
#if defined(DEBUG_EVENTS) || defined(DEBUG_RESTACK)
|
||||||
static int window_get_name(Window w, char **name);
|
static int
|
||||||
|
window_get_name(Window w, char **name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_EVENTS
|
#ifdef DEBUG_EVENTS
|
||||||
|
@ -520,10 +523,14 @@ ev_property_notify(XPropertyEvent *ev);
|
||||||
inline static void
|
inline static void
|
||||||
ev_damage_notify(XDamageNotifyEvent *ev);
|
ev_damage_notify(XDamageNotifyEvent *ev);
|
||||||
|
|
||||||
|
inline static void
|
||||||
|
ev_shape_notify(XShapeEvent *ev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destory the cached border_size of a window.
|
* Destory the cached border_size of a window.
|
||||||
*/
|
*/
|
||||||
inline static void win_free_border_size(Display *dpy, win *w) {
|
inline static void
|
||||||
|
win_free_border_size(Display *dpy, win *w) {
|
||||||
if (w->border_size) {
|
if (w->border_size) {
|
||||||
set_ignore(dpy, NextRequest(dpy));
|
set_ignore(dpy, NextRequest(dpy));
|
||||||
XFixesDestroyRegion(dpy, w->border_size);
|
XFixesDestroyRegion(dpy, w->border_size);
|
||||||
|
@ -534,7 +541,8 @@ inline static void win_free_border_size(Display *dpy, win *w) {
|
||||||
/**
|
/**
|
||||||
* Get a region of the screen size.
|
* Get a region of the screen size.
|
||||||
*/
|
*/
|
||||||
inline static XserverRegion get_screen_region(Display *dpy) {
|
inline static XserverRegion
|
||||||
|
get_screen_region(Display *dpy) {
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
|
@ -547,8 +555,8 @@ inline static XserverRegion get_screen_region(Display *dpy) {
|
||||||
/**
|
/**
|
||||||
* Copies a region
|
* Copies a region
|
||||||
*/
|
*/
|
||||||
inline static XserverRegion copy_region(Display *dpy,
|
inline static XserverRegion
|
||||||
XserverRegion oldregion) {
|
copy_region(Display *dpy, XserverRegion oldregion) {
|
||||||
XserverRegion region = XFixesCreateRegion(dpy, NULL, 0);
|
XserverRegion region = XFixesCreateRegion(dpy, NULL, 0);
|
||||||
|
|
||||||
XFixesCopyRegion(dpy, region, oldregion);
|
XFixesCopyRegion(dpy, region, oldregion);
|
||||||
|
@ -562,9 +570,11 @@ inline static XserverRegion copy_region(Display *dpy,
|
||||||
* @param dpy display in use
|
* @param dpy display in use
|
||||||
* @param w struct _win element representing the window
|
* @param w struct _win element representing the window
|
||||||
*/
|
*/
|
||||||
static inline void add_damage_win(Display *dpy, win *w) {
|
static inline void
|
||||||
if (w->extents)
|
add_damage_win(Display *dpy, win *w) {
|
||||||
|
if (w->extents) {
|
||||||
add_damage(dpy, copy_region(dpy, w->extents));
|
add_damage(dpy, copy_region(dpy, w->extents));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
|
|
Loading…
Reference in New Issue