refactor. remove a lot of dead code.
This commit is contained in:
parent
1591d8b4ce
commit
a353f5bc4b
26
README.md
26
README.md
|
@ -62,23 +62,23 @@ $ compton -cC -fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i 0.6 -e 0.6
|
||||||
|
|
||||||
compton [-d display] [-r radius] [-o opacity]
|
compton [-d display] [-r radius] [-o opacity]
|
||||||
[-l left-offset] [-t top-offset]
|
[-l left-offset] [-t top-offset]
|
||||||
[-i opacity] [-e opacity] [-cCfFS]
|
[-i opacity] [-e opacity] [-cCfFSdG]
|
||||||
|
|
||||||
* `-d` display
|
* `-d` __display__
|
||||||
Specifies the display to manage.
|
Specifies the display to manage.
|
||||||
* `-r` radius
|
* `-r` __radius__
|
||||||
Specifies the blur radius for client-side shadows.
|
Specifies the blur radius for client-side shadows.
|
||||||
* `-o` opacity
|
* `-o` __opacity__
|
||||||
Specifies the opacity for client-side shadows.
|
Specifies the opacity for client-side shadows.
|
||||||
* `-l` left-offset
|
* `-l` __left-offset__
|
||||||
Specifies the left offset for client-side shadows.
|
Specifies the left offset for client-side shadows.
|
||||||
* `-t` top-offset
|
* `-t` __top-offset__
|
||||||
Specifies the top offset for client-side shadows.
|
Specifies the top offset for client-side shadows.
|
||||||
* `-I` fade-in-step
|
* `-I` __fade-in-step__
|
||||||
Specifies the opacity change between steps while fading in.
|
Specifies the opacity change between steps while fading in.
|
||||||
* `-O` fade-out-step
|
* `-O` __fade-out-step__
|
||||||
Specifies the opacity change between steps while fading out.
|
Specifies the opacity change between steps while fading out.
|
||||||
* `-D` fade-delta
|
* `-D` __fade-delta__
|
||||||
Specifies the time (in milliseconds) between steps in a fade.
|
Specifies the time (in milliseconds) between steps in a fade.
|
||||||
* `-c`
|
* `-c`
|
||||||
Enable client-side shadows on windows.
|
Enable client-side shadows on windows.
|
||||||
|
@ -90,10 +90,14 @@ $ compton -cC -fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i 0.6 -e 0.6
|
||||||
* `-F`
|
* `-F`
|
||||||
When -f is specified, also enables the fade effect when windows change their
|
When -f is specified, also enables the fade effect when windows change their
|
||||||
opacity, as with transset(1).
|
opacity, as with transset(1).
|
||||||
* `-i` opacity
|
* `-i` __opacity__
|
||||||
Specifies inactive window transparency. (0.1 - 1.0)
|
Specifies inactive window transparency. (0.1 - 1.0)
|
||||||
* `-e` opacity
|
* `-e` __opacity__
|
||||||
Specifies window frame transparency. (0.1 - 1.0)
|
Specifies window frame transparency. (0.1 - 1.0)
|
||||||
|
* `-G`
|
||||||
|
Avoid painting shadows on DND windows.
|
||||||
|
* `-b` __daemonize__
|
||||||
|
Attempt to daemonize process.
|
||||||
* `-S`
|
* `-S`
|
||||||
Enables synchronous operation. Useful for debugging.
|
Enables synchronous operation. Useful for debugging.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
compton \- a compositor for X11
|
compton \- a compositor for X11
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.nf
|
.nf
|
||||||
.B compton [\-d display] [\-r radius] [\-o opacity] [\-l left-offset] [\-t top-offset] [\-i opacity] [\-e opacity] [\-cCfFS]
|
.B compton [\-d display] [\-r radius] [\-o opacity] [\-l left-offset] [\-t top-offset] [\-i opacity] [\-e opacity] [\-cCfFSdG]
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B compton
|
.B compton
|
||||||
|
@ -57,11 +57,7 @@ When \-f is specified, also enables the fade effect when windows change their
|
||||||
opacity, as with transset(1).
|
opacity, as with transset(1).
|
||||||
.TP
|
.TP
|
||||||
.BI \-b
|
.BI \-b
|
||||||
Attempts to fork to background after registered composition
|
Attempt to fork to background after registering compositor.
|
||||||
manager. Still sits in foreground if fork failed. Maybe useful
|
|
||||||
if you computer is too fast, in which case some programs
|
|
||||||
requiring a composite manager may have started before composite
|
|
||||||
manager is ready.
|
|
||||||
.TP
|
.TP
|
||||||
.BI \-i\ opacity
|
.BI \-i\ opacity
|
||||||
Specifies inactive window transparency. (0.1 - 1.0)
|
Specifies inactive window transparency. (0.1 - 1.0)
|
||||||
|
|
220
compton.c
220
compton.c
|
@ -1,15 +1,19 @@
|
||||||
/*
|
/*
|
||||||
* compton - a compositor for X11
|
* Compton - a compositor for X11
|
||||||
*
|
*
|
||||||
* based on xcompmgr - copyright (c) 2003, keith packard
|
* Based on `xcompmgr` - Copyright (c) 2003, Keith Packard
|
||||||
*
|
*
|
||||||
* copyright (c) 2011, christopher jeffrey
|
* Copyright (c) 2011, Christopher Jeffrey
|
||||||
* See LICENSE for more information.
|
* See LICENSE for more information.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "compton.h"
|
#include "compton.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared
|
||||||
|
*/
|
||||||
|
|
||||||
win *list;
|
win *list;
|
||||||
fade *fades;
|
fade *fades;
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
|
@ -74,7 +78,6 @@ Bool win_type_fade[NUM_WINTYPES];
|
||||||
#define IS_NORMAL_WIN(w) \
|
#define IS_NORMAL_WIN(w) \
|
||||||
((w) && ((w)->window_type == WINTYPE_NORMAL \
|
((w) && ((w)->window_type == WINTYPE_NORMAL \
|
||||||
|| (w)->window_type == WINTYPE_UTILITY))
|
|| (w)->window_type == WINTYPE_UTILITY))
|
||||||
// || (w)->window_type == WINTYPE_UNKNOWN))
|
|
||||||
|
|
||||||
#define HAS_FRAME_OPACITY(w) (frame_opacity && (w)->top_width)
|
#define HAS_FRAME_OPACITY(w) (frame_opacity && (w)->top_width)
|
||||||
|
|
||||||
|
@ -104,7 +107,7 @@ Bool synchronize = False;
|
||||||
* Fades
|
* Fades
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
static int
|
||||||
get_time_in_milliseconds() {
|
get_time_in_milliseconds() {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
|
@ -113,7 +116,7 @@ get_time_in_milliseconds() {
|
||||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
fade *
|
static fade *
|
||||||
find_fade(win *w) {
|
find_fade(win *w) {
|
||||||
fade *f;
|
fade *f;
|
||||||
|
|
||||||
|
@ -124,7 +127,7 @@ find_fade(win *w) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
dequeue_fade(Display *dpy, fade *f) {
|
dequeue_fade(Display *dpy, fade *f) {
|
||||||
fade **prev;
|
fade **prev;
|
||||||
|
|
||||||
|
@ -140,7 +143,7 @@ dequeue_fade(Display *dpy, fade *f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cleanup_fade(Display *dpy, win *w) {
|
cleanup_fade(Display *dpy, win *w) {
|
||||||
fade *f = find_fade (w);
|
fade *f = find_fade (w);
|
||||||
if (f) {
|
if (f) {
|
||||||
|
@ -148,7 +151,7 @@ cleanup_fade(Display *dpy, win *w) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
enqueue_fade(Display *dpy, fade *f) {
|
enqueue_fade(Display *dpy, fade *f) {
|
||||||
if (!fades) {
|
if (!fades) {
|
||||||
fade_time = get_time_in_milliseconds() + fade_delta;
|
fade_time = get_time_in_milliseconds() + fade_delta;
|
||||||
|
@ -192,10 +195,6 @@ set_fade(Display *dpy, win *w, double start,
|
||||||
f->callback = callback;
|
f->callback = callback;
|
||||||
w->opacity = f->cur * OPAQUE;
|
w->opacity = f->cur * OPAQUE;
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("set_fade start %g step %g\n", f->cur, f->step);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
determine_mode(dpy, w);
|
determine_mode(dpy, w);
|
||||||
|
|
||||||
if (w->shadow) {
|
if (w->shadow) {
|
||||||
|
@ -219,7 +218,7 @@ set_fade(Display *dpy, win *w, double start,
|
||||||
w->damaged = 1;
|
w->damaged = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
fade_timeout(void) {
|
fade_timeout(void) {
|
||||||
int now;
|
int now;
|
||||||
int delta;
|
int delta;
|
||||||
|
@ -230,22 +229,17 @@ fade_timeout(void) {
|
||||||
delta = fade_time - now;
|
delta = fade_time - now;
|
||||||
|
|
||||||
if (delta < 0) delta = 0;
|
if (delta < 0) delta = 0;
|
||||||
/* printf("timeout %d\n", delta); */
|
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
run_fades(Display *dpy) {
|
run_fades(Display *dpy) {
|
||||||
int now = get_time_in_milliseconds();
|
int now = get_time_in_milliseconds();
|
||||||
fade *next = fades;
|
fade *next = fades;
|
||||||
int steps;
|
int steps;
|
||||||
Bool need_dequeue;
|
Bool need_dequeue;
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("run fades\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fade_time - now > 0) return;
|
if (fade_time - now > 0) return;
|
||||||
steps = 1 + (now - fade_time) / fade_delta;
|
steps = 1 + (now - fade_time) / fade_delta;
|
||||||
|
|
||||||
|
@ -261,10 +255,6 @@ run_fades(Display *dpy) {
|
||||||
f->cur = 0;
|
f->cur = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("opacity now %g\n", f->cur);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
w->opacity = f->cur * OPAQUE;
|
w->opacity = f->cur * OPAQUE;
|
||||||
need_dequeue = False;
|
need_dequeue = False;
|
||||||
if (f->step > 0) {
|
if (f->step > 0) {
|
||||||
|
@ -333,8 +323,6 @@ make_gaussian_map(Display *dpy, double r) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* printf("gaussian total %f\n", t); */
|
|
||||||
|
|
||||||
for (y = 0; y < size; y++) {
|
for (y = 0; y < size; y++) {
|
||||||
for (x = 0; x < size; x++) {
|
for (x = 0; x < size; x++) {
|
||||||
c->data[y * size + x] /= t;
|
c->data[y * size + x] /= t;
|
||||||
|
@ -489,7 +477,7 @@ make_shadow(Display *dpy, double opacity,
|
||||||
* center (fill the complete data array)
|
* center (fill the complete data array)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!clear_shadow) {
|
if (!clear_shadow) {
|
||||||
if (Gsize > 0) {
|
if (Gsize > 0) {
|
||||||
d = shadow_top[opacity_int * (Gsize + 1) + Gsize];
|
d = shadow_top[opacity_int * (Gsize + 1) + Gsize];
|
||||||
} else {
|
} else {
|
||||||
|
@ -498,10 +486,10 @@ if (!clear_shadow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(data, d, sheight * swidth);
|
memset(data, d, sheight * swidth);
|
||||||
} else {
|
} else {
|
||||||
// zero the pixmap
|
// zero the pixmap
|
||||||
memset(data, 0, sheight * swidth);
|
memset(data, 0, sheight * swidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* corners
|
* corners
|
||||||
|
@ -513,7 +501,7 @@ if (!clear_shadow) {
|
||||||
xlimit = gsize;
|
xlimit = gsize;
|
||||||
if (xlimit > swidth / 2) xlimit = (swidth + 1) / 2;
|
if (xlimit > swidth / 2) xlimit = (swidth + 1) / 2;
|
||||||
|
|
||||||
for (y = 0; y < ylimit; y++)
|
for (y = 0; y < ylimit; y++) {
|
||||||
for (x = 0; x < xlimit; x++) {
|
for (x = 0; x < xlimit; x++) {
|
||||||
if (xlimit == Gsize && ylimit == Gsize) {
|
if (xlimit == Gsize && ylimit == Gsize) {
|
||||||
d = shadow_corner[opacity_int * (Gsize + 1) * (Gsize + 1)
|
d = shadow_corner[opacity_int * (Gsize + 1) * (Gsize + 1)
|
||||||
|
@ -527,6 +515,7 @@ if (!clear_shadow) {
|
||||||
data[(sheight - y - 1) * swidth + (swidth - x - 1)] = d;
|
data[(sheight - y - 1) * swidth + (swidth - x - 1)] = d;
|
||||||
data[y * swidth + (swidth - x - 1)] = d;
|
data[y * swidth + (swidth - x - 1)] = d;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* top/bottom
|
* top/bottom
|
||||||
|
@ -564,8 +553,7 @@ if (!clear_shadow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// zero extra pixels
|
// zero extra pixels
|
||||||
if (clear_shadow)
|
if (clear_shadow && width > gsize && height > gsize) {
|
||||||
if (width > gsize && height > gsize) {
|
|
||||||
int r = gsize / 2;
|
int r = gsize / 2;
|
||||||
int sr = r - 2;
|
int sr = r - 2;
|
||||||
int er = r + 4;
|
int er = r + 4;
|
||||||
|
@ -600,6 +588,7 @@ shadow_picture(Display *dpy, double opacity, Picture alpha_pict,
|
||||||
|
|
||||||
shadow_picture = XRenderCreatePicture(dpy, shadowPixmap,
|
shadow_picture = XRenderCreatePicture(dpy, shadowPixmap,
|
||||||
XRenderFindStandardFormat(dpy, PictStandardA8), 0, 0);
|
XRenderFindStandardFormat(dpy, PictStandardA8), 0, 0);
|
||||||
|
|
||||||
if (!shadow_picture) {
|
if (!shadow_picture) {
|
||||||
XDestroyImage(shadowImage);
|
XDestroyImage(shadowImage);
|
||||||
XFreePixmap(dpy, shadowPixmap);
|
XFreePixmap(dpy, shadowPixmap);
|
||||||
|
@ -627,7 +616,7 @@ shadow_picture(Display *dpy, double opacity, Picture alpha_pict,
|
||||||
return shadow_picture;
|
return shadow_picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Picture
|
static Picture
|
||||||
solid_picture(Display *dpy, Bool argb, double a,
|
solid_picture(Display *dpy, Bool argb, double a,
|
||||||
double r, double g, double b) {
|
double r, double g, double b) {
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
|
@ -666,7 +655,7 @@ solid_picture(Display *dpy, Bool argb, double a,
|
||||||
* Errors
|
* Errors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
discard_ignore(Display *dpy, unsigned long sequence) {
|
discard_ignore(Display *dpy, unsigned long sequence) {
|
||||||
while (ignore_head) {
|
while (ignore_head) {
|
||||||
if ((long) (sequence - ignore_head->sequence) > 0) {
|
if ((long) (sequence - ignore_head->sequence) > 0) {
|
||||||
|
@ -682,7 +671,7 @@ discard_ignore(Display *dpy, unsigned long sequence) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
set_ignore(Display *dpy, unsigned long sequence) {
|
set_ignore(Display *dpy, unsigned long sequence) {
|
||||||
ignore *i = malloc(sizeof(ignore));
|
ignore *i = malloc(sizeof(ignore));
|
||||||
if (!i) return;
|
if (!i) return;
|
||||||
|
@ -693,7 +682,7 @@ set_ignore(Display *dpy, unsigned long sequence) {
|
||||||
ignore_tail = &i->next;
|
ignore_tail = &i->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
should_ignore(Display *dpy, unsigned long sequence) {
|
should_ignore(Display *dpy, unsigned long sequence) {
|
||||||
discard_ignore(dpy, sequence);
|
discard_ignore(dpy, sequence);
|
||||||
return ignore_head && ignore_head->sequence == sequence;
|
return ignore_head && ignore_head->sequence == sequence;
|
||||||
|
@ -809,7 +798,7 @@ win_extents(Display *dpy, win *w) {
|
||||||
if (!w->shadow) {
|
if (!w->shadow) {
|
||||||
double opacity = shadow_opacity;
|
double opacity = shadow_opacity;
|
||||||
|
|
||||||
if (!clear_shadow) {
|
if (!clear_shadow) {
|
||||||
if (w->mode != WINDOW_SOLID) {
|
if (w->mode != WINDOW_SOLID) {
|
||||||
opacity = opacity * ((double)w->opacity) / ((double)OPAQUE);
|
opacity = opacity * ((double)w->opacity) / ((double)OPAQUE);
|
||||||
}
|
}
|
||||||
|
@ -817,7 +806,7 @@ if (!clear_shadow) {
|
||||||
if (HAS_FRAME_OPACITY(w)) {
|
if (HAS_FRAME_OPACITY(w)) {
|
||||||
opacity = opacity * frame_opacity;
|
opacity = opacity * frame_opacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w->shadow = shadow_picture(
|
w->shadow = shadow_picture(
|
||||||
dpy, opacity, w->alpha_pict,
|
dpy, opacity, w->alpha_pict,
|
||||||
|
@ -927,10 +916,10 @@ get_frame_extents(Display *dpy, Window w,
|
||||||
unsigned char *data = NULL;
|
unsigned char *data = NULL;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
// *left = 0;
|
*left = 0;
|
||||||
// *right = 0;
|
*right = 0;
|
||||||
// *top = 0;
|
*top = 0;
|
||||||
// *bottom = 0;
|
*bottom = 0;
|
||||||
|
|
||||||
// w = find_client_win(dpy, w);
|
// w = find_client_win(dpy, w);
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
|
@ -1150,7 +1139,6 @@ paint_all(Display *dpy, XserverRegion region) {
|
||||||
dpy, PictOpOver, w->picture, w->alpha_pict,
|
dpy, PictOpOver, w->picture, w->alpha_pict,
|
||||||
root_buffer, 0, 0, 0, 0, x, y, wid, hei);
|
root_buffer, 0, 0, 0, 0, x, y, wid, hei);
|
||||||
} else {
|
} else {
|
||||||
/* TODO - clean me */
|
|
||||||
unsigned int t = w->top_width;
|
unsigned int t = w->top_width;
|
||||||
unsigned int l = w->left_width;
|
unsigned int l = w->left_width;
|
||||||
unsigned int b = w->bottom_width;
|
unsigned int b = w->bottom_width;
|
||||||
|
@ -1229,7 +1217,7 @@ repair_win(Display *dpy, win *w) {
|
||||||
w->damaged = 1;
|
w->damaged = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if DEBUG_WINTYPE
|
||||||
static const char*
|
static const char*
|
||||||
wintype_name(wintype type) {
|
wintype_name(wintype type) {
|
||||||
const char *t;
|
const char *t;
|
||||||
|
@ -1373,15 +1361,16 @@ map_win(Display *dpy, Window id,
|
||||||
w->a.map_state = IsViewable;
|
w->a.map_state = IsViewable;
|
||||||
w->window_type = determine_wintype(dpy, w->id, w->id);
|
w->window_type = determine_wintype(dpy, w->id, w->id);
|
||||||
|
|
||||||
#if 0
|
#if DEBUG_WINTYPE
|
||||||
printf("window 0x%x type %s\n",
|
printf("window 0x%x type %s\n",
|
||||||
w->id, wintype_name(w->window_type));
|
w->id, wintype_name(w->window_type));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* select before reading the property
|
/* select before reading the property
|
||||||
so that no property changes are lost */
|
so that no property changes are lost */
|
||||||
if (!override_redirect)
|
if (!override_redirect) {
|
||||||
XSelectInput(dpy, id, PropertyChangeMask | FocusChangeMask);
|
XSelectInput(dpy, id, PropertyChangeMask | FocusChangeMask);
|
||||||
|
}
|
||||||
|
|
||||||
// this causes problems for inactive transparency
|
// this causes problems for inactive transparency
|
||||||
//w->opacity = get_opacity_prop(dpy, w, OPAQUE);
|
//w->opacity = get_opacity_prop(dpy, w, OPAQUE);
|
||||||
|
@ -1416,7 +1405,8 @@ finish_unmap_win(Display *dpy, win *w) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (w->extents != None) {
|
if (w->extents != None) {
|
||||||
add_damage(dpy, w->extents); /* destroys region */
|
/* destroys region */
|
||||||
|
add_damage(dpy, w->extents);
|
||||||
w->extents = None;
|
w->extents = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1480,10 +1470,6 @@ unmap_win(Display *dpy, Window id, Bool fade) {
|
||||||
finish_unmap_win(dpy, w);
|
finish_unmap_win(dpy, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the opacity prop from window
|
|
||||||
not found: default
|
|
||||||
otherwise the value
|
|
||||||
*/
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
get_opacity_prop(Display *dpy, win *w, unsigned int def) {
|
get_opacity_prop(Display *dpy, win *w, unsigned int def) {
|
||||||
Atom actual;
|
Atom actual;
|
||||||
|
@ -1505,12 +1491,6 @@ get_opacity_prop(Display *dpy, win *w, unsigned int def) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the opacity property from the window in a percent format
|
|
||||||
* not found: default
|
|
||||||
* otherwise: the value
|
|
||||||
*/
|
|
||||||
|
|
||||||
static double
|
static double
|
||||||
get_opacity_percent(Display *dpy, win *w) {
|
get_opacity_percent(Display *dpy, win *w) {
|
||||||
double def = win_type_opacity[w->window_type];
|
double def = win_type_opacity[w->window_type];
|
||||||
|
@ -1569,16 +1549,6 @@ determine_mode(Display *dpy, win *w) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_opacity(Display *dpy, win *w, unsigned long opacity) {
|
set_opacity(Display *dpy, win *w, unsigned long opacity) {
|
||||||
#if 0
|
|
||||||
if (fade_trans) {
|
|
||||||
double old_opacity = (double)w->opacity / OPAQUE;
|
|
||||||
w->opacity = opacity;
|
|
||||||
set_fade(dpy, w, old_opacity,
|
|
||||||
(double)w->opacity / OPAQUE,
|
|
||||||
fade_out_step, 0, True, False);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
w->opacity = opacity;
|
w->opacity = opacity;
|
||||||
determine_mode(dpy, w);
|
determine_mode(dpy, w);
|
||||||
if (w->shadow) {
|
if (w->shadow) {
|
||||||
|
@ -1683,7 +1653,7 @@ add_win(Display *dpy, Window id, Window prev, Bool override_redirect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
restack_win(Display *dpy, win *w, Window new_above) {
|
restack_win(Display *dpy, win *w, Window new_above) {
|
||||||
Window old_above;
|
Window old_above;
|
||||||
|
|
||||||
|
@ -1871,26 +1841,6 @@ destroy_win(Display *dpy, Window id, Bool fade) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
|
||||||
dump_win(win *w) {
|
|
||||||
printf("\t%08lx: %d x %d + %d + %d(%d)\n", w->id,
|
|
||||||
w->a.width, w->a.height,
|
|
||||||
w->a.x, w->a.y, w->a.border_width);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
dump_wins(void) {
|
|
||||||
win *w;
|
|
||||||
|
|
||||||
printf("windows:\n");
|
|
||||||
for (w = list; w; w = w->next) {
|
|
||||||
dump_win(w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
damage_win(Display *dpy, XDamageNotifyEvent *de) {
|
damage_win(Display *dpy, XDamageNotifyEvent *de) {
|
||||||
win *w = find_win(dpy, de->drawable);
|
win *w = find_win(dpy, de->drawable);
|
||||||
|
@ -1922,18 +1872,6 @@ damage_win(Display *dpy, XDamageNotifyEvent *de) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("unusable damage %d, %d: %d x %d bounds %d, %d: %d x %d\n",
|
|
||||||
de->area.x,
|
|
||||||
de->area.y,
|
|
||||||
de->area.width,
|
|
||||||
de->area.height,
|
|
||||||
w->damage_bounds.x,
|
|
||||||
w->damage_bounds.y,
|
|
||||||
w->damage_bounds.width,
|
|
||||||
w->damage_bounds.height);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (w->damage_bounds.x <= 0
|
if (w->damage_bounds.x <= 0
|
||||||
&& w->damage_bounds.y <= 0
|
&& w->damage_bounds.y <= 0
|
||||||
&& w->a.width <= w->damage_bounds.x + w->damage_bounds.width
|
&& w->a.width <= w->damage_bounds.x + w->damage_bounds.width
|
||||||
|
@ -1988,19 +1926,19 @@ error(Display *dpy, XErrorEvent *ev) {
|
||||||
o = ev->error_code - render_error;
|
o = ev->error_code - render_error;
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case BadPictFormat:
|
case BadPictFormat:
|
||||||
name ="BadPictFormat";
|
name = "BadPictFormat";
|
||||||
break;
|
break;
|
||||||
case BadPicture:
|
case BadPicture:
|
||||||
name ="BadPicture";
|
name = "BadPicture";
|
||||||
break;
|
break;
|
||||||
case BadPictOp:
|
case BadPictOp:
|
||||||
name ="BadPictOp";
|
name = "BadPictOp";
|
||||||
break;
|
break;
|
||||||
case BadGlyphSet:
|
case BadGlyphSet:
|
||||||
name ="BadGlyphSet";
|
name = "BadGlyphSet";
|
||||||
break;
|
break;
|
||||||
case BadGlyph:
|
case BadGlyph:
|
||||||
name ="BadGlyph";
|
name = "BadGlyph";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2010,14 +1948,12 @@ error(Display *dpy, XErrorEvent *ev) {
|
||||||
ev->error_code, name, ev->request_code,
|
ev->error_code, name, ev->request_code,
|
||||||
ev->minor_code, ev->serial);
|
ev->minor_code, ev->serial);
|
||||||
|
|
||||||
/* abort(); this is just annoying to most people */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
expose_root(Display *dpy, Window root, XRectangle *rects, int nrects) {
|
expose_root(Display *dpy, Window root, XRectangle *rects, int nrects) {
|
||||||
XserverRegion region = XFixesCreateRegion(dpy, rects, nrects);
|
XserverRegion region = XFixesCreateRegion(dpy, rects, nrects);
|
||||||
|
|
||||||
add_damage(dpy, region);
|
add_damage(dpy, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2083,9 +2019,9 @@ inline static void
|
||||||
ev_focus_in(XFocusChangeEvent *ev) {
|
ev_focus_in(XFocusChangeEvent *ev) {
|
||||||
if (!inactive_opacity) return;
|
if (!inactive_opacity) return;
|
||||||
|
|
||||||
win *fw = find_win(dpy, ev->window);
|
win *w = find_win(dpy, ev->window);
|
||||||
if (IS_NORMAL_WIN(fw)) {
|
if (IS_NORMAL_WIN(w)) {
|
||||||
set_opacity(dpy, fw, OPAQUE);
|
set_opacity(dpy, w, OPAQUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2102,9 +2038,9 @@ ev_focus_out(XFocusChangeEvent *ev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
win *fw = find_win(dpy, ev->window);
|
win *w = find_win(dpy, ev->window);
|
||||||
if (IS_NORMAL_WIN(fw)) {
|
if (IS_NORMAL_WIN(w)) {
|
||||||
set_opacity(dpy, fw, INACTIVE_OPACITY);
|
set_opacity(dpy, w, INACTIVE_OPACITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2216,7 +2152,7 @@ ev_damage_notify(XDamageNotifyEvent *ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
handle_event(XEvent *ev) {
|
ev_handle(XEvent *ev) {
|
||||||
if ((ev->type & 0x7f) != KeymapNotify) {
|
if ((ev->type & 0x7f) != KeymapNotify) {
|
||||||
discard_ignore(dpy, ev->xany.serial);
|
discard_ignore(dpy, ev->xany.serial);
|
||||||
}
|
}
|
||||||
|
@ -2274,10 +2210,10 @@ handle_event(XEvent *ev) {
|
||||||
* Main
|
* Main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(char *program) {
|
usage() {
|
||||||
fprintf(stderr, "%s v0.0.1\n", program);
|
fprintf(stderr, "compton v0.0.1\n");
|
||||||
fprintf(stderr, "usage: %s [options]\n", program);
|
fprintf(stderr, "usage: compton [options]\n");
|
||||||
|
|
||||||
fprintf(stderr, "Options\n");
|
fprintf(stderr, "Options\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -2328,6 +2264,12 @@ usage(char *program) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -e opacity\n "
|
" -e opacity\n "
|
||||||
"Opacity of window titlebars and borders. (0.1 - 1.0)\n");
|
"Opacity of window titlebars and borders. (0.1 - 1.0)\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" -G\n "
|
||||||
|
"Don't draw shadows on DND windows\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" -b daemonize\n "
|
||||||
|
"Daemonize process.\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -S\n "
|
" -S\n "
|
||||||
"Enable synchronous operation (for debugging).\n");
|
"Enable synchronous operation (for debugging).\n");
|
||||||
|
@ -2369,6 +2311,26 @@ register_cm(int scr) {
|
||||||
XSetSelectionOwner(dpy, a, w, 0);
|
XSetSelectionOwner(dpy, a, w, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fork_after() {
|
||||||
|
if (getppid() == 1) return;
|
||||||
|
|
||||||
|
int pid = fork();
|
||||||
|
|
||||||
|
if (pid == -1) {
|
||||||
|
fprintf(stderr, "Fork failed\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid > 0) _exit(0);
|
||||||
|
|
||||||
|
setsid();
|
||||||
|
|
||||||
|
freopen("/dev/null", "r", stdin);
|
||||||
|
freopen("/dev/null", "w", stdout);
|
||||||
|
freopen("/dev/null", "w", stderr);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_atoms() {
|
get_atoms() {
|
||||||
extents_atom = XInternAtom(dpy,
|
extents_atom = XInternAtom(dpy,
|
||||||
|
@ -2512,7 +2474,7 @@ main(int argc, char **argv) {
|
||||||
fork_after_register = True;
|
fork_after_register = True;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2521,8 +2483,9 @@ main(int argc, char **argv) {
|
||||||
win_type_shadow[WINTYPE_DOCK] = False;
|
win_type_shadow[WINTYPE_DOCK] = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_dnd_shadow)
|
if (no_dnd_shadow) {
|
||||||
win_type_shadow[WINTYPE_DND] = False;
|
win_type_shadow[WINTYPE_DND] = False;
|
||||||
|
}
|
||||||
|
|
||||||
dpy = XOpenDisplay(display);
|
dpy = XOpenDisplay(display);
|
||||||
if (!dpy) {
|
if (!dpy) {
|
||||||
|
@ -2568,13 +2531,9 @@ main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
register_cm(scr);
|
register_cm(scr);
|
||||||
if (fork_after_register) {
|
|
||||||
int pid = fork();
|
if (fork_after_register) fork_after();
|
||||||
if (pid < 0)
|
|
||||||
fprintf(stderr, "Fork failed\n");
|
|
||||||
else if (pid > 0)
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
get_atoms();
|
get_atoms();
|
||||||
|
|
||||||
pa.subwindow_mode = IncludeInferiors;
|
pa.subwindow_mode = IncludeInferiors;
|
||||||
|
@ -2588,6 +2547,7 @@ main(int argc, char **argv) {
|
||||||
root_picture = XRenderCreatePicture(dpy, root,
|
root_picture = XRenderCreatePicture(dpy, root,
|
||||||
XRenderFindVisualFormat(dpy, DefaultVisual(dpy, scr)),
|
XRenderFindVisualFormat(dpy, DefaultVisual(dpy, scr)),
|
||||||
CPSubwindowMode, &pa);
|
CPSubwindowMode, &pa);
|
||||||
|
|
||||||
black_picture = solid_picture(dpy, True, 1, 0, 0, 0);
|
black_picture = solid_picture(dpy, True, 1, 0, 0, 0);
|
||||||
|
|
||||||
all_damage = None;
|
all_damage = None;
|
||||||
|
@ -2620,7 +2580,6 @@ main(int argc, char **argv) {
|
||||||
paint_all(dpy, None);
|
paint_all(dpy, None);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* dump_wins(); */
|
|
||||||
do {
|
do {
|
||||||
if (!QLength(dpy)) {
|
if (!QLength(dpy)) {
|
||||||
if (poll(&ufd, 1, fade_timeout()) == 0) {
|
if (poll(&ufd, 1, fade_timeout()) == 0) {
|
||||||
|
@ -2630,9 +2589,7 @@ main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
XNextEvent(dpy, &ev);
|
XNextEvent(dpy, &ev);
|
||||||
|
ev_handle((XEvent *)&ev);
|
||||||
handle_event((XEvent *)&ev);
|
|
||||||
|
|
||||||
} while (QLength(dpy));
|
} while (QLength(dpy));
|
||||||
|
|
||||||
if (all_damage) {
|
if (all_damage) {
|
||||||
|
@ -2645,4 +2602,3 @@ main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
58
compton.h
58
compton.h
|
@ -1,3 +1,9 @@
|
||||||
|
/**
|
||||||
|
* compton.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Throw everything in here.
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -22,6 +28,7 @@
|
||||||
#define CAN_DO_USABLE 0
|
#define CAN_DO_USABLE 0
|
||||||
#define DEBUG_REPAINT 0
|
#define DEBUG_REPAINT 0
|
||||||
#define DEBUG_EVENTS 0
|
#define DEBUG_EVENTS 0
|
||||||
|
#define DEBUG_WINTYPE 0
|
||||||
#define MONITOR_REPAINT 0
|
#define MONITOR_REPAINT 0
|
||||||
|
|
||||||
#define OPAQUE 0xffffffff
|
#define OPAQUE 0xffffffff
|
||||||
|
@ -31,6 +38,10 @@
|
||||||
#define WINDOW_TRANS 1
|
#define WINDOW_TRANS 1
|
||||||
#define WINDOW_ARGB 2
|
#define WINDOW_ARGB 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types
|
||||||
|
*/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WINTYPE_UNKNOWN,
|
WINTYPE_UNKNOWN,
|
||||||
WINTYPE_DESKTOP,
|
WINTYPE_DESKTOP,
|
||||||
|
@ -113,19 +124,23 @@ typedef struct _fade {
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
} fade;
|
} fade;
|
||||||
|
|
||||||
int
|
/**
|
||||||
|
* Functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
get_time_in_milliseconds();
|
get_time_in_milliseconds();
|
||||||
|
|
||||||
fade *
|
static fade *
|
||||||
find_fade(win *w);
|
find_fade(win *w);
|
||||||
|
|
||||||
void
|
static void
|
||||||
dequeue_fade(Display *dpy, fade *f);
|
dequeue_fade(Display *dpy, fade *f);
|
||||||
|
|
||||||
void
|
static void
|
||||||
cleanup_fade(Display *dpy, win *w);
|
cleanup_fade(Display *dpy, win *w);
|
||||||
|
|
||||||
void
|
static void
|
||||||
enqueue_fade(Display *dpy, fade *f);
|
enqueue_fade(Display *dpy, fade *f);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -134,10 +149,10 @@ set_fade(Display *dpy, win *w, double start,
|
||||||
void(*callback) (Display *dpy, win *w),
|
void(*callback) (Display *dpy, win *w),
|
||||||
Bool exec_callback, Bool override);
|
Bool exec_callback, Bool override);
|
||||||
|
|
||||||
int
|
static int
|
||||||
fade_timeout(void);
|
fade_timeout(void);
|
||||||
|
|
||||||
void
|
static void
|
||||||
run_fades(Display *dpy);
|
run_fades(Display *dpy);
|
||||||
|
|
||||||
static double
|
static double
|
||||||
|
@ -161,17 +176,17 @@ static Picture
|
||||||
shadow_picture(Display *dpy, double opacity, Picture alpha_pict,
|
shadow_picture(Display *dpy, double opacity, Picture alpha_pict,
|
||||||
int width, int height, int *wp, int *hp);
|
int width, int height, int *wp, int *hp);
|
||||||
|
|
||||||
Picture
|
static Picture
|
||||||
solid_picture(Display *dpy, Bool argb, double a,
|
solid_picture(Display *dpy, Bool argb, double a,
|
||||||
double r, double g, double b);
|
double r, double g, double b);
|
||||||
|
|
||||||
void
|
static void
|
||||||
discard_ignore(Display *dpy, unsigned long sequence);
|
discard_ignore(Display *dpy, unsigned long sequence);
|
||||||
|
|
||||||
void
|
static void
|
||||||
set_ignore(Display *dpy, unsigned long sequence);
|
set_ignore(Display *dpy, unsigned long sequence);
|
||||||
|
|
||||||
int
|
static int
|
||||||
should_ignore(Display *dpy, unsigned long sequence);
|
should_ignore(Display *dpy, unsigned long sequence);
|
||||||
|
|
||||||
static win *
|
static win *
|
||||||
|
@ -211,11 +226,6 @@ add_damage(Display *dpy, XserverRegion damage);
|
||||||
static void
|
static void
|
||||||
repair_win(Display *dpy, win *w);
|
repair_win(Display *dpy, win *w);
|
||||||
|
|
||||||
#if 0
|
|
||||||
static const char*
|
|
||||||
wintype_name(wintype type);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static wintype
|
static wintype
|
||||||
get_wintype_prop(Display * dpy, Window w);
|
get_wintype_prop(Display * dpy, Window w);
|
||||||
|
|
||||||
|
@ -253,7 +263,7 @@ set_opacity(Display *dpy, win *w, unsigned long opacity);
|
||||||
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);
|
||||||
|
|
||||||
void
|
static void
|
||||||
restack_win(Display *dpy, win *w, Window new_above);
|
restack_win(Display *dpy, win *w, Window new_above);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -273,11 +283,6 @@ destroy_callback(Display *dpy, win *w);
|
||||||
static void
|
static void
|
||||||
destroy_win(Display *dpy, Window id, Bool fade);
|
destroy_win(Display *dpy, Window id, Bool fade);
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
|
||||||
dump_win(win *w);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
damage_win(Display *dpy, XDamageNotifyEvent *de);
|
damage_win(Display *dpy, XDamageNotifyEvent *de);
|
||||||
|
|
||||||
|
@ -298,8 +303,8 @@ static Window
|
||||||
ev_window(XEvent *ev);
|
ev_window(XEvent *ev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(char *program);
|
usage();
|
||||||
|
|
||||||
static void
|
static void
|
||||||
register_cm(int scr);
|
register_cm(int scr);
|
||||||
|
@ -341,7 +346,10 @@ inline static void
|
||||||
ev_damage_notify(XDamageNotifyEvent *ev);
|
ev_damage_notify(XDamageNotifyEvent *ev);
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
handle_event(XEvent *ev);
|
ev_handle(XEvent *ev);
|
||||||
|
|
||||||
|
static void
|
||||||
|
fork_after();
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_atoms();
|
get_atoms();
|
||||||
|
|
Loading…
Reference in New Issue