summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-10-09 08:19:51 +0200
committerDanny Baumann <dannybaumann@web.de>2008-10-09 08:19:51 +0200
commit00bbcede66961790f27d00e9fb537e0bb1bc8565 (patch)
tree5f733d7dd5fd442692a9d53f345fe741b87748f2
parent3e12b3db623801344370f914fafe96e7c0737939 (diff)
downloadgroup-00bbcede66961790f27d00e9fb537e0bb1bc8565.tar.gz
group-00bbcede66961790f27d00e9fb537e0bb1bc8565.tar.bz2
Fixed window activation behaviour.
Some cleanups.
-rw-r--r--group-internal.h6
-rw-r--r--group.c200
-rw-r--r--init.c7
-rw-r--r--tab.c25
4 files changed, 115 insertions, 123 deletions
diff --git a/group-internal.h b/group-internal.h
index f3d4244..269bdba 100644
--- a/group-internal.h
+++ b/group-internal.h
@@ -341,7 +341,8 @@ struct _GroupSelection {
ChangeTabAnimationDirection nextDirection;
GroupTabBarSlot *nextTopTab;
- GroupTabBarSlot *activateTab;
+ /* check focus stealing prevention after changing tabs */
+ Bool checkFocusAfterTabChange;
GroupTabBar *tabBar;
@@ -419,6 +420,7 @@ typedef struct _GroupScreen {
WindowUngrabNotifyProc windowUngrabNotify;
DamageWindowRectProc damageWindowRect;
WindowStateChangeNotifyProc windowStateChangeNotify;
+ ActivateWindowProc activateWindow;
GroupPendingMoves *pendingMoves;
GroupPendingGrabs *pendingGrabs;
@@ -612,6 +614,8 @@ groupDamageWindowRect (CompWindow *w,
Bool initial,
BoxPtr rect);
+void
+groupActivateWindow (CompWindow *w);
/*
* cairo.c
diff --git a/group.c b/group.c
index 3a1d4e0..54f3fb2 100644
--- a/group.c
+++ b/group.c
@@ -660,7 +660,6 @@ groupAddWindowToGroup (CompWindow *w,
g->topTab = NULL;
g->prevTopTab = NULL;
g->nextTopTab = NULL;
- g->activateTab = NULL;
g->changeAnimationTime = 0;
g->changeAnimationDirection = 0;
@@ -671,6 +670,8 @@ groupAddWindowToGroup (CompWindow *w,
g->tabBar = NULL;
+ g->checkFocusAfterTabChange = FALSE;
+
g->grabWindow = None;
g->grabMask = 0;
@@ -1386,98 +1387,86 @@ void
groupHandleEvent (CompDisplay *d,
XEvent *event)
{
+ CompWindow *w;
+ CompScreen *s;
+
GROUP_DISPLAY (d);
switch (event->type) {
case MotionNotify:
- {
- CompScreen *s;
- s = findScreenAtDisplay (d, event->xmotion.root);
- if (s)
- groupHandleMotionEvent (s, pointerX, pointerY);
- }
+ s = findScreenAtDisplay (d, event->xmotion.root);
+ if (s)
+ groupHandleMotionEvent (s, pointerX, pointerY);
break;
case ButtonPress:
- {
- CompScreen *s;
- s = findScreenAtDisplay (d, event->xbutton.root);
- if (s)
- groupHandleButtonPressEvent (s, event);
- }
+ s = findScreenAtDisplay (d, event->xbutton.root);
+ if (s)
+ groupHandleButtonPressEvent (s, event);
break;
case ButtonRelease:
- {
- CompScreen *s;
- s = findScreenAtDisplay (d, event->xbutton.root);
- if (s)
- groupHandleButtonReleaseEvent (s, event);
- }
+ s = findScreenAtDisplay (d, event->xbutton.root);
+ if (s)
+ groupHandleButtonReleaseEvent (s, event);
break;
case MapNotify:
+ w = findWindowAtDisplay (d, event->xmap.window);
+ if (w)
{
- CompWindow *cw, *w;
- w = findWindowAtDisplay (d, event->xmap.window);
- if (w)
+ CompWindow *cw;
+ for (cw = w->screen->windows; cw; cw = cw->next)
{
- for (cw = w->screen->windows; cw; cw = cw->next)
+ if (w->id == cw->frame)
{
- if (w->id == cw->frame)
- {
- GROUP_WINDOW (cw);
- if (gw->windowHideInfo)
- XUnmapWindow (cw->screen->display->display,
- cw->frame);
- }
+ GROUP_WINDOW (cw);
+ if (gw->windowHideInfo)
+ XUnmapWindow (cw->screen->display->display, cw->frame);
}
}
}
break;
case UnmapNotify:
+ w = findWindowAtDisplay (d, event->xunmap.window);
+ if (w)
{
- CompWindow *w;
- w = findWindowAtDisplay (d, event->xunmap.window);
- if (w)
- {
- GROUP_WINDOW (w);
+ GROUP_WINDOW (w);
- if (w->pendingUnmaps)
+ if (w->pendingUnmaps)
+ {
+ if (w->shaded)
{
- if (w->shaded)
- {
- gw->windowState = WindowShaded;
+ gw->windowState = WindowShaded;
- if (gw->group && groupGetShadeAll (w->screen))
- groupShadeWindows (w, gw->group, TRUE);
- }
- else if (w->minimized)
- {
- gw->windowState = WindowMinimized;
+ if (gw->group && groupGetShadeAll (w->screen))
+ groupShadeWindows (w, gw->group, TRUE);
+ }
+ else if (w->minimized)
+ {
+ gw->windowState = WindowMinimized;
- if (gw->group && groupGetMinimizeAll (w->screen))
- groupMinimizeWindows (w, gw->group, TRUE);
- }
+ if (gw->group && groupGetMinimizeAll (w->screen))
+ groupMinimizeWindows (w, gw->group, TRUE);
}
+ }
- if (gw->group)
+ if (gw->group)
+ {
+ if (gw->group->tabBar && IS_TOP_TAB (w, gw->group))
+ {
+ /* on unmap of the top tab, hide the tab bar and the
+ input prevention window */
+ groupTabSetVisibility (gw->group, FALSE, PERMANENT);
+ }
+ if (!w->pendingUnmaps)
{
- if (gw->group->tabBar && IS_TOP_TAB (w, gw->group))
+ /* close event */
+ if (!(gw->animateState & IS_UNGROUPING))
{
- /* on unmap of the top tab, hide the tab bar and the
- input prevention window */
- groupTabSetVisibility (gw->group, FALSE, PERMANENT);
- }
- if (!w->pendingUnmaps)
- {
- /* close event */
- if (!(gw->animateState & IS_UNGROUPING))
- {
- groupDeleteGroupWindow (w);
- damageScreen (w->screen);
- }
+ groupDeleteGroupWindow (w);
+ damageScreen (w->screen);
}
}
}
@@ -1485,7 +1474,22 @@ groupHandleEvent (CompDisplay *d,
break;
case ClientMessage:
- if (event->xclient.message_type == gd->resizeNotifyAtom)
+ if (event->xclient.message_type == d->winActiveAtom)
+ {
+ w = findWindowAtDisplay (d, event->xclient.window);
+ if (w)
+ {
+ GROUP_WINDOW (w);
+
+ if (gw->group && gw->group->tabBar &&
+ !IS_TOP_TAB (w, gw->group))
+ {
+ gw->group->checkFocusAfterTabChange = TRUE;
+ groupChangeTab (gw->slot, RotateUncertain);
+ }
+ }
+ }
+ else if (event->xclient.message_type == gd->resizeNotifyAtom)
{
CompWindow *w;
w = findWindowAtDisplay (d, event->xclient.window);
@@ -1520,43 +1524,6 @@ groupHandleEvent (CompDisplay *d,
}
}
}
- else if (event->xclient.message_type == d->winActiveAtom)
- {
- CompWindow *w;
- w = findWindowAtDisplay (d, event->xclient.window);
- if (w)
- {
- GROUP_WINDOW (w);
-
- if (gw->group && gw->group->tabBar && HAS_TOP_WIN (gw->group))
- {
- CompWindow *tw = TOP_TAB (gw->group);
-
- if (w->id != tw->id)
- {
- /* if a non top-tab has been activated, switch to the
- top-tab instead - but only if is visible */
- if (tw->shaded)
- {
- int newState;
- newState = tw->state & ~CompWindowStateShadedMask;
- changeWindowState (tw, newState);
- updateWindowAttributes (tw,
- CompStackingUpdateModeNone);
- }
- else if (tw->minimized)
- unminimizeWindow (tw);
-
- if (!(tw->state & CompWindowStateHiddenMask))
- {
- if (gw->group->changeState == NoTabChange)
- gw->group->activateTab = gw->slot;
- sendWindowActivationRequest (tw->screen, tw->id);
- }
- }
- }
- }
- }
break;
default:
@@ -1585,22 +1552,7 @@ groupHandleEvent (CompDisplay *d,
switch (event->type) {
case PropertyNotify:
- if (event->xproperty.atom == d->winActiveAtom)
- {
- CompWindow *w;
- w = findWindowAtDisplay (d, d->activeWindow);
- if (w)
- {
- GROUP_WINDOW (w);
-
- if (gw->group && gw->group->activateTab)
- {
- groupChangeTab (gw->group->activateTab, RotateUncertain);
- gw->group->activateTab = NULL;
- }
- }
- }
- else if (event->xproperty.atom == d->wmNameAtom)
+ if (event->xproperty.atom == d->wmNameAtom)
{
CompWindow *w;
w = findWindowAtDisplay (d, event->xproperty.window);
@@ -2134,3 +2086,19 @@ groupWindowStateChangeNotify (CompWindow *w,
(*s->windowStateChangeNotify) (w, lastState);
WRAP (gs, s, windowStateChangeNotify, groupWindowStateChangeNotify);
}
+
+void
+groupActivateWindow (CompWindow *w)
+{
+ CompScreen *s = w->screen;
+
+ GROUP_SCREEN (s);
+ GROUP_WINDOW (w);
+
+ if (gw->group && gw->group->tabBar && !IS_TOP_TAB (w, gw->group))
+ groupChangeTab (gw->slot, RotateUncertain);
+
+ UNWRAP (gs, s, activateWindow);
+ (*s->activateWindow) (w);
+ WRAP (gs, s, activateWindow, groupActivateWindow);
+}
diff --git a/init.c b/init.c
index 920e181..8d995c4 100644
--- a/init.c
+++ b/init.c
@@ -302,6 +302,7 @@ groupInitScreen (CompPlugin *p,
WRAP (gs, s, windowUngrabNotify, groupWindowUngrabNotify);
WRAP (gs, s, damageWindowRect, groupDamageWindowRect);
WRAP (gs, s, windowStateChangeNotify, groupWindowStateChangeNotify);
+ WRAP (gs, s, activateWindow, groupActivateWindow);
s->base.privates[gd->screenPrivateIndex].ptr = gs;
@@ -431,6 +432,7 @@ groupFiniScreen (CompPlugin *p,
UNWRAP (gs, s, windowUngrabNotify);
UNWRAP (gs, s, damageWindowRect);
UNWRAP (gs, s, windowStateChangeNotify);
+ UNWRAP (gs, s, activateWindow);
finiTexture (s, &gs->glowTexture);
free (gs);
@@ -505,6 +507,11 @@ groupFiniWindow (CompPlugin *p,
groupSetWindowVisibility (w, TRUE);
gw->readOnlyProperty = TRUE;
+
+ /* FIXME: this implicitly calls the wrapped function activateWindow
+ (via groupDeleteTabBarSlot -> groupUnhookTabBarSlot -> groupChangeTab)
+ --> better wrap into removeObject and call it for removeWindow
+ */
if (gw->group)
groupDeleteGroupWindow (w);
diff --git a/tab.c b/tab.c
index 2e57b69..d216dc5 100644
--- a/tab.c
+++ b/tab.c
@@ -698,7 +698,12 @@ groupHandleAnimation (GroupSelection *group)
group->changeState = TabChangeNewIn;
- (*s->activateWindow) (top);
+ if (!group->checkFocusAfterTabChange ||
+ allowWindowFocus (top, NO_FOCUS_MASK, s->x, s->y, 0))
+ {
+ (*s->activateWindow) (top);
+ }
+ group->checkFocusAfterTabChange = FALSE;
}
if (group->changeState == TabChangeNewIn &&
@@ -1554,11 +1559,13 @@ groupChangeTab (GroupTabBarSlot *topTab,
{
CompWindow *w, *oldTopTab;
GroupSelection *group;
+ CompScreen *s;
if (!topTab)
return TRUE;
w = topTab->window;
+ s = w->screen;
GROUP_WINDOW (w);
@@ -1614,7 +1621,7 @@ groupChangeTab (GroupTabBarSlot *topTab,
group->changeAnimationDirection *= -1;
group->changeAnimationTime =
- groupGetChangeAnimationTime (w->screen) * 500 -
+ groupGetChangeAnimationTime (s) * 500 -
group->changeAnimationTime;
group->changeState = (group->changeState == TabChangeOldOut) ?
TabChangeNewIn : TabChangeOldOut;
@@ -1642,7 +1649,7 @@ groupChangeTab (GroupTabBarSlot *topTab,
{
int dx, dy;
- GROUP_SCREEN (w->screen);
+ GROUP_SCREEN (s);
dx = WIN_CENTER_X (oldTopTab) - WIN_CENTER_X (w);
dy = WIN_CENTER_Y (oldTopTab) - WIN_CENTER_Y (w);
@@ -1658,8 +1665,8 @@ groupChangeTab (GroupTabBarSlot *topTab,
/* we use only the half time here -
the second half will be PaintFadeOut */
group->changeAnimationTime =
- groupGetChangeAnimationTime (w->screen) * 500;
- groupTabChangeActivateEvent (w->screen, TRUE);
+ groupGetChangeAnimationTime (s) * 500;
+ groupTabChangeActivateEvent (s, TRUE);
group->changeState = TabChangeOldOut;
}
else
@@ -1669,7 +1676,13 @@ groupChangeTab (GroupTabBarSlot *topTab,
group->prevTopTab = group->topTab;
else
group->prevTopTab = NULL;
- (*w->screen->activateWindow) (w);
+
+ if (!group->checkFocusAfterTabChange ||
+ allowWindowFocus (w, NO_FOCUS_MASK, s->x, s->y, 0))
+ {
+ (*s->activateWindow) (w);
+ }
+ group->checkFocusAfterTabChange = FALSE;
}
}