summaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-08-22 13:59:58 +0200
committerDanny Baumann <dannybaumann@web.de>2007-08-22 13:59:58 +0200
commitc3170ae7bcfffe16e982541118b1b67badd66df0 (patch)
tree9cdab26d0a8836a69e19740ec84479c2376ed4ab /selection.c
parent580f686e1ce1f53a7798ca741423eb9888f85826 (diff)
downloadgroup-c3170ae7bcfffe16e982541118b1b67badd66df0.tar.gz
group-c3170ae7bcfffe16e982541118b1b67badd66df0.tar.bz2
Clean up selection code.
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c181
1 files changed, 95 insertions, 86 deletions
diff --git a/selection.c b/selection.c
index 97730a3..83a2ead 100644
--- a/selection.c
+++ b/selection.c
@@ -179,69 +179,77 @@ groupAddWindowToSelection (CompWindow *w)
*
*/
static void
-groupSelectWindow (CompWindow * w)
+groupSelectWindow (CompWindow *w)
{
+ Bool isGroupable;
+
GROUP_SCREEN (w->screen);
GROUP_WINDOW (w);
- // select singe window
- if (matchEval (groupGetWindowMatch (w->screen), w) &&
- !w->invisible && !gw->inSelection && !gw->group)
- {
- groupAddWindowToSelection(w);
- addWindowDamage(w);
- }
- // unselect single window
- else if (matchEval (groupGetWindowMatch (w->screen), w) &&
- !w->invisible && gw->inSelection && !gw->group)
- {
- groupDeleteSelectionWindow(w);
- addWindowDamage(w);
- }
- // select group
- else if (matchEval (groupGetWindowMatch (w->screen), w) &&
- !w->invisible && !gw->inSelection && gw->group)
+ isGroupable = matchEval (groupGetWindowMatch (w->screen), w) &&
+ !w->invisible;
+
+ if (!isGroupable)
+ return;
+
+ if (gw->inSelection)
{
- int i;
- for (i = 0; i < gw->group->nWins; i++)
+ if (gw->group)
{
- CompWindow *cw = gw->group->windows[i];
+ /* unselect group */
+ GroupSelection *group = gw->group;
+ CompWindow **buf = gs->tmpSel.windows;
+ int i, counter = 0;
- groupAddWindowToSelection (cw);
- addWindowDamage (cw);
- }
- }
- // Unselect group
- else if (matchEval (groupGetWindowMatch (w->screen), w) &&
- !w->invisible && gw->inSelection && gw->group)
- {
+ /* Faster than doing groupDeleteSelectionWindow
+ for each window in this group. */
+ gs->tmpSel.windows = calloc (gs->tmpSel.nWins - gw->group->nWins,
+ sizeof (CompWindow *));
- /* Faster than doing groupDeleteSelectionWindow
- for each window in this group. */
- GroupSelection *group = gw->group;
- CompWindow **buf = gs->tmpSel.windows;
- int counter = 0;
- int i;
+ for (i = 0; i < gs->tmpSel.nWins; i++)
+ {
+ CompWindow *cw = buf[i];
+ GROUP_WINDOW (cw);
- gs->tmpSel.windows = calloc (gs->tmpSel.nWins - gw->group->nWins,
- sizeof (CompWindow *));
+ if (gw->group == group)
+ {
+ gw->inSelection = FALSE;
+ addWindowDamage (cw);
+ continue;
+ }
- for (i = 0; i < gs->tmpSel.nWins; i++)
+ gs->tmpSel.windows[counter++] = buf[i];
+ }
+ gs->tmpSel.nWins = counter;
+ free (buf);
+ }
+ else
{
- CompWindow *cw = buf[i];
- GROUP_WINDOW (cw);
-
- if (gw->group == group)
+ /* unselect single window */
+ groupDeleteSelectionWindow (w);
+ addWindowDamage (w);
+ }
+ }
+ else
+ {
+ if (gw->group)
+ {
+ /* select group */
+ int i;
+ for (i = 0; i < gw->group->nWins; i++)
{
- gw->inSelection = FALSE;
+ CompWindow *cw = gw->group->windows[i];
+
+ groupAddWindowToSelection (cw);
addWindowDamage (cw);
- continue;
}
-
- gs->tmpSel.windows[counter++] = buf[i];
}
- gs->tmpSel.nWins = counter;
- free (buf);
+ else
+ {
+ /* select single window */
+ groupAddWindowToSelection (w);
+ addWindowDamage (w);
+ }
}
}
@@ -259,7 +267,6 @@ groupSelectSingle (CompDisplay *d,
CompWindow *w;
w = findWindowAtDisplay (d, d->activeWindow);
-
if (w)
groupSelectWindow (w);
@@ -280,26 +287,28 @@ groupSelect (CompDisplay *d,
CompWindow *w;
w = findWindowAtDisplay (d, d->activeWindow);
- if (!w)
- return FALSE;
+ if (w)
+ {
+ GROUP_SCREEN (w->screen);
- GROUP_SCREEN (w->screen);
+ if (gs->grabState == ScreenGrabNone)
+ {
+ groupGrabScreen (w->screen, ScreenGrabSelect);
- if (gs->grabState == ScreenGrabNone)
- {
- groupGrabScreen (w->screen, ScreenGrabSelect);
+ if (state & CompActionStateInitKey)
+ action->state |= CompActionStateTermKey;
- if (state & CompActionStateInitKey)
- action->state |= CompActionStateTermKey;
+ if (state & CompActionStateInitButton)
+ action->state |= CompActionStateTermButton;
- if (state & CompActionStateInitButton)
- action->state |= CompActionStateTermButton;
+ gs->x1 = gs->x2 = pointerX;
+ gs->y1 = gs->y2 = pointerY;
+ }
- gs->x1 = gs->x2 = pointerX;
- gs->y1 = gs->y2 = pointerY;
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
/*
@@ -318,7 +327,6 @@ groupSelectTerminate (CompDisplay *d,
xid = getIntOptionNamed(option, nOption, "root", 0);
s = findScreenAtDisplay (d, xid);
-
if (s)
{
GROUP_SCREEN (s);
@@ -329,38 +337,39 @@ groupSelectTerminate (CompDisplay *d,
if (gs->x1 != gs->x2 && gs->y1 != gs->y2)
{
- Region reg = XCreateRegion ();
+ Region reg;
XRectangle rect;
int count;
CompWindow **ws;
- rect.x = MIN (gs->x1, gs->x2) - 2;
- rect.y = MIN (gs->y1, gs->y2) - 2;
- rect.width = MAX (gs->x1, gs->x2) - MIN(gs->x1, gs->x2) + 4;
- rect.height = MAX (gs->y1, gs->y2) - MIN(gs->y1, gs->y2) + 4;
- XUnionRectWithRegion (&rect, reg, reg);
-
- damageScreenRegion (s, reg);
-
- ws = groupFindWindowsInRegion (s, reg, &count);
- if (ws)
+ reg = XCreateRegion ();
+ if (reg)
{
- /* select windows */
- int i;
- for (i = 0; i < count; i++)
+ rect.x = MIN (gs->x1, gs->x2) - 2;
+ rect.y = MIN (gs->y1, gs->y2) - 2;
+ rect.width = MAX (gs->x1, gs->x2) -
+ MIN(gs->x1, gs->x2) + 4;
+ rect.height = MAX (gs->y1, gs->y2) -
+ MIN(gs->y1, gs->y2) + 4;
+ XUnionRectWithRegion (&rect, reg, reg);
+
+ damageScreenRegion (s, reg);
+
+ ws = groupFindWindowsInRegion (s, reg, &count);
+ if (ws)
{
- CompWindow *cw = ws[i];
+ /* select windows */
+ int i;
+ for (i = 0; i < count; i++)
+ groupSelectWindow (ws[i]);
- groupSelectWindow
- (cw);
- }
- if (groupGetAutoGroup(s))
- {
- groupGroupWindows (d, NULL, 0, NULL, 0);
+ if (groupGetAutoGroup(s))
+ groupGroupWindows (d, NULL, 0, NULL, 0);
+
+ free (ws);
}
- free (ws);
+ XDestroyRegion (reg);
}
- XDestroyRegion (reg);
}
}
}