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_CANCEL_MESSAGE 2
#define FORCE_COMPOSITED_RENDERING 1
// selection window
Window net_sel_win = None;
@ -53,6 +51,7 @@ int systray_enabled;
int systray_max_icon_size;
int systray_monitor;
int chrono;
int systray_composited;
// background pixmap if we render ourselves the icons
static Pixmap render_background;
@ -86,16 +85,19 @@ void cleanup_systray()
void init_systray()
{
start_net();
if (!systray_enabled)
return;
if (!server.visual32 && (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)) {
printf("No 32 bit visual for your X implementation. 'systray_asb = 100 0 0' will be forced\n");
systray_composited = !server.disable_transparency && server.visual32;
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.brightness = systray.saturation = 0;
}
start_net();
}
@ -123,7 +125,7 @@ void init_systray_panel(void *p)
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);
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);
@ -202,7 +204,7 @@ void on_change_systray (void *obj)
traywin->y = posy;
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->height = sysbar->icon_size;
if (panel_horizontal) {
@ -223,9 +225,10 @@ void on_change_systray (void *obj)
}
// position and size the icon window
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size);
XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size);
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
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;
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1);
VisualID vid;
if (server.visual32 && (FORCE_COMPOSITED_RENDERING || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0))
if (systray_composited)
vid = XVisualIDFromVisual(server.visual32);
else
vid = XVisualIDFromVisual(server.visual);
@ -427,7 +430,7 @@ gboolean add_icon(Window id)
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\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;
set_attr.colormap = attr.colormap;
set_attr.background_pixel = 0;
@ -438,8 +441,7 @@ gboolean add_icon(Window id)
set_attr.background_pixmap = ParentRelative;
mask = CWBackPixmap;
}
Window parent_window;
parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr);
Window 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);
XReparentWindow(server.dsp, id, parent_window, 0, 0);
// 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);
//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);
XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual);
}
@ -712,7 +714,7 @@ void systray_render_icon_now(void* t)
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)
systray_render_icon_now(traywin);
}

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
// 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
// sigset_t block_mask;
// sigaddset(&block_mask, SIGINT);
// sigaddset(&block_mask, SIGTERM);
// sigaddset(&block_mask, SIGHUP);
// sigaddset(&block_mask, SIGUSR1);
// sigprocmask(SIG_BLOCK, &block_mask, 0);
// sigset_t block_mask;
// sigaddset(&block_mask, SIGINT);
// sigaddset(&block_mask, SIGTERM);
// sigaddset(&block_mask, SIGHUP);
// sigaddset(&block_mask, SIGUSR1);
// sigprocmask(SIG_BLOCK, &block_mask, 0);
}
static int sn_pipe_valid = 0;
@ -834,8 +834,9 @@ void event_configure_notify (Window win)
if (traywin->tray_id == win) {
//printf("move tray %d\n", traywin->x);
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;
refresh_systray = 1;
return;
}
}
@ -1126,8 +1127,8 @@ start:
dnd_sent_request = 0;
dnd_launcher_exec = 0;
// sigset_t empty_mask;
// sigemptyset(&empty_mask);
// sigset_t empty_mask;
// sigemptyset(&empty_mask);
while (1) {
if (panel_refresh) {