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);
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;
static char *name_trayer = 0;
+int real_transparency = 0;
void server_init_atoms ()
{
{
if (name_trayer) free(name_trayer);
XFreeColormap(server.dsp, server.colormap);
+ free(server.monitor);
+ XFreeGC(server.dsp, server.gc);
}
void server_init_visual()
{
- int real_transparency = 0;
XVisualInfo *xvi;
XVisualInfo templ = { .screen=server.screen, .depth=32, .class=TrueColor };
int nvi;
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;
}
#include <X11/Xatom.h>
#include <X11/extensions/Xinerama.h>
-
+extern int real_transparency;
typedef struct Global_atom
{
Atom _XROOTPMAP_ID;
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();
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);
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);
}
#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
}
// 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;
*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;