To reproduce: 1. Open two terminals. 2. Mark on of them as "Always on top". 3. Select the other one and run "notify-send hello". 4. Wait for the notification bubble to disappear. Result: The "always on top" terminal steals focus when the notification bubble disappears.
This is actually triggered by a Gtk bug: https://bugzilla.gnome.org/show_bug.cgi?id=710389 If a window has accept focus = FALSE and take focus = TRUE, then when the window opens the window will not get focused, but when it closes, xfwm4 will behave as if that window *was* focused, and pass focus to the topmost window. The topmost window is not necessarily the currently focused window if "always on top" is in use. This happens because having TAKE_FOCUS set causes clientAcceptFocus() to return true, overriding the focus hint: if ((c->screen_info->params->focus_hint) && !FLAG_TEST (c->wm_flags, WM_FLAG_INPUT | WM_FLAG_TAKEFOCUS)) { return FALSE; } This is a problem because in some places it gets used like this: if (!clientAcceptFocus (c)) and in some places it is used like this: if (!clientAcceptFocus (c) || (c->type & WINDOW_TYPE_DONT_FOCUS)) This causes pending_focus to be set to the notification window, even though it will never get focused.
The focus code in xfwm4 is very fragile and has loads of workarounds already. I don't see a way to really "fix" this. (Actually I see several, and they would all have side-effects just as bad as this bug.) Luckily though, the problem seems to have an easy fix in the notifyd. Just have it set override-redirect on it's bubbles, and then they won't interfere with anything at all, because the window manager won't even see them.
Created attachment 5257 Make notification bubbles override-redirect. This saves the window-manager from having to deal with yet-more focus issues.
Oh, btw, the Gtk bug is not really a bug. It's been that way so long it's now considered standard, if incorrect (depending who you ask) behaviour.
Fixed at https://bugzilla.xfce.org/show_bug.cgi?id=10686 *** This bug has been marked as a duplicate of bug 10686 ***