support skip_taskbar by Andreas.Fink85

git-svn-id: http://tint2.googlecode.com/svn/trunk@169 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-09-07 21:41:21 +00:00
parent a17b62f76f
commit babda8e268
13 changed files with 1399 additions and 1369 deletions

View file

@ -1,3 +1,7 @@
2009-09-07
- fixed issue 117 : support skip_taskbar by Andreas.Fink85
- cleanup : switch space to tab
2009-09-01
- fixed segfault

View file

@ -94,9 +94,9 @@ void init_battery()
}
FILE *fp;
Panel *panel;
Battery *battery;
int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink;
Panel *panel;
Battery *battery;
int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink;
for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i];
@ -268,7 +268,7 @@ void draw_battery (void *obj, cairo_t *c, int active)
void resize_battery(void *obj)
{
Battery *battery = obj;
Battery *battery = obj;
PangoLayout *layout;
int percentage_width, time_width, new_width;

View file

@ -56,9 +56,9 @@ void init_precision()
void init_clock()
{
Panel *panel;
Clock *clock;
int i, time_height, time_height_ink, date_height, date_height_ink;
Panel *panel;
Clock *clock;
int i, time_height, time_height_ink, date_height, date_height_ink;
init_precision();
// update clock to force update (-time_precision)
@ -68,8 +68,8 @@ void init_clock()
time_clock.tv_sec -= time_clock.tv_sec % time_precision;
for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i];
clock = &panel->clock;
panel = &panel1[i];
clock = &panel->clock;
if (!clock->area.on_screen) continue;
@ -114,64 +114,64 @@ void init_clock()
void draw_clock (void *obj, cairo_t *c, int active)
{
Clock *clock = obj;
PangoLayout *layout;
Clock *clock = obj;
PangoLayout *layout;
layout = pango_cairo_create_layout (c);
layout = pango_cairo_create_layout (c);
// draw layout
pango_layout_set_font_description (layout, time1_font_desc);
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_layout_set_text (layout, buf_time, strlen(buf_time));
// draw layout
pango_layout_set_font_description (layout, time1_font_desc);
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_layout_set_text (layout, buf_time, strlen(buf_time));
cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha);
cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time1_posy);
pango_cairo_show_layout (c, layout);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time1_posy);
pango_cairo_show_layout (c, layout);
if (time2_format) {
pango_layout_set_font_description (layout, time2_font_desc);
pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_date, strlen(buf_date));
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
if (time2_format) {
pango_layout_set_font_description (layout, time2_font_desc);
pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_date, strlen(buf_date));
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time2_posy);
pango_cairo_show_layout (c, layout);
}
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time2_posy);
pango_cairo_show_layout (c, layout);
}
g_object_unref (layout);
g_object_unref (layout);
}
void resize_clock (void *obj)
{
Clock *clock = obj;
PangoLayout *layout;
int time_width, date_width, new_width;
Clock *clock = obj;
PangoLayout *layout;
int time_width, date_width, new_width;
clock->area.redraw = 1;
time_width = date_width = 0;
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
if (time2_format)
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
clock->area.redraw = 1;
time_width = date_width = 0;
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
if (time2_format)
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
// vertical panel doen't adjust width
if (!panel_horizontal) return;
//printf(" resize_clock\n");
cairo_surface_t *cs;
cairo_t *c;
//printf(" resize_clock\n");
cairo_surface_t *cs;
cairo_t *c;
Pixmap pmap;
pmap = XCreatePixmap (server.dsp, server.root_win, clock->area.width, clock->area.height, server.depth);
cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height);
c = cairo_create (cs);
layout = pango_cairo_create_layout (c);
cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height);
c = cairo_create (cs);
layout = pango_cairo_create_layout (c);
// check width
// check width
pango_layout_set_font_description (layout, time1_font_desc);
pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_time, strlen(buf_time));
@ -187,28 +187,28 @@ void resize_clock (void *obj)
else new_width = date_width;
new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width);
if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
Panel *panel = ((Area*)obj)->panel;
if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
Panel *panel = ((Area*)obj)->panel;
// resize clock
// we try to limit the number of resize
// printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
// resize clock
// we try to limit the number of resize
// printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
clock->area.width = new_width + 1;
clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
// resize other objects on panel
// resize other objects on panel
panel->area.resize = 1;
#ifdef ENABLE_BATTERY
panel->battery.area.resize = 1;
#endif
systray.area.resize = 1;
panel_refresh = 1;
}
}
g_object_unref (layout);
cairo_destroy (c);
cairo_surface_destroy (cs);
XFreePixmap (server.dsp, pmap);
g_object_unref (layout);
cairo_destroy (c);
cairo_surface_destroy (cs);
XFreePixmap (server.dsp, pmap);
}

File diff suppressed because it is too large Load diff

View file

@ -69,21 +69,21 @@ void init_panel()
p->area.parent = p;
p->area.panel = p;
p->area.on_screen = 1;
p->area.resize = 1;
p->area.resize = 1;
p->area._resize = resize_panel;
p->g_taskbar.parent = p;
p->g_taskbar.panel = p;
p->g_task.area.panel = p;
// add childs
if (p->clock.area.on_screen)
if (p->clock.area.on_screen)
p->area.list = g_slist_append(p->area.list, &p->clock);
#ifdef ENABLE_BATTERY
if (p->battery.area.on_screen)
p->area.list = g_slist_append(p->area.list, &p->battery);
#endif
// systray only on first panel
if (systray.area.on_screen && i == 0)
// systray only on first panel
if (systray.area.on_screen && i == 0)
p->area.list = g_slist_append(p->area.list, &systray);
// full width mode
@ -168,12 +168,12 @@ void cleanup_panel()
task_drag = 0;
task_urgent = 0;
cleanup_systray();
cleanup_taskbar();
cleanup_taskbar();
// font allocated once
if (panel1[0].g_task.font_desc) {
pango_font_description_free(panel1[0].g_task.font_desc);
panel1[0].g_task.font_desc = 0;
if (panel1[0].g_task.font_desc) {
pango_font_description_free(panel1[0].g_task.font_desc);
panel1[0].g_task.font_desc = 0;
}
int i;
@ -182,8 +182,8 @@ void cleanup_panel()
p = &panel1[i];
free_area(&p->area);
free_area(&p->g_task.area);
free_area(&p->g_taskbar);
free_area(&p->g_task.area);
free_area(&p->g_taskbar);
if (p->temp_pmap) {
XFreePixmap(server.dsp, p->temp_pmap);
@ -195,17 +195,17 @@ void cleanup_panel()
}
}
if (panel1) free(panel1);
panel1 = 0;
if (panel1) free(panel1);
panel1 = 0;
}
void resize_panel(void *obj)
{
Panel *panel = (Panel*)obj;
Panel *panel = (Panel*)obj;
if (panel_horizontal) {
int taskbar_width, modulo_width = 0;
int taskbar_width, modulo_width = 0;
taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
if (panel->clock.area.on_screen && panel->clock.area.width)
@ -241,7 +241,7 @@ void resize_panel(void *obj)
}
}
else {
int taskbar_height, modulo_height = 0;
int taskbar_height, modulo_height = 0;
int i, posy;
taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
@ -280,8 +280,8 @@ void resize_panel(void *obj)
void visible_object()
{
Panel *panel;
int i, j;
Panel *panel;
int i, j;
for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i];
@ -304,22 +304,22 @@ void visible_object()
void set_panel_properties(Panel *p)
{
XStoreName (server.dsp, p->main_win, "tint2");
XStoreName (server.dsp, p->main_win, "tint2");
// TODO: check if the name is really needed for a panel/taskbar ?
gsize len;
gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL);
if (name != NULL) {
XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len);
g_free(name);
}
// TODO: check if the name is really needed for a panel/taskbar ?
gsize len;
gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL);
if (name != NULL) {
XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len);
g_free(name);
}
// Dock
long val = server.atom._NET_WM_WINDOW_TYPE_DOCK;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1);
// Dock
long val = server.atom._NET_WM_WINDOW_TYPE_DOCK;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1);
// Reserved space
long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Reserved space
long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
if (panel_horizontal) {
if (panel_position & TOP) {
struts[2] = p->area.height + p->marginy;
@ -348,69 +348,69 @@ void set_panel_properties(Panel *p)
struts[7] = p->posy + p->area.height - 1;
}
}
// Old specification : fluxbox need _NET_WM_STRUT.
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4);
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);
// Old specification : fluxbox need _NET_WM_STRUT.
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4);
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);
// Sticky and below other window
val = 0xFFFFFFFF;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
Atom state[4];
state[0] = server.atom._NET_WM_STATE_SKIP_PAGER;
state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR;
state[2] = server.atom._NET_WM_STATE_STICKY;
state[3] = server.atom._NET_WM_STATE_BELOW;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4);
// Sticky and below other window
val = 0xFFFFFFFF;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
Atom state[4];
state[0] = server.atom._NET_WM_STATE_SKIP_PAGER;
state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR;
state[2] = server.atom._NET_WM_STATE_STICKY;
state[3] = server.atom._NET_WM_STATE_BELOW;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4);
// Fixed position
XSizeHints size_hints;
size_hints.flags = PPosition;
XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4);
// Fixed position
XSizeHints size_hints;
size_hints.flags = PPosition;
XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4);
// Unfocusable
XWMHints wmhints;
wmhints.flags = InputHint;
wmhints.input = False;
XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4);
// Unfocusable
XWMHints wmhints;
wmhints.flags = InputHint;
wmhints.input = False;
XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4);
// Undecorated
long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5);
// Undecorated
long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5);
}
void set_panel_background(Panel *p)
{
get_root_pixmap();
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 (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);
// copy background (server.root_pmap) in panel.area.pix.pmap
Window dummy;
int x, y;
XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy);
XSetTSOrigin(server.dsp, server.gc, -x, -y) ;
XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height);
// copy background (server.root_pmap) in panel.area.pix.pmap
Window dummy;
int x, y;
XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy);
XSetTSOrigin(server.dsp, server.gc, -x, -y) ;
XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height);
// draw background panel
cairo_surface_t *cs;
cairo_t *c;
cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height);
c = cairo_create (cs);
// draw background panel
cairo_surface_t *cs;
cairo_t *c;
cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height);
c = cairo_create (cs);
draw_background(&p->area, c, 0);
draw_background(&p->area, c, 0);
cairo_destroy (c);
cairo_surface_destroy (cs);
cairo_destroy (c);
cairo_surface_destroy (cs);
// redraw panel's object
GSList *l0;
Area *a;
GSList *l0;
Area *a;
for (l0 = p->area.list; l0 ; l0 = l0->next) {
a = l0->data;
set_redraw(a);
}
a = l0->data;
set_redraw(a);
}
}

View file

@ -33,46 +33,46 @@ static char *name_trayer = 0;
void server_init_atoms ()
{
server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False);
server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False);
server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False);
server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False);
server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False);
server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False);
server.atom._NET_WM_WINDOW_TYPE = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE", False);
server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_PAGER", False);
server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_TASKBAR", False);
server.atom._NET_WM_STATE_STICKY = XInternAtom (server.dsp, "_NET_WM_STATE_STICKY", False);
server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom (server.dsp, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DOCK", False);
server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False);
server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_MENU", False);
server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_SPLASH", False);
server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DIALOG", False);
server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_NORMAL", False);
server.atom._NET_WM_DESKTOP = XInternAtom (server.dsp, "_NET_WM_DESKTOP", False);
server.atom.WM_STATE = XInternAtom (server.dsp, "WM_STATE", False);
server.atom._NET_WM_STATE = XInternAtom (server.dsp, "_NET_WM_STATE", False);
server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
server.atom._NET_WM_STATE_SHADED = XInternAtom (server.dsp, "_NET_WM_STATE_SHADED", False);
server.atom._NET_WM_STATE_BELOW = XInternAtom (server.dsp, "_NET_WM_STATE_BELOW", False);
server.atom._NET_WM_STATE_MODAL = XInternAtom (server.dsp, "_NET_WM_STATE_MODAL", False);
server.atom._NET_CLIENT_LIST = XInternAtom (server.dsp, "_NET_CLIENT_LIST", False);
server.atom._NET_WM_VISIBLE_NAME = XInternAtom (server.dsp, "_NET_WM_VISIBLE_NAME", False);
server.atom._NET_WM_NAME = XInternAtom (server.dsp, "_NET_WM_NAME", False);
server.atom._NET_WM_STRUT = XInternAtom (server.dsp, "_NET_WM_STRUT", False);
server.atom._NET_WM_ICON = XInternAtom (server.dsp, "_NET_WM_ICON", False);
server.atom._NET_CLOSE_WINDOW = XInternAtom (server.dsp, "_NET_CLOSE_WINDOW", False);
server.atom.UTF8_STRING = XInternAtom (server.dsp, "UTF8_STRING", False);
server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_SUPPORTING_WM_CHECK", False);
server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_WM_NAME", False);
server.atom._WIN_LAYER = XInternAtom (server.dsp, "_WIN_LAYER", False);
server.atom._NET_WM_STRUT_PARTIAL = XInternAtom (server.dsp, "_NET_WM_STRUT_PARTIAL", False);
server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False);
server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False);
server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False);
server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False);
server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False);
server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False);
server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False);
server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False);
server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False);
server.atom._NET_WM_WINDOW_TYPE = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE", False);
server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_PAGER", False);
server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_TASKBAR", False);
server.atom._NET_WM_STATE_STICKY = XInternAtom (server.dsp, "_NET_WM_STATE_STICKY", False);
server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom (server.dsp, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DOCK", False);
server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False);
server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_MENU", False);
server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_SPLASH", False);
server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DIALOG", False);
server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_NORMAL", False);
server.atom._NET_WM_DESKTOP = XInternAtom (server.dsp, "_NET_WM_DESKTOP", False);
server.atom.WM_STATE = XInternAtom (server.dsp, "WM_STATE", False);
server.atom._NET_WM_STATE = XInternAtom (server.dsp, "_NET_WM_STATE", False);
server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
server.atom._NET_WM_STATE_SHADED = XInternAtom (server.dsp, "_NET_WM_STATE_SHADED", False);
server.atom._NET_WM_STATE_BELOW = XInternAtom (server.dsp, "_NET_WM_STATE_BELOW", False);
server.atom._NET_WM_STATE_MODAL = XInternAtom (server.dsp, "_NET_WM_STATE_MODAL", False);
server.atom._NET_CLIENT_LIST = XInternAtom (server.dsp, "_NET_CLIENT_LIST", False);
server.atom._NET_WM_VISIBLE_NAME = XInternAtom (server.dsp, "_NET_WM_VISIBLE_NAME", False);
server.atom._NET_WM_NAME = XInternAtom (server.dsp, "_NET_WM_NAME", False);
server.atom._NET_WM_STRUT = XInternAtom (server.dsp, "_NET_WM_STRUT", False);
server.atom._NET_WM_ICON = XInternAtom (server.dsp, "_NET_WM_ICON", False);
server.atom._NET_CLOSE_WINDOW = XInternAtom (server.dsp, "_NET_CLOSE_WINDOW", False);
server.atom.UTF8_STRING = XInternAtom (server.dsp, "UTF8_STRING", False);
server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_SUPPORTING_WM_CHECK", False);
server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_WM_NAME", False);
server.atom._WIN_LAYER = XInternAtom (server.dsp, "_WIN_LAYER", False);
server.atom._NET_WM_STRUT_PARTIAL = XInternAtom (server.dsp, "_NET_WM_STRUT_PARTIAL", False);
server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False);
server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False);
server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False);
// systray protocol
name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp));
@ -94,65 +94,65 @@ void cleanup_server()
void send_event32 (Window win, Atom at, long data1, long data2, long data3)
{
XEvent event;
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = True;
event.xclient.display = server.dsp;
event.xclient.window = win;
event.xclient.message_type = at;
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = True;
event.xclient.display = server.dsp;
event.xclient.window = win;
event.xclient.message_type = at;
event.xclient.format = 32;
event.xclient.data.l[0] = data1;
event.xclient.data.l[1] = data2;
event.xclient.data.l[2] = data3;
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
event.xclient.format = 32;
event.xclient.data.l[0] = data1;
event.xclient.data.l[1] = data2;
event.xclient.data.l[2] = data3;
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
XSendEvent(server.dsp, server.root_win, False, SubstructureRedirectMask|SubstructureNotifyMask, &event);
XSendEvent(server.dsp, server.root_win, False, SubstructureRedirectMask|SubstructureNotifyMask, &event);
}
int get_property32 (Window win, Atom at, Atom type)
{
Atom type_ret;
int format_ret = 0, data = 0;
unsigned long nitems_ret = 0;
unsigned long bafter_ret = 0;
unsigned char *prop_value = 0;
int result;
Atom type_ret;
int format_ret = 0, data = 0;
unsigned long nitems_ret = 0;
unsigned long bafter_ret = 0;
unsigned char *prop_value = 0;
int result;
if (!win) return 0;
if (!win) return 0;
result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value);
result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value);
if (result == Success && prop_value) {
data = ((gulong*)prop_value)[0];
XFree (prop_value);
}
return data;
if (result == Success && prop_value) {
data = ((gulong*)prop_value)[0];
XFree (prop_value);
}
return data;
}
void *server_get_property (Window win, Atom at, Atom type, int *num_results)
{
Atom type_ret;
int format_ret = 0;
unsigned long nitems_ret = 0;
unsigned long bafter_ret = 0;
unsigned char *prop_value;
int result;
Atom type_ret;
int format_ret = 0;
unsigned long nitems_ret = 0;
unsigned long bafter_ret = 0;
unsigned char *prop_value;
int result;
if (!win) return 0;
if (!win) return 0;
result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value);
result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value);
/* Send back resultcount */
if (num_results) *num_results = nitems_ret;
/* Send back resultcount */
if (num_results) *num_results = nitems_ret;
if (result == Success && prop_value) return prop_value;
else return 0;
if (result == Success && prop_value) return prop_value;
else return 0;
}
@ -160,7 +160,7 @@ void get_root_pixmap()
{
Pixmap ret = None;
unsigned long *res;
unsigned long *res;
int c = 2;
do {
@ -168,7 +168,7 @@ void get_root_pixmap()
if (res) {
ret = *((Pixmap*)res);
XFree(res);
break;
break;
}
} while (--c > 0);
server.root_pmap = ret;
@ -190,49 +190,49 @@ void get_root_pixmap()
int compareMonitor(const void *monitor1, const void *monitor2)
{
Monitor *m1 = (Monitor*)monitor1;
Monitor *m2 = (Monitor*)monitor2;
Monitor *m1 = (Monitor*)monitor1;
Monitor *m2 = (Monitor*)monitor2;
if (m1->x < m2->x) {
return -1;
}
else
if (m1->x > m2->x) {
return 1;
}
else
if (m1->width < m2->width) {
return 1;
}
else
if (m1->width > m2->width) {
return -1;
}
else {
return 0;
}
if (m1->x < m2->x) {
return -1;
}
else
if (m1->x > m2->x) {
return 1;
}
else
if (m1->width < m2->width) {
return 1;
}
else
if (m1->width > m2->width) {
return -1;
}
else {
return 0;
}
}
void get_monitors_and_desktops()
{
int i;
int i;
if (server.monitor) free(server.monitor);
server.nb_monitor = 0;
server.monitor = 0;
if (server.monitor) free(server.monitor);
server.nb_monitor = 0;
server.monitor = 0;
int nb_monitor;
if (XineramaIsActive(server.dsp)) {
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);
int nb_monitor;
if (XineramaIsActive(server.dsp)) {
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);
if (info) {
if (info) {
int nb=0, j;
i = 0;
server.monitor = calloc(nb_monitor, sizeof(Monitor));
while (i < nb_monitor) {
for (j = 0; j < i; j++) {
i = 0;
server.monitor = calloc(nb_monitor, sizeof(Monitor));
while (i < nb_monitor) {
for (j = 0; j < i; j++) {
if (info[i].x_org >= info[j].x_org && info[i].y_org >= info[j].y_org && (info[i].x_org+info[i].width) <= (info[j].x_org+info[j].width) && (info[i].y_org+info[i].height) <= (info[j].y_org+info[j].height)) {
if (info[i].x_org == info[j].x_org && info[i].y_org == info[j].y_org && info[i].width == info[j].width && info[i].height == info[j].height && nb == 0) {
// add the first monitor
@ -240,48 +240,48 @@ void get_monitors_and_desktops()
}
else {
// doesn't count monitor 'i' because it's included into another one
//fprintf(stderr, "monitor %d included into another one\n", i);
goto next;
//fprintf(stderr, "monitor %d included into another one\n", i);
goto next;
}
}
}
server.monitor[nb].x = info[i].x_org;
server.monitor[nb].y = info[i].y_org;
server.monitor[nb].width = info[i].width;
server.monitor[nb].height = info[i].height;
server.monitor[nb].x = info[i].x_org;
server.monitor[nb].y = info[i].y_org;
server.monitor[nb].width = info[i].width;
server.monitor[nb].height = info[i].height;
nb++;
next:
i++;
}
XFree(info);
server.nb_monitor = nb;
}
XFree(info);
server.nb_monitor = nb;
// ordered monitor according to coordinate
qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor);
}
}
// ordered monitor according to coordinate
qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor);
}
}
if (!server.nb_monitor) {
server.nb_monitor = 1;
server.monitor = calloc(server.nb_monitor, sizeof(Monitor));
server.monitor[0].x = server.monitor[0].y = 0;
server.monitor[0].width = DisplayWidth (server.dsp, server.screen);
server.monitor[0].height = DisplayHeight (server.dsp, server.screen);
}
if (!server.nb_monitor) {
server.nb_monitor = 1;
server.monitor = calloc(server.nb_monitor, sizeof(Monitor));
server.monitor[0].x = server.monitor[0].y = 0;
server.monitor[0].width = DisplayWidth (server.dsp, server.screen);
server.monitor[0].height = DisplayHeight (server.dsp, server.screen);
}
// detect number of desktops
// wait 15s to leave some time for window manager startup
for (i=0 ; i < 15 ; i++) {
server.nb_desktop = server_get_number_of_desktop ();
if (server.nb_desktop > 0) break;
sleep(1);
}
if (server.nb_desktop == 0) {
server.nb_desktop = 1;
fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n");
}
fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop);
for (i=0 ; i < 15 ; i++) {
server.nb_desktop = server_get_number_of_desktop ();
if (server.nb_desktop > 0) break;
sleep(1);
}
if (server.nb_desktop == 0) {
server.nb_desktop = 1;
fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n");
}
fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop);
}

View file

@ -78,14 +78,14 @@ void init_systray()
void cleanup_systray()
{
if (systray.list_icons) {
if (systray.list_icons) {
// remove_icon change systray.list_icons
while(systray.list_icons)
remove_icon((TrayWindow*)systray.list_icons->data);
g_slist_free(systray.list_icons);
systray.list_icons = 0;
}
g_slist_free(systray.list_icons);
systray.list_icons = 0;
}
free_area(&systray.area);
cleanup_net();
@ -199,7 +199,7 @@ int init_net()
}
// init systray protocol
net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
// v0.2 trayer specification. tint2 always orizontal.
// TODO : vertical panel ??
@ -210,11 +210,11 @@ int init_net()
if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) {
fprintf(stderr, "tint2 : can't get systray manager\n");
return 0;
}
}
XClientMessageEvent ev;
XClientMessageEvent ev;
ev.type = ClientMessage;
ev.window = server.root_win;
ev.window = server.root_win;
ev.message_type = server.atom.MANAGER;
ev.format = 32;
ev.data.l[0] = CurrentTime;
@ -230,8 +230,8 @@ int init_net()
void cleanup_net()
{
if (net_sel_win != None) {
XDestroyWindow(server.dsp, net_sel_win);
net_sel_win = None;
XDestroyWindow(server.dsp, net_sel_win);
net_sel_win = None;
}
}
@ -319,9 +319,9 @@ gboolean add_icon(Window id)
traywin = g_new0(TrayWindow, 1);
traywin->id = id;
// systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
// systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows);
systray.area.resize = 1;
systray.area.resize = 1;
systray.area.redraw = 1;
//printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
@ -346,7 +346,7 @@ void remove_icon(TrayWindow *traywin)
// remove from our list
systray.list_icons = g_slist_remove(systray.list_icons, traywin);
g_free(traywin);
systray.area.resize = 1;
systray.area.resize = 1;
systray.area.redraw = 1;
//printf("remove_icon id %lx, %d\n", traywin->id);

View file

@ -204,11 +204,11 @@ void get_icon (Task *tsk)
#endif
}
XFree (data);
}
else {
// get Pixmap icon
XWMHints *hints = XGetWMHints(server.dsp, tsk->win);
if (!hints) return;
}
else {
// get Pixmap icon
XWMHints *hints = XGetWMHints(server.dsp, tsk->win);
if (!hints) return;
if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) {
// get width, height and depth for the pixmap
Window root;
@ -235,7 +235,7 @@ void get_icon (Task *tsk)
imlib_free_image();
}
XFree(hints);
}
}
if (tsk->icon_data) {
tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32));

View file

@ -36,8 +36,8 @@
void init_taskbar()
{
Panel *panel;
int i, j;
Panel *panel;
int i, j;
for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i];
@ -115,9 +115,9 @@ void init_taskbar()
void cleanup_taskbar()
{
Panel *panel;
Panel *panel;
Taskbar *tskbar;
int i, j;
int i, j;
GSList *l0;
Task *tsk;
@ -152,11 +152,11 @@ void cleanup_taskbar()
Task *task_get_task (Window win)
{
Task *tsk;
GSList *l0;
int i, j;
Task *tsk;
GSList *l0;
int i, j;
for (i=0 ; i < nb_panel ; i++) {
for (i=0 ; i < nb_panel ; i++) {
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data;
@ -164,23 +164,23 @@ Task *task_get_task (Window win)
return tsk;
}
}
}
return 0;
}
return 0;
}
void task_refresh_tasklist ()
{
Window *win, active_win;
int num_results, i, j, k;
GSList *l0;
Task *tsk;
Window *win, active_win;
int num_results, i, j, k;
GSList *l0;
Task *tsk;
win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results);
if (!win) return;
win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results);
if (!win) return;
// Remove any old and set active win
active_win = window_get_active ();
// Remove any old and set active win
active_win = window_get_active ();
if (task_active) {
task_active->area.is_active = 0;
task_active = 0;
@ -205,28 +205,28 @@ void task_refresh_tasklist ()
if (k == num_results) remove_task (tsk);
}
}
}
}
// Add any new
for (i = 0; i < num_results; i++)
if (!task_get_task (win[i]))
add_task (win[i]);
// Add any new
for (i = 0; i < num_results; i++)
if (!task_get_task (win[i]))
add_task (win[i]);
XFree (win);
XFree (win);
}
void resize_taskbar(void *obj)
{
Taskbar *taskbar = (Taskbar*)obj;
Panel *panel = (Panel*)taskbar->area.panel;
Task *tsk;
GSList *l;
Panel *panel = (Panel*)taskbar->area.panel;
Task *tsk;
GSList *l;
int task_count;
//printf("resize_taskbar : posx et width des taches\n");
//printf("resize_taskbar : posx et width des taches\n");
taskbar->area.redraw = 1;
taskbar->area.redraw = 1;
if (panel_horizontal) {
int pixel_width, modulo_width=0;

View file

@ -48,52 +48,52 @@ void signal_handler(int sig)
void init (int argc, char *argv[])
{
int c;
int c;
// read options
c = getopt (argc, argv, "c:");
if (c != -1) {
c = getopt (argc, argv, "c:");
if (c != -1) {
config_path = strdup (optarg);
c = getopt (argc, argv, "j:");
if (c != -1)
c = getopt (argc, argv, "j:");
if (c != -1)
thumbnail_path = strdup (optarg);
}
// Set signal handler
signal(SIGUSR1, signal_handler);
signal(SIGUSR1, signal_handler);
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork()
// set global data
memset(&server, 0, sizeof(Server_global));
memset(&systray, 0, sizeof(Systraybar));
// set global data
memset(&server, 0, sizeof(Server_global));
memset(&systray, 0, sizeof(Systraybar));
server.dsp = XOpenDisplay (NULL);
if (!server.dsp) {
fprintf(stderr, "tint2 exit : could not open display.\n");
exit(0);
}
server_init_atoms ();
server.screen = DefaultScreen (server.dsp);
server.dsp = XOpenDisplay (NULL);
if (!server.dsp) {
fprintf(stderr, "tint2 exit : could not open display.\n");
exit(0);
}
server_init_atoms ();
server.screen = DefaultScreen (server.dsp);
server.root_win = RootWindow(server.dsp, server.screen);
server.depth = DefaultDepth (server.dsp, server.screen);
server.visual = DefaultVisual (server.dsp, server.screen);
server.desktop = server_get_current_desktop ();
server.depth = DefaultDepth (server.dsp, server.screen);
server.visual = DefaultVisual (server.dsp, server.screen);
server.desktop = server_get_current_desktop ();
XGCValues gcv;
server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv) ;
XSetErrorHandler ((XErrorHandler) server_catch_error);
XSetErrorHandler ((XErrorHandler) server_catch_error);
imlib_context_set_display (server.dsp);
imlib_context_set_visual (server.visual);
imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
imlib_context_set_display (server.dsp);
imlib_context_set_visual (server.visual);
imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
/* Catch events */
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
/* Catch events */
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
}
@ -101,13 +101,13 @@ void cleanup()
{
cleanup_panel();
if (time1_font_desc) pango_font_description_free(time1_font_desc);
if (time2_font_desc) pango_font_description_free(time2_font_desc);
if (time1_format) g_free(time1_format);
if (time2_format) g_free(time2_format);
if (time1_font_desc) pango_font_description_free(time1_font_desc);
if (time2_font_desc) pango_font_description_free(time2_font_desc);
if (time1_format) g_free(time1_format);
if (time2_format) g_free(time2_format);
#ifdef ENABLE_BATTERY
if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
if (battery_low_cmd) g_free(battery_low_cmd);
if (path_energy_now) g_free(path_energy_now);
if (path_energy_full) g_free(path_energy_full);
@ -119,9 +119,9 @@ void cleanup()
if (config_path) g_free(config_path);
if (thumbnail_path) g_free(thumbnail_path);
if (server.monitor) free(server.monitor);
XFreeGC(server.dsp, server.gc);
XCloseDisplay(server.dsp);
if (server.monitor) free(server.monitor);
XFreeGC(server.dsp, server.gc);
XCloseDisplay(server.dsp);
}
@ -212,7 +212,7 @@ int click_clock(Panel *panel, XEvent *e)
void window_action (Task *tsk, int action)
{
if (!tsk) return;
if (!tsk) return;
int desk;
switch (action) {
case CLOSE:
@ -259,13 +259,13 @@ void window_action (Task *tsk, int action)
void event_button_press (XEvent *e)
{
Panel *panel = get_panel(e->xany.window);
Panel *panel = get_panel(e->xany.window);
if (!panel) return;
if (panel_mode == MULTI_DESKTOP)
task_drag = click_task(panel, e);
if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) {
if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) {
// forward the click to the desktop window (thanks conky)
XUngrabPointer(server.dsp, e->xbutton.time);
e->xbutton.window = server.root_win;
@ -277,15 +277,15 @@ void event_button_press (XEvent *e)
XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
return;
}
}
XLowerWindow (server.dsp, panel->main_win);
XLowerWindow (server.dsp, panel->main_win);
}
void event_button_release (XEvent *e)
{
Panel *panel = get_panel(e->xany.window);
Panel *panel = get_panel(e->xany.window);
if (!panel) return;
if (wm_menu && click_padding(panel, e)) {
@ -295,27 +295,27 @@ void event_button_release (XEvent *e)
return;
}
int action = TOGGLE_ICONIFY;
switch (e->xbutton.button) {
case 2:
action = mouse_middle;
break;
case 3:
action = mouse_right;
break;
case 4:
action = mouse_scroll_up;
break;
case 5:
action = mouse_scroll_down;
break;
case 6:
action = mouse_tilt_left;
break;
case 7:
action = mouse_tilt_right;
break;
}
int action = TOGGLE_ICONIFY;
switch (e->xbutton.button) {
case 2:
action = mouse_middle;
break;
case 3:
action = mouse_right;
break;
case 4:
action = mouse_scroll_up;
break;
case 5:
action = mouse_scroll_down;
break;
case 6:
action = mouse_tilt_left;
break;
case 7:
action = mouse_tilt_right;
break;
}
if ( click_clock(panel, e)) {
clock_action(e->xbutton.button);
@ -332,51 +332,51 @@ void event_button_release (XEvent *e)
return;
}
// drag and drop task
if (task_drag) {
if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
windows_set_desktop(task_drag->win, tskbar->desktop);
if (tskbar->desktop == server.desktop)
set_active(task_drag->win);
task_drag = 0;
}
return;
}
else task_drag = 0;
}
// switch desktop
if (panel_mode == MULTI_DESKTOP) {
if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
set_desktop (tskbar->desktop);
// drag and drop task
if (task_drag) {
if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
windows_set_desktop(task_drag->win, tskbar->desktop);
if (tskbar->desktop == server.desktop)
set_active(task_drag->win);
task_drag = 0;
}
return;
}
else task_drag = 0;
}
// action on task
window_action( click_task(panel, e), action);
// switch desktop
if (panel_mode == MULTI_DESKTOP) {
if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
set_desktop (tskbar->desktop);
}
// to keep window below
XLowerWindow (server.dsp, panel->main_win);
// action on task
window_action( click_task(panel, e), action);
// to keep window below
XLowerWindow (server.dsp, panel->main_win);
}
void event_property_notify (XEvent *e)
{
int i, j;
Task *tsk;
Window win = e->xproperty.window;
Atom at = e->xproperty.atom;
int i, j;
Task *tsk;
Window win = e->xproperty.window;
Atom at = e->xproperty.atom;
if (win == server.root_win) {
if (!server.got_root_win) {
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
server.got_root_win = 1;
}
if (win == server.root_win) {
if (!server.got_root_win) {
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
server.got_root_win = 1;
}
// Change number of desktops
else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
server.nb_desktop = server_get_number_of_desktop ();
cleanup_taskbar();
// Change number of desktops
else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
server.nb_desktop = server_get_number_of_desktop ();
cleanup_taskbar();
init_taskbar();
visible_object();
for (i=0 ; i < nb_panel ; i++) {
@ -384,12 +384,12 @@ void event_property_notify (XEvent *e)
}
task_refresh_tasklist();
panel_refresh = 1;
}
// Change desktop
else if (at == server.atom._NET_CURRENT_DESKTOP) {
server.desktop = server_get_current_desktop ();
}
// Change desktop
else if (at == server.atom._NET_CURRENT_DESKTOP) {
server.desktop = server_get_current_desktop ();
for (i=0 ; i < nb_panel ; i++) {
Panel *panel = &panel1[i];
Panel *panel = &panel1[i];
if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
// redraw taskbar
panel_refresh = 1;
@ -417,72 +417,77 @@ void event_property_notify (XEvent *e)
}
}
}
if (panel_mode != MULTI_DESKTOP) {
if (panel_mode != MULTI_DESKTOP) {
visible_object();
}
}
// Window list
else if (at == server.atom._NET_CLIENT_LIST) {
task_refresh_tasklist();
panel_refresh = 1;
}
// Change active
else if (at == server.atom._NET_ACTIVE_WINDOW) {
GSList *l0;
if (task_active) {
}
}
// Window list
else if (at == server.atom._NET_CLIENT_LIST) {
task_refresh_tasklist();
panel_refresh = 1;
}
// Change active
else if (at == server.atom._NET_ACTIVE_WINDOW) {
GSList *l0;
if (task_active) {
for (i=0 ; i < nb_panel ; i++) {
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data;
tsk->area.is_active = 0;
}
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data;
tsk->area.is_active = 0;
}
}
}
task_active = 0;
task_active = 0;
}
Window w1 = window_get_active ();
Task *t = task_get_task(w1);
if (!t) {
Window w2;
if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
if (w2) t = task_get_task(w2);
}
Window w1 = window_get_active ();
Task *t = task_get_task(w1);
if (!t) {
Window w2;
if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
if (w2) t = task_get_task(w2);
}
if (task_urgent == t) {
init_precision();
task_urgent = 0;
}
// put active state on all task (multi_desktop)
if (t) {
if (t) {
for (i=0 ; i < nb_panel ; i++) {
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data;
if (tsk->win == t->win) {
tsk->area.is_active = 1;
//printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title);
}
}
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data;
if (tsk->win == t->win) {
tsk->area.is_active = 1;
//printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title);
}
}
}
}
task_active = t;
task_active = t;
}
panel_refresh = 1;
}
else if (at == server.atom._XROOTPMAP_ID) {
panel_refresh = 1;
}
else if (at == server.atom._XROOTPMAP_ID) {
// change Wallpaper
for (i=0 ; i < nb_panel ; i++) {
set_panel_background(&panel1[i]);
}
panel_refresh = 1;
}
}
else {
tsk = task_get_task (win);
if (!tsk) return;
//printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
panel_refresh = 1;
}
}
else {
tsk = task_get_task (win);
if (!tsk) {
if ( at != server.atom._NET_WM_STATE)
return;
else if ( !(tsk = add_task(win)) )
return;
}
//printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
// Window title changed
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
// Window title changed
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
Task *tsk2;
GSList *l0;
get_title(tsk);
@ -498,22 +503,25 @@ void event_property_notify (XEvent *e)
}
}
}
panel_refresh = 1;
}
panel_refresh = 1;
}
// Demand attention
else if (at == server.atom._NET_WM_STATE) {
if (window_is_urgent (win)) {
else if (at == server.atom._NET_WM_STATE) {
if (window_is_urgent (win)) {
task_urgent = tsk;
tick_urgent = 0;
time_precision = 1;
}
if (window_is_skip_taskbar(win)) {
remove_task( tsk );
}
}
else if (at == server.atom.WM_STATE) {
// Iconic state
else if (at == server.atom.WM_STATE) {
// Iconic state
// TODO : try to delete following code
if (window_is_iconified (win)) {
if (task_active) {
if (task_active->win == tsk->win) {
if (window_is_iconified (win)) {
if (task_active) {
if (task_active->win == tsk->win) {
Task *tsk2;
GSList *l0;
for (i=0 ; i < nb_panel ; i++) {
@ -524,14 +532,14 @@ void event_property_notify (XEvent *e)
}
}
}
task_active = 0;
}
}
task_active = 0;
}
}
}
}
// Window icon changed
else if (at == server.atom._NET_WM_ICON) {
get_icon(tsk);
// Window icon changed
else if (at == server.atom._NET_WM_ICON) {
get_icon(tsk);
Task *tsk2;
GSList *l0;
for (i=0 ; i < nb_panel ; i++) {
@ -548,10 +556,10 @@ void event_property_notify (XEvent *e)
}
}
}
panel_refresh = 1;
}
// Window desktop changed
else if (at == server.atom._NET_WM_DESKTOP) {
panel_refresh = 1;
}
// Window desktop changed
else if (at == server.atom._NET_WM_DESKTOP) {
int desktop = window_get_desktop (win);
int active = tsk->area.is_active;
//printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
@ -565,21 +573,21 @@ void event_property_notify (XEvent *e)
}
panel_refresh = 1;
}
}
}
if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
}
if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
}
}
void event_expose (XEvent *e)
{
Panel *panel;
Panel *panel;
panel = get_panel(e->xany.window);
if (!panel) return;
// TODO : one panel_refresh per panel ?
panel_refresh = 1;
panel_refresh = 1;
}
@ -593,39 +601,39 @@ void event_configure_notify (Window win)
if (traywin->id == win) {
//printf("move tray %d\n", traywin->x);
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
panel_refresh = 1;
panel_refresh = 1;
return;
}
}
// check 'win' move in another monitor
if (nb_panel == 1) return;
if (server.nb_monitor == 1) return;
Task *tsk = task_get_task (win);
if (!tsk) return;
if (nb_panel == 1) return;
if (server.nb_monitor == 1) return;
Task *tsk = task_get_task (win);
if (!tsk) return;
Panel *p = tsk->area.panel;
if (p->monitor != window_get_monitor (win)) {
remove_task (tsk);
add_task (win);
if (win == window_get_active ()) {
Task *tsk = task_get_task (win);
Panel *p = tsk->area.panel;
if (p->monitor != window_get_monitor (win)) {
remove_task (tsk);
add_task (win);
if (win == window_get_active ()) {
Task *tsk = task_get_task (win);
tsk->area.is_active = 1;
task_active = tsk;
}
panel_refresh = 1;
}
panel_refresh = 1;
}
}
void event_timer()
{
struct timeval stv;
struct timeval stv;
int i;
if (gettimeofday(&stv, 0)) return;
if (gettimeofday(&stv, 0)) return;
if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
time_clock.tv_sec = stv.tv_sec;
time_clock.tv_sec -= time_clock.tv_sec % time_precision;
@ -648,9 +656,9 @@ void event_timer()
#endif
// update clock
if (time1_format) {
if (time1_format) {
for (i=0 ; i < nb_panel ; i++)
panel1[i].clock.area.resize = 1;
panel1[i].clock.area.resize = 1;
}
panel_refresh = 1;
}
@ -658,20 +666,20 @@ void event_timer()
int main (int argc, char *argv[])
{
XEvent e;
fd_set fd;
int x11_fd, i;
struct timeval tv;
Panel *panel;
XEvent e;
fd_set fd;
int x11_fd, i;
struct timeval tv;
Panel *panel;
GSList *it;
init (argc, argv);
init (argc, argv);
load_config:
i = 0;
i = 0;
init_config();
if (config_path)
i = config_read_file (config_path);
if (config_path)
i = config_read_file (config_path);
else
i = config_read ();
if (!i) {
@ -679,7 +687,7 @@ load_config:
cleanup();
exit(1);
}
config_finish();
config_finish();
if (thumbnail_path) {
// usage: tint2 -j <file> for internal use
printf("file %s\n", thumbnail_path);
@ -687,46 +695,46 @@ load_config:
exit(0);
}
x11_fd = ConnectionNumber(server.dsp);
XSync(server.dsp, False);
x11_fd = ConnectionNumber(server.dsp);
XSync(server.dsp, False);
while (1) {
// thanks to AngryLlama for the timer
// Create a File Description Set containing x11_fd
FD_ZERO (&fd);
FD_SET (x11_fd, &fd);
while (1) {
// thanks to AngryLlama for the timer
// Create a File Description Set containing x11_fd
FD_ZERO (&fd);
FD_SET (x11_fd, &fd);
tv.tv_usec = 500000;
tv.tv_sec = 0;
tv.tv_usec = 500000;
tv.tv_sec = 0;
// Wait for X Event or a Timer
if (select(x11_fd+1, &fd, 0, 0, &tv)) {
while (XPending (server.dsp)) {
XNextEvent(server.dsp, &e);
// Wait for X Event or a Timer
if (select(x11_fd+1, &fd, 0, 0, &tv)) {
while (XPending (server.dsp)) {
XNextEvent(server.dsp, &e);
switch (e.type) {
case ButtonPress:
event_button_press (&e);
break;
switch (e.type) {
case ButtonPress:
event_button_press (&e);
break;
case ButtonRelease:
event_button_release(&e);
break;
case ButtonRelease:
event_button_release(&e);
break;
case Expose:
event_expose(&e);
break;
case Expose:
event_expose(&e);
break;
case PropertyNotify:
event_property_notify(&e);
break;
case PropertyNotify:
event_property_notify(&e);
break;
case ConfigureNotify:
if (e.xconfigure.window == server.root_win)
goto load_config;
else
event_configure_notify (e.xconfigure.window);
break;
case ConfigureNotify:
if (e.xconfigure.window == server.root_win)
goto load_config;
else
event_configure_notify (e.xconfigure.window);
break;
case ReparentNotify:
if (!systray.area.on_screen)
@ -753,24 +761,24 @@ load_config:
if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
net_message(&e.xclient);
}
break;
}
}
}
event_timer();
break;
}
}
}
event_timer();
switch (signal_pending) {
case SIGUSR1:
signal_pending = 0;
goto load_config;
goto load_config;
case SIGINT:
case SIGTERM:
case SIGHUP:
cleanup ();
return 0;
}
cleanup ();
return 0;
}
if (panel_refresh) {
if (panel_refresh) {
panel_refresh = 0;
if (refresh_systray) {
@ -783,8 +791,8 @@ load_config:
if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
refresh(&panel->area);
XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
refresh(&panel->area);
XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
}
XFlush (server.dsp);
@ -797,7 +805,7 @@ load_config:
refresh_systray_icon();
}
}
}
}
}

View file

@ -41,23 +41,23 @@ void refresh (Area *a)
size(a);
// don't draw transparent objects (without foreground and without background)
if (a->redraw) {
a->redraw = 0;
//printf("draw area posx %d, width %d\n", a->posx, a->width);
draw(a, 0);
if (a->use_active)
draw(a, 1);
if (a->redraw) {
a->redraw = 0;
//printf("draw area posx %d, width %d\n", a->posx, a->width);
draw(a, 0);
if (a->use_active)
draw(a, 1);
}
// draw current Area
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
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);
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
// and then refresh child object
GSList *l;
for (l = a->list; l ; l = l->next)
refresh(l->data);
for (l = a->list; l ; l = l->next)
refresh(l->data);
}
@ -66,13 +66,13 @@ void size (Area *a)
GSList *l;
if (a->resize) {
a->resize = 0;
a->resize = 0;
for (l = a->list; l ; l = l->next)
size(l->data);
// resize can generate a redraw
if (a->_resize) {
a->_resize(a);
// resize can generate a redraw
if (a->_resize) {
a->_resize(a);
}
}
}
@ -80,159 +80,159 @@ void size (Area *a)
void set_redraw (Area *a)
{
a->redraw = 1;
a->redraw = 1;
GSList *l;
for (l = a->list ; l ; l = l->next)
set_redraw(l->data);
GSList *l;
for (l = a->list ; l ; l = l->next)
set_redraw(l->data);
}
void draw (Area *a, int active)
{
Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
if (*pmap) XFreePixmap (server.dsp, *pmap);
*pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
if (*pmap) XFreePixmap (server.dsp, *pmap);
*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);
// 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);
cairo_surface_t *cs;
cairo_t *c;
cairo_surface_t *cs;
cairo_t *c;
cs = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height);
c = cairo_create (cs);
cs = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height);
c = cairo_create (cs);
draw_background (a, c, active);
draw_background (a, c, active);
if (a->_draw_foreground)
a->_draw_foreground(a, c, active);
if (a->_draw_foreground)
a->_draw_foreground(a, c, active);
cairo_destroy (c);
cairo_surface_destroy (cs);
cairo_destroy (c);
cairo_surface_destroy (cs);
}
void draw_background (Area *a, cairo_t *c, int active)
{
Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active);
Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active);
if (pix->back.alpha > 0.0) {
//printf(" draw_background (%d %d) RGBA (%lf, %lf, %lf, %lf)\n", a->posx, a->posy, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
draw_rect(c, pix->border.width, pix->border.width, a->width-(2.0 * pix->border.width), a->height-(2.0*pix->border.width), pix->border.rounded - pix->border.width/1.571);
cairo_set_source_rgba(c, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
if (pix->back.alpha > 0.0) {
//printf(" draw_background (%d %d) RGBA (%lf, %lf, %lf, %lf)\n", a->posx, a->posy, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
draw_rect(c, pix->border.width, pix->border.width, a->width-(2.0 * pix->border.width), a->height-(2.0*pix->border.width), pix->border.rounded - pix->border.width/1.571);
cairo_set_source_rgba(c, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
cairo_fill(c);
}
cairo_fill(c);
}
if (pix->border.width > 0 && pix->border.alpha > 0.0) {
cairo_set_line_width (c, pix->border.width);
if (pix->border.width > 0 && pix->border.alpha > 0.0) {
cairo_set_line_width (c, pix->border.width);
// draw border inside (x, y, width, height)
draw_rect(c, pix->border.width/2.0, pix->border.width/2.0, a->width - pix->border.width, a->height - pix->border.width, pix->border.rounded);
/*
// convert : radian = degre * M_PI/180
// définir le dégradé dans un carré de (0,0) (100,100)
// ensuite ce dégradé est extrapolé selon le ratio width/height
// dans repère (0, 0) (100, 100)
double X0, Y0, X1, Y1, degre;
// x = X * (a->width / 100), y = Y * (a->height / 100)
double x0, y0, x1, y1;
X0 = 0;
Y0 = 100;
X1 = 100;
Y1 = 0;
degre = 45;
// et ensuite faire la changement d'unité du repère
// car ce qui doit resté inchangée est les traits et pas la direction
// draw border inside (x, y, width, height)
draw_rect(c, pix->border.width/2.0, pix->border.width/2.0, a->width - pix->border.width, a->height - pix->border.width, pix->border.rounded);
/*
// convert : radian = degre * M_PI/180
// définir le dégradé dans un carré de (0,0) (100,100)
// ensuite ce dégradé est extrapolé selon le ratio width/height
// dans repère (0, 0) (100, 100)
double X0, Y0, X1, Y1, degre;
// x = X * (a->width / 100), y = Y * (a->height / 100)
double x0, y0, x1, y1;
X0 = 0;
Y0 = 100;
X1 = 100;
Y1 = 0;
degre = 45;
// et ensuite faire la changement d'unité du repère
// car ce qui doit resté inchangée est les traits et pas la direction
// il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°)
// ceci peut être appliqué une fois pour toute au départ
// ensuite calculer l'angle dans le nouveau repère
// puis faire une rotation de 90°
x0 = X0 * ((double)a->width / 100);
x1 = X1 * ((double)a->width / 100);
y0 = Y0 * ((double)a->height / 100);
y1 = Y1 * ((double)a->height / 100);
// il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°)
// ceci peut être appliqué une fois pour toute au départ
// ensuite calculer l'angle dans le nouveau repère
// puis faire une rotation de 90°
x0 = X0 * ((double)a->width / 100);
x1 = X1 * ((double)a->width / 100);
y0 = Y0 * ((double)a->height / 100);
y1 = Y1 * ((double)a->height / 100);
x0 = X0 * ((double)a->height / 100);
x1 = X1 * ((double)a->height / 100);
y0 = Y0 * ((double)a->width / 100);
y1 = Y1 * ((double)a->width / 100);
x0 = X0 * ((double)a->height / 100);
x1 = X1 * ((double)a->height / 100);
y0 = Y0 * ((double)a->width / 100);
y1 = Y1 * ((double)a->width / 100);
cairo_pattern_t *linpat;
linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
cairo_pattern_add_color_stop_rgba (linpat, 0, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha);
cairo_pattern_add_color_stop_rgba (linpat, 1, a->border.color[0], a->border.color[1], a->border.color[2], 0);
cairo_set_source (c, linpat);
*/
cairo_set_source_rgba (c, pix->border.color[0], pix->border.color[1], pix->border.color[2], pix->border.alpha);
cairo_pattern_t *linpat;
linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
cairo_pattern_add_color_stop_rgba (linpat, 0, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha);
cairo_pattern_add_color_stop_rgba (linpat, 1, a->border.color[0], a->border.color[1], a->border.color[2], 0);
cairo_set_source (c, linpat);
*/
cairo_set_source_rgba (c, pix->border.color[0], pix->border.color[1], pix->border.color[2], pix->border.alpha);
cairo_stroke (c);
//cairo_pattern_destroy (linpat);
}
cairo_stroke (c);
//cairo_pattern_destroy (linpat);
}
}
void remove_area (Area *a)
{
Area *parent = (Area*)a->parent;
Area *parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a);
set_redraw (parent);
parent->list = g_slist_remove(parent->list, a);
set_redraw (parent);
}
void add_area (Area *a)
{
Area *parent = (Area*)a->parent;
Area *parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a);
set_redraw (parent);
parent->list = g_slist_remove(parent->list, a);
set_redraw (parent);
}
void free_area (Area *a)
{
GSList *l0;
for (l0 = a->list; l0 ; l0 = l0->next)
free_area (l0->data);
GSList *l0;
for (l0 = a->list; l0 ; l0 = l0->next)
free_area (l0->data);
if (a->list) {
g_slist_free(a->list);
a->list = 0;
}
if (a->pix.pmap) {
XFreePixmap (server.dsp, a->pix.pmap);
a->pix.pmap = 0;
if (a->list) {
g_slist_free(a->list);
a->list = 0;
}
if (a->pix_active.pmap) {
XFreePixmap (server.dsp, a->pix_active.pmap);
a->pix_active.pmap = 0;
if (a->pix.pmap) {
XFreePixmap (server.dsp, a->pix.pmap);
a->pix.pmap = 0;
}
if (a->pix_active.pmap) {
XFreePixmap (server.dsp, a->pix_active.pmap);
a->pix_active.pmap = 0;
}
}
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r)
{
if (r > 0.0) {
double c1 = 0.55228475 * r;
if (r > 0.0) {
double c1 = 0.55228475 * r;
cairo_move_to(c, x+r, y);
cairo_rel_line_to(c, w-2*r, 0);
cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r);
cairo_rel_line_to(c, 0, h-2*r);
cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r);
cairo_rel_line_to (c, -w +2*r, 0);
cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r);
cairo_rel_line_to (c, 0, -h + 2 * r);
cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r);
}
else
cairo_rectangle(c, x, y, w, h);
cairo_move_to(c, x+r, y);
cairo_rel_line_to(c, w-2*r, 0);
cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r);
cairo_rel_line_to(c, 0, h-2*r);
cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r);
cairo_rel_line_to (c, -w +2*r, 0);
cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r);
cairo_rel_line_to (c, 0, -h + 2 * r);
cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r);
}
else
cairo_rectangle(c, x, y, w, h);
}

View file

@ -38,70 +38,70 @@
void set_active (Window win)
{
send_event32 (win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0);
send_event32 (win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0);
}
void set_desktop (int desktop)
{
send_event32 (server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0);
send_event32 (server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0);
}
void windows_set_desktop (Window win, int desktop)
{
send_event32 (win, server.atom._NET_WM_DESKTOP, desktop, 2, 0);
send_event32 (win, server.atom._NET_WM_DESKTOP, desktop, 2, 0);
}
void set_close (Window win)
{
send_event32 (win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0);
send_event32 (win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0);
}
void window_toggle_shade (Window win)
{
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0);
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0);
}
void window_maximize_restore (Window win)
{
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0);
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0);
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0);
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0);
}
int window_is_hidden (Window win)
{
Window window;
Atom *at;
int count, i;
Window window;
Atom *at;
int count, i;
if (XGetTransientForHint(server.dsp, win, &window) != 0) {
if (window) {
return 1;
}
}
if (XGetTransientForHint(server.dsp, win, &window) != 0) {
if (window) {
return 1;
}
}
at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
XFree(at);
return 1;
}
}
XFree(at);
at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
XFree(at);
return 1;
}
}
XFree(at);
at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count);
for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) {
XFree(at);
return 1;
}
}
XFree(at);
at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count);
for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) {
XFree(at);
return 1;
}
}
XFree(at);
for (i=0 ; i < nb_panel ; i++) {
if (panel1[i].main_win == win) {
@ -109,172 +109,189 @@ int window_is_hidden (Window win)
}
}
// specification
// Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set
// MUST be taken as top-level window.
return 0;
// specification
// Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set
// MUST be taken as top-level window.
return 0;
}
int window_get_desktop (Window win)
{
return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL);
return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL);
}
int window_get_monitor (Window win)
{
int i, x, y;
Window src;
int i, x, y;
Window src;
XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src);
x += 2;
y += 2;
for (i = 0; i < server.nb_monitor; i++) {
if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width))
if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height))
break;
}
XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src);
x += 2;
y += 2;
for (i = 0; i < server.nb_monitor; i++) {
if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width))
if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height))
break;
}
//printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y);
if (i == server.nb_monitor) return 0;
else return i;
//printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y);
if (i == server.nb_monitor) return 0;
else return i;
}
int window_is_iconified (Window win)
{
return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE));
return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE));
}
int window_is_urgent (Window win)
{
Atom *at;
int count, i;
Atom *at;
int count, i;
at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) {
XFree(at);
return 1;
}
}
XFree(at);
at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) {
XFree(at);
return 1;
}
}
XFree(at);
return 0;
}
int window_is_skip_taskbar (Window win)
{
Atom *at;
int count, i;
at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i=0; i<count; i++) {
if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
XFree(at);
return 1;
}
}
XFree(at);
return 0;
}
int server_get_number_of_desktop ()
{
return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL);
return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL);
}
int server_get_current_desktop ()
{
return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL);
return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL);
}
Window window_get_active ()
{
return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW);
return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW);
}
int window_is_active (Window win)
{
return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW));
return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW));
}
int get_icon_count (long *data, int num)
{
int count, pos, w, h;
int count, pos, w, h;
count = 0;
pos = 0;
while (pos < num) {
w = data[pos++];
h = data[pos++];
pos += w * h;
if (pos > num || w * h == 0) break;
count++;
}
count = 0;
pos = 0;
while (pos < num) {
w = data[pos++];
h = data[pos++];
pos += w * h;
if (pos > num || w * h == 0) break;
count++;
}
return count;
return count;
}
long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size)
{
int width[icon_count], height[icon_count], pos, i, w, h;
long *icon_data[icon_count];
int width[icon_count], height[icon_count], pos, i, w, h;
long *icon_data[icon_count];
/* List up icons */
pos = 0;
i = icon_count;
while (i--) {
w = data[pos++];
h = data[pos++];
if (pos + w * h > num) break;
/* List up icons */
pos = 0;
i = icon_count;
while (i--) {
w = data[pos++];
h = data[pos++];
if (pos + w * h > num) break;
width[i] = w;
height[i] = h;
icon_data[i] = &data[pos];
width[i] = w;
height[i] = h;
icon_data[i] = &data[pos];
pos += w * h;
}
pos += w * h;
}
/* Try to find exact size */
int icon_num = -1;
for (i = 0; i < icon_count; i++) {
if (width[i] == best_icon_size) {
icon_num = i;
break;
}
}
/* Try to find exact size */
int icon_num = -1;
for (i = 0; i < icon_count; i++) {
if (width[i] == best_icon_size) {
icon_num = i;
break;
}
}
/* Take the biggest or whatever */
if (icon_num < 0) {
int highest = 0;
for (i = 0; i < icon_count; i++) {
if (width[i] > highest) {
icon_num = i;
highest = width[i];
}
}
}
/* Take the biggest or whatever */
if (icon_num < 0) {
int highest = 0;
for (i = 0; i < icon_count; i++) {
if (width[i] > highest) {
icon_num = i;
highest = width[i];
}
}
}
*iw = width[icon_num];
*ih = height[icon_num];
return icon_data[icon_num];
*iw = width[icon_num];
*ih = height[icon_num];
return icon_data[icon_num];
}
void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len)
{
PangoRectangle rect_ink, rect;
PangoRectangle rect_ink, rect;
Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth);
Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth);
cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height);
cairo_t *c = cairo_create (cs);
cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height);
cairo_t *c = cairo_create (cs);
PangoLayout *layout = pango_cairo_create_layout (c);
pango_layout_set_font_description (layout, font);
pango_layout_set_text (layout, text, len);
PangoLayout *layout = pango_cairo_create_layout (c);
pango_layout_set_font_description (layout, font);
pango_layout_set_text (layout, text, len);
pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
*height_ink = rect_ink.height;
*height = rect.height;
//printf("dimension : %d - %d\n", rect_ink.height, rect.height);
pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
*height_ink = rect_ink.height;
*height = rect.height;
//printf("dimension : %d - %d\n", rect_ink.height, rect.height);
g_object_unref (layout);
cairo_destroy (c);
cairo_surface_destroy (cs);
XFreePixmap (server.dsp, pmap);
g_object_unref (layout);
cairo_destroy (c);
cairo_surface_destroy (cs);
XFreePixmap (server.dsp, pmap);
}

View file

@ -21,6 +21,7 @@ int window_is_iconified (Window win);
int window_is_urgent (Window win);
int window_is_hidden (Window win);
int window_is_active (Window win);
int window_is_skip_taskbar (Window win);
int get_icon_count (long *data, int num);
long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size);
void window_maximize_restore (Window win);