Exemplo n.º 1
0
	GC
create_gc(Display* display, Window win, int reverse_video)
{
	GC gc;
	unsigned long valuemask = 0;
	XGCValues values;
	unsigned int line_width = 2;
	int line_style = LineSolid;
	int cap_style = CapButt;
	int join_style = JoinBevel;
	int screen_num = DefaultScreen(display);

	gc = XCreateGC(display, win, valuemask, &values);
	if (gc < 0) {
		fprintf(stderr, "XCreateGC: \n");
	}

	if (reverse_video) {
		XSetForeground(display, gc, WhitePixel(display, screen_num));
		XSetBackground(display, gc, BlackPixel(display, screen_num));
	}
	else {
		XSetForeground(display, gc, BlackPixel(display, screen_num));
		XSetBackground(display, gc, WhitePixel(display, screen_num));
	}

	XSetLineAttributes(display, gc,
			line_width, line_style, cap_style, join_style);

	XSetFillStyle(display, gc, FillSolid);

	return gc;
}
Exemplo n.º 2
0
void xf_gdi_surface_frame_marker(rdpContext* context, SURFACE_FRAME_MARKER* surface_frame_marker)
{
	xfInfo* xfi = ((xfContext*) context)->xfi;

	switch (surface_frame_marker->frameAction)
	{
		case SURFACECMD_FRAMEACTION_BEGIN:
			xfi->frame_begin = TRUE;
			xfi->frame_x1 = 0;
			xfi->frame_y1 = 0;
			xfi->frame_x2 = 0;
			xfi->frame_y2 = 0;
			break;

		case SURFACECMD_FRAMEACTION_END:
			xfi->frame_begin = FALSE;
			if (xfi->frame_x2 > xfi->frame_x1 && xfi->frame_y2 > xfi->frame_y1)
			{
				XSetFunction(xfi->display, xfi->gc, GXcopy);
				XSetFillStyle(xfi->display, xfi->gc, FillSolid);

				XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc,
					xfi->frame_x1, xfi->frame_y1,
					xfi->frame_x2 - xfi->frame_x1, xfi->frame_y2 - xfi->frame_y1,
					xfi->frame_x1, xfi->frame_y1);
				gdi_InvalidateRegion(xfi->hdc, xfi->frame_x1, xfi->frame_y1,
					xfi->frame_x2 - xfi->frame_x1, xfi->frame_y2 - xfi->frame_y1);
			}
			break;
	}
}
Exemplo n.º 3
0
void xdrawgrid(X11Stuff *xstuff)
{
    int i, j;
    double step;
    XPoint xp;
    unsigned long black = BlackPixel(xstuff->disp, xstuff->screennumber);
    unsigned long white = WhitePixel(xstuff->disp, xstuff->screennumber);
    
    XSetForeground(xstuff->disp, xstuff->gc, white);
    XSetFillStyle(xstuff->disp, xstuff->gc, FillSolid);
    XFillRectangle(xstuff->disp, xstuff->bufpixmap, xstuff->gc, 0, 0, xstuff->win_w, xstuff->win_h);
    XSetForeground(xstuff->disp, xstuff->gc, black);
    
    step = (double) (xstuff->win_scale)/10;
    for (i = 0; i < xstuff->win_w/step; i++) {
        for (j = 0; j < xstuff->win_h/step; j++) {
            xp.x = rint(i*step);
            xp.y = xstuff->win_h - rint(j*step);
            XDrawPoint(xstuff->disp, xstuff->bufpixmap,
                xstuff->gc, xp.x, xp.y);
        }
    }
    
    XSetLineAttributes(xstuff->disp, xstuff->gc,
        1, LineSolid, CapButt, JoinMiter);
    XDrawRectangle(xstuff->disp, xstuff->bufpixmap,
        xstuff->gc, 0, 0, xstuff->win_w - 1, xstuff->win_h - 1);
}
Exemplo n.º 4
0
void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
{
	UINT32 color;
	xfContext* xfc = (xfContext*) context;

	xf_lock_x11(xfc, FALSE);

	color = freerdp_convert_gdi_order_color(opaque_rect->color, context->settings->ColorDepth, xfc->format, xfc->palette);
	color = xf_gdi_get_color(xfc, color);

	XSetFunction(xfc->display, xfc->gc, GXcopy);
	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XSetForeground(xfc->display, xfc->gc, color);

	XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
			opaque_rect->nLeftRect, opaque_rect->nTopRect,
			opaque_rect->nWidth, opaque_rect->nHeight);

	if (xfc->drawing == xfc->primary)
	{
		if (!xfc->remote_app)
		{
			XFillRectangle(xfc->display, xfc->drawable, xfc->gc,
					opaque_rect->nLeftRect, opaque_rect->nTopRect,
					opaque_rect->nWidth, opaque_rect->nHeight);
		}

		gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
				opaque_rect->nWidth, opaque_rect->nHeight);
	}

	xf_unlock_x11(xfc, FALSE);
}
Exemplo n.º 5
0
void xf_gdi_opaque_rect(rdpUpdate* update, OPAQUE_RECT_ORDER* opaque_rect)
{
	uint32 color;
	xfInfo* xfi = ((xfContext*) update->context)->xfi;

	color = freerdp_color_convert(opaque_rect->color, xfi->srcBpp, xfi->bpp, xfi->clrconv);

	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);
	XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
			opaque_rect->nLeftRect, opaque_rect->nTopRect,
			opaque_rect->nWidth, opaque_rect->nHeight);

	if (xfi->drawing == xfi->primary)
	{
		if (xfi->remote_app != True)
		{
			XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
				opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight);
		}

		gdi_InvalidateRegion(xfi->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
				opaque_rect->nWidth, opaque_rect->nHeight);
	}
}
Exemplo n.º 6
0
static BOOL xf_gdi_opaque_rect(rdpContext* context,
                               const OPAQUE_RECT_ORDER* opaque_rect)
{
	XColor color;
	xfContext* xfc = (xfContext*) context;
	BOOL ret = TRUE;

	if (!xf_decode_color(xfc, opaque_rect->color, &color))
		return FALSE;

	xf_lock_x11(xfc, FALSE);
	XSetFunction(xfc->display, xfc->gc, GXcopy);
	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XSetForeground(xfc->display, xfc->gc, color.pixel);
	XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
	               opaque_rect->nLeftRect, opaque_rect->nTopRect,
	               opaque_rect->nWidth, opaque_rect->nHeight);

	if (xfc->drawing == xfc->primary)
		ret = gdi_InvalidateRegion(xfc->hdc, opaque_rect->nLeftRect,
		                           opaque_rect->nTopRect,
		                           opaque_rect->nWidth, opaque_rect->nHeight);

	xf_unlock_x11(xfc, FALSE);
	return ret;
}
Exemplo n.º 7
0
static BOOL xf_gdi_multi_opaque_rect(rdpContext* context,
                                     const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
	UINT32 i;
	xfContext* xfc = (xfContext*) context;
	BOOL ret = TRUE;
	XColor color;

	if (!xf_decode_color(xfc, multi_opaque_rect->color, &color))
		return FALSE;

	xf_lock_x11(xfc, FALSE);
	XSetFunction(xfc->display, xfc->gc, GXcopy);
	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XSetForeground(xfc->display, xfc->gc, color.pixel);

	for (i = 0; i < multi_opaque_rect->numRectangles; i++)
	{
		const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i];
		XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
		               rectangle->left, rectangle->top,
		               rectangle->width, rectangle->height);

		if (xfc->drawing == xfc->primary)
		{
			if (!(ret = gdi_InvalidateRegion(xfc->hdc, rectangle->left, rectangle->top,
			                                 rectangle->width, rectangle->height)))
				break;
		}
	}

	xf_unlock_x11(xfc, FALSE);
	return ret;
}
Exemplo n.º 8
0
void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
{
	UINT32 color;
	xfContext* context_ = (xfContext*) context;
	xfInfo* xfi = context_->xfi;

	color = freerdp_color_convert_var(opaque_rect->color, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv);

	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);

	XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
			opaque_rect->nLeftRect, opaque_rect->nTopRect,
			opaque_rect->nWidth, opaque_rect->nHeight);

	if (xfi->drawing == xfi->primary)
	{
		if (xfi->remote_app != TRUE)
		{
			XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
				opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight);
		}

		gdi_InvalidateRegion(xfi->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
				opaque_rect->nWidth, opaque_rect->nHeight);
	}
}
Exemplo n.º 9
0
void xf_hw_desktop_resize(rdpContext *context)
{
	BOOL same;
	rdpSettings *settings;
	xfContext *xfc = (xfContext *) context;
	settings = xfc->instance->settings;
	xf_lock_x11(xfc, TRUE);
	if(!xfc->fullscreen)
	{
		xfc->width = settings->DesktopWidth;
		xfc->height = settings->DesktopHeight;
		if(xfc->window)
			xf_ResizeDesktopWindow(xfc, xfc->window, settings->DesktopWidth, settings->DesktopHeight);
		if(xfc->primary)
		{
			same = (xfc->primary == xfc->drawing) ? TRUE : FALSE;
			XFreePixmap(xfc->display, xfc->primary);
			xfc->primary = XCreatePixmap(xfc->display, xfc->drawable,
										 xfc->width, xfc->height, xfc->depth);
			if(same)
				xfc->drawing = xfc->primary;
		}
	}
	else
	{
		XSetFunction(xfc->display, xfc->gc, GXcopy);
		XSetFillStyle(xfc->display, xfc->gc, FillSolid);
		XSetForeground(xfc->display, xfc->gc, 0);
		XFillRectangle(xfc->display, xfc->drawable, xfc->gc, 0, 0, xfc->width, xfc->height);
	}
	xf_unlock_x11(xfc, TRUE);
}
Exemplo n.º 10
0
void xf_gdi_dstblt(rdpContext* context, DSTBLT_ORDER* dstblt)
{
	xfContext* xfc = (xfContext*) context;

	xf_lock_x11(xfc, FALSE);

	xf_set_rop3(xfc, gdi_rop3_code(dstblt->bRop));

	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XFillRectangle(xfc->display, xfc->drawing, xfc->gc,
			dstblt->nLeftRect, dstblt->nTopRect,
			dstblt->nWidth, dstblt->nHeight);

	if (xfc->drawing == xfc->primary)
	{
		if (!xfc->remote_app)
		{
			XFillRectangle(xfc->display, xfc->drawable, xfc->gc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
		}
		gdi_InvalidateRegion(xfc->hdc, dstblt->nLeftRect, dstblt->nTopRect, dstblt->nWidth, dstblt->nHeight);
	}

	XSetFunction(xfc->display, xfc->gc, GXcopy);

	xf_unlock_x11(xfc, FALSE);
}
Exemplo n.º 11
0
static BOOL xf_gdi_update_screen(xfContext* xfc,
                                 const SURFACE_BITS_COMMAND* cmd,
                                 const BYTE* pSrcData)
{
	BOOL ret;
	XImage* image;

	if (!xfc || !pSrcData)
		return FALSE;

	XSetFunction(xfc->display, xfc->gc, GXcopy);
	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	image = XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
	                     (char*) pSrcData, cmd->width, cmd->height, xfc->scanline_pad, 0);

	if (image)
	{
		XPutImage(xfc->display, xfc->primary, xfc->gc, image, 0, 0,
		          cmd->destLeft, cmd->destTop, cmd->width, cmd->height);
		XFree(image);
		ret = xf_gdi_surface_update_frame(xfc, cmd->destLeft, cmd->destTop, cmd->width,
		                                  cmd->height);
	}

	XSetClipMask(xfc->display, xfc->gc, None);
	return ret;
}
Exemplo n.º 12
0
void xf_gdi_line_to(rdpContext* context, LINE_TO_ORDER* line_to)
{
	Drawable dst;
	uint32 color;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	xf_set_rop2(xfi, line_to->bRop2);
	color = freerdp_color_convert_rgb(line_to->penColor, xfi->srcBpp, 32, xfi->clrconv);

	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);
	GET_DST(xfi, dst);
	XDrawLine(xfi->display, dst, xfi->gc,
			line_to->nXStart, line_to->nYStart, line_to->nXEnd, line_to->nYEnd);
	if (xfi->drawing == xfi->primary)
	{
		int width, height;
		if (!xfi->remote_app && !xfi->skip_bs)
		{
			XDrawLine(xfi->display, xfi->drawable, xfi->gc,
				line_to->nXStart, line_to->nYStart, line_to->nXEnd,
				line_to->nYEnd);
		}
		width = line_to->nXStart - line_to->nXEnd;
		height = line_to->nYStart - line_to->nYEnd;
		if (width < 0)
			width *= (-1);
		if (height < 0)
			height *= (-1);
		gdi_InvalidateRegion(xfi->hdc, line_to->nXStart, line_to->nYStart, width, height);
	}
	XSetFunction(xfi->display, xfi->gc, GXcopy);
}
Exemplo n.º 13
0
void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
	int i;
	UINT32 color;
	DELTA_RECT* rectangle;
	xfContext* context_ = (xfContext*) context;
	xfInfo* xfi = context_->xfi;

	color = freerdp_color_convert_var(multi_opaque_rect->color, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv);

	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);

	for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++)
	{
		rectangle = &multi_opaque_rect->rectangles[i];

		XFillRectangle(xfi->display, xfi->drawing, xfi->gc,
				rectangle->left, rectangle->top,
				rectangle->width, rectangle->height);

		if (xfi->drawing == xfi->primary)
		{
			if (xfi->remote_app != TRUE)
			{
				XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
					rectangle->left, rectangle->top, rectangle->width, rectangle->height);
			}

			gdi_InvalidateRegion(xfi->hdc, rectangle->left, rectangle->top, rectangle->width, rectangle->height);
		}
	}
}
Exemplo n.º 14
0
void xf_gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect)
{
	Drawable dst;
	uint32 color;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	color = freerdp_color_convert_var(opaque_rect->color, xfi->srcBpp, 32, xfi->clrconv);
	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);
	GET_DST(xfi, dst);
	XFillRectangle(xfi->display, dst, xfi->gc,
			opaque_rect->nLeftRect, opaque_rect->nTopRect,
			opaque_rect->nWidth, opaque_rect->nHeight);
	if (xfi->drawing == xfi->primary)
	{
		if (!xfi->remote_app && !xfi->skip_bs)
		{
			XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
					opaque_rect->nLeftRect, opaque_rect->nTopRect,
					opaque_rect->nWidth, opaque_rect->nHeight);
		}
		gdi_InvalidateRegion(xfi->hdc, opaque_rect->nLeftRect, opaque_rect->nTopRect,
				opaque_rect->nWidth, opaque_rect->nHeight);
	}
}
Exemplo n.º 15
0
void xf_gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect)
{
	Drawable dst;
	int i;
	uint32 color;
	DELTA_RECT* rectangle;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	color = freerdp_color_convert_var(multi_opaque_rect->color, xfi->srcBpp, 32, xfi->clrconv);
	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);
	GET_DST(xfi, dst);
	for (i = 1; i < multi_opaque_rect->numRectangles + 1; i++)
	{
		rectangle = &multi_opaque_rect->rectangles[i];
		XFillRectangle(xfi->display, dst, xfi->gc,
				rectangle->left, rectangle->top,
				rectangle->width, rectangle->height);
		if (xfi->drawing == xfi->primary)
		{
			if (!xfi->remote_app && !xfi->skip_bs)
			{
				XFillRectangle(xfi->display, xfi->drawable, xfi->gc,
					rectangle->left, rectangle->top,
					rectangle->width, rectangle->height);
			}
			gdi_InvalidateRegion(xfi->hdc, rectangle->left, rectangle->top,
					rectangle->width, rectangle->height);
		}
	}
}
Exemplo n.º 16
0
int main( int argc, char* argv[] ) {
    // see openwindow.min for the setup code ...
    display = XOpenDisplay("");         
    if (!display) exit (-1);            
    int screen = XDefaultScreen(display);
int w = 300;
int h = 300;
window = XCreateSimpleWindow(display,DefaultRootWindow(display),   
     10, 10, w, h, 2, 
     XBlackPixel(display, screen), XWhitePixel(display, screen));  
XMapRaised(display, window);  
XFlush(display); 
sleep(1);           // let server get set up before sending drawing commands
                    // this is a hack until we get to events
// drawing demo with graphics context here ...
GC gc = XCreateGC(display, window, 0, 0);       // create a graphics context
XSetForeground(display, gc, XBlackPixel(display, screen));
XSetBackground(display, gc, XWhitePixel(display, screen));
XSetFillStyle(display,  gc, FillSolid);
XSetLineAttributes(display, gc, 3,              // 3 is line width
        LineSolid, CapButt, JoinRound);         // other line options
// draw some things
XDrawLine(display, window, gc, 10, 10, w-10, h-10);  
XFillRectangle(display, window, gc, 50, 50, w-(2*50), h-(2*50));
XSetForeground(display, gc, XWhitePixel(display, screen));
XDrawLine(display, window, gc, w-10, 10, 10, h-10); 

XFlush(display);                   
    std::cout << "ENTER2exit"; std::cin.get(); // wait for input
    XCloseDisplay(display);
}
Exemplo n.º 17
0
void
putimage_test(void)
{
  int num_copies = 200;
  int i;
  long totaltime;
  char buf[80];

  num_copies *= X.percent;

  XSetFillStyle(X.dpy,X.miscgc,FillTiled);
  XFillRectangle(X.dpy,X.win,X.miscgc,0,0,400,400);

  X.image = XGetImage(X.dpy,X.win,0,0,200,200,~0,XYPixmap);

  XSync(X.dpy,0);
  timer(StartTimer);
  for (i=0;i<num_copies;++i)
    XPutImage(X.dpy,X.win,X.gc,X.image,0,0,i,i,200,200);
  XSync(X.dpy,0);
  totaltime = timer(EndTimer);

  snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.);
  show_result(buf);
}
Exemplo n.º 18
0
void
copyplane_test(void)
{
  int num_copies = 200;
  int i;
  long totaltime;
  char buf[80];

  if(!X.gcv.plane_mask || (X.gcv.plane_mask & (X.gcv.plane_mask - 1))) {
    show_result("exactly one bit in plane mask must be set for this test");
    return;
  }


  num_copies *= X.percent;

  XSetPlaneMask(X.dpy, X.gc, ~0L);
  XSetFillStyle(X.dpy,X.miscgc,FillTiled);
  XFillRectangle(X.dpy,X.win,X.miscgc,0,0,400,400);

  XSync(X.dpy,0);
  timer(StartTimer);
  for (i=0;i<num_copies;++i)
    XCopyPlane(X.dpy,X.win,X.win,X.gc,i,200-i,
	      200,200,200-i,i,X.gcv.plane_mask);
  XSync(X.dpy,0);
  totaltime = timer(EndTimer);
  XSetPlaneMask(X.dpy, X.gc, X.gcv.plane_mask);

  snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.);
  show_result(buf);
}
Exemplo n.º 19
0
static BOOL xf_gdi_line_to(rdpContext* context, const LINE_TO_ORDER* line_to)
{
	XColor color;
	xfContext* xfc = (xfContext*) context;
	BOOL ret = TRUE;

	if (!xf_decode_color(xfc, line_to->penColor, &color))
		return FALSE;

	xf_lock_x11(xfc, FALSE);
	xf_set_rop2(xfc, line_to->bRop2);
	XSetFillStyle(xfc->display, xfc->gc, FillSolid);
	XSetForeground(xfc->display, xfc->gc, color.pixel);
	XDrawLine(xfc->display, xfc->drawing, xfc->gc,
	          line_to->nXStart, line_to->nYStart, line_to->nXEnd, line_to->nYEnd);

	if (xfc->drawing == xfc->primary)
	{
		int x, y, w, h;
		x = MIN(line_to->nXStart, line_to->nXEnd);
		y = MIN(line_to->nYStart, line_to->nYEnd);
		w = abs(line_to->nXEnd - line_to->nXStart) + 1;
		h = abs(line_to->nYEnd - line_to->nYStart) + 1;
		ret = gdi_InvalidateRegion(xfc->hdc, x, y, w, h);
	}

	XSetFunction(xfc->display, xfc->gc, GXcopy);
	xf_unlock_x11(xfc, FALSE);
	return ret;
}
Exemplo n.º 20
0
static void xf_process_tsmf_redraw_event(xfInfo* xfi, RDP_REDRAW_EVENT* revent)
{
	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XCopyArea(xfi->display, xfi->primary, xfi->window->handle, xfi->gc,
		revent->x, revent->y, revent->width, revent->height, revent->x, revent->y);
}
Exemplo n.º 21
0
Pixmap
XCreateInsensitivePixmap( Display *display, Pixmap pixmap )

{
    static char stipple_data[] =
        {
            0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
            0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
            0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
            0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA
        };
    GC        gc;
    Pixmap    ipixmap, stipple;
    unsigned    width, height, depth;

    Window    window;    /* These return values */
    unsigned    border;    /* from XGetGeometry() */
    int        x, y;    /* are not needed.     */

    ipixmap = 0;

    if ( NULL == display || 0 == pixmap )
        return ipixmap;

    if ( 0 == XGetGeometry( display, pixmap, &window, &x, &y,
                &width, &height, &border, &depth )
       )
        return ipixmap; /* BadDrawable: probably an invalid pixmap */

    /* Get the stipple pixmap to be used to 'gray-out' the argument pixmap.
     */
    stipple = XCreateBitmapFromData( display, pixmap, stipple_data, 16, 16 );
    if ( 0 != stipple )
    {
        gc = XCreateGC( display, pixmap, (XtGCMask)0, NULL );
        if ( NULL != gc )
        {
            /* Create an identical copy of the argument pixmap.
             */
            ipixmap = XCreatePixmap( display, pixmap, width, height, depth );
            if ( 0 != ipixmap )
            {
                /* Copy the argument pixmap into the new pixmap.
                 */
                XCopyArea( display, pixmap, ipixmap,
                        gc, 0, 0, width, height, 0, 0 );

                /* Refill the new pixmap using the stipple algorithm/pixmap.
                 */
                XSetStipple( display, gc, stipple );
                XSetFillStyle( display, gc, FillStippled );
                XFillRectangle( display, ipixmap, gc, 0, 0, width, height );
            }
            XFreeGC( display, gc );
        }
        XFreePixmap( display, stipple );
    }
    return ipixmap;
}
Exemplo n.º 22
0
void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
{
	int i, npoints;
	XPoint* points;
	UINT32 brush_color;
	xfContext* xfc = (xfContext*) context;

	xf_lock_x11(xfc, FALSE);

	xf_set_rop2(xfc, polygon_sc->bRop2);
	brush_color = freerdp_convert_gdi_order_color(polygon_sc->brushColor, context->settings->ColorDepth, xfc->format, xfc->palette);
	brush_color = xf_gdi_get_color(xfc, brush_color);

	npoints = polygon_sc->numPoints + 1;
	points = malloc(sizeof(XPoint) * npoints);

	points[0].x = polygon_sc->xStart;
	points[0].y = polygon_sc->yStart;

	for (i = 0; i < polygon_sc->numPoints; i++)
	{
		points[i + 1].x = polygon_sc->points[i].x;
		points[i + 1].y = polygon_sc->points[i].y;
	}

	switch (polygon_sc->fillMode)
	{
		case 1: /* alternate */
			XSetFillRule(xfc->display, xfc->gc, EvenOddRule);
			break;

		case 2: /* winding */
			XSetFillRule(xfc->display, xfc->gc, WindingRule);
			break;

		default:
			WLog_ERR(TAG,  "PolygonSC unknown fillMode: %d", polygon_sc->fillMode);
			break;
	}

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

	XFillPolygon(xfc->display, xfc->drawing, xfc->gc,
			points, npoints, Complex, CoordModePrevious);

	if (xfc->drawing == xfc->primary)
	{
		XFillPolygon(xfc->display, xfc->drawable, xfc->gc,
				points, npoints, Complex, CoordModePrevious);
	}

	XSetFunction(xfc->display, xfc->gc, GXcopy);
	free(points);

	xf_unlock_x11(xfc, FALSE);
}
Exemplo n.º 23
0
void
createGC(Display *d, Window *w, int screen, int lineWidth, GC *gc, const char *str, XColor *color) {
    *gc = XCreateGC(d, *w, 0, 0);
    XParseColor(d, DefaultColormap(d, screen), str, color);
    XAllocColor(d, DefaultColormap(d, screen), color);
    XSetForeground(d, *gc, color->pixel);
    XSetLineAttributes(d, *gc, lineWidth, LineSolid, CapRound, JoinRound);
    XSetFillStyle(d, *gc, FillSolid);
    return;
}
Exemplo n.º 24
0
void clearWindowSnow(int winid,bool newrsrc)
{
	if(newrsrc==true)
		{
			if(windowSnow[winid].lasty!=NULL)
				free(windowSnow[winid].lasty);
			if(windowSnow[winid].pixmap!=0)
				XFreePixmap(display,windowSnow[winid].pixmap);
			if(windowSnow[winid].mask!=0)
				XFreePixmap(display,windowSnow[winid].mask);
			if(windowSnow[winid].maskgc!=0)
				XFreeGC(display,windowSnow[winid].maskgc);

			windowSnow[winid].pixmap=XCreatePixmap(display,drawOnThis,windowSnow[winid].width,windowSnow[winid].maxHeight,depth);
			windowSnow[winid].mask=XCreatePixmap(display,drawOnThis,windowSnow[winid].width,windowSnow[winid].maxHeight,1);
			windowSnow[winid].maskgc=XCreateGC(display,windowSnow[winid].mask,0,NULL);

			windowSnow[winid].lasty=(int*)malloc(sizeof(int)*windowSnow[winid].width);
		}

	for(int j=0; j<windowSnow[winid].width; j++)
		windowSnow[winid].lasty[j]=windowSnow[winid].maxHeight;

	if(windowSnow[winid].mask!=0)
		{
			XSetClipMask(display,windowSnow[winid].maskgc,0);
			XSetClipOrigin(display,windowSnow[winid].maskgc,0,0);

			XSetForeground(display,windowSnow[winid].maskgc,blackColor);
			//XSetForeground(display,windowSnow[winid].maskgc,whiteColor);
			XSetFillStyle(display,windowSnow[winid].maskgc,FillSolid);
			XFillRectangle(display,windowSnow[winid].mask,windowSnow[winid].maskgc,0,0,windowSnow[winid].width,windowSnow[winid].maxHeight);

			XSetClipMask(display,gc,0);
			XSetClipOrigin(display,gc,0,0);

			XSetForeground(display,gc,blackColor);
			//XSetForeground(display,gc,whiteColor);
			XSetFillStyle(display,gc,FillSolid);
			XFillRectangle(display,windowSnow[winid].pixmap,gc,0,0,windowSnow[winid].width,windowSnow[winid].maxHeight);
			windowSnow[winid].keepSettling=true;
		}
}
Exemplo n.º 25
0
int main(int argc, char *argv[]) {
	Status rc;
	GC cont;

	dpy = XOpenDisplay(NULL);
	if( !dpy ) {
		fprintf(stderr, "Failed to open display");
		return EXIT_FAILURE;
	}
	scr = DefaultScreen(dpy);
	scr_cmap = DefaultColormap(dpy, scr);

	rc = XAllocNamedColor(dpy, scr_cmap, "green", &green, &green);
	if( !rc ) {
		fprintf(stderr, "XAllocNamedColor: failed to allocate color");
		return EXIT_FAILURE;
	}
	rc = XAllocNamedColor(dpy, scr_cmap, "blue", &blue, &blue);
	if ( !rc ) {
		fprintf(stderr, "XAllocNamedColor: failed to allocate color");
		return EXIT_FAILURE;
	}

	win = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 0, 0, width, width, 0, blue.pixel, blue.pixel);
	XMapWindow(dpy, win);

	cont = XCreateGC(dpy, win, 0, NULL);
	XSetFillStyle(dpy, cont, FillSolid);

	int s;
	int t = 0, q = 1;
	while(1) {
		s = 0;
		while( s<width/2 ) {
			XSetForeground(dpy, cont, t ? 
					(( (s% (2*step) )==0) ? green.pixel: blue.pixel) : 
					(( (s% (2*step) )==0) ? blue.pixel: green.pixel) );
			if(q)
				XFillRectangle(dpy, win, cont, s, s, width - 2*s, width - 2*s);
			else
				XFillRectangle(dpy, win, cont, width/2 - s, width/2 - s, 2*s, 2*s);

			s+=step;
			XFlush(dpy);
//			sleep(1);
			if( s!=step )
				napms(500);
		}
		t=!t;
		q=!q;

	}
	XCloseDisplay(dpy);
	return EXIT_SUCCESS;
}
Exemplo n.º 26
0
void draw_box(int w,int h,int x,int y,int r,int g,int b){
	reset_clip();
	XColor bg=_rgb2XColor(0,0,0);
//	GC bg_gc=XCreateGC(dpy,win,0,0);

	XAllocColor(dpy,attr.colormap,&bg);
	
	XSetForeground(dpy,gc,bg.pixel);
	XSetFillStyle(dpy,gc,FillSolid);
	XFillRectangle(dpy,d,gc,x,y,w,h);
}
Exemplo n.º 27
0
void xf_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor)
{
	xfInfo* xfi = ((xfContext*) context)->xfi;

	bgcolor = (xfi->clrconv->invert)?
		freerdp_color_convert_var_bgr(bgcolor, xfi->srcBpp, 32, xfi->clrconv):
		freerdp_color_convert_var_rgb(bgcolor, xfi->srcBpp, 32, xfi->clrconv);

	fgcolor = (xfi->clrconv->invert)?
		freerdp_color_convert_var_bgr(fgcolor, xfi->srcBpp, 32, xfi->clrconv):
		freerdp_color_convert_var_rgb(fgcolor, xfi->srcBpp, 32, xfi->clrconv);

	XSetFunction(xfi->display, xfi->gc, GXcopy);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, fgcolor);
	XFillRectangle(xfi->display, xfi->drawing, xfi->gc, x, y, width, height);

	XSetForeground(xfi->display, xfi->gc, bgcolor);
	XSetBackground(xfi->display, xfi->gc, fgcolor);
	XSetFillStyle(xfi->display, xfi->gc, FillStippled);
}
Exemplo n.º 28
0
void xf_gdi_polyline(rdpContext* context, POLYLINE_ORDER* polyline)
{
	Drawable dst;
	int i;
	int x, y;
	int x1, y1;
	int x2, y2;
	int npoints;
	uint32 color;
	XPoint* points;
	int width, height;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	xf_set_rop2(xfi, polyline->bRop2);
	color = freerdp_color_convert_rgb(polyline->penColor, xfi->srcBpp, 32, xfi->clrconv);
	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, color);
	npoints = polyline->numPoints + 1;
	points = xmalloc(sizeof(XPoint) * npoints);
	points[0].x = polyline->xStart;
	points[0].y = polyline->yStart;
	for (i = 0; i < polyline->numPoints; i++)
	{
		points[i + 1].x = polyline->points[i].x;
		points[i + 1].y = polyline->points[i].y;
	}
	GET_DST(xfi, dst);
	XDrawLines(xfi->display, dst, xfi->gc, points, npoints, CoordModePrevious);
	if (xfi->drawing == xfi->primary)
	{
		if (!xfi->remote_app && !xfi->skip_bs)
		{
			XDrawLines(xfi->display, xfi->drawable, xfi->gc, points,
					npoints, CoordModePrevious);
		}
		x1 = points[0].x;
		y1 = points[0].y;
		for (i = 1; i < npoints; i++)
		{
			x2 = points[i].x + x1;
			y2 = points[i].y + y1;
			x = (x2 < x1) ? x2 : x1;
			width = (x2 > x1) ? x2 - x1 : x1 - x2;
			y = (y2 < y1) ? y2 : y1;
			height = (y2 > y1) ? y2 - y1 : y1 - y2;
			x1 = x2;
			y1 = y2;
			gdi_InvalidateRegion(xfi->hdc, x, y, width, height);
		}
	}
	XSetFunction(xfi->display, xfi->gc, GXcopy);
	xfree(points);
}
Exemplo n.º 29
0
void xf_gdi_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
{
	int i, npoints;
	XPoint* points;
	UINT32 brush_color;
	xfInfo* xfi = ((xfContext*) context)->xfi;

	xf_set_rop2(xfi, polygon_sc->bRop2);
	brush_color = freerdp_color_convert_var(polygon_sc->brushColor, ((xfContext*)context)->settings->ColorDepth, xfi->bpp, xfi->clrconv);

	npoints = polygon_sc->numPoints + 1;
	points = malloc(sizeof(XPoint) * npoints);

	points[0].x = polygon_sc->xStart;
	points[0].y = polygon_sc->yStart;

	for (i = 0; i < polygon_sc->numPoints; i++)
	{
		points[i + 1].x = polygon_sc->points[i].x;
		points[i + 1].y = polygon_sc->points[i].y;
	}

	switch (polygon_sc->fillMode)
	{
		case 1: /* alternate */
			XSetFillRule(xfi->display, xfi->gc, EvenOddRule);
			break;

		case 2: /* winding */
			XSetFillRule(xfi->display, xfi->gc, WindingRule);
			break;

		default:
			printf("PolygonSC unknown fillMode: %d\n", polygon_sc->fillMode);
			break;
	}

	XSetFillStyle(xfi->display, xfi->gc, FillSolid);
	XSetForeground(xfi->display, xfi->gc, brush_color);

	XFillPolygon(xfi->display, xfi->drawing, xfi->gc,
			points, npoints, Complex, CoordModePrevious);

	if (xfi->drawing == xfi->primary)
	{
		XFillPolygon(xfi->display, xfi->drawable, xfi->gc,
				points, npoints, Complex, CoordModePrevious);
	}

	XSetFunction(xfi->display, xfi->gc, GXcopy);
	free(points);
}
Exemplo n.º 30
0
int xf_OutputUpdate(xfContext* xfc)
{
	UINT16 width, height;
	xfGfxSurface* surface;
	RECTANGLE_16 surfaceRect;
	const RECTANGLE_16* extents;

	if (!xfc->graphicsReset)
		return 1;

	surface = (xfGfxSurface*) xfc->gfx->GetSurfaceData(xfc->gfx, xfc->outputSurfaceId);

	if (!surface)
		return -1;

	surfaceRect.left = 0;
	surfaceRect.top = 0;
	surfaceRect.right = xfc->width;
	surfaceRect.bottom = xfc->height;

	region16_intersect_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &surfaceRect);

	XSetClipMask(xfc->display, xfc->gc, None);
	XSetFunction(xfc->display, xfc->gc, GXcopy);
	XSetFillStyle(xfc->display, xfc->gc, FillSolid);

	if (!region16_is_empty(&(xfc->invalidRegion)))
	{
		extents = region16_extents(&(xfc->invalidRegion));

		width = extents->right - extents->left;
		height = extents->bottom - extents->top;

		if (width > xfc->width)
			width = xfc->width;

		if (height > xfc->height)
			height = xfc->height;

		XPutImage(xfc->display, xfc->drawable, xfc->gc, surface->image,
				extents->left, extents->top,
				extents->left, extents->top, width, height);
	}

	region16_clear(&(xfc->invalidRegion));

	XSetClipMask(xfc->display, xfc->gc, None);
	XSync(xfc->display, True);

	return 1;
}