kristian@beryl-project.org
2007-Apr-19 09:24 UTC
[compiz] [PATCH] Make focusDefaultWindow () take a CompScreen as argument
From: Kristian Lyngstol <kristian@beryl-project.org> Avoids focus jumping from one screen to another. --- include/compiz.h | 4 ++-- plugins/rotate.c | 2 +- src/display.c | 38 +++++++++++++++++--------------------- src/event.c | 6 +++--- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/include/compiz.h b/include/compiz.h index 4c72dd3..f882b84 100644 --- a/include/compiz.h +++ b/include/compiz.h @@ -26,7 +26,7 @@ #ifndef _COMPIZ_H #define _COMPIZ_H -#define ABIVERSION 20070417 +#define ABIVERSION 20070418 #include <stdio.h> #include <sys/time.h> @@ -985,7 +985,7 @@ Time getCurrentTimeFromDisplay (CompDisplay *d); void -focusDefaultWindow (CompDisplay *d); +focusDefaultWindow (CompScreen *s); void forEachWindowOnDisplay (CompDisplay *display, diff --git a/plugins/rotate.c b/plugins/rotate.c index bf6bb95..640c8f4 100644 --- a/plugins/rotate.c +++ b/plugins/rotate.c @@ -521,7 +521,7 @@ rotatePreparePaintScreen (CompScreen *s, /* only focus default window if switcher isn't active */ if (i == s->maxGrab) - focusDefaultWindow (s->display); + focusDefaultWindow (s); } rs->moveWindow = 0; diff --git a/src/display.c b/src/display.c index 220b982..e804bbb 100644 --- a/src/display.c +++ b/src/display.c @@ -2527,7 +2527,7 @@ addDisplay (char *name) if (focus == None || focus == PointerRoot) { - focusDefaultWindow (d); + focusDefaultWindow (d->screens); } else { @@ -2539,7 +2539,7 @@ addDisplay (char *name) moveInputFocusToWindow (w); } else - focusDefaultWindow (d); + focusDefaultWindow (d->screens); } d->pingHandle @@ -2565,45 +2565,41 @@ getCurrentTimeFromDisplay (CompDisplay *d) } void -focusDefaultWindow (CompDisplay *d) +focusDefaultWindow (CompScreen *s) { - CompScreen *s; CompWindow *w; CompWindow *focus = NULL; - for (s = d->screens; s; s = s->next) + for (w = s->reverseWindows; w; w = w->prev) { - for (w = s->reverseWindows; w; w = w->prev) - { - if (w->type & CompWindowTypeDockMask) - continue; + if (w->type & CompWindowTypeDockMask) + continue; - if ((*s->focusWindow) (w)) + if ((*s->focusWindow) (w)) + { + if (focus) { - if (focus) + if (w->type & (CompWindowTypeNormalMask | + CompWindowTypeDialogMask | + CompWindowTypeModalDialogMask)) { - if (w->type & (CompWindowTypeNormalMask | - CompWindowTypeDialogMask | - CompWindowTypeModalDialogMask)) - { - if (compareWindowActiveness (focus, w) < 0) + if (compareWindowActiveness (focus, w) < 0) focus = w; - } } - else - focus = w; } + else + focus = w; } } if (focus) { - if (focus->id != d->activeWindow) + if (focus->id != s->display->activeWindow) moveInputFocusToWindow (focus); } else { - XSetInputFocus (d->display, d->screens->root, RevertToPointerRoot, + XSetInputFocus (s->display->display, s->display->screens->root, RevertToPointerRoot, CurrentTime); } } diff --git a/src/event.c b/src/event.c index 8c91cb6..127c222 100644 --- a/src/event.c +++ b/src/event.c @@ -142,7 +142,7 @@ moveInputFocusToOtherWindow (CompWindow *w) moveInputFocusToWindow (ancestor); } else - focusDefaultWindow (display); + focusDefaultWindow (w->screen); } else if (w->type & (CompWindowTypeDialogMask | CompWindowTypeModalDialogMask)) @@ -177,10 +177,10 @@ moveInputFocusToOtherWindow (CompWindow *w) moveInputFocusToWindow (focus); } else - focusDefaultWindow (display); + focusDefaultWindow (w->screen); } else - focusDefaultWindow (display); + focusDefaultWindow (w->screen); } } -- 1.4.4.4