all repos — openbox @ adc5675823de8e3bbe94a1419b04103c6f845dad

openbox fork - make it a bit more like ryudo

oh, 2 things in this commit..

1) THIS ONE IS IMPORTANT: don't set client->iconfied if the window is not actually going to be allowed to iconify. heh!

2) changes to focus fallback to avoid crashing and to avoid losing focus all at the same time.
Dana Jansens danakj@orodu.net
commit

adc5675823de8e3bbe94a1419b04103c6f845dad

parent

768ce7b456fb7455c39bc275b71af381d635ac0a

M openbox/action.copenbox/action.c

@@ -1172,7 +1172,7 @@

void action_unfocus (union ActionData *data) { if (data->client.any.c == focus_client) - focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING); + focus_fallback(FALSE); } void action_iconify(union ActionData *data)
M openbox/client.copenbox/client.c

@@ -78,6 +78,7 @@ static void client_apply_startup_state(ObClient *self, gint x, gint y);

static void client_restore_session_state(ObClient *self); static void client_restore_session_stacking(ObClient *self); static ObAppSettings *client_get_settings_state(ObClient *self); +static void client_unfocus(ObClient *self); void client_startup(gboolean reconfig) {

@@ -2515,10 +2516,10 @@ if (self->iconic != iconic) {

ob_debug("%sconifying window: 0x%lx\n", (iconic ? "I" : "Uni"), self->window); - self->iconic = iconic; - if (iconic) { if (self->functions & OB_CLIENT_FUNC_ICONIFY) { + self->iconic = iconic; + /* update the focus lists.. iconic windows go to the bottom of the list, put the new iconic window at the 'top of the bottom'. */

@@ -2527,6 +2528,8 @@

changed = TRUE; } } else { + self->iconic = iconic; + if (curdesk) client_set_desktop(self, screen_desktop, FALSE);

@@ -3031,14 +3034,7 @@

ob_debug("Focusing client \"%s\" at time %u\n", self->title, event_curtime); if (self->can_focus) { - /* RevertToPointerRoot causes much more headache than RevertToNone, so - I choose to use it always, hopefully to find errors quicker, if any - are left. (I hate X. I hate focus events.) - - Update: Changing this to RevertToNone fixed a bug with mozilla (bug - #799. So now it is RevertToNone again. - */ - XSetInputFocus(ob_display, self->window, RevertToNone, + XSetInputFocus(ob_display, self->window, RevertToPointerRoot, event_curtime); }

@@ -3073,13 +3069,13 @@

/* Used when the current client is closed or otherwise hidden, focus_last will then prevent focus from going to the mouse pointer */ -void client_unfocus(ObClient *self) +static void client_unfocus(ObClient *self) { if (focus_client == self) { #ifdef DEBUG_FOCUS ob_debug("client_unfocus for %lx\n", self->window); #endif - focus_fallback(OB_FOCUS_FALLBACK_CLOSED); + focus_fallback(FALSE); } }
M openbox/client.hopenbox/client.h

@@ -494,9 +494,6 @@ NOTE: You should validate the client before calling this !! (client_validate)

*/ gboolean client_focus(ObClient *self); -/*! Remove focus from the client window */ -void client_unfocus(ObClient *self); - /*! Activates the client for use, focusing, uniconifying it, etc. To be used when the user deliberately selects a window for use. @param here If true, then the client is brought to the current desktop;
M openbox/event.copenbox/event.c

@@ -422,7 +422,7 @@ break;

} } -#if 0 /* focus debugging stuff */ +#if 1 /* focus debugging stuff */ if (e->type == FocusIn || e->type == FocusOut) { gint mode = e->xfocus.mode; gint detail = e->xfocus.detail;

@@ -655,8 +655,12 @@ break;

case FocusOut: /* Look for the followup FocusIn */ if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) { - /* There is no FocusIn, move focus where we can still hear events*/ - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + /* There is no FocusIn, this means focus went to a window that + is not being managed. most likely, this went to PointerRoot + or None, meaning the window is no longer around so fallback + focus, but not to that window */ + ob_debug("Focus went to a black hole !\n"); + focus_fallback(FALSE); } else if (ce.xany.window == e->xany.window) { /* If focus didn't actually move anywhere, there is nothing to do*/ break;

@@ -667,7 +671,9 @@ event_process(&ce, &ed);

if (ed.ignored) { /* The FocusIn was ignored, this means it was on a window that isn't a client. */ - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + ob_debug("Focus went to an unmanaged window 0x%x !\n", + ce.xfocus.window); + focus_fallback(TRUE); } }
M openbox/focus.copenbox/focus.c

@@ -248,7 +248,7 @@ else

return NULL; } -ObClient* focus_fallback_target(ObFocusFallbackType type) +ObClient* focus_fallback_target(gboolean allow_refocus) { GList *it; ObClient *old;

@@ -256,60 +256,57 @@ ObClient *target = NULL;

old = focus_client; - if ((type == OB_FOCUS_FALLBACK_UNFOCUSING - || type == OB_FOCUS_FALLBACK_CLOSED) && old) { - if (old->transient_for) { - gboolean trans = FALSE; + if (!allow_refocus && old && old->transient_for) { + gboolean trans = FALSE; - if (!config_focus_follow || config_focus_last) - trans = TRUE; - else if ((target = client_under_pointer()) && - client_search_transient - (client_search_top_parent(target), old)) - trans = TRUE; + if (!config_focus_follow || config_focus_last) + trans = TRUE; + else if ((target = client_under_pointer()) && + client_search_transient + (client_search_top_parent(target), old)) + trans = TRUE; - /* try for transient relations */ - if (trans) { - if (old->transient_for == OB_TRAN_GROUP) { - for (it = focus_order[screen_desktop]; it; - it = g_list_next(it)) - { - GSList *sit; + /* try for transient relations */ + if (trans) { + if (old->transient_for == OB_TRAN_GROUP) { + for (it = focus_order[screen_desktop]; it; + it = g_list_next(it)) + { + GSList *sit; - for (sit = old->group->members; sit; - sit = g_slist_next(sit)) - { - if (sit->data == it->data) - if ((target = - focus_fallback_transient(sit->data, old))) - { - ob_debug("found in transient #1\n"); - return target; - } - } - } - } else { - if ((target = - focus_fallback_transient(old->transient_for, old))) + for (sit = old->group->members; sit; + sit = g_slist_next(sit)) { - ob_debug("found in transient #2\n"); - return target; + if (sit->data == it->data) + if ((target = + focus_fallback_transient(sit->data, old))) + { + ob_debug("found in transient #1\n"); + return target; + } } } + } else { + if ((target = + focus_fallback_transient(old->transient_for, old))) + { + ob_debug("found in transient #2\n"); + return target; + } } } } ob_debug("trying pointer stuff\n"); - if (config_focus_follow && - (type == OB_FOCUS_FALLBACK_UNFOCUSING || !config_focus_last)) + if (config_focus_follow && !config_focus_last) { if ((target = client_under_pointer())) - if (client_normal(target) && client_can_focus(target) && - client_validate(target)) { - ob_debug("found in pointer stuff\n"); - return target; - } + if (allow_refocus || target != old) + if (client_normal(target) && client_can_focus(target) && + client_validate(target)) { + ob_debug("found in pointer stuff\n"); + return target; + } } #if 0

@@ -328,7 +325,7 @@ #endif

ob_debug("trying the focus order\n"); for (it = focus_order[screen_desktop]; it; it = g_list_next(it)) - if (type != OB_FOCUS_FALLBACK_UNFOCUSING || it->data != old) + if (allow_refocus || it->data != old) if (client_normal(it->data) && client_can_focus(it->data) && client_validate(it->data)) {

@@ -344,7 +341,7 @@

return NULL; } -void focus_fallback(ObFocusFallbackType type) +void focus_fallback(gboolean allow_refocus) { ObClient *new;

@@ -354,7 +351,7 @@ at all for them.

*/ focus_set_client(NULL); - if ((new = focus_fallback_target(type))) + if ((new = focus_fallback_target(allow_refocus))) client_focus(new); }
M openbox/focus.hopenbox/focus.h

@@ -50,17 +50,10 @@ /*! Specify which client is currently focused, this doesn't actually

send focus anywhere, its called by the Focus event handlers */ void focus_set_client(struct _ObClient *client); -typedef enum { - OB_FOCUS_FALLBACK_UNFOCUSING, /*!< forcefully remove focus from the - current window */ - OB_FOCUS_FALLBACK_CLOSED, /*!< closed the window with focus */ - OB_FOCUS_FALLBACK_NOFOCUS /*!< nothing has focus for some reason */ -} ObFocusFallbackType; - -struct _ObClient* focus_fallback_target(ObFocusFallbackType type); +struct _ObClient* focus_fallback_target(gboolean allow_refocus); /*! Call this when you need to focus something! */ -void focus_fallback(ObFocusFallbackType type); +void focus_fallback(gboolean allow_refocus); /*! Cycle focus amongst windows. */ void focus_cycle(gboolean forward, gboolean linear, gboolean interactive,
M openbox/openbox.copenbox/openbox.c

@@ -278,7 +278,7 @@

if (!reconfigure) { /* get all the existing windows */ client_manage_all(); - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + focus_fallback(TRUE); } else { GList *it;
M openbox/screen.copenbox/screen.c

@@ -463,7 +463,7 @@ }

event_ignore_queued_enters(); - focus_hilite = focus_fallback_target(OB_FOCUS_FALLBACK_NOFOCUS); + focus_hilite = focus_fallback_target(TRUE); if (focus_hilite) { frame_adjust_focus(focus_hilite->frame, TRUE);

@@ -893,7 +893,7 @@ if (((ObClient*)it->data)->type == OB_CLIENT_TYPE_DESKTOP &&

client_validate(it->data) && client_focus(it->data)) break; } else { - focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS); + focus_fallback(TRUE); } show = !!show; /* make it boolean */