예제 #1
0
inline void X11Graphics::addVSegmentInRegion( Region &rMask, int yStart,
                                              int yEnd, int x )
{
    XRectangle rect;
    rect.x = x;
    rect.y = yStart;
    rect.width = 1;
    rect.height = yEnd - yStart;
    Region newMask = XCreateRegion();
    XUnionRectWithRegion( &rect, rMask, newMask );
    XDestroyRegion( rMask );
    rMask = newMask;
}
예제 #2
0
파일: apc_region.c 프로젝트: dk/Prima
static Bool
rgn_empty(Handle self)
{
	XRectangle xr;
	REGION = XCreateRegion();
	xr. x = 0;
	xr. y = 0;
	xr. width  = 1;
	xr. height = 1;
	XUnionRectWithRegion( &xr, REGION, REGION);
	XXorRegion( REGION, REGION, REGION);
	HEIGHT = 0;
	return true;
}
예제 #3
0
static void
handle_expose_event(PaxWidget * paxwidget, XEvent * event)
{
    XRectangle rect;
    if (paxwidget->exposed_region == None)
	paxwidget->exposed_region = XCreateRegion();
    rect.x = event->xexpose.x;
    rect.y = event->xexpose.y;
    rect.width = event->xexpose.width;
    rect.height = event->xexpose.height;
    XUnionRectWithRegion(&rect, paxwidget->exposed_region,
			 paxwidget->exposed_region);
    PaxWidget_RegisterUpdate(paxwidget);
}
예제 #4
0
파일: job.c 프로젝트: magsilva/xvidcap
//XserverRegion
Region
xvc_get_damage_region ()
{
    //XserverRegion region, dmg_region;
    Region region, dmg_region;
    XVC_AppData *app = xvc_appdata_ptr ();

    pthread_mutex_lock (&(app->damage_regions_mutex));
    //region = XFixesCreateRegion (app->dpy, 0, 0);
    region = XCreateRegion ();
    dmg_region = job->dmg_region;
    job->dmg_region = region;
    pthread_mutex_unlock (&(app->damage_regions_mutex));
    return dmg_region;
}
예제 #5
0
파일: minimize.c 프로젝트: jordigh/fusilli
static Bool
minInitWindow (CompPlugin *p,
               CompWindow *w)
{
	MinWindow *mw;

	MIN_SCREEN (w->screen);

	mw = malloc (sizeof (MinWindow));
	if (!mw)
		return FALSE;

	mw->xScale = mw->yScale = 1.0f;
	mw->tx = mw->ty = 0.0f;
	mw->adjust = FALSE;
	mw->xVelocity = mw->yVelocity = 0.0f;
	mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;

	mw->unmapCnt = 0;

	mw->ignoreDamage = FALSE;

	if (w->state & CompWindowStateHiddenMask)
	{
		if (w->shaded)
		{
			mw->state = mw->newState = NormalState;
			mw->shade = 0;
			mw->region = XCreateRegion ();
		}
		else
		{
			mw->state = mw->newState = minGetWindowState (w);
			mw->shade = MAXSHORT;
			mw->region = NULL;
		}
	}
	else
	{
			mw->state = mw->newState = NormalState;
			mw->shade = MAXSHORT;
			mw->region = NULL;
	}

	w->privates[ms->windowPrivateIndex].ptr = mw;

	return TRUE;
}
예제 #6
0
파일: viewer-x.c 프로젝트: nihed/magnetism
static void
expose (XExposeEvent *xev,
	Region       *update_region)
{
  XRectangle  r;

  if (!*update_region)
    *update_region = XCreateRegion ();

  r.x = xev->x;
  r.y = xev->y;
  r.width = xev->width;
  r.height = xev->height;

  XUnionRectWithRegion (&r, *update_region, *update_region);
}
예제 #7
0
void
x_drawable_rep::set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore) {
  (void) restore;
  outer_round (x1, y1, x2, y2);
  renderer_rep::set_clipping (x1, y1, x2, y2);
  Region region= XCreateRegion ();
  decode (x1, y1);
  decode (x2, y2);
  XRectangle r;
  r.x     = x1;
  r.y     = y2;
  r.width = x2-x1;
  r.height= y1-y2;
  XUnionRectWithRegion (&r, region, region);
  XSetRegion (dpy, gc, region);
  XDestroyRegion (region);
}
예제 #8
0
파일: apc_region.c 프로젝트: dk/Prima
Bool
apc_region_combine( Handle self, Handle other_region, int rgnop)
{
	PRegionSysData r2;
	int d;
	Bool ok = true;

	r2 = GET_REGION(other_region);

	if ( rgnop == rgnopCopy ) {
		if ( REGION ) XDestroyRegion( REGION );
		REGION = XCreateRegion();
		XUnionRegion( REGION, r2->region, REGION);
		HEIGHT = r2-> height;
		return true;
	}

	d = HEIGHT - r2-> height;
	if ( d > 0 )
		XOffsetRegion( r2-> region, 0, d);
	else
		XOffsetRegion( REGION, 0, -d);

	switch (rgnop) {
	case rgnopIntersect:
		XIntersectRegion( REGION, r2->region, REGION);
		break;
	case rgnopUnion:
		XUnionRegion( REGION, r2->region, REGION);
		break;
	case rgnopXor:
		XXorRegion( REGION, r2->region, REGION);
		break;
	case rgnopDiff:
		XSubtractRegion( REGION, r2->region, REGION);
		break;
	default:
		ok = false;
	}
	if ( d > 0 )
		XOffsetRegion( r2-> region, 0, -d);
	else
		HEIGHT = r2-> height;

	return ok;
}
예제 #9
0
파일: x.c 프로젝트: 0359xiaodong/OpenAtlas
int _zbar_window_expose (zbar_window_t *w,
                         int x,
                         int y,
                         int width,
                         int height)
{
    window_state_t *xs = w->state;
    if(!xs->exposed)
        xs->exposed = XCreateRegion();
    XRectangle r;
    r.x = x;
    r.y = y;
    r.width = width;
    r.height = height;
    XUnionRectWithRegion(&r, xs->exposed, xs->exposed);
    return(0);
}
예제 #10
0
파일: x.c 프로젝트: 0359xiaodong/OpenAtlas
int _zbar_window_resize (zbar_window_t *w)
{
    window_state_t *x = w->state;
    if(!x)
        return(0);

    int lbw;
    if(w->height * 8 / 10 <= w->width)
        lbw = w->height / 36;
    else
        lbw = w->width * 5 / 144;
    if(lbw < 1)
        lbw = 1;
    x->logo_scale = lbw;
    if(x->logo_zbars)
        XDestroyRegion(x->logo_zbars);
    x->logo_zbars = XCreateRegion();

    int x0 = w->width / 2;
    int y0 = w->height / 2;
    int by0 = y0 - 54 * lbw / 5;
    int bh = 108 * lbw / 5;

    static const int bx[5] = { -6, -3, -1,  2,  5 };
    static const int bw[5] = {  1,  1,  2,  2,  1 };

    int i;
    for(i = 0; i < 5; i++) {
        XRectangle *bar = &x->logo_bars[i];
        bar->x = x0 + lbw * bx[i];
        bar->y = by0;
        bar->width = lbw * bw[i];
        bar->height = bh;
        XUnionRectWithRegion(bar, x->logo_zbars, x->logo_zbars);
    }

    static const int zx[4] = { -7,  7, -7,  7 };
    static const int zy[4] = { -8, -8,  8,  8 };

    for(i = 0; i < 4; i++) {
        x->logo_z[i].x = x0 + lbw * zx[i];
        x->logo_z[i].y = y0 + lbw * zy[i];
    }
    return(0);
}
예제 #11
0
파일: metacity.c 프로젝트: micove/compiz
static Region
meta_get_right_border_region (const MetaFrameGeometry *fgeom,
			      int		      height)
{
    Region     border_xregion;
    XRectangle xrect;

    border_xregion = XCreateRegion ();

    xrect.x	 = 0;
    xrect.y	 = 0;
    xrect.width  = fgeom->right_width;
    xrect.height = height - fgeom->top_height - fgeom->bottom_height;

    XUnionRectWithRegion (&xrect, border_xregion, border_xregion);

    return border_xregion;
}
예제 #12
0
void QRegion::updateX11Region() const
{
    d->rgn = XCreateRegion();
    if (!d->qt_rgn)
        return;

    int n = d->qt_rgn->numRects;
    const QRect *rect = (n == 1 ? &d->qt_rgn->extents : d->qt_rgn->rects.constData());
    while (n--) {
        XRectangle r;
        r.x = qMax(SHRT_MIN, rect->x());
        r.y = qMax(SHRT_MIN, rect->y());
        r.width = qMin((int)USHRT_MAX, rect->width());
        r.height = qMin((int)USHRT_MAX, rect->height());
        XUnionRectWithRegion(&r, d->rgn, d->rgn);
        ++rect;
    }
}
예제 #13
0
/* lpStruct - pointer to RECT */
DWORD
DrvRegionsCreateRectRegion(LPARAM dwParm1, LPARAM dwParm2, LPVOID lpStruct)
{
	LPRECT lpRect;
	Region region;
	XRectangle xRect;

	if (!(lpRect = (LPRECT)lpStruct))
		return (DWORD)ERROR;
	region = XCreateRegion();
	xRect.x = lpRect->left;
	xRect.y = lpRect->top;
	xRect.width = lpRect->right - lpRect->left;
	xRect.height = lpRect->bottom - lpRect->top;

	XUnionRectWithRegion(&xRect, region, region);
		
	return (DWORD)region;
}
예제 #14
0
파일: opacify.c 프로젝트: jordigh/fusilli
static Bool
opacifyInitScreen (CompPlugin *p,
                   CompScreen *s)
{
	OpacifyScreen *os;

	OPACIFY_DISPLAY (&display);

	os = malloc (sizeof (OpacifyScreen));
	if (!os)
		return FALSE;

	os->windowPrivateIndex = allocateWindowPrivateIndex (s);
	if (os->windowPrivateIndex < 0)
	{
		free (os);
		return FALSE;
	}

	WRAP (os, s, paintWindow, opacifyPaintWindow);

	const BananaValue *
	option_window_match = bananaGetOption (bananaIndex,
	                                       "window_match",
	                                       s->screenNum);

	matchInit (&os->window_match);
	matchAddFromString (&os->window_match, option_window_match->s);
	matchUpdate (&os->window_match);

	s->privates[od->screenPrivateIndex].ptr = os;

	os->intersect = XCreateRegion ();

	os->justMoved = FALSE;

	os->passiveNum = 0;

	os->active = 0;

	return TRUE;
}
예제 #15
0
QRegion::QRegion( const QRect &r, RegionType t )
{
    QRect rr = r.normalize();
    data = new QRegionData;
    CHECK_PTR( data );
    data->is_null = FALSE;
    if ( t == Rectangle ) {			// rectangular region
	data->rgn = XCreateRegion();
	XRectangle xr;
	xr.x = rr.x();
	xr.y = rr.y();
	xr.width  = rr.width();
	xr.height = rr.height();
	XUnionRectWithRegion( &xr, data->rgn, data->rgn );
    } else if ( t == Ellipse ) {		// elliptic region
	QPointArray a;
	a.makeEllipse( rr.x(), rr.y(), rr.width(), rr.height() );
	data->rgn = XPolygonRegion( (XPoint*)a.data(), a.size(), EvenOddRule );
    }
}
예제 #16
0
/* lpStruct - Pointer to RECT */
DWORD
DrvRegionsSetRectRegion(LPARAM dwParm1, LPARAM dwParm2, LPVOID lpStruct)
{
	LPRECT lpRect;
	XRectangle xRect;	
	static Region EmptyRegion;
	
	if (!(lpRect = (LPRECT)lpStruct))
		return (DWORD)ERROR;
	if (EmptyRegion == None)
		EmptyRegion = XCreateRegion();
	xRect.x = lpRect->left;
	xRect.y = lpRect->top;
	xRect.width = lpRect->right - lpRect->left;
	xRect.height = lpRect->bottom - lpRect->top;

	XUnionRectWithRegion(&xRect, EmptyRegion, (Region)dwParm1);

	return (DWORD)SIMPLEREGION;
}
예제 #17
0
static void
PaxWidgetDisplay(ClientData clientData)
{
    PaxWidget *paxwidget = (PaxWidget *) clientData;
    Tk_Window tkwin = paxwidget->tkwin;
    PyObject * region;

    paxwidget->update_pending = 0;
    if (!Tk_IsMapped(tkwin))
	return;

    region = PaxRegion_FromRegion(paxwidget->exposed_region);
    if (!region)
	return;
    paxwidget->exposed_region = XCreateRegion();

    paxWidget_CallMethodArgs(paxwidget->obj, RedrawMethodIdx,
			     Py_BuildValue("(O)", region));
    Py_DECREF(region);
}
예제 #18
0
bool wxRegion::DoXor( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, wxT("invalid region") );

    if (!m_refData)
    {
        m_refData = new wxRegionRefData();
        M_REGIONDATA->m_region = XCreateRegion();
    }
    else
    {
        AllocExclusive();
    }

    XXorRegion( M_REGIONDATA->m_region,
                M_REGIONDATA_OF(region)->m_region,
                M_REGIONDATA->m_region );

    return true;
}
예제 #19
0
// Replace top of stack with top of stack minus this rectangle:
void Fl_Device::clip_out(int x, int y, int w, int h)
{
    if (w <= 0 || h <= 0) return;
    Region current = rstack[rstackptr];
    // current must not be zero, you must push a rectangle first.  I
    // return without doing anything because that makes some old fltk code work:
    if (!current) return;
    fl_transform(x,y);
    Region r = XRectangleRegion(x, y, w, h);
#ifndef _WIN32
    Region temp = XCreateRegion();
    XSubtractRegion(current, r, temp);
    XDestroyRegion(r);
    XDestroyRegion(current);
    rstack[rstackptr] = temp;
#else
    CombineRgn(current,current,r,RGN_DIFF);
    DeleteObject(r);
#endif
    fl_restore_clip();
}
예제 #20
0
void X11Graphics::fillRect( int left, int top, int width, int height,
                            uint32_t color )
{
    // Update the mask with the rectangle area
    Region newMask = XCreateRegion();
    XRectangle rect;
    rect.x = left;
    rect.y = top;
    rect.width = width;
    rect.height = height;
    XUnionRectWithRegion( &rect, m_mask, newMask );
    XDestroyRegion( m_mask );
    m_mask = newMask;

    // Draw the rectangle
    XGCValues gcVal;
    gcVal.foreground = m_rDisplay.getPixelValue( color >> 16, color >> 8, color );
    XChangeGC( XDISPLAY, m_gc, GCForeground,  &gcVal );
    XSetRegion( XDISPLAY, m_gc, m_mask );
    XFillRectangle( XDISPLAY, m_pixmap, m_gc, left, top, width, height );
}
예제 #21
0
파일: apc_region.c 프로젝트: dk/Prima
Bool
apc_gp_set_clip_rect( Handle self, Rect clipRect)
{
	DEFXX;
	Region region;
	XRectangle r;

	if ( !XF_IN_PAINT(XX))
		return false;

	SORT( clipRect. left, clipRect. right);
	SORT( clipRect. bottom, clipRect. top);
	r. x = clipRect. left;
	r. y = REVERT( clipRect. top);
	r. width = clipRect. right - clipRect. left+1;
	r. height = clipRect. top - clipRect. bottom+1;
	XX-> clip_rect = r;
	XX-> clip_mask_extent. x = r. width;
	XX-> clip_mask_extent. y = r. height;
	region = XCreateRegion();
	XUnionRectWithRegion( &r, region, region);
	if ( XX-> paint_region)
		XIntersectRegion( region, XX-> paint_region, region);
	if ( XX-> btransform. x != 0 || XX-> btransform. y != 0) {
		XOffsetRegion( region, XX-> btransform. x, -XX-> btransform. y);
	}
	XSetRegion( DISP, XX-> gc, region);
	if ( XX-> flags. kill_current_region)
		XDestroyRegion( XX-> current_region);
	XX-> flags. kill_current_region = 1;
	XX-> current_region = region;
	XX-> flags. xft_clip = 0;
#ifdef USE_XFT
	if ( XX-> xft_drawable) prima_xft_update_region( self);
#endif
#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
	if ( XX-> argb_picture ) XRenderSetPictureClipRegion(DISP, XX->argb_picture, region);
#endif
	return true;
}
예제 #22
0
파일: job.c 프로젝트: magsilva/xvidcap
/**
 * \brief create a new job
 *
 * Since this does a malloc, the job needs to be freed
 * @return a new Job struct with variables set to 0|NULL where possible
 */
static Job *
job_new ()
{
    job = (Job *) malloc (sizeof (Job));
    if (!job) {
        fprintf (stderr, "malloc failed?!?");
        exit (1);
    }

    job->file = NULL;
    job->flags = 0;
    job->state = 0;
    job->pic_no = 0;
    job->movie_no = 0;

    job->time_per_frame = 0;
    job->snd_device = NULL;

    job->get_colors = (void *(*)(XColor *, int)) NULL;
    job->save = (void (*)(FILE *, XImage *)) NULL;
    job->clean = (void (*)(void)) NULL;
    job->capture = (long (*)(void)) NULL;

    job->target = 0;
    job->targetCodec = 0;
    job->au_targetCodec = 0;
    job->ncolors = 0;

    job->color_table = NULL;
    job->colors = NULL;
    job->c_info = NULL;

    job->dmg_region = XCreateRegion ();

    job->capture_returned_errno = 0;
    job->frame_moved_x = 0;
    job->frame_moved_y = 0;

    return (job);
}
예제 #23
0
CompRegion &
CompRegion::operator= (const CompRegion &c)
{
    priv->box = c.priv->box;
    if (priv->box.rects)
	priv->box.rects = &priv->box.extents;
    if (c.priv->region)
    {
	if (!priv->region)
	    priv->region = XCreateRegion ();
	XUnionRegion (CompRegion ().handle (), c.priv->region, priv->region);
    }
    else
    {
	if (priv->region)
	{
	    XDestroyRegion (priv->region);
	    priv->region = NULL;
	}
    }
    return *this;
}
예제 #24
0
void handleExpose(void (*expose)())
/* this function handles the expose event */
{
/* set rectangle to be exposed area */
   rectangle.x = (short) report.xexpose.x;
   rectangle.y = (short) report.xexpose.y;
   rectangle.width = (unsigned short) report.xexpose.width;
   rectangle.height = (unsigned short) report.xexpose.height;

/* union this rect into a region */
   XUnionRectWithRegion(&rectangle, region, region);

/* if this is the last contiguous expose in a group, set
     the clip region, clear region for next time, and draw.*/
   if (report.xexpose.count == 0)
   {
      XSetRegion(display, drawgc, region);
      XDestroyRegion(region);
      region = XCreateRegion();
      if (expose != NULL) (*expose)();
   }
}
예제 #25
0
bool wxRegion::Xor( const wxRegion& region )
{
#if 0
    if (region.IsNull())
        return FALSE;

    if (!m_refData)
    {
        m_refData = new wxRegionRefData();
        M_REGIONDATA->m_region = XCreateRegion();
    }
    else
    {
        AllocExclusive();
    }

    XXorRegion( M_REGIONDATA->m_region,
                M_REGIONDATA_OF(region)->m_region,
                M_REGIONDATA->m_region );
#endif                
    return TRUE;
}
예제 #26
0
void Thumbnail::redraw()
{
    int borderWidth = Settings::instance()->borderWidth();
    int headerHeight = Resources::instance()->headerMiddle()->height();
    int headerLeftWidth = Resources::instance()->headerLeft()->width();
    int headerRightWidth = Resources::instance()->headerRight()->width();

    int w = _clientScaledWidth;
    int h = _clientScaledHeight;

    bool selected = (!Settings::instance()->disableSelection())
                    && this == _teleWindow->activeThumbnail();
    const XRenderColor *borderColor = selected ?
                                      Resources::instance()->borderActiveColor() :
                                      Resources::instance()->borderColor();

    Picture left = selected ?
                   Resources::instance()->headerLeftSelected()->picture() :
                   Resources::instance()->headerLeft()->picture();
    Picture right = selected ?
                    Resources::instance()->headerRightSelected()->picture() :
                    Resources::instance()->headerRight()->picture();
    Picture middle = selected ?
                     Resources::instance()->headerMiddleSelected()->picture() :
                     Resources::instance()->headerMiddle()->picture();

    XRenderComposite(_dpy, PictOpSrc,
                     left, None, _image->picture(),
                     0, 0,
                     0, 0,
                     _clientOffsetX - borderWidth,
                     _clientOffsetY - headerHeight,
                     headerLeftWidth, headerHeight
                    );

    XRenderComposite(_dpy, PictOpSrc,
                     right, None, _image->picture(),
                     0, 0,
                     0, 0,
                     _clientOffsetX + w + borderWidth - headerRightWidth,
                     _clientOffsetY - headerHeight,
                     headerRightWidth, headerHeight
                    );

    XRenderComposite(_dpy, PictOpSrc,
                     middle, None, _image->picture(),
                     0, 0,
                     0, 0,
                     _clientOffsetX - borderWidth + headerLeftWidth,
                     _clientOffsetY - headerHeight,
                     w + 2 * borderWidth - headerLeftWidth - headerRightWidth,
                     headerHeight
                    );

    // Left border
    XRenderFillRectangle(_dpy, PictOpSrc, _image->picture(), borderColor,
                         _clientOffsetX - borderWidth,
                         _clientOffsetY,
                         borderWidth, h
                        );
    // Right border
    XRenderFillRectangle(_dpy, PictOpSrc, _image->picture(), borderColor,
                         _clientOffsetX + w,
                         _clientOffsetY,
                         borderWidth, h
                        );
    // Bottom border
    XRenderFillRectangle(_dpy, PictOpSrc, _image->picture(), borderColor,
                         _clientOffsetX - borderWidth,
                         _clientOffsetY + h,
                         w + 2*borderWidth, borderWidth
                        );


    // Drawing title text

    XftColor fontColor;
    fontColor.pixel = 0;
    fontColor.color.red     = 0xffff;
    fontColor.color.green   = 0xffff;
    fontColor.color.blue    = 0xffff;
    fontColor.color.alpha   = 0xffff;

    XRectangle rect = {
        _clientOffsetX - borderWidth + Settings::instance()->textLeftMargin(),
        _clientOffsetY - headerHeight,
        _clientScaledWidth + 2*borderWidth - Settings::instance()->textLeftMargin() - Settings::instance()->textRightMargin(),
        headerHeight
    };
    Region clip = XCreateRegion();
    XUnionRectWithRegion(&rect, clip, clip);

    XftDrawSetClip(_xftDraw, clip);

    XftDrawStringUtf8(_xftDraw, &fontColor, _teleWindow->xftFont(),
                      _clientOffsetX - borderWidth + Settings::instance()->textLeftMargin(),
                      _clientOffsetY + Settings::instance()->textYOffset(),
                      (const FcChar8*)_title,
                      strlen(_title)
                     );

    XDestroyRegion(clip);


    drawPreview();
}
예제 #27
0
/* No Parameters */ 
DWORD
DrvRegionsCreateRegion(LPARAM dwParm1, LPARAM dwParm2, LPVOID lpStruct)
{
	return (DWORD)XCreateRegion();
}
예제 #28
0
/*
 *     polytoregion
 *
 *     Scan converts a polygon by returning a run-length
 *     encoding of the resultant bitmap -- the run-length
 *     encoding is in the form of an array of rectangles.
 */
Region
XPolygonRegion(
    XPoint     *Pts,		     /* the pts                 */
    int       Count,                 /* number of pts           */
    int	rule)			     /* winding rule */
{
    Region region;
    register EdgeTableEntry *pAET;   /* Active Edge Table       */
    register int y;                  /* current scanline        */
    register int iPts = 0;           /* number of pts in buffer */
    register EdgeTableEntry *pWETE;  /* Winding Edge Table Entry*/
    register ScanLineList *pSLL;     /* current scanLineList    */
    register XPoint *pts;             /* output buffer           */
    EdgeTableEntry *pPrevAET;        /* ptr to previous AET     */
    EdgeTable ET;                    /* header node for ET      */
    EdgeTableEntry AET;              /* header node for AET     */
    EdgeTableEntry *pETEs;           /* EdgeTableEntries pool   */
    ScanLineListBlock SLLBlock;      /* header for scanlinelist */
    int fixWAET = FALSE;
    POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers    */
    POINTBLOCK *tmpPtBlock;
    int numFullPtBlocks = 0;

    if (! (region = XCreateRegion())) return (Region) NULL;

    /* special case a rectangle */
    pts = Pts;
    if (((Count == 4) ||
	 ((Count == 5) && (pts[4].x == pts[0].x) && (pts[4].y == pts[0].y))) &&
	(((pts[0].y == pts[1].y) &&
	  (pts[1].x == pts[2].x) &&
	  (pts[2].y == pts[3].y) &&
	  (pts[3].x == pts[0].x)) ||
	 ((pts[0].x == pts[1].x) &&
	  (pts[1].y == pts[2].y) &&
	  (pts[2].x == pts[3].x) &&
	  (pts[3].y == pts[0].y)))) {
	region->extents.x1 = min(pts[0].x, pts[2].x);
	region->extents.y1 = min(pts[0].y, pts[2].y);
	region->extents.x2 = max(pts[0].x, pts[2].x);
	region->extents.y2 = max(pts[0].y, pts[2].y);
	if ((region->extents.x1 != region->extents.x2) &&
	    (region->extents.y1 != region->extents.y2)) {
	    region->numRects = 1;
	    *(region->rects) = region->extents;
	}
	return(region);
    }

    if (Count < 2) return region;

    if (! (pETEs = Xmalloc(sizeof(EdgeTableEntry) * Count))) {
	XDestroyRegion(region);
	return (Region) NULL;
    }

    pts = FirstPtBlock.pts;
    CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
    pSLL = ET.scanlines.next;
    curPtBlock = &FirstPtBlock;

    if (rule == EvenOddRule) {
        /*
         *  for each scanline
         */
        for (y = ET.ymin; y < ET.ymax; y++) {
            /*
             *  Add a new edge to the active edge table when we
             *  get to the next edge.
             */
            if (pSLL != NULL && y == pSLL->scanline) {
                loadAET(&AET, pSLL->edgelist);
                pSLL = pSLL->next;
            }
            pPrevAET = &AET;
            pAET = AET.next;

            /*
             *  for each active edge
             */
            while (pAET) {
                pts->x = pAET->bres.minor_axis,  pts->y = y;
                pts++, iPts++;

                /*
                 *  send out the buffer
                 */
                if (iPts == NUMPTSTOBUFFER) {
                    tmpPtBlock = Xmalloc(sizeof(POINTBLOCK));
                    curPtBlock->next = tmpPtBlock;
                    curPtBlock = tmpPtBlock;
                    pts = curPtBlock->pts;
                    numFullPtBlocks++;
                    iPts = 0;
                }
                EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
            }
            (void) InsertionSort(&AET);
        }
    }
    else {
        /*
         *  for each scanline
         */
        for (y = ET.ymin; y < ET.ymax; y++) {
            /*
             *  Add a new edge to the active edge table when we
             *  get to the next edge.
             */
            if (pSLL != NULL && y == pSLL->scanline) {
                loadAET(&AET, pSLL->edgelist);
                computeWAET(&AET);
                pSLL = pSLL->next;
            }
            pPrevAET = &AET;
            pAET = AET.next;
            pWETE = pAET;

            /*
             *  for each active edge
             */
            while (pAET) {
                /*
                 *  add to the buffer only those edges that
                 *  are in the Winding active edge table.
                 */
                if (pWETE == pAET) {
                    pts->x = pAET->bres.minor_axis,  pts->y = y;
                    pts++, iPts++;

                    /*
                     *  send out the buffer
                     */
                    if (iPts == NUMPTSTOBUFFER) {
                        tmpPtBlock = Xmalloc(sizeof(POINTBLOCK));
                        curPtBlock->next = tmpPtBlock;
                        curPtBlock = tmpPtBlock;
                        pts = curPtBlock->pts;
                        numFullPtBlocks++;    iPts = 0;
                    }
                    pWETE = pWETE->nextWETE;
                }
                EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
            }

            /*
             *  recompute the winding active edge table if
             *  we just resorted or have exited an edge.
             */
            if (InsertionSort(&AET) || fixWAET) {
                computeWAET(&AET);
                fixWAET = FALSE;
            }
        }
    }
    FreeStorage(SLLBlock.next);
    (void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
    for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
	tmpPtBlock = curPtBlock->next;
	Xfree(curPtBlock);
	curPtBlock = tmpPtBlock;
    }
    Xfree(pETEs);
    return(region);
}
예제 #29
0
파일: minimize.c 프로젝트: jordigh/fusilli
static void
minHandleEvent (XEvent      *event)
{
	CompWindow *w;

	MIN_DISPLAY (&display);

	switch (event->type) {
	case MapNotify:
		w = findWindowAtDisplay (event->xmap.window);
		if (w)
		{
			MIN_WINDOW (w);

			if (mw->adjust)
				mw->state = mw->newState;

			if (mw->region)
				w->height = 0;

			mw->ignoreDamage = TRUE;
			while (mw->unmapCnt)
			{
				unmapWindow (w);
				mw->unmapCnt--;
			}
			mw->ignoreDamage = FALSE;
		}
		break;
	case UnmapNotify:
		w = findWindowAtDisplay (event->xunmap.window);
		if (w)
		{
			MIN_SCREEN (w->screen);

			if (w->pendingUnmaps && onCurrentDesktop (w)) /* Normal -> Iconic */
			{
				MIN_WINDOW (w);

				if (w->shaded)
				{
					if (!mw->region)
						mw->region = XCreateRegion ();

					if (mw->region && ms->shadeStep)
					{
						XSubtractRegion (w->region, &emptyRegion, mw->region);
						XOffsetRegion (mw->region, -w->attrib.x,
						           w->attrib.height +
						           w->attrib.border_width * 2 -
						           w->height - w->attrib.y);

						mw->shade = w->height;

						mw->adjust     = FALSE;
						ms->moreAdjust = TRUE;

						mw->unmapCnt++;
						w->unmapRefCnt++;

						addWindowDamage (w);
					}
				}
				else if (!w->invisible && matchEval (&ms->match, w))
				{
					if (w->iconGeometrySet)
					{
						mw->newState = IconicState;

						mw->xScale = w->paint.xScale;
						mw->yScale = w->paint.yScale;
						mw->tx     = w->attrib.x - w->serverX;
						mw->ty     = w->attrib.y - w->serverY;

						if (mw->region)
						{
							XDestroyRegion (mw->region);
							mw->region = NULL;
						}

						mw->shade = MAXSHORT;

						mw->adjust     = TRUE;
						ms->moreAdjust = TRUE;

						mw->unmapCnt++;
						w->unmapRefCnt++;

						addWindowDamage (w);
					}
				}
			}
			else  /* X -> Withdrawn */
			{
				MIN_WINDOW (w);

				if (mw->adjust)
				{
					mw->adjust = FALSE;
					mw->xScale = mw->yScale = 1.0f;
					mw->tx = mw->ty = 0.0f;
					mw->xVelocity = mw->yVelocity = 0.0f;
					mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;
					mw->shade = MAXSHORT;

					if (mw->region)
					{
						XDestroyRegion (mw->region);
						mw->region = NULL;
					}
				}

				mw->state = NormalState;
			}
		}
	default:
		break;
	}

	UNWRAP (md, &display, handleEvent);
	(*display.handleEvent) (event);
	WRAP (md, &display, handleEvent, minHandleEvent);

	switch (event->type) {
	case MapRequest:
		w = findWindowAtDisplay (event->xmaprequest.window);
		if (w && w->hints && w->hints->initial_state == IconicState)
		{
			MIN_WINDOW (w);
			mw->newState = mw->state = IconicState;
		}
		break;
	default:
		break;
	}
}
예제 #30
0
static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
{
	XTransform transform;
	Picture windowPicture;
	Picture primaryPicture;
	XRenderPictureAttributes pa;
	XRenderPictFormat* picFormat;
	double xScalingFactor;
	double yScalingFactor;
	int x2;
	int y2;

	if (xfc->scaledWidth <= 0 || xfc->scaledHeight <= 0)
	{
		WLog_ERR(TAG, "the current window dimensions are invalid");
		return;
	}

	if (xfc->sessionWidth <= 0 || xfc->sessionHeight <= 0)
	{
		WLog_ERR(TAG, "the window dimensions are invalid");
		return;
	}

	xScalingFactor = xfc->sessionWidth / (double)xfc->scaledWidth;
	yScalingFactor = xfc->sessionHeight / (double)xfc->scaledHeight;

	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XSetForeground(xfc->display, xfc->gc, 0);

	/* Black out possible space between desktop and window borders */
	{
		XRectangle box1 = { 0, 0, xfc->window->width, xfc->window->height };
		XRectangle box2 = { xfc->offset_x, xfc->offset_y, xfc->scaledWidth, xfc->scaledHeight };
		Region reg1 = XCreateRegion();
		Region reg2 = XCreateRegion();
		XUnionRectWithRegion(&box1, reg1, reg1);
		XUnionRectWithRegion(&box2, reg2, reg2);

		if (XSubtractRegion(reg1, reg2, reg1) && !XEmptyRegion(reg1))
		{
			XSetRegion(xfc->display, xfc->gc, reg1);
			XFillRectangle(xfc->display, xfc->window->handle, xfc->gc, 0, 0, xfc->window->width, xfc->window->height);
			XSetClipMask(xfc->display, xfc->gc, None);
		}

		XDestroyRegion(reg1);
		XDestroyRegion(reg2);
	}

	picFormat = XRenderFindVisualFormat(xfc->display, xfc->visual);

	pa.subwindow_mode = IncludeInferiors;
	primaryPicture = XRenderCreatePicture(xfc->display, xfc->primary, picFormat, CPSubwindowMode, &pa);
	windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle, picFormat, CPSubwindowMode, &pa);

	XRenderSetPictureFilter(xfc->display, primaryPicture, FilterBilinear, 0, 0);

	transform.matrix[0][0] = XDoubleToFixed(xScalingFactor);
	transform.matrix[0][1] = XDoubleToFixed(0.0);
	transform.matrix[0][2] = XDoubleToFixed(0.0);
	transform.matrix[1][0] = XDoubleToFixed(0.0);
	transform.matrix[1][1] = XDoubleToFixed(yScalingFactor);
	transform.matrix[1][2] = XDoubleToFixed(0.0);
	transform.matrix[2][0] = XDoubleToFixed(0.0);
	transform.matrix[2][1] = XDoubleToFixed(0.0);
	transform.matrix[2][2] = XDoubleToFixed(1.0);

	/* calculate and fix up scaled coordinates */
	x2 = x + w;
	y2 = y + h;
	x = floor(x / xScalingFactor) - 1;
	y = floor(y / yScalingFactor) - 1;
	w = ceil(x2 / xScalingFactor) + 1 - x;
	h = ceil(y2 / yScalingFactor) + 1 - y;

	XRenderSetPictureTransform(xfc->display, primaryPicture, &transform);
	XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x, y, 0, 0, xfc->offset_x + x, xfc->offset_y + y, w, h);
	XRenderFreePicture(xfc->display, primaryPicture);
	XRenderFreePicture(xfc->display, windowPicture);
}