From 7ad85517b33bb1ae2404af7c4d019b3abfe7ca1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 26 Jul 2021 14:33:56 +0200 Subject: Highlight tray button when active --- src/traybutton.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/traybutton.c b/src/traybutton.c index ce185d0..1f98d0f 100644 --- a/src/traybutton.c +++ b/src/traybutton.c @@ -42,7 +42,7 @@ typedef struct TrayButtonType { static TrayButtonType *buttons; static void CheckedCreate(TrayComponentType *cp); -static void Create(TrayComponentType *cp); +static void Create(TrayComponentType *cp, int active); static void Destroy(TrayComponentType *cp); static void SetSize(TrayComponentType *cp, int width, int height); static void Resize(TrayComponentType *cp); @@ -287,14 +287,14 @@ CheckedCreate(TrayComponentType *cp) */ } - Create(cp); + Create(cp, 0); } /*************************************************************************** ***************************************************************************/ void -Create(TrayComponentType *cp) +Create(TrayComponentType *cp, int active) { ButtonNode button; @@ -310,7 +310,7 @@ Create(TrayComponentType *cp) JXFillRectangle(display, cp->pixmap, rootGC, 0, 0, cp->width, cp->height); ResetButton(&button, cp->pixmap, rootGC); - button.type = BUTTON_TASK; + button.type = active ? BUTTON_TASK_ACTIVE : BUTTON_TASK; button.width = cp->width - 3; button.height = cp->height - 3; button.x = 1; @@ -342,6 +342,8 @@ Create(TrayComponentType *cp) cp->width - labelx, NULL, bp->label); } + UpdateSpecificTray(cp->tray, cp); + } /*************************************************************************** @@ -351,7 +353,7 @@ Resize(TrayComponentType *cp) { Destroy(cp); - Create(cp); + Create(cp, 0); } @@ -372,13 +374,19 @@ ProcessButtonEvent(TrayComponentType *cp, int x, int y, int mask) { const ScreenType *sp; + //long evmask; int mwidth, mheight; int button; + //XEvent ev; + + //XSendEvent(display, rootWindow, False, evmask, &ev); TrayButtonType *bp = (TrayButtonType*)cp->object; Assert(bp); + Create(cp, 1); + if(bp->action && strlen(bp->action) > 0) { if(!strncmp(bp->action, "exec:", 5)) { RunCommand(bp->action + 5); @@ -417,6 +425,7 @@ ProcessButtonEvent(TrayComponentType *cp, int x, int y, int mask) ShowRootMenu(button, x, y); + Create(cp, 0); } /*************************************************************************** -- cgit v1.2.3