aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroga2008-05-01 18:01:13 +0000
committeroga2008-05-01 18:01:13 +0000
commit9b75e9613b34b47c145de16e7d8fea99149b9838 (patch)
treeed97614ad27ef15b20433a8011322ad2988b46e6
parent6117df1277a10bfa2de1e5c9b08c9e6a68d12c28 (diff)
downloadcwm-9b75e9613b34b47c145de16e7d8fea99149b9838.tar.gz
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@
-rw-r--r--calmwm.h4
-rw-r--r--client.c84
-rw-r--r--screen.c5
3 files changed, 33 insertions, 60 deletions
diff --git a/calmwm.h b/calmwm.h
index e38fd3d..b5c7bbb 100644
--- a/calmwm.h
+++ b/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/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)
{
diff --git a/screen.c b/screen.c
index 6155e45..76cc843 100644
--- a/screen.c
+++ b/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;
}