Ejemplo n.º 1
0
bool
ShowrepaintScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
				  const GLMatrix            &transform,
				  const CompRegion          &region,
				  CompOutput                *output,
				  unsigned int               mask)
{
    bool           status;
    GLMatrix       sTransform; // initially identity matrix
    unsigned short color[4];

    status = gScreen->glPaintOutput (attrib, transform, region, output, mask);

    tmpRegion = region.intersected (*output);

    if (tmpRegion.isEmpty ())
	return status;

    sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);

    color[3] = optionGetIntensity () * 0xffff / 100;
    color[0] = (rand () & 7) * color[3] / 8;
    color[1] = (rand () & 7) * color[3] / 8;
    color[2] = (rand () & 7) * color[3] / 8;

    glColor4usv (color);
    glPushMatrix ();
    glLoadMatrixf (sTransform.getMatrix ());
    glEnable (GL_BLEND);

    glBegin (GL_QUADS);
    foreach (const CompRect &box, tmpRegion.rects ())
    {
	glVertex2i (box.x1 (), box.y1 ());
	glVertex2i (box.x1 (), box.y2 ());
	glVertex2i (box.x2 (), box.y2 ());
	glVertex2i (box.x2 (), box.y1 ());
    }
    glEnd ();

    glDisable (GL_BLEND);
    glPopMatrix();

    glColor4usv (defaultColor);

    return status;
}
Ejemplo n.º 2
0
CompPoint
compiz::wall::movementWindowOnScreen (const CompRect &serverBorderRect,
                                      const CompRegion &screenRegion)
{
    CompRegion sbrRegion (serverBorderRect);

    /* If the window would be partially offscreen
     * after it was moved then we should move it back
     * so that it is completely onscreen, since we moved
     * from mostly offscreen on B to mostly onscreen on A,
     * the user should be able to see their selected window */
    CompRegion inter = sbrRegion.intersected (screenRegion);
    CompRegion rem = sbrRegion - screenRegion;

    int dx = 0;
    int dy = 0;

    const CompRect::vector &rects (rem.rects ());

    for (std::vector <CompRect>::const_iterator it = rects.begin ();
            it != rects.end ();
            ++it)
    {
        const CompRect &r = *it;

        if (r.x1 () >= inter.boundingRect ().x2 ())
            dx -= r.width ();
        else if (r.x2 () <= inter.boundingRect ().x1 ())
            dx += r.width ();

        if (r.y1 () >= inter.boundingRect ().y2 ())
            dy -= r.height ();
        else if (r.y2 () <= inter.boundingRect ().y1 ())
            dy += r.height ();
    }

    return CompPoint (dx, dy);
}
Ejemplo n.º 3
0
bool
ShowrepaintScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
				  const GLMatrix            &transform,
				  const CompRegion          &region,
				  CompOutput                *output,
				  unsigned int               mask)
{
    bool           status;
    GLMatrix       sTransform; // initially identity matrix
    unsigned short color[4];

    status = gScreen->glPaintOutput (attrib, transform, region, output, mask);

    tmpRegion = region.intersected (*output);

    if (tmpRegion.isEmpty ())
	return status;

    sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);

    color[3] = optionGetIntensity () * 0xffff / 100;
    color[0] = (rand () & 7) * color[3] / 8;
    color[1] = (rand () & 7) * color[3] / 8;
    color[2] = (rand () & 7) * color[3] / 8;

    GLboolean glBlendEnabled = glIsEnabled (GL_BLEND);

    if (!glBlendEnabled)
	glEnable (GL_BLEND);

    std::vector<GLfloat> vertices;
    /* for each rectangle, use two triangles to display it */
    foreach (const CompRect &box, tmpRegion.rects ())
    {
	//first triangle
	vertices.push_back (box.x1 ());
	vertices.push_back (box.y1 ());
	vertices.push_back (0.0f);

	vertices.push_back (box.x1 ());
	vertices.push_back (box.y2 ());
	vertices.push_back (0.0f);

	vertices.push_back (box.x2 ());
	vertices.push_back (box.y2 ());
	vertices.push_back (0.0f);

	//second triangle
	vertices.push_back (box.x2 ());
	vertices.push_back (box.y2 ());
	vertices.push_back (0.0f);

	vertices.push_back (box.x2 ());
	vertices.push_back (box.y1 ());
	vertices.push_back (0.0f);

	vertices.push_back (box.x1 ());
	vertices.push_back (box.y1 ());
	vertices.push_back (0.0f);
    }

    GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();

    stream->begin (GL_TRIANGLES);
    stream->color4f ((float)color[0] / 65535.0f, (float)color[1] / 65535.0f, (float)color[2] / 65535.0f, (float)color[3] / 65535.0f);
    stream->addVertices (vertices.size () / 3, &vertices[0]);
    if (stream->end ())
	stream->render (sTransform);

    stream->colorDefault ();

    /* only disable blending if it was disabled before */
    if (!glBlendEnabled)
	glDisable (GL_BLEND);

    return status;
}