From 982767ce2e4b1f868593dacdbd5a287f04eaad86 Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 2 Apr 2017 11:18:17 +0200 Subject: [PATCH] Buttons: export alignment variables for menu --- src/button/button.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/button/button.c b/src/button/button.c index 3a00f33..fd5faf7 100644 --- a/src/button/button.c +++ b/src/button/button.c @@ -536,6 +536,7 @@ void button_action(void *obj, int mouse_button, int x, int y) } if (command) { int aligned_x, aligned_y, aligned_x1, aligned_y1, aligned_x2, aligned_y2; + int panel_x1, panel_x2, panel_y1, panel_y2; if (panel_horizontal) { if (area_is_first(button)) aligned_x1 = panel->posx; @@ -560,6 +561,10 @@ void button_action(void *obj, int mouse_button, int x, int y) aligned_y = panel->posy + panel->area.height; aligned_y1 = aligned_y2 = aligned_y; + + panel_x1 = panel->posx; + panel_x2 = panel->posx + panel->area.width; + panel_y1 = panel_y2 = aligned_y; } else { if (area_is_first(button)) aligned_y1 = panel->posy; @@ -571,18 +576,23 @@ void button_action(void *obj, int mouse_button, int x, int y) else aligned_y2 = panel->posy + button->area.posy + button->area.height; - if (panel_position & RIGHT) - aligned_x = panel->posx; - else - aligned_x = panel->posx + panel->area.width; - - aligned_x1 = aligned_x2 = aligned_x; if (area_is_first(button)) aligned_y = aligned_y1; else if (area_is_last(button)) aligned_y = aligned_y2; else aligned_y = aligned_y1; + + if (panel_position & RIGHT) + aligned_x = panel->posx; + else + aligned_x = panel->posx + panel->area.width; + + aligned_x1 = aligned_x2 = aligned_x; + + panel_x1 = panel_x2 = aligned_x; + panel_y1 = panel->posy; + panel_y2 = panel->posy + panel->area.height; } char *full_cmd = g_strdup_printf("export BUTTON_X=%d;" @@ -595,6 +605,10 @@ void button_action(void *obj, int mouse_button, int x, int y) "export BUTTON_ALIGNED_Y1=%d;" "export BUTTON_ALIGNED_X2=%d;" "export BUTTON_ALIGNED_Y2=%d;" + "export BUTTON_PANEL_X1=%d;" + "export BUTTON_PANEL_Y1=%d;" + "export BUTTON_PANEL_X2=%d;" + "export BUTTON_PANEL_Y2=%d;" "%s", x, y, @@ -606,6 +620,10 @@ void button_action(void *obj, int mouse_button, int x, int y) aligned_y1, aligned_x2, aligned_y2, + panel_x1, + panel_y1, + panel_x2, + panel_y2, command); pid_t pid = fork(); if (pid < 0) {