mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
complete frame opacity
This commit is contained in:
parent
d8b437aca3
commit
cde4d0c75f
2 changed files with 58 additions and 18 deletions
12
README.md
12
README.md
|
@ -12,12 +12,17 @@ partially doing this out of a desire to learn Xlib.
|
||||||
## Changes from xcompmgr:
|
## Changes from xcompmgr:
|
||||||
|
|
||||||
* __inactive window transparency__ (specified with `-i`)
|
* __inactive window transparency__ (specified with `-i`)
|
||||||
|
* __titlebar/frame transparency__ (specified with `-e`)
|
||||||
* shadows are now enabled for argb windows, e.g. terminals with transparency
|
* shadows are now enabled for argb windows, e.g. terminals with transparency
|
||||||
* removed serverside shadows (and simple compositing) to clean the code,
|
* removed serverside shadows (and simple compositing) to clean the code,
|
||||||
the only option that remains is clientside shadows
|
the only option that remains is clientside shadows
|
||||||
* titlebar transparency (and possibly border transparency) is on the way
|
|
||||||
* menu transparency (thanks to Dana)
|
* menu transparency (thanks to Dana)
|
||||||
|
|
||||||
|
The above features give compton a feature set similar to the xfce compositor.
|
||||||
|
|
||||||
|
Compton has only been tested with openbox so far, but frame transparency
|
||||||
|
should work with any window manager that properly sets `_NET_FRAME_EXTENTS`.
|
||||||
|
|
||||||
## Fixes from the original xcompmgr:
|
## Fixes from the original xcompmgr:
|
||||||
|
|
||||||
* fixed a segfault when opening certain window types
|
* fixed a segfault when opening certain window types
|
||||||
|
@ -64,7 +69,8 @@ The above will produce a single binary.
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
$ xcompmgr -cC -t -5 -l -5 -r 5 -o 0.5 -fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i &
|
$ xcompmgr -cC -t -5 -l -5 -r 5 -o 0.4 \
|
||||||
|
-fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i 0.6 -e 0.6 &
|
||||||
|
|
||||||
$ xcompmgr -cC -t -5 -l -5 -r 5 -o 0.5 -i &
|
$ xcompmgr -cC -t -5 -l -5 -r 5 -o 0.4 -i 0.6 -e 0.6 &
|
||||||
```
|
```
|
||||||
|
|
64
xcompmgr.c
64
xcompmgr.c
|
@ -101,7 +101,10 @@ typedef struct _win {
|
||||||
wintype window_type;
|
wintype window_type;
|
||||||
unsigned long damage_sequence; /* sequence when damage was created */
|
unsigned long damage_sequence; /* sequence when damage was created */
|
||||||
Bool destroyed;
|
Bool destroyed;
|
||||||
|
unsigned int left_width;
|
||||||
|
unsigned int right_width;
|
||||||
unsigned int top_width;
|
unsigned int top_width;
|
||||||
|
unsigned int bottom_width;
|
||||||
|
|
||||||
Bool need_configure;
|
Bool need_configure;
|
||||||
XConfigureEvent queue_configure;
|
XConfigureEvent queue_configure;
|
||||||
|
@ -977,7 +980,8 @@ find_client_win(Display *dpy, Window win) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_frame_extents(Display *dpy, Window w, int *top) {
|
get_frame_extents(Display *dpy, Window w,
|
||||||
|
int *left, int *right, int *top, int *bottom) {
|
||||||
long *extents;
|
long *extents;
|
||||||
Atom type;
|
Atom type;
|
||||||
int format;
|
int format;
|
||||||
|
@ -985,7 +989,10 @@ get_frame_extents(Display *dpy, Window w, int *top) {
|
||||||
unsigned char *data = NULL;
|
unsigned char *data = NULL;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
*left = 0;
|
||||||
|
*right = 0;
|
||||||
*top = 0;
|
*top = 0;
|
||||||
|
*bottom = 0;
|
||||||
|
|
||||||
w = find_client_win(dpy, w);
|
w = find_client_win(dpy, w);
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
|
@ -999,7 +1006,10 @@ get_frame_extents(Display *dpy, Window w, int *top) {
|
||||||
if (result == Success) {
|
if (result == Success) {
|
||||||
if (nitems == 4 && after == 0) {
|
if (nitems == 4 && after == 0) {
|
||||||
extents = (long *)data;
|
extents = (long *)data;
|
||||||
|
*left = (int) *extents;
|
||||||
|
*right = (int) *(extents + 1);
|
||||||
*top = (int) *(extents + 2);
|
*top = (int) *(extents + 2);
|
||||||
|
*bottom = (int) *(extents + 3);
|
||||||
}
|
}
|
||||||
XFree(data);
|
XFree(data);
|
||||||
}
|
}
|
||||||
|
@ -1202,15 +1212,36 @@ 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;
|
||||||
/* transparent title bar */
|
unsigned int l = w->left_width;
|
||||||
|
unsigned int b = w->bottom_width;
|
||||||
|
unsigned int r = w->right_width;
|
||||||
|
|
||||||
|
/* top */
|
||||||
XRenderComposite(
|
XRenderComposite(
|
||||||
dpy, PictOpOver, w->picture, w->alpha_border_pict,
|
dpy, PictOpOver, w->picture, w->alpha_border_pict, root_buffer,
|
||||||
root_buffer, 0, 0, 0, 0, x, y, wid, t);
|
0, 0, 0, 0, x, y, wid, t);
|
||||||
/* rest of the window */
|
|
||||||
|
/* left */
|
||||||
XRenderComposite(
|
XRenderComposite(
|
||||||
dpy, PictOpOver, w->picture, w->alpha_pict,
|
dpy, PictOpOver, w->picture, w->alpha_border_pict, root_buffer,
|
||||||
root_buffer, 0, t, 0, t, x, y + t, wid, hei - t);
|
0, t, 0, t, x, y + t, l, hei - t);
|
||||||
|
|
||||||
|
/* bottom */
|
||||||
|
XRenderComposite(
|
||||||
|
dpy, PictOpOver, w->picture, w->alpha_border_pict, root_buffer,
|
||||||
|
l, hei - b, l, hei - b, x + l, y + hei - b, wid - l - r, b);
|
||||||
|
|
||||||
|
/* right */
|
||||||
|
XRenderComposite(
|
||||||
|
dpy, PictOpOver, w->picture, w->alpha_border_pict, root_buffer,
|
||||||
|
wid - r, t, wid - r, t, x + wid - r, y + t, r, hei - t);
|
||||||
|
|
||||||
|
/* body */
|
||||||
|
XRenderComposite(
|
||||||
|
dpy, PictOpOver, w->picture, w->alpha_pict, root_buffer,
|
||||||
|
l, t, l, t, x + l, y + t, wid - l - r, hei - t - b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1664,8 +1695,12 @@ add_win(Display *dpy, Window id, Window prev) {
|
||||||
new->next = *p;
|
new->next = *p;
|
||||||
*p = new;
|
*p = new;
|
||||||
|
|
||||||
|
new->left_width = 0;
|
||||||
|
new->right_width = 0;
|
||||||
new->top_width = 0;
|
new->top_width = 0;
|
||||||
get_frame_extents(dpy, id, &new->top_width);
|
new->bottom_width = 0;
|
||||||
|
get_frame_extents(dpy, id,
|
||||||
|
&new->left_width, &new->right_width, &new->top_width, &new->bottom_width);
|
||||||
|
|
||||||
if (new->a.map_state == IsViewable) {
|
if (new->a.map_state == IsViewable) {
|
||||||
new->window_type = determine_wintype(dpy, id, id);
|
new->window_type = determine_wintype(dpy, id, id);
|
||||||
|
@ -2113,6 +2148,9 @@ usage(char *program) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -i opacity\n "
|
" -i opacity\n "
|
||||||
"Opacity of inactive windows. (0.1 - 1.0)\n");
|
"Opacity of inactive windows. (0.1 - 1.0)\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" -e opacity\n "
|
||||||
|
"Opacity of window titlebars and borders. (0.1 - 1.0)\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -S\n "
|
" -S\n "
|
||||||
"Enable synchronous operation (for debugging).\n");
|
"Enable synchronous operation (for debugging).\n");
|
||||||
|
@ -2181,7 +2219,7 @@ main(int argc, char **argv) {
|
||||||
/* don't bother to draw a shadow for the desktop */
|
/* don't bother to draw a shadow for the desktop */
|
||||||
win_type_shadow[WINTYPE_DESKTOP] = False;
|
win_type_shadow[WINTYPE_DESKTOP] = False;
|
||||||
|
|
||||||
while ((o = getopt(argc, argv, "D:I:O:d:r:o:m:l:t:i:z:scnfFCaS")) != -1) {
|
while ((o = getopt(argc, argv, "D:I:O:d:r:o:m:l:t:i:e:scnfFCaS")) != -1) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'd':
|
case 'd':
|
||||||
display = optarg;
|
display = optarg;
|
||||||
|
@ -2236,13 +2274,8 @@ main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
inactive_opacity = (double)atof(optarg);
|
inactive_opacity = (double)atof(optarg);
|
||||||
if (inactive_opacity < 0.1
|
|
||||||
|| inactive_opacity > 1.0) {
|
|
||||||
fprintf(stderr, "Opacity must be 0.1 - 1.0.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'e':
|
||||||
frame_opacity = (double)atof(optarg);
|
frame_opacity = (double)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
@ -2423,6 +2456,7 @@ main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CreateNotify:
|
case CreateNotify:
|
||||||
|
//if (ev.xcreatewindow.override_redirect) break;
|
||||||
add_win(dpy, ev.xcreatewindow.window, 0);
|
add_win(dpy, ev.xcreatewindow.window, 0);
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
|
|
Loading…
Reference in a new issue