From: Thierry Lorthiois Date: Thu, 4 Jun 2009 18:41:14 +0000 (+0000) Subject: clock command on rigt/left click by dmitry.medvinsky X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=5679142e44a103a6fe1e62365fe991d273e41049;p=chaz%2Ftint2 clock command on rigt/left click by dmitry.medvinsky --- diff --git a/ChangeLog b/ChangeLog index b00d399..34ab28f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-06-04 +- patch by dmitry.medvinsky : right/left clic command + 2009-06-02 - Systray Temp_Fix from keshto not yet perfect, but a first step diff --git a/src/clock/clock.c b/src/clock/clock.c index 79104c0..eaaf69c 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "window.h" #include "server.h" @@ -31,8 +32,10 @@ #include "clock.h" -char *time1_format = 0; -char *time2_format = 0; +char *time1_format; +char *time2_format; +char *clock_lclick_command; +char *clock_rclick_command; struct timeval time_clock; int time_precision; PangoFontDescription *time1_font_desc; @@ -189,3 +192,25 @@ void resize_clock (void *obj) XFreePixmap (server.dsp, pmap); } + +void clock_action(int button) +{ + char *command = 0; + switch (button) { + case 1: + command = clock_lclick_command; + break; + case 3: + command = clock_rclick_command; + break; + } + if (command) { + pid_t pid; + pid = fork(); + if (pid == 0) { + execl("/bin/sh", "/bin/sh", "-c", command, NULL); + _exit(0); + } + } +} + diff --git a/src/clock/clock.h b/src/clock/clock.h index 90e1a89..7b28e85 100644 --- a/src/clock/clock.h +++ b/src/clock/clock.h @@ -30,6 +30,8 @@ extern struct timeval time_clock; extern int time_precision; extern PangoFontDescription *time1_font_desc; extern PangoFontDescription *time2_font_desc; +extern char *clock_lclick_command; +extern char *clock_rclick_command; // initialize clock : y position, precision, ... @@ -39,4 +41,6 @@ void draw_clock (void *obj, cairo_t *c, int active); void resize_clock (void *obj); +void clock_action(int button); + #endif diff --git a/src/config.c b/src/config.c index d861ba5..bfe8801 100644 --- a/src/config.c +++ b/src/config.c @@ -398,6 +398,16 @@ void add_entry (char *key, char *value) memcpy(&panel_config->clock.area.pix.back, &a->pix.back, sizeof(Color)); memcpy(&panel_config->clock.area.pix.border, &a->pix.border, sizeof(Border)); } + else if (strcmp(key, "clock_lclick_command") == 0) { + if (clock_lclick_command) g_free(clock_lclick_command); + if (strlen(value) > 0) clock_lclick_command = strdup(value); + else clock_lclick_command = 0; + } + else if (strcmp(key, "clock_rclick_command") == 0) { + if (clock_rclick_command) g_free(clock_rclick_command); + if (strlen(value) > 0) clock_rclick_command = strdup(value); + else clock_rclick_command = 0; + } /* Taskbar */ else if (strcmp (key, "taskbar_mode") == 0) { diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c index 0a728e7..ef1578f 100644 --- a/src/systray/systraybar.c +++ b/src/systray/systraybar.c @@ -109,7 +109,8 @@ void draw_systray(void *obj, cairo_t *c, int active) // position and size the icon window XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size); - XSetWindowBackgroundPixmap (server.dsp, panel->main_win, systray.area.pix.pmap); + // ceci intervertie les fonds : le premier icone prend le fond du dernier + // le dernier prend le fond de l'avant dernier, ... // resize our window so that the new window can fit in it //fix_geometry(); @@ -123,6 +124,7 @@ void draw_systray(void *obj, cairo_t *c, int active) // show the window XMapRaised(server.dsp, traywin->id); } + XSetWindowBackgroundPixmap (server.dsp, panel->main_win, systray.area.pix.pmap); } diff --git a/src/tint.c b/src/tint.c index 28366cc..cfe0c70 100644 --- a/src/tint.c +++ b/src/tint.c @@ -99,6 +99,8 @@ void cleanup() if (path_energy_full) g_free(path_energy_full); if (path_current_now) g_free(path_current_now); if (path_status) g_free(path_status); + if (clock_lclick_command) g_free(clock_lclick_command); + if (clock_rclick_command) g_free(clock_rclick_command); if (server.monitor) free(server.monitor); XFreeGC(server.dsp, server.gc); @@ -194,12 +196,17 @@ void event_button_release (XEvent *e) // search taskbar Taskbar *tskbar; GSList *l0; - for (l0 = panel->area.list; l0 ; l0 = l0->next) { - tskbar = l0->data; - if (!tskbar->area.on_screen) continue; - if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width)) - goto suite; - } + Clock clk = panel->clock; + if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width)) + clock_action(e->xbutton.button); + else { + for (l0 = panel->area.list; l0 ; l0 = l0->next) { + tskbar = l0->data; + if (!tskbar->area.on_screen) continue; + if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width)) + goto suite; + } + } // TODO: check better solution to keep window below XLowerWindow (server.dsp, panel->main_win); diff --git a/src/tint2 b/src/tint2 index 449ece2..35eeffa 100755 Binary files a/src/tint2 and b/src/tint2 differ