summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-07-05 15:55:23 +0200
committerDanny Baumann <dannybaumann@web.de>2007-07-05 15:55:23 +0200
commitd44b8c4754c925314b59be4236db765c901c206b (patch)
treeb4d2022061b3c8e0a4bc723b1599ea2c625edd61
parent648f2af9dbabc91b8d4806a59a1cf77ed7a7ad50 (diff)
downloadshowdesktop-d44b8c4754c925314b59be4236db765c901c206b.tar.gz
showdesktop-d44b8c4754c925314b59be4236db765c901c206b.tar.bz2
Compiz indent style and minor cleanup.
-rw-r--r--showdesktop.c1159
1 files changed, 597 insertions, 562 deletions
diff --git a/showdesktop.c b/showdesktop.c
index 17c91cf..dc28a05 100644
--- a/showdesktop.c
+++ b/showdesktop.c
@@ -8,7 +8,7 @@
* the following conditions:
*
* Give credit where credit is due, keep the authors message below.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -59,54 +59,52 @@
/* necessary plugin structs */
typedef struct _ShowdesktopPlacer
{
- int placed;
- int onScreenX, onScreenY;
- int offScreenX, offScreenY;
- int origViewportX;
- int origViewportY;
+ int placed;
+ int onScreenX, onScreenY;
+ int offScreenX, offScreenY;
+ int origViewportX;
+ int origViewportY;
} ShowdesktopPlacer;
typedef struct _ShowdesktopDisplay
{
- int screenPrivateIndex;
+ int screenPrivateIndex;
- HandleEventProc handleEvent;
+ HandleEventProc handleEvent;
} ShowdesktopDisplay;
typedef struct _ShowdesktopScreen
{
- int windowPrivateIndex;
-
- PreparePaintScreenProc preparePaintScreen;
- PaintOutputProc paintOutput;
- DonePaintScreenProc donePaintScreen;
- PaintWindowProc paintWindow;
- EnterShowDesktopModeProc enterShowDesktopMode;
- LeaveShowDesktopModeProc leaveShowDesktopMode;
- GetAllowedActionsForWindowProc getAllowedActionsForWindow;
-
- int state;
- int moreAdjust;
-
- Bool ignoreNextTerminateEvent;
+ int windowPrivateIndex;
+
+ PreparePaintScreenProc preparePaintScreen;
+ PaintOutputProc paintOutput;
+ DonePaintScreenProc donePaintScreen;
+ PaintWindowProc paintWindow;
+ EnterShowDesktopModeProc enterShowDesktopMode;
+ LeaveShowDesktopModeProc leaveShowDesktopMode;
+ GetAllowedActionsForWindowProc getAllowedActionsForWindow;
+
+ int state;
+ int moreAdjust;
} ShowdesktopScreen;
typedef struct _ShowdesktopWindow
{
- int sid;
- int distance;
+ int sid;
+ int distance;
- ShowdesktopPlacer *placer;
+ ShowdesktopPlacer *placer;
- GLfloat xVelocity, yVelocity;
- GLfloat tx, ty;
+ GLfloat xVelocity, yVelocity;
+ GLfloat tx, ty;
- unsigned int notAllowedMask;
- unsigned int stateMask;
- Bool wasManaged;
+ unsigned int notAllowedMask;
+ unsigned int stateMask;
+ Bool wasManaged;
- float delta;
- Bool adjust;
+ float delta;
+ Bool adjust;
} ShowdesktopWindow;
/* shortcut macros, usually named X_DISPLAY, X_SCREEN and X_WINDOW
@@ -118,8 +116,8 @@ typedef struct _ShowdesktopWindow
#define SD_DISPLAY(d) \
ShowdesktopDisplay *sd = GET_SHOWDESKTOP_DISPLAY (d)
-#define GET_SHOWDESKTOP_SCREEN(s, fd) \
- ((ShowdesktopScreen *) (s)->privates[(fd)->screenPrivateIndex].ptr)
+#define GET_SHOWDESKTOP_SCREEN(s, sd) \
+ ((ShowdesktopScreen *) (s)->privates[(sd)->screenPrivateIndex].ptr)
#define SD_SCREEN(s) \
ShowdesktopScreen *ss = GET_SHOWDESKTOP_SCREEN (s, GET_SHOWDESKTOP_DISPLAY (s->display))
@@ -129,717 +127,754 @@ typedef struct _ShowdesktopWindow
#define SD_WINDOW(w) \
ShowdesktopWindow *sw = GET_SHOWDESKTOP_WINDOW (w, \
- GET_SHOWDESKTOP_SCREEN (w->screen, \
- GET_SHOWDESKTOP_DISPLAY (w->screen->display)))
+ GET_SHOWDESKTOP_SCREEN (w->screen, \
+ GET_SHOWDESKTOP_DISPLAY (w->screen->display)))
+
/* plugin private index */
static int displayPrivateIndex;
-
/* non interfacing code, aka the logic of the plugin */
-static Bool isSDWin(CompWindow * w)
+static Bool
+isSDWin (CompWindow * w)
{
- if (!(*w->screen->focusWindow) (w))
- return FALSE;
+ if (!(*w->screen->focusWindow) (w))
+ return FALSE;
- if (!matchEval(showdesktopGetWindowMatch(w->screen), w))
- return FALSE;
+ if (!matchEval (showdesktopGetWindowMatch (w->screen), w))
+ return FALSE;
- if (w->state & CompWindowStateSkipPagerMask)
- return FALSE;
+ if (w->state & CompWindowStateSkipPagerMask)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
-static void setSDWindowHints(CompWindow *w, Bool enterSDMode)
+static void
+setSDWindowHints (CompWindow *w,
+ Bool enterSDMode)
{
- unsigned int state = w->state;
+ unsigned int state = w->state;
- SD_WINDOW (w);
+ SD_WINDOW (w);
if (enterSDMode)
- {
- sw->stateMask = state & CompWindowStateSkipPagerMask;
- state |= CompWindowStateSkipPagerMask;
- sw->notAllowedMask = CompWindowActionMoveMask |
- CompWindowActionResizeMask;
- }
+ {
+ sw->stateMask = state & CompWindowStateSkipPagerMask;
+ state |= CompWindowStateSkipPagerMask;
+ sw->notAllowedMask = CompWindowActionMoveMask |
+ CompWindowActionResizeMask;
+ }
else
- {
- state &= ~CompWindowStateSkipPagerMask;
- state |= (sw->stateMask & CompWindowStateSkipPagerMask);
- sw->notAllowedMask = 0;
- }
+ {
+ state &= ~CompWindowStateSkipPagerMask;
+ state |= (sw->stateMask & CompWindowStateSkipPagerMask);
+ sw->notAllowedMask = 0;
+ }
- changeWindowState(w, state);
- recalcWindowActions (w);
+ changeWindowState (w, state);
+ recalcWindowActions (w);
- if (enterSDMode)
- {
- sw->wasManaged = w->managed;
- w->managed = FALSE;
- }
- else
- w->managed = sw->wasManaged;
+ if (enterSDMode)
+ {
+ sw->wasManaged = w->managed;
+ w->managed = FALSE;
+ }
+ else
+ w->managed = sw->wasManaged;
}
-static void repositionSDPlacer(CompWindow * w, int oldState)
+static void
+repositionSDPlacer (CompWindow * w,
+ int oldState)
{
- SD_WINDOW(w);
-
- if (!sw->placer)
- return;
-
- if (oldState == SD_STATE_OFF)
- {
- sw->placer->onScreenX = w->attrib.x;
- sw->placer->onScreenY = w->attrib.y;
- sw->placer->origViewportX = w->screen->x;
- sw->placer->origViewportY = w->screen->y;
- }
-
- switch (showdesktopGetDirection(w->screen))
- {
- case DirectionUp:
- sw->placer->offScreenX = w->attrib.x;
- sw->placer->offScreenY = w->screen->workArea.y - OFF_TOP(w) +
- showdesktopGetWindowPartSize(w->screen);
- break;
- case DirectionDown:
- sw->placer->offScreenX = w->attrib.x;
- sw->placer->offScreenY = w->screen->workArea.y + w->screen->workArea.height +
- OFF_BOTTOM(w) - showdesktopGetWindowPartSize(w->screen);
- break;
- case DirectionLeft:
- sw->placer->offScreenX = w->screen->workArea.x - OFF_LEFT(w) +
- showdesktopGetWindowPartSize(w->screen);
- sw->placer->offScreenY = w->attrib.y;
- break;
- case DirectionRight:
- sw->placer->offScreenX = w->screen->workArea.x + w->screen->workArea.width +
- OFF_RIGHT(w) - showdesktopGetWindowPartSize(w->screen);
- sw->placer->offScreenY = w->attrib.y;
- break;
- case DirectionUpDown:
- sw->placer->offScreenX = w->attrib.x;
- if (MOVE_UP(w))
- sw->placer->offScreenY = w->screen->workArea.y - OFF_TOP(w) +
- showdesktopGetWindowPartSize(w->screen);
- else
- sw->placer->offScreenY = w->screen->workArea.y +
- w->screen->workArea.height + OFF_BOTTOM(w) -
- showdesktopGetWindowPartSize(w->screen);
- break;
- case DirectionLeftRight:
- sw->placer->offScreenY = w->attrib.y;
- if (MOVE_LEFT(w))
- sw->placer->offScreenX = w->screen->workArea.x - OFF_LEFT(w) +
- showdesktopGetWindowPartSize(w->screen);
- else
- sw->placer->offScreenX = w->screen->workArea.x +
- w->screen->workArea.width + OFF_RIGHT(w) -
- showdesktopGetWindowPartSize(w->screen);
- break;
- case DirectionToCorners:
- if (MOVE_LEFT(w))
- sw->placer->offScreenX = w->screen->workArea.x - OFF_LEFT(w) +
- showdesktopGetWindowPartSize(w->screen);
- else
- sw->placer->offScreenX = w->screen->workArea.x +
- w->screen->workArea.width + OFF_RIGHT(w) -
- showdesktopGetWindowPartSize(w->screen);
- if (MOVE_UP(w))
- sw->placer->offScreenY = w->screen->workArea.y - OFF_TOP(w) +
- showdesktopGetWindowPartSize(w->screen);
- else
- sw->placer->offScreenY = w->screen->workArea.y +
- w->screen->workArea.height + OFF_BOTTOM(w) -
- showdesktopGetWindowPartSize(w->screen);
- break;
- default:
- break;
- }
+ SD_WINDOW (w);
+
+ if (!sw->placer)
+ return;
+
+ if (oldState == SD_STATE_OFF)
+ {
+ sw->placer->onScreenX = w->attrib.x;
+ sw->placer->onScreenY = w->attrib.y;
+ sw->placer->origViewportX = w->screen->x;
+ sw->placer->origViewportY = w->screen->y;
+ }
+
+ switch (showdesktopGetDirection (w->screen))
+ {
+ case DirectionUp:
+ sw->placer->offScreenX = w->attrib.x;
+ sw->placer->offScreenY = w->screen->workArea.y - OFF_TOP (w) +
+ showdesktopGetWindowPartSize (w->screen);
+ break;
+ case DirectionDown:
+ sw->placer->offScreenX = w->attrib.x;
+ sw->placer->offScreenY = w->screen->workArea.y +
+ w->screen->workArea.height + OFF_BOTTOM (w) -
+ showdesktopGetWindowPartSize (w->screen);
+ break;
+ case DirectionLeft:
+ sw->placer->offScreenX = w->screen->workArea.x - OFF_LEFT (w) +
+ showdesktopGetWindowPartSize (w->screen);
+ sw->placer->offScreenY = w->attrib.y;
+ break;
+ case DirectionRight:
+ sw->placer->offScreenX = w->screen->workArea.x +
+ w->screen->workArea.width + OFF_RIGHT (w) -
+ showdesktopGetWindowPartSize (w->screen);
+ sw->placer->offScreenY = w->attrib.y;
+ break;
+ case DirectionUpDown:
+ sw->placer->offScreenX = w->attrib.x;
+ if (MOVE_UP (w))
+ sw->placer->offScreenY = w->screen->workArea.y - OFF_TOP (w) +
+ showdesktopGetWindowPartSize (w->screen);
+ else
+ sw->placer->offScreenY = w->screen->workArea.y +
+ w->screen->workArea.height +
+ OFF_BOTTOM (w) -
+ showdesktopGetWindowPartSize (w->screen);
+ break;
+ case DirectionLeftRight:
+ sw->placer->offScreenY = w->attrib.y;
+ if (MOVE_LEFT (w))
+ sw->placer->offScreenX = w->screen->workArea.x - OFF_LEFT (w) +
+ showdesktopGetWindowPartSize (w->screen);
+ else
+ sw->placer->offScreenX = w->screen->workArea.x +
+ w->screen->workArea.width + OFF_RIGHT (w) -
+ showdesktopGetWindowPartSize (w->screen);
+ break;
+ case DirectionToCorners:
+ if (MOVE_LEFT (w))
+ sw->placer->offScreenX = w->screen->workArea.x - OFF_LEFT (w) +
+ showdesktopGetWindowPartSize (w->screen);
+ else
+ sw->placer->offScreenX = w->screen->workArea.x +
+ w->screen->workArea.width + OFF_RIGHT (w) -
+ showdesktopGetWindowPartSize (w->screen);
+ if (MOVE_UP(w))
+ sw->placer->offScreenY = w->screen->workArea.y - OFF_TOP (w) +
+ showdesktopGetWindowPartSize (w->screen);
+ else
+ sw->placer->offScreenY = w->screen->workArea.y +
+ w->screen->workArea.height +
+ OFF_BOTTOM (w) -
+ showdesktopGetWindowPartSize (w->screen);
+ break;
+ default:
+ break;
+ }
}
-static int prepareSDWindows(CompScreen * s, int oldState)
+static int
+prepareSDWindows (CompScreen * s,
+ int oldState)
{
- CompWindow *w;
- CompWindow *desktopWindow;
- int count = 0;
+ CompWindow *w;
+ int count = 0;
- desktopWindow = 0;
-
- for (w = s->windows; w; w = w->next)
- {
- SD_WINDOW(w);
+ for (w = s->windows; w; w = w->next)
+ {
+ SD_WINDOW (w);
- if (getWindowType(s->display, w->id) == CompWindowTypeDesktopMask)
- desktopWindow = w;
+ if (!isSDWin (w))
+ continue;
- if (!isSDWin(w))
- continue;
+ if (!sw->placer)
+ sw->placer = malloc (sizeof (ShowdesktopPlacer));
- if (!sw->placer)
- sw->placer = malloc(sizeof(ShowdesktopPlacer));
+ repositionSDPlacer (w, oldState);
- repositionSDPlacer(w, oldState);
+ sw->placer->placed = TRUE;
+ sw->adjust = TRUE;
+ w->inShowDesktopMode = TRUE;
- sw->placer->placed = TRUE;
- sw->adjust = TRUE;
- w->inShowDesktopMode = TRUE;
- setSDWindowHints (w, TRUE);
+ setSDWindowHints (w, TRUE);
- if (sw->tx)
- sw->tx -= (sw->placer->onScreenX - sw->placer->offScreenX);
- if (sw->ty)
- sw->ty -= (sw->placer->onScreenY - sw->placer->offScreenY);
+ if (sw->tx)
+ sw->tx -= (sw->placer->onScreenX - sw->placer->offScreenX);
+ if (sw->ty)
+ sw->ty -= (sw->placer->onScreenY - sw->placer->offScreenY);
- moveWindow(w,
- sw->placer->offScreenX - w->attrib.x,
- sw->placer->offScreenY - w->attrib.y,
- TRUE, TRUE);
- syncWindowPosition(w);
+ moveWindow(w,
+ sw->placer->offScreenX - w->attrib.x,
+ sw->placer->offScreenY - w->attrib.y,
+ TRUE, TRUE);
+ syncWindowPosition(w);
- count++;
- }
+ count++;
+ }
- if (desktopWindow)
- activateWindow(desktopWindow);
-
- return count;
+ return count;
}
/* plugin initialization */
-static Bool showdesktopInit(CompPlugin * p)
+static Bool
+showdesktopInit (CompPlugin * p)
{
- displayPrivateIndex = allocateDisplayPrivateIndex();
+ displayPrivateIndex = allocateDisplayPrivateIndex ();
- if (displayPrivateIndex < 0)
- return FALSE;
+ if (displayPrivateIndex < 0)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
/* plugin finalization */
-static void showdesktopFini(CompPlugin * p)
+static void
+showdesktopFini (CompPlugin * p)
{
-
- if (displayPrivateIndex >= 0)
- freeDisplayPrivateIndex(displayPrivateIndex);
+ freeDisplayPrivateIndex (displayPrivateIndex);
}
/* adjust velocity for each animation step (adapted from the scale plugin) */
-static int adjustSDVelocity(CompWindow * w)
+static int
+adjustSDVelocity (CompWindow * w)
{
- float dx, dy, adjust, amount;
- float x1, y1;
- float baseX, baseY;
-
- SD_WINDOW(w);
- SD_SCREEN(w->screen);
-
- x1 = y1 = 0.0;
-
- if (ss->state == SD_STATE_ACTIVATING)
- {
- x1 = sw->placer->offScreenX;
- y1 = sw->placer->offScreenY;
- baseX = sw->placer->onScreenX;
- baseY = sw->placer->onScreenY;
- }
- else
- {
- x1 = sw->placer->onScreenX;
- y1 = sw->placer->onScreenY;
- baseX = sw->placer->offScreenX;
- baseY = sw->placer->offScreenY;
- }
-
- dx = x1 - (baseX + sw->tx);
-
- adjust = dx * 0.15f;
- amount = fabs(dx) * 1.5f;
- if (amount < 0.5f)
- amount = 0.5f;
- else if (amount > 5.0f)
- amount = 5.0f;
-
- sw->xVelocity = (amount * sw->xVelocity + adjust) / (amount + 1.0f);
-
- dy = y1 - (baseY + sw->ty);
-
- adjust = dy * 0.15f;
- amount = fabs(dy) * 1.5f;
- if (amount < 0.5f)
- amount = 0.5f;
- else if (amount > 5.0f)
- amount = 5.0f;
-
- sw->yVelocity = (amount * sw->yVelocity + adjust) / (amount + 1.0f);
-
- if (fabs(dx) < 0.1f && fabs(sw->xVelocity) < 0.2f &&
- fabs(dy) < 0.1f && fabs(sw->yVelocity) < 0.2f)
- {
- sw->xVelocity = sw->yVelocity = 0.0f;
- sw->tx = x1 - baseX;
- sw->ty = y1 - baseY;
+ float dx, dy, adjust, amount;
+ float x1, y1;
+ float baseX, baseY;
+
+ SD_WINDOW (w);
+ SD_SCREEN (w->screen);
+
+ x1 = y1 = 0.0;
+
+ if (ss->state == SD_STATE_ACTIVATING)
+ {
+ x1 = sw->placer->offScreenX;
+ y1 = sw->placer->offScreenY;
+ baseX = sw->placer->onScreenX;
+ baseY = sw->placer->onScreenY;
+ }
+ else
+ {
+ x1 = sw->placer->onScreenX;
+ y1 = sw->placer->onScreenY;
+ baseX = sw->placer->offScreenX;
+ baseY = sw->placer->offScreenY;
+ }
+
+ dx = x1 - (baseX + sw->tx);
+
+ adjust = dx * 0.15f;
+ amount = fabs (dx) * 1.5f;
+ if (amount < 0.5f)
+ amount = 0.5f;
+ else if (amount > 5.0f)
+ amount = 5.0f;
+
+ sw->xVelocity = (amount * sw->xVelocity + adjust) / (amount + 1.0f);
+
+ dy = y1 - (baseY + sw->ty);
+
+ adjust = dy * 0.15f;
+ amount = fabs (dy) * 1.5f;
+ if (amount < 0.5f)
+ amount = 0.5f;
+ else if (amount > 5.0f)
+ amount = 5.0f;
+
+ sw->yVelocity = (amount * sw->yVelocity + adjust) / (amount + 1.0f);
+
+ if (fabs (dx) < 0.1f && fabs (sw->xVelocity) < 0.2f &&
+ fabs (dy) < 0.1f && fabs (sw->yVelocity) < 0.2f)
+ {
+ sw->xVelocity = sw->yVelocity = 0.0f;
+ sw->tx = x1 - baseX;
+ sw->ty = y1 - baseY;
- return 0;
- }
- return 1;
+ return 0;
+ }
+ return 1;
}
/* this function gets called periodically (about every 15ms on this machine),
* animation takes place here */
static void
-showdesktopPreparePaintScreen(CompScreen * s, int msSinceLastPaint)
+showdesktopPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
{
- SD_SCREEN(s);
+ SD_SCREEN (s);
- UNWRAP(ss, s, preparePaintScreen);
- (*s->preparePaintScreen) (s, msSinceLastPaint);
- WRAP(ss, s, preparePaintScreen, showdesktopPreparePaintScreen);
+ UNWRAP (ss, s, preparePaintScreen);
+ (*s->preparePaintScreen) (s, msSinceLastPaint);
+ WRAP (ss, s, preparePaintScreen, showdesktopPreparePaintScreen);
- if ((ss->state == SD_STATE_ACTIVATING) ||
- (ss->state == SD_STATE_DEACTIVATING))
- {
- CompWindow *w;
- int steps;
- float amount, chunk;
+ if ((ss->state == SD_STATE_ACTIVATING) ||
+ (ss->state == SD_STATE_DEACTIVATING))
+ {
+ CompWindow *w;
+ int steps;
+ float amount, chunk;
- amount = msSinceLastPaint * 0.05f * showdesktopGetSpeed(s);
- steps = amount / (0.5f * showdesktopGetTimestep(s));
- if (!steps)
- steps = 1;
- chunk = amount / (float)steps;
+ amount = msSinceLastPaint * 0.05f * showdesktopGetSpeed (s);
+ steps = amount / (0.5f * showdesktopGetTimestep (s));
+ if (!steps)
+ steps = 1;
+ chunk = amount / (float)steps;
- while (steps--)
- {
- ss->moreAdjust = 0;
+ while (steps--)
+ {
+ ss->moreAdjust = 0;
- for (w = s->windows; w; w = w->next)
- {
- SD_WINDOW(w);
+ for (w = s->windows; w; w = w->next)
+ {
+ SD_WINDOW (w);
- if (sw->adjust)
- {
- sw->adjust = adjustSDVelocity(w);
+ if (sw->adjust)
+ {
+ sw->adjust = adjustSDVelocity (w);
- ss->moreAdjust |= sw->adjust;
+ ss->moreAdjust |= sw->adjust;
- sw->tx += sw->xVelocity * chunk;
- sw->ty += sw->yVelocity * chunk;
- }
- }
- if (!ss->moreAdjust)
- break;
+ sw->tx += sw->xVelocity * chunk;
+ sw->ty += sw->yVelocity * chunk;
}
-
+ }
+ if (!ss->moreAdjust)
+ break;
}
+ }
}
static Bool
-showdesktopPaintOutput(CompScreen * s,
- const ScreenPaintAttrib * sAttrib,
- const CompTransform *transform,
- Region region, CompOutput *output,
- unsigned int mask)
+showdesktopPaintOutput(CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
{
- Bool status;
+ Bool status;
- SD_SCREEN(s);
+ SD_SCREEN (s);
- if ((ss->state == SD_STATE_ACTIVATING) || (ss->state == SD_STATE_DEACTIVATING))
- mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
+ if ((ss->state == SD_STATE_ACTIVATING) ||
+ (ss->state == SD_STATE_DEACTIVATING))
+ {
+ mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
+ }
- UNWRAP(ss, s, paintOutput);
- status = (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
- WRAP(ss, s, paintOutput, showdesktopPaintOutput);
+ UNWRAP (ss, s, paintOutput);
+ status = (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
+ WRAP (ss, s, paintOutput, showdesktopPaintOutput);
- return status;
+ return status;
}
/* this one gets called after the one above and periodically,
* here the plugin checks if windows reached the end */
-static void showdesktopDonePaintScreen(CompScreen * s)
+static void
+showdesktopDonePaintScreen(CompScreen * s)
{
- SD_SCREEN(s);
+ SD_SCREEN (s);
- if (ss->moreAdjust)
- {
- damageScreen(s);
- }
- else
+ if (ss->moreAdjust)
+ {
+ damageScreen (s);
+ }
+ else
+ {
+ if ((ss->state == SD_STATE_ACTIVATING) ||
+ (ss->state == SD_STATE_DEACTIVATING))
{
- if ((ss->state == SD_STATE_ACTIVATING) ||
- (ss->state == SD_STATE_DEACTIVATING))
+ CompWindow *w;
+ if (ss->state == SD_STATE_ACTIVATING)
+ {
+ ss->state = SD_STATE_ON;
+ }
+ else
+ {
+ Bool inSDMode = FALSE;
+
+ for (w = s->windows; w; w = w->next)
{
- CompWindow *w;
- if (ss->state == SD_STATE_ACTIVATING)
+ if (w->inShowDesktopMode)
+ inSDMode = TRUE;
+ else
+ {
+ SD_WINDOW (w);
+ if (sw->placer)
{
- ss->state = SD_STATE_ON;
+ free (sw->placer);
+ sw->placer = NULL;
}
- else
- {
- Bool inSDMode = FALSE;
-
- for (w = s->windows; w; w = w->next)
- {
- if (w->inShowDesktopMode)
- inSDMode = TRUE;
- else
- {
- SD_WINDOW(w);
- if (sw->placer)
- {
- free(sw->placer);
- sw->placer = NULL;
- }
- }
- }
-
- if (inSDMode)
- ss->state = SD_STATE_ON;
- else
- ss->state = SD_STATE_OFF;
- }
-
- damageScreen(s);
+ }
}
+
+ if (inSDMode)
+ ss->state = SD_STATE_ON;
+ else
+ ss->state = SD_STATE_OFF;
+ }
+
+ damageScreen (s);
}
+ }
- UNWRAP(ss, s, donePaintScreen);
- (*s->donePaintScreen) (s);
- WRAP(ss, s, donePaintScreen, showdesktopDonePaintScreen);
+ UNWRAP (ss, s, donePaintScreen);
+ (*s->donePaintScreen) (s);
+ WRAP (ss, s, donePaintScreen, showdesktopDonePaintScreen);
}
-static Bool showdesktopPaintWindow(CompWindow *w,
- const WindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region, unsigned int mask)
+static Bool
+showdesktopPaintWindow (CompWindow *w,
+ const WindowPaintAttrib *attrib,
+ const CompTransform *transform,
+ Region region,
+ unsigned int mask)
{
- SD_SCREEN(w->screen);
- Bool status;
-
- if ((ss->state == SD_STATE_ACTIVATING) || (ss->state == SD_STATE_DEACTIVATING))
- {
- SD_WINDOW(w);
-
- CompTransform wTransform = *transform;
- WindowPaintAttrib wAttrib = *attrib;
-
- if (sw->adjust)
- {
- float offsetX, offsetY;
+ Bool status;
- offsetX = (ss->state == SD_STATE_DEACTIVATING) ?
- (sw->placer->offScreenX - sw->placer->onScreenX) :
- (sw->placer->onScreenX - sw->placer->offScreenX);
- offsetY = (ss->state == SD_STATE_DEACTIVATING) ?
- (sw->placer->offScreenY - sw->placer->onScreenY) :
- (sw->placer->onScreenY - sw->placer->offScreenY);
+ SD_SCREEN (w->screen);
- wAttrib.opacity = OPAQUE;
-
- mask |= PAINT_WINDOW_TRANSFORMED_MASK;
-
- matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f);
- matrixScale (&wTransform, 1.0f, 1.0f, 1.0f);
- matrixTranslate (&wTransform, sw->tx + offsetX - w->attrib.x,
- sw->ty + offsetY - w->attrib.y, 0.0f);
- }
-
- UNWRAP(ss, w->screen, paintWindow);
- status = (*w->screen->paintWindow) (w, &wAttrib, &wTransform, region, mask);
- WRAP(ss, w->screen, paintWindow, showdesktopPaintWindow);
- }
- else if (ss->state == SD_STATE_ON)
- {
- WindowPaintAttrib wAttrib = *attrib;
+ if ((ss->state == SD_STATE_ACTIVATING) ||
+ (ss->state == SD_STATE_DEACTIVATING))
+ {
+ SD_WINDOW (w);
- if (w->inShowDesktopMode)
- wAttrib.opacity = wAttrib.opacity * showdesktopGetWindowOpacity(w->screen);
+ CompTransform wTransform = *transform;
+ WindowPaintAttrib wAttrib = *attrib;
- UNWRAP(ss, w->screen, paintWindow);
- status = (*w->screen->paintWindow) (w, &wAttrib, transform, region, mask);
- WRAP(ss, w->screen, paintWindow, showdesktopPaintWindow);
- }
- else
+ if (sw->adjust)
{
- UNWRAP(ss, w->screen, paintWindow);
- status = (*w->screen->paintWindow) (w, attrib, transform, region, mask);
- WRAP(ss, w->screen, paintWindow, showdesktopPaintWindow);
+ float offsetX, offsetY;
+
+ offsetX = (ss->state == SD_STATE_DEACTIVATING) ?
+ (sw->placer->offScreenX - sw->placer->onScreenX) :
+ (sw->placer->onScreenX - sw->placer->offScreenX);
+ offsetY = (ss->state == SD_STATE_DEACTIVATING) ?
+ (sw->placer->offScreenY - sw->placer->onScreenY) :
+ (sw->placer->onScreenY - sw->placer->offScreenY);
+
+ wAttrib.opacity = OPAQUE;
+ mask |= PAINT_WINDOW_TRANSFORMED_MASK;
+
+ matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f);
+ matrixScale (&wTransform, 1.0f, 1.0f, 1.0f);
+ matrixTranslate (&wTransform,
+ sw->tx + offsetX - w->attrib.x,
+ sw->ty + offsetY - w->attrib.y, 0.0f);
}
- return status;
+ UNWRAP (ss, w->screen, paintWindow);
+ status = (*w->screen->paintWindow) (w, &wAttrib, &wTransform,
+ region, mask);
+ WRAP (ss, w->screen, paintWindow, showdesktopPaintWindow);
+ }
+ else if (ss->state == SD_STATE_ON)
+ {
+ WindowPaintAttrib wAttrib = *attrib;
+
+ if (w->inShowDesktopMode)
+ wAttrib.opacity = wAttrib.opacity *
+ showdesktopGetWindowOpacity (w->screen);
+
+ UNWRAP (ss, w->screen, paintWindow);
+ status = (*w->screen->paintWindow) (w, &wAttrib, transform,
+ region, mask);
+ WRAP (ss, w->screen, paintWindow, showdesktopPaintWindow);
+ }
+ else
+ {
+ UNWRAP (ss, w->screen, paintWindow);
+ status = (*w->screen->paintWindow) (w, attrib, transform, region, mask);
+ WRAP (ss, w->screen, paintWindow, showdesktopPaintWindow);
+ }
+
+ return status;
}
-static void showdesktopHandleEvent(CompDisplay *d, XEvent *event)
+static void
+showdesktopHandleEvent (CompDisplay *d, XEvent *event)
{
- SD_DISPLAY(d);
+ SD_DISPLAY (d);
- switch(event->type)
+ switch (event->type)
+ {
+ case PropertyNotify:
+ if (event->xproperty.atom == d->desktopViewportAtom)
{
- case PropertyNotify:
- if (event->xproperty.atom == d->desktopViewportAtom)
- {
- CompScreen *s = findScreenAtDisplay(d, event->xproperty.window);
- if (s)
- {
- SD_SCREEN(s);
-
- if ((ss->state == SD_STATE_ON) || (ss->state == SD_STATE_ACTIVATING))
- (*s->leaveShowDesktopMode)(s, NULL);
- }
- }
- break;
+ CompScreen *s = findScreenAtDisplay (d, event->xproperty.window);
+ if (s)
+ {
+ SD_SCREEN (s);
+
+ if ((ss->state == SD_STATE_ON) ||
+ (ss->state == SD_STATE_ACTIVATING))
+ {
+ (*s->leaveShowDesktopMode)(s, NULL);
+ }
+ }
}
+ break;
+ }
- UNWRAP(sd, d, handleEvent);
- (*d->handleEvent)(d, event);
- WRAP(sd, d, handleEvent, showdesktopHandleEvent);
+ UNWRAP (sd, d, handleEvent);
+ (*d->handleEvent)(d, event);
+ WRAP (sd, d, handleEvent, showdesktopHandleEvent);
}
static unsigned int
showdesktopGetAllowedActionsForWindow (CompWindow *w)
{
- unsigned int actions;
+ unsigned int actions;
- SD_SCREEN (w->screen);
- SD_WINDOW (w);
+ SD_SCREEN (w->screen);
+ SD_WINDOW (w);
- UNWRAP (ss, w->screen, getAllowedActionsForWindow);
- actions = (*w->screen->getAllowedActionsForWindow) (w);
- WRAP (ss, w->screen, getAllowedActionsForWindow,
- showdesktopGetAllowedActionsForWindow);
+ UNWRAP (ss, w->screen, getAllowedActionsForWindow);
+ actions = (*w->screen->getAllowedActionsForWindow) (w);
+ WRAP (ss, w->screen, getAllowedActionsForWindow,
+ showdesktopGetAllowedActionsForWindow);
- return (actions & ~sw->notAllowedMask);
+ return (actions & ~sw->notAllowedMask);
}
-static void showdesktopEnterShowDesktopMode(CompScreen *s)
+static void
+showdesktopEnterShowDesktopMode(CompScreen *s)
{
- SD_SCREEN(s);
- int count = 0;
+ int count = 0;
- if (ss->state == SD_STATE_OFF || ss->state == SD_STATE_DEACTIVATING)
+ SD_SCREEN (s);
+
+ if (ss->state == SD_STATE_OFF || ss->state == SD_STATE_DEACTIVATING)
+ {
+ count = prepareSDWindows (s, ss->state);
+ if (count > 0)
{
- count = prepareSDWindows(s, ss->state);
- if (count > 0)
- {
- XSetInputFocus(s->display->display, s->root,
- RevertToPointerRoot, CurrentTime);
- ss->state = SD_STATE_ACTIVATING;
- damageScreen(s);
- }
+ XSetInputFocus (s->display->display, s->root,
+ RevertToPointerRoot, CurrentTime);
+ ss->state = SD_STATE_ACTIVATING;
+ damageScreen (s);
}
+ }
- UNWRAP(ss, s, enterShowDesktopMode);
- (*s->enterShowDesktopMode)(s);
- WRAP(ss, s, enterShowDesktopMode, showdesktopEnterShowDesktopMode);
+ UNWRAP (ss, s, enterShowDesktopMode);
+ (*s->enterShowDesktopMode) (s);
+ WRAP (ss, s, enterShowDesktopMode, showdesktopEnterShowDesktopMode);
}
-static void showdesktopLeaveShowDesktopMode(CompScreen *s, CompWindow *w)
+static void
+showdesktopLeaveShowDesktopMode (CompScreen *s,
+ CompWindow *w)
{
- SD_SCREEN(s);
+ SD_SCREEN (s);
- if (ss->state != SD_STATE_OFF)
- {
- CompWindow *cw;
+ if (ss->state != SD_STATE_OFF)
+ {
+ CompWindow *cw;
- for (cw = s->windows; cw; cw = cw->next)
- {
- SD_WINDOW(cw);
-
- if (w && (w->id != cw->id))
- continue;
-
- if (sw->placer && sw->placer->placed)
- {
- sw->adjust = TRUE;
- sw->placer->placed = FALSE;
-
- /* adjust onscreen position to
- handle viewport changes
- */
- sw->tx += (sw->placer->onScreenX - sw->placer->offScreenX);
- sw->ty += (sw->placer->onScreenY - sw->placer->offScreenY);
-
- sw->placer->onScreenX += (sw->placer->origViewportX -
- cw->screen->x) * cw->screen->width;
- sw->placer->onScreenY += (sw->placer->origViewportY -
- cw->screen->y) * cw->screen->height;
-
- moveWindow(cw, sw->placer->onScreenX - cw->attrib.x,
- sw->placer->onScreenY - cw->attrib.y, TRUE, TRUE);
- syncWindowPosition(cw);
+ for (cw = s->windows; cw; cw = cw->next)
+ {
+ SD_WINDOW (cw);
+
+ if (w && (w->id != cw->id))
+ continue;
+
+ if (sw->placer && sw->placer->placed)
+ {
+ sw->adjust = TRUE;
+ sw->placer->placed = FALSE;
+
+ /* adjust onscreen position to
+ handle viewport changes
+ */
+ sw->tx += (sw->placer->onScreenX - sw->placer->offScreenX);
+ sw->ty += (sw->placer->onScreenY - sw->placer->offScreenY);
+
+ sw->placer->onScreenX += (sw->placer->origViewportX -
+ cw->screen->x) * cw->screen->width;
+ sw->placer->onScreenY += (sw->placer->origViewportY -
+ cw->screen->y) * cw->screen->height;
+
+ moveWindow(cw,
+ sw->placer->onScreenX - cw->attrib.x,
+ sw->placer->onScreenY - cw->attrib.y,
+ TRUE, TRUE);
+ syncWindowPosition(cw);
- setSDWindowHints (cw, FALSE);
- cw->inShowDesktopMode = FALSE;
- }
- }
- ss->state = SD_STATE_DEACTIVATING;
- damageScreen(s);
+ setSDWindowHints (cw, FALSE);
+ cw->inShowDesktopMode = FALSE;
+ }
}
+ ss->state = SD_STATE_DEACTIVATING;
+ damageScreen (s);
+ }
- UNWRAP(ss, s, leaveShowDesktopMode);
- (*s->leaveShowDesktopMode)(s, w);
- WRAP(ss, s, leaveShowDesktopMode, showdesktopLeaveShowDesktopMode);
+ UNWRAP (ss, s, leaveShowDesktopMode);
+ (*s->leaveShowDesktopMode) (s, w);
+ WRAP (ss, s, leaveShowDesktopMode, showdesktopLeaveShowDesktopMode);
}
/* display initialization */
-static Bool showdesktopInitDisplay(CompPlugin * p, CompDisplay * d)
+static Bool
+showdesktopInitDisplay (CompPlugin * p,
+ CompDisplay * d)
{
- ShowdesktopDisplay *sd;
+ ShowdesktopDisplay *sd;
- sd = malloc(sizeof(ShowdesktopDisplay)); /* allocate the display */
- if (!sd)
- return FALSE;
+ sd = malloc (sizeof (ShowdesktopDisplay));
+ if (!sd)
+ return FALSE;
- sd->screenPrivateIndex = allocateScreenPrivateIndex(d);
- if (sd->screenPrivateIndex < 0)
- {
- free(sd);
- return FALSE;
- }
+ sd->screenPrivateIndex = allocateScreenPrivateIndex (d);
+ if (sd->screenPrivateIndex < 0)
+ {
+ free (sd);
+ return FALSE;
+ }
- WRAP(sd, d, handleEvent, showdesktopHandleEvent);
+ WRAP (sd, d, handleEvent, showdesktopHandleEvent);
- d->privates[displayPrivateIndex].ptr = sd;
+ d->privates[displayPrivateIndex].ptr = sd;
- return TRUE;
+ return TRUE;
}
-static void showdesktopFiniDisplay(CompPlugin * p, CompDisplay * d)
+static void
+showdesktopFiniDisplay (CompPlugin * p,
+ CompDisplay * d)
{
- SD_DISPLAY(d);
+ SD_DISPLAY (d);
- freeScreenPrivateIndex(d, sd->screenPrivateIndex);
+ freeScreenPrivateIndex(d, sd->screenPrivateIndex);
- UNWRAP(sd, d, handleEvent);
+ UNWRAP (sd, d, handleEvent);
- free(sd);
+ free (sd);
}
-static Bool showdesktopInitScreen(CompPlugin * p, CompScreen * s)
+static Bool
+showdesktopInitScreen (CompPlugin * p,
+ CompScreen * s)
{
- ShowdesktopScreen *ss;
-
- SD_DISPLAY(s->display);
+ ShowdesktopScreen *ss;
- ss = malloc(sizeof(ShowdesktopScreen));
- if (!ss)
- return FALSE;
+ SD_DISPLAY (s->display);
- ss->windowPrivateIndex = allocateWindowPrivateIndex(s);
- if (ss->windowPrivateIndex < 0)
- {
- free(ss);
- return FALSE;
- }
+ ss = malloc (sizeof (ShowdesktopScreen));
+ if (!ss)
+ return FALSE;
- ss->state = SD_STATE_OFF;
- ss->moreAdjust = 0;
- ss->ignoreNextTerminateEvent = FALSE;
+ ss->windowPrivateIndex = allocateWindowPrivateIndex (s);
+ if (ss->windowPrivateIndex < 0)
+ {
+ free (ss);
+ return FALSE;
+ }
- WRAP(ss, s, preparePaintScreen, showdesktopPreparePaintScreen);
- WRAP(ss, s, paintOutput, showdesktopPaintOutput);
- WRAP(ss, s, donePaintScreen, showdesktopDonePaintScreen);
- WRAP(ss, s, paintWindow, showdesktopPaintWindow);
- WRAP(ss, s, enterShowDesktopMode, showdesktopEnterShowDesktopMode);
- WRAP(ss, s, leaveShowDesktopMode, showdesktopLeaveShowDesktopMode);
- WRAP(ss, s, getAllowedActionsForWindow,
- showdesktopGetAllowedActionsForWindow);
+ ss->state = SD_STATE_OFF;
+ ss->moreAdjust = 0;
- s->privates[sd->screenPrivateIndex].ptr = ss;
+ WRAP (ss, s, preparePaintScreen, showdesktopPreparePaintScreen);
+ WRAP (ss, s, paintOutput, showdesktopPaintOutput);
+ WRAP (ss, s, donePaintScreen, showdesktopDonePaintScreen);
+ WRAP (ss, s, paintWindow, showdesktopPaintWindow);
+ WRAP (ss, s, enterShowDesktopMode, showdesktopEnterShowDesktopMode);
+ WRAP (ss, s, leaveShowDesktopMode, showdesktopLeaveShowDesktopMode);
+ WRAP (ss, s, getAllowedActionsForWindow,
+ showdesktopGetAllowedActionsForWindow);
- return TRUE;
+ s->privates[sd->screenPrivateIndex].ptr = ss;
+ return TRUE;
}
/* Free screen resources */
-static void showdesktopFiniScreen(CompPlugin * p, CompScreen * s)
+static void
+showdesktopFiniScreen (CompPlugin * p,
+ CompScreen * s)
{
- SD_SCREEN(s);
+ SD_SCREEN (s);
- UNWRAP(ss, s, preparePaintScreen);
- UNWRAP(ss, s, paintOutput);
- UNWRAP(ss, s, donePaintScreen);
- UNWRAP(ss, s, paintWindow);
- UNWRAP(ss, s, enterShowDesktopMode);
- UNWRAP(ss, s, leaveShowDesktopMode);
- UNWRAP(ss, s, getAllowedActionsForWindow);
+ UNWRAP (ss, s, preparePaintScreen);
+ UNWRAP (ss, s, paintOutput);
+ UNWRAP (ss, s, donePaintScreen);
+ UNWRAP (ss, s, paintWindow);
+ UNWRAP (ss, s, enterShowDesktopMode);
+ UNWRAP (ss, s, leaveShowDesktopMode);
+ UNWRAP (ss, s, getAllowedActionsForWindow);
- freeWindowPrivateIndex(s, ss->windowPrivateIndex);
+ freeWindowPrivateIndex (s, ss->windowPrivateIndex);
- free(ss);
+ free (ss);
}
-
/* window init */
-static Bool showdesktopInitWindow(CompPlugin * p, CompWindow * w)
+static Bool
+showdesktopInitWindow (CompPlugin * p,
+ CompWindow * w)
{
- ShowdesktopWindow *sw;
+ ShowdesktopWindow *sw;
- SD_SCREEN(w->screen);
+ SD_SCREEN (w->screen);
- sw = malloc(sizeof(ShowdesktopWindow));
- if (!sw)
- return FALSE;
+ sw = malloc (sizeof (ShowdesktopWindow));
+ if (!sw)
+ return FALSE;
- sw->tx = sw->ty = 0.0f;
- sw->adjust = FALSE;
- sw->xVelocity = sw->yVelocity = 0.0f;
- sw->delta = 1.0f;
- sw->placer = NULL;
+ sw->adjust = FALSE;
+ sw->delta = 1.0f;
+ sw->placer = NULL;
- sw->stateMask = 0;
- sw->notAllowedMask = 0;
+ sw->tx = sw->ty = 0.0f;
+ sw->xVelocity = sw->yVelocity = 0.0f;
- w->privates[ss->windowPrivateIndex].ptr = sw;
+ sw->stateMask = 0;
+ sw->notAllowedMask = 0;
- return TRUE;
+ w->privates[ss->windowPrivateIndex].ptr = sw;
+
+ return TRUE;
}
/* Free window resources */
-static void showdesktopFiniWindow(CompPlugin * p, CompWindow * w)
+static void
+showdesktopFiniWindow (CompPlugin * p,
+ CompWindow * w)
{
- SD_WINDOW(w);
+ SD_WINDOW (w);
- free(sw);
+ free (sw);
}
-static int
-showdesktopGetVersion (CompPlugin *plugin, int version)
+static int
+showdesktopGetVersion (CompPlugin *plugin,
+ int version)
{
- return ABIVERSION;
+ return ABIVERSION;
}
/* plugin vtable */
static CompPluginVTable showdesktopVTable = {
- "showdesktop",
- showdesktopGetVersion,
- 0,
- showdesktopInit,
- showdesktopFini,
- showdesktopInitDisplay,
- showdesktopFiniDisplay,
- showdesktopInitScreen,
- showdesktopFiniScreen,
- showdesktopInitWindow,
- showdesktopFiniWindow,
- NULL,
- NULL,
- NULL,
- NULL,
- 0, /* deps */
- 0, /* sizeof (deps) / sizeof (deps[0]) */
- 0,
- 0
+ "showdesktop",
+ showdesktopGetVersion,
+ 0,
+ showdesktopInit,
+ showdesktopFini,
+ showdesktopInitDisplay,
+ showdesktopFiniDisplay,
+ showdesktopInitScreen,
+ showdesktopFiniScreen,
+ showdesktopInitWindow,
+ showdesktopFiniWindow,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0, /* deps */
+ 0, /* sizeof (deps) / sizeof (deps[0]) */
+ 0,
+ 0
};
/* send plugin info */
-CompPluginVTable *getCompPluginInfo(void)
+CompPluginVTable *
+getCompPluginInfo (void)
{
- return &showdesktopVTable;
+ return &showdesktopVTable;
}