From: Thierry Lorthiois Date: Tue, 3 Feb 2009 20:40:46 +0000 (+0000) Subject: fixed issue 13, removed Window magager s menu for stability reason X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=cb9288bcb990b5ff5b550285f6d3ef752bd44d68;p=chaz%2Ftint2 fixed issue 13, removed Window magager s menu for stability reason --- diff --git a/ChangeLog b/ChangeLog index ba42e14..cdbfc22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ -2009-01-30 -- fixed issue 13 (not sure but it look right) +2009-02-05 +- 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 - use panel_margin parameter even with full_width diff --git a/doc/tint2-0.7.odt b/doc/tint2-0.7.odt index 37a72fe..52535d0 100644 Binary files a/doc/tint2-0.7.odt and b/doc/tint2-0.7.odt differ diff --git a/src/clock/clock.c b/src/clock/clock.c index 97ab535..e90f83f 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -30,33 +30,39 @@ #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) { char buf_time[40]; char buf_date[40]; 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; - else clock->time_precision = 1; + if (strchr(time1_format, 'S') == NULL) time_precision = 60; + else time_precision = 1; clock->area.posy = panel.area.pix.border.width + panel.area.paddingy; clock->area.height = panel.area.height - (2 * clock->area.posy); clock->area.width = 0; // force posx and width detection clock->area.redraw = 1; - gettimeofday(&clock->clock, 0); - clock->clock.tv_sec -= clock->clock.tv_sec % clock->time_precision; + gettimeofday(&time_clock, 0); + time_clock.tv_sec -= time_clock.tv_sec % time_precision; - strftime(buf_time, sizeof(buf_time), clock->time1_format, localtime(&clock->clock.tv_sec)); - if (clock->time2_format) - strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec)); + 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)); 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; - 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)); 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; time_width = date_width = 0; - strftime(buf_time, sizeof(buf_time), clock->time1_format, localtime(&clock->clock.tv_sec)); - if (clock->time2_format) - strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec)); + 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)); //printf(" draw_foreground_clock : %s\n", buf_time); redraw: @@ -87,7 +93,7 @@ redraw: pango_layout_set_indent(layout, 0); pango_layout_set_text (layout, buf_time, strlen(buf_time)); 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_indent(layout, 0); pango_layout_set_text (layout, buf_date, strlen(buf_date)); @@ -120,7 +126,7 @@ redraw: cairo_move_to (c, 0, clock->time1_posy); 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_indent(layout, 0); pango_layout_set_text (layout, buf_date, strlen(buf_date)); diff --git a/src/clock/clock.h b/src/clock/clock.h index 246bb2e..4eea837 100644 --- a/src/clock/clock.h +++ b/src/clock/clock.h @@ -1,9 +1,9 @@ /************************************************************************** * Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) * -* clock : -* - draw clock, adjust width -* +* Clock with fonctionnal data (timeval, precision) and drawing data (area, font, ...). +* Each panel use his own drawing data. +* **************************************************************************/ #ifndef CLOCK_H @@ -23,13 +23,13 @@ typedef struct Clock { PangoFontDescription *time2_font_desc; int time1_posy; int time2_posy; - char *time1_format; - char *time2_format; - - struct timeval clock; - int time_precision; } Clock; +extern char *time1_format; +extern char *time2_format; +extern struct timeval time_clock; +extern int time_precision; + // initialize clock : y position, precision, ... void init_clock(Clock *clock, int panel_height); diff --git a/src/config.c b/src/config.c index fd1cfcc..e292375 100644 --- a/src/config.c +++ b/src/config.c @@ -77,9 +77,10 @@ void cleanup () 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.taskbar) cleanup_taskbar(); - if (panel.clock.time1_format) g_free(panel.clock.time1_format); - if (panel.clock.time2_format) g_free(panel.clock.time2_format); + if (time1_format) g_free(time1_format); + if (time2_format) g_free(time2_format); if (server.monitor) free(server.monitor); + XFreeGC(server.dsp, server.gc); XCloseDisplay(server.dsp); } @@ -288,14 +289,14 @@ void add_entry (char *key, char *value) /* Clock */ else if (strcmp (key, "time1_format") == 0) { - if (panel.clock.time1_format) g_free(panel.clock.time1_format); - if (strlen(value) > 0) panel.clock.time1_format = strdup (value); - else panel.clock.time1_format = 0; + if (time1_format) g_free(time1_format); + if (strlen(value) > 0) time1_format = strdup (value); + else time1_format = 0; } else if (strcmp (key, "time2_format") == 0) { - if (panel.clock.time2_format) g_free(panel.clock.time2_format); - if (strlen(value) > 0) panel.clock.time2_format = strdup (value); - else panel.clock.time2_format = 0; + if (time2_format) g_free(time2_format); + if (strlen(value) > 0) time2_format = strdup (value); + else time2_format = 0; } else if (strcmp (key, "time1_font") == 0) { 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); } } - if (panel.clock.time1_format) + if (time1_format) 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); @@ -552,7 +553,8 @@ void config_finish () 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 g_taskbar.posy = panel.area.pix.border.width + panel.area.paddingy; diff --git a/src/panel.c b/src/panel.c index f2e9746..cbe765b 100644 --- a/src/panel.c +++ b/src/panel.c @@ -32,9 +32,6 @@ void visual_refresh () { - if (!panel.area.pix.pmap) - set_panel_background(); - if (server.pmap) XFreePixmap (server.dsp, server.pmap); 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); // 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); panel.refresh = 0; } @@ -73,12 +73,14 @@ void set_panel_properties (Window win) if (panel.position & TOP) { struts[2] = panel.area.height + panel.marginy; 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 { struts[3] = panel.area.height + panel.marginy; 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. 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 () { - Window win; - /* 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 { - if (panel.position & RIGHT) server.posx = server.monitor[panel.monitor].x + server.monitor[panel.monitor].width - panel.area.width - panel.marginright; - else server.posx = server.monitor[panel.monitor].x + ((server.monitor[panel.monitor].width - panel.area.width) / 2); + if (panel.position & RIGHT) { + //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; - else server.posy = server.monitor[panel.monitor].y + server.monitor[panel.monitor].height - panel.area.height - panel.marginy; + if (panel.position & TOP) { + 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 }; // 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. + Window 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); window.main_win = win; - // replaced : server.gc = DefaultGC (server.dsp, 0); - 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); + set_panel_background(); XMapWindow (server.dsp, win); XFlush (server.dsp); @@ -156,7 +164,7 @@ void visible_object() // list of visible objects // 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); int i, j; @@ -174,44 +182,52 @@ void visible_object() } -Pixmap get_root_pixmap () +void get_root_pixmap() { - Pixmap ret; - Window root = RootWindow(server.dsp, server.screen); - - ret = None; - int act_format, c = 2 ; - u_long nitems ; - u_long bytes_after ; - u_char *prop ; - Atom dummy_id; - - do { - if (XGetWindowProperty(server.dsp, root, server.atom._XROOTPMAP_ID, 0, 1, - False, XA_PIXMAP, &dummy_id, &act_format, - &nitems, &bytes_after, &prop) == Success) { - if (prop) { - ret = *((Pixmap *)prop); - XFree(prop); - break; - } - } - } while (--c > 0); - - if (ret == None) fprintf(stderr, "unknown background\n"); - return ret; + Pixmap ret = None; + + unsigned long *res; + int c = 2; + + do { + res = server_get_property (server.root_win, server.atom._XROOTPMAP_ID, XA_PIXMAP, 0); + if (res) { + ret = *((Pixmap*)res); + XFree(res); + break; + } + } while (--c > 0); + server.root_pmap = ret; + + if (server.root_pmap != None) { + 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() { - Pixmap wall = get_root_pixmap(); + get_root_pixmap(); 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); - // add layer of root pixmap - XCopyArea(server.dsp, wall, panel.area.pix.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0); + // copy background (server.root_pmap) in panel + 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 cairo_surface_t *cs; @@ -224,10 +240,11 @@ void set_panel_background() cairo_destroy (c); cairo_surface_destroy (cs); - // 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); - + // redraw panel 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); } diff --git a/src/panel.h b/src/panel.h index 0ab2293..105cd8e 100644 --- a/src/panel.h +++ b/src/panel.h @@ -82,6 +82,11 @@ void visual_refresh (); void set_panel_properties (Window win); void window_draw_panel (); void visible_object(); + +// draw background panel void set_panel_background(); +// detect server.root_pmap +void get_root_pixmap(); + #endif diff --git a/src/server.c b/src/server.c index 4b5726d..8e90d24 100644 --- a/src/server.c +++ b/src/server.c @@ -172,19 +172,36 @@ void get_monitors() XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor); 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)); - for (i = 0; i < server.nb_monitor; i++) { - server.monitor[i].x = info[i].x_org; - server.monitor[i].y = info[i].y_org; - server.monitor[i].width = info[i].width; - server.monitor[i].height = info[i].height; + 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 + 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); - + server.nb_monitor = nb; + // ordered monitor according to coordinate qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor); } diff --git a/src/server.h b/src/server.h index 369014a..2f8a701 100644 --- a/src/server.h +++ b/src/server.h @@ -17,72 +17,74 @@ typedef struct Global_atom { - Atom _XROOTPMAP_ID; - Atom _NET_CURRENT_DESKTOP; - Atom _NET_NUMBER_OF_DESKTOPS; - Atom _NET_DESKTOP_GEOMETRY; - Atom _NET_DESKTOP_VIEWPORT; - Atom _NET_ACTIVE_WINDOW; - Atom _NET_WM_WINDOW_TYPE; - Atom _NET_WM_STATE_SKIP_PAGER; - Atom _NET_WM_STATE_SKIP_TASKBAR; - Atom _NET_WM_STATE_STICKY; - Atom _NET_WM_WINDOW_TYPE_DOCK; - Atom _NET_WM_WINDOW_TYPE_DESKTOP; - Atom _NET_WM_WINDOW_TYPE_TOOLBAR; - Atom _NET_WM_WINDOW_TYPE_MENU; - Atom _NET_WM_WINDOW_TYPE_SPLASH; - Atom _NET_WM_WINDOW_TYPE_DIALOG; - Atom _NET_WM_WINDOW_TYPE_NORMAL; - Atom _NET_WM_DESKTOP; - Atom WM_STATE; - Atom _NET_WM_STATE; - Atom _NET_WM_STATE_SHADED; - Atom _NET_WM_STATE_BELOW; - Atom _NET_WM_STATE_MODAL; - Atom _NET_CLIENT_LIST; - Atom _NET_WM_NAME; - Atom _NET_WM_VISIBLE_NAME; - Atom _NET_WM_STRUT; - Atom _NET_WM_ICON; - Atom _NET_CLOSE_WINDOW; - Atom UTF8_STRING; - Atom _NET_SUPPORTING_WM_CHECK; - Atom _WIN_LAYER; - Atom _NET_WM_STRUT_PARTIAL; - Atom WM_NAME; - Atom __SWM_VROOT; - Atom _MOTIF_WM_HINTS; + Atom _XROOTPMAP_ID; + Atom _NET_CURRENT_DESKTOP; + Atom _NET_NUMBER_OF_DESKTOPS; + Atom _NET_DESKTOP_GEOMETRY; + Atom _NET_DESKTOP_VIEWPORT; + Atom _NET_ACTIVE_WINDOW; + Atom _NET_WM_WINDOW_TYPE; + Atom _NET_WM_STATE_SKIP_PAGER; + Atom _NET_WM_STATE_SKIP_TASKBAR; + Atom _NET_WM_STATE_STICKY; + Atom _NET_WM_WINDOW_TYPE_DOCK; + Atom _NET_WM_WINDOW_TYPE_DESKTOP; + Atom _NET_WM_WINDOW_TYPE_TOOLBAR; + Atom _NET_WM_WINDOW_TYPE_MENU; + Atom _NET_WM_WINDOW_TYPE_SPLASH; + Atom _NET_WM_WINDOW_TYPE_DIALOG; + Atom _NET_WM_WINDOW_TYPE_NORMAL; + Atom _NET_WM_DESKTOP; + Atom WM_STATE; + Atom _NET_WM_STATE; + Atom _NET_WM_STATE_SHADED; + Atom _NET_WM_STATE_BELOW; + Atom _NET_WM_STATE_MODAL; + Atom _NET_CLIENT_LIST; + Atom _NET_WM_NAME; + Atom _NET_WM_VISIBLE_NAME; + Atom _NET_WM_STRUT; + Atom _NET_WM_ICON; + Atom _NET_CLOSE_WINDOW; + Atom UTF8_STRING; + Atom _NET_SUPPORTING_WM_CHECK; + Atom _WIN_LAYER; + Atom _NET_WM_STRUT_PARTIAL; + Atom WM_NAME; + Atom __SWM_VROOT; + Atom _MOTIF_WM_HINTS; } Global_atom; typedef struct Monitor { - int x; - int y; - int width; - int height; + int x; + int y; + int width; + int height; } Monitor; typedef struct { - Display *dsp; - Window root_win; - int desktop; - int screen; - int depth; - int nb_desktop; - Monitor *monitor; - int nb_monitor; - int got_root_win; - Visual *visual; - int posx, posy; - Pixmap pmap; - GC gc; - GC gc_root; - Global_atom atom; + Display *dsp; + Window root_win; + int desktop; + int screen; + int depth; + int nb_desktop; + // number of monitor (without monitor included into another one) + int nb_monitor; + Monitor *monitor; + int got_root_win; + Visual *visual; + int posx, posy; + Pixmap pmap; + // root background + Pixmap root_pmap; + GC gc; + Global_atom atom; } Server_global; @@ -97,6 +99,9 @@ void server_refresh_root_pixmap (); void server_refresh_main_pixmap (); void server_catch_error (Display *d, XErrorEvent *ev); void server_init_atoms (); + +// detect monitors +// doesn't count monitor included into another one void get_monitors(); diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 7a2bb3f..a2aa99c 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -153,7 +153,7 @@ void resize_taskbar() else taskbar_on_screen = panel.nb_monitor; 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 = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) / taskbar_on_screen; diff --git a/src/tint.c b/src/tint.c index 9ff04fc..e228aae 100644 --- a/src/tint.c +++ b/src/tint.c @@ -75,12 +75,14 @@ void init () 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); // init systray - display = server.dsp; - root = RootWindow(display, DefaultScreen(display)); + //display = server.dsp; + //root = RootWindow(display, DefaultScreen(display)); //create_main_window(); //kde_init(); //net_init(); @@ -296,8 +298,7 @@ void event_property_notify (Window win, Atom at) } /* Wallpaper changed */ else if (at == server.atom._XROOTPMAP_ID) { - XFreePixmap (server.dsp, panel.area.pix.pmap); - panel.area.pix.pmap = 0; + set_panel_background(); panel.refresh = 1; } } @@ -395,15 +396,15 @@ void event_timer() { struct timeval stv; - if (!panel.clock.time1_format) return; + if (!time1_format) 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 - panel.clock.clock.tv_sec = stv.tv_sec; - panel.clock.clock.tv_sec -= panel.clock.clock.tv_sec % panel.clock.time_precision; + time_clock.tv_sec = stv.tv_sec; + time_clock.tv_sec -= time_clock.tv_sec % time_precision; panel.clock.area.redraw = 1; panel.refresh = 1; } @@ -420,8 +421,6 @@ int main (int argc, char *argv[]) init (); load_config: - if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap); - panel.area.pix.pmap = 0; // append full transparency background list_back = g_slist_append(0, calloc(1, sizeof(Area))); @@ -470,8 +469,9 @@ load_config: break; 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, 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, 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, 0, 0, panel.area.width, panel.area.height, 0, 0); break; case PropertyNotify: diff --git a/src/tint2 b/src/tint2 index 71ec37c..effbfca 100755 Binary files a/src/tint2 and b/src/tint2 differ diff --git a/tintrc01 b/tintrc01 index 99a0c4a..d839c65 100644 --- a/tintrc01 +++ b/tintrc01 @@ -26,7 +26,7 @@ border_color = #ffffff 70 panel_monitor = 1 panel_position = bottom center panel_size = 0 30 -panel_margin = 15 2 15 +panel_margin = 20 2 panel_padding = 9 0 font_shadow = 0 panel_background_id = 1 diff --git a/tintrc02 b/tintrc02 index 1970a48..2206f35 100644 --- a/tintrc02 +++ b/tintrc02 @@ -6,8 +6,8 @@ # BACKGROUND AND BORDER #--------------------------------------------- rounded = 1 -border_width = 0 -background_color = #282828 60 +border_width = 0 +background_color = #282828 40 border_color = #000000 0 rounded = 1 @@ -24,9 +24,9 @@ border_color = #cccccc 40 # PANEL #--------------------------------------------- panel_monitor = 1 -panel_position = top left +panel_position = top center panel_size = 0 27 -panel_margin = 0 0 +panel_margin = 5 0 panel_padding = 7 3 7 font_shadow = 0 panel_background_id = 1 @@ -61,8 +61,8 @@ task_active_background_id = 3 #--------------------------------------------- # CLOCK #--------------------------------------------- -time1_format = %H:%M:%S -time1_font = sans 7 +time1_format = %H:%M +time1_font = sans 7 time2_format = %A %d %B time2_font = sans 7 clock_font_color = #ffffff 100