Allow middle click & up/down mousewheel on the clock The bulk of this commit originally came from David B. Cortarello's patch (see here - https://gitlab.com/o9000/tint2/issues/430), with me adding the up/down mousewheel elements. Under Openbox the middle-click is normally used to display the Openbox menu and the mousewheel to switch desktop. So I needed to modify tint.c in order to prevent openbox intercepting the new actions. This commit creates the following new configuration settings :- clock_mclick_command clock_uwheel_command clock_dwheel_command
berkley4 jeffblake0@gmail.com
4 files changed,
41 insertions(+),
1 deletions(-)
M
src/clock/clock.c
→
src/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.h
→
src/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.c
→
src/config.c
@@ -463,9 +463,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/tint.c
→
src/tint.c
@@ -447,7 +447,11 @@ 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;