From 33a0603d8d1abc0074c98de6d6d74d3e1851a0af Mon Sep 17 00:00:00 2001 From: Roi Cohen Date: Tue, 5 Jun 2007 14:49:33 +0300 Subject: [PATCH] plugin events --- include/cube.h | 15 ++++++++- plugins/cube.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- plugins/rotate.c | 29 ++++++++++++++++ 3 files changed, 135 insertions(+), 4 deletions(-) diff --git a/include/cube.h b/include/cube.h index bc44a32..0dcb14b 100644 --- a/include/cube.h +++ b/include/cube.h @@ -25,7 +25,7 @@ #include -#define CUBE_ABIVERSION 20070604 +#define CUBE_ABIVERSION 20070605 #define CUBE_DISPLAY_OPTION_ABI 0 #define CUBE_DISPLAY_OPTION_INDEX 1 @@ -38,6 +38,8 @@ typedef struct _CubeDisplay { int screenPrivateIndex; CompOption opt[CUBE_DISPLAY_OPTION_NUM]; + + HandleCompizEventProc handleCompizEvent; } CubeDisplay; #define CUBE_SCREEN_OPTION_COLOR 0 @@ -77,6 +79,13 @@ typedef enum _PaintOrder FTB } PaintOrder; +typedef enum _RotationMode +{ + NoRotation = 0, + RotationChange, + RotationManual +} RotationMode; + typedef struct _CubeScreen { PreparePaintScreenProc preparePaintScreen; DonePaintScreenProc donePaintScreen; @@ -131,6 +140,10 @@ typedef struct _CubeScreen { float outputXOffset; float outputYOffset; + RotationMode rotationMode; + Bool disableCaps; + Bool paintAllViewports; + CompTexture *bg; int nBg; } CubeScreen; diff --git a/plugins/cube.c b/plugins/cube.c index f28b9f5..43c6578 100644 --- a/plugins/cube.c +++ b/plugins/cube.c @@ -1295,10 +1295,10 @@ cubePaintTransformedOutput (CompScreen *s, else paintOrder = BTF; // Inside cube - start with BTF faces. - if (cs->invert == -1) + if (cs->invert == -1 || cs->paintAllViewports) cubePaintAllViewports(s, &sa, transform, region, outputPtr, mask, xMove, size, hsize, paintOrder); - if (!clear && cs->grabIndex == 0 && hsize > 2 && + if (!clear && cs->grabIndex == 0 && hsize > 2 && !cs->disableCaps && (cs->invert != 1 || sa.vRotate != 0.0f || sa.yTranslate != 0.0f)) { (*cs->paintTopBottom) (s, &sa, transform, outputPtr, hsize); @@ -1309,7 +1309,7 @@ cubePaintTransformedOutput (CompScreen *s, else paintOrder = FTB; // Inside cube - continue with FTB faces. - if (cs->invert == 1) + if (cs->invert == 1 || cs->paintAllViewports) cubePaintAllViewports(s, &sa, transform, region, outputPtr, mask, xMove, size, hsize, paintOrder); s->display->textureFilter = filter; @@ -1458,6 +1458,85 @@ cubeApplyScreenTransform (CompScreen *s, matrixTranslate (transform, -cs->outputXOffset, cs->outputYOffset, 0.0f); } +static void cubeHandleCompizEvent(CompDisplay * d, char *pluginName, + char *eventName, CompOption * option, int nOption) +{ + CUBE_DISPLAY(d); + + UNWRAP (cd, d, handleCompizEvent); + (*d->handleCompizEvent) (d, pluginName, eventName, option, nOption); + WRAP (cd, d, handleCompizEvent, cubeHandleCompizEvent); + + if (strcmp(pluginName, "3d") == 0) + { + if (strcmp(eventName, "disableCapsEvent") == 0) + { + Window xid = getIntOptionNamed(option, nOption, "root", 0); + CompScreen *s = findScreenAtDisplay(d, xid); + + if (s) + { + CUBE_SCREEN(s); + cs->disableCaps = getBoolOptionNamed(option, nOption, "disableCaps", FALSE); + } + } + + else if (strcmp(eventName, "paintAllViewportsEvent") == 0) + { + Window xid = getIntOptionNamed(option, nOption, "root", 0); + CompScreen *s = findScreenAtDisplay(d, xid); + + if (s) + { + CUBE_SCREEN(s); + cs->paintAllViewports = getBoolOptionNamed(option, nOption, "paintAllViewports", FALSE); + } + } + } + if (strcmp(pluginName, "rotate") == 0) + { + if (strcmp(eventName, "rotateEvent") == 0) + { + Window xid = getIntOptionNamed(option, nOption, "root", 0); + CompScreen *s = findScreenAtDisplay(d, xid); + + if (s) + { + CUBE_SCREEN(s); + Bool rotate = getBoolOptionNamed(option, nOption, "rotating", FALSE); + Bool manual = getBoolOptionNamed(option, nOption, "manual", FALSE); + + if (rotate && manual) + cs->rotationMode = RotationManual; + else if (rotate) + cs->rotationMode = RotationChange; + else + cs->rotationMode = NoRotation; + damageScreen(s); + } + } + } +} + +static void +cubeFoldEvent(CompScreen *s, Bool unfolded) +{ + CompOption o[2]; + + o[0].type = CompOptionTypeInt; + o[0].name = "root"; + o[0].value.i = s->root; + + o[1].type = CompOptionTypeBool; + o[1].name = "unfolded"; + o[1].value.b = unfolded; + + (*s->display->handleCompizEvent) (s->display, + "cube", + "unfoldEvent", + o, 2); +} + static Bool cubeUnfold (CompDisplay *d, CompAction *action, @@ -1487,6 +1566,7 @@ cubeUnfold (CompDisplay *d, if (cs->grabIndex) { cs->unfolded = TRUE; + cubeFoldEvent (s, TRUE); damageScreen (s); } @@ -1522,6 +1602,7 @@ cubeFold (CompDisplay *d, if (cs->grabIndex) { cs->unfolded = FALSE; + cubeFoldEvent (s, FALSE); damageScreen (s); } } @@ -1710,6 +1791,8 @@ cubeInitDisplay (CompPlugin *p, d->privates[cubeDisplayPrivateIndex].ptr = cd; + WRAP (cd, d, handleCompizEvent, cubeHandleCompizEvent); + return TRUE; } @@ -1721,6 +1804,8 @@ cubeFiniDisplay (CompPlugin *p, freeScreenPrivateIndex (d, cd->screenPrivateIndex); + UNWRAP (cd, d, handleCompizEvent); + compFiniDisplayOptions (d, cd->opt, CUBE_DISPLAY_OPTION_NUM); free (cd); @@ -1807,6 +1892,10 @@ cubeInitScreen (CompPlugin *p, cs->bg = NULL; cs->nBg = 0; + cs->disableCaps = FALSE; + cs->paintAllViewports = FALSE; + cs->rotationMode = NoRotation; + memset (cs->cleared, 0, sizeof (cs->cleared)); cubeUpdateOutputs (s); diff --git a/plugins/rotate.c b/plugins/rotate.c index b91d387..4e44465 100644 --- a/plugins/rotate.c +++ b/plugins/rotate.c @@ -255,6 +255,30 @@ rotateReleaseMoveWindow (CompScreen *s) rs->moveWindow = None; } +static void rotateEvent(CompScreen *s, + Bool rotating, + Bool manual) +{ + CompOption o[3]; + + o[0].type = CompOptionTypeInt; + o[0].name = "root"; + o[0].value.i = s->root; + + o[1].type = CompOptionTypeBool; + o[1].name = "rotating"; + o[1].value.b = rotating; + + o[2].type = CompOptionTypeBool; + o[2].name = "manual"; + o[2].value.b = manual; + + (*s->display->handleCompizEvent)(s->display, + "rotate", + "rotateEvent", + o, 3); +} + static void rotatePreparePaintScreen (CompScreen *s, int msSinceLastPaint) @@ -342,6 +366,7 @@ rotatePreparePaintScreen (CompScreen *s, else tx = (s->hsize * xrot / 360.0f) + 0.5f; + rotateEvent (s, FALSE, FALSE); moveScreenViewport (s, tx, 0, TRUE); rs->xrot = 0.0f; @@ -500,6 +525,10 @@ rotateInitiate (CompDisplay *d, rs->moving = FALSE; rs->slow = FALSE; + /* notify other plugins that rotation starts - if action is + non-NULL, we are called from the 'Initiate rotate' binding */ + rotateEvent (s, TRUE, (action != NULL)); + if (!rs->grabIndex) { rs->grabIndex = pushScreenGrab (s, s->invisibleCursor, "rotate"); -- 1.4.4.2