*add* more real_transparency things added... whole panel works now, but systray still has problems :(

git-svn-id: http://tint2.googlecode.com/svn/trunk@306 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
Andreas.Fink85 2009-12-30 16:25:19 +00:00
parent c65ad3628d
commit 7478765723
5 changed files with 47 additions and 13 deletions

View file

@ -160,6 +160,13 @@ void init_panel()
XMoveResizeWindow(server.dsp, p->main_win, p->posx, p->posy, p->area.width, p->area.height);
}
if (!server.gc) {
XGCValues gcv;
if (real_transparency)
server.gc = XCreateGC(server.dsp, p->main_win, 0, &gcv);
else
server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv);
}
//printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
set_panel_properties(p);
set_panel_background(p);
@ -479,11 +486,23 @@ void set_panel_properties(Panel *p)
void set_panel_background(Panel *p)
{
get_root_pixmap();
if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap);
p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
if (real_transparency) {
cairo_surface_t *tmp = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height);
cairo_t *cr = cairo_create(tmp);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_rectangle(cr, 0, 0, p->area.width, p->area.height);
cairo_set_source_rgba(cr, 1, 1, 1, 0);
cairo_paint (cr);
cairo_destroy (cr);
cairo_surface_destroy (tmp);
return;
}
get_root_pixmap();
// copy background (server.root_pmap) in panel.area.pix.pmap
Window dummy;
int x, y;

View file

@ -32,6 +32,7 @@ void server_catch_error (Display *d, XErrorEvent *ev){}
static char *name_trayer = 0;
int real_transparency = 0;
void server_init_atoms ()
{
@ -97,6 +98,8 @@ void cleanup_server()
{
if (name_trayer) free(name_trayer);
XFreeColormap(server.dsp, server.colormap);
free(server.monitor);
XFreeGC(server.dsp, server.gc);
}
@ -304,7 +307,6 @@ void get_desktops()
void server_init_visual()
{
int real_transparency = 0;
XVisualInfo *xvi;
XVisualInfo templ = { .screen=server.screen, .depth=32, .class=TrueColor };
int nvi;
@ -325,8 +327,8 @@ void server_init_visual()
XFree (xvi);
if (visual && real_transparency) {
printf("real transparency on... depth: %d\n", server.depth);
server.depth = 32;
printf("real transparency on... depth: %d\n", server.depth);
server.colormap = XCreateColormap(server.dsp, server.root_win, visual, AllocNone);
server.visual = visual;
}

View file

@ -13,7 +13,7 @@
#include <X11/Xatom.h>
#include <X11/extensions/Xinerama.h>
extern int real_transparency;
typedef struct Global_atom
{
Atom _XROOTPMAP_ID;
@ -112,6 +112,7 @@ void server_refresh_main_pixmap ();
void server_catch_error (Display *d, XErrorEvent *ev);
void server_init_atoms ();
void server_init_visual();
void cleanup_server();
// detect root background
void get_root_pixmap();

View file

@ -102,8 +102,6 @@ void init (int argc, char *argv[])
server.screen = DefaultScreen (server.dsp);
server.root_win = RootWindow(server.dsp, server.screen);
server.desktop = server_get_current_desktop ();
XGCValues gcv;
server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv);
server_init_visual();
XSetErrorHandler ((XErrorHandler) server_catch_error);
@ -151,8 +149,7 @@ void cleanup()
if (config_path) g_free(config_path);
if (snapshot_path) g_free(snapshot_path);
if (server.monitor) free(server.monitor);
XFreeGC(server.dsp, server.gc);
cleanup_server();
XCloseDisplay(server.dsp);
}

View file

@ -29,6 +29,10 @@
#include "server.h"
#include "panel.h"
// QUESTION: Why do we need Pixmaps for drawing? Can't we draw directly in the Window???
// Parent could pass a cairo_surface_t to the children, and children use it, for drawing...
// 1) resize child
// 2) resize parent
// 3) redraw parent
@ -55,9 +59,9 @@ void refresh (Area *a)
}
// draw current Area
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
if (*pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
Pixmap pmap = (a->is_active == 0) ? (a->pix.pmap) : (a->pix_active.pmap);
if (pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
XCopyArea (server.dsp, pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
// and then refresh child object
GSList *l;
@ -104,7 +108,18 @@ void draw (Area *a, int active)
*pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
// add layer of root pixmap
XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
if (real_transparency) {
cairo_surface_t *tmp = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height);
cairo_t *cr = cairo_create(tmp);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_rectangle(cr, 0, 0, a->width, a->height);
cairo_set_source_rgba(cr, 1, 1, 1, 0);
cairo_paint (cr);
cairo_destroy (cr);
cairo_surface_destroy (tmp);
}
else
XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
cairo_surface_t *cs;
cairo_t *c;