aboutsummaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c84
1 files changed, 31 insertions, 53 deletions
diff --git a/client.c b/client.c
index 95faaeb..f27e8d8 100644
--- a/client.c
+++ b/client.c
@@ -15,14 +15,12 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: client.c,v 1.18 2008/04/16 13:35:37 oga Exp $
+ * $Id: client.c,v 1.19 2008/05/01 18:01:13 oga Exp $
*/
#include "headers.h"
#include "calmwm.h"
-static struct client_ctx *client__cycle(struct client_ctx *cc,
- struct client_ctx *(*iter)(struct client_ctx *));
int _inwindowbounds(struct client_ctx *, int, int);
static char emptystring[] = "";
@@ -231,9 +229,6 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow)
if (_curcc == cc)
_curcc = NULL;
- if (sc->cycle_client == cc)
- sc->cycle_client = NULL;
-
XFree(cc->size);
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
@@ -595,50 +590,47 @@ match:
return;
}
-/*
- * TODO: seems to have some issues still on the first invocation
- * (globally the first)
- */
-
struct client_ctx *
client_cyclenext(int reverse)
{
- struct screen_ctx *sc;
- struct client_ctx *cc;
- struct client_ctx *(*iter)(struct client_ctx *) =
- reverse ? &client_mruprev : &client_mrunext;
-
- /* TODO: maybe this should just be a CIRCLEQ. */
+ struct client_ctx *oldcc = client_current(), *newcc;
+ struct screen_ctx *sc = screen_current();
+ int again = 1;
- if ((cc = client_current()) == NULL) {
- if (TAILQ_EMPTY(&Clientq))
- return(NULL);
- cc = TAILQ_FIRST(&Clientq);
- }
+ /* If no windows then you cant cycle */
+ if (TAILQ_EMPTY(&sc->mruq))
+ return (NULL);
- sc = CCTOSC(cc);
+ if (oldcc == NULL)
+ oldcc = (reverse ? TAILQ_LAST(&sc->mruq, cycle_entry_q) :
+ TAILQ_FIRST(&sc->mruq));
- /* if altheld; then reset the iterator to the beginning */
- if (!sc->altpersist || sc->cycle_client == NULL)
- sc->cycle_client = TAILQ_FIRST(&sc->mruq);
+ newcc = oldcc;
+ while (again) {
+ again = 0;
- if (sc->cycle_client == NULL)
- return (NULL);
+ newcc = (reverse ? client_mruprev(newcc) :
+ client_mrunext(newcc));
- /*
- * INVARIANT: as long as sc->cycle_client != NULL here, we
- * won't exit with sc->cycle_client == NULL
- */
+ /* Only cycle visible windows. */
+ if (newcc->flags & CLIENT_HIDDEN)
+ again = 1;
- if ((sc->cycle_client = client__cycle(cc, iter)) == NULL)
- sc->cycle_client = cc;
+ /* Is oldcc the only non-hidden window? */
+ if (newcc == oldcc) {
+ if (again)
+ return (NULL); /* No windows visible. */
- /* Do the actual warp. */
- client_ptrsave(cc);
- client_ptrwarp(sc->cycle_client);
- sc->altpersist = 1; /* This is reset when alt is let go... */
+ goto done;
+ }
+ }
+done:
+ /* reset when alt is released. XXX I hate this hack */
+ sc->altpersist = 1;
+ client_ptrsave(oldcc);
+ client_ptrwarp(newcc);
- return (sc->cycle_client);
+ return (newcc);
}
struct client_ctx *
@@ -661,20 +653,6 @@ client_mruprev(struct client_ctx *cc)
ccc : TAILQ_LAST(&sc->mruq, cycle_entry_q));
}
-static struct client_ctx *
-client__cycle(struct client_ctx *cc,
- struct client_ctx *(*iter)(struct client_ctx *))
-{
- struct client_ctx *save = cc;
-
- do {
- if (!((cc = (*iter)(cc))->flags & CLIENT_HIDDEN))
- break;
- } while (cc != save);
-
- return (cc != save ? cc : NULL);
-}
-
void
client_placecalc(struct client_ctx *cc)
{