Disable systray composited rendering if disable_transparency = 1

This commit is contained in:
o9000 2015-06-07 11:44:43 +02:00
parent b235f77f39
commit fbcfa54061
2 changed files with 148 additions and 145 deletions

View file

@ -41,8 +41,6 @@ GSList *icons;
#define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_BEGIN_MESSAGE 1
#define SYSTEM_TRAY_CANCEL_MESSAGE 2 #define SYSTEM_TRAY_CANCEL_MESSAGE 2
#define FORCE_COMPOSITED_RENDERING 1
// selection window // selection window
Window net_sel_win = None; Window net_sel_win = None;
@ -53,6 +51,7 @@ int systray_enabled;
int systray_max_icon_size; int systray_max_icon_size;
int systray_monitor; int systray_monitor;
int chrono; int chrono;
int systray_composited;
// background pixmap if we render ourselves the icons // background pixmap if we render ourselves the icons
static Pixmap render_background; static Pixmap render_background;
@ -86,16 +85,19 @@ void cleanup_systray()
void init_systray() void init_systray()
{ {
start_net();
if (!systray_enabled) if (!systray_enabled)
return; return;
if (!server.visual32 && (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)) { systray_composited = !server.disable_transparency && server.visual32;
printf("No 32 bit visual for your X implementation. 'systray_asb = 100 0 0' will be forced\n"); printf("Systray composited rendering %s\n", systray_composited ? "on" : "off");
if (!systray_composited) {
printf("systray_asb forced to 100 0 0\n");
systray.alpha = 100; systray.alpha = 100;
systray.brightness = systray.saturation = 0; systray.brightness = systray.saturation = 0;
} }
start_net();
} }
@ -115,7 +117,7 @@ void init_systray_panel(void *p)
} }
if (count == 0) if (count == 0)
hide(&systray.area); hide(&systray.area);
else else
show(&systray.area); show(&systray.area);
refresh_systray = 0; refresh_systray = 0;
} }
@ -123,7 +125,7 @@ void init_systray_panel(void *p)
void draw_systray(void *obj, cairo_t *c) void draw_systray(void *obj, cairo_t *c)
{ {
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (systray_composited) {
if (render_background) XFreePixmap(server.dsp, render_background); if (render_background) XFreePixmap(server.dsp, render_background);
render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth); render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0); XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0);
@ -202,7 +204,7 @@ void on_change_systray (void *obj)
traywin->y = posy; traywin->y = posy;
traywin->x = posx; traywin->x = posx;
// printf("systray %d : pos %d, %d\n", traywin->tray_id, posx, posy); // printf("systray %d %d : pos %d, %d\n", traywin->id, traywin->tray_id, posx, posy);
traywin->width = sysbar->icon_size; traywin->width = sysbar->icon_size;
traywin->height = sysbar->icon_size; traywin->height = sysbar->icon_size;
if (panel_horizontal) { if (panel_horizontal) {
@ -223,9 +225,10 @@ void on_change_systray (void *obj)
} }
// position and size the icon window // position and size the icon window
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size); XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size); XMoveResizeWindow(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height);
} }
refresh_systray = 1;
} }
@ -277,7 +280,7 @@ void start_net()
long orient = 0; long orient = 0;
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1); XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1);
VisualID vid; VisualID vid;
if (server.visual32 && (FORCE_COMPOSITED_RENDERING || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)) if (systray_composited)
vid = XVisualIDFromVisual(server.visual32); vid = XVisualIDFromVisual(server.visual32);
else else
vid = XVisualIDFromVisual(server.visual); vid = XVisualIDFromVisual(server.visual);
@ -427,7 +430,7 @@ gboolean add_icon(Window id)
Visual* visual = server.visual; Visual* visual = server.visual;
//printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height); //printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height);
//printf("icon with depth: %d\n", attr.depth); //printf("icon with depth: %d\n", attr.depth);
if (attr.depth != server.depth || FORCE_COMPOSITED_RENDERING || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (systray_composited || attr.depth != server.depth) {
visual = attr.visual; visual = attr.visual;
set_attr.colormap = attr.colormap; set_attr.colormap = attr.colormap;
set_attr.background_pixel = 0; set_attr.background_pixel = 0;
@ -438,8 +441,7 @@ gboolean add_icon(Window id)
set_attr.background_pixmap = ParentRelative; set_attr.background_pixmap = ParentRelative;
mask = CWBackPixmap; mask = CWBackPixmap;
} }
Window parent_window; Window parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr);
parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr);
old = XSetErrorHandler(window_error_handler); old = XSetErrorHandler(window_error_handler);
XReparentWindow(server.dsp, id, parent_window, 0, 0); XReparentWindow(server.dsp, id, parent_window, 0, 0);
// watch for the icon trying to resize itself / closing again! // watch for the icon trying to resize itself / closing again!
@ -512,7 +514,7 @@ gboolean add_icon(Window id)
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows); systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
//printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons)); //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (systray_composited) {
traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles); traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles);
XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual); XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual);
} }
@ -564,7 +566,7 @@ void remove_icon(TrayWindow *traywin)
} }
if (count == 0) if (count == 0)
hide(&systray.area); hide(&systray.area);
// changed in systray // changed in systray
systray.area.resize = 1; systray.area.resize = 1;
panel_refresh = 1; panel_refresh = 1;
@ -578,22 +580,22 @@ void net_message(XClientMessageEvent *e)
opcode = e->data.l[1]; opcode = e->data.l[1];
switch (opcode) { switch (opcode) {
case SYSTEM_TRAY_REQUEST_DOCK: case SYSTEM_TRAY_REQUEST_DOCK:
id = e->data.l[2]; id = e->data.l[2];
if (id) add_icon(id); if (id) add_icon(id);
break; break;
case SYSTEM_TRAY_BEGIN_MESSAGE: case SYSTEM_TRAY_BEGIN_MESSAGE:
case SYSTEM_TRAY_CANCEL_MESSAGE: case SYSTEM_TRAY_CANCEL_MESSAGE:
// we don't show baloons messages. // we don't show baloons messages.
break; break;
default: default:
if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA) if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA)
printf("message from dockapp: %s\n", e->data.b); printf("message from dockapp: %s\n", e->data.b);
else else
fprintf(stderr, "SYSTEM_TRAY : unknown message type\n"); fprintf(stderr, "SYSTEM_TRAY : unknown message type\n");
break; break;
} }
} }
@ -603,16 +605,16 @@ void systray_render_icon_now(void* t)
// we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here // we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here
TrayWindow* traywin = t; TrayWindow* traywin = t;
// wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms // wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
struct timespec earliest_render = add_msec_to_timespec(traywin->time_last_render, 50); struct timespec earliest_render = add_msec_to_timespec(traywin->time_last_render, 50);
if (compare_timespecs(&earliest_render, &now) > 0) { if (compare_timespecs(&earliest_render, &now) > 0) {
traywin->render_timeout = add_timeout(50, 0, systray_render_icon_now, traywin, &traywin->render_timeout); traywin->render_timeout = add_timeout(50, 0, systray_render_icon_now, traywin, &traywin->render_timeout);
return; return;
} }
traywin->time_last_render.tv_sec = now.tv_sec; traywin->time_last_render.tv_sec = now.tv_sec;
traywin->time_last_render.tv_nsec = now.tv_nsec; traywin->time_last_render.tv_nsec = now.tv_nsec;
if ( traywin->width == 0 || traywin->height == 0 ) { if ( traywin->width == 0 || traywin->height == 0 ) {
// reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu) // reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu)
@ -620,10 +622,10 @@ void systray_render_icon_now(void* t)
return; return;
} }
if (traywin->render_timeout) { if (traywin->render_timeout) {
stop_timeout(traywin->render_timeout); stop_timeout(traywin->render_timeout);
traywin->render_timeout = NULL; traywin->render_timeout = NULL;
} }
int empty = 1; int empty = 1;
XImage *ximage = XGetImage(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, AllPlanes, XYPixmap); XImage *ximage = XGetImage(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, AllPlanes, XYPixmap);
@ -669,7 +671,7 @@ void systray_render_icon_now(void* t)
} }
Picture pict_image; Picture pict_image;
//if (server.real_transparency) //if (server.real_transparency)
//pict_image = XRenderCreatePicture(server.dsp, traywin->id, f, 0, 0); //pict_image = XRenderCreatePicture(server.dsp, traywin->id, f, 0, 0);
// reverted Rev 407 because here it's breaking alls icon with systray + xcompmgr // reverted Rev 407 because here it's breaking alls icon with systray + xcompmgr
pict_image = XRenderCreatePicture(server.dsp, traywin->tray_id, f, 0, 0); pict_image = XRenderCreatePicture(server.dsp, traywin->tray_id, f, 0, 0);
Picture pict_drawable = XRenderCreatePicture(server.dsp, tmp_pmap, XRenderFindVisualFormat(server.dsp, server.visual32), 0, 0); Picture pict_drawable = XRenderCreatePicture(server.dsp, tmp_pmap, XRenderFindVisualFormat(server.dsp, server.visual32), 0, 0);
@ -687,7 +689,7 @@ void systray_render_icon_now(void* t)
imlib_context_set_image(image); imlib_context_set_image(image);
//if (traywin->depth == 24) //if (traywin->depth == 24)
//imlib_save_image("/home/thil77/test.jpg"); //imlib_save_image("/home/thil77/test.jpg");
imlib_image_set_has_alpha(1); imlib_image_set_has_alpha(1);
DATA32* data = imlib_image_get_data(); DATA32* data = imlib_image_get_data();
if (traywin->depth == 24) { if (traywin->depth == 24) {
@ -712,14 +714,14 @@ void systray_render_icon_now(void* t)
void systray_render_icon(TrayWindow* traywin) void systray_render_icon(TrayWindow* traywin)
{ {
if (FORCE_COMPOSITED_RENDERING || server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (systray_composited) {
if (!traywin->render_timeout) if (!traywin->render_timeout)
systray_render_icon_now(traywin); systray_render_icon_now(traywin);
} }
else { else {
// Pixmap pix = XCreatePixmap(server.dsp, server.root_win, traywin->width, traywin->height, server.depth); // Pixmap pix = XCreatePixmap(server.dsp, server.root_win, traywin->width, traywin->height, server.depth);
// XCopyArea(server.dsp, panel->temp_pmap, pix, server.gc, traywin->x, traywin->y, traywin->width, traywin->height, 0, 0); // XCopyArea(server.dsp, panel->temp_pmap, pix, server.gc, traywin->x, traywin->y, traywin->width, traywin->height, 0, 0);
// XSetWindowBackgroundPixmap(server.dsp, traywin->id, pix); // XSetWindowBackgroundPixmap(server.dsp, traywin->id, pix);
XClearArea(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, True); XClearArea(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, True);
} }
} }

View file

@ -117,12 +117,12 @@ void init (int argc, char *argv[])
// BSD does not support pselect(), therefore we have to use select and hope that we do not // BSD does not support pselect(), therefore we have to use select and hope that we do not
// end up in a race condition there (see 'man select()' on a linux machine for more information) // end up in a race condition there (see 'man select()' on a linux machine for more information)
// block all signals, such that no race conditions occur before pselect in our main loop // block all signals, such that no race conditions occur before pselect in our main loop
// sigset_t block_mask; // sigset_t block_mask;
// sigaddset(&block_mask, SIGINT); // sigaddset(&block_mask, SIGINT);
// sigaddset(&block_mask, SIGTERM); // sigaddset(&block_mask, SIGTERM);
// sigaddset(&block_mask, SIGHUP); // sigaddset(&block_mask, SIGHUP);
// sigaddset(&block_mask, SIGUSR1); // sigaddset(&block_mask, SIGUSR1);
// sigprocmask(SIG_BLOCK, &block_mask, 0); // sigprocmask(SIG_BLOCK, &block_mask, 0);
} }
static int sn_pipe_valid = 0; static int sn_pipe_valid = 0;
@ -241,7 +241,7 @@ void init_X11_post_config()
/* Catch events */ /* Catch events */
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
// load default icon // load default icon
gchar *path; gchar *path;
const gchar * const *data_dirs; const gchar * const *data_dirs;
@ -323,60 +323,60 @@ void window_action (Task *tsk, int action)
if (!tsk) return; if (!tsk) return;
int desk; int desk;
switch (action) { switch (action) {
case CLOSE: case CLOSE:
set_close (tsk->win); set_close (tsk->win);
break; break;
case TOGGLE: case TOGGLE:
set_active(tsk->win); set_active(tsk->win);
break; break;
case ICONIFY: case ICONIFY:
XIconifyWindow (server.dsp, tsk->win, server.screen);
break;
case TOGGLE_ICONIFY:
if (task_active && tsk->win == task_active->win)
XIconifyWindow (server.dsp, tsk->win, server.screen); XIconifyWindow (server.dsp, tsk->win, server.screen);
break; else
case TOGGLE_ICONIFY: set_active (tsk->win);
if (task_active && tsk->win == task_active->win) break;
XIconifyWindow (server.dsp, tsk->win, server.screen); case SHADE:
else window_toggle_shade (tsk->win);
set_active (tsk->win); break;
break; case MAXIMIZE_RESTORE:
case SHADE: window_maximize_restore (tsk->win);
window_toggle_shade (tsk->win); break;
break; case MAXIMIZE:
case MAXIMIZE_RESTORE: window_maximize_restore (tsk->win);
window_maximize_restore (tsk->win); break;
break; case RESTORE:
case MAXIMIZE: window_maximize_restore (tsk->win);
window_maximize_restore (tsk->win); break;
break; case DESKTOP_LEFT:
case RESTORE: if ( tsk->desktop == 0 ) break;
window_maximize_restore (tsk->win); desk = tsk->desktop - 1;
break; windows_set_desktop(tsk->win, desk);
case DESKTOP_LEFT: if (desk == server.desktop)
if ( tsk->desktop == 0 ) break; set_active(tsk->win);
desk = tsk->desktop - 1; break;
windows_set_desktop(tsk->win, desk); case DESKTOP_RIGHT:
if (desk == server.desktop) if (tsk->desktop == server.nb_desktop ) break;
set_active(tsk->win); desk = tsk->desktop + 1;
break; windows_set_desktop(tsk->win, desk);
case DESKTOP_RIGHT: if (desk == server.desktop)
if (tsk->desktop == server.nb_desktop ) break; set_active(tsk->win);
desk = tsk->desktop + 1; break;
windows_set_desktop(tsk->win, desk); case NEXT_TASK:
if (desk == server.desktop) {
set_active(tsk->win); Task *tsk1;
break; tsk1 = next_task(find_active_task(tsk, task_active));
case NEXT_TASK: set_active(tsk1->win);
{ }
Task *tsk1; break;
tsk1 = next_task(find_active_task(tsk, task_active)); case PREV_TASK:
set_active(tsk1->win); {
} Task *tsk1;
break; tsk1 = prev_task(find_active_task(tsk, task_active));
case PREV_TASK: set_active(tsk1->win);
{ }
Task *tsk1;
tsk1 = prev_task(find_active_task(tsk, task_active));
set_active(tsk1->win);
}
} }
} }
@ -386,10 +386,10 @@ int tint2_handles_click(Panel* panel, XButtonEvent* e)
Task* task = click_task(panel, e->x, e->y); Task* task = click_task(panel, e->x, e->y);
if (task) { if (task) {
if( (e->button == 1 && mouse_left != 0) if( (e->button == 1 && mouse_left != 0)
|| (e->button == 2 && mouse_middle != 0) || (e->button == 2 && mouse_middle != 0)
|| (e->button == 3 && mouse_right != 0) || (e->button == 3 && mouse_right != 0)
|| (e->button == 4 && mouse_scroll_up != 0) || (e->button == 4 && mouse_scroll_up != 0)
|| (e->button == 5 && mouse_scroll_down !=0) ) || (e->button == 5 && mouse_scroll_down !=0) )
{ {
return 1; return 1;
} }
@ -530,27 +530,27 @@ void event_button_release (XEvent *e)
int action = TOGGLE_ICONIFY; int action = TOGGLE_ICONIFY;
switch (e->xbutton.button) { switch (e->xbutton.button) {
case 1: case 1:
action = mouse_left; action = mouse_left;
break; break;
case 2: case 2:
action = mouse_middle; action = mouse_middle;
break; break;
case 3: case 3:
action = mouse_right; action = mouse_right;
break; break;
case 4: case 4:
action = mouse_scroll_up; action = mouse_scroll_up;
break; break;
case 5: case 5:
action = mouse_scroll_down; action = mouse_scroll_down;
break; break;
case 6: case 6:
action = mouse_tilt_left; action = mouse_tilt_left;
break; break;
case 7: case 7:
action = mouse_tilt_right; action = mouse_tilt_right;
break; break;
} }
if ( click_clock(panel, e->xbutton.x, e->xbutton.y)) { if ( click_clock(panel, e->xbutton.x, e->xbutton.y)) {
@ -834,8 +834,9 @@ void event_configure_notify (Window win)
if (traywin->tray_id == win) { if (traywin->tray_id == win) {
//printf("move tray %d\n", traywin->x); //printf("move tray %d\n", traywin->x);
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height); XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
XResizeWindow(server.dsp, traywin->tray_id, traywin->width, traywin->height); XMoveResizeWindow(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height);
panel_refresh = 1; panel_refresh = 1;
refresh_systray = 1;
return; return;
} }
} }
@ -895,8 +896,8 @@ struct Property read_property(Display* disp, Window w, Atom property)
if (ret != 0) if (ret != 0)
XFree(ret); XFree(ret);
XGetWindowProperty(disp, w, property, 0, read_bytes, False, AnyPropertyType, XGetWindowProperty(disp, w, property, 0, read_bytes, False, AnyPropertyType,
&actual_type, &actual_format, &nitems, &bytes_after, &actual_type, &actual_format, &nitems, &bytes_after,
&ret); &ret);
read_bytes *= 2; read_bytes *= 2;
} while (bytes_after != 0); } while (bytes_after != 0);
@ -1126,8 +1127,8 @@ start:
dnd_sent_request = 0; dnd_sent_request = 0;
dnd_launcher_exec = 0; dnd_launcher_exec = 0;
// sigset_t empty_mask; // sigset_t empty_mask;
// sigemptyset(&empty_mask); // sigemptyset(&empty_mask);
while (1) { while (1) {
if (panel_refresh) { if (panel_refresh) {
@ -1269,7 +1270,7 @@ start:
break; break;
for (it = systray.list_icons; it; it = g_slist_next(it)) { for (it = systray.list_icons; it; it = g_slist_next(it)) {
if (((TrayWindow*)it->data)->tray_id == e.xany.window) { if (((TrayWindow*)it->data)->tray_id == e.xany.window) {
remove_icon((TrayWindow*)it->data); remove_icon((TrayWindow*)it->data);
break; break;
} }
} }
@ -1414,7 +1415,7 @@ start:
for (l = systray.list_icons; l ; l = l->next) { for (l = systray.list_icons; l ; l = l->next) {
traywin = (TrayWindow*)l->data; traywin = (TrayWindow*)l->data;
if ( traywin->id == de->drawable ) { if ( traywin->id == de->drawable ) {
systray_render_icon(traywin); systray_render_icon(traywin);
break; break;
} }
} }