summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaniac <maniac>2007-03-13 10:20:32 +0000
committermaniac <maniac>2007-03-13 10:20:32 +0000
commit2efad6654e9ef3bb2f901362a04ce7a0ea2fe933 (patch)
tree40c472cc06b155a03a08e058955e6b205205509d
parente2a98963bbe51be0b209c6cb2ce81affd7659c8d (diff)
downloadberyl-plugins-unsupported-2efad6654e9ef3bb2f901362a04ce7a0ea2fe933.tar.gz
beryl-plugins-unsupported-2efad6654e9ef3bb2f901362a04ce7a0ea2fe933.tar.bz2
tile plugin: beautification
-rw-r--r--src/tile.c261
1 files changed, 142 insertions, 119 deletions
diff --git a/src/tile.c b/src/tile.c
index e647fc7..aacd9e6 100644
--- a/src/tile.c
+++ b/src/tile.c
@@ -219,14 +219,14 @@ static Bool tilePaintWindow(CompWindow * w, const WindowPaintAttrib * attrib,
TILE_WINDOW(w);
TILE_SCREEN(s);
- if(tw->isResizing)
+ if (tw->isResizing)
{
TILE_DISPLAY(s->display);
WindowPaintAttrib wAttrib = *attrib;
CompTransform wTransform = *transform;
- switch(td->currentAnimationType)
+ switch (td->currentAnimationType)
{
/*
Drop animation
@@ -258,7 +258,7 @@ static Bool tilePaintWindow(CompWindow * w, const WindowPaintAttrib * attrib,
(ts->msResizing - 0.75 * td->animationDuration) /
(0.25 * td->animationDuration);
- if(ts->msResizing > current * ts->oneDuration)
+ if (ts->msResizing > current * ts->oneDuration)
// windows that have animation finished already
{
mask |= PAINT_WINDOW_TRANSFORMED_MASK;
@@ -296,7 +296,7 @@ static Bool tilePaintWindow(CompWindow * w, const WindowPaintAttrib * attrib,
*/
case fade:
// first half of the animation, fade out
- if(ts->msResizing < 0.40f * td->animationDuration)
+ if (ts->msResizing < 0.40f * td->animationDuration)
{
wAttrib.opacity = OPAQUE - OPAQUE *
ts->msResizing / (0.40f * td->animationDuration);
@@ -348,17 +348,17 @@ static void tilePreparePaintScreen(CompScreen * s, int msSinceLastPaint)
current = THIS_VIEWPORT(s).tiledCount;
// add spent time
- if(ts->isResizing)
+ if (ts->isResizing)
ts->msResizing += msSinceLastPaint;
// Check if the animation hasnt finished yet
- if(ts->isResizing && ts->msResizing > td->animationDuration)
+ if (ts->isResizing && ts->msResizing > td->animationDuration)
{
CompWindow *w = THIS_VIEWPORT(s).firstTiled;
- while(w)
+ while (w)
{
TILE_WINDOW(w);
- if(tw->isResizing)
+ if (tw->isResizing)
tw->isResizing = FALSE;
w = tw->next;
@@ -377,7 +377,7 @@ static void tileDonePaintScreen(CompScreen * s)
TILE_SCREEN(s);
// hope this is ok
- if(ts->isResizing)
+ if (ts->isResizing)
damageScreen(s);
UNWRAP(ts, s, donePaintScreen);
@@ -396,7 +396,7 @@ static Bool tilePaintScreen(CompScreen * s,
TILE_SCREEN(s);
TILE_DISPLAY(s->display);
- if(ts->isResizing)
+ if (ts->isResizing)
mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
UNWRAP(ts, s, paintScreen);
@@ -404,7 +404,7 @@ static Bool tilePaintScreen(CompScreen * s,
WRAP(ts, s, paintScreen, tilePaintScreen);
// Check if animation is enabled, there is resizing on screen and only outline should be drawn
- if(!td->opt[TILE_DISPLAY_OPTION_ANIMATE].value.b || !ts->isResizing || td->currentAnimationType != outline)
+ if (!td->opt[TILE_DISPLAY_OPTION_ANIMATE].value.b || !ts->isResizing || td->currentAnimationType != outline)
return status;
transformToScreenSpace(s, output, -DEFAULT_Z_CAMERA, &sTransform);
@@ -414,26 +414,27 @@ static Bool tilePaintScreen(CompScreen * s,
glLineWidth(4.0f);
CompWindow *w = THIS_VIEWPORT(s).firstTiled;
- while(w && isTileWindow(w))
+ while (w && isTileWindow(w))
{
TILE_WINDOW(w);
- if(tw->isResizing)
+ if (tw->isResizing)
{
// Coordinate = start + speed * elapsedTime
// Coordinate = start + (target - start)/interval * elapsedTime
// Draw outline
- int x = ((float)w->attrib.x - (float)tw->previousX)/td->animationDuration * ts->msResizing + tw->previousX;
- x -= w->input.left; // decoration
- int y = ((float)w->attrib.y - (float)tw->previousY)/td->animationDuration * ts->msResizing + tw->previousY;
- y -= w->input.top; // decoration
- int width = ((float)w->attrib.width - (float)tw->previousWidth)/td->animationDuration * ts->msResizing + tw->previousWidth;
- width += w->input.left + w->input.right; // decoration
- int height = ((float)w->attrib.height - (float)tw->previousHeight)/td->animationDuration * ts->msResizing + tw->previousHeight;
- height += w->input.top + w->input.bottom; //decoration
-
- glColor3us(tw->outlineColor[0]*0.66, tw->outlineColor[1]*0.66, tw->outlineColor[2]*0.66);
+ int x = tw->previousX - w->input.left +
+ (((float)(w->attrib.x - tw->previousX)) * ts->msResizing / td->animationDuration);
+ int y = tw->previousY - w->input.top +
+ (((float)(w->attrib.y - tw->previousY)) * ts->msResizing / td->animationDuration);
+ int width = tw->previousWidth + w->input.left + w->input.right +
+ (((float)(w->attrib.width - tw->previousWidth)) * ts->msResizing / td->animationDuration);
+ int height = tw->previousHeight + w->input.top + w->input.bottom +
+ (((float)(w->attrib.height - tw->previousHeight)) * ts->msResizing / td->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);
@@ -444,6 +445,8 @@ static Bool tilePaintScreen(CompScreen * s,
glVertex3f(x + width, y + height, 0.0f);
glVertex3f(x, y + height, 0.0f);
glEnd();
+
+ glColor4usv(defaultColor);
}
w = tw->next;
@@ -486,94 +489,114 @@ static void tileResizeNotify(CompWindow * w, int dx, int dy, int dwidth,
(*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight, preview);
WRAP(ts, w->screen, windowResizeNotify, tileResizeNotify);
- if(!tw->resizedAlready)
+ if (!tw->resizedAlready)
{
tw->resizedAlready = True; // window is resized now
return;
}
// Dont do anything if joining is disabled or windows are being resized
- if(preview || !td->opt[TILE_DISPLAY_OPTION_JOIN].value.b || ts->isResizing)
+ if (preview || !td->opt[TILE_DISPLAY_OPTION_JOIN].value.b || ts->isResizing)
return;
- if(THIS_VIEWPORT(w->screen).currentTileType == vert)
- {
- 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)
- {
- int currentX = w->attrib.x + w->width + w->input.right + tw->next->input.left;
- placeWindow(tw->next, currentX, tw->next->attrib.y, tw->next->width + tw->next->attrib.x - currentX, tw->next->height);
- }
- }
- else if(THIS_VIEWPORT(w->screen).currentTileType == horz)
+ switch (THIS_VIEWPORT(w->screen).currentTileType)
{
- if(tw->prev)
- {
- placeWindow(tw->prev, tw->prev->attrib.x, tw->prev->attrib.y, tw->prev->width, w->attrib.y - tw->prev->attrib.y - w->input.top - tw->prev->input.bottom);
- }
- if(tw->next)
- {
- int currentY = w->attrib.y + w->height + w->input.bottom + tw->next->input.top;
- placeWindow(tw->next, tw->next->attrib.x, currentY, tw->next->width, tw->next->height + tw->next->attrib.y - currentY);
- }
- }
- else if(THIS_VIEWPORT(w->screen).currentTileType == left)
- {
- if(!tw->next && tw->prev && dwidth) // last window - on the left
- {
- CompWindow *temp = THIS_VIEWPORT(w->screen).firstTiled;
- while(temp)
+ case vert:
+ 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)
{
- TILE_WINDOW(temp);
- if(!tw->next)
- break;
+ int currentX = w->attrib.x + w->width + w->input.right + tw->next->input.left;
+ placeWindow(tw->next, currentX, tw->next->attrib.y,
+ tw->next->width + tw->next->attrib.x - currentX, tw->next->height);
+ }
+ break;
- XRectangle workArea;
- screenGetOutputDevWorkArea(w->screen, screenGetCurrentOutputDev(w->screen), &workArea);
+ case horz:
+ if (tw->prev)
+ placeWindow(tw->prev,
+ tw->prev->attrib.x, tw->prev->attrib.y,
+ tw->prev->width,
+ w->attrib.y - tw->prev->attrib.y - w->input.top - tw->prev->input.bottom);
- int currentX = workArea.x + w->serverX + w->serverWidth + w->input.right + temp->input.left;
- placeWindow(temp, currentX, temp->attrib.y, workArea.width - currentX - w->input.right, temp->attrib.height);
- temp = tw->next;
+ if (tw->next)
+ {
+ int currentY = w->attrib.y + w->height + w->input.bottom + tw->next->input.top;
+ placeWindow(tw->next, tw->next->attrib.x, currentY,
+ tw->next->width, tw->next->height + tw->next->attrib.y - currentY);
}
- }
- else if(tw->next) // windows on the right
- {
- XRectangle workArea;
- screenGetOutputDevWorkArea(w->screen, screenGetCurrentOutputDev(w->screen), &workArea);
+ break;
- CompWindow *temp = THIS_VIEWPORT(w->screen).firstTiled;
- while(temp)
+ case left:
+ if (!tw->next && tw->prev && dwidth) // last window - on the left
{
- TILE_WINDOW(temp);
- if(!tw->next) // left window, last window
+ CompWindow *temp = THIS_VIEWPORT(w->screen).firstTiled;
+ while (temp)
{
- placeWindow(temp, workArea.x + temp->input.left, temp->attrib.y, w->serverX - w->input.left - temp->input.left - temp->input.right - workArea.x, temp->attrib.height);
- break;
+ TILE_WINDOW(temp);
+
+ if (!tw->next)
+ break;
+
+ XRectangle workArea;
+ screenGetOutputDevWorkArea(w->screen, screenGetCurrentOutputDev(w->screen), &workArea);
+
+ int currentX = workArea.x + w->serverX + w->serverWidth + w->input.right + temp->input.left;
+
+ placeWindow(temp, currentX, temp->attrib.y,
+ workArea.width - currentX - w->input.right, temp->attrib.height);
+
+ temp = tw->next;
}
+ }
+ else if (tw->next) // windows on the right
+ {
+ XRectangle workArea;
+ screenGetOutputDevWorkArea(w->screen, screenGetCurrentOutputDev(w->screen), &workArea);
- if(w->id != temp->id)
+ CompWindow *temp = THIS_VIEWPORT(w->screen).firstTiled;
+ while (temp)
{
- int x = temp->attrib.x;
- int y = temp->attrib.y;
- int width = temp->attrib.width;
- int height = temp->attrib.height;
-
- TileWindow * otw = GET_TILE_WINDOW(w, ts); // tileWindow from the resized window, tw is from temp
- if(otw->prev && (temp->id == otw->prev->id))
- height = w->serverY - temp->attrib.y - w->input.top - temp->input.bottom;
- else if(otw->next && (temp->id == otw->next->id))
- y = w->serverY + w->serverHeight + w->input.bottom + temp->input.top;
- x = w->serverX;
- width = workArea.width + workArea.x - w->serverX - w->input.right;
-
- placeWindow(temp, x, y, width, height);
+ TILE_WINDOW(temp);
+ if (!tw->next) // left window, last window
+ {
+ placeWindow(temp,
+ workArea.x + temp->input.left, temp->attrib.y,
+ w->serverX - w->input.left - temp->input.left - temp->input.right - workArea.x,
+ temp->attrib.height);
+ break;
+ }
+
+ if (w->id != temp->id)
+ {
+ int x = temp->attrib.x;
+ int y = temp->attrib.y;
+ int width = temp->attrib.width;
+ int height = temp->attrib.height;
+
+ /* tileWindow of the resized window, tw is the tileWindow of temp */
+ TileWindow * otw = GET_TILE_WINDOW(w, ts);
+
+ if (otw->prev && (temp->id == otw->prev->id))
+ height = w->serverY - temp->attrib.y - w->input.top - temp->input.bottom;
+ else if (otw->next && (temp->id == otw->next->id))
+ y = w->serverY + w->serverHeight + w->input.bottom + temp->input.top;
+
+ x = w->serverX;
+ width = workArea.width + workArea.x - w->serverX - w->input.right;
+
+ placeWindow(temp, x, y, width, height);
+ }
+ temp = tw->next;
}
- temp = tw->next;
}
- }
+ break;
+ default:
+ break;
}
}
@@ -765,14 +788,14 @@ static void constrainMinMax(CompWindow * w, int width, int height, int *newWidth
static Bool placeWindow(CompWindow *w, int x, int y, int width, int height)
{
// window existence check
- if(!w)
+ 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)
+ if (x == w->attrib.x && y == w->attrib.y && width == w->attrib.width && height == w->attrib.height)
return TRUE;
TILE_WINDOW(w);
@@ -793,17 +816,17 @@ static Bool placeWindow(CompWindow *w, int x, int y, int width, int height)
tw->resizedAlready = False; // window is not resized now
- if(!td->opt[TILE_DISPLAY_OPTION_ANIMATE].value.b)
+ if (!td->opt[TILE_DISPLAY_OPTION_ANIMATE].value.b)
setWindowFutureSize(w);
else
{
- if(td->currentAnimationType != fade) // for now all animations except fade resize window before animation
+ if (td->currentAnimationType != fade) // for now all animations except fade resize window before animation
{
setWindowFutureSize(w);
}
// set animation
- if(td->opt[TILE_DISPLAY_OPTION_ANIMATE].value.b)
+ if (td->opt[TILE_DISPLAY_OPTION_ANIMATE].value.b)
{
ts->isResizing = TRUE;
tw->isResizing = TRUE;
@@ -888,21 +911,21 @@ static Bool loadTiledWindows(CompScreen *s)
CompWindow *first = 0, *previous = 0;
CompWindow *w;
- if(THIS_VIEWPORT(s).currentTileType != none)
+ if (THIS_VIEWPORT(s).currentTileType != none)
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 (isTileWindow(w) && (x == s->x) && (y == s->y))
{
- if(previous)
+ if (previous)
{
TILE_WINDOW(previous);
tw->next = w;
}
TILE_WINDOW(w);
- if(!first)
+ if (!first)
first = w;
tw->prev = previous;
@@ -917,19 +940,19 @@ static Bool loadTiledWindows(CompScreen *s)
TILE_WINDOW(w);
int x,y;
defaultViewportForWindow(w,&x,&y);
- if((tw->originalWidth || tw->originalHeight) && (x == s->x) && (y == s->y))
+ if ((tw->originalWidth || tw->originalHeight) && (x == s->x) && (y == s->y))
{
// This fixes problem with window closing animation running while restoring window, causing beryl crash
- if(IPCS_GetBool(IPCS_OBJECT(w), tw->isOtherAnimationAtom))
+ if (IPCS_GetBoolD(IPCS_OBJECT(w), tw->isOtherAnimationAtom, FALSE))
continue;
- if(previous)
+ if (previous)
{
TILE_WINDOW(previous);
tw->next = w;
}
- if(!first)
+ if (!first)
first = w;
tw->prev = previous;
@@ -951,7 +974,7 @@ static Bool saveCoords(CompWindow *w)
TILE_WINDOW(w);
// if the window was maximized save "restore data" for later restoring
- if(w->state & MAXIMIZE_STATE)
+ if (w->state & MAXIMIZE_STATE)
{
if (w->saveMask & CWX)
tw->originalX = w->saveWc.x;
@@ -992,11 +1015,11 @@ static Bool applyTiling(CompScreen *s)
{
TILE_SCREEN(s);
TILE_DISPLAY(s->display);
- if(ts->isResizing)
+ if (ts->isResizing)
return FALSE;
loadTiledWindows(s);
- if(THIS_VIEWPORT(s).tiledCount>1)
+ if (THIS_VIEWPORT(s).tiledCount > 1)
{
int i = 0, head;
XRectangle workArea;
@@ -1042,10 +1065,10 @@ static Bool applyTiling(CompScreen *s)
int winWidth = workArea.width / countX;
int winHeight = workArea.height / countY;
- while(w)
+ while (w)
{
TILE_WINDOW(w);
- if(!tw->originalWidth || !tw->originalHeight)
+ if (!tw->originalWidth || !tw->originalHeight)
saveCoords(w);
placeWindow(w, currentX + border.left,
@@ -1076,7 +1099,7 @@ static Bool applyTiling(CompScreen *s)
int height = workArea.height / (THIS_VIEWPORT(s).tiledCount - 1);
int occupancy = td->opt[TILE_DISPLAY_OPTION_LEFT_OCCUPANCY].value.i;
- while(w)
+ while (w)
{
TILE_WINDOW(w);
if (!tw->next) // this is the last window in the list - the active/topmost window
@@ -1093,7 +1116,7 @@ static Bool applyTiling(CompScreen *s)
winWidth = (workArea.width * (100 - occupancy) / 100);
winHeight = height;
}
- if(!tw->originalWidth || !tw->originalHeight)
+ if (!tw->originalWidth || !tw->originalHeight)
saveCoords(w);
placeWindow(w, x + border.left, y + border.top,
@@ -1114,12 +1137,12 @@ static Bool applyTiling(CompScreen *s)
int winHeight = workArea.height;
int y = workArea.y;
- while(w)
+ while (w)
{
TILE_WINDOW(w);
int x = workArea.x + (winWidth * i);
- if(!tw->originalWidth || !tw->originalHeight)
+ if (!tw->originalWidth || !tw->originalHeight)
saveCoords(w);
placeWindow(w, x + border.left, y + border.top,
@@ -1140,12 +1163,12 @@ static Bool applyTiling(CompScreen *s)
int winHeight = workArea.height / THIS_VIEWPORT(s).tiledCount;
int x = workArea.x;
- while(w)
+ while (w)
{
TILE_WINDOW(w);
int y = workArea.y + (winHeight * i);
- if(!tw->originalWidth || !tw->originalHeight)
+ if (!tw->originalWidth || !tw->originalHeight)
saveCoords(w);
placeWindow(w, x + border.left, y + border.top,
@@ -1168,10 +1191,10 @@ static Bool applyTiling(CompScreen *s)
int winHeight = workArea.height - delta * (THIS_VIEWPORT(s).tiledCount - 1);
int winWidth = workArea.width - delta * (THIS_VIEWPORT(s).tiledCount - 1);
- while(w)
+ while (w)
{
TILE_WINDOW(w);
- if(!tw->originalWidth || !tw->originalHeight)
+ if (!tw->originalWidth || !tw->originalHeight)
saveCoords(w);
placeWindow(w, currentX + border.left,
@@ -1191,7 +1214,7 @@ static Bool applyTiling(CompScreen *s)
*/
case none:
{
- while(w)
+ while (w)
{
TILE_WINDOW(w);
@@ -1611,13 +1634,13 @@ static void tileFiniWindow(CompPlugin * p, CompWindow * w)
TILE_WINDOW(w);
TILE_SCREEN(w->screen);
- if(tw->originalWidth > 0 && tw->originalHeight > 0)
+ if (tw->originalWidth && tw->originalHeight)
{
// when one window is destroyed, join the linked list
CompWindow *prev = tw->prev;
CompWindow *next = tw->next;
- if(prev)
+ if (prev)
{
TileWindow *twprev = GET_TILE_WINDOW(prev, GET_TILE_SCREEN (prev->screen, GET_TILE_DISPLAY (prev->screen->display)));
twprev->next = next;