summaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-09-10 11:40:05 +0200
committerDanny Baumann <dannybaumann@web.de>2007-09-10 11:40:05 +0200
commit620a403cfd3fe8b70e1cd291e60fa26f9ba74005 (patch)
treecfd2348806886ae9d1e2548d9af7e7ed3ff3be68 /selection.c
parent57b0175fc4c4f65f237d0b0b10003beaf2eb8624 (diff)
downloadgroup-620a403cfd3fe8b70e1cd291e60fa26f9ba74005.tar.gz
group-620a403cfd3fe8b70e1cd291e60fa26f9ba74005.tar.bz2
Compiz indention style.
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c488
1 files changed, 244 insertions, 244 deletions
diff --git a/selection.c b/selection.c
index 578124e..1b8fc6e 100644
--- a/selection.c
+++ b/selection.c
@@ -30,36 +30,36 @@
*/
static Bool
groupWindowInRegion (CompWindow *w,
- Region src,
- float precision)
+ Region src,
+ float precision)
{
- Region buf;
- int i;
- int area = 0;
- BOX *box;
-
- buf = XCreateRegion ();
- if (!buf)
- return FALSE;
-
- XIntersectRegion (w->region, src, buf);
-
- /* buf area */
- for (i = 0; i < buf->numRects; i++)
- {
- box = &buf->rects[i];
- area += (box->x2 - box->x1) * (box->y2 - box->y1); /* width * height */
- }
+ Region buf;
+ int i;
+ int area = 0;
+ BOX *box;
- XDestroyRegion (buf);
+ buf = XCreateRegion ();
+ if (!buf)
+ return FALSE;
- if (area >= WIN_WIDTH (w) * WIN_HEIGHT (w) * precision)
- {
- XSubtractRegion (src, w->region, src);
- return TRUE;
- }
+ XIntersectRegion (w->region, src, buf);
- return FALSE;
+ /* buf area */
+ for (i = 0; i < buf->numRects; i++)
+ {
+ box = &buf->rects[i];
+ area += (box->x2 - box->x1) * (box->y2 - box->y1); /* width * height */
+ }
+
+ XDestroyRegion (buf);
+
+ if (area >= WIN_WIDTH (w) * WIN_HEIGHT (w) * precision)
+ {
+ XSubtractRegion (src, w->region, src);
+ return TRUE;
+ }
+
+ return FALSE;
}
/*
@@ -68,21 +68,21 @@ groupWindowInRegion (CompWindow *w,
*/
static Bool
groupFindGroupInWindows (GroupSelection *group,
- CompWindow **windows,
- int nWins)
+ CompWindow **windows,
+ int nWins)
{
- int i;
+ int i;
- for (i = 0; i < nWins; i++)
- {
- CompWindow *cw = windows[i];
- GROUP_WINDOW (cw);
+ for (i = 0; i < nWins; i++)
+ {
+ CompWindow *cw = windows[i];
+ GROUP_WINDOW (cw);
- if (gw->group == group)
- return TRUE;
- }
+ if (gw->group == group)
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
/*
@@ -91,33 +91,33 @@ groupFindGroupInWindows (GroupSelection *group,
*/
static CompWindow**
groupFindWindowsInRegion (CompScreen *s,
- Region reg,
- int *c)
+ Region reg,
+ int *c)
{
- float precision = groupGetSelectPrecision (s) / 100.0f;
- CompWindow **ret = NULL;
- int count = 0;
- CompWindow *w;
-
- for (w = s->reverseWindows; w; w = w->prev)
+ float precision = groupGetSelectPrecision (s) / 100.0f;
+ CompWindow **ret = NULL;
+ int count = 0;
+ CompWindow *w;
+
+ for (w = s->reverseWindows; w; w = w->prev)
+ {
+ if (matchEval (groupGetWindowMatch (s), w) &&
+ !w->invisible &&
+ groupWindowInRegion (w, reg, precision))
{
- if (matchEval (groupGetWindowMatch (s), w) &&
- !w->invisible &&
- groupWindowInRegion (w, reg, precision))
- {
- GROUP_WINDOW (w);
- if (gw->group && groupFindGroupInWindows (gw->group, ret, count))
- continue;
+ GROUP_WINDOW (w);
+ if (gw->group && groupFindGroupInWindows (gw->group, ret, count))
+ continue;
- ret = realloc (ret, sizeof (CompWindow) * (count + 1));
- ret[count] = w;
+ ret = realloc (ret, sizeof (CompWindow) * (count + 1));
+ ret[count] = w;
- count++;
- }
+ count++;
}
+ }
- (*c) = count;
- return ret;
+ (*c) = count;
+ return ret;
}
/*
@@ -127,31 +127,31 @@ groupFindWindowsInRegion (CompScreen *s,
static void
groupDeleteSelectionWindow (CompWindow *w)
{
- GROUP_SCREEN (w->screen);
- GROUP_WINDOW (w);
-
- if (gs->tmpSel.nWins > 0 && gs->tmpSel.windows)
- {
- CompWindow **buf = gs->tmpSel.windows;
- int counter = 0;
- int i;
+ GROUP_SCREEN (w->screen);
+ GROUP_WINDOW (w);
- gs->tmpSel.windows = calloc (gs->tmpSel.nWins - 1,
- sizeof (CompWindow *));
+ if (gs->tmpSel.nWins > 0 && gs->tmpSel.windows)
+ {
+ CompWindow **buf = gs->tmpSel.windows;
+ int counter = 0;
+ int i;
- for (i = 0; i < gs->tmpSel.nWins; i++)
- {
- if (buf[i]->id == w->id)
- continue;
+ gs->tmpSel.windows = calloc (gs->tmpSel.nWins - 1,
+ sizeof (CompWindow *));
- gs->tmpSel.windows[counter++] = buf[i];
- }
+ for (i = 0; i < gs->tmpSel.nWins; i++)
+ {
+ if (buf[i]->id == w->id)
+ continue;
- gs->tmpSel.nWins = counter;
- free (buf);
+ gs->tmpSel.windows[counter++] = buf[i];
}
- gw->inSelection = FALSE;
+ gs->tmpSel.nWins = counter;
+ free (buf);
+ }
+
+ gw->inSelection = FALSE;
}
/*
@@ -161,17 +161,17 @@ groupDeleteSelectionWindow (CompWindow *w)
static void
groupAddWindowToSelection (CompWindow *w)
{
- GROUP_SCREEN (w->screen);
- GROUP_WINDOW (w);
+ GROUP_SCREEN (w->screen);
+ GROUP_WINDOW (w);
- gs->tmpSel.windows = realloc (gs->tmpSel.windows,
- sizeof (CompWindow *) *
- (gs->tmpSel.nWins + 1));
+ gs->tmpSel.windows = realloc (gs->tmpSel.windows,
+ sizeof (CompWindow *) *
+ (gs->tmpSel.nWins + 1));
- gs->tmpSel.windows[gs->tmpSel.nWins] = w;
- gs->tmpSel.nWins++;
+ gs->tmpSel.windows[gs->tmpSel.nWins] = w;
+ gs->tmpSel.nWins++;
- gw->inSelection = TRUE;
+ gw->inSelection = TRUE;
}
/*
@@ -181,72 +181,72 @@ groupAddWindowToSelection (CompWindow *w)
static void
groupSelectWindow (CompWindow *w)
{
- GROUP_SCREEN (w->screen);
- GROUP_WINDOW (w);
+ GROUP_SCREEN (w->screen);
+ GROUP_WINDOW (w);
- /* filter out windows we don't want to be groupable */
- if (w->invisible || !matchEval (groupGetWindowMatch (w->screen), w))
- return;
+ /* filter out windows we don't want to be groupable */
+ if (w->invisible || !matchEval (groupGetWindowMatch (w->screen), w))
+ return;
- if (gw->inSelection)
+ if (gw->inSelection)
+ {
+ if (gw->group)
{
- if (gw->group)
- {
- /* unselect group */
- GroupSelection *group = gw->group;
- CompWindow **buf = gs->tmpSel.windows;
- int i, counter = 0;
-
- /* Faster than doing groupDeleteSelectionWindow
- for each window in this group. */
- gs->tmpSel.windows = calloc (gs->tmpSel.nWins - gw->group->nWins,
- sizeof (CompWindow *));
-
- for (i = 0; i < gs->tmpSel.nWins; i++)
- {
- CompWindow *cw = buf[i];
- GROUP_WINDOW (cw);
-
- if (gw->group == group)
- {
- gw->inSelection = FALSE;
- addWindowDamage (cw);
- continue;
- }
-
- gs->tmpSel.windows[counter++] = buf[i];
- }
- gs->tmpSel.nWins = counter;
- free (buf);
- }
- else
+ /* unselect group */
+ GroupSelection *group = gw->group;
+ CompWindow **buf = gs->tmpSel.windows;
+ int i, counter = 0;
+
+ /* Faster than doing groupDeleteSelectionWindow
+ for each window in this group. */
+ gs->tmpSel.windows = calloc (gs->tmpSel.nWins - gw->group->nWins,
+ sizeof (CompWindow *));
+
+ for (i = 0; i < gs->tmpSel.nWins; i++)
+ {
+ CompWindow *cw = buf[i];
+ GROUP_WINDOW (cw);
+
+ if (gw->group == group)
{
- /* unselect single window */
- groupDeleteSelectionWindow (w);
- addWindowDamage (w);
+ gw->inSelection = FALSE;
+ addWindowDamage (cw);
+ continue;
}
+
+ gs->tmpSel.windows[counter++] = buf[i];
+ }
+ gs->tmpSel.nWins = counter;
+ free (buf);
}
else
{
- if (gw->group)
- {
- /* select group */
- int i;
- for (i = 0; i < gw->group->nWins; i++)
- {
- CompWindow *cw = gw->group->windows[i];
-
- groupAddWindowToSelection (cw);
- addWindowDamage (cw);
- }
- }
- else
- {
- /* select single window */
- groupAddWindowToSelection (w);
- addWindowDamage (w);
- }
+ /* unselect single window */
+ groupDeleteSelectionWindow (w);
+ addWindowDamage (w);
+ }
+ }
+ else
+ {
+ if (gw->group)
+ {
+ /* select group */
+ int i;
+ for (i = 0; i < gw->group->nWins; i++)
+ {
+ CompWindow *cw = gw->group->windows[i];
+
+ groupAddWindowToSelection (cw);
+ addWindowDamage (cw);
+ }
+ }
+ else
+ {
+ /* select single window */
+ groupAddWindowToSelection (w);
+ addWindowDamage (w);
}
+ }
}
/*
@@ -255,18 +255,18 @@ groupSelectWindow (CompWindow *w)
*/
Bool
groupSelectSingle (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
- CompWindow *w;
-
- w = findWindowAtDisplay (d, d->activeWindow);
- if (w)
- groupSelectWindow (w);
+ CompWindow *w;
- return TRUE;
+ w = findWindowAtDisplay (d, d->activeWindow);
+ if (w)
+ groupSelectWindow (w);
+
+ return TRUE;
}
/*
@@ -275,36 +275,36 @@ groupSelectSingle (CompDisplay *d,
*/
Bool
groupSelect (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
- CompWindow *w;
-
- w = findWindowAtDisplay (d, d->activeWindow);
- if (w)
- {
- GROUP_SCREEN (w->screen);
+ CompWindow *w;
- if (gs->grabState == ScreenGrabNone)
- {
- groupGrabScreen (w->screen, ScreenGrabSelect);
+ w = findWindowAtDisplay (d, d->activeWindow);
+ if (w)
+ {
+ GROUP_SCREEN (w->screen);
- if (state & CompActionStateInitKey)
- action->state |= CompActionStateTermKey;
+ if (gs->grabState == ScreenGrabNone)
+ {
+ groupGrabScreen (w->screen, ScreenGrabSelect);
- if (state & CompActionStateInitButton)
- action->state |= CompActionStateTermButton;
+ if (state & CompActionStateInitKey)
+ action->state |= CompActionStateTermKey;
- gs->x1 = gs->x2 = pointerX;
- gs->y1 = gs->y2 = pointerY;
- }
+ if (state & CompActionStateInitButton)
+ action->state |= CompActionStateTermButton;
- return TRUE;
+ gs->x1 = gs->x2 = pointerX;
+ gs->y1 = gs->y2 = pointerY;
}
- return FALSE;
+ return TRUE;
+ }
+
+ return FALSE;
}
/*
@@ -313,66 +313,66 @@ groupSelect (CompDisplay *d,
*/
Bool
groupSelectTerminate (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
- CompScreen *s;
- Window xid;
+ CompScreen *s;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "root", 0);
+ s = findScreenAtDisplay (d, xid);
+ if (s)
+ {
+ GROUP_SCREEN (s);
- xid = getIntOptionNamed(option, nOption, "root", 0);
- s = findScreenAtDisplay (d, xid);
- if (s)
+ if (gs->grabState == ScreenGrabSelect)
{
- GROUP_SCREEN (s);
+ groupGrabScreen (s, ScreenGrabNone);
- if (gs->grabState == ScreenGrabSelect)
+ if (gs->x1 != gs->x2 && gs->y1 != gs->y2)
+ {
+ Region reg;
+ XRectangle rect;
+ int count;
+ CompWindow **ws;
+
+ reg = XCreateRegion ();
+ if (reg)
{
- groupGrabScreen (s, ScreenGrabNone);
-
- if (gs->x1 != gs->x2 && gs->y1 != gs->y2)
- {
- Region reg;
- XRectangle rect;
- int count;
- CompWindow **ws;
-
- reg = XCreateRegion ();
- if (reg)
- {
- 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)
- {
- /* select windows */
- int i;
- for (i = 0; i < count; i++)
- groupSelectWindow (ws[i]);
-
- if (groupGetAutoGroup(s))
- groupGroupWindows (d, NULL, 0, NULL, 0);
-
- free (ws);
- }
- XDestroyRegion (reg);
- }
- }
+ 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)
+ {
+ /* select windows */
+ int i;
+ for (i = 0; i < count; i++)
+ groupSelectWindow (ws[i]);
+
+ if (groupGetAutoGroup(s))
+ groupGroupWindows (d, NULL, 0, NULL, 0);
+
+ free (ws);
+ }
+ XDestroyRegion (reg);
}
+ }
}
+ }
- action->state &= ~(CompActionStateTermKey | CompActionStateTermButton);
+ action->state &= ~(CompActionStateTermKey | CompActionStateTermButton);
- return FALSE;
+ return FALSE;
}
/*
@@ -381,28 +381,28 @@ groupSelectTerminate (CompDisplay *d,
*/
void
groupDamageSelectionRect (CompScreen *s,
- int xRoot,
- int yRoot)
+ int xRoot,
+ int yRoot)
{
- REGION reg;
-
- GROUP_SCREEN (s);
+ REGION reg;
+
+ GROUP_SCREEN (s);
- reg.rects = &reg.extents;
- reg.numRects = 1;
+ reg.rects = &reg.extents;
+ reg.numRects = 1;
- reg.extents.x1 = MIN (gs->x1, gs->x2) - 5;
- reg.extents.y1 = MIN (gs->y1, gs->y2) - 5;
- reg.extents.x2 = MAX (gs->x1, gs->x2) + 5;
- reg.extents.y2 = MAX (gs->y1, gs->y2) + 5;
- damageScreenRegion (s, &reg);
+ reg.extents.x1 = MIN (gs->x1, gs->x2) - 5;
+ reg.extents.y1 = MIN (gs->y1, gs->y2) - 5;
+ reg.extents.x2 = MAX (gs->x1, gs->x2) + 5;
+ reg.extents.y2 = MAX (gs->y1, gs->y2) + 5;
+ damageScreenRegion (s, &reg);
- gs->x2 = xRoot;
- gs->y2 = yRoot;
+ gs->x2 = xRoot;
+ gs->y2 = yRoot;
- reg.extents.x1 = MIN (gs->x1, gs->x2) - 5;
- reg.extents.y1 = MIN (gs->y1, gs->y2) - 5;
- reg.extents.x2 = MAX (gs->x1, gs->x2) + 5;
- reg.extents.y2 = MAX (gs->y1, gs->y2) + 5;
- damageScreenRegion (s, &reg);
+ reg.extents.x1 = MIN (gs->x1, gs->x2) - 5;
+ reg.extents.y1 = MIN (gs->y1, gs->y2) - 5;
+ reg.extents.x2 = MAX (gs->x1, gs->x2) + 5;
+ reg.extents.y2 = MAX (gs->y1, gs->y2) + 5;
+ damageScreenRegion (s, &reg);
}