Quoth I,
Draw dimmer icons for windows of a different WM_CLASS when using GroupNext/PrevKey in the switchpanel.
One slightly unintuitive consequence of the previous patch is that if you use GroupNext/PrevKey, dimming some icons, then select a window by mousing over its icon or by using the Home or End keys, the dimmed icons remain dim. If you select a different class of window that could cause confusion.
The attached patch will ensure that icons are undimmed when such a selection is made.
Some readers may be concerned about the implications of redrawing all the icons all the time. It's unnecessary in the case where the screen image doesn't actually change. I had a play with various techniques for avoiding the redraws, such as constructing an array of opacity values for each icon and having a flag which remembered if one of the same-class hotkeys had been used. Eventually I concluded that it was a premature optimisation. The redraws weren't any smoother or noticeably quicker. I preferred to write a smaller, easier-to-understand patch.
Of course I can revisit that decision if people disagree.
From 8b2b6d602bfd325aec4135590a85ed96682022d4 Mon Sep 17 00:00:00 2001 From: Iain Patterson <[email protected]> Date: Fri, 24 May 2013 14:14:34 +0100 Subject: [PATCH] Undim switchpanel icons when selecting windows directly. If one or more icons were dimmed in the switchpanel because the user used GroupNext/PrevKey, then an icon was selected with the mouse or the Home or End keys, dimmed icons remained dim. That could be unintuitive if the selected window was of a different class. Instead we now always redraw all icons when highlighting a different icon. --- src/switchpanel.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/switchpanel.c b/src/switchpanel.c index 6c8f6ea..cfb0033 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -625,12 +625,16 @@ WWindow *wSwitchPanelSelectFirst(WSwitchPanel *panel, int back) { WWindow *wwin; int count = WMGetArrayItemCount(panel->windows); + int i; if (count == 0) return NULL; - if (panel->win) - changeImage(panel, panel->current, 0, False); + if (panel->win) { + WM_ITERATE_ARRAY(panel->windows, wwin, i) { + changeImage(panel, i, 0, False); + } + } if (back) { panel->current = count - 1; @@ -671,7 +675,9 @@ WWindow *wSwitchPanelHandleEvent(WSwitchPanel *panel, XEvent *event) if (focus >= 0 && panel->current != focus) { WWindow *wwin; - changeImage(panel, panel->current, 0, False); + WM_ITERATE_ARRAY(panel->windows, wwin, i) { + changeImage(panel, i, 0, False); + } changeImage(panel, focus, 1, False); panel->current = focus; -- 1.8.1.4
