static Bool ringPaintWindow (CompWindow *w, const WindowPaintAttrib *attrib, const CompTransform *transform, Region region, unsigned int mask) { CompScreen *s = w->screen; Bool status; RING_SCREEN (s); if (rs->state != RingStateNone) { WindowPaintAttrib sAttrib = *attrib; Bool scaled = FALSE; RING_WINDOW (w); if (w->mapNum) { if (!w->texture->pixmap && !w->bindFailed) bindWindow (w); } if (rw->adjust || rw->slot) { scaled = rw->adjust || (rw->slot && rs->paintingSwitcher); mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; } else if (rs->state != RingStateIn) { if (ringGetDarkenBack (s)) { /* modify brightness of the other windows */ sAttrib.brightness = sAttrib.brightness / 2; } } UNWRAP (rs, s, paintWindow); status = (*s->paintWindow) (w, &sAttrib, transform, region, mask); WRAP (rs, s, paintWindow, ringPaintWindow); if (scaled && w->texture->pixmap) { FragmentAttrib fragment; CompTransform wTransform = *transform; if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK) return FALSE; initFragmentAttrib (&fragment, &w->lastPaint); if (rw->slot) { fragment.brightness = (float) fragment.brightness * rw->slot->depthBrightness; if (w != rs->selectedWindow) fragment.opacity = (float)fragment.opacity * ringGetInactiveOpacity (s) / 100; } if (w->alpha || fragment.opacity != OPAQUE) mask |= PAINT_WINDOW_TRANSLUCENT_MASK; matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f); matrixScale (&wTransform, rw->scale, rw->scale, 1.0f); matrixTranslate (&wTransform, rw->tx / rw->scale - w->attrib.x, rw->ty / rw->scale - w->attrib.y, 0.0f); glPushMatrix (); glLoadMatrixf (wTransform.m); (*s->drawWindow) (w, &wTransform, &fragment, region, mask | PAINT_WINDOW_TRANSFORMED_MASK); glPopMatrix (); } if (scaled && (rs->state != RingStateIn) && ((ringGetOverlayIcon (s) != OverlayIconNone) || !w->texture->pixmap)) { CompIcon *icon; icon = getWindowIcon (w, MAX_ICON_SIZE, MAX_ICON_SIZE); if (!icon) icon = w->screen->defaultIcon; if (icon && (icon->texture.name || iconToTexture (w->screen, icon))) { REGION iconReg; CompMatrix matrix; float scale; float x, y; int width, height; int scaledWinWidth, scaledWinHeight; RingOverlayIconEnum iconOverlay; scaledWinWidth = w->attrib.width * rw->scale; scaledWinHeight = w->attrib.height * rw->scale; if (!w->texture->pixmap) iconOverlay = OverlayIconBig; else iconOverlay = ringGetOverlayIcon (s); switch (iconOverlay) { case OverlayIconNone: case OverlayIconEmblem: scale = (rw->slot) ? rw->slot->depthScale : 1.0f; scale = MIN ((scale * ICON_SIZE / icon->width), (scale * ICON_SIZE / icon->height)); break; case OverlayIconBig: default: if (w->texture->pixmap) { /* only change opacity if not painting an icon for a minimized window */ sAttrib.opacity /= 3; scale = MIN (((float) scaledWinWidth / icon->width), ((float) scaledWinHeight / icon->height)); } else { scale = 0.8f * ((rw->slot) ? rw->slot->depthScale : 1.0f); scale = MIN ((scale * ringGetThumbWidth (s) / icon->width), (scale * ringGetThumbHeight (s) / icon->height)); } break; } width = icon->width * scale; height = icon->height * scale; switch (iconOverlay) { case OverlayIconNone: case OverlayIconEmblem: x = w->attrib.x + scaledWinWidth - width; y = w->attrib.y + scaledWinHeight - height; break; case OverlayIconBig: default: x = w->attrib.x + scaledWinWidth / 2 - width / 2; y = w->attrib.y + scaledWinHeight / 2 - height / 2; break; } x += rw->tx; y += rw->ty; mask |= PAINT_WINDOW_BLEND_MASK | PAINT_WINDOW_TRANSFORMED_MASK; iconReg.rects = &iconReg.extents; iconReg.numRects = 1; iconReg.extents.x1 = w->attrib.x; iconReg.extents.y1 = w->attrib.y; iconReg.extents.x2 = w->attrib.x + icon->width; iconReg.extents.y2 = w->attrib.y + icon->height; matrix = icon->texture.matrix; matrix.x0 -= (w->attrib.x * icon->texture.matrix.xx); matrix.y0 -= (w->attrib.y * icon->texture.matrix.yy); w->vCount = w->indexCount = 0; (*w->screen->addWindowGeometry) (w, &matrix, 1, &iconReg, &infiniteRegion); if (w->vCount) { FragmentAttrib fragment; CompTransform wTransform = *transform; if (!w->texture->pixmap) sAttrib.opacity = w->paint.opacity; initFragmentAttrib (&fragment, &sAttrib); if (rw->slot) fragment.brightness = (float) fragment.brightness * rw->slot->depthBrightness; matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f); matrixScale (&wTransform, scale, scale, 1.0f); matrixTranslate (&wTransform, (x - w->attrib.x) / scale - w->attrib.x, (y - w->attrib.y) / scale - w->attrib.y, 0.0f); glPushMatrix (); glLoadMatrixf (wTransform.m); (*w->screen->drawWindowTexture) (w, &icon->texture, &fragment, mask); glPopMatrix (); } } } } else { UNWRAP (rs, s, paintWindow); status = (*s->paintWindow) (w, attrib, transform, region, mask); WRAP (rs, s, paintWindow, ringPaintWindow); } return status; }
static Bool minDamageWindowRect (CompWindow *w, Bool initial, BoxPtr rect) { Bool status = FALSE; MIN_SCREEN (w->screen); MIN_WINDOW (w); if (mw->ignoreDamage) return TRUE; if (initial) { if (mw->state == IconicState) { mw->state = NormalState; if (!w->invisible && w->iconGeometrySet && matchEval (&ms->match, w)) { if (!mw->adjust) { mw->adjust = TRUE; ms->moreAdjust = TRUE; mw->tx = w->iconGeometry.x - w->serverX; mw->ty = w->iconGeometry.y - w->serverY; mw->xScale = (float) w->iconGeometry.width / w->width; mw->yScale = (float) w->iconGeometry.height / w->height; addWindowDamage (w); } } } else if (mw->region && mw->shade < w->height) { if (ms->shadeStep && !w->invisible) { XSubtractRegion (w->region, &emptyRegion, mw->region); XOffsetRegion (mw->region, -w->attrib.x, -w->attrib.y); /* bind pixmap here so we have something to unshade with */ if (!w->texture->pixmap && !w->bindFailed) bindWindow (w); ms->moreAdjust = TRUE; } else { mw->shade = MAXSHORT; } } mw->newState = NormalState; } else if (mw->adjust) { damageTransformedWindowRect (w, mw->xScale, mw->yScale, mw->tx, mw->ty, rect); status = TRUE; } UNWRAP (ms, w->screen, damageWindowRect); status |= (*w->screen->damageWindowRect) (w, initial, rect); WRAP (ms, w->screen, damageWindowRect, minDamageWindowRect); return status; }
void Context::makeActive(Util::Window* window) { setActive(true); bindWindow(window); }