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.
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)
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)
{
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'. */
changed = TRUE;
}
} else {
+ self->iconic = iconic;
+
if (curdesk)
client_set_desktop(self, screen_desktop, FALSE);
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);
}
/* 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);
}
}
*/
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;
}
}
-#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;
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;
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);
}
}
return NULL;
}
-ObClient* focus_fallback_target(ObFocusFallbackType type)
+ObClient* focus_fallback_target(gboolean allow_refocus)
{
GList *it;
ObClient *old;
old = focus_client;
- if ((type == OB_FOCUS_FALLBACK_UNFOCUSING
- || type == OB_FOCUS_FALLBACK_CLOSED) && old) {
- if (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;
-
- /* 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))
+ 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;
+
+ /* 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))
{
- 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)))
- {
- 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
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))
{
return NULL;
}
-void focus_fallback(ObFocusFallbackType type)
+void focus_fallback(gboolean allow_refocus)
{
ObClient *new;
*/
focus_set_client(NULL);
- if ((new = focus_fallback_target(type)))
+ if ((new = focus_fallback_target(allow_refocus)))
client_focus(new);
}
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,
if (!reconfigure) {
/* get all the existing windows */
client_manage_all();
- focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+ focus_fallback(TRUE);
} else {
GList *it;
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);
client_validate(it->data) && client_focus(it->data))
break;
} else {
- focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+ focus_fallback(TRUE);
}
show = !!show; /* make it boolean */