summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-05-01 18:01:14 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-05-01 18:01:14 +0000
commita484fbc9b1a4ead013e494e9465c027417b49b51 (patch)
tree1e70faf343e1766388b2cc23244bdff71e407f92 /app/cwm
parentd8c6fd36bac4fd6a1e528111ce281d607c39a7e2 (diff)
Rework the alt-tabbing code to be a lot simpler.
Diff mostly from Edd Barrett, with some minor changes from me. Unfortunately the issue where apps like gvim and xpdf are stealing keyrelease events causing the ordering to be messed up, but this is a lot better. A fix for the aforementioned issue shall be forthcoming, once a good one's been found. ok okan@, also tested by todd@
Diffstat (limited to 'app/cwm')
-rw-r--r--app/cwm/calmwm.h4
-rw-r--r--app/cwm/client.c84
-rw-r--r--app/cwm/screen.c5
3 files changed, 33 insertions, 60 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index e38fd3d1f..b5c7bbb00 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: calmwm.h,v 1.37 2008/04/16 13:47:29 oga Exp $
+ * $Id: calmwm.h,v 1.38 2008/05/01 18:01:13 oga Exp $
*/
#ifndef _CALMWM_H_
@@ -82,8 +82,6 @@ struct screen_ctx {
struct cycle_entry_q mruq;
- struct client_ctx* cycle_client;
-
struct fonthash fonthash;
XftDraw *xftdraw;
XftColor xftcolor;
diff --git a/app/cwm/client.c b/app/cwm/client.c
index 95faaeb68..f27e8d8f2 100644
--- a/app/cwm/client.c
+++ b/app/cwm/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)
{
diff --git a/app/cwm/screen.c b/app/cwm/screen.c
index 6155e45b4..76cc8439f 100644
--- a/app/cwm/screen.c
+++ b/app/cwm/screen.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: screen.c,v 1.5 2008/04/16 13:35:37 oga Exp $
+ * $Id: screen.c,v 1.6 2008/05/01 18:01:13 oga Exp $
*/
#include "headers.h"
@@ -69,7 +69,4 @@ screen_updatestackingorder(void)
void
screen_init(void)
{
- struct screen_ctx *sc = screen_current();
-
- sc->cycle_client = NULL;
}