add WST_FOCUSED state and use it instead widget-own states (WListbox::focused, WButton::selected, WTree::active, etc). Test this option instead of callback call;

get rid of multiple widget redraw. In many cases messages MSG_DRAW and MSG_FOCUS (and/or MSG_RESIZE) are sent to widget in series. Handling these messages, widget is redrawn twice (for example, see input_callback():