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
This commit is contained in:
parent
c4fbc2962e
commit
e84d963ab6
4 changed files with 41 additions and 1 deletions
|
@ -39,7 +39,10 @@ char *time2_timezone;
|
||||||
char *time_tooltip_format;
|
char *time_tooltip_format;
|
||||||
char *time_tooltip_timezone;
|
char *time_tooltip_timezone;
|
||||||
char *clock_lclick_command;
|
char *clock_lclick_command;
|
||||||
|
char *clock_mclick_command;
|
||||||
char *clock_rclick_command;
|
char *clock_rclick_command;
|
||||||
|
char *clock_uwheel_command;
|
||||||
|
char *clock_dwheel_command;
|
||||||
struct timeval time_clock;
|
struct timeval time_clock;
|
||||||
PangoFontDescription *time1_font_desc;
|
PangoFontDescription *time1_font_desc;
|
||||||
PangoFontDescription *time2_font_desc;
|
PangoFontDescription *time2_font_desc;
|
||||||
|
@ -61,7 +64,10 @@ void default_clock()
|
||||||
time_tooltip_format = NULL;
|
time_tooltip_format = NULL;
|
||||||
time_tooltip_timezone = NULL;
|
time_tooltip_timezone = NULL;
|
||||||
clock_lclick_command = NULL;
|
clock_lclick_command = NULL;
|
||||||
|
clock_mclick_command = NULL;
|
||||||
clock_rclick_command = NULL;
|
clock_rclick_command = NULL;
|
||||||
|
clock_uwheel_command = NULL;
|
||||||
|
clock_dwheel_command = NULL;
|
||||||
time1_font_desc = NULL;
|
time1_font_desc = NULL;
|
||||||
time2_font_desc = NULL;
|
time2_font_desc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +92,14 @@ void cleanup_clock()
|
||||||
time_tooltip_timezone = NULL;
|
time_tooltip_timezone = NULL;
|
||||||
free(clock_lclick_command);
|
free(clock_lclick_command);
|
||||||
clock_lclick_command = NULL;
|
clock_lclick_command = NULL;
|
||||||
|
free(clock_mclick_command);
|
||||||
|
clock_mclick_command = NULL;
|
||||||
free(clock_rclick_command);
|
free(clock_rclick_command);
|
||||||
clock_rclick_command = NULL;
|
clock_rclick_command = NULL;
|
||||||
|
free(clock_uwheel_command);
|
||||||
|
clock_uwheel_command = NULL;
|
||||||
|
free(clock_dwheel_command);
|
||||||
|
clock_dwheel_command = NULL;
|
||||||
stop_timeout(clock_timeout);
|
stop_timeout(clock_timeout);
|
||||||
clock_timeout = NULL;
|
clock_timeout = NULL;
|
||||||
}
|
}
|
||||||
|
@ -277,9 +289,18 @@ void clock_action(int button)
|
||||||
case 1:
|
case 1:
|
||||||
command = clock_lclick_command;
|
command = clock_lclick_command;
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
command = clock_mclick_command;
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
command = clock_rclick_command;
|
command = clock_rclick_command;
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
command = clock_uwheel_command;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
command = clock_dwheel_command;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
tint_exec(command);
|
tint_exec(command);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,10 @@ extern char *time_tooltip_timezone;
|
||||||
extern PangoFontDescription *time1_font_desc;
|
extern PangoFontDescription *time1_font_desc;
|
||||||
extern PangoFontDescription *time2_font_desc;
|
extern PangoFontDescription *time2_font_desc;
|
||||||
extern char *clock_lclick_command;
|
extern char *clock_lclick_command;
|
||||||
|
extern char *clock_mclick_command;
|
||||||
extern char *clock_rclick_command;
|
extern char *clock_rclick_command;
|
||||||
|
extern char *clock_uwheel_command;
|
||||||
|
extern char *clock_dwheel_command;
|
||||||
extern int clock_enabled;
|
extern int clock_enabled;
|
||||||
|
|
||||||
|
|
||||||
|
|
12
src/config.c
12
src/config.c
|
@ -463,10 +463,22 @@ void add_entry (char *key, char *value)
|
||||||
if (strlen(value) > 0)
|
if (strlen(value) > 0)
|
||||||
clock_lclick_command = strdup(value);
|
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) {
|
else if (strcmp(key, "clock_rclick_command") == 0) {
|
||||||
if (strlen(value) > 0)
|
if (strlen(value) > 0)
|
||||||
clock_rclick_command = strdup(value);
|
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 */
|
/* Taskbar */
|
||||||
else if (strcmp (key, "taskbar_mode") == 0) {
|
else if (strcmp (key, "taskbar_mode") == 0) {
|
||||||
|
|
|
@ -447,7 +447,11 @@ int tint2_handles_click(Panel* panel, XButtonEvent* e)
|
||||||
if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
|
if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP)
|
||||||
return 1;
|
return 1;
|
||||||
if (click_clock(panel, e->x, e->y)) {
|
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;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue