summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2011-02-22 13:45:09 +0100
committerMichael Cardell Widerkrantz <mc@hack.org>2011-02-22 13:45:09 +0100
commit4762de7978fbba95e3de54a8779cfee949f57d76 (patch)
tree0f20cb2031739e5a738169ade199781b40becc9b
parent64ab7ab9813e76ca1ae1972e014e8ddbbeeffed0 (diff)
downloadmcwm-4762de7978fbba95e3de54a8779cfee949f57d76.zip
Simplify focusnext(). We already have a pointer to our place in the
wslist in struct client. Use it! Don't go through the list looking for our data.
-rw-r--r--mcwm.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/mcwm.c b/mcwm.c
index 03f7009..fc2d5df 100644
--- a/mcwm.c
+++ b/mcwm.c
@@ -1197,8 +1197,6 @@ void movewindow(xcb_drawable_t win, uint16_t x, uint16_t y)
void focusnext(void)
{
struct client *client;
- bool found = false;
- struct item *item;
#if DEBUG
if (NULL != focuswin)
@@ -1217,45 +1215,24 @@ void focusnext(void)
}
client = wslist[curws]->data;
- found = true;
}
else
{
- /*
- * Find our current focused window in list of windows on the
- * current workspace and focus the next.
- */
- for (item = wslist[curws]; item != NULL; item = item->next)
+ if (NULL == focuswin->wsitem[curws]->next)
{
- if (focuswin == item->data)
- {
- if (NULL != item->next)
- {
- client = item->next->data;
- found = true;
- break;
- }
- else
- {
- /*
- * We were at the end of list. Focusing on first window in
- * list instead.
- */
- client = wslist[curws]->data;
- found = true;
- break;
- }
- }
+ /*
+ * We were at the end of list. Focusing on first window in
+ * list.
+ */
+ client = wslist[curws]->data;
}
- }
+ else
+ {
+ /* Otherwise, focus the next in list. */
+ client = focuswin->wsitem[curws]->next->data;
+ }
+ } /* if NULL focuswin */
- if (!found)
- {
- PDEBUG("Couldn't find any new window to focus on. Focusing first in "
- "list...\n");
- client = wslist[curws]->data;
- }
-
/*
* Raise window if it's occluded, then warp pointer into it and
* set keyboard focus to it.
@@ -2763,7 +2740,7 @@ void events(void)
handle_keypress(e);
}
break;
-
+
case XCB_ENTER_NOTIFY:
{
xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *)ev;