all repos — tint2 @ c874e763435aa8616bf7ac29214ad32c378a5d74

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

Merge branch 'moreclicks' into 'master'

Moreclicks

The two commits in this merge request would allow the user to set up as many as eight extra custom actions via tint2rc.

I've been running these changes (minus the up/down wheel actions) for many months without any obvious issues, mainly to adjust laptop screen brightness via a couple of scripts.

I've just tested the wheel actions and they appeared to work fine. The clock commit should solve issue #505.

I have merely augmented the work of two other people, and appropriate credits/references are indicated in the individual commit messages.

See merge request !5
o9000 mrovi9000@gmail.com
commit

c874e763435aa8616bf7ac29214ad32c378a5d74

parent

687f5f2a1b0cd00ad75aff51acf8d3f6bb1aeded

M src/battery/battery.csrc/battery/battery.c

@@ -56,6 +56,11 @@

int8_t battery_low_status; unsigned char battery_low_cmd_sent; char *battery_low_cmd; +char *battery_lclick_command; +char *battery_mclick_command; +char *battery_rclick_command; +char *battery_uwheel_command; +char *battery_dwheel_command; gchar *path_energy_now; gchar *path_energy_full; gchar *path_current_now;

@@ -141,6 +146,11 @@ battery_timeout = NULL;

bat1_font_desc = NULL; bat2_font_desc = NULL; battery_low_cmd = NULL; + battery_lclick_command = NULL; + battery_mclick_command = NULL; + battery_rclick_command = NULL; + battery_uwheel_command = NULL; + battery_dwheel_command = NULL; path_energy_now = NULL; path_energy_full = NULL; path_current_now = NULL;

@@ -171,6 +181,16 @@ g_free(path_status);

path_status = NULL; free(battery_low_cmd); battery_low_cmd = NULL; + free(battery_lclick_command); + battery_lclick_command = NULL; + free(battery_mclick_command); + battery_mclick_command = NULL; + free(battery_rclick_command); + battery_rclick_command = NULL; + free(battery_uwheel_command); + battery_uwheel_command = NULL; + free(battery_dwheel_command); + battery_dwheel_command = NULL; stop_timeout(battery_timeout); battery_timeout = NULL; battery_found = 0;

@@ -574,3 +594,26 @@ }

} return ret; } + +void battery_action(int button) +{ + char *command = 0; + switch (button) { + case 1: + command = battery_lclick_command; + break; + case 2: + command = battery_mclick_command; + break; + case 3: + command = battery_rclick_command; + break; + case 4: + command = battery_uwheel_command; + break; + case 5: + command = battery_dwheel_command; + break; + } + tint_exec(command); +}
M src/battery/battery.hsrc/battery/battery.h

@@ -56,6 +56,12 @@

extern int8_t battery_low_status; extern char *battery_low_cmd; +extern char *battery_lclick_command; +extern char *battery_mclick_command; +extern char *battery_rclick_command; +extern char *battery_uwheel_command; +extern char *battery_dwheel_command; + // default global data void default_battery();

@@ -70,5 +76,7 @@

void draw_battery(void *obj, cairo_t *c); int resize_battery(void *obj); + +void battery_action(int button); #endif
M src/clock/clock.csrc/clock/clock.c

@@ -39,7 +39,10 @@ char *time2_timezone;

char *time_tooltip_format; char *time_tooltip_timezone; char *clock_lclick_command; +char *clock_mclick_command; char *clock_rclick_command; +char *clock_uwheel_command; +char *clock_dwheel_command; struct timeval time_clock; PangoFontDescription *time1_font_desc; PangoFontDescription *time2_font_desc;

@@ -61,7 +64,10 @@ time2_timezone = NULL;

time_tooltip_format = NULL; time_tooltip_timezone = NULL; clock_lclick_command = NULL; + clock_mclick_command = NULL; clock_rclick_command = NULL; + clock_uwheel_command = NULL; + clock_dwheel_command = NULL; time1_font_desc = NULL; time2_font_desc = NULL; }

@@ -86,8 +92,14 @@ free(time_tooltip_timezone);

time_tooltip_timezone = NULL; free(clock_lclick_command); clock_lclick_command = NULL; + free(clock_mclick_command); + clock_mclick_command = NULL; free(clock_rclick_command); clock_rclick_command = NULL; + free(clock_uwheel_command); + clock_uwheel_command = NULL; + free(clock_dwheel_command); + clock_dwheel_command = NULL; stop_timeout(clock_timeout); clock_timeout = NULL; }

@@ -277,8 +289,17 @@ switch (button) {

case 1: command = clock_lclick_command; break; + case 2: + command = clock_mclick_command; + break; case 3: command = clock_rclick_command; + break; + case 4: + command = clock_uwheel_command; + break; + case 5: + command = clock_dwheel_command; break; } tint_exec(command);
M src/clock/clock.hsrc/clock/clock.h

@@ -33,7 +33,10 @@ extern char *time_tooltip_timezone;

extern PangoFontDescription *time1_font_desc; extern PangoFontDescription *time2_font_desc; extern char *clock_lclick_command; +extern char *clock_mclick_command; extern char *clock_rclick_command; +extern char *clock_uwheel_command; +extern char *clock_dwheel_command; extern int clock_enabled;
M src/config.csrc/config.c

@@ -358,6 +358,36 @@ if(battery_low_status < 0 || battery_low_status > 100)

battery_low_status = 0; #endif } + else if (strcmp(key, "battery_lclick_command") == 0) { +#ifdef ENABLE_BATTERY + if (strlen(value) > 0) + battery_lclick_command = strdup(value); +#endif + } + else if (strcmp(key, "battery_mclick_command") == 0) { +#ifdef ENABLE_BATTERY + if (strlen(value) > 0) + battery_mclick_command = strdup(value); +#endif + } + else if (strcmp(key, "battery_rclick_command") == 0) { +#ifdef ENABLE_BATTERY + if (strlen(value) > 0) + battery_rclick_command = strdup(value); +#endif + } + else if (strcmp(key, "battery_uwheel_command") == 0) { +#ifdef ENABLE_BATTERY + if (strlen(value) > 0) + battery_uwheel_command = strdup(value); +#endif + } + else if (strcmp(key, "battery_dwheel_command") == 0) { +#ifdef ENABLE_BATTERY + if (strlen(value) > 0) + battery_dwheel_command = strdup(value); +#endif + } else if (strcmp (key, "battery_low_cmd") == 0) { #ifdef ENABLE_BATTERY if (strlen(value) > 0)

@@ -470,9 +500,21 @@ else if (strcmp(key, "clock_lclick_command") == 0) {

if (strlen(value) > 0) clock_lclick_command = strdup(value); } + else if (strcmp(key, "clock_mclick_command") == 0) { + if (strlen(value) > 0) + clock_mclick_command = strdup(value); + } else if (strcmp(key, "clock_rclick_command") == 0) { if (strlen(value) > 0) clock_rclick_command = strdup(value); + } + else if (strcmp(key, "clock_uwheel_command") == 0) { + if (strlen(value) > 0) + clock_uwheel_command = strdup(value); + } + else if (strcmp(key, "clock_dwheel_command") == 0) { + if (strlen(value) > 0) + clock_dwheel_command = strdup(value); } /* Taskbar */
M src/panel.csrc/panel.c

@@ -796,6 +796,22 @@ return FALSE;

} +#ifdef ENABLE_BATTERY +int click_battery(Panel *panel, int x, int y) +{ + Battery bat = panel->battery; + if (panel_horizontal) { + if (bat.area.on_screen && x >= bat.area.posx && x <= (bat.area.posx + bat.area.width)) + return TRUE; + } else { + if (bat.area.on_screen && y >= bat.area.posy && y <= (bat.area.posy + bat.area.height)) + return TRUE; + } + return FALSE; +} +#endif + + Area* click_area(Panel *panel, int x, int y) { Area* result = &panel->area;
M src/panel.hsrc/panel.h

@@ -160,6 +160,11 @@ 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); + +#ifdef ENABLE_BATTERY +int click_battery(Panel *panel, int x, int y); +#endif + Area* click_area(Panel *panel, int x, int y); void autohide_show(void* p);
M src/tint.csrc/tint.c

@@ -447,11 +447,27 @@ Taskbar *tskbar = click_taskbar(panel, e->x, e->y);

if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP) return 1; if (click_clock(panel, e->x, e->y)) { - if ( (e->button == 1 && clock_lclick_command) || (e->button == 3 && clock_rclick_command) ) + if ( (e->button == 1 && clock_lclick_command) || + (e->button == 2 && clock_mclick_command) || + (e->button == 3 && clock_rclick_command) || + (e->button == 4 && clock_uwheel_command) || + (e->button == 5 && clock_dwheel_command) ) return 1; else return 0; } + #ifdef ENABLE_BATTERY + if (click_battery(panel, e->x, e->y)) { + if ( (e->button == 1 && battery_lclick_command) || + (e->button == 2 && battery_mclick_command) || + (e->button == 3 && battery_rclick_command) || + (e->button == 4 && battery_uwheel_command) || + (e->button == 5 && battery_dwheel_command) ) + return 1; + else + return 0; + } + #endif return 0; }

@@ -598,6 +614,16 @@ XLowerWindow (server.dsp, panel->main_win);

task_drag = 0; return; } + + #ifdef ENABLE_BATTERY + if (click_battery(panel, e->xbutton.x, e->xbutton.y)) { + battery_action(e->xbutton.button); + if (panel_layer == BOTTOM_LAYER) + XLowerWindow (server.dsp, panel->main_win); + task_drag = 0; + return; + } + #endif if (e->xbutton.button == 1 && click_launcher(panel, e->xbutton.x, e->xbutton.y)) { LauncherIcon *icon = click_launcher_icon(panel, e->xbutton.x, e->xbutton.y);