예제 #1
0
static void *
lcdscrub_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  XGCValues gcv;
  st->dpy = dpy;
  st->window = window;
  st->delay  = get_integer_resource (st->dpy, "delay",  "Integer");
  st->spread = get_integer_resource (st->dpy, "spread", "Integer");
  st->cycles = get_integer_resource (st->dpy, "cycles", "Integer");

  XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
  gcv.foreground = BlackPixelOfScreen (st->xgwa.screen);
  gcv.background = WhitePixelOfScreen (st->xgwa.screen);
  st->bg = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
  gcv.foreground = WhitePixelOfScreen (st->xgwa.screen);
  gcv.background = BlackPixelOfScreen (st->xgwa.screen);
  st->fg = XCreateGC (st->dpy, st->window, GCForeground, &gcv);

#ifdef HAVE_COCOA
  jwxyz_XSetAntiAliasing (st->dpy, st->fg, False);
  jwxyz_XSetAntiAliasing (st->dpy, st->bg, False);
#endif

  return st;
}
예제 #2
0
static void *
lcdscrub_init (Display *dpy, Window window)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  XGCValues gcv;
  st->dpy = dpy;
  st->window = window;
  //st->delay  = get_integer_resource (st->dpy, "delay",  "Integer");
  //st->spread = get_integer_resource (st->dpy, "spread", "Integer");
  //st->cycles = get_integer_resource (st->dpy, "cycles", "Integer");
  st->delay  = delay;
  st->spread = spread;
  st->cycles = cycles;

  XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
  gcv.foreground = BlackPixelOfScreen (st->xgwa.screen);
  gcv.background = WhitePixelOfScreen (st->xgwa.screen);
  st->bg  = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
  st->bg2 = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
  gcv.foreground = WhitePixelOfScreen (st->xgwa.screen);
  gcv.background = BlackPixelOfScreen (st->xgwa.screen);
  st->fg = XCreateGC (st->dpy, st->window, GCForeground, &gcv);

#ifdef HAVE_COCOA
  jwxyz_XSetAntiAliasing (st->dpy, st->fg,  False);
  jwxyz_XSetAntiAliasing (st->dpy, st->bg,  False);
  jwxyz_XSetAntiAliasing (st->dpy, st->bg2, False);
#endif

  st->enabled_mask = 0;
#if 1
	# define PREF(R,F) \
	   if (R) st->enabled_mask |= (1 << F)
#else
	# define PREF(R,F) \
	   if (get_boolean_resource (st->dpy, R, "Mode")) st->enabled_mask |= (1 << F)
#endif
  PREF("modeHW", HORIZ_W);
  PREF("modeHB", HORIZ_B);
  PREF("modeVW", VERT_W);
  PREF("modeVB", VERT_B);
  PREF("modeDW", DIAG_W);
  PREF("modeDB", DIAG_B);
  PREF("modeW",  WHITE);
  PREF("modeB",  BLACK);
  PREF("modeRGB", RGB);
# undef PREF
  if (! st->enabled_mask) 
    {
      fprintf (stderr, "%s: no modes enabled\n", progname);
      exit (1);
    }

  pick_mode (st);

  return st;
}
예제 #3
0
/*
** BeginWait/EndWait
**
** Display/Remove a watch cursor over topCursorWidget and its descendents
*/
void BeginWait(Widget topCursorWidget)
{
    Display *display = XtDisplay(topCursorWidget);
    Pixmap pixmap;
    Pixmap maskPixmap;
    XColor xcolors[2];
    static Cursor  waitCursor = 0;
    
    /* if the watch cursor hasn't been created yet, create it */
    if (!waitCursor) {
	pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
		(char *)watch_bits, watch_width, watch_height);

	maskPixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
		(char *)watch_mask_bits, watch_width, watch_height);

	xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(display));
	xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(display));

	XQueryColors(display, DefaultColormapOfScreen(
		DefaultScreenOfDisplay(display)), xcolors, 2);
	waitCursor = XCreatePixmapCursor(display, pixmap, maskPixmap,
		&xcolors[0], &xcolors[1], watch_x_hot, watch_y_hot);
	XFreePixmap(display, pixmap);
	XFreePixmap(display, maskPixmap);
    }

    /* display the cursor */
    XDefineCursor(display, XtWindow(topCursorWidget), waitCursor);
}
예제 #4
0
파일: UxXt.c 프로젝트: nagyistge/ctn
static Pixmap
ConvertPixmap(char *file_name, int depth)
#endif
{
    XrmValue fg_from,
        fg_to,
        bg_from,
        bg_to;
    Pixel fg,
        bg;

    fg_from.size = strlen(XtDefaultForeground);
    fg_from.addr = XtDefaultForeground;
    fg_to.addr = (XPointer) & fg;
    bg_from.size = strlen(XtDefaultBackground);
    bg_from.addr = XtDefaultBackground;
    bg_to.addr = (XPointer) & bg;
    if (!XtConvertAndStore
	(UxTopLevel, XtRString, &bg_from, XtRPixel, &bg_to)
	|| !XtConvertAndStore
	(UxTopLevel, XtRString, &fg_from, XtRPixel, &fg_to)
	|| (fg == bg)) {
	fg = WhitePixelOfScreen(XtScreen(UxTopLevel));
	bg = BlackPixelOfScreen(XtScreen(UxTopLevel));
    }
    if (depth)
	return (XmGetPixmapByDepth
		(XtScreen(UxTopLevel), file_name, fg, bg, depth));

    else
	return (XmGetPixmap(XtScreen(UxTopLevel), file_name, fg, bg));
}
예제 #5
0
파일: XbrGfx.c 프로젝트: idunham/dtextra
Pixmap XbrGfxLoadBitmap(Widget w, char *bits, int width, int height, int inherit)
{
    XGCValues vals;
    Pixmap pixmap;
    GC gc;
    Display *display = XtDisplay(w);
    Screen *screen = XtScreen(w);
    Window root = RootWindowOfScreen(screen);
  
    /* Get the foreground and background colours of the widget */
    if(inherit) {
        XtVaGetValues(w, XmNforeground, &vals.foreground, XmNbackground,
          &vals.background, NULL);
    } else {
        vals.foreground = BlackPixelOfScreen(screen);
	vals.background = WhitePixelOfScreen(screen);
    }

    /* Create a GC for drawing the pixmap */
    gc = XCreateGC(display, root, GCForeground|GCBackground, &vals);

    /* Change the bitmap to a pixmap */
    pixmap = XbrGfxReadBitmap(display, screen, gc, bits, width, height);

    /* Free GC we have finished with */
    XFreeGC(display, gc);

    /* Return the pixmap */
    return(pixmap);
}
예제 #6
0
Window create_window(Display *dsp, Screen *screen) {
	Window window;
	int x, y;
	int width, height;
	int depth;
	XSetWindowAttributes winAttrib;
	XWindowAttributes window_attributes;
	
	x = 30;
	y = 60;
	width = 200;
	height = 300;
	winAttrib.background_pixel = BlackPixelOfScreen(screen);
	winAttrib.border_pixel = WhitePixelOfScreen(screen);
	winAttrib.backing_store = Always/*NotUseful*/;
	winAttrib.override_redirect = False;
	winAttrib.bit_gravity = NorthWestGravity;
	winAttrib.win_gravity = NorthWestGravity;
	depth = DefaultDepthOfScreen(screen);
	if (XGetWindowAttributes(dsp, RootWindowOfScreen(screen), &window_attributes) == 0)
	{
		fprintf(stderr, "xf_get_pixmap_info: XGetWindowAttributes failed\n");
		return 1;
	}
	window = XCreateWindow(dsp, RootWindowOfScreen(screen),
						x, y,
						width, height,
						0,
						depth,
						InputOutput, /*window_attributes.visual*/DefaultVisual(dsp, 0),
						0, &winAttrib);
	setWindowDecorations(dsp, window, 0);	//设置后没有Ubuntu自带的关闭、最小和最大这三个键
	return window;
}
예제 #7
0
HelloWorld::HelloWorld(Display* display) :
    _game() {

    _display = display;
    _screen = XDefaultScreenOfDisplay(display);

    _blackColor = BlackPixelOfScreen(_screen);
    _whiteColor = WhitePixelOfScreen(_screen);
    _font = XLoadFont(_display, WINDOW_FONT);

    int screenWidth = XWidthOfScreen(_screen);
    int screenHeight = XHeightOfScreen(_screen);

    int windowWidth = MIN_CELL_SIZE * 3;
    int windowHeight = MIN_CELL_SIZE * 3 + STRING_HEIGHT * 3;
    int windowX = (screenWidth + windowWidth) / 2;
    int windowY = (screenHeight + windowHeight) / 2;
    _window = XCreateSimpleWindow(_display, XRootWindowOfScreen(_screen),
            windowX, windowY, windowWidth, windowHeight, 1, _blackColor,
            _whiteColor);

    long eventMask = ButtonPressMask | ExposureMask | KeyPressMask;
    XSelectInput(_display, _window, eventMask);

    draw();
}
예제 #8
0
파일: image.c 프로젝트: juddy/edcde
void
drawimage(perwindow *pwin)
{
    imagestruct *ip;
    int         i;

    ip = (imagestruct *)pwin->data;
    XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
    for (i = 0; i < ip->iconcount; i++) {
	if (!ip->iconmode)
	    XFillRectangle(dsp, pwin->w, pwin->gc,
			   ip->xb + xlogo_width * ip->icons[i].x,
			   ip->yb + xlogo_height * ip->icons[i].y,
			   xlogo_width, xlogo_height);

	ip->icons[i].x = random() % ip->ncols;
	ip->icons[i].y = random() % ip->nrows;
    }
    if (pwin->perscreen->npixels == 2)
      XSetForeground(dsp, pwin->gc, WhitePixelOfScreen(pwin->perscreen->screen));
    for (i = 0; i < ip->iconcount; i++) {
	if (pwin->perscreen->npixels > 2)
	    XSetForeground(dsp, pwin->gc,
		 pwin->perscreen->pixels[random() % pwin->perscreen->npixels]);

	XPutImage(dsp, pwin->w, pwin->gc, &logo,
		  0, 0,
		  ip->xb + xlogo_width * ip->icons[i].x,
		  ip->yb + xlogo_height * ip->icons[i].y,
		  xlogo_width, xlogo_height);
    }
}
예제 #9
0
파일: Delay.C 프로젝트: Stabledog/dddbash
Cursor _Delay::hourglass_cursor()
{
    if (hourglass_cache != 0)
	return hourglass_cache;

    Display *display = XtDisplay(widget);

#if SMALL_HOURGLASS_CURSOR || LARGE_HORGLASS_CURSOR
    Screen *screen = XtScreen(widget);
    Window rootWindow = RootWindowOfScreen(screen);

    unsigned char *cursor_bits      = time16_bits;
    unsigned char *cursor_mask_bits = time16m_bits;
    unsigned int cursor_width       = time16_width;
    unsigned int cursor_height      = time16_height;
    unsigned int cursor_x_hot       = time16_x_hot;
    unsigned int cursor_y_hot       = time16_y_hot;

#if LARGE_HOURGLASS_CURSOR
    // Fetch cursor shape
    unsigned int width, height;
    XQueryBestCursor(display, rootWindow, 32, 32, &width, &height);
    Boolean largeCursors = (width >= 32 && height >= 32);
    if (largeCursors)
    {
	cursor_bits      = time32_bits;
	cursor_mask_bits = time32m_bits;
	cursor_width     = time32_width;
	cursor_height    = time32_height;
	cursor_x_hot     = time32_x_hot;
	cursor_y_hot     = time32_y_hot;
    }
#endif

    Pixmap cursor_pixmap = 
	XCreateBitmapFromData(display, rootWindow, (char *)cursor_bits,
			      cursor_width, cursor_height);
    Pixmap cursor_mask_pixmap = 
	XCreateBitmapFromData(display, rootWindow, (char *)cursor_mask_bits,
			      cursor_width, cursor_height);
    
    XColor cursor_colors[2];
    cursor_colors[0].pixel = BlackPixelOfScreen(screen);
    cursor_colors[1].pixel = WhitePixelOfScreen(screen);

    XQueryColors(display, DefaultColormapOfScreen(screen), 
		 cursor_colors, 2);

    hourglass_cache = 
	XCreatePixmapCursor(display, cursor_pixmap, cursor_mask_pixmap,
			    cursor_colors, cursor_colors + 1, 
			    cursor_x_hot, cursor_y_hot);
#else // Watch cursor
    hourglass_cache = 
	XCreateFontCursor(display, XC_watch);
#endif

    return hourglass_cache;
}
예제 #10
0
static void
monoColormap(Screen * scr, ScreenInfo * si, char *foreground, char *background)
{
	si->black_pixel = BlackPixelOfScreen(scr);
	si->white_pixel = WhitePixelOfScreen(scr);
	if (strcmp(foreground, "White") == 0 || strcmp(foreground, "white") == 0 ||
	    strcmp(background, "Black") == 0 || strcmp(background, "black") == 0) {
		si->fg_pixel = WhitePixelOfScreen(scr);
		si->bg_pixel = BlackPixelOfScreen(scr);
	} else {
		si->fg_pixel = BlackPixelOfScreen(scr);
		si->bg_pixel = WhitePixelOfScreen(scr);
	}
	si->pixels[0] = WhitePixelOfScreen(scr);
	si->pixels[1] = BlackPixelOfScreen(scr);
	si->npixels = 2;
}
예제 #11
0
파일: converters.C 프로젝트: sampost/ddd
// Convert String to Pixmap (using XmGetPixmap)
// A Pixmap will be read in as bitmap file
// 1 and 0 values are set according to the widget's 
// foreground/background colors.
static Boolean CvtStringToPixmap(Display *display, 
				 XrmValue *args, Cardinal *num_args, 
				 XrmValue *fromVal, XrmValue *toVal,
				 XtPointer *)
{
    // Default parameters
    Screen *screen   = DefaultScreenOfDisplay(display);
    Pixel background = WhitePixelOfScreen(screen);
    Pixel foreground = BlackPixelOfScreen(screen);

    if (*num_args >= 1)
    {
	// convert first arg into widget
	Widget w = *(Widget *) args[0].addr;
	background = w->core.background_pixel;
	
	screen = XtScreen(w);
	
	if (XtIsWidget(w) && XmIsPrimitive(w))
	{
	    // Get foreground color from widget
	    foreground = XmPrimitiveWidget(w)->primitive.foreground;
	}
	else
	{
	    // Ask Motif for a default foreground color
	    Pixel newfg, newtop, newbot, newselect;
	    XmGetColors(screen, w->core.colormap, background,
			&newfg, &newtop, &newbot, &newselect);
	    foreground = newfg;
	}
    }

    // Get pixmap
    Pixmap p = XmUNSPECIFIED_PIXMAP;

    string value = str(fromVal, false);

    // Some Motif versions use `unspecified_pixmap' and `unspecified pixmap'
    // as values for XmUNSPECIFIED_PIXMAP.  Check for this.
    string v = downcase(value);
    v.gsub(" ", "_");
    if (v.contains("xm", 0))
	v = v.after("xm");
    if (v != "unspecified_pixmap")
    {
	p = XmGetPixmap(screen, XMST(value.chars()), foreground, background);

	if (p == XmUNSPECIFIED_PIXMAP)
	{
	    XtDisplayStringConversionWarning(display, fromVal->addr, 
					     XmRPixmap);
	    return False;
	}
    }

    done(Pixmap, p);
}
예제 #12
0
void xf_create_window(xfContext* xfc)
{
	XEvent xevent;
	int width, height;
	char* windowTitle;

	ZeroMemory(&xevent, sizeof(xevent));

	width = xfc->width;
	height = xfc->height;

	if (!xfc->remote_app)
	{
		xfc->attribs.background_pixel = BlackPixelOfScreen(xfc->screen);
		xfc->attribs.border_pixel = WhitePixelOfScreen(xfc->screen);
		xfc->attribs.backing_store = xfc->primary ? NotUseful : Always;
		xfc->attribs.override_redirect = xfc->grab_keyboard ? xfc->fullscreen : False;
		xfc->attribs.colormap = xfc->colormap;
		xfc->attribs.bit_gravity = NorthWestGravity;
		xfc->attribs.win_gravity = NorthWestGravity;

		if (xfc->instance->settings->WindowTitle)
		{
			windowTitle = _strdup(xfc->instance->settings->WindowTitle);
		}
		else if (xfc->instance->settings->ServerPort == 3389)
		{
			windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfc->instance->settings->ServerHostname));
			sprintf(windowTitle, "FreeRDP: %s", xfc->instance->settings->ServerHostname);
		}
		else
		{
			windowTitle = malloc(1 + sizeof("FreeRDP: ") + strlen(xfc->instance->settings->ServerHostname) + sizeof(":00000"));
			sprintf(windowTitle, "FreeRDP: %s:%i", xfc->instance->settings->ServerHostname, xfc->instance->settings->ServerPort);
		}

		printf ("xfc->settings->Decorations=%d\n", xfc->settings->Decorations);

		xfc->window = xf_CreateDesktopWindow(xfc, windowTitle, width, height, xfc->settings->Decorations);
		free(windowTitle);

		if (xfc->fullscreen)
			xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen);

		xfc->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

		XSetWMProtocols(xfc->display, xfc->window->handle, &(xfc->WM_DELETE_WINDOW), 1);
		xfc->drawable = xfc->window->handle;
	}
	else
	{
		xfc->drawable = DefaultRootWindow(xfc->display);
	}
}
예제 #13
0
Pixmap
makepixmap(Widget toplevel, char bits[], int width, int height)
{
  return (Pixmap)XCreatePixmapFromBitmapData(XtDisplay(toplevel),
			   DefaultRootWindow(XtDisplay(toplevel)),
                           bits,
                           width,
                           height,
                           BlackPixelOfScreen(XtScreen(toplevel)),
                           WhitePixelOfScreen(XtScreen(toplevel)),
                           DefaultDepthOfScreen(XtScreen(toplevel)));
}
예제 #14
0
파일: xfreerdp.c 프로젝트: hcgpalm/FreeRDP
void xf_create_window(xfInfo* xfi)
{
	XEvent xevent;
	char* win_title;
	int width, height;

	width = xfi->width;
	height = xfi->height;

	xfi->attribs.background_pixel = BlackPixelOfScreen(xfi->screen);
	xfi->attribs.border_pixel = WhitePixelOfScreen(xfi->screen);
	xfi->attribs.backing_store = xfi->primary ? NotUseful : Always;
	xfi->attribs.override_redirect = xfi->fullscreen;
	xfi->attribs.colormap = xfi->colormap;
	xfi->attribs.bit_gravity = ForgetGravity;
	xfi->attribs.win_gravity = StaticGravity;

	if (xfi->instance->settings->window_title != NULL)
	{
		win_title = xstrdup(xfi->instance->settings->window_title);
	}
	else if (xfi->instance->settings->port == 3389)
	{
		win_title = xmalloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname));
		sprintf(win_title, "FreeRDP: %s", xfi->instance->settings->hostname);
	}
	else
	{
		win_title = xmalloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname) + sizeof(":00000"));
		sprintf(win_title, "FreeRDP: %s:%i", xfi->instance->settings->hostname, xfi->instance->settings->port);
	}

	xfi->window = xf_CreateDesktopWindow(xfi, win_title, width, height, xfi->decorations);
	xfree(win_title);

	if (xfi->parent_window)
		XReparentWindow(xfi->display, xfi->window->handle, xfi->parent_window, 0, 0);

	if (xfi->fullscreen)
		xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);

	/* wait for VisibilityNotify */
	do
	{
		XMaskEvent(xfi->display, VisibilityChangeMask, &xevent);
	}
	while (xevent.type != VisibilityNotify);

	xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

	XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1);
	xfi->drawable = xfi->window->handle;
}
예제 #15
0
파일: main.c 프로젝트: epronk/xtickertape
/* Create the icon window */
static Window
create_icon(Widget shell)
{
    Display *display = XtDisplay(shell);
    Screen *screen = XtScreen(shell);
    Colormap colormap = XDefaultColormapOfScreen(screen);
    int depth = DefaultDepthOfScreen(screen);
    unsigned long black = BlackPixelOfScreen(screen);
    Window window;
    Pixmap pixmap, mask;
    XColor color;
    GC gc;
    XGCValues values;

    /* Create the actual icon window */
    window = XCreateSimpleWindow(
        display, RootWindowOfScreen(screen),
        0, 0, mask_width, mask_height, 0,
        CopyFromParent, CopyFromParent);

    /* Allocate the color red by name */
    XAllocNamedColor(display, colormap, "red", &color, &color);

    /* Create a pixmap from the red bitmap data */
    pixmap = XCreatePixmapFromBitmapData(
        display, window, (char *)red_bits, red_width, red_height,
        color.pixel, black, depth);

    /* Create a graphics context */
    values.function = GXxor;
    gc = XCreateGC(display, pixmap, GCFunction, &values);

    /* Create a pixmap for the white 'e' and paint it on top */
    mask = XCreatePixmapFromBitmapData(
        display, pixmap, (char *)white_bits, white_width, white_height,
        WhitePixelOfScreen(screen) ^ black, 0, depth);
    XCopyArea(display, mask, pixmap, gc, 0, 0,
              white_width, white_height, 0, 0);
    XFreePixmap(display, mask);
    XFreeGC(display, gc);

#ifdef HAVE_LIBXEXT
    /* Create a shape mask and apply it to the window */
    mask = XCreateBitmapFromData(display, pixmap, (char *)mask_bits,
                                 mask_width, mask_height);
    XShapeCombineMask(display, window, ShapeBounding, 0, 0, mask, ShapeSet);
#endif /* HAVE_LIBXEXT */

    /* Set the window's background to be the pixmap */
    XSetWindowBackgroundPixmap(display, window, pixmap);
    return window;
}
예제 #16
0
파일: XbrGfx.c 프로젝트: idunham/dtextra
void XbrGfxBWPixels(Display *display, Screen *screen, Colormap colourmap,
                    XColor *black, XColor *white)
{
    if(black != NULL) {
        black->pixel = BlackPixelOfScreen(screen);
        XQueryColor(display, colourmap, black);
    }

    if(white != NULL) {
        white->pixel = WhitePixelOfScreen(screen);
        XQueryColor(display, colourmap, white);
    }
}
예제 #17
0
파일: xfreerdp.c 프로젝트: kidfolk/FreeRDP
void xf_create_window(xfInfo* xfi)
{
	XEvent xevent;
	char* title;
	char* hostname;
	int width, height;

	width = xfi->width;
	height = xfi->height;

	xfi->attribs.background_pixel = BlackPixelOfScreen(xfi->screen);
	xfi->attribs.border_pixel = WhitePixelOfScreen(xfi->screen);
	xfi->attribs.backing_store = xfi->primary ? NotUseful : Always;
	xfi->attribs.override_redirect = xfi->fullscreen;
	xfi->attribs.colormap = xfi->colormap;

	if (xfi->remote_app != True)
	{
		if (xfi->fullscreen)
		{
			width = xfi->fullscreen ? WidthOfScreen(xfi->screen) : xfi->width;
			height = xfi->fullscreen ? HeightOfScreen(xfi->screen) : xfi->height;
		}

		hostname = xfi->instance->settings->hostname;
		title = xmalloc(sizeof("FreeRDP: ") + strlen(hostname));
		sprintf(title, "FreeRDP: %s", hostname);

		xfi->window = xf_CreateDesktopWindow(xfi, title, width, height, xfi->decorations);
		xfree(title);

		if (xfi->fullscreen)
			xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);

		/* wait for VisibilityNotify */
		do
		{
			XMaskEvent(xfi->display, VisibilityChangeMask, &xevent);
		}
		while (xevent.type != VisibilityNotify);

		xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

		XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1);
		xfi->drawable = xfi->window->handle;
	}
	else
	{
		xfi->drawable = DefaultRootWindow(xfi->display);
	}
}
예제 #18
0
파일: pixmaps.c 프로젝트: RobArthan/pp
Pixmap get_pp_pixmap(void){
	if(!pp_pixmap) {
		pp_pixmap = XCreatePixmapFromBitmapData(
			XtDisplay(root),
			RootWindowOfScreen(XtScreen(root)),
			(char*)pp_bitmap_bits,
			pp_bitmap_width,
			pp_bitmap_height,
			BlackPixelOfScreen(XtScreen(root)), /* foreground pixel */
			WhitePixelOfScreen(XtScreen(root)), /* background pixel */
			DefaultDepthOfScreen(XtScreen(root)) /* depth */);
	}
	return pp_pixmap;
}
예제 #19
0
Cursor
HelpAgent::create_help_cursor(Widget parent)
{
  Display     *display = XtDisplay(parent);
  Screen      *retScr = XtScreen(parent);
  int          screen = XScreenNumberOfScreen(retScr);
  char        *bits;
  char        *maskBits;
  unsigned int width;
  unsigned int height;
  unsigned int xHotspot;
  unsigned int yHotspot;
  Pixmap       pixmap;
  Pixmap       maskPixmap;
  XColor       xcolors[2];
  Cursor      cursor;

  width    = onitem32_width;
  height   = onitem32_height;
  bits     = (char *) onitem32_bits;
  maskBits = (char *) onitem32_m_bits;
  xHotspot = onitem32_x_hot;
  yHotspot = onitem32_y_hot;

  pixmap = XCreateBitmapFromData (display,
             RootWindowOfScreen(XtScreen(parent)), bits,
             width, height);


  maskPixmap = XCreateBitmapFromData (display,
                 RootWindowOfScreen(XtScreen(parent)), maskBits,
                 width, height);

  xcolors[0].pixel = BlackPixelOfScreen(ScreenOfDisplay(display, screen));
  xcolors[1].pixel = WhitePixelOfScreen(ScreenOfDisplay(display, screen));

  XQueryColors (display,
    DefaultColormapOfScreen(ScreenOfDisplay(display, screen)), xcolors, 2);

  cursor = XCreatePixmapCursor (display, pixmap, maskPixmap,
                       &(xcolors[0]), &(xcolors[1]),
                       xHotspot, yHotspot);
  XFreePixmap (display, pixmap);
  XFreePixmap (display, maskPixmap);

  return cursor;

}
예제 #20
0
파일: x11.c 프로젝트: aosm/X11
LispObj *
Lisp_XWhitePixelOfScreen(LispBuiltin *builtin)
/*
 x-white-pixel-of-screen screen
 */
{
    LispObj *screen;

    screen = ARGUMENT(0);

    if (!CHECKO(screen, x11Screen_t))
	LispDestroy("%s: cannot convert %s to Screen*",
		    STRFUN(builtin), STROBJ(screen));

    return (INTEGER(WhitePixelOfScreen((Screen*)(screen->data.opaque.data))));
}
예제 #21
0
파일: XmDrawdbl.c 프로젝트: rrusk/TQGG
void  WPigEraseMain(void)
{

    XtVaGetValues( MainCanvas, 
        XtNheight, &height, 
        XtNwidth, &width, 
        NULL);
    /*printf ("erasemain height,width= (%d,%d)\n", height, width);*/

    XSetForeground (XtDisplay (MainCanvas), gc,BlackPixelOfScreen (XtScreen (MainCanvas)));

    XFillRectangle (XtDisplay(MainCanvas), XtWindow(MainCanvas), gc, 0, 0, width, height );
    if (use_pixmap) XFillRectangle (XtDisplay(MainCanvas), pixmap, gc, 0, 0, width, height );

    XSetForeground (XtDisplay (MainCanvas), gc,WhitePixelOfScreen (XtScreen (MainCanvas)));

}  
예제 #22
0
파일: xfreerdp.c 프로젝트: Osirium/FreeRDP
void xf_create_window(xfInfo* xfi)
{
	XEvent xevent;
	char* win_title;
	int width, height;

	memset(&xevent, 0x00, sizeof(xevent));

	width = xfi->width;
	height = xfi->height;

	xfi->attribs.background_pixel = BlackPixelOfScreen(xfi->screen);
	xfi->attribs.border_pixel = WhitePixelOfScreen(xfi->screen);
	xfi->attribs.backing_store = xfi->primary ? NotUseful : Always;
	xfi->attribs.override_redirect = xfi->fullscreen;
	xfi->attribs.colormap = xfi->colormap;
	xfi->attribs.bit_gravity = NorthWestGravity;
	xfi->attribs.win_gravity = NorthWestGravity;

	if (xfi->instance->settings->WindowTitle != NULL)
	{
		win_title = _strdup(xfi->instance->settings->WindowTitle);
	}
	else if (xfi->instance->settings->ServerPort == 3389)
	{
		win_title = malloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->ServerHostname));
		sprintf(win_title, "FreeRDP: %s", xfi->instance->settings->ServerHostname);
	}
	else
	{
		win_title = malloc(1 + sizeof("FreeRDP: ") + strlen(xfi->instance->settings->ServerHostname) + sizeof(":00000"));
		sprintf(win_title, "FreeRDP: %s:%i", xfi->instance->settings->ServerHostname, xfi->instance->settings->ServerPort);
	}

	xfi->window = xf_CreateDesktopWindow(xfi, win_title, width, height, xfi->decorations);
	free(win_title);

	if (xfi->fullscreen)
		xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);

	xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

	XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1);
	xfi->drawable = xfi->window->handle;
}
예제 #23
0
int main(int argc, char *argv[])
{
    theDisplay = XOpenDisplay(NULL);
    XSynchronize(theDisplay, True);
    theScreen = DefaultScreenOfDisplay(theDisplay);
    theWindow = XCreateSimpleWindow(theDisplay, RootWindowOfScreen(theScreen),
                                    0, 0,
                                    WINDOW_SIZE, WINDOW_SIZE, 0,
                                    BlackPixelOfScreen(theScreen),
                                    WhitePixelOfScreen(theScreen));
    theGC = XCreateGC(theDisplay, theWindow, 0L, NULL);
    XSetForeground(theDisplay, theGC, BlackPixelOfScreen(theScreen));
    XMapWindow(theDisplay, theWindow);
    /* more stuff to come here... */
    tortoise_reset();
    gh_enter(argc, argv, inner_main);
    return 0; /* never reached */
}
예제 #24
0
파일: XDPSpreview.c 프로젝트: aosm/X11
static void FillPixmapWithGray(
    Screen *screen,
    Drawable dest,
    XRectangle *bbox,
    int xOffset, int yOffset,
    double pixelsPerPoint,
    Bool createMask)
{
    int width, height, x, y;
    GC gc;
    XGCValues v;
    static char grayBits[] = {0x01, 0x02};
    Pixmap grayStipple;
    Display *dpy = DisplayOfScreen(screen);

    width = ceil(bbox->width * pixelsPerPoint);
    height = ceil(bbox->height * pixelsPerPoint);
    x = (bbox->x + xOffset) * pixelsPerPoint;
    y = (bbox->y + yOffset) * pixelsPerPoint;

    if (createMask) {
	v.foreground = 1;
	v.function = GXcopy;

	gc = XCreateGC(dpy, dest, GCForeground | GCFunction, &v);
	XFillRectangle(dpy, dest, gc, x, y, width, height);
	XFreeGC(dpy, gc);
	return;
    }

    grayStipple = XCreateBitmapFromData(dpy, dest, grayBits, 2, 2);

    v.foreground = BlackPixelOfScreen(screen);
    v.background = WhitePixelOfScreen(screen);
    v.function = GXcopy;
    v.stipple = grayStipple;
    v.fill_style = FillOpaqueStippled;
    gc = XCreateGC(dpy, dest, GCForeground | GCBackground | GCFunction |
		              GCStipple | GCFillStyle, &v);
    XFillRectangle(dpy, dest, gc, x, y, width, height);
    XFreeGC(dpy, gc);
    XFreePixmap(dpy, grayStipple);
}
예제 #25
0
/*--------------------------------------------------------------------------*/
int sci_opentk(char *fname, unsigned long l)
{
    Tcl_Interp *TCLinterpLocal = NULL;

    CheckRhs(0, 0);
    CheckLhs(1, 1);

    TCLinterpLocal = Tcl_CreateInterp();
    Tcl_Init(TCLinterpLocal);
    Tk_Init(TCLinterpLocal);
    TKmainWindow = Tk_MainWindow(TCLinterpLocal);
    Tk_GeometryRequest(TKmainWindow, 200, 200);
    Tk_SetWindowBackground(TKmainWindow, WhitePixelOfScreen(Tk_Screen(TKmainWindow)));

    LhsVar(1) = 0;
    PutLhsVar();

    return 0;
}
예제 #26
0
/*ARGSUSED*/
Boolean
XmuCvtStringToColorCursor(Display *dpy, XrmValuePtr args, Cardinal *num_args,
			  XrmValuePtr fromVal, XrmValuePtr toVal,
			  XtPointer *converter_data)
{
    Cursor cursor;
    Screen *screen;
    Pixel fg, bg;
    Colormap c_map;
    XColor colors[2];
    Cardinal number;
    XrmValue ret_val;

    if (*num_args != 4) {
	XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
	    "wrongParameters","cvtStringToColorCursor","XmuError",
            "String to color cursor conversion needs four arguments",
	    (String *)NULL, (Cardinal *)NULL);
	return False;
    }

    screen = *((Screen **) args[0].addr);
    fg = *((Pixel *) args[1].addr);
    bg = *((Pixel *) args[2].addr);
    c_map = *((Colormap *) args[3].addr);

    number = 1;
    XmuCvtStringToCursor(args, &number, fromVal, &ret_val);

    cursor = *((Cursor *) ret_val.addr);

    if (cursor == None || (fg == BlackPixelOfScreen(screen)
			   && bg == WhitePixelOfScreen(screen)))
	new_done(Cursor, cursor);

    colors[0].pixel = fg;
    colors[1].pixel = bg;

    XQueryColors (dpy, c_map, colors, 2);
    XRecolorCursor(dpy, cursor, colors, colors + 1);
    new_done(Cursor, cursor);
}
예제 #27
0
void* iupdrvImageLoad(const char* name, int type)
{
  if (type == IUPIMAGE_CURSOR)
  {
    Cursor cursor = 0;
    int id;
    if (iupStrToInt(name, &id))
      cursor = XCreateFontCursor(iupmot_display, id);
    return (void*)cursor;
  }
  else /* IUPIMAGE_IMAGE or IUPIMAGE_ICON */
  {
    Screen* screen = ScreenOfDisplay(iupmot_display, iupmot_screen);
  	Pixmap pixmap = XmGetPixmap(screen, (char*)name, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen));
    if (pixmap == XmUNSPECIFIED_PIXMAP)
    {
	    unsigned int width, height;
	    int hotx, hoty;
      pixmap = 0;
    	XReadBitmapFile(iupmot_display, RootWindow(iupmot_display,iupmot_screen), name, &width, &height, &pixmap, &hotx, &hoty);
    }
  	return (void*)pixmap;
  }
}
예제 #28
0
void
TkpDrawCheckIndicator(
    Tk_Window tkwin,		/* handle for resource alloc */
    Display *display,
    Drawable d,			/* what to draw on */
    int x, int y,		/* where to draw */
    Tk_3DBorder bgBorder,	/* colors of the border */
    XColor *indicatorColor,	/* color of the indicator */
    XColor *selectColor,	/* color when selected */
    XColor *disableColor,	/* color when disabled */
    int on,			/* are we on? */
    int disabled,		/* are we disabled? */
    int mode)			/* kind of indicator to draw */
{
    int ix, iy;
    int dim;
    int imgsel, imgstart;
    TkBorder *bg_brdr = (TkBorder*)bgBorder;
    XGCValues gcValues;
    GC copyGC;
    unsigned long imgColors[8];
    XImage *img;
    Pixmap pixmap;
    int depth;

    /*
     * Sanity check.
     */

    if (tkwin == NULL || display == None || d == None || bgBorder == NULL
	    || indicatorColor == NULL) {
	return;
    }

    if (disableColor == NULL) {
	disableColor = bg_brdr->bgColorPtr;
    }

    if (selectColor == NULL) {
	selectColor = bg_brdr->bgColorPtr;
    }

    depth = Tk_Depth(tkwin);

    /*
     * Compute starting point and dimensions of image inside button_images to
     * be used.
     */

    switch (mode) {
    default:
    case CHECK_BUTTON:
	imgsel = on == 2 ? CHECK_DISON_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START;
	dim = CHECK_BUTTON_DIM;
	break;

    case CHECK_MENU:
	imgsel = on == 2 ? CHECK_DISOFF_OFFSET :
		on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
	imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
	imgstart = CHECK_START + 2;
	imgsel += 2;
	dim = CHECK_MENU_DIM;
	break;

    case RADIO_BUTTON:
	imgsel = on == 2 ? RADIO_DISON_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START;
	dim = RADIO_BUTTON_DIM;
	break;

    case RADIO_MENU:
	imgsel = on == 2 ? RADIO_DISOFF_OFFSET :
		on==1 ? RADIO_ON_OFFSET : RADIO_OFF_OFFSET;
	imgsel += disabled && on != 2 ? RADIO_DISOFF_OFFSET : 0;
	imgstart = RADIO_START + 3;
	imgsel += 3;
	dim = RADIO_MENU_DIM;
	break;
    }

    /*
     * Allocate the drawing areas to use. Note that we use double-buffering
     * here because not all code paths leading to this function do so.
     */

    pixmap = Tk_GetPixmap(display, d, dim, dim, depth);
    if (pixmap == None) {
	return;
    }

    x -= dim/2;
    y -= dim/2;

    img = XGetImage(display, pixmap, 0, 0,
	    (unsigned int)dim, (unsigned int)dim, AllPlanes, ZPixmap);
    if (img == NULL) {
	return;
    }

    /*
     * Set up the color mapping table.
     */

    TkpGetShadows(bg_brdr, tkwin);

    imgColors[0 /*A*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
    imgColors[1 /*B*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
    imgColors[2 /*C*/] = (bg_brdr->lightColorPtr != NULL) ?
	    Tk_GetColorByValue(tkwin, bg_brdr->lightColorPtr)->pixel :
	    WhitePixelOfScreen(bg_brdr->screen);
    imgColors[3 /*D*/] =
	    Tk_GetColorByValue(tkwin, selectColor)->pixel;
    imgColors[4 /*E*/] = (bg_brdr->darkColorPtr != NULL) ?
	    Tk_GetColorByValue(tkwin, bg_brdr->darkColorPtr)->pixel :
	    BlackPixelOfScreen(bg_brdr->screen);
    imgColors[5 /*F*/] =
	    Tk_GetColorByValue(tkwin, bg_brdr->bgColorPtr)->pixel;
    imgColors[6 /*G*/] =
	    Tk_GetColorByValue(tkwin, indicatorColor)->pixel;
    imgColors[7 /*H*/] =
	    Tk_GetColorByValue(tkwin, disableColor)->pixel;

    /*
     * Create the image, painting it into an XImage one pixel at a time.
     */

    for (iy=0 ; iy<dim ; iy++) {
	for (ix=0 ; ix<dim ; ix++) {
	    XPutPixel(img, ix, iy,
		    imgColors[button_images[imgstart+iy][imgsel+ix] - 'A'] );
	}
    }

    /*
     * Copy onto our target drawable surface.
     */

    memset(&gcValues, 0, sizeof(gcValues));
    gcValues.background = bg_brdr->bgColorPtr->pixel;
    gcValues.graphics_exposures = False;
    copyGC = Tk_GetGC(tkwin, 0, &gcValues);

    XPutImage(display, pixmap, copyGC, img, 0, 0, 0, 0,
	    (unsigned int)dim, (unsigned int)dim);
    XCopyArea(display, pixmap, d, copyGC, 0, 0,
	    (unsigned int)dim, (unsigned int)dim, x, y);

    /*
     * Tidy up.
     */

    Tk_FreeGC(display, copyGC);
    XDestroyImage(img);
    Tk_FreePixmap(display, pixmap);
}
예제 #29
0
static Bool
GradientLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
	       Pixmap *pixmap_return, Pixmap *mask_return,
	       Dimension *width_return, Dimension *height_return)
{
  double ired, igreen, iblue, red, green, blue;
  XColor start, end, color;
  XGCValues values;
  GC gc;
  double i, inc, x, y, xend, yend;
  Pixmap pixmap;
  XawArgVal *argval;
  int orientation, dimension, steps;
  char *value;

  if (XmuCompareISOLatin1(params->name, "vertical") == 0)
    orientation = VERTICAL;
  else if (XmuCompareISOLatin1(params->name, "horizontal") == 0)
    orientation = HORIZONTAL;
  else
    return (False);

  if ((argval = XawFindArgVal(params, "dimension")) != NULL
      && argval->value)
    {
      dimension = atoi(argval->value);
      if (dimension <= 0)
	return (False);
    }
  else
    dimension = 50;

  if ((argval = XawFindArgVal(params, "steps")) != NULL
      && argval->value)
    {
      steps = atoi(argval->value);
      if (steps <= 0)
	return (False);
    }
  else
      steps = dimension;

  steps = XawMin(steps, dimension);

  value = NULL;
  if ((argval = XawFindArgVal(params, "start")) != NULL)
    value = argval->value;
  if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
			    &start, &color))
    return (False);
  else if (!value)
    {
      start.pixel = WhitePixelOfScreen(screen);
      XQueryColor(DisplayOfScreen(screen), colormap, &start);
    }
  value = NULL;
  if ((argval = XawFindArgVal(params, "end")) != NULL)
    value = argval->value;
  if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
			    &end, &color))
    return (False);
  else if (!value)
    {
      end.pixel = BlackPixelOfScreen(screen);
      XQueryColor(DisplayOfScreen(screen), colormap, &end);
    }

  if ((pixmap = XCreatePixmap(DisplayOfScreen(screen),
			      RootWindowOfScreen(screen),
			      orientation == VERTICAL ? 1 : dimension,
			      orientation == VERTICAL ? dimension : 1, depth))
      == 0)
    return (False);

  ired   = (double)(end.red   - start.red)   / (double)steps;
  igreen = (double)(end.green - start.green) / (double)steps;
  iblue  = (double)(end.blue  - start.blue)  / (double)steps;

  red   = color.red   = start.red;
  green = color.green = start.green;
  blue  = color.blue  = start.blue;

  inc = (double)dimension / (double)steps;

  gc = XCreateGC(DisplayOfScreen(screen), pixmap, 0, &values);

  x = y = 0.0;
  if (orientation == VERTICAL)
    {
      xend = 1;
      yend = 0;
    }
  else
    {
      xend = 0;
      yend = 1;
    }

  color.flags = DoRed | DoGreen | DoBlue;

  XSetForeground(DisplayOfScreen(screen), gc, start.pixel);
  for (i = 0.0; i < dimension; i += inc)
    {
      if ((int)color.red != (int)red || (int)color.green != (int)green
	  || (int)color.blue != (int)blue)
	{
	  XFillRectangle(DisplayOfScreen(screen), pixmap, gc, (int)x, (int)y,
			 (unsigned int)xend, (unsigned int)yend);
	  color.red   = (unsigned short)red;
	  color.green = (unsigned short)green;
	  color.blue  = (unsigned short)blue;
	  if (!XAllocColor(DisplayOfScreen(screen), colormap, &color))
	    {
	      XFreePixmap(DisplayOfScreen(screen), pixmap);
	      return (False);
	    }
	  XSetForeground(DisplayOfScreen(screen), gc, color.pixel);
	  if (orientation == VERTICAL)
	    y = yend;
	  else
	    x = xend;
	}
      red   += ired;
      green += igreen;
      blue  += iblue;
      if (orientation == VERTICAL)
	yend += inc;
      else
	xend += inc;
    }
  XFillRectangle(DisplayOfScreen(screen), pixmap, gc, (int)x, (int)y,
		 (unsigned int)xend, (unsigned int)yend);

  *pixmap_return = pixmap;
  *mask_return = None;
  *width_return = orientation == VERTICAL ? 1 : dimension;
  *height_return = orientation == VERTICAL ? dimension : 1;

  XFreeGC(DisplayOfScreen(screen), gc);

  return (True);
}
예제 #30
0
static Bool
BitmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
	     Pixmap *pixmap_return, Pixmap *mask_return,
	     Dimension *width_return, Dimension *height_return)
{
  Pixel fg, bg;
  XColor color, exact;
  Pixmap pixmap;
  unsigned int width, height;
  unsigned char *data = NULL;
  int hotX, hotY;
  XawArgVal *argval;
  Bool retval = False;
  static SubstitutionRec sub[] = {
    {'H',   NULL},
    {'N',   NULL},
    {'T',   "bitmaps"},
    {'P',   PROJECT_ROOT},
  };
  char *filename;

  fg = BlackPixelOfScreen(screen);
  bg = WhitePixelOfScreen(screen);

  if ((argval = XawFindArgVal(params, "foreground")) != NULL
      && argval->value)
    {
      if (XAllocNamedColor(DisplayOfScreen(screen), colormap, argval->value,
			   &color, &exact))
	fg = color.pixel;
      else
	return (False);
    }
  if ((argval = XawFindArgVal(params, "background")) != NULL
      && argval->value)
    {
      if (XAllocNamedColor(DisplayOfScreen(screen), colormap, argval->value,
			   &color, &exact))
	bg = color.pixel;
      else
	return (False);
    }

  if (params->name[0] != '/' && params->name[0] != '.')
    {
      if (!sub[0].substitution)
	#ifdef _MSC_VER
	sub[0].substitution = ".";
	#else
	sub[0].substitution = getenv("HOME");
	#endif
      sub[1].substitution = params->name;
      if (pixmap_path == NULL)
	GetResourcePixmapPath(DisplayOfScreen(screen));
      filename = XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
      if (!filename)
	return (FALSE);
    }
  else
    filename = params->name;

  if (XReadBitmapFileData(filename, &width, &height, &data,
			  &hotX, &hotY) == BitmapSuccess)
    {
      pixmap = XCreatePixmapFromBitmapData(DisplayOfScreen(screen),
					   RootWindowOfScreen(screen),
					   (char *)data,
					   width, height, fg, bg, depth);
      if (data)
	XFree(data);
      *pixmap_return = pixmap;
      *mask_return = None;
      *width_return = width;
      *height_return = height;

      retval = True;
    }

  if (filename != params->name)
    XtFree(filename);

  return (retval);
}