fixed decorated window with compiz
git-svn-id: http://tint2.googlecode.com/svn/trunk@22 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
103
src/util/area.c
103
src/util/area.c
@@ -30,52 +30,59 @@
|
||||
#include "area.h"
|
||||
|
||||
|
||||
void redraw (Area *a)
|
||||
void refresh (Area *a)
|
||||
{
|
||||
a->redraw = 1;
|
||||
|
||||
GSList *l;
|
||||
for (l = a->list ; l ; l = l->next)
|
||||
redraw(l->data);
|
||||
}
|
||||
|
||||
|
||||
int draw (Area *a)
|
||||
{
|
||||
cairo_surface_t *cs;
|
||||
cairo_t *c;
|
||||
int ret = 0;
|
||||
|
||||
if (a->redraw) {
|
||||
//printf("begin draw area\n");
|
||||
if (a->pmap) XFreePixmap (server.dsp, a->pmap);
|
||||
a->pmap = server_create_pixmap (a->width, a->height);
|
||||
|
||||
// add layer of root pixmap
|
||||
XCopyArea (server.dsp, server.pmap, a->pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
||||
|
||||
cs = cairo_xlib_surface_create (server.dsp, a->pmap, server.visual, a->width, a->height);
|
||||
c = cairo_create (cs);
|
||||
|
||||
draw_background (a, c);
|
||||
|
||||
if (a->draw_foreground)
|
||||
ret = a->draw_foreground(a, c);
|
||||
|
||||
cairo_destroy (c);
|
||||
cairo_surface_destroy (cs);
|
||||
a->redraw = 0;
|
||||
if (a->draw)
|
||||
a->draw(a);
|
||||
else
|
||||
draw(a);
|
||||
}
|
||||
|
||||
XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
|
||||
|
||||
GSList *l = a->list;
|
||||
// draw child object
|
||||
// refresh child object (after refreshing parent)
|
||||
for (; l ; l = l->next)
|
||||
draw(l->data);
|
||||
refresh(l->data);
|
||||
|
||||
//printf("end draw area\n");
|
||||
return ret;
|
||||
//printf("end refresh area\n");
|
||||
}
|
||||
|
||||
|
||||
void set_redraw (Area *a)
|
||||
{
|
||||
a->redraw = 1;
|
||||
|
||||
GSList *l;
|
||||
for (l = a->list ; l ; l = l->next)
|
||||
set_redraw(l->data);
|
||||
}
|
||||
|
||||
|
||||
void draw (Area *a)
|
||||
{
|
||||
cairo_surface_t *cs;
|
||||
cairo_t *c;
|
||||
|
||||
//printf("begin draw area\n");
|
||||
if (a->pmap) XFreePixmap (server.dsp, a->pmap);
|
||||
a->pmap = server_create_pixmap (a->width, a->height);
|
||||
|
||||
// add layer of root pixmap
|
||||
XCopyArea (server.dsp, server.pmap, a->pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
||||
|
||||
cs = cairo_xlib_surface_create (server.dsp, a->pmap, server.visual, a->width, a->height);
|
||||
c = cairo_create (cs);
|
||||
|
||||
draw_background (a, c);
|
||||
|
||||
if (a->draw_foreground)
|
||||
a->draw_foreground(a, c);
|
||||
|
||||
cairo_destroy (c);
|
||||
cairo_surface_destroy (cs);
|
||||
a->redraw = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,27 +91,9 @@ void draw_background (Area *a, cairo_t *c)
|
||||
if (a->back.alpha > 0.0) {
|
||||
//printf(" draw_background %d %d\n", a->width, a->height);
|
||||
draw_rect(c, a->border.width, a->border.width, a->width-(2.0 * a->border.width), a->height-(2.0*a->border.width), a->border.rounded - a->border.width/1.571);
|
||||
/*
|
||||
double x0, y0, x1, y1;
|
||||
x0 = 0;
|
||||
y0 = 100;
|
||||
x1 = 100;
|
||||
y1 = 0;
|
||||
|
||||
cairo_pattern_t *linpat;
|
||||
cairo_matrix_t matrix;
|
||||
linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
|
||||
|
||||
cairo_pattern_add_color_stop_rgba (linpat, 0, a->back.color[0], a->back.color[1], a->back.color[2], a->back.alpha);
|
||||
cairo_pattern_add_color_stop_rgba (linpat, 1, a->back.color[0], a->back.color[1], a->back.color[2], 0);
|
||||
//cairo_matrix_init_scale (&matrix, a->height, a->width);
|
||||
//cairo_pattern_set_matrix (linpat, &matrix);
|
||||
cairo_set_source (c, linpat);
|
||||
*/
|
||||
cairo_set_source_rgba(c, a->back.color[0], a->back.color[1], a->back.color[2], a->back.alpha);
|
||||
|
||||
cairo_fill(c);
|
||||
//cairo_pattern_destroy (linpat);
|
||||
}
|
||||
|
||||
if (a->border.width > 0 && a->border.alpha > 0.0) {
|
||||
@@ -163,7 +152,7 @@ void remove_area (Area *a)
|
||||
|
||||
parent = (Area*)a->parent;
|
||||
parent->list = g_slist_remove(parent->list, a);
|
||||
redraw (parent);
|
||||
set_redraw (parent);
|
||||
|
||||
}
|
||||
|
||||
@@ -174,7 +163,7 @@ void add_area (Area *a)
|
||||
|
||||
parent = (Area*)a->parent;
|
||||
parent->list = g_slist_remove(parent->list, a);
|
||||
redraw (parent);
|
||||
set_redraw (parent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,60 +5,23 @@
|
||||
* Area is at the begining of each graphical object so &object == &area.
|
||||
*
|
||||
* Area manage the background and border drawing, size and padding.
|
||||
* Area manage also the tree of visible objects
|
||||
* Area also manage the tree of visible objects
|
||||
* panel -> taskbars -> tasks
|
||||
* -> systray -> icons
|
||||
* -> clock
|
||||
*
|
||||
* un objet comprend les actions:
|
||||
* 1) redraw(obj)
|
||||
* force l'indicateur 'redraw' sur l'objet
|
||||
* parcoure la liste des sous objets => redraw(obj)
|
||||
* 2) draw(obj)
|
||||
* dessine le background, dessine le contenu dans pmap
|
||||
* parcoure la liste des sous objets => draw(obj)
|
||||
* le pmap de l'objet se base sur le pmap de l'objet parent (cumul des couches)
|
||||
* 3) draw_background(obj)
|
||||
* dessine le fond dans pmap
|
||||
* 4) draw_foreground(obj) = 0 : fonction virtuelle à redéfinir
|
||||
* dessine le contenu dans pmap
|
||||
* si l'objet n'a pas de contenu, la fonction est nulle
|
||||
* 5) resize_width(obj, width) = 0 : fonction virtuelle à redéfinir
|
||||
* draw_foreground(obj) and draw(obj) are virtual function.
|
||||
*
|
||||
* resize_width(obj, width) = 0 : fonction virtuelle à redéfinir
|
||||
* recalcule la largeur de l'objet (car la hauteur est fixe)
|
||||
* - taille systray calculée à partir de la liste des icones
|
||||
* - taille clock calculée à partir de l'heure
|
||||
* - taille d'une tache calculée à partir de la taskbar (ajout, suppression, taille)
|
||||
* - taille d'une taskbar calculée à partir de la taille du panel et des autres objets
|
||||
* 6) voir refresh(obj)
|
||||
*
|
||||
* Implémentation :
|
||||
* - l'objet est en fait une zone (area).
|
||||
* l'imbrication des sous objet doit permettre de gérer le layout.
|
||||
* - les taches ont 2 objets : l'un pour la tache inactive et l'autre pour la tache active
|
||||
* draw(obj) est appellé sur le premier objet automatiquement
|
||||
* et draw_foreground(obj) lance l'affichage du 2 ieme objet
|
||||
* ainsi la taskbar gère bien une liste d'objets mais draw(obj) dessine les 2 objets
|
||||
* - les fonctions de refresh et de draw sont totalement dissociées
|
||||
*
|
||||
* ----------------------------------------------------
|
||||
* A évaluer :
|
||||
* 1. voir comment définir et gérer le panel_layout avec les objets
|
||||
* => peut on s'affranchir des données spécifiques à chaque objet ?
|
||||
* => comment gérer l'affichage du layout ?
|
||||
* => comment configurer le layout ?
|
||||
* => voir le cumul des couches et l'imbrication entre objet et parent ?
|
||||
* 2. voir la fonction de refresh des objets ??
|
||||
* surtout le refresh des taches qui est différent pour la tache active
|
||||
*
|
||||
* 3. tester l'implémentation et évaluer les autres abstractions possibles ?
|
||||
*
|
||||
* 4. comment gérer le groupage des taches
|
||||
*
|
||||
* voir resize_taskbar(), resize_clock() et resize_tasks()
|
||||
* voir les taches actives et inactives ?? une seule tache est active !
|
||||
* variable widthChanged ou bien emission d'un signal ???
|
||||
*
|
||||
* 6) config(obj) configure un objet (définie les positions verticales)
|
||||
* voir config(obj) configure un objet (définie les positions verticales)
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
@@ -89,38 +52,40 @@ typedef struct
|
||||
|
||||
|
||||
typedef struct {
|
||||
// need redraw Pixmap
|
||||
int redraw;
|
||||
|
||||
int paddingx, paddingy;
|
||||
// TODO: isoler 'draw' de 'refresh'
|
||||
// TODO: isoler les données locales des données communes aux freres
|
||||
// absolute coordinate in panel
|
||||
int posx, posy;
|
||||
int width, height;
|
||||
Pixmap pmap;
|
||||
|
||||
// list of child : Area object
|
||||
GSList *list;
|
||||
|
||||
// need redraw Pixmap
|
||||
int redraw;
|
||||
int paddingx, paddingy;
|
||||
// parent Area
|
||||
void *parent;
|
||||
|
||||
Color back;
|
||||
Border border;
|
||||
|
||||
// absolute coordinate in panel
|
||||
int posx, posy;
|
||||
// parent Area
|
||||
void *parent;
|
||||
|
||||
// pointer to function
|
||||
// draw_foreground : return 1 if width changed, return O otherwise
|
||||
int (*draw_foreground)(void *obj, cairo_t *c);
|
||||
// each object can overwrite following function
|
||||
void (*draw)(void *obj);
|
||||
void (*draw_foreground)(void *obj, cairo_t *c);
|
||||
void (*add_child)(void *obj);
|
||||
int (*remove_child)(void *obj);
|
||||
|
||||
// list of child : Area object
|
||||
GSList *list;
|
||||
int (*remove_child)(void *obj);
|
||||
} Area;
|
||||
|
||||
|
||||
// redraw an area and childs
|
||||
void redraw (Area *a);
|
||||
|
||||
// draw background and foreground
|
||||
// return 1 if width changed, return O otherwise
|
||||
int draw (Area *a);
|
||||
void refresh (Area *a);
|
||||
|
||||
// set 'redraw' on an area and childs
|
||||
void set_redraw (Area *a);
|
||||
void draw (Area *a);
|
||||
void draw_background (Area *a, cairo_t *c);
|
||||
|
||||
void remove_area (Area *a);
|
||||
|
||||
@@ -14,6 +14,22 @@
|
||||
// taskbar table : convert 2 dimension in 1 dimension
|
||||
#define index(i, j) ((i * panel.nb_monitor) + j)
|
||||
|
||||
/*
|
||||
void fxfree(void** ptr){
|
||||
if(*ptr){
|
||||
free(*ptr);
|
||||
*ptr=NULL;
|
||||
}
|
||||
}
|
||||
FXint fxmalloc(void** ptr,unsigned long size){
|
||||
*ptr=NULL;
|
||||
if(size!=0){
|
||||
if((*ptr=malloc(size))==NULL) return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
// mouse actions
|
||||
enum { NONE=0, CLOSE, TOGGLE, ICONIFY, SHADE, TOGGLE_ICONIFY };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user