static void
fxDodgeProcessSubject (CompWindow *wCur,
		       Region wRegion,
		       Region dodgeRegion,
		       Bool alwaysInclude)
{
    XRectangle rect;
    rect.x = WIN_X(wCur);
    rect.y = WIN_Y(wCur);
    rect.width = WIN_W(wCur);
    rect.height = WIN_H(wCur);
    Region wCurRegion = XCreateRegion();
    if (!wCurRegion)
	return;

    XUnionRectWithRegion(&rect, &emptyRegion, wCurRegion);
    if (!alwaysInclude)
    {
	Region intersectionRegion = XCreateRegion();
	if (intersectionRegion)
	{
	    XIntersectRegion(wRegion, wCurRegion,
			     intersectionRegion);
	    if (!XEmptyRegion(intersectionRegion))
		XUnionRegion(dodgeRegion, wCurRegion, dodgeRegion);
	    XDestroyRegion (intersectionRegion);
	}
    }
    else
	XUnionRegion(dodgeRegion, wCurRegion, dodgeRegion);

    XDestroyRegion (wCurRegion);
}
/* Generates a region containing free space (here the
 * active window counts as free space). The region argument
 * is the start-region (ie: the output dev).
 */
static Region
smartputEmptyRegion (CompWindow *window,
		     Region     region)
{
    CompScreen *s = window->screen;
    CompWindow *w;
    Region     newRegion, tmpRegion;
    XRectangle tmpRect;

    newRegion = XCreateRegion ();
    if (!newRegion)
	return NULL;

    tmpRegion = XCreateRegion ();
    if (!tmpRegion)
    {
	XDestroyRegion (newRegion);
	return NULL;
    }

    XUnionRegion (region, newRegion, newRegion);

    for (w = s->windows; w; w = w->next)
    {
	EMPTY_REGION (tmpRegion);
        if (w->id == window->id)
            continue;

        if (w->invisible || w->hidden || w->minimized)
            continue;

	if (w->wmType & CompWindowTypeDesktopMask)
	    continue;

	if (w->wmType & CompWindowTypeDockMask)
	{
	    if (w->struts)
	    {
		XUnionRectWithRegion (&w->struts->left, tmpRegion, tmpRegion);
		XUnionRectWithRegion (&w->struts->right, tmpRegion, tmpRegion);
		XUnionRectWithRegion (&w->struts->top, tmpRegion, tmpRegion);
		XUnionRectWithRegion (&w->struts->bottom, tmpRegion, tmpRegion);
		XSubtractRegion (newRegion, tmpRegion, newRegion);
	    }
	    continue;
	}

	tmpRect.x = w->serverX - w->input.left;
	tmpRect.y = w->serverY - w->input.top;
	tmpRect.width  = w->serverWidth + w->input.right + w->input.left;
	tmpRect.height = w->serverHeight + w->input.top +
	                 w->input.bottom;
	XUnionRectWithRegion (&tmpRect, tmpRegion, tmpRegion);
	XSubtractRegion (newRegion, tmpRegion, newRegion);
    }

    XDestroyRegion (tmpRegion);

    return newRegion;
}
Beispiel #3
0
void X11Factory::getMonitorInfo( const GenericWindow &rWindow,
                                 int* p_x, int* p_y,
                                 int* p_width, int* p_height ) const
{
    // initialize to default geometry
    *p_x = 0;
    *p_y = 0;
    *p_width = getScreenWidth();
    *p_height = getScreenHeight();

    // Use Xinerama to determine the monitor where the video
    // mostly resides (biggest surface)
    Display *pDisplay = m_pDisplay->getDisplay();
    Window wnd = (Window)rWindow.getOSHandle();
    Window root = DefaultRootWindow( pDisplay );
    Window child_wnd;

    int x, y;
    unsigned int w, h, border, depth;
    XGetGeometry( pDisplay, wnd, &root, &x, &y, &w, &h, &border, &depth );
    XTranslateCoordinates( pDisplay, wnd, root, 0, 0, &x, &y, &child_wnd );

    int num;
    XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num );
    if( info )
    {
        Region reg1 = XCreateRegion();
        XRectangle rect1 = { (short)x, (short)y, (unsigned short)w, (unsigned short)h };
        XUnionRectWithRegion( &rect1, reg1, reg1 );

        unsigned int surface = 0;
        for( int i = 0; i < num; i++ )
        {
            Region reg2 = XCreateRegion();
            XRectangle rect2 = { info[i].x_org, info[i].y_org,
                                 (unsigned short)info[i].width, (unsigned short)info[i].height };
            XUnionRectWithRegion( &rect2, reg2, reg2 );

            Region reg = XCreateRegion();
            XIntersectRegion( reg1, reg2, reg );
            XRectangle rect;
            XClipBox( reg, &rect );
            unsigned int surf = rect.width * rect.height;
            if( surf > surface )
            {
               surface = surf;
               *p_x = info[i].x_org;
               *p_y = info[i].y_org;
               *p_width = info[i].width;
               *p_height = info[i].height;
            }
            XDestroyRegion( reg );
            XDestroyRegion( reg2 );
        }
        XDestroyRegion( reg1 );
        XFree( info );
    }
}
Beispiel #4
0
Bool
XftDrawSetClip (XftDraw	*draw,
		Region	r)
{
    Region			n = 0;

    if (!r && !draw->clip)
	return True;

    if (r)
    {
	n = XCreateRegion ();
	if (n)
	{
	    if (!XUnionRegion (n, r, n))
	    {
		XDestroyRegion (n);
		return False;
	    }
	}
    }
    if (draw->clip)
    {
	XDestroyRegion (draw->clip);
    }
    draw->clip = n;
    if (draw->render_able)
    {
	XRenderPictureAttributes	pa;
        if (n)
	{
	    XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
	}
	else
	{
	    pa.clip_mask = None;
	    XRenderChangePicture (draw->dpy, draw->render.pict,
				  CPClipMask, &pa);
	}
    }
    if (draw->core_set)
    {
	XGCValues   gv;
	
	if (n)
	    XSetRegion (draw->dpy, draw->core.draw_gc, n);
	else
	{
	    gv.clip_mask = None;
	    XChangeGC (draw->dpy, draw->core.draw_gc,
		       GCClipMask, &gv);
	}
    }
    return True;
}
Beispiel #5
0
void X11Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc,
                                int ySrc, int xDest, int yDest, int width,
                                int height )
{
    const X11Graphics& rGraph = (X11Graphics&)rGraphics;

    // check and adapt to source if needed
    if( !checkBoundaries( 0, 0, rGraph.getWidth(), rGraph.getHeight(),
                          xSrc, ySrc, width, height ) )
    {
        msg_Err( getIntf(), "nothing to draw from graphics source" );
        return;
    }

    // check destination
    if( !checkBoundaries( 0, 0, m_width, m_height,
                          xDest, yDest, width, height ) )
    {
        msg_Err( getIntf(), "out of reach destination! pls, debug your skin" );
        return;
    }

    // Source drawable
    Drawable src = rGraph.getDrawable();

    // Create the mask for transparency
    Region voidMask = XCreateRegion();
    XRectangle rect;
    rect.x = xSrc;
    rect.y = ySrc;
    rect.width = width;
    rect.height = height;
    Region clipMask = XCreateRegion();
    XUnionRectWithRegion( &rect, voidMask, clipMask );
    Region mask = XCreateRegion();
    XIntersectRegion( rGraph.getMask(), clipMask, mask );
    XDestroyRegion( clipMask );
    XDestroyRegion( voidMask );
    XOffsetRegion( mask, xDest - xSrc, yDest - ySrc );

    // Copy the pixmap
    XSetRegion( XDISPLAY, m_gc, mask );
    XCopyArea( XDISPLAY, src, m_pixmap, m_gc, xSrc, ySrc, width, height,
               xDest, yDest );

    // Add the source mask to the mask of the graphics
    Region newMask = XCreateRegion();
    XUnionRegion( m_mask, mask, newMask );
    XDestroyRegion( mask );
    XDestroyRegion( m_mask );
    m_mask = newMask;
}
Beispiel #6
0
static void
update_wireframe_window (MetaDisplay         *display,
                         Window               xwindow,
                         const MetaRectangle *rect)
{
  XMoveResizeWindow (display->xdisplay,
                     xwindow,
                     rect->x, rect->y,
                     rect->width, rect->height);

#define OUTLINE_WIDTH 3

  if (rect->width > OUTLINE_WIDTH * 2 &&
      rect->height > OUTLINE_WIDTH * 2)
    {
      XRectangle xrect;
      Region inner_xregion;
      Region outer_xregion;

      inner_xregion = XCreateRegion ();
      outer_xregion = XCreateRegion ();

      xrect.x = 0;
      xrect.y = 0;
      xrect.width = rect->width;
      xrect.height = rect->height;

      XUnionRectWithRegion (&xrect, outer_xregion, outer_xregion);

      xrect.x += OUTLINE_WIDTH;
      xrect.y += OUTLINE_WIDTH;
      xrect.width -= OUTLINE_WIDTH * 2;
      xrect.height -= OUTLINE_WIDTH * 2;

      XUnionRectWithRegion (&xrect, inner_xregion, inner_xregion);

      XSubtractRegion (outer_xregion, inner_xregion, outer_xregion);

      XShapeCombineRegion (display->xdisplay, xwindow,
                           ShapeBounding, 0, 0, outer_xregion, ShapeSet);

      XDestroyRegion (outer_xregion);
      XDestroyRegion (inner_xregion);
    }
  else
    {
      /* Unset the shape */
      XShapeCombineMask (display->xdisplay, xwindow,
                         ShapeBounding, 0, 0, None, ShapeSet);
    }
}
Beispiel #7
0
 virtual bool destroy_detached(XRegion detached) const {
     if ((detached)) {
         XDestroyRegion(detached);
         return true;
     }
     return false;
 }
Beispiel #8
0
// Intersect & push a new clip rectangle:
void Fl_Device::push_clip(int x, int y, int w, int h)
{
    Region r;
    if (w > 0 && h > 0)
    {
        fl_transform(x,y);
        r = XRectangleRegion(x, y, w, h);
        Region current = rstack[rstackptr];
        if (current)
        {
#ifndef _WIN32
            Region temp = XCreateRegion();
            XIntersectRegion(current, r, temp);
            XDestroyRegion(r);
            r = temp;
#else
            CombineRgn(r,r,current,RGN_AND);
#endif
        }
    }                            // make empty clip region:
    else
    {
#ifndef _WIN32
        r = XCreateRegion();
#else
        r = CreateRectRgn(0,0,0,0);
#endif
    }
    if (rstackptr < STACK_MAX) rstack[++rstackptr] = r;
    fl_restore_clip();
}
Beispiel #9
0
// Replace the top of the clip stack:
void fl_clip_region(Region r)
{
    Region oldr = rstack[rstackptr];
    if(oldr) XDestroyRegion(oldr);
    rstack[rstackptr] = r;
    fl_restore_clip();
}
Beispiel #10
0
void
x_gram_expose(Display *dpy,
              Window w,
              x_gram *gram,
              XExposeEvent *event)
{
   static Region region;
   static int partregion;
   XRectangle rect;

   rect.x = (short) event->x;
   rect.y = (short) event->y;
   rect.width = (unsigned short) event->width;
   rect.height = (unsigned short) event->height;

#ifdef MARK_DEBUG
   printf("----- xeventExpose:\nx=%d y=%d w=%d h=%d\n-----",
          event->x,event->y,event->width,event->height);
#endif

   if (! partregion) {
      region=XCreateRegion();
      partregion = 1;
   }

   if (rect.width && rect.height) XUnionRectWithRegion(&rect,region,region);

   if (event->count == 0) {
      x_gram_draw(dpy,w,gram,region);
      partregion = 0;
      XDestroyRegion(region);
   }
}
Beispiel #11
0
void 
XmRedisplayWidget(Widget widget) 
{
    XExposeEvent xev ;
    Region region ;

    xev.type = Expose ;
                 /* is this better than 0 ? shouldn't make much difference
		  unless the expose method is very tricky... */
    xev.serial = LastKnownRequestProcessed(XtDisplay(widget)) ;  
    xev.send_event = False ;
    xev.display = XtDisplay(widget);
    xev.window = XtWindowOfObject(widget);  /* work with gadget too */
    xev.x = 0 ;
    xev.y = 0 ;
    xev.width = widget->core.width ;
    xev.height = widget->core.height ;
    xev.count = 0 ;

    region = XCreateRegion();
    XtAddExposureToRegion((XEvent*)&xev, region);    

    if (widget->core.widget_class->core_class.expose)
	(*(widget->core.widget_class->core_class.expose))
	    (widget, (XEvent*)&xev, region);

    XDestroyRegion(region);
}
Beispiel #12
0
// Destroy region
FXRegion::~FXRegion(){
#ifdef WIN32
  DeleteObject((HRGN)region);
#else
  XDestroyRegion((Region)region);
#endif
  }
Beispiel #13
0
void
finiCore (void)
{
    CompPlugin *p;

    while (core.displays)
	removeDisplay (core.displays);

    if (core.watchPollFds)
	free (core.watchPollFds);

    while ((p = popPlugin ()))
	unloadPlugin (p);

    XDestroyRegion (core.outputRegion);
    XDestroyRegion (core.tmpRegion);
}
Beispiel #14
0
void sClipExclude(const sRect &r)
{
  sVERIFY(ClipIndex != 0);
  Region temp = sRectToRegion(r);
  XSubtractRegion(ClipStack[ClipIndex],temp,ClipStack[ClipIndex]);
  XDestroyRegion(temp);
  sChangedRegions();
}
Beispiel #15
0
void sClipRect(const sRect &r)
{
  sVERIFY(ClipIndex != 0);
  Region temp = sRectToRegion(r);
  XIntersectRegion(ClipStack[ClipIndex],temp,ClipStack[ClipIndex]);
  XDestroyRegion(temp);
  sChangedRegions();
}
Beispiel #16
0
Bool
apc_gp_set_region( Handle self, Handle rgn)
{
	DEFXX;
	Region region;
	PRegionSysData r;

	if ( PObject( self)-> options. optInDrawInfo) return false;
	if ( !XF_IN_PAINT(XX)) return false;

	if (rgn == nilHandle) {
		Rect r;
		r. left   = 0;
		r. bottom = 0;
		r. right  = XX-> size. x - 1;
		r. top	  = XX-> size. y - 1;
		return apc_gp_set_clip_rect( self, r);
	}

	r = GET_REGION(rgn);

	XClipBox( r-> region, &XX-> clip_rect);
	XX-> clip_rect. y += XX-> size. y - r-> height;
	XX-> clip_mask_extent. x = XX-> clip_rect. width;
	XX-> clip_mask_extent. y = XX-> clip_rect. height;
	if ( XX-> clip_rect. width == 0 || XX-> clip_rect. height == 0) {
		Rect r;
		r. left   = -1;
		r. bottom = -1;
		r. right  = -1;
		r. top	  = -1;
		return apc_gp_set_clip_rect( self, r);
	}

	region = XCreateRegion();
	XUnionRegion( region, r-> region, region);
	/* offset region if drawable is buffered */
	XOffsetRegion( region, XX-> btransform. x, XX-> size.y - r-> height - XX-> btransform. y);
	/* otherwise ( and only otherwise ), and if there's a
		X11 clipping, intersect the region with it. X11 clipping
		must not mix with the buffer clipping */
	if (( !XX-> udrawable || XX-> udrawable == XX-> gdrawable) &&
		XX-> paint_region)
		XIntersectRegion( region, XX-> paint_region, region);
	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;
}
Beispiel #17
0
EAPI void
ecore_x_xregion_free(Ecore_X_XRegion *region)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   if (!region)
      return;

   XDestroyRegion((Region)region);
} /* ecore_x_xregion_free */
Beispiel #18
0
Bool
apc_region_destroy( Handle self)
{
	if ( REGION ) {
		XDestroyRegion(REGION);
		REGION = NULL;
	}
	return true;
}
Beispiel #19
0
// Reset region to empty
void FXRegion::reset(){
#ifdef WIN32
  DeleteObject((HRGN)region);
  region=(void*)CreateRectRgn(0,0,0,0);
#else
  XDestroyRegion((Region)region);
  region=XCreateRegion();
#endif
  }
Beispiel #20
0
// pop back to previous clip:
void Fl_Device::pop_clip()
{
    if (rstackptr > 0)
    {
        Region oldr = rstack[rstackptr--];
        if (oldr) XDestroyRegion(oldr);
        fl_restore_clip();
    }
}
XftTextRenderer::~XftTextRenderer()
{
    if (xclip)
	XDestroyRegion(xclip);

    font->release();

    if (owner) 
	owner->rendererDeleted(this);
}
Beispiel #22
0
static void
PaxWidgetDestroy(char * data)
{
    PaxWidget *paxwidget = (PaxWidget *) data;

    Tk_FreeOptions(configSpecs, (char *) paxwidget, paxwidget->display, 0);
    Py_XDECREF(paxwidget->obj);
    XDestroyRegion(paxwidget->exposed_region);
    ckfree((char *) paxwidget);
}
Beispiel #23
0
static void ExitXLib()
{
  if(sGetSystemFlags() & sISF_2D)
  {
    XRenderFreePicture(sXDisplay(),XPict);
    XftDrawDestroy(XDraw);
    
    for(sInt i=0;i<MAX_COLORS;i++)
      XftColorFree(sXDisplay(),sXVisual,sXColMap,&ColorXFT[i]);
    
    for(sInt i=0;i<MAX_CLIPS;i++)
      XDestroyRegion(ClipStack[i]);
    
    XDestroyRegion(EmptyRegion);
    
    for(sInt i=0;i<sMP_MAX;i++)
      XFreeCursor(sXDisplay(),Cursors[i]);
  }
}
Beispiel #24
0
void X11Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc,
                                int ySrc, int xDest, int yDest, int width,
                                int height )
{
    if( width == -1 )
    {
        width = rGraphics.getWidth();
    }
    if( height == -1 )
    {
        height = rGraphics.getHeight();
    }

    // Source drawable
    Drawable src = ((X11Graphics&)rGraphics).getDrawable();

    // Create the mask for transparency
    Region voidMask = XCreateRegion();
    XRectangle rect;
    rect.x = xSrc;
    rect.y = ySrc;
    rect.width = width;
    rect.height = height;
    Region clipMask = XCreateRegion();
    XUnionRectWithRegion( &rect, voidMask, clipMask );
    Region mask = XCreateRegion();
    XIntersectRegion( ((X11Graphics&)rGraphics).getMask(), clipMask, mask );
    XDestroyRegion( clipMask );
    XDestroyRegion( voidMask );
    XOffsetRegion( mask, xDest - xSrc, yDest - ySrc );

    // Copy the pixmap
    XSetRegion( XDISPLAY, m_gc, mask );
    XCopyArea( XDISPLAY, src, m_pixmap, m_gc, xSrc, ySrc, width, height,
               xDest, yDest );

    // Add the source mask to the mask of the graphics
    Region newMask = XCreateRegion();
    XUnionRegion( m_mask, mask, newMask );
    XDestroyRegion( mask );
    XDestroyRegion( m_mask );
    m_mask = newMask;
}
Beispiel #25
0
int _zbar_window_end (zbar_window_t *w)
{
    window_state_t *x = w->state;
    XSetClipMask(w->display, x->gc, None);
    if(x->exposed) {
        XDestroyRegion(x->exposed);
        x->exposed = NULL;
    }
    XFlush(w->display);
    return(0);
}
Beispiel #26
0
// Xor region r with this one
FXRegion& FXRegion::operator^=(const FXRegion& r){
#ifdef WIN32
  CombineRgn((HRGN)region,(HRGN)region,(HRGN)r.region,RGN_XOR);
#else
  Region res=XCreateRegion();
  XXorRegion((Region)region,(Region)r.region,res);
  XDestroyRegion((Region)region);
  region=res;
#endif
  return *this;
  }
Beispiel #27
0
// Substract region r from this one
FXRegion& FXRegion::operator-=(const FXRegion& r){
#ifndef WIN32
  Region res=XCreateRegion();
  XSubtractRegion((Region)region,(Region)r.region,res);
  XDestroyRegion((Region)region);
  region=res;
#else
  CombineRgn((HRGN)region,(HRGN)region,(HRGN)r.region,RGN_DIFF);
#endif
  return *this;
  }
Beispiel #28
0
// Assign region r to this one
FXRegion& FXRegion::operator=(const FXRegion& r){
#ifdef WIN32
  CombineRgn((HRGN)region,(HRGN)r.region,(HRGN)r.region,RGN_COPY);
#else
  if(region!=r.region){
    XDestroyRegion((Region)region);
    region=XCreateRegion();
    XUnionRegion((Region)r.region,(Region)region,(Region)region);
    }
#endif
  return *this;
  }
Beispiel #29
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();
}
Beispiel #30
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;
}