这篇教程C++ BlackPixel函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BlackPixel函数的典型用法代码示例。如果您正苦于以下问题:C++ BlackPixel函数的具体用法?C++ BlackPixel怎么用?C++ BlackPixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BlackPixel函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: puglCreateWindowintpuglCreateWindow(PuglView* view, const char* title){ PuglInternals* const impl = view->impl; impl->display = XOpenDisplay(NULL); impl->screen = DefaultScreen(impl->display); XVisualInfo* const vi = getVisual(view); if (!vi) { XCloseDisplay(impl->display); impl->display = NULL; return 1; }#ifdef PUGL_HAVE_GL int glxMajor, glxMinor; glXQueryVersion(impl->display, &glxMajor, &glxMinor); PUGL_LOGF("GLX Version %d.%d/n", glxMajor, glxMinor);#endif Window xParent = view->parent ? (Window)view->parent : RootWindow(impl->display, impl->screen); Colormap cmap = XCreateColormap( impl->display, xParent, vi->visual, AllocNone); XSetWindowAttributes attr; memset(&attr, 0, sizeof(XSetWindowAttributes)); attr.background_pixel = BlackPixel(impl->display, impl->screen); attr.border_pixel = BlackPixel(impl->display, impl->screen); attr.colormap = cmap; attr.event_mask = (ExposureMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask); impl->win = XCreateWindow( impl->display, xParent, 0, 0, view->width, view->height, 0, vi->depth, InputOutput, vi->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &attr); if (!createContext(view, vi)) { XDestroyWindow(impl->display, impl->win); impl->win = 0; XCloseDisplay(impl->display); impl->display = NULL; return 1; } XSizeHints sizeHints; memset(&sizeHints, 0, sizeof(sizeHints)); if (!view->resizable) { sizeHints.flags = PMinSize|PMaxSize; sizeHints.min_width = view->width; sizeHints.min_height = view->height; sizeHints.max_width = view->width; sizeHints.max_height = view->height; XSetNormalHints(impl->display, impl->win, &sizeHints); } else if (view->min_width > 0 && view->min_height > 0) { sizeHints.flags = PMinSize; sizeHints.min_width = view->min_width; sizeHints.min_height = view->min_height; XSetNormalHints(impl->display, impl->win, &sizeHints); } if (title) { XStoreName(impl->display, impl->win, title); } if (!view->parent) { Atom wmDelete = XInternAtom(impl->display, "WM_DELETE_WINDOW", True); XSetWMProtocols(impl->display, impl->win, &wmDelete, 1); } if (glXIsDirect(impl->display, impl->ctx)) { PUGL_LOG("DRI enabled (to disable, set LIBGL_ALWAYS_INDIRECT=1/n"); } else { PUGL_LOG("No DRI available/n"); } XFree(vi); return PUGL_SUCCESS;}
开发者ID:falkTX,项目名称:DPF-Plugins,代码行数:89,
示例2: mainint main(void){ Display *display; Window window; //initialization for a window int screen; //which screen /* open connection with the server */ display = XOpenDisplay(NULL); if(display == NULL) { fprintf(stderr, "cannot open display/n"); return 0; } screen = DefaultScreen(display); /* set window size */ int width = 400; int height = 400; /* set window position */ int x = 0; int y = 0; /* border width in pixels */ int border_width = 0; /* create window */ window = XCreateSimpleWindow(display, RootWindow(display, screen), x, y, width, height, border_width, BlackPixel(display, screen), WhitePixel(display, screen)); /* create graph */ GC gc; XGCValues values; long valuemask = 0; gc = XCreateGC(display, window, valuemask, &values); //XSetBackground (display, gc, WhitePixel (display, screen)); XSetForeground (display, gc, BlackPixel (display, screen)); XSetBackground(display, gc, 0X0000FF00); XSetLineAttributes (display, gc, 1, LineSolid, CapRound, JoinRound); /* map(show) the window */ XMapWindow(display, window); XSync(display, 0); struct timespec timeStart, timeEnd; clock_gettime(CLOCK_REALTIME, &timeStart); /* draw points */ int* repeatsBuffer; Compl z, c; int repeats; double temp, lengthsq; int i, j; repeatsBuffer = (int*)malloc(sizeof(int) * width * height); #pragma omp parallel for num_threads(60) private(i,j,repeats,lengthsq,temp,z,c) schedule(static,10) for(i=0; i<width; i++) { for(j=0; j<height; j++) { z.real = 0.0; z.imag = 0.0; c.real = -2.0 + (double)i * (4.0/(double)width); c.imag = -2.0 + (double)j * (4.0/(double)height); repeats = 0; lengthsq = 0.0; while(repeats < 100000 && lengthsq < 4.0) { /* Theorem : If c belongs to M, then |Zn| <= 2. So Zn^2 <= 4 */ temp = z.real*z.real - z.imag*z.imag + c.real; z.imag = 2*z.real*z.imag + c.imag; z.real = temp; lengthsq = z.real*z.real + z.imag*z.imag; repeats++; } repeatsBuffer[i*width+j]=repeats; } } clock_gettime(CLOCK_REALTIME, &timeEnd); printf("Time Usage: %lf s/n", (double)(timeEnd.tv_sec - timeStart.tv_sec) + (double)(timeEnd.tv_nsec - timeStart.tv_nsec)/1e9); fflush(stdout); for(i = 0; i < width * height; i++){ XSetForeground (display, gc, 1024 * 1024 * (repeatsBuffer[i] % 256)); XDrawPoint (display, window, gc, i/width, i%width); } XFlush(display); free(repeatsBuffer); sleep(2); return 0;}
开发者ID:guoxy95,项目名称:mandelbrot,代码行数:90,
示例3: mainint main(int argc, char** argv){ Display* dpy = XOpenDisplay(NULL); if (dpy == NULL) { fprintf(stderr, "Cannot open display/n"); exit(1); } int s = DefaultScreen(dpy); Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, s), 10, 10, 660, 200, 1, BlackPixel(dpy, s), WhitePixel(dpy, s)); XSelectInput(dpy, win, ExposureMask | KeyPressMask); XMapWindow(dpy, win);#if defined(__APPLE_CC__) XStoreName(dpy, win, "Geeks3D.com - X11 window under Mac OS X (Lion)");#else XStoreName(dpy, win, "Geeks3D.com - X11 window under Linux (Mint 10)");#endif Atom WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", False); XSetWMProtocols(dpy, win, &WM_DELETE_WINDOW, 1); bool uname_ok = false; struct utsname sname; int ret = uname(&sname); if (ret != -1) { uname_ok = true; } XEvent e; while (1) { XNextEvent(dpy, &e); if (e.type == Expose) { int y_offset = 20;#if defined(__APPLE_CC__) const char* s1 = "X11 test app under Mac OS X Lion";#else const char* s1 = "X11 test app under Linux";#endif const char* s2 = "(C)2012 Geeks3D.com"; XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, s1, strlen(s1)); y_offset += 20; XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, s2, strlen(s2)); y_offset += 20; if (uname_ok) { char buf[256] = {0}; sprintf(buf, "System information:"); XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, buf, strlen(buf)); y_offset += 15; sprintf(buf, "- System: %s", sname.sysname); XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, buf, strlen(buf)); y_offset += 15; sprintf(buf, "- Release: %s", sname.release); XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, buf, strlen(buf)); y_offset += 15; sprintf(buf, "- Version: %s", sname.version); XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, buf, strlen(buf)); y_offset += 15; sprintf(buf, "- Machine: %s", sname.machine); XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, buf, strlen(buf)); y_offset += 20; } XWindowAttributes wa; XGetWindowAttributes(dpy, win, &wa); int width = wa.width; int height = wa.height; char buf[128]= {0}; sprintf(buf, "Current window size: %dx%d", width, height); XDrawString(dpy, win, DefaultGC(dpy, s), 10, y_offset, buf, strlen(buf)); y_offset += 20; } if (e.type == KeyPress) { char buf[128] = {0}; KeySym keysym; int len = XLookupString(&e.xkey, buf, sizeof buf, &keysym, NULL); if (keysym == XK_Escape) break; } if ((e.type == ClientMessage) && (static_cast<unsigned int>(e.xclient.data.l[0]) == WM_DELETE_WINDOW)) {//.........这里部分代码省略.........
开发者ID:EQ4,项目名称:axLib,代码行数:101,
示例4: winClipboardProc//.........这里部分代码省略......... /* Save the display in the screen privates */ g_pClipboardDisplay = pDisplay; ErrorF("winClipboardProc - XOpenDisplay () returned and " "successfully opened the display./n"); /* Get our connection number */ iConnectionNumber = ConnectionNumber(pDisplay);#ifdef HAS_DEVWINDOWS /* Open a file descriptor for the windows message queue */ fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY); if (fdMessageQueue == -1) { ErrorF("winClipboardProc - Failed opening %s/n", WIN_MSG_QUEUE_FNAME); goto winClipboardProc_Done; } /* Find max of our file descriptors */ iMaxDescriptor = max(fdMessageQueue, iConnectionNumber) + 1;#else iMaxDescriptor = iConnectionNumber + 1;#endif /* Create atoms */ atomClipboard = XInternAtom(pDisplay, "CLIPBOARD", False); atomClipboardManager = XInternAtom(pDisplay, "CLIPBOARD_MANAGER", False); /* Create a messaging window */ iWindow = XCreateSimpleWindow(pDisplay, DefaultRootWindow(pDisplay), 1, 1, 500, 500, 0, BlackPixel(pDisplay, 0), BlackPixel(pDisplay, 0)); if (iWindow == 0) { ErrorF("winClipboardProc - Could not create an X window./n"); goto winClipboardProc_Done; } XStoreName(pDisplay, iWindow, "xwinclip"); /* Select event types to watch */ if (XSelectInput(pDisplay, iWindow, PropertyChangeMask) == BadWindow) ErrorF("winClipboardProc - XSelectInput generated BadWindow " "on messaging window/n"); /* Save the window in the screen privates */ g_iClipboardWindow = iWindow; /* Create Windows messaging window */ hwnd = winClipboardCreateMessagingWindow(); /* Save copy of HWND in screen privates */ g_hwndClipboard = hwnd; /* Assert ownership of selections if Win32 clipboard is owned */ if (NULL != GetClipboardOwner()) { /* PRIMARY */ iReturn = XSetSelectionOwner(pDisplay, XA_PRIMARY, iWindow, CurrentTime); if (iReturn == BadAtom || iReturn == BadWindow || XGetSelectionOwner(pDisplay, XA_PRIMARY) != iWindow) { ErrorF("winClipboardProc - Could not set PRIMARY owner/n"); goto winClipboardProc_Done; }
开发者ID:csulmone,项目名称:X11,代码行数:67,
示例5: windrawstringvoid windrawstring(pdfapp_t *app, int x, int y, char *s){ XSetForeground(xdpy, xgc, BlackPixel(xdpy, DefaultScreen(xdpy))); XDrawString(xdpy, xwin, xgc, x, y, s, strlen(s));}
开发者ID:Enzime,项目名称:mupdf,代码行数:5,
示例6: GLW_SetMode//.........这里部分代码省略......... { // must be 16 bit attrib[ATTR_RED_IDX] = 4; attrib[ATTR_GREEN_IDX] = 4; attrib[ATTR_BLUE_IDX] = 4; } attrib[ATTR_DEPTH_IDX] = tdepthbits; // default to 24 depth attrib[ATTR_STENCIL_IDX] = tstencilbits; visinfo = qglXChooseVisual(dpy, scrnum, attrib); if (!visinfo) { continue; } CL_RefPrintf( PRINT_ALL, "Using %d/%d/%d Color bits, %d depth, %d stencil display./n", attrib[ATTR_RED_IDX], attrib[ATTR_GREEN_IDX], attrib[ATTR_BLUE_IDX], attrib[ATTR_DEPTH_IDX], attrib[ATTR_STENCIL_IDX]); glConfig.colorBits = tcolorbits; glConfig.depthBits = tdepthbits; glConfig.stencilBits = tstencilbits; break; } if (!visinfo) { CL_RefPrintf( PRINT_ALL, "Couldn't get a visual/n" ); return RSERR_INVALID_MODE; } /* window attributes */ attr.background_pixel = BlackPixel(dpy, scrnum); attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); attr.event_mask = X_MASK; if (vidmode_active) { mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask | CWOverrideRedirect; attr.override_redirect = True; attr.backing_store = NotUseful; attr.save_under = False; } else mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow(dpy, root, 0, 0, actualWidth, actualHeight, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr); XStoreName( dpy, win, WINDOW_CLASS_NAME ); /* GH: Don't let the window be resized */ sizehints.flags = PMinSize | PMaxSize; sizehints.min_width = sizehints.max_width = actualWidth; sizehints.min_height = sizehints.max_height = actualHeight; XSetWMNormalHints( dpy, win, &sizehints ); XMapWindow( dpy, win ); if (vidmode_active) XMoveWindow(dpy, win, 0, 0);
开发者ID:zturtleman,项目名称:recoil,代码行数:66,
示例7: wxCHECK_MSG// real construction (Init() must have been called before!)bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name){ wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") ); CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); parent->AddChild(this); Display *xdisplay = (Display*) wxGlobalDisplay(); int xscreen = DefaultScreen( xdisplay ); Visual *xvisual = DefaultVisual( xdisplay, xscreen ); Colormap cm = DefaultColormap( xdisplay, xscreen ); m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); m_backgroundColour.CalcPixel( (WXColormap) cm ); m_foregroundColour = *wxBLACK; m_foregroundColour.CalcPixel( (WXColormap) cm ); Window xparent = (Window) parent->GetClientAreaWindow(); // Add window's own scrollbars to main window, not to client window if (parent->GetInsertIntoMain()) { // wxLogDebug( "Inserted into main: %s", GetName().c_str() ); xparent = (Window) parent->GetMainWindow(); } // Size (not including the border) must be nonzero (or a Value error results)! // Note: The Xlib manual doesn't mention this restriction of XCreateWindow. wxSize size2(size); if (size2.x <= 0) size2.x = 20; if (size2.y <= 0) size2.y = 20; wxPoint pos2(pos); if (pos2.x == -1) pos2.x = 0; if (pos2.y == -1) pos2.y = 0;#if wxUSE_TWO_WINDOWS bool need_two_windows = ((( wxSUNKEN_BORDER | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0);#else bool need_two_windows = FALSE;#endif#if wxUSE_NANOX long xattributes = 0;#else XSetWindowAttributes xattributes; long xattributes_mask = 0; xattributes_mask |= CWBackPixel; xattributes.background_pixel = m_backgroundColour.GetPixel(); xattributes_mask |= CWBorderPixel; xattributes.border_pixel = BlackPixel( xdisplay, xscreen ); xattributes_mask |= CWEventMask;#endif if (need_two_windows) {#if wxUSE_NANOX long backColor, foreColor; backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, 0, 0, InputOutput, xvisual, backColor, foreColor); XSelectInput( xdisplay, xwindow, GR_EVENT_MASK_CLOSE_REQ | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | PropertyChangeMask );#else // Normal X11 xattributes.event_mask = ExposureMask | StructureNotifyMask | ColormapChangeMask; Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );#endif XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); m_mainWindow = (WXWindow) xwindow; wxAddWindowToTable( xwindow, (wxWindow*) this ); XMapWindow( xdisplay, xwindow );//.........这里部分代码省略.........
开发者ID:gitrider,项目名称:wxsj2,代码行数:101,
示例8: mainint main(int argc, char **argv){ FILE *fp; int x_1,y_1,x_2,y_2,x_3,y_3; char a; int i,j; int outside; int ButtonPressed = 0; int temp_x, temp_y; pixel_count = 0; for(i=0;i<302;i++) { for(j=0;j<302;j++) { cost[i][j] = 9999; } } if( (display_ptr = XOpenDisplay(display_name)) == NULL ) { printf("Could not open display. /n"); exit(-1);} printf("Connected to X server %s/n", XDisplayName(display_name) ); screen_num = DefaultScreen( display_ptr ); screen_ptr = DefaultScreenOfDisplay( display_ptr ); color_map = XDefaultColormap( display_ptr, screen_num ); display_width = DisplayWidth( display_ptr, screen_num ); display_height = DisplayHeight( display_ptr, screen_num ); printf("Width %d, Height %d, Screen Number %d/n", display_width, display_height, screen_num); border_width = 10; win_x = 0; win_y = 0; win_width = display_width; win_height = display_height; win= XCreateSimpleWindow( display_ptr, RootWindow( display_ptr, screen_num), win_x, win_y, win_width, win_height, border_width, BlackPixel(display_ptr, screen_num), WhitePixel(display_ptr, screen_num) ); size_hints = XAllocSizeHints(); wm_hints = XAllocWMHints(); class_hints = XAllocClassHint(); if( size_hints == NULL || wm_hints == NULL || class_hints == NULL ) { printf("Error allocating memory for hints. /n"); exit(-1);} size_hints -> flags = PPosition | PSize | PMinSize ; size_hints -> min_width = 60; size_hints -> min_height = 60; XStringListToTextProperty( &win_name_string,1,&win_name); XStringListToTextProperty( &icon_name_string,1,&icon_name); wm_hints -> flags = StateHint | InputHint ; wm_hints -> initial_state = NormalState; wm_hints -> input = False; class_hints -> res_name = "x_use_example"; class_hints -> res_class = "examples"; XSetWMProperties( display_ptr, win, &win_name, &icon_name, argv, argc, size_hints, wm_hints, class_hints ); XSelectInput( display_ptr, win, ExposureMask | StructureNotifyMask | ButtonPressMask ); XMapWindow( display_ptr, win ); XFlush(display_ptr); gc_red = XCreateGC( display_ptr, win, valuemask, &gc_red_values); XSetLineAttributes( display_ptr, gc_red, 3, LineSolid, CapRound, JoinRound); if( XAllocNamedColor( display_ptr, color_map, "red", &tmp_color1, &tmp_color2 ) == 0 ) {printf("failed to get color red/n"); exit(-1);} else XSetForeground( display_ptr, gc_red, tmp_color1.pixel ); gc_black = XCreateGC( display_ptr, win, valuemask, &gc_black_values); XSetLineAttributes(display_ptr, gc_black, 3, LineSolid,CapRound, JoinRound); if( XAllocNamedColor( display_ptr, color_map, "black", &tmp_color1, &tmp_color2 ) == 0 ) {printf("failed to get color black/n"); exit(-1);} else XSetForeground( display_ptr, gc_black, tmp_color1.pixel ); gc_blue = XCreateGC( display_ptr, win, valuemask, &gc_blue_values); XSetLineAttributes(display_ptr, gc_blue, 3, LineSolid,CapRound, JoinRound); if( XAllocNamedColor( display_ptr, color_map, "blue", &tmp_color1, &tmp_color2 ) == 0 ) {printf("failed to get blue yellow/n"); exit(-1);} else XSetForeground( display_ptr, gc_blue, tmp_color1.pixel ); gc_white = XCreateGC( display_ptr, win, valuemask, &gc_white_values); XSetLineAttributes(display_ptr, gc_white, 3, LineSolid,CapRound, JoinRound); if( XAllocNamedColor( display_ptr, color_map, "white", &tmp_color1, &tmp_color2 ) == 0 ) {printf("failed to get color white/n"); exit(-1);} else XSetForeground( display_ptr, gc_white, tmp_color1.pixel ); if ( argc != 2 ) { printf( "Usage: %s filename.extension /n", argv[0] ); exit(-1);//.........这里部分代码省略.........
开发者ID:ankan1612,项目名称:Shortest-Path,代码行数:101,
示例9: BlackPixelunsigned long QXlibScreen::blackPixel(){ return BlackPixel(mDisplay->nativeDisplay(), mScreen);}
开发者ID:RS102839,项目名称:qt,代码行数:4,
示例10: BlackPixel unsigned long XApplication::GetBlackColor() const { return BlackPixel(this->display, this->screen); }
开发者ID:johannalee,项目名称:cs349,代码行数:4,
示例11: strcpyvoidWindowDevice::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,
示例12: gstroke_invisible_window_init/* This function should be written using GTK+ primitives*/static voidgstroke_invisible_window_init (GtkWidget *widget){ XSetWindowAttributes w_attr; XWindowAttributes orig_w_attr; unsigned long mask, col_border, col_background; unsigned int border_width; XSizeHints hints; Display *disp = GDK_WINDOW_XDISPLAY(gtk_widget_get_window(widget)); Window wind = gdk_x11_window_get_xid(gtk_widget_get_window(widget)); int screen = DefaultScreen (disp); if (!gstroke_draw_strokes()) return; gstroke_disp = disp; /* X server should save what's underneath */ XGetWindowAttributes (gstroke_disp, wind, &orig_w_attr); hints.x = orig_w_attr.x; hints.y = orig_w_attr.y; hints.width = orig_w_attr.width; hints.height = orig_w_attr.height; mask = CWSaveUnder; w_attr.save_under = True; /* inhibit all the decorations */ mask |= CWOverrideRedirect; w_attr.override_redirect = True; /* Don't set a background, transparent window */ mask |= CWBackPixmap; w_attr.background_pixmap = None; /* Default input window look */ col_background = WhitePixel (gstroke_disp, screen); /* no border for the window */#if 0 border_width = 5;#endif border_width = 0; col_border = BlackPixel (gstroke_disp, screen); gstroke_window = XCreateSimpleWindow (gstroke_disp, wind, 0, 0, hints.width - 2 * border_width, hints.height - 2 * border_width, border_width, col_border, col_background); gstroke_gc = XCreateGC (gstroke_disp, gstroke_window, 0, NULL); XSetFunction (gstroke_disp, gstroke_gc, GXinvert); XChangeWindowAttributes (gstroke_disp, gstroke_window, mask, &w_attr); XSetLineAttributes (gstroke_disp, gstroke_gc, 2, LineSolid, CapButt, JoinMiter); XMapRaised (gstroke_disp, gstroke_window);#if 0 /*FIXME: is this call really needed? If yes, does it need the real argc and argv? */ hints.flags = PPosition | PSize; XSetStandardProperties (gstroke_disp, gstroke_window, "gstroke_test", NULL, (Pixmap)NULL, NULL, 0, &hints); /* Receive the close window client message */ { /* FIXME: is this really needed? If yes, something should be done with wmdelete...*/ Atom wmdelete = XInternAtom (gstroke_disp, "WM_DELETE_WINDOW", False); XSetWMProtocols (gstroke_disp, gstroke_window, &wmdelete, True); }#endif}
开发者ID:N8Fear,项目名称:purple-facebook,代码行数:81,
示例13: main int main (void) { int i; int allocateOK; ximg = NULL; d = XOpenDisplay (NULL); if (!d) fputs ("Couldn't open display/n", stderr), exit (1); screen = DefaultScreen (d); gc = DefaultGC (d, screen); /* Find a visual */ vis.screen = screen; vlist = XGetVisualInfo (d, VisualScreenMask, &vis, &match); if (!vlist) fputs ("No matched visuals/n", stderr), exit (1); vis = vlist[0]; XFree (vlist); // That's not a fair comparison colormap_size is depth in bits! // if (vis.colormap_size < COLORS) // printf("Colormap is too small: %i./n",vis.colormap_size); // , exit (1); // printf("Colour depth: %i/n",vis.colormap_size); // No way this number means nothing! It is 64 for 16-bit truecolour and 256 for 8-bit! win = XCreateSimpleWindow (d, DefaultRootWindow (d), 0, 0, WIN_W, WIN_H, 0, WhitePixel (d, screen), BlackPixel (d, screen)); int xclass=get_xvisinfo_class(vis); // printf("class = %i/n",xclass); stylee = ( vis.depth > 8 ? styleeTrueColor : styleePrivate ); // printf("stylee=%i/n",stylee); if ( get_xvisinfo_class(vis) % 2 == 1) { /* The odd numbers can redefine colors */ // printf("%i/n",get_xvisinfo_class(vis)); colormap = DefaultColormap (d, screen); Visual *defaultVisual=DefaultVisual(d,screen); /* Allocate cells */ allocateOK = (XAllocColorCells (d, colormap, 1, NULL, 0, color, COLORS) != 0); printf("Allocated OK? %i/n",allocateOK); if (allocateOK) { // printf("Allocated OK/n"); // This doesn't work for installed colormap! /* Modify the colorcells */ for (i = 0; i < COLORS; i++) xrgb[i].pixel = color[i]; XStoreColors (d, colormap, xrgb, COLORS); } else { colormap = XCreateColormap(d,win,defaultVisual,AllocNone); // redocolors(); } // black = XBlackPixel(d,screen); // white = XWhitePixel(d,screen); XAllocColorCells(d,colormap,1,0,0,color,colors); XSetWindowColormap(d,win,colormap); } else if ( get_xvisinfo_class(vis) == TrueColor) { colormap = DefaultColormap (d, screen); // printf("TrueColor %i = %i/n",xclass,TrueColor); /* This will lookup the color and sets the xrgb[i].pixel value */ // for (i = 0; i < COLORS; i++) // XAllocColor (d, colormap, &xrgb[i]); } else fprintf (stderr, "Not content with visual class %d./n", get_xvisinfo_class(vis) ), exit (1); /* Find out if MITSHM is supported and useable */ printf ("MITSHM: "); if (XShmQueryVersion (d, &mitshm_major_code, &mitshm_minor_code, &shared_pixmaps)) { int (*handler) (Display *, XErrorEvent *); ximg = XShmCreateImage (d, vis.visual, vis.depth, XShmPixmapFormat (d), NULL, &shminfo, WIN_W, WIN_H);//.........这里部分代码省略.........
开发者ID:10crimes,项目名称:code,代码行数:101,
示例14: loadFontint XMessageBox::show(){ if (mDisplay == NULL) return -1; int retVal = 0; retVal = loadFont(); if (retVal < 0) return retVal; // set the maximum window dimensions mScreenWidth = DisplayWidth(mDisplay, DefaultScreen(mDisplay)); mScreenHeight = DisplayHeight(mDisplay, DefaultScreen(mDisplay)); mMaxWindowWidth = min(mScreenWidth, MessageBox_MaxWinWidth); mMaxWindowHeight = min(mScreenHeight, MessageBox_MaxWinHeight); // split the message into a vector of lines splitMessage(); // set the dialog dimensions setDimensions(); mWin = XCreateSimpleWindow( mDisplay, DefaultRootWindow(mDisplay), (mScreenWidth - mMBWidth) / 2, (mScreenHeight - mMBHeight) / 2, mMBWidth, mMBHeight, 1, BlackPixel(mDisplay, DefaultScreen(mDisplay)), WhitePixel(mDisplay, DefaultScreen(mDisplay))); mGC = XCreateGC(mDisplay, mWin, 0, 0); XSetFont(mDisplay, mGC, mFS->fid); // set input mask XSelectInput(mDisplay, mWin, ExposureMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask); // set wm protocols in case they hit X Atom wm_delete_window = XInternAtom(mDisplay, "WM_DELETE_WINDOW", False); Atom wm_protocols = XInternAtom(mDisplay, "WM_PROTOCOLS", False); XSetWMProtocols (mDisplay, mWin, &wm_delete_window, 1); // set pop up dialog hint XSetTransientForHint(mDisplay, mWin, mWin); // set title XTextProperty wtitle; wtitle.value = (unsigned char *)mTitle; wtitle.encoding = XA_STRING; wtitle.format = 8; wtitle.nitems = strlen(mTitle); XSetWMName(mDisplay, mWin, &wtitle); // show window XMapWindow(mDisplay, mWin); // move it in case some bozo window manager repositioned it XMoveWindow(mDisplay, mWin, (mScreenWidth - mMBWidth) / 2, (mScreenHeight - mMBHeight) / 2); // raise it to top XRaiseWindow(mDisplay, mWin); XMessageBoxButton* clickedButton = NULL; XEvent event; Vector<XMessageBoxButton>::iterator iter; bool done = false; while (!done) { XNextEvent(mDisplay, &event); switch (event.type) { case Expose: repaint(); break; case MotionNotify: for (iter = mButtons.begin(); iter != mButtons.end(); ++iter) iter->setMouseCoordinates(event.xmotion.x, event.xmotion.y); break; case ButtonPress: for (iter = mButtons.begin(); iter != mButtons.end(); ++iter) { if (iter->pointInRect(event.xbutton.x, event.xbutton.y)) { iter->setMouseDown(true); iter->setMouseCoordinates(event.xbutton.x, event.xbutton.y); break; } } break; case ButtonRelease: for (iter = mButtons.begin(); iter != mButtons.end(); ++iter) { if (iter->pointInRect(event.xbutton.x, event.xbutton.y) && iter->isMouseDown()) { // we got a winner! clickedButton = iter; done = true;//.........这里部分代码省略.........
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:101,
示例15: drawswarmvoiddrawswarm(Window win){ swarmstruct *sp = &swarms[screen]; int b; /* <=- Wasp -=> */ /* Age the arrays. */ sp->wx[2] = sp->wx[1]; sp->wx[1] = sp->wx[0]; sp->wy[2] = sp->wy[1]; sp->wy[1] = sp->wy[0]; /* Accelerate */ sp->wxv += balance_rand(WASPACC); sp->wyv += balance_rand(WASPACC); /* Speed Limit Checks */ if (sp->wxv > WASPVEL) sp->wxv = WASPVEL; if (sp->wxv < -WASPVEL) sp->wxv = -WASPVEL; if (sp->wyv > WASPVEL) sp->wyv = WASPVEL; if (sp->wyv < -WASPVEL) sp->wyv = -WASPVEL; /* Move */ sp->wx[0] = sp->wx[1] + sp->wxv; sp->wy[0] = sp->wy[1] + sp->wyv; /* Bounce Checks */ if ((sp->wx[0] < sp->border) || (sp->wx[0] > sp->width - sp->border - 1)) { sp->wxv = -sp->wxv; sp->wx[0] += sp->wxv; } if ((sp->wy[0] < sp->border) || (sp->wy[0] > sp->height - sp->border - 1)) { sp->wyv = -sp->wyv; sp->wy[0] += sp->wyv; } /* Don't let things settle down. */ sp->xv[LRAND() % sp->beecount] += balance_rand(3); sp->yv[LRAND() % sp->beecount] += balance_rand(3); /* <=- Bees -=> */ for (b = 0; b < sp->beecount; b++) { int distance, dx, dy; /* Age the arrays. */ X(2, b) = X(1, b); X(1, b) = X(0, b); Y(2, b) = Y(1, b); Y(1, b) = Y(0, b); /* Accelerate */ dx = sp->wx[1] - X(1, b); dy = sp->wy[1] - Y(1, b); distance = abs(dx) + abs(dy); /* approximation */ if (distance == 0) distance = 1; sp->xv[b] += (dx * BEEACC) / distance; sp->yv[b] += (dy * BEEACC) / distance; /* Speed Limit Checks */ if (sp->xv[b] > BEEVEL) sp->xv[b] = BEEVEL; if (sp->xv[b] < -BEEVEL) sp->xv[b] = -BEEVEL; if (sp->yv[b] > BEEVEL) sp->yv[b] = BEEVEL; if (sp->yv[b] < -BEEVEL) sp->yv[b] = -BEEVEL; /* Move */ X(0, b) = X(1, b) + sp->xv[b]; Y(0, b) = Y(1, b) + sp->yv[b]; /* Fill the segment lists. */ sp->segs[b].x1 = X(0, b); sp->segs[b].y1 = Y(0, b); sp->segs[b].x2 = X(1, b); sp->segs[b].y2 = Y(1, b); sp->old_segs[b].x1 = X(1, b); sp->old_segs[b].y1 = Y(1, b); sp->old_segs[b].x2 = X(2, b); sp->old_segs[b].y2 = Y(2, b); } XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen)); XDrawLine(dsp, win, Scr[screen].gc, sp->wx[1], sp->wy[1], sp->wx[2], sp->wy[2]); XDrawSegments(dsp, win, Scr[screen].gc, sp->old_segs, sp->beecount); XSetForeground(dsp, Scr[screen].gc, WhitePixel(dsp, screen)); XDrawLine(dsp, win, Scr[screen].gc, sp->wx[0], sp->wy[0], sp->wx[1], sp->wy[1]); if (!mono && Scr[screen].npixels > 2) { XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[sp->pix]); if (++sp->pix >= Scr[screen].npixels) sp->pix = 0; }//.........这里部分代码省略.........
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:101,
示例16: mainmain(){ int llx,lly,urx,ury,width,height, scrwidth,scrheight,scrwidthmm,scrheightmm; float xres,yres; char buf[LBUF]; Display *dpy; int scr; unsigned long black,white; GC gcpix,gcwin; Window win; Pixmap pix; XEvent ev; DPSContext dps; /* open display */ if ((dpy=XOpenDisplay(NULL))==NULL) { fprintf(stderr,"Cannot connect to display %s/n", XDisplayName(NULL)); exit(-1); } scr = DefaultScreen(dpy); black = BlackPixel(dpy,scr); white = WhitePixel(dpy,scr); /* determine BoundingBox */ llx = LLX_DEFAULT; lly = LLY_DEFAULT; urx = URX_DEFAULT; ury = URY_DEFAULT; fgets(buf,LBUF,stdin); if (strstr(buf,"EPS")!=NULL) { while(fgets(buf,LBUF,stdin)!=NULL) { if (buf[0]!='%' || buf[1]!='%') continue; if (strstr(buf,"%%BoundingBox:")==buf) { if (strstr(buf,"(atend)")==NULL) { sscanf(&buf[14],"%d %d %d %d", &llx,&lly,&urx,&ury); } break; } else if (strstr(buf,"%%EndComments")==buf) { break; } else if (strstr(buf,"%%EndProlog")==buf) { break; } } } /* width and height in pixels */ scrwidth = WidthOfScreen(DefaultScreenOfDisplay(dpy)); scrheight = HeightOfScreen(DefaultScreenOfDisplay(dpy)); scrwidthmm = WidthMMOfScreen(DefaultScreenOfDisplay(dpy)); scrheightmm = HeightMMOfScreen(DefaultScreenOfDisplay(dpy)); xres = (int)(25.4*scrwidth/scrwidthmm)/72.0; yres = (int)(25.4*scrheight/scrheightmm)/72.0; if (xres*(urx-llx)>scrwidth || yres*(ury-lly)>scrheight) { xres = (scrwidth-32.0)/(urx-llx); yres = (scrheight-32.0)/(ury-lly); xres = yres = (xres<yres)?xres:yres; } width = (urx-llx)*xres; height = (ury-lly)*yres; /* create pixmap and its gc */ pix = XCreatePixmap(dpy,DefaultRootWindow(dpy),width,height, DefaultDepth(dpy,scr)); gcpix = XCreateGC(dpy,pix,0,NULL); /* create and set Display PostScript context for pixmap */ dps = XDPSCreateSimpleContext(dpy,pix,gcpix,0,height, DPSDefaultTextBackstop,DPSDefaultErrorProc,NULL); if (dps==NULL) { fprintf(stderr,"Cannot create DPS context/n"); exit(-1); } DPSPrintf(dps,"/n resyncstart/n"); DPSSetContext(dps); DPSFlushContext(dps); DPSWaitContext(dps); /* paint white background */ DPSPrintf(dps, "gsave/n" "1 setgray/n" "0 0 %d %d rectfill/n" "grestore/n", urx-llx,ury-lly); /* translate */ DPSPrintf(dps,"%d %d translate/n",-llx,-lly); /* read PostScript from standard input and render in pixmap */ DPSPrintf(dps,"/showpage {} def/n"); while (fgets(buf,LBUF,stdin)!=NULL) DPSWritePostScript(dps,buf,strlen(buf)); DPSFlushContext(dps); DPSWaitContext(dps); /* create and map window */ win = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),//.........这里部分代码省略.........
开发者ID:gwowen,项目名称:seismicunix,代码行数:101,
示例17: CreeTermGraphint CreeTermGraph(TC *p,unsigned int largeur,unsigned int hauteur,char* titre){ char *display_name = getenv("DISPLAY"); unsigned long valuemask = 0; XGCValues values ; p->largeur = largeur; p->hauteur = hauteur; if ((p->display = XOpenDisplay(display_name)) == NULL) return -1; p->screen_num = DefaultScreen(p->display); p->win = XCreateSimpleWindow(p->display, RootWindow(p->display,p->screen_num), 0,0, largeur,hauteur, 1, BlackPixel(p->display,p->screen_num), WhitePixel(p->display,p->screen_num)); XStoreName(p->display,p->win,titre); XMapWindow(p->display,p->win); XFlush(p->display); p->gc = XCreateGC(p->display,p->win,valuemask,&values); /***** Allocations des couleurs *****/ p->cm = DefaultColormap(p->display,DefaultScreen(p->display)); if (XAllocNamedColor(p->display,p->cm,"black",&(p->Noir),&(p->Noir)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"white",&(p->Blanc),&(p->Blanc)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"red",&(p->Rouge),&(p->Rouge)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"blue",&(p->Bleu),&(p->Bleu)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"green",&(p->Vert),&(p->Vert)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"yellow",&(p->Jaune),&(p->Jaune)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"brown",&(p->Brun),&(p->Brun)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"gray",&(p->Gris),&(p->Gris)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"magenta",&(p->Magenta),&(p->Magenta)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"cyan",&(p->Cyan),&(p->Cyan)) == 0) return -1; if (XAllocNamedColor(p->display,p->cm,"orange",&(p->Orange),&(p->Orange)) == 0) return -1; XSetBackground(p->display, p->gc, p->Blanc.pixel); XSync(p->display, False); sleep(1); return 0;}
开发者ID:r0llup,项目名称:SpaceInvaders,代码行数:72,
示例18: QPlatformWindowQT_BEGIN_NAMESPACEQXlibWindow::QXlibWindow(QWidget *window) : QPlatformWindow(window) , mGLContext(0) , mScreen(QXlibScreen::testLiteScreenForWidget(window)){ int x = window->x(); int y = window->y(); int w = window->width(); int h = window->height();#if !defined(QT_NO_OPENGL) if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) || window->platformWindowFormat().alpha()) {#if !defined(QT_OPENGL_ES_2) XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat());#else QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat()); EGLDisplay eglDisplay = mScreen->eglDisplay(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat); VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); visualInfoTemplate.visualid = id; XVisualInfo *visualInfo; int matchingCount = 0; visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);#endif //!defined(QT_OPENGL_ES_2) if (visualInfo) { mDepth = visualInfo->depth; mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; mVisual = visualInfo->visual; Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone); XSetWindowAttributes a; a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); a.colormap = cmap; x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h, 0, visualInfo->depth, InputOutput, visualInfo->visual, CWBackPixel|CWBorderPixel|CWColormap, &a); } else { qFatal("no window!"); } } else#endif //!defined(QT_NO_OPENGL) { mDepth = mScreen->depth(); mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; mVisual = mScreen->defaultVisual(); x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), x, y, w, h, 0 /*border_width*/, mScreen->blackPixel(), mScreen->whitePixel()); }#ifdef MYX11_DEBUG qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;#endif XSetWindowBackgroundPixmap(mScreen->display()->nativeDisplay(), x_window, XNone); XSelectInput(mScreen->display()->nativeDisplay(), x_window, ExposureMask | KeyPressMask | KeyReleaseMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PropertyChangeMask | StructureNotifyMask); gc = createGC(); Atom protocols[5]; int n = 0; protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW); // support del window protocol protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS); // support take focus window protocol// protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol#ifndef QT_NO_XSYNC protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol#endif // QT_NO_XSYNC if (window->windowFlags() & Qt::WindowContextHelpButtonHint) protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP); XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);}
开发者ID:maxxant,项目名称:qt,代码行数:88,
示例19: ui_initintui_init( int *argc, char ***argv ){ char *displayName=NULL; /* Use default display */ XWMHints *wmHints; XSizeHints *sizeHints; XClassHint *classHint; char *windowNameList=(char *)"Fuse",*iconNameList=(char *)"Fuse"; XTextProperty windowName, iconName; unsigned long windowFlags; XSetWindowAttributes windowAttributes; /* Allocate memory for various things */ if( ui_widget_init() ) return 1; if(!(wmHints = XAllocWMHints())) { fprintf(stderr,"%s: failure allocating memory/n", fuse_progname); return 1; } if(!(sizeHints = XAllocSizeHints())) { fprintf(stderr,"%s: failure allocating memory/n", fuse_progname); return 1; } if(!(classHint = XAllocClassHint())) { fprintf(stderr,"%s: failure allocating memory/n", fuse_progname); return 1; } if(XStringListToTextProperty(&windowNameList,1,&windowName) == 0 ) { fprintf(stderr,"%s: structure allocation for windowName failed/n", fuse_progname); return 1; } if(XStringListToTextProperty(&iconNameList,1,&iconName) == 0 ) { fprintf(stderr,"%s: structure allocation for iconName failed/n", fuse_progname); return 1; } /* Open a connection to the X server */ if ( ( display=XOpenDisplay(displayName)) == NULL ) { fprintf(stderr,"%s: cannot connect to X server %s/n", fuse_progname, XDisplayName(displayName)); return 1; } /* Set up our error handler */ xerror_expecting = xerror_error = 0; XSetErrorHandler( xerror_handler ); xui_screenNum = DefaultScreen(display); /* Create the main window */ xui_mainWindow = XCreateSimpleWindow( display, RootWindow( display, xui_screenNum ), 0, 0, DISPLAY_ASPECT_WIDTH, DISPLAY_SCREEN_HEIGHT, 0, BlackPixel( display, xui_screenNum ), WhitePixel( display, xui_screenNum ) ); /* Set standard window properties */ sizeHints->flags = PBaseSize | PResizeInc | PMaxSize | PMinSize; sizeHints->base_width = 0; sizeHints->base_height = 0; sizeHints->min_width = DISPLAY_ASPECT_WIDTH; sizeHints->min_height = DISPLAY_SCREEN_HEIGHT; sizeHints->width_inc = DISPLAY_ASPECT_WIDTH; sizeHints->height_inc = DISPLAY_SCREEN_HEIGHT; sizeHints->max_width = 3 * DISPLAY_ASPECT_WIDTH; sizeHints->max_height = 3 * DISPLAY_SCREEN_HEIGHT; if( settings_current.aspect_hint ) { sizeHints->flags |= PAspect; sizeHints->min_aspect.x = 4; sizeHints->min_aspect.y = 3; sizeHints->max_aspect.x = 4; sizeHints->max_aspect.y = 3; } wmHints->flags=StateHint | InputHint; wmHints->initial_state=NormalState; wmHints->input=True; classHint->res_name=(char *)fuse_progname; classHint->res_class=(char *)"Fuse"; XSetWMProperties(display, xui_mainWindow, &windowName, &iconName, *argv, *argc, sizeHints, wmHints, classHint); XFree( windowName.value ); XFree( iconName.value ); XFree( sizeHints );//.........这里部分代码省略.........
开发者ID:jacadym,项目名称:fuse-emulator,代码行数:101,
示例20: set_full_screenint set_full_screen(Display *dpy) { signal(SIGUSR1, fake_right_button); fulldisplay = dpy; Window curwin, rootw; Cursor hand_cursor; int x1, y1, winx, winy; unsigned int mask; XEvent ev; int screen_num; if (!dpy) { fprintf(stderr, "WTPEN : cannot get default display/n"); exit(1); } /* style for line */ unsigned int line_width = 8; int line_style = LineSolid; int cap_style = CapRound; int join_style = JoinRound; screen_num = DefaultScreen(dpy); rootw = DefaultRootWindow(dpy); if (rootw == None) { fprintf(stderr, "WTPEN : full screen mode cannot get root window/n"); exit(1); } hand_cursor = XCreateFontCursor(dpy, XC_hand2); drawgc = XCreateGC(dpy, rootw, 0, NULL); // hier wordt getekend (met xor) XSetSubwindowMode(dpy, drawgc, IncludeInferiors); XSetForeground(dpy, drawgc, WhitePixel(dpy, screen_num) ^ BlackPixel(dpy, screen_num)); XSetLineAttributes(dpy, drawgc, line_width, line_style, cap_style, join_style); XSetFunction(dpy, drawgc, GXandInverted); //XSetFunction(dpy, drawgc, GXxor); fprintf(stderr, "full screen mode grab button/n"); XGrabButton(dpy, AnyButton, 0, rootw, False, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | OwnerGrabButtonMask, GrabModeSync, GrabModeAsync, None, hand_cursor); while (1) { fprintf (stderr, "fullscreen/n"); // wordt bij tekenen aangeroepen XAllowEvents(dpy, SyncPointer, CurrentTime); XWindowEvent(dpy, rootw, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask, &ev); switch(ev.type) { case ButtonPress: kill(getppid(), SIGUSR2); if(ev.xbutton.button != Button1) { int num; XUngrabButton(dpy, AnyButton, 0, rootw); XFlush(dpy); record_coordinate(0xff, 0xff); clear_draw_area(dpy, rootw, drawgc); num = get_coordinates_num(); return num; } XQueryPointer(dpy, rootw, &rootw, &curwin, &x1, &y1, //root x, root y &winx, &winy, &mask); record_coordinate(x1, y1); break; case ButtonRelease: if (ev.xbutton.button == Button1) { if (get_coordinates_num() == 2) { free_coordinates(); XUngrabButton(dpy, AnyButton, 0, rootw); forward_click_event(dpy, &ev); XFlush(dpy); return 0; } record_coordinate(0xff, 0x00); kill(getppid(), SIGALRM); } break; case MotionNotify: if (ev.xmotion.state & Button1MotionMask) { CoordinateList *cl_end; XQueryPointer(dpy, rootw, &rootw, &curwin, &x1, &y1, //root x, root y &winx, &winy, &mask); cl_end = coordinate_list_end(); if (cl_end) { if (!(cl_end->x == 0xff && cl_end->y == 0x00)) { XDrawLine(dpy, rootw, drawgc, x1, y1, cl_end->x, cl_end->y);//.........这里部分代码省略.........
开发者ID:arievanleyen,项目名称:xpen,代码行数:101,
示例21: main//.........这里部分代码省略......... scroll_type = SCROLL_SMOOTH3; } else if (strcmp(optarg, "smooth4") == 0) { scroll_type = SCROLL_SMOOTH4; } else { fprintf(stderr, "/ninvalid scroll type specified/n/n"); usage(); return -1; } break; default: usage(); return -1; } } // must have at least one operation if ((!draw_lines) && (!draw_rects) && (!draw_stipples) && (!draw_fonts) && (!draw_image)) { usage(); return -1; } g_disp = XOpenDisplay(NULL); if (!g_disp) { dprint("error opening X display/n"); exit(-1); } screenNumber = DefaultScreen(g_disp); white = WhitePixel(g_disp, screenNumber); black = BlackPixel(g_disp, screenNumber); g_win = XCreateSimpleWindow(g_disp, DefaultRootWindow(g_disp), 50, 50, // origin g_winWidth, g_winHeight, // size 0, black, // border white ); // backgd XMapWindow(g_disp, g_win); //eventMask = StructureNotifyMask | MapNotify | VisibilityChangeMask; eventMask = StructureNotifyMask | VisibilityChangeMask; XSelectInput(g_disp, g_win, eventMask); g_gc = XCreateGC(g_disp, g_win, 0, // mask of values NULL ); // array of values #if 0 do { dprint("about to call XNextEvent(...)/n"); XNextEvent(g_disp, &evt);// calls XFlush dprint("returned from XNextEvent(...)/n"); } //while(evt.type != MapNotify); while(evt.type != VisibilityNotify); #endif // get access to the screen's color map colormap = DefaultColormap(g_disp, screenNumber); // alloc red color rc = XAllocNamedColor(g_disp, colormap, "red", &g_colors[0], &g_colors[0]);
开发者ID:cuzz,项目名称:xrdp,代码行数:67,
示例22: init_windowvoid init_window(int argc, char *argv[]){ unsigned long get_color_pix(char *color_name); screen = DefaultScreen(display);#if defined(HAVE_BZERO) && !defined(HAVE_MEMSET) bzero(&xsh, sizeof(xsh));#else memset(&xsh, 0, sizeof(xsh));#endif if (geometry) { int bitmask; bitmask = XGeometry(display, screen, geometry, NULL, bwidth, 1, 1, 1, 1, &(xsh.x), &(xsh.y), &(xsh.width), &(xsh.height)); if (bitmask & (XValue | YValue)) { xsh.flags |= USPosition; } if (bitmask & (WidthValue | HeightValue)) { xsh.flags |= USSize; } } else { xsh.flags = USPosition | PSize; if (!landscape) { xsh.width = XLENG / shrink; xsh.height = YLENG / shrink; xsh.x = X0; xsh.y = Y0; } else { xsh.width = YLENG / shrink; xsh.height = XLENG / shrink; xsh.x = X0_LAND; xsh.y = Y0; } } /** Color **/#ifdef COLOR_BUG reverse = 1;#endif if (DisplayPlanes(display, screen) >= 3) { c_flg = 1; if (!reverse) { forepix = get_color_pix(fore_color); backpix = get_color_pix(back_color); highpix = get_color_pix(high_color); brdrpix = get_color_pix(brdr_color); mouspix = get_color_pix(mous_color); } else { forepix = get_color_pix(back_color); backpix = get_color_pix(fore_color); highpix = get_color_pix(high_color); brdrpix = get_color_pix(brdr_color); mouspix = get_color_pix(mous_color); } } else { if (!reverse) { forepix = BlackPixel(display, screen); highpix = BlackPixel(display, screen); backpix = WhitePixel(display, screen); brdrpix = BlackPixel(display, screen); mouspix = BlackPixel(display, screen); } else { forepix = WhitePixel(display, screen); highpix = WhitePixel(display, screen); backpix = BlackPixel(display, screen); brdrpix = WhitePixel(display, screen); mouspix = WhitePixel(display, screen); } } /** Generate Window **/ main_window = XCreateSimpleWindow(display, DefaultRootWindow(display), xsh.x, xsh.y, xsh.width, xsh.height, bwidth, brdrpix, backpix); XSetStandardProperties(display, main_window, windowtitle, windowtitle, None, argv, argc, &xsh); /* winatt.bit_gravity = SouthWestGravity; */ XChangeWindowAttributes(display, main_window, CWBitGravity, &winatt); /** Map Window **/ XSelectInput(display, main_window, StructureNotifyMask); XMapWindow(display, main_window); for (;;) { XNextEvent(display, &ev); if (ev.type == MapNotify) break; } XSelectInput(display, main_window, ButtonPressMask | PointerMotionMask | KeyPressMask | ExposureMask); /* KeyReleaseMask|ExposureMask|StructureNotifyMask); */ /** Cursor **///.........这里部分代码省略.........
开发者ID:minhquangnguyen,项目名称:Backup,代码行数:101,
示例23: gui_draw_xor_boxstatic void gui_draw_xor_box(GC gc, int x, int y, int width, int height){ XSetForeground(gui->display, gc, WhitePixel(gui->display, gui->screen) ^ BlackPixel(gui->display, gui->screen)); XDrawRectangle(gui->display, gui->root, gc, x, y, width, height);}
开发者ID:chinese-opendesktop,项目名称:oxim,代码行数:5,
示例24: main int main(int argc, char **argv) { static char *string = "Hello World!"; Display *display; int screen_num; Window win; //窗口ID unsigned int width, height; //窗口尺寸 unsigned int border_width = 0; //边界空白 unsigned int display_width, display_height;//屏幕尺寸 int count; XEvent report; GC gc; unsigned long valuemask = 0; XGCValues values; char *display_name = NULL; //attribute vars XSizeHints size_hints; XSetWindowAttributes attrib; unsigned long attribmask; //moving window Window root, child; unsigned int mask; int root_x, root_y, win_x, win_y, orig_x, orig_y; // 和X 服务器连接 if ( (display=XOpenDisplay(display_name)) == NULL ) { printf("Cannot connect to X server %s/n", XDisplayName(display_name)); exit(-1); } //获得缺省的 screen_num screen_num = DefaultScreen(display); //获得屏幕的宽度和高度 display_width = DisplayWidth(display, screen_num); display_height = DisplayHeight(display, screen_num); //指定所建立窗口的宽度和高度 width = display_width/3; height = display_height/4; //建立窗口 win = XCreateSimpleWindow(display, //display RootWindow(display,screen_num), //父窗口 100, 100, width, height, //位置和大小 border_width, //边界宽度 BlackPixel(display,screen_num), //前景色 WhitePixel(display,screen_num));//背景色 //设置属性 attrib.override_redirect = True; attribmask = CWOverrideRedirect; XChangeWindowAttributes(display, win, attribmask, &attrib); //选择窗口感兴趣的事件掩码 XSelectInput(display, win, ExposureMask | KeyPressMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask); //建立GC gc = DefaultGC(display, screen_num); //显示窗口 XMapWindow(display, win); //设置为键盘聚焦窗口 XSetInputFocus(display, win, False, CurrentTime); //进入事件循环 while (1) { //取得队列中的事件 XNextEvent(display, &report); switch (report.type) { //曝光事件, 窗口应重绘 case Expose: //取得最后一个曝光事件 if (report.xexpose.count != 0) break; draw(display, win, gc); break; //窗口尺寸改变, 重新取得窗口的宽度和高度 case ConfigureNotify: break; //取得位置 case ButtonPress: //把窗口浮动到最上方 XRaiseWindow(display, win); //设置键盘聚焦 XSetInputFocus(display, win, False,CurrentTime); //取得指针相对于根窗口的位置和窗口的位置 XQueryPointer(display,win,&root,&child, &root_x, &root_y, &win_x, &win_y,//.........这里部分代码省略.........
开发者ID:alannet,项目名称:example,代码行数:101,
示例25: gui_move_windowvoidgui_move_window(winlist_t *win){ xccore_t *xccore = (xccore_t *)win->data; int event_x, event_y; int offset_x, offset_y; int move_x, move_y; GC moveGC; int draw_flag = False; int workarea_x, workarea_y; int workarea_x2, workarea_y2; unsigned int workarea_width, workarea_height; gui_get_workarea(&workarea_x, &workarea_y, &workarea_width, &workarea_height); workarea_x2 = workarea_x + workarea_width; workarea_y2 = workarea_y + workarea_height; gui_get_mouse_xy(&event_x, &event_y); offset_x = event_x - win->pos_x; offset_y = event_y - win->pos_y; moveGC = XCreateGC(gui->display, gui->root, 0, NULL); XSetSubwindowMode(gui->display, moveGC, IncludeInferiors); XSetForeground(gui->display, moveGC, BlackPixel(gui->display, gui->screen)); XSetFunction(gui->display, moveGC, GXxor); XChangeActivePointerGrab(gui->display, PointerMotionMask | ButtonMotionMask | ButtonReleaseMask | OwnerGrabButtonMask, None, CurrentTime); XGrabServer(gui->display); XEvent myevent; while(1) { XNextEvent(gui->display, &myevent); switch(myevent.type) { case ButtonRelease: if(myevent.xbutton.button == Button1) { if (draw_flag) { gui_draw_xor_box(moveGC, move_x - offset_x, move_y - offset_y, win->width, win->height); } XFreeGC(gui->display, moveGC); gui_get_mouse_xy(&move_x, &move_y); win->pos_x = move_x - offset_x; win->pos_y = move_y - offset_y; /* */ if (win->pos_x < workarea_x) win->pos_x = workarea_x; if (win->pos_y < workarea_y) win->pos_y = workarea_y; if (win->pos_x + win->width > workarea_x2) win->pos_x = workarea_x2 - win->width - 2; if (win->pos_y + win->height > workarea_y2) win->pos_y = workarea_y2 - win->height - 2; XMoveWindow(gui->display, win->window, win->pos_x, win->pos_y); XUngrabServer(gui->display); gui_save_window_pos(); /* C++ BlackPixelOfScreen函数代码示例 C++ Bits_memset函数代码示例
|