all repos — tint2 @ 7e17a3c7f0b66e46fb7c31225f30e553026e85e2

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

added basic launcher by mrovi

git-svn-id: http://tint2.googlecode.com/svn/trunk@521 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
thilor77 thilor77@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

7e17a3c7f0b66e46fb7c31225f30e553026e85e2

parent

73c0b524af840f8ca0503be9edefc29e49c13939

5 files changed, 109 insertions(+), 3 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -29,6 +29,7 @@ src/battery

src/clock src/systray src/taskbar + src/launcher src/tooltip src/util ${X11_INCLUDE_DIRS}

@@ -45,6 +46,7 @@ src/server.c

src/tint.c src/clock/clock.c src/systray/systraybar.c + src/launcher/launcher.c src/taskbar/task.c src/taskbar/taskbar.c src/tooltip/tooltip.c
M src/config.csrc/config.c

@@ -41,6 +41,7 @@ #include "panel.h"

#include "task.h" #include "taskbar.h" #include "systraybar.h" +#include "launcher.h" #include "clock.h" #include "config.h" #include "window.h"

@@ -500,12 +501,13 @@ /* Systray */

// systray disabled in snapshot mode else if (strcmp (key, "systray") == 0 && snapshot_path == 0) { systray_enabled = atoi(value); - // systray is latest option added. files without 'systray' are old. old_config_file = 0; } else if (strcmp (key, "systray_padding") == 0 && snapshot_path == 0) { - if (old_config_file) + if (old_config_file) { + // if tint2rc is an old config file, systray_padding enabled the systray bar. systray_enabled = 1; + } extract_values(value, &value1, &value2, &value3); systray.area.paddingxlr = systray.area.paddingx = atoi (value1); if (value2) systray.area.paddingy = atoi (value2);

@@ -534,6 +536,33 @@ extract_values(value, &value1, &value2, &value3);

systray.alpha = atoi(value1); systray.saturation = atoi(value2); systray.brightness = atoi(value3); + } + + /* Launcher */ + else if (strcmp (key, "launcher") == 0) { + launcher_enabled = atoi(value); + } + else if (strcmp (key, "launcher_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.launcher.area.paddingxlr = panel_config.launcher.area.paddingx = atoi (value1); + if (value2) panel_config.launcher.area.paddingy = atoi (value2); + if (value3) panel_config.launcher.area.paddingx = atoi (value3); + } + else if (strcmp (key, "launcher_background_id") == 0) { + int id = atoi (value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.launcher.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp(key, "launcher_icon_size") == 0) { + launcher_max_icon_size = atoi(value); + } + else if (strcmp(key, "launcher_item_icon") == 0) { + char *path = strdup(value); + panel_config.launcher.list_icon_paths = g_slist_append(panel_config.launcher.list_icon_paths, path); + } + else if (strcmp(key, "launcher_item_cmd") == 0) { + char *cmd = strdup(value); + panel_config.launcher.list_cmds = g_slist_append(panel_config.launcher.list_cmds, cmd); } /* Tooltip */
M src/panel.csrc/panel.c

@@ -134,6 +134,7 @@ }

init_tooltip(); init_systray(); + init_launcher(); init_clock(); #ifdef ENABLE_BATTERY init_battery();

@@ -178,6 +179,10 @@ init_battery_panel(p);

p->area.list = g_slist_append(p->area.list, &p->battery); } #endif + if (launcher_enabled) { + init_launcher_panel(p); + p->area.list = g_slist_append(p->area.list, &p->launcher); + } // systray only on first panel if (systray.area.on_screen && i == 0) { init_systray_panel(p);

@@ -305,6 +310,8 @@

taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width); if (panel->clock.area.on_screen && panel->clock.area.width) taskbar_width -= (panel->clock.area.width + panel->area.paddingx); + if (panel->launcher.area.on_screen && panel->launcher.area.width) + taskbar_width -= (panel->launcher.area.width + panel->area.paddingx); #ifdef ENABLE_BATTERY if (panel->battery.area.on_screen && panel->battery.area.width) taskbar_width -= (panel->battery.area.width + panel->area.paddingx);

@@ -322,6 +329,8 @@

// change posx and width for all taskbar int i, posx; posx = panel->area.bg->border.width + panel->area.paddingxlr; + if (panel->launcher.area.on_screen && panel->launcher.area.width) + posx += (panel->launcher.area.width + panel->area.paddingx); for (i=0 ; i < panel->nb_desktop ; i++) { panel->taskbar[i].area.posx = posx; panel->taskbar[i].area.width = taskbar_width;

@@ -342,6 +351,8 @@

taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width); if (panel->clock.area.on_screen && panel->clock.area.height) taskbar_height -= (panel->clock.area.height + panel->area.paddingx); + if (panel->launcher.area.on_screen && panel->launcher.area.height) + taskbar_height -= (panel->launcher.area.height + panel->area.paddingx); #ifdef ENABLE_BATTERY if (panel->battery.area.on_screen && panel->battery.area.height) taskbar_height -= (panel->battery.area.height + panel->area.paddingx);

@@ -351,6 +362,8 @@ if (systray.area.on_screen && systray.area.height && panel == &panel1[0])

taskbar_height -= (systray.area.height + panel->area.paddingx); posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - taskbar_height; + if (panel->launcher.area.on_screen && panel->launcher.area.height) + posy -= (panel->launcher.area.height + panel->area.paddingx); if (panel_mode == MULTI_DESKTOP) { int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx); taskbar_height = height / panel->nb_desktop;

@@ -640,6 +653,43 @@ tsk = l0->data;

if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) { return tsk; } + } + } + } + return NULL; +} + + +Launcher *click_launcher (Panel *panel, int x, int y) +{ + Launcher *launcher = &panel->launcher; + + if (panel_horizontal) { + if (launcher->area.on_screen && x >= launcher->area.posx && x <= (launcher->area.posx + launcher->area.width)) + return launcher; + } + else { + if (launcher->area.on_screen && y >= launcher->area.posy && y <= (launcher->area.posy + launcher->area.height)) + return launcher; + } + return NULL; +} + + +LauncherIcon *click_launcher_icon (Panel *panel, int x, int y) +{ + GSList *l0; + Launcher *launcher; + + //printf("Click x=%d y=%d\n", x, y); + if ( (launcher = click_launcher(panel, x, y)) ) { + LauncherIcon *icon; + for (l0 = launcher->list_icons; l0 ; l0 = l0->next) { + icon = l0->data; + if (x >= (launcher->area.posx + icon->x) && x <= (launcher->area.posx + icon->x + icon->width) && + y >= (launcher->area.posy + icon->y) && y <= (launcher->area.posy + icon->y + icon->height)) { + //printf("Hit rect x=%d y=%d xmax=%d ymax=%d\n", launcher->area.posx + icon->x, launcher->area.posy + icon->y, launcher->area.posx + icon->x + icon->width, launcher->area.posy + icon->y + icon->height); + return icon; } } }
M src/panel.hsrc/panel.h

@@ -19,6 +19,7 @@ #include "clock.h"

#include "task.h" #include "taskbar.h" #include "systraybar.h" +#include "launcher.h" #ifdef ENABLE_BATTERY #include "battery.h"

@@ -107,6 +108,8 @@ #ifdef ENABLE_BATTERY

Battery battery; #endif + Launcher launcher; + // autohide int is_hidden; int hidden_width, hidden_height;

@@ -144,6 +147,8 @@ Panel *get_panel(Window win);

Taskbar *click_taskbar (Panel *panel, int x, int y); Task *click_task (Panel *panel, int x, int y); +Launcher *click_launcher (Panel *panel, int x, int y); +LauncherIcon *click_launcher_icon (Panel *panel, int x, int y); int click_padding(Panel *panel, int x, int y); int click_clock(Panel *panel, int x, int y); Area* click_area(Panel *panel, int x, int y);
M src/tint.csrc/tint.c

@@ -38,6 +38,7 @@ #include "config.h"

#include "task.h" #include "taskbar.h" #include "systraybar.h" +#include "launcher.h" #include "panel.h" #include "tooltip.h" #include "timer.h"

@@ -63,6 +64,7 @@ #ifdef ENABLE_BATTERY

default_battery(); #endif default_clock(); + default_launcher(); default_taskbar(); default_tooltip(); default_panel();

@@ -159,6 +161,7 @@ cleanup_systray();

cleanup_panel(); cleanup_tooltip(); cleanup_clock(); + cleanup_launcher(); #ifdef ENABLE_BATTERY cleanup_battery(); #endif

@@ -278,7 +281,15 @@ }

else return 0; } - // no task clicked --> check if taskbar clicked + LauncherIcon *icon = click_launcher_icon(panel, e->x, e->y); + if (icon) { + if (e->button == 1) { + return 1; + } else { + return 0; + } + } + // no launcher/task clicked --> check if taskbar clicked Taskbar *tskbar = click_taskbar(panel, e->x, e->y); if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP) return 1;

@@ -417,6 +428,15 @@ if ( click_clock(panel, e->xbutton.x, e->xbutton.y)) {

clock_action(e->xbutton.button); if (panel_layer == BOTTOM_LAYER) XLowerWindow (server.dsp, panel->main_win); + task_drag = 0; + return; + } + + if ( click_launcher(panel, e->xbutton.x, e->xbutton.y)) { + LauncherIcon *icon = click_launcher_icon(panel, e->xbutton.x, e->xbutton.y); + if (icon) { + launcher_action(icon); + } task_drag = 0; return; }