all repos — tint2 @ 9cc4916c69b5529cffab51793ad9fd8d78feb6e0

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

cleanup code

git-svn-id: http://tint2.googlecode.com/svn/trunk@56 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
lorthiois@bbsoft.fr lorthiois@bbsoft.fr@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

9cc4916c69b5529cffab51793ad9fd8d78feb6e0

parent

01393825148250443ada56a5c3aa5a17578c6147

M src/Makefilesrc/Makefile

@@ -23,7 +23,7 @@

$(PROGNAME): $(FILES) $(SYSTRAYOBJ) $(CC) $(CFLAGS) -I. -Iutil -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS) - #strip $(PROGNAME) + strip $(PROGNAME) install: mkdir -p $(BINDIR)
M src/clock/clock.csrc/clock/clock.c

@@ -41,45 +41,51 @@ static char buf_time[40];

static char buf_date[40]; -void init_clock(Clock *clock, Area *parent) +void init_clock() { - Panel *panel = (Panel *)parent; - int 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; - clock->area.parent = parent; - clock->area.panel = panel; - if (!time1_format) return; + for (i=0 ; i < nb_panel ; i++) { + panel = &panel1[i]; + clock = &panel->clock; - clock->area._draw_foreground = draw_foreground_clock; - clock->area._resize = resize_clock; + clock->area.parent = panel; + clock->area.panel = panel; + if (!clock->area.visible) return; - if (strchr(time1_format, 'S') == NULL) time_precision = 60; - else time_precision = 1; + clock->area._draw_foreground = draw_foreground_clock; + clock->area._resize = resize_clock; - // update clock to force update (-time_precision) - struct timeval stv; - gettimeofday(&stv, 0); - time_clock.tv_sec = stv.tv_sec - time_precision; - time_clock.tv_sec -= time_clock.tv_sec % time_precision; + if (strchr(time1_format, 'S') == NULL) time_precision = 60; + else time_precision = 1; - clock->area.posy = parent->pix.border.width + parent->paddingy; - clock->area.height = parent->height - (2 * clock->area.posy); - clock->area.resize = 1; - clock->area.redraw = 1; + // update clock to force update (-time_precision) + struct timeval stv; + gettimeofday(&stv, 0); + time_clock.tv_sec = stv.tv_sec - time_precision; + time_clock.tv_sec -= time_clock.tv_sec % time_precision; - 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.posy = panel->area.pix.border.width + panel->area.paddingy; + clock->area.height = panel->area.height - (2 * clock->area.posy); + clock->area.resize = 1; + clock->area.redraw = 1; - get_text_size(time1_font_desc, &time_height_ink, &time_height, parent->height, buf_time, strlen(buf_time)); - clock->time1_posy = (clock->area.height - time_height) / 2; + 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)); - if (time2_format) { - get_text_size(time2_font_desc, &date_height_ink, &date_height, parent->height, buf_date, strlen(buf_date)); + get_text_size(time1_font_desc, &time_height_ink, &time_height, panel->area.height, buf_time, strlen(buf_time)); + clock->time1_posy = (clock->area.height - time_height) / 2; - clock->time1_posy -= ((date_height_ink + 2) / 2); - clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2; - } + if (time2_format) { + get_text_size(time2_font_desc, &date_height_ink, &date_height, panel->area.height, buf_date, strlen(buf_date)); + + clock->time1_posy -= ((date_height_ink + 2) / 2); + clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2; + } + } }
M src/clock/clock.hsrc/clock/clock.h

@@ -33,7 +33,7 @@ extern PangoFontDescription *time2_font_desc;

// initialize clock : y position, precision, ... -void init_clock(Clock *clock, Area *parent); +void init_clock(); void draw_foreground_clock (void *obj, cairo_t *c, int active);
M src/config.csrc/config.c

@@ -311,6 +311,7 @@ else if (strcmp (key, "time1_format") == 0) {

if (time1_format) g_free(time1_format); if (strlen(value) > 0) time1_format = strdup (value); else time1_format = 0; + panel_config->clock.area.visible = 1; } else if (strcmp (key, "time2_format") == 0) { if (time2_format) g_free(time2_format);

@@ -410,12 +411,19 @@ memcpy(&panel_config->g_task.area.pix_active.back, &a->pix.back, sizeof(Color));

memcpy(&panel_config->g_task.area.pix_active.border, &a->pix.border, sizeof(Border)); } - /* Trayer */ - else if (strcmp (key, "trayer_background_id") == 0) { + /* Systray */ + else if (strcmp (key, "systray_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->systray.area.paddingxlr = panel_config->systray.area.paddingx = atoi (value1); + if (value2) panel_config->systray.area.paddingy = atoi (value2); + if (value3) panel_config->systray.area.paddingx = atoi (value3); + panel_config->systray.area.visible = 1; + } + else if (strcmp (key, "systray_background_id") == 0) { int id = atoi (value); Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->trayer.area.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->trayer.area.pix.border, &a->pix.border, sizeof(Border)); + memcpy(&panel_config->systray.area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->systray.area.pix.border, &a->pix.border, sizeof(Border)); } /* Mouse actions */

@@ -569,14 +577,18 @@ panel1[i].monitor = i;

} } + // TODO: user can configure layout => ordered objects in panel.area.list + // clock and systray before taskbar because resize(clock) can resize others object init_panel(); + init_clock(); // force the resize for (i=0 ; i < nb_panel ; i++) { panel1[i].area.resize = 1; - if (time1_format) + if (panel1[i].clock.area.visible) resize_clock(&panel1[i].clock); } + init_systray(); init_taskbar(); visible_object();
M src/panel.csrc/panel.c

@@ -67,9 +67,10 @@ p->g_taskbar.panel = p;

p->g_task.area.panel = p; // add childs - if (time1_format) + if (p->clock.area.visible) p->area.list = g_slist_append(p->area.list, &p->clock); - //panel->area.list = g_slist_append(panel->area.list, &panel->trayer); + if (p->systray.area.visible) + p->area.list = g_slist_append(p->area.list, &p->systray); // detect panel size if (p->pourcentx)

@@ -120,8 +121,6 @@ set_panel_properties(p);

set_panel_background(p); XMapWindow (server.dsp, p->main_win); - - init_clock(&p->clock, &p->area); } panel_refresh = 1; }

@@ -174,9 +173,10 @@ if (panel_mode == MULTI_DESKTOP) taskbar_on_screen = panel->nb_desktop;

else taskbar_on_screen = 1; taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); - if (time1_format) + if (panel->clock.area.visible) taskbar_width -= (panel->clock.area.width + panel->area.paddingx); - //taskbar_width -= (panel->trayer.area.width + panel->area.paddingx); + if (panel->systray.area.visible) + taskbar_width -= (panel->systray.area.width + panel->area.paddingx); taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) / taskbar_on_screen;

@@ -212,12 +212,6 @@ int i, j;

for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i]; - - // clock before taskbar because resize(clock) can resize others object - if (time1_format) - panel->clock.area.visible = 1; - else - panel->clock.area.visible = 0; Taskbar *taskbar; for (j=0 ; j < panel->nb_desktop ; j++) {
M src/panel.hsrc/panel.h

@@ -79,7 +79,7 @@ Clock clock;

// -------------------------------------------------- // systray - Systraybar trayer; + Systraybar systray; // global taskbar parameter //Area g_systraybar;
M src/server.csrc/server.c

@@ -73,7 +73,7 @@ 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)); - server.atom._NET_SYSTEM_TRAY = XInternAtom(server.dsp, name_trayer, False); + server.atom._NET_SYSTEM_TRAY_SCREEN = XInternAtom(server.dsp, name_trayer, False); server.atom._NET_SYSTEM_TRAY_OPCODE = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_OPCODE", False); server.atom.MANAGER = XInternAtom(server.dsp, "MANAGER", False); server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
M src/server.hsrc/server.h

@@ -53,7 +53,7 @@ Atom _NET_WM_STRUT_PARTIAL;

Atom WM_NAME; Atom __SWM_VROOT; Atom _MOTIF_WM_HINTS; - Atom _NET_SYSTEM_TRAY; + Atom _NET_SYSTEM_TRAY_SCREEN; Atom _NET_SYSTEM_TRAY_OPCODE; Atom MANAGER; Atom _NET_SYSTEM_TRAY_MESSAGE_DATA;
D src/systray/Makefile

@@ -1,71 +0,0 @@

-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# -# # -# Change these values to customize your installation and build process # -# # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# - -# Change this PREFIX to where you want docker to be installed -PREFIX=/usr/local -# Change this XLIBPATH to point to your X11 development package's installation -XLIBPATH=/usr/X11R6/lib - -# Sets some flags for stricter compiling -CFLAGS=-pedantic -Wall -W -O - -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# -# # -# Leave the rest of the Makefile alone if you want it to build! # -# # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# - -PACKAGE=docker -VERSION=1.5 - -target=docker -sources=docker.c kde.c icons.c xproperty.c net.c -headers=docker.h kde.h icons.h xproperty.h net.h version.h -extra=README COPYING version.h.in - -all: $(target) $(sources) $(headers) - @echo Build Successful - -$(target): $(sources:.c=.o) - $(CC) $(CFLAGS) -L$(XLIBPATH) -lX11 \ - `pkg-config --libs glib-2.0` $^ -o $@ - -%.o: %.c - $(CC) -c $(CFLAGS) `pkg-config --cflags glib-2.0` $< - -version.h: version.h.in Makefile - sed -e "s/@VERSION@/$(VERSION)/" version.h.in > $@ - -install: all - install $(target) $(PREFIX)/bin/$(target) - -uninstall: - rm -f $(PREFIX)/$(target) - -clean: - rm -rf .dist - rm -f core *.o .\#* *\~ $(target) - -distclean: clean - rm -f version.h - rm -f $(PACKAGE)-*.tar.gz - -dist: Makefile $(sources) $(headers) $(extra) - mkdir -p .dist/$(PACKAGE)-$(VERSION) && \ - cp $^ .dist/$(PACKAGE)-$(VERSION) && \ - tar -c -z -C .dist -f \ - $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) && \ - rm -rf .dist - -love: $(sources) - touch $^ - -# local dependancies -docker.o: docker.c version.h kde.h icons.h docker.h net.h -icons.o: icons.c icons.h docker.h -kde.o: kde.c kde.h docker.h xproperty.h -net.o: net.c net.h docker.h icons.h -xproperty.o: xproperty.c xproperty.h docker.h
D src/systray/README

@@ -1,75 +0,0 @@

-Docker - Docking System Tray - -Copyright (C) 2003 Ben Jansens - - -What is Docker? - -Docker is a docking application (WindowMaker dock app) which acts as a system -tray for KDE3 and GNOME2. It can be used to replace the panel in either -environment, allowing you to have a system tray without running the KDE/GNOME -panel. - - -What window managers can I use Docker with? - -I wrote and designed Docker to work with Openbox 2, but it should work fine in -any window manager that supports WindowMaker dock apps. - - -Why don't my KDE3 system tray icons show up? - -Docker requires a KDE3 compliant window manager to handle KDE3 system tray -icons, and since it is a docking application, the window manager needs to also -support WindowMaker Dock Apps. The only window manager that meets these -requirements to my knowledge is: - - Openbox 2 (http://icculus.org/openbox) -If you know of any other window managers that support the KDE3 hints for the -system tray and docking apps (i.e. that docker works in), please let me know so -I can add them to this list, and test docker out in them! - - -Why don't my GNOME2 system tray icons show up? - -I don't know! Email me and let me know what application isn't working. (Don't -you dare email me about a GNOME1 application! :) - - -Who wrote Docker? - -Me, of course. That is, Ben Jansens. I can be reached at <ben@orodu.net>. I am -the founder and currently the project head of sorts for the Openbox project. - - -=============================== -|| INSTALLATION INSTRUCTIONS || -=============================== - -To install this application, simply do the following: - -% make -(as root) -# make install - -You can change a couple of things in the Makefile if you want to: -PREFIX defines where the program will be installed to. -XLIBPATH defines where your libX11.so is located. If it is not on the standard - /usr/X11R6/lib path, then you will have to change this. - -================== -|| LICENSE INFO || -================== - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
D src/systray/docker.c

@@ -1,180 +0,0 @@

-#include "version.h" -#include "kde.h" -#include "icons.h" -#include "docker.h" -#include "net.h" - -#include <assert.h> -#include <signal.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <X11/Xutil.h> - -int argc; -char **argv; - -Window win = None, hint_win = None, root = None; -gboolean wmaker = FALSE; /* WindowMakerMode!!! wheeee */ -Display *display = NULL; -GSList *icons = NULL; -int width = 0, height = 0; -int border = 1; /* blank area around icons. must be > 0 */ -gboolean horizontal = TRUE; /* layout direction */ -int icon_size = 24; /* width and height of systray icons */ - -//static char *display_string = NULL; -/* excluding the border. sum of all child apps */ -static gboolean exit_app = FALSE; - -/* -void create_hint_win() -{ - XWMHints hints; - XClassHint classhints; - - hint_win = XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, 0, 0); - assert(hint_win); - - hints.flags = StateHint | WindowGroupHint | IconWindowHint; - hints.initial_state = WithdrawnState; - hints.window_group = hint_win; - hints.icon_window = win; - - classhints.res_name = "docker"; - classhints.res_class = "Docker"; - - XSetWMProperties(display, hint_win, NULL, NULL, argv, argc, - NULL, &hints, &classhints); - - XMapWindow(display, hint_win); -} - - -void create_main_window() -{ - XWMHints hints; - XTextProperty text; - char *name = "Docker"; - - // the border must be > 0 if not in wmaker mode - assert(wmaker || border > 0); - - if (!wmaker) - win = XCreateSimpleWindow(display, root, 0, 0, - border * 2, border * 2, 0, 0, 0); - else - win = XCreateSimpleWindow(display, root, 0, 0, - 64, 64, 0, 0, 0); - - assert(win); - - XStringListToTextProperty(&name, 1, &text); - XSetWMName(display, win, &text); - - hints.flags = StateHint; - hints.initial_state = WithdrawnState; - XSetWMHints(display, win, &hints); - - create_hint_win(); - - XSync(display, False); - XSetWindowBackgroundPixmap(display, win, ParentRelative); - XClearWindow(display, win); -} -*/ - -void reposition_icons() -{ - int x = border + ((width % icon_size) / 2), - y = border + ((height % icon_size) / 2); - GSList *it; - - for (it = icons; it != NULL; it = g_slist_next(it)) { - TrayWindow *traywin = it->data; - traywin->x = x; - traywin->y = y; - XMoveWindow(display, traywin->id, x, y); - XSync(display, False); - if (wmaker) { - x += icon_size; - if (x + icon_size > width) { - x = border; - y += icon_size; - } - } else if (horizontal) - x += icon_size; - else - y += icon_size; - } -} - - -void fix_geometry() -{ - GSList *it; - - // in wmaker mode we're a fixed size - if (wmaker) return; - - //* find the proper width and height - width = horizontal ? 0 : icon_size; - height = horizontal ? icon_size : 0; - for (it = icons; it != NULL; it = g_slist_next(it)) { - if (horizontal) - width += icon_size; - else - height += icon_size; - } - - XResizeWindow(display, win, width + border * 2, height + border * 2); -} - -/* -int main(int c, char **v) -{ - struct sigaction act; - - argc = c; argv = v; - - act.sa_handler = signal_handler; - act.sa_flags = 0; - sigaction(SIGSEGV, &act, NULL); - sigaction(SIGPIPE, &act, NULL); - sigaction(SIGFPE, &act, NULL); - sigaction(SIGTERM, &act, NULL); - sigaction(SIGINT, &act, NULL); - sigaction(SIGHUP, &act, NULL); - - parse_cmd_line(argc, argv); - - display = XOpenDisplay(display_string); - if (!display) { - g_printerr("Unable to open Display %s. Exiting.\n", - DisplayString(display_string)); - } - - root = RootWindow(display, DefaultScreen(display)); - assert(root); - - if (wmaker) - width = height = 64 - border * 2; - - create_main_window(); - - // set up to find KDE systray icons, and get any that already exist - kde_init(); - - net_init(); - - // we want to get ConfigureNotify events, and assume our parent's background - // has changed when we do, so we need to refresh ourself to match - XSelectInput(display, win, StructureNotifyMask); - - event_loop(); - - XCloseDisplay(display); - - return 0; -} -*/
D src/systray/docker.h

@@ -1,31 +0,0 @@

-#ifndef __docker_h -#define __docker_h - -#include <glib.h> -#include <X11/Xlib.h> - -extern Display *display; -extern Window root, win; -extern GSList *icons; -extern int width, height; -extern int border; -extern gboolean horizontal; -extern int icon_size; -extern gboolean wmaker; - -typedef enum { - KDE = 1, /* kde specific */ - NET /* follows the standard (freedesktop.org) */ -} TrayWindowType; - -typedef struct -{ - TrayWindowType type; - Window id; - int x, y; -} TrayWindow; - -void reposition_icons(); -void fix_geometry(); - -#endif /* __docker_h */
D src/systray/icons.c

@@ -1,122 +0,0 @@

-#include "icons.h" -#include "net.h" -#include <assert.h> -#include <stdlib.h> - -gboolean error; -int window_error_handler(Display *d, XErrorEvent *e) -{ - d=d;e=e; - if (e->error_code == BadWindow) { - error = TRUE; - } else { - g_printerr("X ERROR NOT BAD WINDOW!\n"); - abort(); - } - return 0; -} - - -gboolean icon_swallow(TrayWindow *traywin) -{ - XErrorHandler old; - - error = FALSE; - old = XSetErrorHandler(window_error_handler); - XReparentWindow(display, traywin->id, win, 0, 0); - XSync(display, False); - XSetErrorHandler(old); - - return !error; -} - - -/* - The traywin must have its id and type set. -*/ -gboolean icon_add(Window id, TrayWindowType type) -{ - TrayWindow *traywin; - - assert(id); - assert(type); - - if (wmaker) { - /* do we have room in our window for another icon? */ - unsigned int max = (width / icon_size) * (height / icon_size); - if (g_slist_length(icons) >= max) - return FALSE; /* no room, sorry! REJECTED! */ - } - - traywin = g_new0(TrayWindow, 1); - traywin->type = type; - traywin->id = id; - - if (!icon_swallow(traywin)) { - g_free(traywin); - return FALSE; - } - - /* find the positon for the systray app window */ - if (!wmaker) { - traywin->x = border + (horizontal ? width : 0); - traywin->y = border + (horizontal ? 0 : height); - } else { - int count = g_slist_length(icons); - traywin->x = border + ((width % icon_size) / 2) + - (count % (width / icon_size)) * icon_size; - traywin->y = border + ((height % icon_size) / 2) + - (count / (height / icon_size)) * icon_size; - } - - /* add the new icon to the list */ - icons = g_slist_append(icons, traywin); - - /* watch for the icon trying to resize itself! BAD ICON! BAD! */ - XSelectInput(display, traywin->id, StructureNotifyMask); - - /* position and size the icon window */ - XMoveResizeWindow(display, traywin->id, - traywin->x, traywin->y, icon_size, icon_size); - - /* resize our window so that the new window can fit in it */ - fix_geometry(); - - /* flush before clearing, otherwise the clear isn't effective. */ - XFlush(display); - /* make sure the new child will get the right stuff in its background - for ParentRelative. */ - XClearWindow(display, win); - - /* show the window */ - XMapRaised(display, traywin->id); - - return TRUE; -} - - -void icon_remove(GSList *node) -{ - XErrorHandler old; - TrayWindow *traywin = node->data; - Window traywin_id = traywin->id; - - if (traywin->type == NET) - net_icon_remove(traywin); - - XSelectInput(display, traywin->id, NoEventMask); - - /* remove it from our list */ - g_free(node->data); - icons = g_slist_remove_link(icons, node); - - /* reparent it to root */ - error = FALSE; - old = XSetErrorHandler(window_error_handler); - XReparentWindow(display, traywin_id, root, 0, 0); - XSync(display, False); - XSetErrorHandler(old); - - reposition_icons(); - fix_geometry(); -}
D src/systray/icons.h

@@ -1,13 +0,0 @@

-#ifndef __icons_h -#define __icons_h - -#include <glib.h> -#include <X11/Xlib.h> -#include "docker.h" - -extern gboolean error; - -gboolean icon_add(Window id, TrayWindowType type); -void icon_remove(GSList *node); - -#endif /* __icons_h */
D src/systray/kde.c

@@ -1,76 +0,0 @@

-#include "kde.h" -#include "icons.h" -#include "docker.h" -#include "xproperty.h" -#include <assert.h> -#include <X11/Xatom.h> - -Atom kde_systray_prop = None; - -void kde_init() -{ - kde_systray_prop = XInternAtom(display, - "_KDE_NET_SYSTEM_TRAY_WINDOWS", False); - assert(kde_systray_prop); - - XSelectInput(display, root, PropertyChangeMask); - kde_update_icons(); -} - -void kde_update_icons() -{ - gulong count = (unsigned) -1; /* grab as many as possible */ - Window *ids; - unsigned int i; - GSList *it, *next; - gboolean removed = FALSE; /* were any removed? */ - - if (! xprop_get32(root, kde_systray_prop, XA_WINDOW, sizeof(Window)*8, - &count, &ids)) - return; - - /* add new windows to our list */ - for (i = 0; i < count; ++i) { - for (it = icons; it != NULL; it = g_slist_next(it)) { - TrayWindow *traywin = it->data; - if (traywin->id == ids[i]) - break; - } - if (!it) - icon_add(ids[i], KDE); - } - - /* remove windows from our list that no longer exist in the property */ - for (it = icons; it != NULL;) { - TrayWindow *traywin = it->data; - gboolean exists; - - if (traywin->type != KDE) { - /* don't go removing non-kde windows */ - exists = TRUE; - } else { - exists = FALSE; - for (i = 0; i < count; ++i) { - if (traywin->id == ids[i]) { - exists = TRUE; - break; - } - } - } - - next = g_slist_next(it); - if (!exists) { - icon_remove(it); - removed =TRUE; - } - it = next; - } - - if (removed) { - /* at least one tray app was removed, so reorganize 'em all and resize*/ - reposition_icons(); - fix_geometry(); - } - - XFree(ids); -}
D src/systray/kde.h

@@ -1,12 +0,0 @@

-#ifndef __kde_h -#define __kde_h - -#include <glib.h> -#include <X11/Xlib.h> - -extern Atom kde_systray_prop; - -void kde_update_icons(); -void kde_init(); - -#endif /* __kde_h */
D src/systray/net.c

@@ -1,44 +0,0 @@

-#include "net.h" -#include "docker.h" -#include "icons.h" -#include <assert.h> - -Atom net_opcode_atom; -Window net_sel_win; - -static Atom net_sel_atom; -static Atom net_manager_atom; -static Atom net_message_data_atom; - -/* defined in the systray spec */ -#define SYSTEM_TRAY_REQUEST_DOCK 0 -#define SYSTEM_TRAY_BEGIN_MESSAGE 1 -#define SYSTEM_TRAY_CANCEL_MESSAGE 2 - -static void net_create_selection_window() -{ - net_sel_win = XCreateSimpleWindow(display, root, -1, -1, 1, 1, 0, 0, 0); - assert(net_sel_win); -} - - -static void net_destroy_selection_window() -{ - XDestroyWindow(display, net_sel_win); - net_sel_win = None; -} - -void net_icon_remove(TrayWindow *traywin) -{ - assert(traywin); - - XSelectInput(display, traywin->id, NoEventMask); -} - - -void net_destroy() -{ - net_destroy_selection_window(); -} - -
D src/systray/net.h

@@ -1,15 +0,0 @@

-#ifndef __net_h -#define __net_h - -#include <glib.h> -#include <X11/Xlib.h> -#include "docker.h" - -extern Window net_sel_win; -extern Atom net_opcode_atom; - -void net_init(); -void net_message(XClientMessageEvent *e); -void net_icon_remove(TrayWindow *traywin); - -#endif /* __net_h */
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -36,34 +36,79 @@ #define SYSTEM_TRAY_REQUEST_DOCK 0

#define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 -Window net_sel_win; +Window net_sel_win = None; -void init_systray(Systraybar *sysbar, Area *parent) +void init_systray() { - Panel *panel = (Panel *)parent; + Panel *panel; + Systraybar *sysbar; + int i, run_systray; - sysbar->area.parent = parent; - sysbar->area.panel = panel; + cleanup_systray(); - sysbar->area.posy = parent->pix.border.width + parent->paddingy; - sysbar->area.height = parent->height - (2 * sysbar->area.posy); - sysbar->area.width = 100; + run_systray = 0; + for (i=0 ; i < nb_panel ; i++) { + if (panel1[i].systray.area.visible) { + run_systray = 1; + break; + } + } + if (run_systray) { + if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != None) { + fprintf(stderr, "tint2 warning : another systray is running\n"); + run_systray = 0; + } + } - sysbar->area.posx = panel->area.width - panel->clock.area.width - panel->area.paddingxlr - panel->area.pix.border.width - panel->area.paddingx - sysbar->area.width; + if (run_systray) + run_systray = net_init(); - sysbar->area.redraw = 1; + for (i=0 ; i < nb_panel ; i++) { + panel = &panel1[i]; + sysbar = &panel->systray; -//printf("init_systray"); + if (!run_systray) { + sysbar->area.visible = 0; + continue; + } + if (!sysbar->area.visible) + continue; - net_init(); + sysbar->area.parent = panel; + sysbar->area.panel = panel; + + sysbar->area.posy = panel->area.pix.border.width + panel->area.paddingy; + sysbar->area.height = panel->area.height - (2 * sysbar->area.posy); + sysbar->area.width = 100; + + sysbar->area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - sysbar->area.width; + if (panel->clock.area.visible) + sysbar->area.posx -= (panel->clock.area.width + panel->area.paddingx); + + sysbar->area.redraw = 1; + } } -// net_sel_atom == server.atom._NET_SYSTEM_TRAY -// net_opcode_atom == server.atom._NET_SYSTEM_TRAY_OPCODE -// net_manager_atom == server.atom.MANAGER -// net_message_data_atom == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA +void cleanup_systray() +{ + Panel *panel; + int i; + + for (i=0 ; i < nb_panel ; i++) { + panel = &panel1[i]; + if (!panel->systray.area.visible) continue; + + free_area(&panel->systray.area); + } + + if (net_sel_win != None) { + XDestroyWindow(server.dsp, net_sel_win); + net_sel_win = None; + } +} + int resize_systray (Systraybar *sysbar) {

@@ -90,12 +135,6 @@ width += icon_size;

} XResizeWindow(server.dsp, win, width + border * 2, height + border * 2); -} - - -static void net_create_selection_window() -{ - net_sel_win = XCreateSimpleWindow(server.dsp, root, -1, -1, 1, 1, 0, 0, 0); }

@@ -172,15 +211,15 @@ return TRUE;

} -void net_init() +int net_init() { // init systray protocol net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0); - XSetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY, net_sel_win, CurrentTime); - if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY) != net_sel_win) { - fprintf(stderr, "tint error : can't get trayer selection"); - return; + XSetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN, net_sel_win, CurrentTime); + if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) { + fprintf(stderr, "tint2 warning : can't get systray manager\n"); + return 0; } XEvent m;

@@ -188,11 +227,12 @@ m.type = ClientMessage;

m.xclient.message_type = server.atom.MANAGER; m.xclient.format = 32; m.xclient.data.l[0] = CurrentTime; - m.xclient.data.l[1] = server.atom._NET_SYSTEM_TRAY; + m.xclient.data.l[1] = server.atom._NET_SYSTEM_TRAY_SCREEN; m.xclient.data.l[2] = net_sel_win; m.xclient.data.l[3] = 0; m.xclient.data.l[4] = 0; XSendEvent(server.dsp, server.root_win, False, StructureNotifyMask, &m); + return 1; }
M src/systray/systraybar.hsrc/systray/systraybar.h

@@ -20,12 +20,19 @@

typedef struct { - Window id; - int x, y; + Window id; + int x, y; + + Window win; + long *icon_data; + int icon_width; + int icon_height; } TrayWindow; -void init_systray(Systraybar *sysbar, Area *parent); +void init_systray(); +void cleanup_systray(); +int net_init(); // return 1 if task_width changed int resize_systray (Systraybar *sysbar);
D src/systray/tint_merge.h

@@ -1,21 +0,0 @@

-/************************************************************************** -* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) -* -* Merge 'docker' with 'tint2'. -* The goal is to keep unchanged docker code, but without data duplication. -* -**************************************************************************/ - -#ifndef TINT_MERGE_H -#define TINT_MERGE_H -/* -#define display server.dsp -#define root server.root_win - -/* delete main(), parse_cmd_line() and display_string from docker.c - * include "tint_merge.h" in docker.h - */ - - -#endif -
D src/systray/version.h

@@ -1,1 +0,0 @@

-#define VERSION "1.5"
D src/systray/version.h.in

@@ -1,1 +0,0 @@

-#define VERSION "@VERSION@"
D src/systray/xproperty.c

@@ -1,64 +0,0 @@

-#include "xproperty.h" -#include "docker.h" - -gboolean xprop_get8(Window window, Atom atom, Atom type, int size, - gulong *count, guchar **value) -{ - Atom ret_type; - int ret_size; - unsigned long ret_bytes; - int result; - unsigned long nelements = *count; - unsigned long maxread = nelements; - - *value = NULL; - - /* try get the first element */ - result = XGetWindowProperty(display, window, atom, 0l, 1l, False, - AnyPropertyType, &ret_type, &ret_size, - &nelements, &ret_bytes, value); - if (! (result == Success && ret_type == type && - ret_size == size && nelements > 0)) { - if (*value) XFree(*value); - *value = NULL; - nelements = 0; - } else { - /* we didn't the whole property's value, more to get */ - if (! (ret_bytes == 0 || maxread <= nelements)) { - int remain; - - /* get the entire property since it is larger than one element long */ - XFree(*value); - /* - the number of longs that need to be retreived to get the property's - entire value. The last + 1 is the first long that we retrieved above. - */ - remain = (ret_bytes - 1)/sizeof(long) + 1 + 1; - /* dont get more than the max */ - if (remain > size/8 * (signed)maxread) - remain = size/8 * (signed)maxread; - result = XGetWindowProperty(display, window, atom, 0l, remain, - False, type, &ret_type, &ret_size, - &nelements, &ret_bytes, value); - /* - If the property has changed type/size, or has grown since our first - read of it, then stop here and try again. If it shrank, then this will - still work. - */ - if (!(result == Success && ret_type == type && - ret_size == size && ret_bytes == 0)) { - if (*value) XFree(*value); - xprop_get8(window, atom, type, size, count, value); - } - } - } - - *count = nelements; - return *value != NULL; -} - -gboolean xprop_get32(Window window, Atom atom, Atom type, int size, - gulong *count, gulong **value) -{ - return xprop_get8(window, atom, type, size, count, (guchar**)value); -}
D src/systray/xproperty.h

@@ -1,13 +0,0 @@

-#ifndef __xproperty_h -#define __xproperty_h - -#include <glib.h> -#include <X11/Xlib.h> - -/* if the func returns TRUE, the returned value must be XFree()'d */ -gboolean xprop_get8(Window window, Atom atom, Atom type, int size, - gulong *count, guchar **value); -gboolean xprop_get32(Window window, Atom atom, Atom type, int size, - gulong *count, gulong **value); - -#endif /* __xproperty_h */
M tintrc03tintrc03

@@ -23,7 +23,7 @@ panel_monitor = all

panel_position = bottom center panel_size = 100% 30 panel_margin = 0 0 -panel_padding = 6 0 6 +panel_padding = 6 3 6 font_shadow = 0 panel_background_id = 0

@@ -41,7 +41,7 @@ task_icon = 1

task_text = 1 task_width = 160 task_centered = 1 -task_padding = 2 5 +task_padding = 2 2 task_font = Dejavu sans 8 task_font_color = #000000 60 task_active_font_color = #000000 100

@@ -51,7 +51,7 @@

#--------------------------------------------- # CLOCK #--------------------------------------------- -#time1_format = %A %d %H:%M +time1_format = %A %d %H:%M time1_font = Dejavu sans 10 #time2_format = %A %d %B time2_font = sans 7
A tintrc04

@@ -0,0 +1,68 @@

+#--------------------------------------------- +# TINT2 CONFIG FILE +#--------------------------------------------- + +#--------------------------------------------- +# BACKGROUND AND BORDER +#--------------------------------------------- +rounded = 3 +border_width = 1 +background_color = #000000 40 +border_color = #d1d1d1 34 + +rounded = 3 +border_width = 1 +background_color = #000000 55 +border_color = #d1d1d1 40 + +#--------------------------------------------- +# PANEL +#--------------------------------------------- +panel_monitor = all +panel_position = bottom left +panel_size = 99% 27 +panel_margin = 0 0 +panel_padding = 5 3 5 +font_shadow = 0 +panel_background_id = 0 + +#--------------------------------------------- +# TASKBAR +#--------------------------------------------- +taskbar_mode = single_monitor +taskbar_padding = 0 0 5 +taskbar_background_id = 0 + +#--------------------------------------------- +# TASKS +#--------------------------------------------- +task_icon = 0 +task_text = 1 +task_width = 160 +task_centered = 1 +task_padding = 3 1 +task_font = sans bold 7.5 +task_font_color = #ffffff 60 +task_active_font_color = #ffffff 90 +task_background_id = 1 +task_active_background_id = 2 + +#--------------------------------------------- +# CLOCK +#--------------------------------------------- +time1_format = %a %d %H:%M +time1_font = sans bold 7.5 +#time2_format = %A %d %B +time2_font = sans bold 7.5 +clock_font_color = #ffffff 60 +clock_padding = 5 0 +clock_background_id = 1 + +#--------------------------------------------- +# MOUSE ACTION ON TASK +#--------------------------------------------- +mouse_middle = none +mouse_right = close +mouse_scroll_up = toggle +mouse_scroll_down = iconify +