diff options
author | Danny Baumann <dannybaumann@web.de> | 2007-04-16 14:38:47 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2007-04-16 14:38:47 +0200 |
commit | f5be415caa085a112636187cae337c999af8c0a7 (patch) | |
tree | e2c70635564caa7cbe5fd0b3903d770d9854dc63 | |
parent | a28f1eec7d88e54e1e614773369e9cb3dab778ba (diff) | |
download | beryl-premerge-f5be415caa085a112636187cae337c999af8c0a7.tar.gz beryl-premerge-f5be415caa085a112636187cae337c999af8c0a7.tar.bz2 |
Rewrote tile's operation logic:
- Don't base the logic on viewports. This logic breaks whenever a tiled window is moved to another viewport.
- Get rid of linked lists to manage tiled windows.
- Clean ups.
-rw-r--r-- | src/tile.c | 1498 |
1 files changed, 650 insertions, 848 deletions
@@ -36,383 +36,334 @@ #include <compiz.h> #include "tile_options.h" -#define GET_TILE_DISPLAY(d) ((TileDisplay *) (d)->privates[displayPrivateIndex].ptr) -#define TILE_DISPLAY(d) TileDisplay *td = GET_TILE_DISPLAY (d) - -#define GET_TILE_SCREEN(s, td) ((TileScreen *) (s)->privates[(td)->screenPrivateIndex].ptr) -#define TILE_SCREEN(s) TileScreen *ts = GET_TILE_SCREEN (s, GET_TILE_DISPLAY (s->display)) - -#define GET_TILE_WINDOW(w, ts) ((TileWindow *) (w)->privates[(ts)->windowPrivateIndex].ptr) -#define TILE_WINDOW(w) TileWindow *tw = GET_TILE_WINDOW (w, GET_TILE_SCREEN (w->screen, GET_TILE_DISPLAY (w->screen->display))) - -#define THIS_VIEWPORT(s) (ts->viewports[(((s)->hsize * (s)->y) + (s)->x)]) - -// Minimal width and height under which the window cant be resized -#define MINIMUM_WIDTH 25 -#define MINIMUM_HEIGHT 10 - static int displayPrivateIndex = 0; +typedef enum { + NoAnimation = 0, + Animating, + AnimationDone +} WindowAnimationType; + typedef struct _TileDisplay { - int screenPrivateIndex; + int screenPrivateIndex; } TileDisplay; -typedef struct _TileViewport { - TileTileToggleTypeEnum currentTileType; // which kind of tiling is applied to windows on viewport - int tiledCount; // number of windows - CompWindow *firstTiled; // pointer to first tiled window -} TileViewport; - typedef struct _TileScreen { - TileViewport *viewports; - Bool isResizing; // whether there any windows on screen being resized - int oneDuration; // duration of animation for one window - int msResizing; // number of ms elapsed from start of resizing animation - - PaintWindowProc paintWindow; - WindowResizeNotifyProc windowResizeNotify; - PreparePaintScreenProc preparePaintScreen; - DonePaintScreenProc donePaintScreen; - PaintScreenProc paintScreen; - SetScreenOptionProc setScreenOption; - - int windowPrivateIndex; + int windowPrivateIndex; + + Bool isAnimating; + int oneDuration; // duration of animation for one window + int msResizing; // number of ms elapsed from start of resizing animation + TileTileToggleTypeEnum tileType; + + PaintWindowProc paintWindow; + WindowResizeNotifyProc windowResizeNotify; + PreparePaintScreenProc preparePaintScreen; + DonePaintScreenProc donePaintScreen; + PaintScreenProc paintScreen; } TileScreen; typedef struct _TileWindow { - CompWindow *next; // next window for tiling - CompWindow *prev; // previous window for tiling + Bool isTiled; - Bool resizedAlready; // whether the animation already resized the window + XRectangle savedCoords; + XRectangle prevCoords; + XRectangle newCoords; + unsigned int savedMaxState; + Bool savedValid; - // coords used in animation, before last resize - int previousX; - int previousY; - int previousWidth; - int previousHeight; + Bool alreadyResized; - // coords used when configuring window in middle of animation - int futureX; - int futureY; - int futureWidth; - int futureHeight; + WindowAnimationType animationType; + unsigned int animationNum; - Bool isResizing; // tells if the window is being resized + GLushort outlineColor[3]; +} TileWindow; - GLushort outlineColor[3]; - int prevState; +#define GET_TILE_DISPLAY(d) ((TileDisplay *) (d)->privates[displayPrivateIndex].ptr) +#define TILE_DISPLAY(d) TileDisplay *td = GET_TILE_DISPLAY (d) - // coords before whole tiling - int originalX; - int originalY; - int originalWidth; - int originalHeight; -} TileWindow; +#define GET_TILE_SCREEN(s, td) ((TileScreen *) (s)->privates[(td)->screenPrivateIndex].ptr) +#define TILE_SCREEN(s) TileScreen *ts = GET_TILE_SCREEN (s, GET_TILE_DISPLAY (s->display)) -static Bool placeWindow(CompWindow *w, int x, int y, int width, int height); -static Bool isTileWindow(CompWindow *w); -static Bool setWindowFutureSize(CompWindow *w); +#define GET_TILE_WINDOW(w, ts) ((TileWindow *) (w)->privates[(ts)->windowPrivateIndex].ptr) +#define TILE_WINDOW(w) TileWindow *tw = GET_TILE_WINDOW (w, GET_TILE_SCREEN (w->screen, GET_TILE_DISPLAY (w->screen->display))) -int current = 0; + +static Bool placeWindow(CompWindow *w, int x, int y, int width, int height); +static Bool tileSetNewWindowSize(CompWindow *w); // window painting function, draws animation static Bool tilePaintWindow(CompWindow * w, - const WindowPaintAttrib * attrib, - const CompTransform * transform, - Region region, unsigned int mask) + const WindowPaintAttrib * attrib, + const CompTransform * transform, + Region region, unsigned int mask) { - CompScreen *s = w->screen; - Bool status; - Bool dontDraw = FALSE; + CompScreen *s = w->screen; + Bool status; + Bool dontDraw = FALSE; - TILE_WINDOW(w); - TILE_SCREEN(s); + TILE_WINDOW(w); + TILE_SCREEN(s); - if (tw->isResizing) + if (tw->animationType != NoAnimation) + { + WindowPaintAttrib wAttrib = *attrib; + CompTransform wTransform = *transform; + float animationDuration = tileGetAnimationDuration(s->display); + + switch (tileGetAnimateType(s->display)) { - WindowPaintAttrib wAttrib = *attrib; - CompTransform wTransform = *transform; - float animationDuration = tileGetAnimationDuration(s->display); + /* + Drop animation + */ + case AnimateTypeDrop: + matrixRotate(&wTransform, + 100.0f / animationDuration * ts->msResizing - 100, + 0.0f, 0.0f, 1.0f); + mask |= PAINT_WINDOW_TRANSFORMED_MASK; + break; + + /* + Zoom animation + */ + case AnimateTypeZoom: + matrixTranslate(&wTransform, 0, 0, + -1 + ts->msResizing / animationDuration); + mask |= PAINT_WINDOW_TRANSFORMED_MASK; + break; + + /* + Slide animation + */ + case AnimateTypeSlide: + if (ts->msResizing < 0.75 * animationDuration) + wAttrib.opacity = OPAQUE / 2; + else + wAttrib.opacity = OPAQUE / 2 + OPAQUE / 2 * + (ts->msResizing - 0.75 * animationDuration) / + (0.25 * animationDuration); - switch (tileGetAnimateType(s->display)) + if (ts->msResizing > tw->animationNum * ts->oneDuration) { - /* - Drop animation - */ - case AnimateTypeDrop: - matrixRotate(&wTransform, - 100.0f / animationDuration * ts->msResizing - 100, - 0.0f, 0.0f, 1.0f); - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - break; - - /* - Zoom animation - */ - case AnimateTypeZoom: - matrixTranslate(&wTransform, 0, 0, - -1 + ts->msResizing / animationDuration); - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - break; - - /* - Slide animation - */ - case AnimateTypeSlide: - if (ts->msResizing < 0.75 * animationDuration) - wAttrib.opacity = OPAQUE / 2; - else - wAttrib.opacity = OPAQUE / 2 + OPAQUE / 2 * - (ts->msResizing - 0.75 * animationDuration) / - (0.25 * animationDuration); - - if (ts->msResizing > current * ts->oneDuration) - // windows that have animation finished already - { - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - } - else if (ts->msResizing > (current-1)*ts->oneDuration && ts->msResizing < current*ts->oneDuration) - // animation in progress - { - int thisDur; // ms spent animating this window - for(thisDur = ts->msResizing;thisDur > ts->oneDuration;thisDur -= ts->oneDuration); - - if (current % 2) - matrixTranslate(&wTransform, -s->width + - s->width * (float)thisDur / ts->oneDuration, - 0, 0); - else - matrixTranslate(&wTransform, s->width - - s->width * (float)thisDur / ts->oneDuration, - 0, 0); - - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - } - else - dontDraw = TRUE; - break; - - /* - Outline animation - */ - case AnimateTypeOutline: - dontDraw = TRUE; - break; - - /* - Fade animation - */ - case AnimateTypeFade: - // first half of the animation, fade out - if (ts->msResizing < 0.40f * animationDuration) - { - wAttrib.opacity = OPAQUE - OPAQUE * - ts->msResizing / (0.40f * animationDuration); - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - } - else if (ts->msResizing > 0.40f * animationDuration && !tw->resizedAlready) - { - // resize window right after first half - setWindowFutureSize(w); - dontDraw = TRUE; - } - else if (ts->msResizing > 0.60f * animationDuration) - // second half of animation, fade in - { - wAttrib.opacity = OPAQUE * - (ts->msResizing - 0.60f * animationDuration) / - (0.40f * animationDuration); - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - } - break; - - default: - break; + /* animation finished */ + tw->animationType = AnimationDone; + } + else if (ts->msResizing > (tw->animationNum - 1) * ts->oneDuration) + { + int thisDur; // ms spent animating this window + thisDur = ts->msResizing % ts->oneDuration; + + if (tw->animationNum % 2) + matrixTranslate(&wTransform, s->width - + s->width * (float)thisDur / ts->oneDuration, + 0, 0); + else + matrixTranslate(&wTransform, -s->width + + s->width * (float)thisDur / ts->oneDuration, + 0, 0); + + mask |= PAINT_WINDOW_TRANSFORMED_MASK; + } + else + dontDraw = TRUE; + break; + /* + Outline animation + */ + case AnimateTypeOutline: + dontDraw = TRUE; + break; + + /* + Fade animation + */ + case AnimateTypeFade: + // first half of the animation, fade out + if (ts->msResizing < 0.40f * animationDuration) + { + wAttrib.opacity = OPAQUE - OPAQUE * + ts->msResizing / (0.40f * animationDuration); + mask |= PAINT_WINDOW_TRANSFORMED_MASK; + } + else if (ts->msResizing > 0.40f * animationDuration && !tw->alreadyResized) + { + // resize window right after first half + tileSetNewWindowSize(w); + dontDraw = TRUE; + } + else if (ts->msResizing > 0.60f * animationDuration) + // second half of animation, fade in + { + wAttrib.opacity = OPAQUE * + (ts->msResizing - 0.60f * animationDuration) / + (0.40f * animationDuration); + mask |= PAINT_WINDOW_TRANSFORMED_MASK; } + break; - if (dontDraw) - mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; + default: + break; + } - UNWRAP(ts, s, paintWindow); - status = (*s->paintWindow) (w, &wAttrib, &wTransform, region, mask); - WRAP(ts, s, paintWindow, tilePaintWindow); + if (dontDraw) + mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; - current -= 1; - } - else // paint window as always - { - UNWRAP(ts, s, paintWindow); - status = (*s->paintWindow) (w, attrib, transform, region, mask); - WRAP(ts, s, paintWindow, tilePaintWindow); - } + UNWRAP(ts, s, paintWindow); + status = (*s->paintWindow) (w, &wAttrib, &wTransform, region, mask); + WRAP(ts, s, paintWindow, tilePaintWindow); + } + else // paint window as always + { + UNWRAP(ts, s, paintWindow); + status = (*s->paintWindow) (w, attrib, transform, region, mask); + WRAP(ts, s, paintWindow, tilePaintWindow); + } - return status; + return status; } static void tilePreparePaintScreen(CompScreen * s, int msSinceLastPaint) { - TILE_SCREEN(s); - current = THIS_VIEWPORT(s).tiledCount; + TILE_SCREEN(s); - // add spent time - if (ts->isResizing) - ts->msResizing += msSinceLastPaint; + // add spent time + if (ts->isAnimating) + ts->msResizing += msSinceLastPaint; - // Check if the animation hasnt finished yet - if (ts->isResizing && ts->msResizing > tileGetAnimationDuration(s->display)) + // Check if the animation hasnt finished yet + if (ts->isAnimating && ts->msResizing > tileGetAnimationDuration(s->display)) + { + CompWindow *w; + for (w = s->windows; w; w = w->next) { - CompWindow *w = THIS_VIEWPORT(s).firstTiled; - while (w) - { - TILE_WINDOW(w); - if (tw->isResizing) - tw->isResizing = FALSE; - - w = tw->next; - } - ts->isResizing = FALSE; - ts->msResizing = 0; + TILE_WINDOW(w); + tw->animationType = NoAnimation; } - UNWRAP(ts, s, preparePaintScreen); - (*s->preparePaintScreen) (s, msSinceLastPaint); - WRAP(ts, s, preparePaintScreen, tilePreparePaintScreen); + ts->isAnimating = FALSE; + ts->msResizing = 0; + } + + UNWRAP(ts, s, preparePaintScreen); + (*s->preparePaintScreen) (s, msSinceLastPaint); + WRAP(ts, s, preparePaintScreen, tilePreparePaintScreen); } static void tileDonePaintScreen(CompScreen * s) { - TILE_SCREEN(s); + TILE_SCREEN(s); - if (ts->isResizing) - damageScreen(s); + if (ts->isAnimating) + damageScreen(s); - UNWRAP(ts, s, donePaintScreen); - (*s->donePaintScreen) (s); - WRAP(ts, s, donePaintScreen, tileDonePaintScreen); + UNWRAP(ts, s, donePaintScreen); + (*s->donePaintScreen) (s); + WRAP(ts, s, donePaintScreen, tileDonePaintScreen); } static Bool tilePaintScreen(CompScreen * s, - const ScreenPaintAttrib * sa, - const CompTransform * transform, - Region region, int output, unsigned int mask) + const ScreenPaintAttrib * sa, + const CompTransform * transform, + Region region, int output, unsigned int mask) { - Bool status; - CompTransform sTransform = *transform; + Bool status; + CompTransform sTransform = *transform; - TILE_SCREEN(s); + TILE_SCREEN(s); - if (ts->isResizing) - mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK; + if (ts->isAnimating) + mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK; - UNWRAP(ts, s, paintScreen); - status = (*s->paintScreen) (s, sa, transform, region, output, mask); - WRAP(ts, s, paintScreen, tilePaintScreen); + UNWRAP(ts, s, paintScreen); + status = (*s->paintScreen) (s, sa, transform, region, output, mask); + WRAP(ts, s, paintScreen, tilePaintScreen); - // Check if animation is enabled, there is resizing on screen and only outline should be drawn + // Check if animation is enabled, there is resizing on screen and only outline should be drawn - if (ts->isResizing && (tileGetAnimateType(s->display) == AnimateTypeOutline)) - { - transformToScreenSpace(s, output, -DEFAULT_Z_CAMERA, &sTransform); - glPushMatrix(); - glLoadMatrixf(sTransform.m); - - glLineWidth(4.0f); + if (ts->isAnimating && (tileGetAnimateType(s->display) == AnimateTypeOutline)) + { + CompWindow *w; + float animationDuration = tileGetAnimationDuration(s->display); - CompWindow *w = THIS_VIEWPORT(s).firstTiled; - float animationDuration = tileGetAnimationDuration(s->display); + transformToScreenSpace(s, output, -DEFAULT_Z_CAMERA, &sTransform); + glPushMatrix(); + glLoadMatrixf(sTransform.m); - while (w && isTileWindow(w)) - { - TILE_WINDOW(w); + glLineWidth(4.0f); - if (tw->isResizing) - { - // Coordinate = start + speed * elapsedTime - // Coordinate = start + (target - start)/interval * elapsedTime - // Draw outline - - int x = tw->previousX - w->input.left + - (((float)(w->attrib.x - tw->previousX)) * ts->msResizing / animationDuration); - int y = tw->previousY - w->input.top + - (((float)(w->attrib.y - tw->previousY)) * ts->msResizing / animationDuration); - int width = tw->previousWidth + w->input.left + w->input.right + - (((float)(w->attrib.width - tw->previousWidth)) * ts->msResizing / animationDuration); - int height = tw->previousHeight + w->input.top + w->input.bottom + - (((float)(w->attrib.height - tw->previousHeight)) * ts->msResizing / animationDuration); - - glColor3us(tw->outlineColor[0] * 0.66, tw->outlineColor[1] * 0.66, - tw->outlineColor[2]*0.66); - glRecti(x, y + height, x + width, y); - - glColor3usv(tw->outlineColor); - - glBegin(GL_LINE_LOOP); - glVertex3f(x, y, 0.0f); - glVertex3f(x + width, y, 0.0f); - glVertex3f(x + width, y + height, 0.0f); - glVertex3f(x, y + height, 0.0f); - glEnd(); - - glColor4usv(defaultColor); - } - - w = tw->next; - } + for (w = s->windows; w; w = w->next) + { + TILE_WINDOW(w); + + if (tw->animationType == Animating) + { + // Coordinate = start + speed * elapsedTime + // Coordinate = start + (target - start)/interval * elapsedTime + // Draw outline + + int x = tw->prevCoords.x - w->input.left + + (((float)(w->attrib.x - tw->prevCoords.x)) * ts->msResizing / animationDuration); + int y = tw->prevCoords.y - w->input.top + + (((float)(w->attrib.y - tw->prevCoords.y)) * ts->msResizing / animationDuration); + int width = tw->prevCoords.width + w->input.left + w->input.right + + (((float)(w->attrib.width - tw->prevCoords.width)) * ts->msResizing / animationDuration); + int height = tw->prevCoords.height + w->input.top + w->input.bottom + + (((float)(w->attrib.height - tw->prevCoords.height)) * ts->msResizing / animationDuration); + + glColor3us(tw->outlineColor[0] * 0.66, tw->outlineColor[1] * 0.66, + tw->outlineColor[2]*0.66); + glRecti(x, y + height, x + width, y); + + glColor3usv(tw->outlineColor); + + glBegin(GL_LINE_LOOP); + glVertex3f(x, y, 0.0f); + glVertex3f(x + width, y, 0.0f); + glVertex3f(x + width, y + height, 0.0f); + glVertex3f(x, y + height, 0.0f); + glEnd(); - glPopMatrix(); glColor4usv(defaultColor); - glLineWidth(1.0f); + } } - return status; -} - -static Bool tileSetCoreScreenOption(CompScreen *s, char *name, CompOptionValue *value) -{ - TILE_SCREEN(s); - Bool status; - - UNWRAP(ts, s, setScreenOption); - status = (*s->setScreenOption) (s, name, value); - WRAP(ts, s, setScreenOption, tileSetCoreScreenOption); + glPopMatrix(); + glColor4usv(defaultColor); + glLineWidth(1.0f); + } - if (status && ((strcmp(name, "size") == 0) || (strcmp(name, "vsize") == 0))) - { - ts->viewports = realloc(ts->viewports, sizeof(TileViewport) * - (s->hsize * s->vsize)); - } - - return status; + return status; } // Resize notify used when windows are tiled horizontally or vertically static void tileResizeNotify(CompWindow * w, int dx, int dy, int dwidth, int dheight) { - TILE_SCREEN(w->screen); - TILE_WINDOW(w); - - UNWRAP(ts, w->screen, windowResizeNotify); - (*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight); - WRAP(ts, w->screen, windowResizeNotify, tileResizeNotify); - - if (!tw->resizedAlready) - { - tw->resizedAlready = True; // window is resized now - return; - } - - // Dont do anything if joining is disabled or windows are being resized - if (!tileGetTileJoin(w->screen->display) || ts->isResizing) - return; - - switch (THIS_VIEWPORT(w->screen).currentTileType) - { - case TileToggleTypeTile: - if (tw->prev) - placeWindow(tw->prev, - tw->prev->attrib.x, tw->prev->attrib.y, - w->attrib.x - tw->prev->attrib.x - w->input.left - tw->prev->input.right, - tw->prev->height); + TILE_SCREEN(w->screen); + TILE_WINDOW(w); + + UNWRAP(ts, w->screen, windowResizeNotify); + (*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight); + WRAP(ts, w->screen, windowResizeNotify, tileResizeNotify); + + if (!tw->alreadyResized) + { + tw->alreadyResized = TRUE; + return; + } + + // Dont do anything if joining is disabled or windows are being resized + if (!tileGetTileJoin(w->screen->display) || ts->isAnimating) + return; +#if 0 + switch (ts->tileType) + { + case TileToggleTypeTile: + if (tw->prev) + placeWindow(tw->prev, + tw->prev->attrib.x, tw->prev->attrib.y, + w->attrib.x - tw->prev->attrib.x - w->input.left - tw->prev->input.right, + tw->prev->height); if (tw->next) { @@ -504,6 +455,7 @@ static void tileResizeNotify(CompWindow * w, int dx, int dy, int dwidth, int dhe default: break; } +#endif } static Bool tileInitScreen(CompPlugin * p, CompScreen * s) @@ -522,22 +474,16 @@ static Bool tileInitScreen(CompPlugin * p, CompScreen * s) s->privates[td->screenPrivateIndex].ptr = ts; - ts->isResizing = FALSE; + ts->isAnimating = FALSE; ts->msResizing = 0; ts->oneDuration = 0; - ts->viewports = calloc(s->hsize * s->vsize, sizeof(TileViewport)); - int i; - for(i = 0;i < (s->hsize * s->vsize); i++) - ts->viewports[i].currentTileType = TileToggleTypeNum; - // Wrap plugin functions WRAP(ts, s, paintScreen, tilePaintScreen); WRAP(ts, s, preparePaintScreen, tilePreparePaintScreen); WRAP(ts, s, donePaintScreen, tileDonePaintScreen); WRAP(ts, s, windowResizeNotify, tileResizeNotify); WRAP(ts, s, paintWindow, tilePaintWindow); - WRAP(ts, s, setScreenOption, tileSetCoreScreenOption); return TRUE; } @@ -547,7 +493,6 @@ static void tileFiniScreen(CompPlugin * p, CompScreen * s) TILE_SCREEN(s); freeWindowPrivateIndex(s, ts->windowPrivateIndex); - free(ts->viewports); //Restore the original function UNWRAP(ts, s, paintScreen); @@ -555,7 +500,6 @@ static void tileFiniScreen(CompPlugin * p, CompScreen * s) UNWRAP(ts, s, donePaintScreen); UNWRAP(ts, s, windowResizeNotify); UNWRAP(ts, s, paintWindow); - UNWRAP(ts, s, setScreenOption); //Free the pointer free(ts); @@ -606,672 +550,530 @@ static void constrainMinMax(CompWindow * w, int width, int height, int *newWidth // Moves window to [x,y] and resizes to width x height if no animation or starts animation static Bool placeWindow(CompWindow *w, int x, int y, int width, int height) { - // window existence check - if (!w) - return FALSE; - - // this checks if the window isnt smaller than minimum size it has defined - constrainMinMax(w, width, height, &width, &height); - - // check if the window isnt already where its going to be - if (x == w->attrib.x && y == w->attrib.y && width == w->attrib.width && height == w->attrib.height) - return TRUE; - - TILE_WINDOW(w); - TILE_SCREEN(w->screen); - - // set previous coordinates for animation - tw->previousX = w->attrib.x; - tw->previousY = w->attrib.y; - tw->previousWidth = w->attrib.width; - tw->previousHeight = w->attrib.height; - - // set future coordinates for animation - tw->futureX = x; - tw->futureY = y; - tw->futureWidth = width; - tw->futureHeight = height; - - tw->resizedAlready = False; // window is not resized now + // window existence check + if (!w) + return FALSE; - switch (tileGetAnimateType(w->screen->display)) - { - case AnimateTypeNone: - setWindowFutureSize(w); - break; - case AnimateTypeOutline: - case AnimateTypeSlide: - case AnimateTypeZoom: - case AnimateTypeDrop: - setWindowFutureSize(w); - /* fall-through */ - case AnimateTypeFade: - ts->isResizing = TRUE; - tw->isResizing = TRUE; - ts->msResizing = 0; - ts->oneDuration = tileGetAnimationDuration(w->screen->display) / - THIS_VIEWPORT(w->screen).tiledCount; - break; - default: - break; - } + // this checks if the window isnt smaller than minimum size it has defined + constrainMinMax(w, width, height, &width, &height); + // check if the window isnt already where its going to be + if (x == w->attrib.x && y == w->attrib.y && width == w->attrib.width && height == w->attrib.height) return TRUE; + + TILE_WINDOW(w); + TILE_SCREEN(w->screen); + + // set previous coordinates for animation + tw->prevCoords.x = w->attrib.x; + tw->prevCoords.y = w->attrib.y; + tw->prevCoords.width = w->attrib.width; + tw->prevCoords.height = w->attrib.height; + + // set future coordinates for animation + tw->newCoords.x = x; + tw->newCoords.y = y; + tw->newCoords.width = width; + tw->newCoords.height = height; + + tw->alreadyResized = FALSE; // window is not resized now + + switch (tileGetAnimateType(w->screen->display)) + { + case AnimateTypeNone: + tileSetNewWindowSize(w); + break; + case AnimateTypeOutline: + case AnimateTypeSlide: + case AnimateTypeZoom: + case AnimateTypeDrop: + tileSetNewWindowSize(w); + /* fall-through */ + case AnimateTypeFade: + ts->isAnimating = TRUE; + tw->animationType = Animating; + ts->msResizing = 0; + break; + default: + break; + } + + return TRUE; } -static Bool setWindowFutureSize(CompWindow *w) +static Bool tileSetNewWindowSize(CompWindow *w) { TILE_WINDOW(w); TILE_SCREEN(w->screen); XWindowChanges xwc; - xwc.x = tw->futureX; - xwc.y = tw->futureY; - xwc.width = tw->futureWidth; - xwc.height = tw->futureHeight; + xwc.x = tw->newCoords.x; + xwc.y = tw->newCoords.y; + xwc.width = tw->newCoords.width; + xwc.height = tw->newCoords.height; - if (THIS_VIEWPORT(w->screen).currentTileType == TileToggleTypeNum) - maximizeWindow(w, tw->prevState); - else - maximizeWindow(w, 0); - - // FIXME - // restack window where it should be, under next window because maximization/restoration breaks it somehow - if (tw->prevState & MAXIMIZE_STATE && tw->next) - restackWindowBelow(w, tw->next); - - /* TODO */ -#if 0 - // if after restoring the window is maximized, then restore "restore data" :P - if ((w->state & MAXIMIZE_STATE) && THIS_VIEWPORT(w->screen).currentTileType == none) - saveWindowGeometry(w, &xwc, CWX | CWY | CWWidth | CWHeight); + if (ts->tileType == TileToggleTypeNum) + { + if (tw->savedValid) + maximizeWindow(w, tw->savedMaxState); + } else - configureXWindow (w, CWX | CWY | CWWidth | CWHeight, &xwc); -#endif + maximizeWindow(w, 0); + + configureXWindow (w, CWX | CWY | CWWidth | CWHeight, &xwc); + return TRUE; } // Heavily inspired by windowIs3D and isSDWindow, returns TRUE if the window is usable for tiling static Bool isTileWindow(CompWindow * w) { - if (matchEval(tileGetExcludeMatch(w->screen->display), w)) - return FALSE; - - if (w->attrib.override_redirect) - return FALSE; - - if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask)) - return FALSE; - - if (w->state & CompWindowStateSkipPagerMask) - return FALSE; - - // Normal window - if ((w->type & CompWindowTypeNormalMask)==CompWindowTypeNormalMask && !w->minimized && w->placed) - return TRUE; - + if (matchEval(tileGetExcludeMatch(w->screen->display), w)) return FALSE; -} - -// Finds windows on desktop that are to be tiled -static Bool loadTiledWindows(CompScreen *s) -{ - TILE_SCREEN(s); - int count = 0; - CompWindow *first = 0, *previous = 0; - - CompWindow *w; - if (THIS_VIEWPORT(s).currentTileType != TileToggleTypeNum) - for (w = s->windows; w; w = w->next) - { - int x,y; - defaultViewportForWindow(w, &x, &y); - if (isTileWindow(w) && (x == s->x) && (y == s->y)) - { - if (previous) - { - TILE_WINDOW(previous); - tw->next = w; - } - - TILE_WINDOW(w); - if (!first) - first = w; + if (w->attrib.override_redirect) + return FALSE; - tw->prev = previous; - previous = w; - tw->next = 0; - count++; - } - } - else // when reloading windows for restoration, in case window order was changed since last tiling - for (w = s->windows; w; w = w->next) - { - TILE_WINDOW(w); - int x,y; - defaultViewportForWindow(w,&x,&y); - if ((tw->originalWidth || tw->originalHeight) && (x == s->x) && (y == s->y)) - { - if (previous) - { - TILE_WINDOW(previous); - tw->next = w; - } + if (!((*w->screen->focusWindow)(w))) + return FALSE; - if (!first) - first = w; + if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask)) + return FALSE; - tw->prev = previous; - previous = w; - tw->next = 0; - count++; - } - } + if (w->state & CompWindowStateSkipPagerMask) + return FALSE; - THIS_VIEWPORT(s).firstTiled = first; - THIS_VIEWPORT(s).tiledCount = count; + if (w->minimized || !w->placed) + return FALSE; - return TRUE; + return TRUE; } // save window coordinates to use for restore -static Bool saveCoords(CompWindow *w) +static void saveCoords(CompWindow *w) { TILE_WINDOW(w); - // if the window was maximized save "restore data" for later restoring - if (w->state & MAXIMIZE_STATE) - { - if (w->saveMask & CWX) - tw->originalX = w->saveWc.x; - else - tw->originalX = w->serverX; - - if (w->saveMask & CWY) - tw->originalY = w->saveWc.y; - else - tw->originalY = w->serverY; + if (tw->savedValid) + return; - if (w->saveMask & CWWidth) - tw->originalWidth = w->saveWc.width; - else - tw->originalWidth = w->serverWidth; + tw->savedCoords.x = w->serverX; + tw->savedCoords.y = w->serverY; + tw->savedCoords.width = w->serverWidth; + tw->savedCoords.height = w->serverHeight; - if (w->saveMask & CWHeight) - tw->originalHeight = w->saveWc.height; - else - tw->originalHeight = w->serverHeight; - } - else - { - tw->originalX = w->serverX; - tw->originalY = w->serverY; - tw->originalWidth = w->serverWidth; - tw->originalHeight = w->serverHeight; - } + tw->savedMaxState = w->state & MAXIMIZE_STATE; - // save state - tw->prevState = w->state; + tw->savedValid = TRUE; - return TRUE; + return; } // Applies tiling/restoring static Bool applyTiling(CompScreen *s) { - TILE_SCREEN(s); - - if (ts->isResizing) - return FALSE; - - loadTiledWindows(s); - if (THIS_VIEWPORT(s).tiledCount > 1) - { - int i = 0; - XRectangle workArea; - CompWindow *w; - CompWindowExtents border; - - memset(&border, 0, sizeof(CompWindowExtents)); - /* first get the largest border of the windows on this - screen - some of the windows in our list might be - maximized now and not be maximized later, so - their border information may be inaccurate */ - for (w = s->windows; w; w = w->next) - { - if (w->input.left > border.left) - border.left = w->input.left; - if (w->input.right > border.right) - border.right = w->input.right; - if (w->input.top > border.top) - border.top = w->input.top; - if (w->input.bottom > border.bottom) - border.bottom = w->input.bottom; - } - - w = THIS_VIEWPORT(s).firstTiled; - - /* FIXME */ - getWorkareaForOutput(s, s->currentOutputDev, &workArea); - - switch(THIS_VIEWPORT(s).currentTileType) - { - /* - Tile into grid - */ - case TileToggleTypeTile : - { - int countX = ceil(sqrt(THIS_VIEWPORT(s).tiledCount)); - int countY = ceil((float)THIS_VIEWPORT(s).tiledCount / countX); - - int currentX = workArea.x; - int currentY = workArea.y; - - int winWidth = workArea.width / countX; - int winHeight = workArea.height / countY; - - while (w) - { - TILE_WINDOW(w); - if (!tw->originalWidth || !tw->originalHeight) - saveCoords(w); - - placeWindow(w, currentX + border.left, - currentY + border.top, - winWidth - (border.left + border.right), - winHeight - (border.top + border.bottom)); - i++; - - if (!(i % countX)) - { - currentX = workArea.x; - currentY += winHeight; - } - else - currentX += winWidth; - - w = tw->next; - } - } - break; + TILE_SCREEN(s); - /* - Tile left - */ - case TileToggleTypeLeft: - { - int x = 0, y = 0, winWidth = 0, winHeight = 0; - int height = workArea.height / (THIS_VIEWPORT(s).tiledCount - 1); - int occupancy = tileGetTileLeftOccupancy(s->display); + if (ts->isAnimating) + return FALSE; - while (w) - { - TILE_WINDOW(w); - if (!tw->next) // this is the last window in the list - the active/topmost window - { - x = workArea.x; - y = workArea.y; - winWidth = workArea.width * occupancy / 100; - winHeight = workArea.height; - } - else - { - x = workArea.x + (workArea.width * occupancy / 100); - y = workArea.y + (i * height); - winWidth = (workArea.width * (100 - occupancy) / 100); - winHeight = height; - } - if (!tw->originalWidth || !tw->originalHeight) - saveCoords(w); - - placeWindow(w, x + border.left, y + border.top, - winWidth - (border.left + border.right), - winHeight - (border.top + border.bottom)); - i++; - w = tw->next; - } - } - break; + int count = 0; + CompWindow *w; - /* - Tile vertically - */ - case TileToggleTypeVertical: - { - int winWidth = workArea.width / THIS_VIEWPORT(s).tiledCount; - int winHeight = workArea.height; - int y = workArea.y; + for (w = s->windows; w; w = w->next) + { + if (isTileWindow(w)) + count++; + } - while (w) - { - TILE_WINDOW(w); + ts->oneDuration = tileGetAnimationDuration(s->display) / MAX(count, 1); - int x = workArea.x + (winWidth * i); - if (!tw->originalWidth || !tw->originalHeight) - saveCoords(w); + if (count > 1) + { + int i = 0; + XRectangle workArea; + CompWindowExtents border; - placeWindow(w, x + border.left, y + border.top, - winWidth - (border.left + border.right), - winHeight - (border.top + border.bottom)); - i++; - w = tw->next; - } - } - break; - - /* - Tile horizontally - */ - case TileToggleTypeHorizontal: - { - int winWidth = workArea.width; - int winHeight = workArea.height / THIS_VIEWPORT(s).tiledCount; - int x = workArea.x; + memset(&border, 0, sizeof(CompWindowExtents)); + /* first get the largest border of the windows on this + screen - some of the windows in our list might be + maximized now and not be maximized later, so + their border information may be inaccurate */ + for (w = s->windows; w; w = w->next) + { + if (w->input.left > border.left) + border.left = w->input.left; + if (w->input.right > border.right) + border.right = w->input.right; + if (w->input.top > border.top) + border.top = w->input.top; + if (w->input.bottom > border.bottom) + border.bottom = w->input.bottom; + } - while (w) - { - TILE_WINDOW(w); + int countX = 0, countY = 0; + int currentX = 0, currentY = 0; + int winWidth = 0, winHeight = 0; + int x = 0, y = 0; + int height = 0, occupancy = 0, delta = 0; + Bool first = TRUE; - int y = workArea.y + (winHeight * i); - if (!tw->originalWidth || !tw->originalHeight) - saveCoords(w); + workArea = s->workArea; - placeWindow(w, x + border.left, y + border.top, - winWidth - (border.left + border.right), - winHeight - (border.top + border.bottom)); - i++; - w = tw->next; - } - } - break; + switch (ts->tileType) + { + case TileToggleTypeTile: + countX = ceil(sqrt(count)); + countY = ceil((float)count / countX); + currentX = workArea.x; + currentY = workArea.y; + winWidth = workArea.width / countX; + winHeight = workArea.height / countY; + break; + case TileToggleTypeLeft: + height = workArea.height / (count - 1); + occupancy = tileGetTileLeftOccupancy(s->display); + break; + case TileToggleTypeVertical: + winWidth = workArea.width / count; + winHeight = workArea.height; + y = workArea.y; + break; + case TileToggleTypeHorizontal: + winWidth = workArea.width; + winHeight = workArea.height / count; + x = workArea.x; + break; + case TileToggleTypeCascade: + delta = tileGetTileDelta(s->display); + currentX = workArea.x; + currentY = workArea.y; + winHeight = workArea.height - delta * (count - 1); + winWidth = workArea.width - delta * (count - 1); + break; + default: + break; + } - /* - Cascade - */ - case TileToggleTypeCascade: - { - int delta = tileGetTileDelta(s->display); - int currentX = workArea.x; - int currentY = workArea.y; - int winHeight = workArea.height - delta * (THIS_VIEWPORT(s).tiledCount - 1); - int winWidth = workArea.width - delta * (THIS_VIEWPORT(s).tiledCount - 1); + for (w = s->windows; w; w = w->next) + { + if (!isTileWindow(w)) + continue; - while (w) - { - TILE_WINDOW(w); - if (!tw->originalWidth || !tw->originalHeight) - saveCoords(w); - - placeWindow(w, currentX + border.left, - currentY + border.top, - winWidth - (border.left + border.right), - winHeight - (border.top + border.bottom)); - - currentX += delta; - currentY += delta; - w = tw->next; - } - } - break; + TILE_WINDOW(w); - /* - Restore - */ - case TileToggleTypeNum: - { - while (w) - { - TILE_WINDOW(w); + if (!tw->savedValid) + saveCoords(w); - placeWindow(w, tw->originalX, tw->originalY, tw->originalWidth, tw->originalHeight); + switch (ts->tileType) + { + case TileToggleTypeTile: + placeWindow(w, currentX + border.left, + currentY + border.top, + winWidth - (border.left + border.right), + winHeight - (border.top + border.bottom)); + tw->isTiled = TRUE; + break; + case TileToggleTypeLeft: + if (first) + { + x = workArea.x; + y = workArea.y; + winWidth = workArea.width * occupancy / 100; + winHeight = workArea.height; + first = FALSE; + } + else + { + x = workArea.x + (workArea.width * occupancy / 100); + y = workArea.y + (i * height); + winWidth = (workArea.width * (100 - occupancy) / 100); + winHeight = height; + } + + placeWindow(w, x + border.left, y + border.top, + winWidth - (border.left + border.right), + winHeight - (border.top + border.bottom)); + tw->isTiled = TRUE; + break; + case TileToggleTypeVertical: + x = workArea.x + (winWidth * i); + placeWindow(w, x + border.left, y + border.top, + winWidth - (border.left + border.right), + winHeight - (border.top + border.bottom)); + tw->isTiled = TRUE; + break; + case TileToggleTypeHorizontal: + y = workArea.y + (winHeight * i); + placeWindow(w, x + border.left, y + border.top, + winWidth - (border.left + border.right), + winHeight - (border.top + border.bottom)); + tw->isTiled = TRUE; + break; + case TileToggleTypeCascade: + placeWindow(w, currentX + border.left, + currentY + border.top, + winWidth - (border.left + border.right), + winHeight - (border.top + border.bottom)); + tw->isTiled = TRUE; + break; + case TileToggleTypeNum: + if (tw->isTiled) + { + placeWindow(w, tw->savedCoords.x, tw->savedCoords.y, + tw->savedCoords.width, tw->savedCoords.height); + tw->savedValid = FALSE; + tw->isTiled = FALSE; + } + break; + default: + break; + } - tw->originalX = 0; - tw->originalY = 0; - tw->originalWidth = 0; - tw->originalHeight = 0; + i++; + tw->animationNum = i; - w = tw->next; - } - } - break; - } + switch (ts->tileType) + { + case TileToggleTypeTile: + if (!(i % countX)) + { + currentX = workArea.x; + currentY += winHeight; + } + else + currentX += winWidth; + break; + case TileToggleTypeCascade: + currentX += delta; + currentY += delta; + default: + break; + } } + } - return TRUE; + return TRUE; } static Bool tileTile(CompDisplay * d, CompAction * ac, CompActionState state, CompOption * option, int nOption) { - CompScreen *s; - s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); + CompScreen *s; + s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); - if (s) { - TILE_SCREEN(s); - THIS_VIEWPORT(s).currentTileType = TileToggleTypeTile; - applyTiling(s); - } - return FALSE; + if (s) { + TILE_SCREEN(s); + ts->tileType = TileToggleTypeTile; + applyTiling(s); + } + + return FALSE; } static Bool tileVertically(CompDisplay * d, CompAction * ac, CompActionState state,CompOption * option, int nOption) { - CompScreen *s; - s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); + CompScreen *s; + s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); - if (s) { - TILE_SCREEN(s); - THIS_VIEWPORT(s).currentTileType = TileToggleTypeVertical; - applyTiling(s); - } - return FALSE; + if (s) { + TILE_SCREEN(s); + ts->tileType = TileToggleTypeVertical; + applyTiling(s); + } + + return FALSE; } static Bool tileHorizontally(CompDisplay * d, CompAction * ac, CompActionState state, CompOption * option, int nOption) { - CompScreen *s; - s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); + CompScreen *s; + s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); - if (s) { - TILE_SCREEN(s); - THIS_VIEWPORT(s).currentTileType = TileToggleTypeHorizontal; - applyTiling(s); - } - return FALSE; + if (s) { + TILE_SCREEN(s); + ts->tileType = TileToggleTypeHorizontal; + applyTiling(s); + } + + return FALSE; } static Bool tileCascade(CompDisplay * d, CompAction * ac, CompActionState state, CompOption * option, int nOption) { - CompScreen *s; - s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); + CompScreen *s; + s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); - if (s) { - TILE_SCREEN(s); - THIS_VIEWPORT(s).currentTileType = TileToggleTypeCascade; - applyTiling(s); - } - return FALSE; + if (s) { + TILE_SCREEN(s); + ts->tileType = TileToggleTypeCascade; + applyTiling(s); + } + + return FALSE; } static Bool tileRestore(CompDisplay * d, CompAction * ac, CompActionState state, CompOption * option, int nOption) { - CompScreen *s; - s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); + CompScreen *s; + s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); - if (s) { - TILE_SCREEN(s); - if(THIS_VIEWPORT(s).currentTileType != TileToggleTypeNum) - { - THIS_VIEWPORT(s).currentTileType = TileToggleTypeNum; - applyTiling(s); - } - } - return FALSE; + if (s) { + TILE_SCREEN(s); + ts->tileType = TileToggleTypeNum; + applyTiling(s); + } + + return FALSE; } static Bool tileToggle(CompDisplay * d, CompAction * ac, CompActionState state, CompOption * option, int nOption) { - CompScreen *s; - s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); + CompScreen *s; + s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0)); - if (s) { - TILE_SCREEN(s); - if(THIS_VIEWPORT(s).currentTileType != TileToggleTypeNum) - { - THIS_VIEWPORT(s).currentTileType = TileToggleTypeNum; - applyTiling(s); - } - else - { - THIS_VIEWPORT(s).currentTileType = tileGetTileToggleType(d); - applyTiling(s); - } + if (s) { + CompWindow *w; + TILE_SCREEN(s); + + for (w = s->windows; w; w = w->next) + { + TILE_WINDOW(w); + if (tw->isTiled) + break; } - return FALSE; + if (w) + { + ts->tileType = TileToggleTypeNum; + applyTiling(s); + } + else + { + ts->tileType = tileGetTileToggleType(d); + applyTiling(s); + } + } + + return FALSE; } static Bool tileInitDisplay(CompPlugin * p, CompDisplay * d) { - //Generate a tile display - TileDisplay *td = (TileDisplay *) malloc(sizeof(TileDisplay)); - //Allocate a private index - td->screenPrivateIndex = allocateScreenPrivateIndex(d); - - //Check if its valid - if (td->screenPrivateIndex < 0) { - free(td); - return FALSE; - } + //Generate a tile display + TileDisplay *td = (TileDisplay *) malloc(sizeof(TileDisplay)); + //Allocate a private index + td->screenPrivateIndex = allocateScreenPrivateIndex(d); + + //Check if its valid + if (td->screenPrivateIndex < 0) { + free(td); + return FALSE; + } - tileSetTileVerticallyInitiate(d, tileVertically); - tileSetTileHorizontallyInitiate(d, tileHorizontally); - tileSetTileTileInitiate(d, tileTile); - tileSetTileCascadeInitiate(d, tileCascade); - tileSetTileRestoreInitiate(d, tileRestore); - tileSetTileToggleInitiate(d, tileToggle); + tileSetTileVerticallyInitiate(d, tileVertically); + tileSetTileHorizontallyInitiate(d, tileHorizontally); + tileSetTileTileInitiate(d, tileTile); + tileSetTileCascadeInitiate(d, tileCascade); + tileSetTileRestoreInitiate(d, tileRestore); + tileSetTileToggleInitiate(d, tileToggle); - //Record the display - d->privates[displayPrivateIndex].ptr = td; + //Record the display + d->privates[displayPrivateIndex].ptr = td; - return TRUE; + return TRUE; } static void tileFiniDisplay(CompPlugin * p, CompDisplay * d) { - TILE_DISPLAY(d); + TILE_DISPLAY(d); - //Free the private index - freeScreenPrivateIndex(d, td->screenPrivateIndex); - //Free the pointer - free(td); + //Free the private index + freeScreenPrivateIndex(d, td->screenPrivateIndex); + //Free the pointer + free(td); } static Bool tileInitWindow(CompPlugin * p, CompWindow * w) { - TileWindow *tw; + TileWindow *tw; - TILE_SCREEN(w->screen); - - tw = malloc(sizeof(TileWindow)); - if (!tw) - return FALSE; + TILE_SCREEN(w->screen); - tw->next = 0; - tw->prev = 0; + tw = malloc(sizeof(TileWindow)); + if (!tw) + return FALSE; - tw->originalX = 0; - tw->originalY = 0; - tw->originalWidth = 0; - tw->originalHeight = 0; + memset(&tw->newCoords, 0, sizeof(XRectangle)); + memset(&tw->prevCoords, 0, sizeof(XRectangle)); + memset(&tw->savedCoords, 0, sizeof(XRectangle)); - tw->previousX = 0; - tw->previousY = 0; - tw->previousWidth = 0; - tw->previousHeight = 0; - tw->isResizing = FALSE; - tw->prevState = 0; + tw->savedValid = FALSE; + tw->animationType = NoAnimation; + tw->savedMaxState = 0; + tw->isTiled = FALSE; - // random color, from group.c thanks to the author for doing it - tw->outlineColor[0] = rand() % 0xFFFF; - tw->outlineColor[1] = rand() % 0xFFFF; - tw->outlineColor[2] = rand() % 0xFFFF; + // random color, from group.c thanks to the author for doing it + tw->outlineColor[0] = rand() % 0xFFFF; + tw->outlineColor[1] = rand() % 0xFFFF; + tw->outlineColor[2] = rand() % 0xFFFF; - w->privates[ts->windowPrivateIndex].ptr = tw; + w->privates[ts->windowPrivateIndex].ptr = tw; - return TRUE; + return TRUE; } static void tileFiniWindow(CompPlugin * p, CompWindow * w) { - TILE_WINDOW(w); - TILE_SCREEN(w->screen); + TILE_WINDOW(w); - if (tw->originalWidth && tw->originalHeight) - { - // when one window is destroyed, join the linked list - CompWindow *prev = tw->prev; - CompWindow *next = tw->next; - - if (prev) - { - TileWindow *twprev = GET_TILE_WINDOW(prev, GET_TILE_SCREEN (prev->screen, GET_TILE_DISPLAY (prev->screen->display))); - twprev->next = next; - } - else - { - THIS_VIEWPORT(w->screen).firstTiled = next; - } - } - - free(tw); + free(tw); } static Bool tileInit(CompPlugin * p) { - displayPrivateIndex = allocateDisplayPrivateIndex(); + displayPrivateIndex = allocateDisplayPrivateIndex(); - if (displayPrivateIndex < 0) - return FALSE; + if (displayPrivateIndex < 0) + return FALSE; - return TRUE; + return TRUE; } static void tileFini(CompPlugin * p) { - if (displayPrivateIndex >= 0) - freeDisplayPrivateIndex(displayPrivateIndex); + if (displayPrivateIndex >= 0) + freeDisplayPrivateIndex(displayPrivateIndex); } static int tileGetVersion(CompPlugin *p, int version) { - return ABIVERSION; + return ABIVERSION; } CompPluginVTable tileVTable = { - "tile", - N_("Tile"), - N_("Tile windows"), - tileGetVersion, - tileInit, - tileFini, - tileInitDisplay, - tileFiniDisplay, - tileInitScreen, - tileFiniScreen, - tileInitWindow, - tileFiniWindow, - 0, - 0, - 0, /*tileGetScreenOptions */ - 0, /*tileSetScreenOption */ - 0, - 0, - 0, - 0 + "tile", + N_("Tile"), + N_("Tile windows"), + tileGetVersion, + tileInit, + tileFini, + tileInitDisplay, + tileFiniDisplay, + tileInitScreen, + tileFiniScreen, + tileInitWindow, + tileFiniWindow, + 0, + 0, + 0, /*tileGetScreenOptions */ + 0, /*tileSetScreenOption */ + 0, + 0, + 0, + 0 }; CompPluginVTable *getCompPluginInfo(void) { - return &tileVTable; + return &tileVTable; } |