fixed issue 13, removed Window magager s menu for stability reason

git-svn-id: http://tint2.googlecode.com/svn/trunk@31 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-02-03 20:40:46 +00:00
parent 1d88864c0c
commit 5b4d782ca2
14 changed files with 224 additions and 168 deletions

View file

@ -1,5 +1,9 @@
2009-01-30 2009-02-05
- fixed issue 13 (not sure but it look right) - better fixed for Robert Escriva problem : set_panel_properties -> Reserved space
- fixed issue 13 with background detection
- fixed bug with disconnected monitor (in multi monitor mode)
- removed capability to show Window magager's menu
it's a feature I would like, but implementation was buggy
2009-01-29 2009-01-29
- use panel_margin parameter even with full_width - use panel_margin parameter even with full_width

Binary file not shown.

View file

@ -30,33 +30,39 @@
#include "panel.h" #include "panel.h"
char *time1_format = 0;
char *time2_format = 0;
struct timeval time_clock;
int time_precision;
void init_clock(Clock *clock, int panel_height) void init_clock(Clock *clock, int panel_height)
{ {
char buf_time[40]; char buf_time[40];
char buf_date[40]; char buf_date[40];
int time_height, time_height_ink, date_height, date_height_ink; int time_height, time_height_ink, date_height, date_height_ink;
if (!clock->time1_format) return; if (!time1_format) return;
if (strchr(clock->time1_format, 'S') == NULL) clock->time_precision = 60; if (strchr(time1_format, 'S') == NULL) time_precision = 60;
else clock->time_precision = 1; else time_precision = 1;
clock->area.posy = panel.area.pix.border.width + panel.area.paddingy; clock->area.posy = panel.area.pix.border.width + panel.area.paddingy;
clock->area.height = panel.area.height - (2 * clock->area.posy); clock->area.height = panel.area.height - (2 * clock->area.posy);
clock->area.width = 0; // force posx and width detection clock->area.width = 0; // force posx and width detection
clock->area.redraw = 1; clock->area.redraw = 1;
gettimeofday(&clock->clock, 0); gettimeofday(&time_clock, 0);
clock->clock.tv_sec -= clock->clock.tv_sec % clock->time_precision; time_clock.tv_sec -= time_clock.tv_sec % time_precision;
strftime(buf_time, sizeof(buf_time), clock->time1_format, localtime(&clock->clock.tv_sec)); strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
if (clock->time2_format) if (time2_format)
strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec)); strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
get_text_size(clock->time1_font_desc, &time_height_ink, &time_height, panel_height, buf_time, strlen(buf_time)); get_text_size(clock->time1_font_desc, &time_height_ink, &time_height, panel_height, buf_time, strlen(buf_time));
clock->time1_posy = (clock->area.height - time_height) / 2; clock->time1_posy = (clock->area.height - time_height) / 2;
if (clock->time2_format) { if (time2_format) {
get_text_size(clock->time2_font_desc, &date_height_ink, &date_height, panel_height, buf_date, strlen(buf_date)); get_text_size(clock->time2_font_desc, &date_height_ink, &date_height, panel_height, buf_date, strlen(buf_date));
clock->time1_posy -= ((date_height_ink + 2) / 2); clock->time1_posy -= ((date_height_ink + 2) / 2);
@ -74,9 +80,9 @@ void draw_foreground_clock (void *obj, cairo_t *c, int active)
int time_width, date_width, new_width; int time_width, date_width, new_width;
time_width = date_width = 0; time_width = date_width = 0;
strftime(buf_time, sizeof(buf_time), clock->time1_format, localtime(&clock->clock.tv_sec)); strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
if (clock->time2_format) if (time2_format)
strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec)); strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
//printf(" draw_foreground_clock : %s\n", buf_time); //printf(" draw_foreground_clock : %s\n", buf_time);
redraw: redraw:
@ -87,7 +93,7 @@ redraw:
pango_layout_set_indent(layout, 0); pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_time, strlen(buf_time)); pango_layout_set_text (layout, buf_time, strlen(buf_time));
pango_layout_get_pixel_size (layout, &time_width, NULL); pango_layout_get_pixel_size (layout, &time_width, NULL);
if (clock->time2_format) { if (time2_format) {
pango_layout_set_font_description (layout, clock->time2_font_desc); pango_layout_set_font_description (layout, clock->time2_font_desc);
pango_layout_set_indent(layout, 0); pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_date, strlen(buf_date)); pango_layout_set_text (layout, buf_date, strlen(buf_date));
@ -120,7 +126,7 @@ redraw:
cairo_move_to (c, 0, clock->time1_posy); cairo_move_to (c, 0, clock->time1_posy);
pango_cairo_show_layout (c, layout); pango_cairo_show_layout (c, layout);
if (clock->time2_format) { if (time2_format) {
pango_layout_set_font_description (layout, clock->time2_font_desc); pango_layout_set_font_description (layout, clock->time2_font_desc);
pango_layout_set_indent(layout, 0); pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_date, strlen(buf_date)); pango_layout_set_text (layout, buf_date, strlen(buf_date));

View file

@ -1,9 +1,9 @@
/************************************************************************** /**************************************************************************
* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) * Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
* *
* clock : * Clock with fonctionnal data (timeval, precision) and drawing data (area, font, ...).
* - draw clock, adjust width * Each panel use his own drawing data.
* *
**************************************************************************/ **************************************************************************/
#ifndef CLOCK_H #ifndef CLOCK_H
@ -23,13 +23,13 @@ typedef struct Clock {
PangoFontDescription *time2_font_desc; PangoFontDescription *time2_font_desc;
int time1_posy; int time1_posy;
int time2_posy; int time2_posy;
char *time1_format;
char *time2_format;
struct timeval clock;
int time_precision;
} Clock; } Clock;
extern char *time1_format;
extern char *time2_format;
extern struct timeval time_clock;
extern int time_precision;
// initialize clock : y position, precision, ... // initialize clock : y position, precision, ...
void init_clock(Clock *clock, int panel_height); void init_clock(Clock *clock, int panel_height);

View file

@ -77,9 +77,10 @@ void cleanup ()
if (panel.clock.time1_font_desc) pango_font_description_free(panel.clock.time1_font_desc); if (panel.clock.time1_font_desc) pango_font_description_free(panel.clock.time1_font_desc);
if (panel.clock.time2_font_desc) pango_font_description_free(panel.clock.time2_font_desc); if (panel.clock.time2_font_desc) pango_font_description_free(panel.clock.time2_font_desc);
if (panel.taskbar) cleanup_taskbar(); if (panel.taskbar) cleanup_taskbar();
if (panel.clock.time1_format) g_free(panel.clock.time1_format); if (time1_format) g_free(time1_format);
if (panel.clock.time2_format) g_free(panel.clock.time2_format); if (time2_format) g_free(time2_format);
if (server.monitor) free(server.monitor); if (server.monitor) free(server.monitor);
XFreeGC(server.dsp, server.gc);
XCloseDisplay(server.dsp); XCloseDisplay(server.dsp);
} }
@ -288,14 +289,14 @@ void add_entry (char *key, char *value)
/* Clock */ /* Clock */
else if (strcmp (key, "time1_format") == 0) { else if (strcmp (key, "time1_format") == 0) {
if (panel.clock.time1_format) g_free(panel.clock.time1_format); if (time1_format) g_free(time1_format);
if (strlen(value) > 0) panel.clock.time1_format = strdup (value); if (strlen(value) > 0) time1_format = strdup (value);
else panel.clock.time1_format = 0; else time1_format = 0;
} }
else if (strcmp (key, "time2_format") == 0) { else if (strcmp (key, "time2_format") == 0) {
if (panel.clock.time2_format) g_free(panel.clock.time2_format); if (time2_format) g_free(time2_format);
if (strlen(value) > 0) panel.clock.time2_format = strdup (value); if (strlen(value) > 0) time2_format = strdup (value);
else panel.clock.time2_format = 0; else time2_format = 0;
} }
else if (strcmp (key, "time1_font") == 0) { else if (strcmp (key, "time1_font") == 0) {
if (panel.clock.time1_font_desc) pango_font_description_free(panel.clock.time1_font_desc); if (panel.clock.time1_font_desc) pango_font_description_free(panel.clock.time1_font_desc);
@ -522,7 +523,7 @@ void config_taskbar()
panel.area.list = g_slist_append(panel.area.list, tskbar); panel.area.list = g_slist_append(panel.area.list, tskbar);
} }
} }
if (panel.clock.time1_format) if (time1_format)
panel.area.list = g_slist_append(panel.area.list, &panel.clock); panel.area.list = g_slist_append(panel.area.list, &panel.clock);
//printf("taskbar (desktop x monitor) : (%d x %d)\n", panel.nb_desktop, panel.nb_monitor); //printf("taskbar (desktop x monitor) : (%d x %d)\n", panel.nb_desktop, panel.nb_monitor);
@ -552,7 +553,8 @@ void config_finish ()
fprintf(stderr, "tint2 error : invalid monitor size.\n"); fprintf(stderr, "tint2 error : invalid monitor size.\n");
} }
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width - 1 - panel.marginleft - panel.marginright; // use panel.marginleft and panel.marginright even in full width mode
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width - panel.marginleft - panel.marginright;
// taskbar // taskbar
g_taskbar.posy = panel.area.pix.border.width + panel.area.paddingy; g_taskbar.posy = panel.area.pix.border.width + panel.area.paddingy;

View file

@ -32,9 +32,6 @@
void visual_refresh () void visual_refresh ()
{ {
if (!panel.area.pix.pmap)
set_panel_background();
if (server.pmap) XFreePixmap (server.dsp, server.pmap); if (server.pmap) XFreePixmap (server.dsp, server.pmap);
server.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth); server.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth);
@ -46,7 +43,10 @@ void visual_refresh ()
refresh (l->data); refresh (l->data);
// main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right.
XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0); // this feature is disabled !
//XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0);
XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
XFlush (server.dsp); XFlush (server.dsp);
panel.refresh = 0; panel.refresh = 0;
} }
@ -73,12 +73,14 @@ void set_panel_properties (Window win)
if (panel.position & TOP) { if (panel.position & TOP) {
struts[2] = panel.area.height + panel.marginy; struts[2] = panel.area.height + panel.marginy;
struts[8] = server.posx; struts[8] = server.posx;
struts[9] = server.posx + panel.area.width; // panel.area.width - 1 allowed full screen on monitor 2
struts[9] = server.posx + panel.area.width - 1;
} }
else { else {
struts[3] = panel.area.height + panel.marginy; struts[3] = panel.area.height + panel.marginy;
struts[10] = server.posx; struts[10] = server.posx;
struts[11] = server.posx + panel.area.width; // panel.area.width - 1 allowed full screen on monitor 2
struts[11] = server.posx + panel.area.width - 1;
} }
// Old specification : fluxbox need _NET_WM_STRUT. // Old specification : fluxbox need _NET_WM_STRUT.
XChangeProperty (server.dsp, win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4); XChangeProperty (server.dsp, win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4);
@ -113,34 +115,40 @@ void set_panel_properties (Window win)
void window_draw_panel () void window_draw_panel ()
{ {
Window win;
/* panel position determined here */ /* panel position determined here */
if (panel.position & LEFT) server.posx = server.monitor[panel.monitor].x + panel.marginleft; if (panel.position & LEFT) {
server.posx = server.monitor[panel.monitor].x + panel.marginleft;
}
else { else {
if (panel.position & RIGHT) server.posx = server.monitor[panel.monitor].x + server.monitor[panel.monitor].width - panel.area.width - panel.marginright; if (panel.position & RIGHT) {
else server.posx = server.monitor[panel.monitor].x + ((server.monitor[panel.monitor].width - panel.area.width) / 2); //server.posx = server.monitor[panel.monitor].x + server.monitor[panel.monitor].width - panel.area.width - panel.marginright;
server.posx = server.monitor[panel.monitor].x + server.monitor[panel.monitor].width - panel.area.width;
}
else {
server.posx = server.monitor[panel.monitor].x + ((server.monitor[panel.monitor].width - panel.area.width) / 2);
}
} }
if (panel.position & TOP) server.posy = server.monitor[panel.monitor].y + panel.marginy; if (panel.position & TOP) {
else server.posy = server.monitor[panel.monitor].y + server.monitor[panel.monitor].height - panel.area.height - panel.marginy; server.posy = server.monitor[panel.monitor].y + panel.marginy;
}
else {
server.posy = server.monitor[panel.monitor].y + server.monitor[panel.monitor].height - panel.area.height - panel.marginy;
}
/* Catch some events */ // Catch some events
XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 }; XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 };
// XCreateWindow(display, parent, x, y, w, h, border, depth, class, visual, mask, attrib) // XCreateWindow(display, parent, x, y, w, h, border, depth, class, visual, mask, attrib)
// main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right.
Window win;
if (window.main_win) XDestroyWindow(server.dsp, window.main_win); if (window.main_win) XDestroyWindow(server.dsp, window.main_win);
win = XCreateWindow (server.dsp, server.root_win, server.posx+panel.area.paddingxlr, server.posy, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att); //win = XCreateWindow (server.dsp, server.root_win, server.posx+panel.area.paddingxlr, server.posy, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att);
win = XCreateWindow (server.dsp, server.root_win, server.posx, server.posy, panel.area.width, panel.area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att);
set_panel_properties (win); set_panel_properties (win);
window.main_win = win; window.main_win = win;
// replaced : server.gc = DefaultGC (server.dsp, 0); set_panel_background();
if (server.gc) XFree(server.gc);
XGCValues gcValues;
server.gc = XCreateGC(server.dsp, win, (unsigned long) 0, &gcValues);
if (server.gc_root) XFree(server.gc_root);
server.gc_root = XCreateGC(server.dsp, server.root_win, (unsigned long) 0, &gcValues);
XMapWindow (server.dsp, win); XMapWindow (server.dsp, win);
XFlush (server.dsp); XFlush (server.dsp);
@ -156,7 +164,7 @@ void visible_object()
// list of visible objects // list of visible objects
// start with clock because draw(clock) can resize others object // start with clock because draw(clock) can resize others object
if (panel.clock.time1_format) if (time1_format)
panel.area.list = g_slist_append(panel.area.list, &panel.clock); panel.area.list = g_slist_append(panel.area.list, &panel.clock);
int i, j; int i, j;
@ -174,44 +182,52 @@ void visible_object()
} }
Pixmap get_root_pixmap () void get_root_pixmap()
{ {
Pixmap ret; Pixmap ret = None;
Window root = RootWindow(server.dsp, server.screen);
ret = None; unsigned long *res;
int act_format, c = 2 ; int c = 2;
u_long nitems ;
u_long bytes_after ;
u_char *prop ;
Atom dummy_id;
do { do {
if (XGetWindowProperty(server.dsp, root, server.atom._XROOTPMAP_ID, 0, 1, res = server_get_property (server.root_win, server.atom._XROOTPMAP_ID, XA_PIXMAP, 0);
False, XA_PIXMAP, &dummy_id, &act_format, if (res) {
&nitems, &bytes_after, &prop) == Success) { ret = *((Pixmap*)res);
if (prop) { XFree(res);
ret = *((Pixmap *)prop); break;
XFree(prop); }
break; } while (--c > 0);
} server.root_pmap = ret;
}
} while (--c > 0);
if (ret == None) fprintf(stderr, "unknown background\n"); if (server.root_pmap != None) {
return ret; XGCValues gcv;
gcv.ts_x_origin = 0;
gcv.ts_y_origin = 0;
gcv.fill_style = FillTiled;
uint mask = GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle | GCTile;
gcv.tile = server.root_pmap;
XChangeGC(server.dsp, server.gc, mask, &gcv);
//fprintf(stderr, "pixmap background detected\n");
}
else
fprintf(stderr, "pixmap background detection failed\n");
} }
void set_panel_background() void set_panel_background()
{ {
Pixmap wall = get_root_pixmap(); get_root_pixmap();
if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap); if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap);
panel.area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth); panel.area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth);
// add layer of root pixmap // copy background (server.root_pmap) in panel
XCopyArea(server.dsp, wall, panel.area.pix.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0); Window dummy;
int x, y ;
XTranslateCoordinates(server.dsp, window.main_win, server.root_win, 0, 0, &x, &y, &dummy);
XSetTSOrigin(server.dsp, server.gc, -x, -y) ;
XFillRectangle(server.dsp, panel.area.pix.pmap, server.gc, 0, 0, panel.area.width, panel.area.height);
// draw background panel // draw background panel
cairo_surface_t *cs; cairo_surface_t *cs;
@ -224,10 +240,11 @@ void set_panel_background()
cairo_destroy (c); cairo_destroy (c);
cairo_surface_destroy (cs); cairo_surface_destroy (cs);
// copy background panel on desktop window // redraw panel
XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
set_redraw (&panel.area); set_redraw (&panel.area);
// copy background panel on desktop window
//XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
} }

View file

@ -82,6 +82,11 @@ void visual_refresh ();
void set_panel_properties (Window win); void set_panel_properties (Window win);
void window_draw_panel (); void window_draw_panel ();
void visible_object(); void visible_object();
// draw background panel
void set_panel_background(); void set_panel_background();
// detect server.root_pmap
void get_root_pixmap();
#endif #endif

View file

@ -172,19 +172,36 @@ void get_monitors()
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor); XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);
if (info) { if (info) {
int i; int i = 0, nb=0, j;
//printf("nb_monitors %d\n", nb_monitor);
server.nb_monitor = nb_monitor;
server.monitor = calloc(nb_monitor, sizeof(Monitor)); server.monitor = calloc(nb_monitor, sizeof(Monitor));
for (i = 0; i < server.nb_monitor; i++) { while (i < nb_monitor) {
server.monitor[i].x = info[i].x_org; for (j = 0; j < i; j++) {
server.monitor[i].y = info[i].y_org; 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)) {
server.monitor[i].width = info[i].width; 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) {
server.monitor[i].height = info[i].height; // add the first monitor
break;
}
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 added\n", i);
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); XFree(info);
server.nb_monitor = nb;
// ordered monitor according to coordinate // ordered monitor according to coordinate
qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor); qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor);
} }

View file

@ -17,72 +17,74 @@
typedef struct Global_atom typedef struct Global_atom
{ {
Atom _XROOTPMAP_ID; Atom _XROOTPMAP_ID;
Atom _NET_CURRENT_DESKTOP; Atom _NET_CURRENT_DESKTOP;
Atom _NET_NUMBER_OF_DESKTOPS; Atom _NET_NUMBER_OF_DESKTOPS;
Atom _NET_DESKTOP_GEOMETRY; Atom _NET_DESKTOP_GEOMETRY;
Atom _NET_DESKTOP_VIEWPORT; Atom _NET_DESKTOP_VIEWPORT;
Atom _NET_ACTIVE_WINDOW; Atom _NET_ACTIVE_WINDOW;
Atom _NET_WM_WINDOW_TYPE; Atom _NET_WM_WINDOW_TYPE;
Atom _NET_WM_STATE_SKIP_PAGER; Atom _NET_WM_STATE_SKIP_PAGER;
Atom _NET_WM_STATE_SKIP_TASKBAR; Atom _NET_WM_STATE_SKIP_TASKBAR;
Atom _NET_WM_STATE_STICKY; Atom _NET_WM_STATE_STICKY;
Atom _NET_WM_WINDOW_TYPE_DOCK; Atom _NET_WM_WINDOW_TYPE_DOCK;
Atom _NET_WM_WINDOW_TYPE_DESKTOP; Atom _NET_WM_WINDOW_TYPE_DESKTOP;
Atom _NET_WM_WINDOW_TYPE_TOOLBAR; Atom _NET_WM_WINDOW_TYPE_TOOLBAR;
Atom _NET_WM_WINDOW_TYPE_MENU; Atom _NET_WM_WINDOW_TYPE_MENU;
Atom _NET_WM_WINDOW_TYPE_SPLASH; Atom _NET_WM_WINDOW_TYPE_SPLASH;
Atom _NET_WM_WINDOW_TYPE_DIALOG; Atom _NET_WM_WINDOW_TYPE_DIALOG;
Atom _NET_WM_WINDOW_TYPE_NORMAL; Atom _NET_WM_WINDOW_TYPE_NORMAL;
Atom _NET_WM_DESKTOP; Atom _NET_WM_DESKTOP;
Atom WM_STATE; Atom WM_STATE;
Atom _NET_WM_STATE; Atom _NET_WM_STATE;
Atom _NET_WM_STATE_SHADED; Atom _NET_WM_STATE_SHADED;
Atom _NET_WM_STATE_BELOW; Atom _NET_WM_STATE_BELOW;
Atom _NET_WM_STATE_MODAL; Atom _NET_WM_STATE_MODAL;
Atom _NET_CLIENT_LIST; Atom _NET_CLIENT_LIST;
Atom _NET_WM_NAME; Atom _NET_WM_NAME;
Atom _NET_WM_VISIBLE_NAME; Atom _NET_WM_VISIBLE_NAME;
Atom _NET_WM_STRUT; Atom _NET_WM_STRUT;
Atom _NET_WM_ICON; Atom _NET_WM_ICON;
Atom _NET_CLOSE_WINDOW; Atom _NET_CLOSE_WINDOW;
Atom UTF8_STRING; Atom UTF8_STRING;
Atom _NET_SUPPORTING_WM_CHECK; Atom _NET_SUPPORTING_WM_CHECK;
Atom _WIN_LAYER; Atom _WIN_LAYER;
Atom _NET_WM_STRUT_PARTIAL; Atom _NET_WM_STRUT_PARTIAL;
Atom WM_NAME; Atom WM_NAME;
Atom __SWM_VROOT; Atom __SWM_VROOT;
Atom _MOTIF_WM_HINTS; Atom _MOTIF_WM_HINTS;
} Global_atom; } Global_atom;
typedef struct Monitor typedef struct Monitor
{ {
int x; int x;
int y; int y;
int width; int width;
int height; int height;
} Monitor; } Monitor;
typedef struct typedef struct
{ {
Display *dsp; Display *dsp;
Window root_win; Window root_win;
int desktop; int desktop;
int screen; int screen;
int depth; int depth;
int nb_desktop; int nb_desktop;
Monitor *monitor; // number of monitor (without monitor included into another one)
int nb_monitor; int nb_monitor;
int got_root_win; Monitor *monitor;
Visual *visual; int got_root_win;
int posx, posy; Visual *visual;
Pixmap pmap; int posx, posy;
GC gc; Pixmap pmap;
GC gc_root; // root background
Global_atom atom; Pixmap root_pmap;
GC gc;
Global_atom atom;
} Server_global; } Server_global;
@ -97,6 +99,9 @@ void server_refresh_root_pixmap ();
void server_refresh_main_pixmap (); void server_refresh_main_pixmap ();
void server_catch_error (Display *d, XErrorEvent *ev); void server_catch_error (Display *d, XErrorEvent *ev);
void server_init_atoms (); void server_init_atoms ();
// detect monitors
// doesn't count monitor included into another one
void get_monitors(); void get_monitors();

View file

@ -153,7 +153,7 @@ void resize_taskbar()
else taskbar_on_screen = panel.nb_monitor; else taskbar_on_screen = panel.nb_monitor;
taskbar_width = panel.area.width - (2 * panel.area.paddingxlr) - (2 * panel.area.pix.border.width); taskbar_width = panel.area.width - (2 * panel.area.paddingxlr) - (2 * panel.area.pix.border.width);
if (panel.clock.time1_format) if (time1_format)
taskbar_width -= (panel.clock.area.width + panel.area.paddingx); taskbar_width -= (panel.clock.area.width + panel.area.paddingx);
taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) / taskbar_on_screen; taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) / taskbar_on_screen;

View file

@ -75,12 +75,14 @@ void init ()
server.depth = DefaultDepth (server.dsp, server.screen); server.depth = DefaultDepth (server.dsp, server.screen);
server.visual = DefaultVisual (server.dsp, server.screen); server.visual = DefaultVisual (server.dsp, server.screen);
server.desktop = server_get_current_desktop (); 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);
// init systray // init systray
display = server.dsp; //display = server.dsp;
root = RootWindow(display, DefaultScreen(display)); //root = RootWindow(display, DefaultScreen(display));
//create_main_window(); //create_main_window();
//kde_init(); //kde_init();
//net_init(); //net_init();
@ -296,8 +298,7 @@ void event_property_notify (Window win, Atom at)
} }
/* Wallpaper changed */ /* Wallpaper changed */
else if (at == server.atom._XROOTPMAP_ID) { else if (at == server.atom._XROOTPMAP_ID) {
XFreePixmap (server.dsp, panel.area.pix.pmap); set_panel_background();
panel.area.pix.pmap = 0;
panel.refresh = 1; panel.refresh = 1;
} }
} }
@ -395,15 +396,15 @@ void event_timer()
{ {
struct timeval stv; struct timeval stv;
if (!panel.clock.time1_format) return; if (!time1_format) return;
if (gettimeofday(&stv, 0)) return; if (gettimeofday(&stv, 0)) return;
if (abs(stv.tv_sec - panel.clock.clock.tv_sec) < panel.clock.time_precision) return; if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
// update clock // update clock
panel.clock.clock.tv_sec = stv.tv_sec; time_clock.tv_sec = stv.tv_sec;
panel.clock.clock.tv_sec -= panel.clock.clock.tv_sec % panel.clock.time_precision; time_clock.tv_sec -= time_clock.tv_sec % time_precision;
panel.clock.area.redraw = 1; panel.clock.area.redraw = 1;
panel.refresh = 1; panel.refresh = 1;
} }
@ -420,8 +421,6 @@ int main (int argc, char *argv[])
init (); init ();
load_config: load_config:
if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap);
panel.area.pix.pmap = 0;
// append full transparency background // append full transparency background
list_back = g_slist_append(0, calloc(1, sizeof(Area))); list_back = g_slist_append(0, calloc(1, sizeof(Area)));
@ -470,8 +469,9 @@ load_config:
break; break;
case Expose: case Expose:
XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy); //XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0); //XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0);
XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
break; break;
case PropertyNotify: case PropertyNotify:

BIN
src/tint2

Binary file not shown.

View file

@ -26,7 +26,7 @@ border_color = #ffffff 70
panel_monitor = 1 panel_monitor = 1
panel_position = bottom center panel_position = bottom center
panel_size = 0 30 panel_size = 0 30
panel_margin = 15 2 15 panel_margin = 20 2
panel_padding = 9 0 panel_padding = 9 0
font_shadow = 0 font_shadow = 0
panel_background_id = 1 panel_background_id = 1

View file

@ -6,8 +6,8 @@
# BACKGROUND AND BORDER # BACKGROUND AND BORDER
#--------------------------------------------- #---------------------------------------------
rounded = 1 rounded = 1
border_width = 0 border_width = 0
background_color = #282828 60 background_color = #282828 40
border_color = #000000 0 border_color = #000000 0
rounded = 1 rounded = 1
@ -24,9 +24,9 @@ border_color = #cccccc 40
# PANEL # PANEL
#--------------------------------------------- #---------------------------------------------
panel_monitor = 1 panel_monitor = 1
panel_position = top left panel_position = top center
panel_size = 0 27 panel_size = 0 27
panel_margin = 0 0 panel_margin = 5 0
panel_padding = 7 3 7 panel_padding = 7 3 7
font_shadow = 0 font_shadow = 0
panel_background_id = 1 panel_background_id = 1
@ -61,8 +61,8 @@ task_active_background_id = 3
#--------------------------------------------- #---------------------------------------------
# CLOCK # CLOCK
#--------------------------------------------- #---------------------------------------------
time1_format = %H:%M:%S time1_format = %H:%M
time1_font = sans 7 time1_font = sans 7
time2_format = %A %d %B time2_format = %A %d %B
time2_font = sans 7 time2_font = sans 7
clock_font_color = #ffffff 100 clock_font_color = #ffffff 100