您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DefaultDepth函数代码示例

51自学网 2021-06-01 20:26:03
  C++
这篇教程C++ DefaultDepth函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中DefaultDepth函数的典型用法代码示例。如果您正苦于以下问题:C++ DefaultDepth函数的具体用法?C++ DefaultDepth怎么用?C++ DefaultDepth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了DefaultDepth函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mume_x11_create_window

Window mume_x11_create_window(    Display *display, int type, Window parent,    int x, int y, unsigned int width, unsigned int height,    unsigned int clazz, int eventmask){    int screen;    int depth;    Visual *visual;    unsigned long valuemask;    XSetWindowAttributes attributes;    XSizeHints *size_hints;    XWMHints *wm_hints;    XClassHint *class_hints;    Window window;    screen = DefaultScreen(display);    visual = DefaultVisual(display, screen);    if (clazz != InputOnly) {        depth = DefaultDepth(display, screen);        valuemask = CWBackPixel | CWBorderPixel;        attributes.background_pixel = WhitePixel(display, screen);        attributes.border_pixel = BlackPixel(display, screen);        if (MUME_BACKWIN_MENU == type) {            assert(RootWindow(display, screen) == parent);            valuemask |= CWSaveUnder | CWOverrideRedirect;            attributes.save_under = True;            attributes.override_redirect = True;        }    }    else {        depth = 0;        valuemask = 0;    }    if (None == parent)        parent = RootWindow(display, screen);    window = XCreateWindow(        display, parent, x, y, width, height, 0, depth,        clazz, visual, valuemask, &attributes);    if (clazz != InputOnly) {        /* Setup standard properties. */        if (!(size_hints = XAllocSizeHints()))            mume_abort(("allocating memory failed!/n"));        if (!(wm_hints = XAllocWMHints()))            mume_abort(("allocating memory failed!/n"));        if (!(class_hints = XAllocClassHint()))            mume_abort(("allocating memory failed!/n"));        size_hints->flags = PPosition | PSize | PMinSize;        size_hints->min_width = 0;        size_hints->min_height = 0;        wm_hints->initial_state = NormalState;        wm_hints->input = True;        /* wm_hints->icon_pixmap = icon_pixmap; */        wm_hints->flags = StateHint/* | IconPixmapHint*/ | InputHint;        class_hints->res_name = "mume";        class_hints->res_class = "mume";        /* or use XSizeHints, XSetClassHint, XSetWMHints */        XmbSetWMProperties(display, window, "mume", "mume",                           NULL, 0, size_hints, wm_hints, class_hints);        XFree(wm_hints);        XFree(class_hints);        XFree(size_hints);    }    /* Select event */    XSelectInput(display, window, eventmask);    return window;}
开发者ID:tomnotcat,项目名称:mume,代码行数:79,


示例2: main

int main(int ac, char **av){    Display *xDpy = XOpenDisplay(NULL);    int screenId;    GC gc;    XGCValues values;    Pixmap blendPixmap;    vertexDataRec warpData[6];    int nvDpyId;    if (!xDpy) {        fprintf (stderr, "Could not open X Display %s!/n", XDisplayName(NULL));        return 1;    }    screenId = XDefaultScreen(xDpy);    if (ac != 2) {        fprintf (stderr, "Usage: ./nv-control-warpblend nvDpyId/n");        fprintf (stderr, "See 'nvidia-settings -q CurrentMetaMode' for currently connected DPYs./n");        return 1;    }    nvDpyId = atoi(av[1]);    // Start with two screen-aligned triangles, and warp them using the sample    // keystone matrix in transformPoint. Make sure we save W for correct    // perspective and pass it through as the last texture coordinate component.    warpData[0].pos.x = 0.0f;    warpData[0].pos.y = 0.0f;    warpData[0].tex.x = 0.0f;    warpData[0].tex.y = 0.0f;    warpData[0].tex2.x = 0.0f;    warpData[0].tex2.y = transformPoint(&warpData[0].pos);    warpData[1].pos.x = 1.0f;    warpData[1].pos.y = 0.0f;    warpData[1].tex.x = 1.0f;    warpData[1].tex.y = 0.0f;    warpData[1].tex2.x = 0.0f;    warpData[1].tex2.y = transformPoint(&warpData[1].pos);    warpData[2].pos.x = 0.0f;    warpData[2].pos.y = 1.0f;    warpData[2].tex.x = 0.0f;    warpData[2].tex.y = 1.0f;    warpData[2].tex2.x = 0.0f;    warpData[2].tex2.y = transformPoint(&warpData[2].pos);    warpData[3].pos.x = 1.0f;    warpData[3].pos.y = 0.0f;    warpData[3].tex.x = 1.0f;    warpData[3].tex.y = 0.0f;    warpData[3].tex2.x = 0.0f;    warpData[3].tex2.y = transformPoint(&warpData[3].pos);    warpData[4].pos.x = 1.0f;    warpData[4].pos.y = 1.0f;    warpData[4].tex.x = 1.0f;    warpData[4].tex.y = 1.0f;    warpData[4].tex2.x = 0.0f;    warpData[4].tex2.y = transformPoint(&warpData[4].pos);    warpData[5].pos.x = 0.0f;    warpData[5].pos.y = 1.0f;    warpData[5].tex.x = 0.0f;    warpData[5].tex.y = 1.0f;    warpData[5].tex2.x = 0.0f;    warpData[5].tex2.y = transformPoint(&warpData[5].pos);    // Prime the random number generator, since the helper functions need it.    srand(time(NULL));    // Apply our transformed warp data to the chosen display.    XNVCTRLSetScanoutWarping(xDpy,                             screenId,                             nvDpyId,                             NV_CTRL_WARP_DATA_TYPE_MESH_TRIANGLES_XYUVRQ,                             6, // 6 vertices for two triangles                             (float *)warpData);    // Create a sample blending pixmap; let's make it solid white with a grey    // border and rely on upscaling with filtering to feather the edges.    // Start with a 32x32 pixmap.    blendPixmap = XCreatePixmap(xDpy, RootWindow(xDpy, screenId), 32, 32, DefaultDepth(xDpy, screenId));    values.foreground = 0x77777777;    gc = XCreateGC(xDpy, blendPixmap, GCForeground, &values);    // Fill it fully with grey.    XFillRectangle(xDpy, blendPixmap, gc, 0, 0, 32, 32);    values.foreground = 0xffffffff;    XChangeGC(xDpy, gc, GCForeground, &values);    // Fill everything but a one-pixel border with white.    XFillRectangle(xDpy, blendPixmap, gc, 1, 1, 30, 30);    // Apply it to the display. blendAfterWarp is FALSE, so the edges will be//.........这里部分代码省略.........
开发者ID:carbn,项目名称:nvidia-settings,代码行数:101,


示例3: alock_bg_shade_init

static int alock_bg_shade_init(const char* args, struct aXInfo* xinfo) {    char* color_name = strdup("black");    unsigned int shade = 80;    Pixmap src_pm = None;    Pixmap dst_pm = None;    int width = 0;    int height = 0;    if (!xinfo || !args)        return 0;    if (strstr(args, "shade:") == args && strlen(&args[6]) > 0) {        char* arguments = strdup(&args[6]);        char* tmp;        char* arg = NULL;        for (tmp = arguments; tmp; ) {            arg = strsep(&tmp, ",");            if (arg) {                if (strstr(arg, "color=") == arg && strlen(arg) > 6 && strlen(&arg[6])) {                    free(color_name);                    color_name = strdup(&arg[6]);                }                else if (strstr(arg, "shade=") == arg && strlen(arg) > 6 && strlen(&arg[6])) {                    long int tmp_shade;                    char* tmp_char;                    tmp_shade = strtol(&arg[6], &tmp_char, 0);                    if ((!tmp_shade || tmp_char != &arg[6]) && tmp_shade > 0 && tmp_shade < 100)                        shade = tmp_shade;                    else {                        printf("%s", "alock: error, given value invalid or out of range for [shade]./n");                        free(arguments);                        free(color_name);                        return 0;                    }                }            }        }        free(arguments);    }    if (!alock_check_xrender(xinfo)) {        free(color_name);        return 0;    }    {        window = (Window*)calloc(xinfo->nr_screens, sizeof(Window));        color = (XColor*)calloc(xinfo->nr_screens, sizeof(XColor));    }    {        int scr;        for (scr = 0; scr < xinfo->nr_screens; scr++) {            /* get a color from color_name */            alock_alloc_color(xinfo, scr, color_name, "black", &color[scr]);            width = xinfo->width_of_root[scr];            height = xinfo->height_of_root[scr];            { /* xrender stuff */                Display* dpy = xinfo->display;                Window root = xinfo->root[scr];                int depth = DefaultDepth(dpy, scr);                GC gc = DefaultGC(dpy, scr);                { /* grab whats on the screen */                    XImage* image = XGetImage(dpy, root, 0, 0, width, height, AllPlanes, ZPixmap);                    src_pm = XCreatePixmap(dpy, root, width, height, depth);                    XPutImage(dpy, src_pm, gc, image, 0, 0, 0, 0, width, height);                    XDestroyImage(image);                }                dst_pm = XCreatePixmap(dpy, root, width, height, depth);                { /* tint the dst*/                    GC tintgc;                    XGCValues tintval;                    tintval.foreground = color[scr].pixel;                    tintgc = XCreateGC(dpy, dst_pm, GCForeground, &tintval);                    XFillRectangle(dpy, dst_pm, tintgc, 0, 0, width, height);                    XFreeGC(dpy, tintgc);                }                alock_shade_pixmap(xinfo, scr, src_pm, dst_pm, shade, 0, 0, 0, 0, width, height);            }            { /* create final window */                XSetWindowAttributes xswa;                long xsmask = 0;                xswa.override_redirect = True;                xswa.colormap = xinfo->colormap[scr];                xswa.background_pixmap = dst_pm;                xsmask |= CWOverrideRedirect;//.........这里部分代码省略.........
开发者ID:alopatindev,项目名称:alock,代码行数:101,


示例4: setup

voidsetup(int topbar, const char *bg, unsigned int lines) {    int x = 0, y = 0; /* position of the window */    /* if (!dc) { */        dc = initdc();    /* } */    initfont(dc, font);    XInitThreads();    screen = DefaultScreen(dc->dpy);    Window root = RootWindow(dc->dpy, screen);    XSetWindowAttributes swa;    XIM xim;#ifdef XINERAMA    int n;    XineramaScreenInfo *info;#endif    clip = XInternAtom(dc->dpy, "CLIPBOARD",   False);    utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);    /* calculate menu geometry */    bh = dc->font.height + 2;    lines = MAX(lines, 0);    mh = (lines + 1) * bh;#ifdef XINERAMA    if((info = XineramaQueryScreens(dc->dpy, &n))) {        int a, j, di, i = 0, area = 0;        unsigned int du;        Window w, pw, dw, *dws;        XWindowAttributes wa;        XGetInputFocus(dc->dpy, &w, &di);        if(w != root && w != PointerRoot && w != None) {            /* find top-level window containing current input focus */            do {                if(XQueryTree(dc->dpy, (pw = w), &dw, &w, &dws, &du) && dws)                    XFree(dws);            } while(w != root && w != pw);            /* find xinerama screen with which the window intersects most */            if(XGetWindowAttributes(dc->dpy, pw, &wa))                for(j = 0; j < n; j++)                    if((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {                        area = a;                        i = j;                    }        }        /* no focused window is on screen, so use pointer location instead */        if(!area && XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du))            for(i = 0; i < n; i++)                if(INTERSECT(x, y, 1, 1, info[i]))                    break;        x = info[i].x_org;        y = info[i].y_org + (topbar ? 0 : info[i].height - mh);        mw = info[i].width;        XFree(info);    }    else#endif    {        x = 0;        y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh;        mw = DisplayWidth(dc->dpy, screen);    }    /* create menu window */    swa.override_redirect = True;    swa.background_pixel = getcolor(dc, bg);    swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;    win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0,            DefaultDepth(dc->dpy, screen), CopyFromParent,            DefaultVisual(dc->dpy, screen),            CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);    XResizeWindow(dc->dpy, win, mw, mh);    /* open input methods */    xim = XOpenIM(dc->dpy, NULL, NULL, NULL);    xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,            XNClientWindow, win, XNFocusWindow, win, NULL);    XMapRaised(dc->dpy, win);    resizedc(dc, mw, mh);    mapdc(dc, win, mw, mh);}
开发者ID:regnat,项目名称:dmlenu,代码行数:84,


示例5: value

XImage *xNewImage (Display *dpy         /* display pointer */, 		   unsigned long pmin   /* minimum pixel value (corresponding to byte=0) */, 		   unsigned long pmax   /* maximum pixel value (corresponding to byte=255) */,		   int width            /* number of bytes in x dimension */, 		   int height           /* number of bytes in y dimension */, 		   float blank          /* portion for blanking (0 to 1) */, 		   unsigned char *bytes /* unsigned bytes to be mapped to an image */)/*< make a new image of pixels from bytes >*//******************************************************************************Author:		Dave Hale, Colorado School of Mines, 06/08/90*****************************************************************************/{	int scr=DefaultScreen(dpy);	int i,j,k,line,iline,jline,widthpad;	float base,scale;	unsigned long map[256],bkgnd;	unsigned char *data;	int byte_perpixel;	unsigned int depth;	XImage *xim;		xim=(XImage *) NULL;	depth=(unsigned int)DefaultDepth(dpy,scr);		byte_perpixel=4;	if(depth<=8) byte_perpixel=1;	else if(depth<=16) byte_perpixel=2;/*	else if(depth<=24) byte_perpixel=3;*/	/* build map for translating bytes to pixels */	base = ((double) pmin)+0.499;	scale = ((double) (pmax-pmin))/255.0;	for (i=0; i<=255; ++i){		map[i] = base+i*scale;	}	/* blanking */	bkgnd = (unsigned long) WhitePixel(dpy,scr);	j = SF_MAX(0,SF_MIN(256,(int)(256*blank)));	for (i = 0; i < j; i++)		map[255-i] = bkgnd;	/* allocate memory for image data */	widthpad = (1+(width-1)/(BitmapPad(dpy)/8))*BitmapPad(dpy)/8;	data = (unsigned char*) sf_alloc(widthpad*height,byte_perpixel);	xim=XCreateImage(	(Display *) dpy,				(Visual *) DefaultVisual(dpy,scr),				(unsigned int) DefaultDepth(dpy,scr),				(int) ZPixmap,				(int) 0,				(char *) data,				(unsigned int) widthpad,				(unsigned int) height,/*				(int) BitmapPad(dpy),				(int) widthpad*byte_perpixel*/				8,0);	byte_perpixel=xim->bits_per_pixel/8;/*	fprintf(stderr,"/nbyte_perpixel = %d, depth= %d/n", byte_perpixel,depth); */	/* translate bytes to pixels, padding scanlines as necessary */	for (line=0; line<height; line++) {		iline = line*width;		jline = line*widthpad;		for (i=iline,j=jline,k=0; k<width; ++i,++j,++k)		{       if(byte_perpixel==1)			((unsigned char *)data)[j] =(unsigned char)map[bytes[i]];			if(byte_perpixel==2)			  {			    int edn=xim->byte_order;			    if(edn==LSBFirst){			      ((unsigned char *)data)[j*2+0] =(unsigned char)(truecolor_pixel[bytes[i]]);			      ((unsigned char *)data)[j*2+1] =(unsigned char)(truecolor_pixel[bytes[i]]>>8);			    }else{			      ((unsigned char *)data)[j*2+0] =(unsigned char)(truecolor_pixel[bytes[i]]>>24); 			      ((unsigned char *)data)[j*2+1] =(unsigned char)(truecolor_pixel[bytes[i]]>>16);			      }			    /*((unsigned short *)data)[j] =(unsigned short)(truecolor_pixel[bytes[i]]);*/			  }	
开发者ID:1014511134,项目名称:src,代码行数:84,


示例6: CGX_SetIcon

void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask){#if 0	SDL_Surface *sicon;	XWMHints *wmhints;	XImage *icon_image;	Pixmap icon_pixmap;	Pixmap mask_pixmap;#ifdef USE_ICON_WINDOW	Window icon_window;#endif	GC GC;	XGCValues GCvalues;	int i, b, dbpp;	SDL_Rect bounds;	Uint8 *LSBmask, *color_tried;	Visual *dvis;	/* Lock the event thread, in multi-threading environments */	SDL_Lock_EventThread();	/* The icon must use the default visual, depth and colormap of the	   screen, so it might need a conversion */	dbpp = DefaultDepth(SDL_Display, SDL_Screen);	switch(dbpp) {	case 15:	    dbpp = 16; break;	case 24:	    dbpp = 32; break;	}	dvis = DefaultVisual(SDL_Display, SDL_Screen);	/* The Visual struct is supposed to be opaque but we cheat a little */	sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,				     dbpp,				     dvis->red_mask, dvis->green_mask,				     dvis->blue_mask, 0);	if ( sicon == NULL ) {		goto done;	}	/* If we already have allocated colours from the default colormap,	   copy them */	if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap	   && this->screen->format->palette && sicon->format->palette) {	    memcpy(sicon->format->palette->colors,		   this->screen->format->palette->colors,		   this->screen->format->palette->ncolors * sizeof(SDL_Color));	}	bounds.x = 0;	bounds.y = 0;	bounds.w = icon->w;	bounds.h = icon->h;	if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 )		goto done;	/* Lock down the colors used in the colormap */	color_tried = NULL;	if ( sicon->format->BitsPerPixel == 8 ) {		SDL_Palette *palette;		Uint8 *p;		XColor wanted;		palette = sicon->format->palette;		color_tried = malloc(palette->ncolors);		if ( color_tried == NULL ) {			goto done;		}		if ( SDL_iconcolors != NULL ) {			free(SDL_iconcolors);		}		SDL_iconcolors = malloc(palette->ncolors					* sizeof(*SDL_iconcolors));		if ( SDL_iconcolors == NULL ) {			free(color_tried);			goto done;		}		memset(color_tried, 0, palette->ncolors);		memset(SDL_iconcolors, 0,		       palette->ncolors * sizeof(*SDL_iconcolors));		p = (Uint8 *)sicon->pixels; 		for ( i = sicon->w*sicon->h; i > 0; --i, ++p ) {			if ( ! color_tried[*p] ) {				wanted.pixel = *p;				wanted.red   = (palette->colors[*p].r<<8);				wanted.green = (palette->colors[*p].g<<8);				wanted.blue  = (palette->colors[*p].b<<8);				wanted.flags = (DoRed|DoGreen|DoBlue);				if (XAllocColor(SDL_Display,						SDL_DisplayColormap, &wanted)) {					++SDL_iconcolors[wanted.pixel];				}				color_tried[*p] = 1;			}		}	}	if ( color_tried != NULL ) {		free(color_tried);//.........这里部分代码省略.........
开发者ID:johntalbain28,项目名称:Stepmania-AMX,代码行数:101,


示例7: SilChessMachine

XSilChessWindow::XSilChessWindow(XtAppContext app, Widget toplevel,                                 Visual * vsl, int vsldepth, Colormap cmap){	char tmp[512];	Arg al[10];	int i;	XmString xms;	// Initialize member variables	App=app;	TopLevel=toplevel;	Disp=XtDisplay(TopLevel);	Vsl=vsl;	VslDepth=vsldepth;	CMap=cmap;	DlgVsl=DefaultVisual(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));	DlgVslDepth=DefaultDepth(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));	DlgCMap=DefaultColormap(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));	PixelSize=(VslDepth<=8 ? 1 : (VslDepth<=16 ? 2 : 4));	RedMask=Vsl->red_mask;	GreenMask=Vsl->green_mask;	BlueMask=Vsl->blue_mask;	SelX=SelY-1;	IsSearching=false;	AbortSearching=false;	NeedPainting=false;	IsPainting=false;	HintWanted=false;	HintValid=false;	// Create main window	MainWin=XtVaCreateManagedWidget(		"mainWin",xmMainWindowWidgetClass,TopLevel,		(char*)NULL	);	// Create main menu bar	MainMenu=XmCreateMenuBar(MainWin,(char*)"mainMenu",NULL,0);	XtManageChild(MainMenu);	// Create menu item: file	XtSetArg(al[0],XmNvisual,Vsl);	XtSetArg(al[1],XmNdepth,VslDepth);	XtSetArg(al[2],XmNcolormap,CMap);	FileMenu=XmCreatePulldownMenu(MainMenu,(char*)"fileMenu",al,3);	BFile=XtVaCreateManagedWidget(		"file",xmCascadeButtonWidgetClass,MainMenu,		XmNsubMenuId,FileMenu,		(char*)NULL	);	// Create menu item: file/load	BFileLoad=XtVaCreateManagedWidget(		"load",xmPushButtonWidgetClass,FileMenu,		(char*)NULL	);	XtAddCallback(BFileLoad,XmNactivateCallback,HandleCallback,this);	// Create menu item: file/save	BFileSave=XtVaCreateManagedWidget(		"save",xmPushButtonWidgetClass,FileMenu,		(char*)NULL	);	XtAddCallback(BFileSave,XmNactivateCallback,HandleCallback,this);	// Create menu item: file/exit	XtVaCreateManagedWidget(		"separator",xmSeparatorWidgetClass,FileMenu,		(char*)NULL	);	BFileExit=XtVaCreateManagedWidget(		"exit",xmPushButtonWidgetClass,FileMenu,		(char*)NULL	);	XtAddCallback(BFileExit,XmNactivateCallback,HandleCallback,this);	// Create menu item: game	XtSetArg(al[0],XmNvisual,Vsl);	XtSetArg(al[1],XmNdepth,VslDepth);	XtSetArg(al[2],XmNcolormap,CMap);	GameMenu=XmCreatePulldownMenu(MainMenu,(char*)"gameMenu",al,3);	BGame=XtVaCreateManagedWidget(		"game",xmCascadeButtonWidgetClass,MainMenu,		XmNsubMenuId,GameMenu,		(char*)NULL	);	// Create menu item: game/new	BGameNew=XtVaCreateManagedWidget(		"new",xmPushButtonWidgetClass,GameMenu,		(char*)NULL	);	XtAddCallback(BGameNew,XmNactivateCallback,HandleCallback,this);	// Create menu item: game/flip	BGameFlip=XtVaCreateManagedWidget(		"flip",xmPushButtonWidgetClass,GameMenu,		(char*)NULL	);	XtAddCallback(BGameFlip,XmNactivateCallback,HandleCallback,this);//.........这里部分代码省略.........
开发者ID:ackalker,项目名称:eaglemode,代码行数:101,


示例8: lockscreen

static Lock *lockscreen(Display *dpy, int screen) {	char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};	unsigned int len;	Lock *lock;	XColor color;	XSetWindowAttributes wa;	Cursor invisible;	int hue1, hue2;	if(dpy == NULL || screen < 0)		return NULL;	lock = malloc(sizeof(Lock));	if(lock == NULL)		return NULL;	lock->screen = screen;	lock->root = RootWindow(dpy, lock->screen);	/* init */	wa.override_redirect = 1;	lock->win = XCreateWindow(dpy, lock->root, 0, 0, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen),			0, DefaultDepth(dpy, lock->screen), CopyFromParent,			DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa);		/* locked color */	hue1 = rand() % 360;	gen_random_pastel(&color, hue1);	XAllocColor(dpy, DefaultColormap(dpy, lock->screen), &color);	lock->colors[0] = color.pixel;	XSetWindowBackground(dpy, lock->win, lock->colors[0]);		/* trying to unlock color */	hue2 = hue1 + 180;	if (hue2 >= 360) {		hue2 -= 360;	}	gen_random_pastel(&color, hue2);	XAllocColor(dpy, DefaultColormap(dpy, lock->screen), &color);	lock->colors[1] = color.pixel;		lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);	invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);	XDefineCursor(dpy, lock->win, invisible);	XMapRaised(dpy, lock->win);	for(len = 1000; len; len--) {		if(XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,			GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)			break;		usleep(1000);	}	if(running && (len > 0)) {		for(len = 1000; len; len--) {			if(XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime)				== GrabSuccess)				break;			usleep(1000);		}	}	running &= (len > 0);	if(!running) {		unlockscreen(dpy, lock);		lock = NULL;	}	else 		XSelectInput(dpy, lock->root, SubstructureNotifyMask);	return lock;}
开发者ID:eepp,项目名称:slock,代码行数:71,


示例9: Init_X

int Init_X (int swidth, int sheight){    XGCValues vals;    Colormap TheColormap;    XColor TheColor;    int i;    TheWidth = swidth ;    TheHeight = sheight ;    TheDisplay = XOpenDisplay("/0");    TheRootWindow = DefaultRootWindow(TheDisplay);    TheScreenNumber = DefaultScreen(TheDisplay);     TheDepth = DefaultDepth(TheDisplay, TheScreenNumber);    if (TheDepth != 24) {      printf("24 bit color not supported./n") ;      printf("Color function not likely to work./n") ;    }    TheWindow = XCreateSimpleWindow(TheDisplay, TheRootWindow,                        0, 0, TheWidth, TheHeight, 0, 0, 0);    if (!TheWindow) return 0 ;    ThePixmap = XCreatePixmap(TheDisplay, TheRootWindow, TheWidth, TheHeight, 				TheDepth);    if (!ThePixmap) return 0 ;    TheDrawable = ThePixmap;        XMapWindow(TheDisplay, TheWindow);    XSelectInput(TheDisplay, TheWindow, ExposureMask |					StructureNotifyMask |					PointerMotionMask | 					ButtonPressMask |					KeyPressMask );    /*    TheWindowContext = XCreateGC(TheDisplay, TheWindow, 0, 0);    // this is a bad idea ... see test t02.c for an example    // of what can happen to the behavior of the event handler,    //       int Handle_Events_X(int *px, int *py)    // if you do this, you'll get runaway calls to Handle_Events    // with the default condition being met and this produces    // a great deal of tearing in the animation of t02.c    */    /* also a bad idea...same behavior as above    vals.graphics_exposures = 1; // True    */    // so this is what you want :    vals.graphics_exposures = 0; // False    TheWindowContext = XCreateGC(TheDisplay, TheWindow,                                 GCGraphicsExposures, &vals);    if (!TheWindowContext) return 0;    ThePixmapContext = XCreateGC(TheDisplay, ThePixmap, 0, 0);    if (!ThePixmapContext) return 0;    TheColormap = DefaultColormap(TheDisplay, TheScreenNumber);    for(i = 0; i < 256; i++) {	TheColor.green = TheColor.blue = TheColor.red = (i << 8) | i;	TheColor.flags = DoRed | DoGreen | DoBlue;	XAllocColor(TheDisplay, TheColormap, &TheColor);	Grays[i] = TheColor.pixel;    }     TheFontInfo = XLoadQueryFont(TheDisplay, TheFont) ;    XSetFont(TheDisplay, TheWindowContext, TheFontInfo->fid) ;    //   XClearWindow(TheDisplay, TheWindow);    //   XClearArea(TheDisplay, TheWindow, 0,0,0,0,False); // same as above    XClearArea(TheDisplay, TheWindow, 0,0,0,0,True);                   // Does the boolean matter here?    // most people expect a white piece of paper    // with a black pencil    Set_Color_Rgb_X (255,255,255) ; // white    Clear_Buffer_X() ; // otherwise you can inherit garbage    // from the parent window    //    Set_Color_Rgb_X (255,0,255) ; // purple    //    Fill_Rectangle_X(10,10,50,80) ;    // above was just a test//.........这里部分代码省略.........
开发者ID:javins,项目名称:fpt,代码行数:101,


示例10: WPwcic

        short    WPwcic(        Window   px_id,        short    x,        short    y,        short    bw,        char    *fnam,        short    cb,        short    cf,        WPICON **outptr)/*      Create WPICON. * *      In: px_id  = Parent window X-id. *          x      = X-position. *          y      = Y-position. *          fnam   = Pixmap file. *          cb     = Not used. *          cf     = Not used. * *      Ut: *outptr = Ptr to a WPICON. * *      Felkod: WP1212 = Can't load pixmap file %s *              WP1292 = Can't malloc() *              WP1712 = XPM error code = %s * *      (C)microform ab 13/1/94 J. Kjellander * *      2007-06-17 Xpm, J.Kjellander * ********************************************************/  {    char                 errbuf[V3STRLEN];    XSetWindowAttributes xwina;    unsigned long        xwinm;    unsigned int         dx,dy;    int                  status;    Window               xwin_id;    Pixmap               icon_pixmap,icon_mask;    XGCValues            values;    XpmAttributes        attributes;    WPICON              *icoptr;/****Read the xpm-file and create a pixmap. Set attributes to XpmSize so***that the size of the icon is returned.***XpmColorError  =  1***XpmSuccess     =  0***XpmOpenFailed  = -1***XpmFileInvalid = -2***XpmNoMemory    = -3***XpmColorFailed = -4*/    attributes.valuemask = XpmSize;    status = XpmReadFileToPixmap(xdisp,px_id,fnam,&icon_pixmap,&icon_mask,&attributes);    if ( status != XpmSuccess )      {      sprintf(errbuf,"%d",status);      erpush("WP1712",errbuf);      return(erpush("WP1212",fnam));      }    dx = attributes.width;    dy = attributes.height;/****Create the X window.*/    xwina.background_pixel  = WPgcol(cb);    xwina.border_pixel      = WPgcol(WP_BGND2);    xwina.override_redirect = True;    xwina.save_under        = False;    xwinm = ( CWBackPixel        | CWBorderPixel |              CWOverrideRedirect | CWSaveUnder );      if ( bw > 0 )      {      dx += 2*bw + 2;      dy += 2*bw + 2;      }    xwin_id = XCreateWindow(xdisp,px_id,x,y,dx,dy,bw,                            DefaultDepth(xdisp,xscr),                            InputOutput,CopyFromParent,xwinm,&xwina);/****Input events.*/    if ( bw > 0 ) XSelectInput(xdisp,xwin_id,ButtonPressMask   |                                             ButtonReleaseMask |                                             EnterWindowMask   |                                             LeaveWindowMask);/****Create a WPICON.*/    if ( (icoptr=(WPICON *)v3mall(sizeof(WPICON),"WPwcic")) == NULL )       return(erpush("WP1292",fnam));    icoptr->id.w_id = (wpw_id)NULL;//.........这里部分代码省略.........
开发者ID:mildred,项目名称:Varkon,代码行数:101,


示例11: X11_SetupWindow

/* * Setup X11 wnd System */voidX11_SetupWindow (GF_VideoOutput * vout){	X11VID ();	const char *sOpt;        Bool autorepeat, supported;	xWindow->display = XOpenDisplay (NULL);	xWindow->screennum = DefaultScreen (xWindow->display);	xWindow->screenptr = DefaultScreenOfDisplay (xWindow->display);	xWindow->visual = DefaultVisualOfScreen (xWindow->screenptr);	xWindow->depth = DefaultDepth (xWindow->display, xWindow->screennum);	{		Float screenWidth = (Float)XWidthOfScreen(xWindow->screenptr);		Float screenWidthIn = (Float)XWidthMMOfScreen(xWindow->screenptr) / 25.4f;		Float screenHeight = (Float)XHeightOfScreen(xWindow->screenptr);		Float screenHeightIn = (Float)XHeightMMOfScreen(xWindow->screenptr) / 25.4f;		vout->dpi_x = (u32)(screenWidth / screenWidthIn);		vout->dpi_y = (u32)(screenHeight / screenHeightIn);	}	switch (xWindow->depth) {	case 8:		xWindow->pixel_format = GF_PIXEL_GREYSCALE;		break;	case 16:		xWindow->pixel_format = GF_PIXEL_RGB_565;		break;	case 24:		xWindow->pixel_format = GF_PIXEL_RGB_32;		break;	default:		xWindow->pixel_format = GF_PIXEL_GREYSCALE;		break;	}	xWindow->bpp = xWindow->depth / 8;	xWindow->bpp = xWindow->bpp == 3 ? 4 : xWindow->bpp;xWindow->screennum=0;	vout->max_screen_width = DisplayWidth(xWindow->display, xWindow->screennum);	vout->max_screen_height = DisplayHeight(xWindow->display, xWindow->screennum);	/*	 * Full screen wnd	 */	xWindow->full_wnd = XCreateWindow (xWindow->display,								   RootWindowOfScreen (xWindow->screenptr),								   0, 0,								   vout->max_screen_width,								   vout->max_screen_height, 0,								   xWindow->depth, InputOutput,								   xWindow->visual, 0, NULL);	XSelectInput(xWindow->display, xWindow->full_wnd,					FocusChangeMask | ExposureMask | PointerMotionMask | ButtonReleaseMask | ButtonPressMask | KeyPressMask | KeyReleaseMask);	if (!xWindow->par_wnd) {		xWindow->w_width = 320;		xWindow->w_height = 240;		xWindow->wnd = XCreateWindow (xWindow->display,					   RootWindowOfScreen(xWindow->screenptr), 0, 0,					   xWindow->w_width, xWindow->w_height, 0,					   xWindow->depth, InputOutput,					   xWindow->visual, 0, NULL);		XMapWindow (xWindow->display, (Window) xWindow->wnd);	} else {		XWindowAttributes pwa;		XGetWindowAttributes(xWindow->display, xWindow->par_wnd, &pwa);		xWindow->w_width = pwa.width;		xWindow->w_height = pwa.height;		xWindow->wnd = XCreateWindow (xWindow->display, xWindow->par_wnd, pwa.x, pwa.y,					xWindow->w_width, xWindow->w_height, 0,					   xWindow->depth, InputOutput,					   xWindow->visual, 0, NULL);		XMapWindow (xWindow->display, (Window) xWindow->wnd);	}	XSync(xWindow->display, False);	XUnmapWindow (xWindow->display, (Window) xWindow->wnd);	XSync(xWindow->display, False);	old_handler = XSetErrorHandler(X11_BadAccess_ByPass);	selectinput_err = 0;	XSelectInput(xWindow->display, xWindow->wnd,		FocusChangeMask | StructureNotifyMask | PropertyChangeMask | ExposureMask |		PointerMotionMask | ButtonReleaseMask | ButtonPressMask |		KeyPressMask | KeyReleaseMask);	XSync(xWindow->display, False);	XSetErrorHandler(old_handler);	if (selectinput_err) {	       	XSelectInput(xWindow->display, xWindow->wnd,			StructureNotifyMask | PropertyChangeMask | ExposureMask |			KeyPressMask | KeyReleaseMask);		GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("[X11] Cannot select input focus/n"));	}	XSync(xWindow->display, False);	XMapWindow (xWindow->display, (Window) xWindow->wnd);//.........这里部分代码省略.........
开发者ID:erelh,项目名称:gpac,代码行数:101,


示例12: read_ppm_file

XImage *read_ppm_file(Display *disp, Colormap cmap, int depth, IOSTREAM *fd){ XImage *img;  long here = Stell(fd);  int c;  int fmt, encoding;  int width, height, bytes_per_line, scale=0;  char *data;  int allocdepth;  int pad = XBitmapPad(disp);  Visual *v = DefaultVisual(disp, DefaultScreen(disp));  ncolours = nmapped = nfailed = 0;	/* statistics */  assert(pad%8 == 0);  if ( (c=Sgetc(fd)) != 'P' )  { Sungetc(c, fd);    return NULL;  }  if ( !cmap )    cmap = DefaultColormap(disp, DefaultScreen(disp));  c = Sgetc(fd);  if ( c < '1' || c > '9' )    goto errout;  c -= '0';  fmt      = ((c - 1) % 3) + 1;  encoding = c - fmt;  width = getNum(fd);  height = getNum(fd);  if ( fmt == PNM_PBM )  { depth = 1;  } else  { scale = getNum(fd);    if ( !depth )      depth = DefaultDepth(disp, DefaultScreen(disp));  }  if ( width < 0 || height < 0 || scale < 0 )    goto errout;  allocdepth = (depth >= 24 ? 32 : depth);  bytes_per_line = roundup((width*allocdepth+7)/8, pad/8);  data = (char *)pceMalloc(height * bytes_per_line);  img = XCreateImage(disp,		     v,		     depth,		     fmt == PNM_PBM ? XYBitmap : ZPixmap,		     0,		     data,		     width, height,		     pad, bytes_per_line);  if ( !img )  { perror("XCreateImage");    pceFree(data);    goto errout;  }  img->bits_per_pixel = depth;  switch(encoding)  { int x, y;    case PNM_ASCII:    { switch(fmt)      { case PNM_PBM:	  for(y=0; y<height; y++)	  { for(x=0; x<width; x++)	    { int value = getNum(fd);	      if ( value < 0 || value > 1 )		goto errout;	      XPutPixel(img, x, y, value);	    }	  }	  break;	case PNM_PGM:	{ Table t = newTable(64);	  for(y=0; y<height; y++)	  { for(x=0; x<width; x++)	    { int g = getNum(fd);	      unsigned long pixel;	      if ( g < 0 || g > scale )		goto errout;	      if ( scale != 255 )		g = rescale(g, scale, 255);	      pixel = colourPixel(disp, depth, cmap, t, g, g, g);	      XPutPixel(img, x, y, pixel);	    }	  }	  freeTable(t);	  break;//.........这里部分代码省略.........
开发者ID:brayc0,项目名称:nlfetdb,代码行数:101,


示例13: int

bool GlxBackend::initDrawableConfigs(){    const int attribs[] = {        GLX_RENDER_TYPE,    GLX_RGBA_BIT,        GLX_DRAWABLE_TYPE,  GLX_WINDOW_BIT | GLX_PIXMAP_BIT,        GLX_X_VISUAL_TYPE,  GLX_TRUE_COLOR,        GLX_X_RENDERABLE,   True,        GLX_CONFIG_CAVEAT,  int(GLX_DONT_CARE), // The ARGB32 visual is marked non-conformant in Catalyst        GLX_RED_SIZE,       5,        GLX_GREEN_SIZE,     5,        GLX_BLUE_SIZE,      5,        GLX_ALPHA_SIZE,     0,        GLX_STENCIL_SIZE,   0,        GLX_DEPTH_SIZE,     0,        0    };    int count = 0;    GLXFBConfig *configs = glXChooseFBConfig(display(), DefaultScreen(display()), attribs, &count);    if (count < 1) {        qCritical() << "Could not find any usable framebuffer configurations.";        return false;    }    for (int i = 0; i <= 32; i++) {        fbcdrawableinfo[i].fbconfig            = NULL;        fbcdrawableinfo[i].bind_texture_format = 0;        fbcdrawableinfo[i].texture_targets     = 0;        fbcdrawableinfo[i].y_inverted          = 0;        fbcdrawableinfo[i].mipmap              = 0;    }    // Find the first usable framebuffer configuration for each depth.    // Single-buffered ones will appear first in the list.    const int depths[] = { 15, 16, 24, 30, 32 };    for (unsigned int i = 0; i < sizeof(depths) / sizeof(depths[0]); i++) {        const int depth = depths[i];        for (int j = 0; j < count; j++) {            int alpha_size, buffer_size;            glXGetFBConfigAttrib(display(), configs[j], GLX_ALPHA_SIZE,  &alpha_size);            glXGetFBConfigAttrib(display(), configs[j], GLX_BUFFER_SIZE, &buffer_size);            if (buffer_size != depth && (buffer_size - alpha_size) != depth)                continue;            if (depth == 32 && alpha_size != 8)                continue;            XVisualInfo *vi = glXGetVisualFromFBConfig(display(), configs[j]);            if (vi == NULL)                continue;            int visual_depth = vi->depth;            XFree(vi);            if (visual_depth != depth)                continue;            int bind_rgb, bind_rgba;            glXGetFBConfigAttrib(display(), configs[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &bind_rgba);            glXGetFBConfigAttrib(display(), configs[j], GLX_BIND_TO_TEXTURE_RGB_EXT,  &bind_rgb);            // Skip this config if it cannot be bound to a texture            if (!bind_rgb && !bind_rgba)                continue;            int texture_format;            if (depth == 32)                texture_format = bind_rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT;            else                texture_format = bind_rgb ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT;            int y_inverted, texture_targets;            glXGetFBConfigAttrib(display(), configs[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &texture_targets);            glXGetFBConfigAttrib(display(), configs[j], GLX_Y_INVERTED_EXT, &y_inverted);            fbcdrawableinfo[depth].fbconfig            = configs[j];            fbcdrawableinfo[depth].bind_texture_format = texture_format;            fbcdrawableinfo[depth].texture_targets     = texture_targets;            fbcdrawableinfo[depth].y_inverted          = y_inverted;            fbcdrawableinfo[depth].mipmap              = 0;            break;        }    }    if (count)        XFree(configs);    if (fbcdrawableinfo[DefaultDepth(display(), DefaultScreen(display()))].fbconfig == NULL) {        qCritical() << "Could not find a framebuffer configuration for the default depth.";        return false;    }    if (fbcdrawableinfo[32].fbconfig == NULL) {        qCritical() << "Could not find a framebuffer configuration for depth 32.";        return false;    }//.........这里部分代码省略.........
开发者ID:KDE,项目名称:kde-workspace,代码行数:101,


示例14: setup

static voidsetup(void){	int x, y;	XSetWindowAttributes swa;	XIM xim;#ifdef XINERAMA	XineramaScreenInfo *info;	Window w, pw, dw, *dws;	XWindowAttributes wa;	int a, j, di, n, i = 0, area = 0;	unsigned int du;#endif	/* init appearance */	scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);	scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);	scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);	scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);	scheme[SchemeOut].bg = drw_clr_create(drw, outbgcolor);	scheme[SchemeOut].fg = drw_clr_create(drw, outfgcolor);	clip = XInternAtom(dpy, "CLIPBOARD",   False);	utf8 = XInternAtom(dpy, "UTF8_STRING", False);	/* calculate menu geometry */	bh = drw->fonts[0]->h + 2;	lines = MAX(lines, 0);	mh = (lines + 1) * bh;#ifdef XINERAMA	if ((info = XineramaQueryScreens(dpy, &n))) {		XGetInputFocus(dpy, &w, &di);		if (mon != -1 && mon < n)			i = mon;		else if (w != root && w != PointerRoot && w != None) {			/* find top-level window containing current input focus */			do {				if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)					XFree(dws);			} while (w != root && w != pw);			/* find xinerama screen with which the window intersects most */			if (XGetWindowAttributes(dpy, pw, &wa))				for (j = 0; j < n; j++)					if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {						area = a;						i = j;					}		}		/* no focused window is on screen, so use pointer location instead */		if (mon == -1 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))			for (i = 0; i < n; i++)				if (INTERSECT(x, y, 1, 1, info[i]))					break;		x = info[i].x_org;		y = info[i].y_org + (topbar ? 0 : info[i].height - mh);		mw = info[i].width;		XFree(info);	} else#endif	{		x = 0;		y = topbar ? 0 : sh - mh;		mw = sw;	}	promptw = (prompt && *prompt) ? TEXTW(prompt) : 0;	inputw = MIN(inputw, mw/3);	fuzzymatch();	/* create menu window */	swa.override_redirect = True;	swa.background_pixel = scheme[SchemeNorm].bg->pix;	swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;	win = XCreateWindow(dpy, root, x, y, mw, mh, 0,	                    DefaultDepth(dpy, screen), CopyFromParent,	                    DefaultVisual(dpy, screen),	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);	/* open input methods */	xim = XOpenIM(dpy, NULL, NULL, NULL);	xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,	                XNClientWindow, win, XNFocusWindow, win, NULL);	XMapRaised(dpy, win);	drw_resize(drw, mw, mh);	drawmenu();}
开发者ID:laur89,项目名称:dotfiles,代码行数:87,


示例15: x11grab_read_header

/** * Initialize the x11 grab device demuxer (public device demuxer API). * * @param s1 Context from avformat core * @param ap Parameters from avformat core * @return <ul> *          <li>AVERROR(ENOMEM) no memory left</li> *          <li>AVERROR(EIO) other failure case</li> *          <li>0 success</li> *         </ul> */static intx11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap){    struct x11_grab *x11grab = s1->priv_data;    Display *dpy;    AVStream *st = NULL;    enum PixelFormat input_pixfmt;    XImage *image;    int x_off = 0;    int y_off = 0;    int screen;    int use_shm;    char *param, *offset;    int ret = 0;    AVRational framerate;    param = av_strdup(s1->filename);    offset = strchr(param, '+');    if (offset) {        sscanf(offset, "%d,%d", &x_off, &y_off);        x11grab->draw_mouse = !strstr(offset, "nomouse");        *offset= 0;    }    if ((ret = av_parse_video_size(&x11grab->width, &x11grab->height, x11grab->video_size)) < 0) {        av_log(s1, AV_LOG_ERROR, "Couldn't parse video size./n");        goto out;    }    if ((ret = av_parse_video_rate(&framerate, x11grab->framerate)) < 0) {        av_log(s1, AV_LOG_ERROR, "Could not parse framerate: %s./n", x11grab->framerate);        goto out;    }    av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d/n",           s1->filename, param, x_off, y_off, x11grab->width, x11grab->height);    dpy = XOpenDisplay(param);    if(!dpy) {        av_log(s1, AV_LOG_ERROR, "Could not open X display./n");        ret = AVERROR(EIO);        goto out;    }    st = avformat_new_stream(s1, NULL);    if (!st) {        ret = AVERROR(ENOMEM);        goto out;    }    av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */    screen = DefaultScreen(dpy);    if (x11grab->follow_mouse) {        int screen_w, screen_h;        Window w;        screen_w = DisplayWidth(dpy, screen);        screen_h = DisplayHeight(dpy, screen);        XQueryPointer(dpy, RootWindow(dpy, screen), &w, &w, &x_off, &y_off, &ret, &ret, &ret);        x_off -= x11grab->width / 2;        y_off -= x11grab->height / 2;        x_off = FFMIN(FFMAX(x_off, 0), screen_w - x11grab->width);        y_off = FFMIN(FFMAX(y_off, 0), screen_h - x11grab->height);        av_log(s1, AV_LOG_INFO, "followmouse is enabled, resetting grabbing region to x: %d y: %d/n", x_off, y_off);    }    use_shm = XShmQueryExtension(dpy);    av_log(s1, AV_LOG_INFO, "shared memory extension %s found/n", use_shm ? "" : "not");    if(use_shm) {        int scr = XDefaultScreen(dpy);        image = XShmCreateImage(dpy,                                DefaultVisual(dpy, scr),                                DefaultDepth(dpy, scr),                                ZPixmap,                                NULL,                                &x11grab->shminfo,                                x11grab->width, x11grab->height);        x11grab->shminfo.shmid = shmget(IPC_PRIVATE,                                        image->bytes_per_line * image->height,                                        IPC_CREAT|0777);        if (x11grab->shminfo.shmid == -1) {            av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!/n");            ret = AVERROR(ENOMEM);            goto out;        }        x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0);        x11grab->shminfo.readOnly = False;        if (!XShmAttach(dpy, &x11grab->shminfo)) {//.........这里部分代码省略.........
开发者ID:LibXenonProject,项目名称:libav-libxenon,代码行数:101,


示例16: DefaultScreen

Visual *XAbstractGui::GetBestVisual(Display *dpy, int *vClass, int *depth){    int default_depth;    XVisualInfo vTemplate;    XVisualInfo *visualList = nullptr;    Visual *visual = nullptr;    int nrOfVisuals;    vTemplate.screen = DefaultScreen(dpy);    default_depth = DefaultDepth(dpy, vTemplate.screen);    switch (default_depth)    {        case 8:            *vClass = vTemplate.c_class  = PseudoColor;            visualList = XGetVisualInfo(dpy,                                        VisualScreenMask | VisualClassMask,                                        &vTemplate, &nrOfVisuals);            if (nrOfVisuals > 0)            {                *depth = visualList[0].depth;                visual = visualList[0].visual;            }            else            {                *vClass = vTemplate.c_class = TrueColor;                visualList = XGetVisualInfo(dpy,                                            VisualScreenMask | VisualClassMask,                                            &vTemplate, &nrOfVisuals);                if (nrOfVisuals > 0)                {                    *depth = visualList[0].depth;                    visual = visualList[0].visual;                }                else                {                    *vClass = vTemplate.c_class  = GrayScale;                    visualList = XGetVisualInfo(dpy, VisualScreenMask |                                                VisualClassMask, &vTemplate,                                                &nrOfVisuals);                    if (nrOfVisuals > 0)                    {                        *depth = visualList[0].depth;                        visual = visualList[0].visual;                    }                }            }            break;        case 16:        case 24:        case 32:            *vClass = vTemplate.c_class  = TrueColor;            visualList = XGetVisualInfo(dpy,                                        VisualScreenMask | VisualClassMask,                                        &vTemplate, &nrOfVisuals);            if (nrOfVisuals > 0)            {                *depth = visualList[0].depth;                visual = visualList[0].visual;            }            break;    }    XFree(visualList);    return visual;}
开发者ID:aladur,项目名称:flexemu,代码行数:73,


示例17: run

	int32_t run(Filesystem* fs, ConfigSettings* cs)	{		// Create main window		XInitThreads();		XSetErrorHandler(x11_error_handler);		m_x11_display = XOpenDisplay(NULL);		CE_ASSERT(m_x11_display != NULL, "Unable to open X11 display");		int screen = DefaultScreen(m_x11_display);		int depth = DefaultDepth(m_x11_display, screen);		Visual* visual = DefaultVisual(m_x11_display, screen);		m_x11_parent_window = (m_parent_window_handle == 0) ? RootWindow(m_x11_display, screen) :			(Window) m_parent_window_handle;		// Create main window		XSetWindowAttributes win_attribs;		win_attribs.background_pixmap = 0;		win_attribs.border_pixel = 0;		win_attribs.event_mask = FocusChangeMask			| StructureNotifyMask 			| KeyPressMask			| KeyReleaseMask 			| ButtonPressMask 			| ButtonReleaseMask			| PointerMotionMask;		m_x11_window = XCreateWindow(m_x11_display,			m_x11_parent_window,			0, 0,			cs->window_width,			cs->window_height,			0,			depth,			InputOutput,			visual,			CWBorderPixel | CWEventMask,			&win_attribs		);		CE_ASSERT(m_x11_window != None, "Unable to create X window");		// Do we have detectable autorepeat?		Bool detectable;		m_x11_detectable_autorepeat = (bool) XkbSetDetectableAutoRepeat(m_x11_display, true, &detectable);		// Build hidden cursor		Pixmap bm_no;		XColor black, dummy;		Colormap colormap;		static char no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };		colormap = XDefaultColormap(m_x11_display, screen);		XAllocNamedColor(m_x11_display, colormap, "black", &black, &dummy);		bm_no = XCreateBitmapFromData(m_x11_display, m_x11_window, no_data, 8, 8);		m_x11_hidden_cursor = XCreatePixmapCursor(m_x11_display, bm_no, bm_no, &black, &black, 0, 0);		m_wm_delete_message = XInternAtom(m_x11_display, "WM_DELETE_WINDOW", False);		XSetWMProtocols(m_x11_display, m_x11_window, &m_wm_delete_message, 1);		oswindow_set_window(m_x11_display, m_x11_window);		bgfx::x11SetDisplayWindow(m_x11_display, m_x11_window);		XMapRaised(m_x11_display, m_x11_window);		// Get screen configuration		m_screen_config = XRRGetScreenInfo(m_x11_display, RootWindow(m_x11_display, screen));		Rotation rr_old_rot;		const SizeID rr_old_sizeid = XRRConfigCurrentConfiguration(m_screen_config, &rr_old_rot);		// Start main thread		MainThreadArgs mta;		mta.fs = fs;		mta.cs = cs;		Thread main_thread;		main_thread.start(func, &mta);		while (!s_exit)		{			pump_events();		}		main_thread.stop();		// Restore previous screen configuration if changed		Rotation rr_cur_rot;		const SizeID rr_cur_sizeid = XRRConfigCurrentConfiguration(m_screen_config, &rr_cur_rot);		if (rr_cur_rot != rr_old_rot || rr_cur_sizeid != rr_old_sizeid)		{			XRRSetScreenConfig(m_x11_display,				m_screen_config,				RootWindow(m_x11_display, screen),				rr_old_sizeid,				rr_old_rot,				CurrentTime);		}		XRRFreeScreenConfigInfo(m_screen_config);//.........这里部分代码省略.........
开发者ID:dgu123,项目名称:crown,代码行数:101,


示例18: GETSTRORGOTO

static BackgroundTexture *parseTexture(RContext * rc, char *text){	BackgroundTexture *texture = NULL;	WMPropList *texarray;	WMPropList *val;	int count;	char *tmp;	char *type;#define GETSTRORGOTO(val, str, i, label) /    val = WMGetFromPLArray(texarray, i);/    if (!WMIsPLString(val)) {/    wwarning("could not parse texture %s", text);/    goto label;/    }/    str = WMGetFromPLString(val)	texarray = WMCreatePropListFromDescription(text);	if (!texarray || !WMIsPLArray(texarray)	    || (count = WMGetPropListItemCount(texarray)) < 2) {		wwarning("could not parse texture %s", text);		if (texarray)			WMReleasePropList(texarray);		return NULL;	}	texture = wmalloc(sizeof(BackgroundTexture));	GETSTRORGOTO(val, type, 0, error);	if (strcasecmp(type, "solid") == 0) {		XColor color;		Pixmap pixmap;		texture->solid = 1;		GETSTRORGOTO(val, tmp, 1, error);		if (!XParseColor(dpy, DefaultColormap(dpy, scr), tmp, &color)) {			wwarning("could not parse color %s in texture %s", tmp, text);			goto error;		}		XAllocColor(dpy, DefaultColormap(dpy, scr), &color);		pixmap = XCreatePixmap(dpy, root, 8, 8, DefaultDepth(dpy, scr));		XSetForeground(dpy, DefaultGC(dpy, scr), color.pixel);		XFillRectangle(dpy, pixmap, DefaultGC(dpy, scr), 0, 0, 8, 8);		texture->pixmap = pixmap;		texture->color = color;		texture->width = 8;		texture->height = 8;	} else if (strcasecmp(type, "vgradient") == 0		   || strcasecmp(type, "dgradient") == 0 || strcasecmp(type, "hgradient") == 0) {		XColor color;		RColor color1, color2;		RImage *image;		Pixmap pixmap;		RGradientStyle gtype;		int iwidth, iheight;		GETSTRORGOTO(val, tmp, 1, error);		if (!XParseColor(dpy, DefaultColormap(dpy, scr), tmp, &color)) {			wwarning("could not parse color %s in texture %s", tmp, text);			goto error;		}		color1.red = color.red >> 8;		color1.green = color.green >> 8;		color1.blue = color.blue >> 8;		GETSTRORGOTO(val, tmp, 2, error);		if (!XParseColor(dpy, DefaultColormap(dpy, scr), tmp, &color)) {			wwarning("could not parse color %s in texture %s", tmp, text);			goto error;		}		color2.red = color.red >> 8;		color2.green = color.green >> 8;		color2.blue = color.blue >> 8;		switch (type[0]) {		case 'h':		case 'H':			gtype = RHorizontalGradient;			iwidth = scrWidth;			iheight = 32;			break;		case 'V':		case 'v':			gtype = RVerticalGradient;			iwidth = 32;			iheight = scrHeight;			break;		default:			gtype = RDiagonalGradient;			iwidth = scrWidth;//.........这里部分代码省略.........
开发者ID:cneira,项目名称:wmaker-crm,代码行数:101,


示例19: framebuffer

    framebuffer( uint32_t width = 800, uint32_t height = 600 ) : width_(width), height_(height) {                        {            // select display and screen            const char *dpyName = ":0";            display_ = XOpenDisplay( dpyName );            scrnum_ = DefaultScreen( display_ );            if( display_ == 0 ) {                throw std::runtime_error( "X11 display == 0/n" );            }                }                        {            // create window                        Window root;            root = RootWindow( display_, scrnum_ );                        XSetWindowAttributes attr;                               attr.background_pixel = 0;            attr.border_pixel = 0;            attr.colormap = XCreateColormap( display_, root, DefaultVisual( display_, 0 ), AllocNone );            attr.event_mask =  StructureNotifyMask | ExposureMask | KeyPressMask | FocusChangeMask;            unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;                        window_ = XCreateWindow( display_, root, 0, 0, width, height,                                      0, DefaultDepth(display_, 0), InputOutput, DefaultVisual(display_, 0), mask, &attr );                        if( window_ == 0 )            {                                throw std::runtime_error( "XCreateWindow failed/n" );            }                }                        {            // additional window setup            XSizeHints sizehints;            sizehints.width = width_;            sizehints.height = height_;            sizehints.flags = USSize;            XSetNormalHints( display_, window_, &sizehints );                        const char *name = "Human Interface";            // is XSetNormalHints above just plain stupid?            XSetStandardProperties( display_, window_, name, name, None, (char**)0, 0, &sizehints );           }                        XMapWindow( display_, window_ );                // wait for map notify        while(true) {            XEvent e;            XNextEvent(display_, &e);            std::cout << "event: " << e.type << "/n";            if (e.type == MapNotify) {                break;            }        }                        // done                gc_ = XCreateGC( display_, window_, 0, 0 );            //         shminfo.#if 0            XImage *xi = XShmCreateImage(display_, DefaultVisual( display_, 0 ), DefaultDepthOfScreen(screen),                          ZPixmap, NULL, &shminfo,                          width_, height_);#endif                    }
开发者ID:sim82,项目名称:playground,代码行数:81,


示例20: XDefaultDepth

int XDefaultDepth(Display *dpy, int scr){    return(DefaultDepth(dpy, scr));}
开发者ID:mirror,项目名称:libX11,代码行数:4,


示例21: run

		int32_t run(int _argc, char** _argv)		{			XInitThreads();			m_display = XOpenDisplay(0);			int32_t screen = DefaultScreen(m_display);			int32_t depth = DefaultDepth(m_display, screen);			Visual* visual = DefaultVisual(m_display, screen);			Window root = RootWindow(m_display, screen);			XSetWindowAttributes windowAttrs;			memset(&windowAttrs, 0, sizeof(windowAttrs) );			windowAttrs.background_pixmap = 0;			windowAttrs.border_pixel = 0;			windowAttrs.event_mask = 0					| ButtonPressMask					| ButtonReleaseMask					| ExposureMask					| KeyPressMask					| KeyReleaseMask					| PointerMotionMask					| ResizeRedirectMask					| StructureNotifyMask					;			m_window = XCreateWindow(m_display									, root									, 0, 0									, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT, 0, depth									, InputOutput									, visual									, CWBorderPixel|CWEventMask									, &windowAttrs									);			XMapWindow(m_display, m_window);			XStoreName(m_display, m_window, "BGFX");			bgfx::x11SetDisplayWindow(m_display, m_window);			MainThreadEntry mte;			mte.m_argc = _argc;			mte.m_argv = _argv;			bx::Thread thread;			thread.init(mte.threadFunc, &mte);			while (!m_exit)			{				if (XPending(m_display) )				{					XEvent event;					XNextEvent(m_display, &event);					switch (event.type)					{						case Expose:							break;						case ConfigureNotify:							break;						case ButtonPress:						case ButtonRelease:							{								const XButtonEvent& xbutton = event.xbutton;								MouseButton::Enum mb;								switch (xbutton.button)								{									case Button1: mb = MouseButton::Left;   break;									case Button2: mb = MouseButton::Middle; break;									case Button3: mb = MouseButton::Right;  break;									default:      mb = MouseButton::None;   break;								}								if (MouseButton::None != mb)								{									m_eventQueue.postMouseEvent(xbutton.x										, xbutton.y										, mb										, event.type == ButtonPress										);								}							}							break;						case MotionNotify:							{								const XMotionEvent& xmotion = event.xmotion;								m_eventQueue.postMouseEvent(xmotion.x										, xmotion.y										);							}							break;						case KeyPress:						case KeyRelease:							{								XKeyEvent& xkey = event.xkey;								KeySym keysym = XLookupKeysym(&xkey, 0);//.........这里部分代码省略.........
开发者ID:cdoty,项目名称:bgfx,代码行数:101,


示例22: iHwndX_declareDesktopHwnd

////////////// Called at startup one time to declare the initial desktop window as a pseudo-window// which is////////	SHwndX* iHwndX_declareDesktopHwnd(void)	{		s32			lnWidth, lnHeight;		WNDCLASSEX	wcx;		SHwndX*		win;		//////////		// Allocate our primary SHwndX buffer if need be		//////			if (!gsWindows)			iBuilder_createAndInitialize(&gsWindows, -1);			if (!gsClasses)			iBuilder_createAndInitialize(&gsClasses, -1);			if (!gsHdcs)			iBuilder_createAndInitialize(&gsHdcs, -1);		//////////		// Connect to X11		//////			gsDesktop.display		= XOpenDisplay(NULL);			gsDesktop.screen		= DefaultScreen(gsDesktop.display);			gsDesktop.depth			= DefaultDepth(gsDesktop.display, gsDesktop.screen);			gsDesktop.connection	= ConnectionNumber(gsDesktop.display);			gsDesktop.windowDesktop	= RootWindow(gsDesktop.display, gsDesktop.screen);		//////////		// Register our logical desktop class		//////			memset(&wcx, 0, sizeof(wcx));			wcx.cbSize			= sizeof(wcx);			wcx.style			= CS_OWNDC;			wcx._lpfnWndProc	= (uptr)&DefWindowProc;			wcx.lpszClassName	= (cs8*)&cgcDesktop[0];			wcx.lpszMenuName	= (cs8*)&cgcDesktop[0];			RegisterClassEx(&wcx);		//////////		// Create our logical desktop window		//////			lnWidth			= XDisplayWidth(gsDesktop.display, gsDesktop.screen);			lnHeight		= XDisplayHeight(gsDesktop.display, gsDesktop.screen);debug_break;			ghWndDesktop	= CreateWindowEx(	0, cgcDesktop, cgcDesktop, WS_POPUP,												0, 0, lnWidth, lnHeight,												null0, null0, null0, null0);		//////////		// Create our default device context		//////			win = iHwndX_findWindow_byHwnd(ghWndDesktop);			if (win)			{				// Create the actual hdc				win->hdcx = iHwndX_createHdc(lnWidth, lnHeight, NULL);				// Populate with default items				//XQueryFont(gsDesktop.display, "*");			}		//////////		// Return the logical desktop pointer		//////			return(win);	}
开发者ID:ralvaradoc,项目名称:libsf,代码行数:73,


示例23: strcpy

voidWindowDevice::WINOPEN(const char *_title, int _xLoc, int _yLoc, int _width, int _height){    // set the WindowDevices title, height, wdth, xLoc and yLoc    strcpy(title, _title);    height = _height;    width = _width;      xLoc = _xLoc;    yLoc = _yLoc;#ifdef _UNIX    if (winOpen == 0) { // we must close the old window	XFreeGC(theDisplay, theGC);	XDestroyWindow(theDisplay, theWindow);     }    // define the position and size of the window - only hints    hints.x = _xLoc;    hints.y = _yLoc;    hints.width = _width;    hints.height = _height;    hints.flags = PPosition | PSize;    // set the defualt foreground and background colors    XVisualInfo visual;     visual.visual = 0;    int depth = DefaultDepth(theDisplay, theScreen);    if (background == 0) {      if (XMatchVisualInfo(theDisplay, theScreen, depth, PseudoColor, &visual) == 0) {	  foreground = BlackPixel(theDisplay, theScreen);	  background = WhitePixel(theDisplay, theScreen);          } else {	foreground = 0;	background = 255;      }    }    // now open a window    theWindow = XCreateSimpleWindow(theDisplay,RootWindow(theDisplay,0),				    hints.x, hints.y,				    hints.width,hints.height,4,				    foreground, background);    if (theWindow == 0) {	opserr << "WindowDevice::WINOPEN() - could not open a window/n";	exit(-1);    }	        XSetStandardProperties(theDisplay, theWindow, title, title, None, 0, 0, &hints);        // create a graphical context    theGC = XCreateGC(theDisplay, theWindow, 0, 0);    // if we were unable to get space for our colors    // we must create and use our own colormap    if (colorFlag == 3 ) {      // create the colormap if the 1st window      if (numWindowDevice == 1) {	int fail = false;	//	XMatchVisualInfo(theDisplay, theScreen, depth, PseudoColor, &visual);	if (XMatchVisualInfo(theDisplay, theScreen, depth, PseudoColor, &visual) == 0) {	  opserr << "WindowDevice::initX11() - could not get a visual for PseudoColor/n";	  opserr << "Colors diplayed will be all over the place/n";	  cmap = DefaultColormap(theDisplay, theScreen);	  fail = true;        } else {	  opserr << "WindowDevice::WINOPEN have created our own colormap, /n";	  opserr << "windows may change color as move mouse from one window to/n";	  opserr << "another - depends on your video card to use another colormap/n/n";		  cmap = XCreateColormap(theDisplay,theWindow,				 visual.visual, AllocAll);	}	/*	cmap = XCreateColormap(theDisplay,theWindow,			   DefaultVisual(theDisplay,0),AllocAll);	*/	if (cmap == 0) {	    opserr << "WindowDevice::initX11() - could not get a new color table/n";	    exit(-1);	}	    	// we are going to try to allocate 256 new colors -- need 8 planes for this	depth = DefaultDepth(theDisplay, theScreen);	if (depth < 8) {	    opserr << "WindowDevice::initX11() - needed at least 8 planes/n";	    exit(-1);	}	    	if (fail == false) {	  int cnt = 0;	  for (int red = 0; red < 8; red++) {	    for (int green = 0; green < 8; green++) {		for (int blue = 0; blue < 4; blue++) {//.........这里部分代码省略.........
开发者ID:DBorello,项目名称:OpenSees,代码行数:101,


示例24: iHwndX_initializeXWindow

////////////// Called to physically create the X11 window which will be drawn on the desktop.////////	s32 iHwndX_initializeXWindow(SXWindow* xwin, s32 width, s32 height, s8* title)	{		XSizeHints Hints;		// Make sure our environment is sane		if (xwin)		{			//////////			// Allocate a display			//////				xwin->display = XOpenDisplay(NULL);				if (!xwin->display)					return _X11_NO_DISPLAY;			//////////			// Populate our local settings			//////				xwin->width		= width;				xwin->height	= height;				xwin->drawable	= DefaultScreen(xwin->display);				xwin->screenptr	= DefaultScreenOfDisplay(xwin->display);				xwin->visual	= DefaultVisualOfScreen(xwin->screenptr);				xwin->depth		= DefaultDepth(xwin->display, xwin->drawable);				xwin->pixelsize	= 4;			//////////			// Make sure we have a compatible display			//////				if (xwin->depth != 24 && xwin->depth != 32)					return _X11_UNSUPPORTED;			//////////			// Physically create the window on the desktop			//////				xwin->window	= XCreateWindow(xwin->display,												RootWindowOfScreen(xwin->screenptr),												0, 0, xwin->width, xwin->height,												0, xwin->depth,												InputOutput,												xwin->visual, 0, NULL);				// Are we valid?				if (!xwin->window)					return _X11_NO_WINDOW;				// Raise it to the top				XMapRaised(xwin->display, xwin->window);			//////////			// Provide hints because we do our own resizing internally			//////				Hints.flags			= PSize | PMinSize | PMaxSize;				Hints.min_width		= Hints.max_width	= Hints.base_width	= width;				Hints.min_height	= Hints.max_height	= Hints.base_height	= height;				XSetWMNormalHints(xwin->display, xwin->window, &Hints);			//////////			// Set window title and specify those events we would like to receive			//////				XStoreName(xwin->display, xwin->window, title);				XSelectInput(xwin->display, xwin->window, 		ExposureMask															|	KeyPressMask															|	KeyReleaseMask															|	ButtonPressMask															|	EnterWindowMask															|	LeaveWindowMask															|	PointerMotionMask															|	FocusChangeMask);			//////////			// Graphical context			//////				xwin->gc = XCreateGC(xwin->display, xwin->window, 0, NULL);			//////////			// Primray pixel buffer			//////				xwin->screensize	= xwin->height * xwin->width * xwin->pixelsize;				xwin->virtualscreen	= (SBgra*)malloc(xwin->screensize);				if (!xwin->virtualscreen)					return _X11_NO_VIRTUAL_SCREEN;				// Logical image				xwin->ximage = XCreateImage(xwin->display, xwin->visual, xwin->depth,											ZPixmap, 0,											(s8*)xwin->virtualscreen,											xwin->width, xwin->height,											(xwin->pixelsize * 8),//.........这里部分代码省略.........
开发者ID:ralvaradoc,项目名称:libsf,代码行数:101,


示例25: main

int main (int argc, char **argv){		Visual *vis;	Colormap cm;	Display *_display;	Imlib_Context context;	Imlib_Image image;	Pixmap pixmap;	Imlib_Color_Modifier modifier = NULL;	_display = XOpenDisplay (NULL);	int width, height, depth, i, alpha;		char str1[40];	char str2[40];	char str3[40];	char str4[40];	char str5[40];		int ck0;	int w, h; 	w = 0;	h = 0;						for (screen = 0; screen < ScreenCount (_display); screen++)	{		display = XOpenDisplay (NULL);		context = imlib_context_new ();		imlib_context_push (context);		imlib_context_set_display (display);		vis = DefaultVisual (display, screen);		cm = DefaultColormap (display, screen);		width = DisplayWidth (display, screen);		height = DisplayHeight (display, screen);		depth = DefaultDepth (display, screen);		pixmap =			XCreatePixmap (display, RootWindow (display, screen),							width, height, depth);		imlib_context_set_visual (vis);		imlib_context_set_colormap (cm);		imlib_context_set_drawable (pixmap);		imlib_context_set_color_range (imlib_create_color_range ());				image = imlib_create_image (width, height);		imlib_context_set_image (image);						imlib_context_set_color (0, 0, 0, 255);		imlib_image_fill_rectangle (0, 0, width, height);		imlib_context_set_dither (1);		imlib_context_set_blend (1);				alpha = 255;	for (i = 1; i < argc; i++)	{		if (modifier != NULL)		{			imlib_apply_color_modifier ();			imlib_free_color_modifier ();		}	modifier = imlib_create_color_modifier ();	imlib_context_set_color_modifier (modifier);		if (strcmp (argv[i], "-alpha") == 0)		{			if ((++i) >= argc)			{				fprintf (stderr, "Missing alpha/n");				continue;			}				if (sscanf (argv[i], "%i", &alpha) == 0)				{					fprintf (stderr, "Bad alpha (%s)/n", argv[i]);					continue;				}		}	else if (strcmp (argv[i], "-solid") == 0)	{		Color c;				if ((++i) >= argc)		{			fprintf (stderr, "Missing color/n");			continue;		}			if (parse_color (argv[i], &c, alpha) == 1)			{				fprintf (stderr, "Bad color (%s)/n", argv[i]);				continue;//.........这里部分代码省略.........
开发者ID:userx-bw,项目名称:mhrootset,代码行数:101,


示例26: client_main

/**************************************************************************  Entry point for GUI specific portion. Called from client_main()**************************************************************************/void ui_main(int argc, char *argv[]){  int i;  struct sprite *icon;   parse_options(argc, argv);  /* include later - pain to see the warning at every run */  XtSetLanguageProc(NULL, NULL, NULL);    toplevel = XtVaAppInitialize(	       &app_context,               /* Application context */	       "Freeciv",                  /* application class name */#ifdef UNUSED	       cmd_options, XtNumber(cmd_options),#else	       NULL, 0,#endif	                                   /* command line option list */	       &argc, argv,                /* command line args */	       &fallback_resources[1],     /* for missing app-defaults file */	       XtNallowShellResize, True,	       NULL);                XtGetApplicationResources(toplevel, &appResources, resources,                            XtNumber(resources), NULL, 0);/*  XSynchronize(display, 1);   XSetErrorHandler(myerr);*/  if(appResources.version==NULL)  {    freelog(LOG_FATAL, _("No version number in resources."));    freelog(LOG_FATAL, _("You probably have an old (circa V1.0)"			 " Freeciv resource file somewhere."));    exit(EXIT_FAILURE);  }  /* TODO: Use capabilities here instead of version numbers */  if (0 != strncmp(appResources.version, VERSION_STRING,		   strlen(appResources.version))) {    freelog(LOG_FATAL, _("Game version does not match Resource version."));    freelog(LOG_FATAL, _("Game version: %s - Resource version: %s"), 	    VERSION_STRING, appResources.version);    freelog(LOG_FATAL, _("You might have an old Freeciv resourcefile"			 " in /usr/lib/X11/app-defaults"));    exit(EXIT_FAILURE);  }    if(!appResources.gotAppDefFile) {    freelog(LOG_NORMAL, _("Using fallback resources - which is OK"));  }  display = XtDisplay(toplevel);  screen_number=XScreenNumberOfScreen(XtScreen(toplevel));  display_depth=DefaultDepth(display, screen_number);  root_window=DefaultRootWindow(display);  display_color_type=get_visual();     if(display_color_type!=COLOR_DISPLAY) {    freelog(LOG_FATAL, _("Only color displays are supported for now..."));    /*    exit(EXIT_FAILURE); */  }  {    XGCValues values;    char **missing_charset_list_return;    int missing_charset_count_return;    char *def_string_return;    char *city_names_font, *city_productions_font_name;    values.graphics_exposures = False;    civ_gc = XCreateGC(display, root_window, GCGraphicsExposures, &values);    city_names_font = mystrdup("-*-*-*-*-*-*-14-*");    city_productions_font_name = mystrdup("-*-*-*-*-*-*-14-*");    main_font_set = XCreateFontSet(display, city_names_font,	&missing_charset_list_return,	&missing_charset_count_return,	&def_string_return);    if (!main_font_set) {      freelog(LOG_FATAL, _("Unable to open fontset: %s"),	      city_names_font);      freelog(LOG_FATAL,	      _("Doing 'xset fp rehash' may temporarily solve a problem."));      exit(EXIT_FAILURE);    }    for (i = 0; i < missing_charset_count_return; i++) {      freelog(LOG_ERROR, _("Font for charset %s is lacking"),	      missing_charset_list_return[i]);    }    values.foreground = get_color(tileset, COLOR_MAPVIEW_CITYTEXT)->color.pixel;    values.background = get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color.pixel;    font_gc= XCreateGC(display, root_window, 		       GCForeground|GCBackground|GCGraphicsExposures, //.........这里部分代码省略.........
开发者ID:2085020,项目名称:freeciv-web,代码行数:101,


示例27: textbox_draw

void textbox_draw(textbox *tb){	int i;	XGlyphInfo extents;	GC context    = XCreateGC(display, tb->window, 0, 0);	Pixmap canvas = XCreatePixmap(display, tb->window, tb->w, tb->h, DefaultDepth(display, screen_id));	XftDraw *draw = XftDrawCreate(display, canvas, DefaultVisual(display, screen_id), DefaultColormap(display, screen_id));	// clear canvas	XftDrawRect(draw, &tb->color_bg, 0, 0, tb->w, tb->h);	char *line   = tb->text,		*text   = tb->text ? tb->text: "",		*prompt = tb->prompt ? tb->prompt: "";	int text_len    = strlen(text);	int length      = text_len;	int line_height = tb->font->ascent + tb->font->descent;	int line_width  = 0;	int cursor_x      = 0;	int cursor_offset = 0;	int cursor_width  = MAX(2, line_height/10);	if (tb->flags & TB_EDITABLE)	{		int prompt_len = strlen(prompt);		length = text_len + prompt_len;		cursor_offset = MIN(tb->cursor + prompt_len, length);		line = alloca(length + 10);		sprintf(line, "%s%s", prompt, text);		// replace spaces so XftTextExtents8 includes their width		for (i = 0; i < length; i++) if (isspace(line[i])) line[i] = '_';		// calc cursor position		XftTextExtents8(display, tb->font, (unsigned char*)line, cursor_offset, &extents);		cursor_x = extents.width;		// restore correct text string with spaces		sprintf(line, "%s%s", prompt, text);	}	// calc full input text width	XftTextExtents8(display, tb->font, (unsigned char*)line, length, &extents);	line_width = extents.width;	int x = 0, y = tb->font->ascent;	if (tb->flags & TB_RIGHT)  x = tb->w - line_width;	if (tb->flags & TB_CENTER) x = (tb->w - line_width) / 2;	// draw the text, including any prompt in edit mode	XftDrawString8(draw, &tb->color_fg, tb->font, x, y, (unsigned char*)line, length);	// draw the cursor	if (tb->flags & TB_EDITABLE)		XftDrawRect(draw, &tb->color_fg, cursor_x, 2, cursor_width, line_height-4);	// flip canvas to window	XCopyArea(display, canvas, tb->window, context, 0, 0, tb->w, tb->h, 0, 0);	XFreeGC(display, context);	XftDrawDestroy(draw);	XFreePixmap(display, canvas);}
开发者ID:Ismael-VC,项目名称:goomwwm,代码行数:67,


示例28: main

intmain(int argc, char *argv[]){	XEvent e;	Atom type;	XClassHint *h;	XSetWindowAttributes wa;	unsigned int desktop;	struct pollfd pfd[1];	int nfds;	char *fontstr = FONT;	int running = 1;	d = XOpenDisplay(NULL);	if (d == NULL) {		fprintf(stderr, "Cannot open display/n");		exit(1);	}	s = DefaultScreen(d);	wa.override_redirect = 1;	wa.background_pixmap = ParentRelative;	wa.event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask;	w = XCreateWindow(d, RootWindow(d, s), 0, BARPOS, BARWIDTH, BARHEIGHT, 0,	    DefaultDepth(d, s), CopyFromParent, DefaultVisual(d, s),	    CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);	h = XAllocClassHint();	h->res_name  = "status";	h->res_class = "status";	XSetClassHint(d, w, h);	XFree(h);	XStoreName(d, w, "status");	type = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_WINDOW_TYPE", False),	    XInternAtom(d, "ATOM", False), 32, PropModeReplace, (unsigned char *)&type, 1);	type = XInternAtom(d, "_NET_WM_STATE_ABOVE", False);	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_STATE", False),	    XInternAtom(d, "ATOM", False), 32, PropModeReplace, (unsigned char *)&type, 1);	type = XInternAtom(d, "_NET_WM_STATE_STICKY", False);	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_STATE", False),	    XInternAtom(d, "ATOM", False), 32, PropModeAppend, (unsigned char *)&type, 1); 	desktop = 0xffffffff;	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_DESKTOP", False),	    XInternAtom(d, "CARDINAL", False), 32, PropModeReplace, (unsigned char *)&desktop, 1);	xftd = XftDrawCreate(d, w, DefaultVisual(d, s), DefaultColormap(d, s));	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "white",  &white);	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "black",  &black);	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "red",  &red);	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "green",  &green);	xftfont = XftFontOpenXlfd(d, s, fontstr);	if (!xftfont)		xftfont = XftFontOpenName(d, s, fontstr);	if (!xftfont)		exit(1);	XSelectInput(d, w, ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask);	XSelectInput(d, RootWindow(d, s), PropertyChangeMask);	XMapWindow(d, w);	XFlush(d);	pfd[0].fd = ConnectionNumber(d);	pfd[0].events = POLLIN;	while (running) {		nfds = poll(pfd, 1, 1000);		if (nfds == -1 || (pfd[0].revents & (POLLERR|POLLHUP|POLLNVAL)))			break;		if (nfds == 0) {			redraw();			XFlush(d);			continue;		}		while (XPending(d)) {			XNextEvent(d, &e);			if (e.type == PropertyNotify &&			    e.xproperty.window == RootWindow(d, s) &&			    e.xproperty.atom == XInternAtom(d, "_NET_CURRENT_DESKTOP", True)) {				redraw();			}			if (e.type == Expose) {				XftDrawRect(xftd, &black, 0, 0, BARWIDTH, BARHEIGHT);				redraw();			}			if (e.type == ButtonPress) {				/*running = 0;				break;*/				redraw();//.........这里部分代码省略.........
开发者ID:awaw,项目名称:status,代码行数:101,



注:本文中的DefaultDepth函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ DefaultDepthOfScreen函数代码示例
C++ DefaultColormap函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。