示例#1
0
static void init_X() {
    int screen;
    unsigned long foreground, background;
    XSizeHints hints;
    char **argv = NULL;
    XGCValues gcValues;
    Colormap colormap;
    XColor rgb_color, hw_color;
    Font font;
    //char *FNAME = "hanzigb24st";
    char *FNAME = "-misc-fixed-medium-r-normal--0-0-100-100-c-0-iso10646-1";

    display = XOpenDisplay(NULL);
    if (display == NULL) {
	fprintf(stderr, "Can't open dsplay\n");
	exit(1);
    }
    screen = DefaultScreen(display);
    foreground = BlackPixel(display, screen);
    background = WhitePixel(display, screen);

    window = XCreateSimpleWindow(display,
				 DefaultRootWindow(display),
				 0, 0, WIDTH, HEIGHT, 10,
				 foreground, background);
    hints.x = 0;
    hints.y = 0;
    hints.width = WIDTH;
    hints.height = HEIGHT;
    hints.flags = PPosition | PSize;

    XSetStandardProperties(display, window, 
			   "X", "X", 
			   None,
			   argv, 0,
			   &hints);

    XMapWindow(display, window);


    set_font();
    surface = cairo_xlib_surface_create(display, window,
					DefaultVisual(display, 0), WIDTH, HEIGHT);
    cairo_xlib_surface_set_size(surface, WIDTH, HEIGHT);

    paint_background();

    /*
    cr = cairo_create(surface);
    draw_text(g_array_index(lyric_lines.lines, GString *, 0)->str,
	      0.0, 0.0, 1.0, height_lyric_pixbufs[0]);
    draw_text(g_array_index(lyric_lines.lines, GString*, 1)->str,
	      0.0, 0.0, 1.0, height_lyric_pixbufs[0]);
    cairo_destroy(cr);
    */
    XFlush(display);
}
示例#2
0
static Window make_rgb_db_window( Display *dpy, int xpos, int ypos,
				  unsigned int width, unsigned int height )
{
   int attrib[] = { GLX_RGBA,
		    GLX_RED_SIZE, 1,
		    GLX_GREEN_SIZE, 1,
		    GLX_BLUE_SIZE, 1,
		    GLX_DOUBLEBUFFER,
		    None };
   int scrnum;
   XSetWindowAttributes attr;
   unsigned long mask;
   Window root;
   Window win;
   GLXContext ctx;
   XVisualInfo *visinfo;

   scrnum = DefaultScreen( dpy );
   root = RootWindow( dpy, scrnum );

   visinfo = glXChooseVisual( dpy, scrnum, attrib );
   if (!visinfo) {
      printf("Error: couldn't get an RGB, Double-buffered visual\n");
      exit(1);
   }

   /* window attributes */
   attr.background_pixel = 0;
   attr.border_pixel = 0;
   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

   win = XCreateWindow( dpy, root, 0, 0, width, height,
		        0, visinfo->depth, InputOutput,
		        visinfo->visual, mask, &attr );

   {
      XSizeHints sizehints;
      sizehints.x = xpos;
      sizehints.y = ypos;
      sizehints.width  = width;
      sizehints.height = height;
      sizehints.flags = USSize | USPosition;
      XSetNormalHints(dpy, win, &sizehints);
      XSetStandardProperties(dpy, win, ProgramName, ProgramName,
                              None, (char **)NULL, 0, &sizehints);
   }


   ctx = glXCreateContext( dpy, visinfo, NULL, True );

   glXMakeCurrent( dpy, win, ctx );

   return win;
}
示例#3
0
void clViewport::SetViewportTitle( const LString& Title )
{
#ifdef OS_WINDOWS
    SetWindowText( FWindowHandle, Title.c_str() );
#endif

#if defined(OS_LINUX) && !defined(OS_ANDROID)
    XSetStandardProperties( FDeviceHandle, *FWindowHandle, Title.c_str(), Title.c_str(), None, NULL, 0, NULL );
#endif
}
示例#4
0
int liqcanvas_settitle(char *newtitle)
{
    
    if(!liqcanvas_isopen())return -1;
    
    
    XSetStandardProperties(liqcanvas_getx11info()->mydisplay, liqcanvas_getx11info()->mywindow, newtitle,
            newtitle, None, NULL, 0, NULL);
    return 0;
}
示例#5
0
/////////////////////////////////////////////////////////
// titleMess
//
/////////////////////////////////////////////////////////
void gemglxwindow :: titleMess(const std::string&s)
{
  m_title=s;
  if(m_pimpl->dpy && m_pimpl->win) {
    XSetStandardProperties(m_pimpl->dpy, m_pimpl->win,
                           m_title.c_str(), "gem",
                           None, 0, 0, NULL);
  }

}
示例#6
0
static void
openWindow(Display *&display, Window &window, unsigned int windowX,
	   unsigned int windowY, char *title)
//
//////////////////////////////////////////////////////////////
{
    XVisualInfo			*vi;
    Colormap			cmap;
    XSetWindowAttributes	swa;
    GLXContext			cx;
    XEvent			event;
    static int			attributeList[] = {
	GLX_RGBA,
	GLX_RED_SIZE, 1,
	GLX_GREEN_SIZE, 1,
	GLX_BLUE_SIZE, 1,
	GLX_DEPTH_SIZE, 1,
	None,		// May be replaced w/GLX_DOUBLEBUFFER
	None,
    };

    display = XOpenDisplay(0);
    vi   = glXChooseVisual(display,
			   DefaultScreen(display),
			   attributeList);
    cx   = glXCreateContext(display, vi, 0, GL_TRUE);
    cmap = XCreateColormap(display,
			   RootWindow(display, vi->screen),
			   vi->visual, AllocNone);
    swa.colormap	= cmap;
    swa.border_pixel	= 0;
    swa.event_mask	= StructureNotifyMask;
    window = XCreateWindow(display,
	   RootWindow(display, vi->screen),
	   10, 10, windowX, windowY,
	   0, vi->depth, InputOutput, vi->visual,
	   (CWBorderPixel | CWColormap | CWEventMask), &swa);

    // Make the window appear in the lower left corner
    XSizeHints *xsh = XAllocSizeHints();
    xsh->flags = USPosition;
    XSetWMNormalHints(display, window, xsh);
    XSetStandardProperties(display, window, title, title, None, 0, 0, 0);
    XFree(xsh);

    XMapWindow(display, window);
    XIfEvent(display, &event, waitForNotify, (char *) window);
    glXMakeCurrent(display, window, cx);

    glEnable(GL_DEPTH_TEST);
    glClearColor(0.5, 0.5, 0.5, 1);
    
    // clear the graphics window and depth planes
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
示例#7
0
static void InternalLinkScreenAndGo( const char * WindowName )
{
	XGetWindowAttributes( CNFGDisplay, CNFGWindow, &CNFGWinAtt );

	XSelectInput (CNFGDisplay, CNFGWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask );
	XSetStandardProperties( CNFGDisplay, CNFGWindow, WindowName, WindowName, None, NULL, 0, NULL );

	CNFGWindowGC = XCreateGC(CNFGDisplay, CNFGWindow, 0, 0);

	CNFGPixmap = XCreatePixmap( CNFGDisplay, CNFGWindow, CNFGWinAtt.width, CNFGWinAtt.height, CNFGWinAtt.depth );
	CNFGGC = XCreateGC(CNFGDisplay, CNFGPixmap, 0, 0);
}
示例#8
0
void createWindowBoxes(void)
{
	WindowBox *winbox;
	char title [128];
	XWMHints      wmhints;
	XSizeHints    sizehints;

	for(winbox = Scr->FirstWindowBox; winbox; winbox = winbox->next) {
		int mask, x, y, gravity;
		unsigned int w, h;
		Window win;

		mask = XParseGeometry(winbox->geometry, &x, &y, &w, &h);
		if(mask & XNegative) {
			x += Scr->rootw  - w;
			gravity = (mask & YNegative) ? SouthEastGravity : NorthEastGravity;
		}
		else {
			gravity = (mask & YNegative) ? SouthWestGravity : NorthWestGravity;
		}
		if(mask & YNegative) {
			y += Scr->rooth - h;
		}

		win = XCreateSimpleWindow(dpy, Scr->Root, x, y, w, h, 0, Scr->Black,
		                          Scr->White);
		/*printf ("createWindowBoxes : name = %s, win = 0x%x, x = %d, y = %d, w = %d, h = %d\n",
		        winbox->name, win, x, y, w, h); */
		sprintf(title, "%s", winbox->name);
		XSetStandardProperties(dpy, win, title, title, None, NULL, 0, NULL);
		sizehints.flags  = USPosition | USSize | PWinGravity;
		sizehints.x      = x;
		sizehints.y      = y;
		sizehints.width  = w;
		sizehints.height = h;
		sizehints.win_gravity = gravity;
		XSetWMSizeHints(dpy, win, &sizehints, XA_WM_NORMAL_HINTS);

		wmhints.initial_state = NormalState;
		wmhints.input         = True;
		wmhints.flags         = InputHint | StateHint;
		XSetWMHints(dpy, win, &wmhints);

		winbox->window = win;
		winbox->twmwin = AddWindow(win, ADD_WINDOW_WINDOWBOX, NULL, Scr->currentvs);
		if(!winbox->twmwin) {
			fprintf(stderr, "cannot create %s window box, exiting...\n", winbox->name);
			exit(1);
		}
		winbox->twmwin->iswinbox = TRUE;
		XMapWindow(dpy, win);
	}
}
示例#9
0
Window
xNewWindow (Display *dpy, int x, int y, int width, int height,
	int border, int background, char *name)
/*****************************************************************************
Create a new window and return the window ID
******************************************************************************
Input:
dpy		display pointer
x		x in pixels of upper left corner
y		y in pixels of upper left corner
width		width in pixels
height		height in pixels
border		border pixel
background	background pixel
name		name of window (also used for icon)
******************************************************************************
Notes:
The parent window is the root window.
The border_width is 4 pixels.
******************************************************************************
Author:		Dave Hale, Colorado School of Mines, 01/06/90
*****************************************************************************/
{
	Window root,win;
	XSizeHints size_hints;
	XWMHints wm_hints;
	int scr,border_w=4;

	/* get screen and root window */
	scr = DefaultScreen(dpy);
	root = RootWindow(dpy,scr);

	/* create window */
	win = XCreateSimpleWindow(dpy,root,x,y,width,height,
		border_w,border,background);

	/* set window properties for window manager */
	size_hints.flags = USPosition|USSize;
	size_hints.x = x;
	size_hints.y = y;
	size_hints.width = width;
	size_hints.height = height;
	XSetStandardProperties(dpy,win,name,name,None,0,0,&size_hints);
	wm_hints.flags = InputHint;
	wm_hints.input = True;
	XSetWMHints(dpy,win,&wm_hints);

	/* return window ID */
	return win;
}
示例#10
0
  void XWindow::SetTitle(const char* title)
  {
    XSizeHints hints;
	
    // Set its basic properties
    XSetStandardProperties(	display,
                                this->window,
                                title,
                                title,
                                None, // Pixmap for icon
                                NULL,
                                0,
                                &hints);
  }
bool AbstractXApplication::tryCreateContext(const Configuration& configuration) {
    CORRADE_ASSERT(!_context, "AbstractXApplication::tryCreateContext(): context already created", false);

    _viewportSize = configuration.size();

    /* Get default X display */
    _display = XOpenDisplay(nullptr);

    /* Get visual ID */
    VisualID visualId = _contextHandler->getVisualId(_display);

    /* Get visual info */
    XVisualInfo *visInfo, visTemplate;
    int visualCount;
    visTemplate.visualid = visualId;
    visInfo = XGetVisualInfo(_display, VisualIDMask, &visTemplate, &visualCount);
    if(!visInfo) {
        Error() << "Platform::WindowlessGlxApplication::tryCreateContext(): cannot get X visual";
        return false;
    }

    /* Create X Window */
    Window root = RootWindow(_display, DefaultScreen(_display));
    XSetWindowAttributes attr;
    attr.background_pixel = 0;
    attr.border_pixel = 0;
    attr.colormap = XCreateColormap(_display, root, visInfo->visual, AllocNone);
    attr.event_mask = 0;
    unsigned long mask = CWBackPixel|CWBorderPixel|CWColormap|CWEventMask;
    _window = XCreateWindow(_display, root, 20, 20, configuration.size().x(), configuration.size().y(), 0, visInfo->depth, InputOutput, visInfo->visual, mask, &attr);
    XSetStandardProperties(_display, _window, configuration.title().data(), nullptr, 0, nullptr, 0, nullptr);
    XFree(visInfo);

    /* Be notified about closing the window */
    _deleteWindow = XInternAtom(_display, "WM_DELETE_WINDOW", True);
    XSetWMProtocols(_display, _window, &_deleteWindow, 1);

    /* Create context */
    _contextHandler->createContext(configuration, _window);

    /* Capture exposure, keyboard and mouse button events */
    XSelectInput(_display, _window, INPUT_MASK);

    /* Set OpenGL context as current */
    _contextHandler->makeCurrent();

    _context.reset(new Platform::Context);
    return true;
}
示例#12
0
static void
InformWindowManagerOfResizeStrategy()
{
   if (resize_allowed) {
      srgpx__sizehints.flags = PMinSize | PMaxSize | PResizeInc;
      srgpx__sizehints.min_width = 5; srgpx__sizehints.min_height = 5;
      srgpx__sizehints.max_width = 5000; srgpx__sizehints.max_height = 5000;
      srgpx__sizehints.width_inc = 1; srgpx__sizehints.height_inc = 1;
      XSetStandardProperties
	 (srgpx__display, srgp__canvasTable[0].drawable.win,
	  NULL, NULL, 0, 0, 0, &srgpx__sizehints);
   }
   else {
      int width = srgp__canvasTable[0].max_xcoord + 1;
      int height = srgp__canvasTable[0].max_ycoord + 1;
      srgpx__sizehints.flags = PSize | PMinSize | PMaxSize;
      srgpx__sizehints.width = width;     srgpx__sizehints.height = height;
      srgpx__sizehints.min_width = width; srgpx__sizehints.min_height = height;
      srgpx__sizehints.max_width = width; srgpx__sizehints.max_height = height;
      XSetStandardProperties
	 (srgpx__display, srgp__curActiveCanvasSpec.drawable.win,
	  NULL, NULL, 0, 0, 0, &srgpx__sizehints);
   }
}
示例#13
0
    EglDrawable(const Visual *vis, int w, int h, bool pbuffer) :
        Drawable(vis, w, h, pbuffer),
        api(EGL_OPENGL_ES_API)
    {
        XVisualInfo *visinfo = static_cast<const EglVisual *>(visual)->visinfo;

        Window root = RootWindow(display, screen);

        /* window attributes */
        XSetWindowAttributes attr;
        attr.background_pixel = 0;
        attr.border_pixel = 0;
        attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
        attr.event_mask = StructureNotifyMask;

        unsigned long mask;
        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

        int x = 0, y = 0;

        window = XCreateWindow(
            display, root,
            x, y, width, height,
            0,
            visinfo->depth,
            InputOutput,
            visinfo->visual,
            mask,
            &attr);

        XSizeHints sizehints;
        sizehints.x = x;
        sizehints.y = y;
        sizehints.width  = width;
        sizehints.height = height;
        sizehints.flags = USSize | USPosition;
        XSetNormalHints(display, window, &sizehints);

        const char *name = "glretrace";
        XSetStandardProperties(
            display, window, name, name,
            None, (char **)NULL, 0, &sizehints);

        eglWaitNative(EGL_CORE_NATIVE_ENGINE);

        EGLConfig config = static_cast<const EglVisual *>(visual)->config;
        surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL);
    }
示例#14
0
static bool xrCallBack(struct t_x11 *x11,XEvent *event, Window w, void *data)
{
  t_app   *app;
  t_xrama *xr;
  char    buf[256];
  int     i;
  
  (void)XTextHeight(x11->font);
  app=(t_app *)data;
  xr=app->xr;
  scx=app->xrwd.width/(2.0*M_PI);
  scy=app->xrwd.height/(2.0*M_PI);
  switch (event->type) {
  case Expose:
    XClearWindow(x11->disp,app->xrwd.self);
    XDrawLine(x11->disp,app->xrwd.self,x11->gc,
	      SX(0),SY(-M_PI)+1,SX(0),SY(M_PI)-1);
    XDrawLine(x11->disp,app->xrwd.self,x11->gc,
	      SX(-M_PI)+1,SY(0),SX(M_PI)-1,SY(0));
    TextInRect(x11,app->xrwd.self,"Phi",SX(M_PI)-50,SY(0)+4,46,20,eXRight,eYTop);
    TextInRect(x11,app->xrwd.self,"Psi",SX(0)+4,4,46,20,eXLeft,eYTop);
    for(i=0; (i<xr->npp); i++) 
      if (app->bShowGly || !app->bIsGly[i])
	plot_pp(x11,app->xrwd.self,&(xr->pp[i]),xr->dih);
    break;
  case ButtonPress:
    if (label_pp(x11,app->xrwd.self,xr->npp,xr->pp,xr->dih,
		 event->xbutton.x,event->xbutton.y))
      ExposeWin(x11->disp,app->xrwd.self);
    break;
  case ConfigureNotify:
    app->xrwd.width=event->xconfigure.width;
    app->xrwd.height=event->xconfigure.height;
    break;
  }
  if (app->status == esGo) {
    if (!new_data(app->xr)) 
      app->status=ebStop;
    else {
      ExposeWin(x11->disp,app->xrwd.self);
      sprintf(buf,"Rama: t=%.2f",app->xr->t);
      XSetStandardProperties(x11->disp,app->wd.self,buf,
			     "Rama",0,NULL,0,NULL);
      
    }
  }
  return FALSE;
}
示例#15
0
Window
createWindow(XVisualInfo *visinfo,
             const char *name,
             int width, int height)
{
    Window root = RootWindow(display, screen);

    /* window attributes */
    XSetWindowAttributes attr;
    attr.background_pixel = 0;
    attr.border_pixel = 0;
    attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
    attr.event_mask = StructureNotifyMask | KeyPressMask;

    unsigned long mask;
    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

    int x = 0, y = 0;

    Window window = XCreateWindow(
        display, root,
        x, y, width, height,
        0,
        visinfo->depth,
        InputOutput,
        visinfo->visual,
        mask,
        &attr);

    XSizeHints sizehints;
    sizehints.x = x;
    sizehints.y = y;
    sizehints.width  = width;
    sizehints.height = height;
    sizehints.flags = USSize | USPosition;
    XSetNormalHints(display, window, &sizehints);

    XSetStandardProperties(
        display, window, name, name,
        None, (char **)NULL, 0, &sizehints);

    XSync(display, False);

    return window;
}
示例#16
0
// Create an X11 window to render in. This is only used by testing
void
X11Device::createWindow(const char *name, int x, int y, int width, int height)
{
    GNASH_REPORT_FUNCTION;

    if (!_display) {
        log_error("No Display device set!");
        return;
    }
    
    if (!_root) {
        log_error("No drawable window set!");
        return;
    }

    XSetWindowAttributes attr;
    unsigned long mask;
    // Window root;
    // XVisualInfo visTemplate;
    // int num_visuals;

    // window attributes
    attr.background_pixel = 0;
    attr.border_pixel = 0;
    attr.colormap = XCreateColormap(_display, _root, _vinfo->visual, AllocNone);
    attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
    
    _window = XCreateWindow(_display, _root, 0, 0, width, height,
                        0, _vinfo->depth, InputOutput,
                        _vinfo->visual, mask, &attr);
    
    // set hints and properties
    XSizeHints sizehints;
    sizehints.x = x;
    sizehints.y = y;
    sizehints.width  = width;
    sizehints.height = height;
    sizehints.flags = USSize | USPosition;
    XSetNormalHints(_display, _window, &sizehints);
    XSetStandardProperties(_display, _window, name, name, None, (char **)NULL,
                           0, &sizehints);
    
    XMapWindow(_display, _window);
}
示例#17
0
文件: proba3.c 项目: Macvol/OldBundle
void init_x() {
/* get the colors black and white (see section for details) */        
	unsigned long black,white;

	dis=XOpenDisplay((char *)0);
   	screen=DefaultScreen(dis);
	black=BlackPixel(dis,screen),
	white=WhitePixel(dis, screen);
   	win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0,	
		300, 300, 5,black, white);
	XSetStandardProperties(dis,win,"Bugaga","Hi",None,NULL,0,NULL);
	XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask);
        gc=XCreateGC(dis, win, 0,0);        
	XSetBackground(dis,gc,white);
	XSetForeground(dis,gc,black);
	XClearWindow(dis, win);
	XMapRaised(dis, win);
};
示例#18
0
void init_x() {
	/* get the colors black and white (see section for details) */
	unsigned long black,white;

	/* use the information from the environment variable DISPLAY 
	   to create the X connection:
	*/	
	display=XOpenDisplay((char *)0);
   	screen=DefaultScreen(display);
	black=BlackPixel(display,screen),	/* get color black */
	white=WhitePixel(display,screen);       /* get color white */

	/* once the display is initialized, create the window.
	   This window will be have be 200 pixels across and 300 down.
	   It will have the foreground white and background black
	*/
   	window=XCreateSimpleWindow(display,DefaultRootWindow(display),0,0,	
		200, 300, 5, black, white);

	/* here is where some properties of the window can be set.
	   The third and fourth items indicate the name which appears
	   at the top of the window and the name of the minimized window
	   respectively.
	*/
	XSetStandardProperties(display,window,"My Window","HI!",None,NULL,0,NULL);

	/* this routine determines which types of input are allowed in
	   the input.  see the appropriate section for details...
	*/
	XSelectInput(display, window, ExposureMask|ButtonPressMask|KeyPressMask);

	/* create the Graphics Context */
        gc=XCreateGC(display, window, 0,0);        

	/* here is another routine to set the foreground and background
	   colors _currently_ in use in the window.
	*/
	XSetBackground(display,gc,white);
	XSetForeground(display,gc,black);

	/* clear the window and bring it on top of the other windows */
	XClearWindow(display, window);
	XMapRaised(display, window);
};
示例#19
0
    GlxDrawable(const Visual *vis, int w, int h, bool pbuffer) :
        Drawable(vis, w, h, pbuffer)
    {
        XVisualInfo *visinfo = static_cast<const GlxVisual *>(visual)->visinfo;

        Window root = RootWindow(display, screen);

        /* window attributes */
        XSetWindowAttributes attr;
        attr.background_pixel = 0;
        attr.border_pixel = 0;
        attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
        attr.event_mask = StructureNotifyMask | KeyPressMask;

        unsigned long mask;
        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

        int x = 0, y = 0;

        window = XCreateWindow(
            display, root,
            x, y, width, height,
            0,
            visinfo->depth,
            InputOutput,
            visinfo->visual,
            mask,
            &attr);

        XSizeHints sizehints;
        sizehints.x = x;
        sizehints.y = y;
        sizehints.width  = width;
        sizehints.height = height;
        sizehints.flags = USSize | USPosition;
        XSetNormalHints(display, window, &sizehints);

        const char *name = "glretrace";
        XSetStandardProperties(
            display, window, name, name,
            None, (char **)NULL, 0, &sizehints);

        glXWaitX();
    }
示例#20
0
void XVWindow::setSizeHints(int x, int y, int imageWidth, int imageHeight, int windowWidth, int windowHeight) {
	XSizeHints xshints;

	xshints.flags = PPosition | PSize | PAspect | PMinSize;

	xshints.min_aspect.x = imageWidth;
	xshints.min_aspect.y = imageHeight;
	xshints.max_aspect.x = imageWidth;
	xshints.max_aspect.y = imageHeight;

	xshints.x = x;
	xshints.y = y;
	xshints.width = windowWidth;
	xshints.height = windowHeight;
	xshints.min_width = 25;
	xshints.min_height = 25;

	XSetStandardProperties(_display, _XVWindow, "Video", "Video", None, NULL, 0, &xshints);
}
// standart openwindow function
Window openWindow(int x, int y, int width, int height,
                  int border_width, int argc, char** argv)
{
    Window new_window; // axali fanjara
    XSizeHints size_hints;
    new_window = XCreateSimpleWindow(display, DefaultRootWindow(display),
                                     x, y, width, height, border_width, foreground,
                                     background);
    size_hints.x = x;
    size_hints.y = y;
    size_hints.width = width;
    size_hints.height = height;
    size_hints.flags = PPosition | PSize;
    XSetStandardProperties(display, new_window, WINDOW_NAME, ICON_NAME,
                           None, argv, argc, &size_hints);
    XSelectInput(display, new_window, (ButtonPressMask | KeyPressMask | ButtonReleaseMask |
                                       ExposureMask | PointerMotionMask));
    return (new_window);
}
示例#22
0
/* EXPORT-> MakeXGraf: Connect to the X-server and init globals */
void MakeXGraf(char *wname, int x, int y, int w, int h, int bw)
{
   char sbuf[MAXSTRLEN], *hgraf = "HGraf";
   Window window, parent;
   XSetWindowAttributes setwinattr;
   unsigned long vmask;
   
   if (winCreated)
      HError(6870, "MakeXGraf: Attempt to recreate the graphics window");
   if ((theDisp = XOpenDisplay(NULL)) == NULL)
      HError(6870, "MakeXGraf: cannot connect to X server %s", XDisplayName(NULL));
   InitGlobals();
   InstallFonts();
   InstallColours();
   parent = RootWindow(theDisp, theScreen);
   window = XCreateSimpleWindow(theDisp, parent, x, y, w, h, bw, black, white );
   /* allow for backing up the contents of the window */
   vmask = CWBackingStore;  setwinattr.backing_store = WhenMapped;
   XChangeWindowAttributes(theDisp, window, vmask, &setwinattr);
   /* set the size hints for the window manager */
   hints.flags = PPosition | PSize | PMaxSize | PMinSize;
   hints.y = y;              hints.x = x;
   hints.width  = w;         hints.height = h;
   hints.min_width  = w;     hints.min_height = h;
   hints.max_width  = w;     hints.max_height = h;
   /* compose the name of the window */
   strcpy(sbuf, hgraf);  strcat(sbuf, ": ");  strcat(sbuf, wname);
   XSetStandardProperties(theDisp, window, sbuf, hgraf, None, NULL, 0, &hints);
   /* select events to receive */
   XSelectInput(theDisp, window, ExposureMask | KeyPressMask | ButtonPressMask | 
                ButtonReleaseMask | PointerMotionHintMask | PointerMotionMask);
   XMapWindow(theDisp, theWindow = window);
   InitGCs(); 
   HSetXMode(GCOPY); HSetFontSize(0); HSetLineWidth(0); HSetColour(BLACK);
   /* wait for the first expose event - cannot draw before it has arrived */
   do 
      XNextEvent(theDisp, &report); 
   while (report.type != Expose);
   XSendEvent(theDisp,window,False,ExposureMask,&report);
   /* Create heap for buttons */
   CreateHeap(&btnHeap, "Button heap", MHEAP, sizeof(HButton), 1.0, 100, 100);
   winCreated = TRUE;
}
示例#23
0
int main( int argc , char *argv[] ){
    Display *display;
    Window window;
    GC     gc;
    char title[]      = "This is TITLE";
    char message[]    = "Hello New World!";
    char icon_title[] = "ICON!";
    unsigned long background;
    unsigned long foreground;

    display = XOpenDisplay(NULL);

    background = WhitePixel(display,0);
    foreground = BlackPixel(display,0);

    window = XCreateSimpleWindow(display,
                                 DefaultRootWindow(display),
                                 0,0,200,100,
                                 0,0,background);

    XSetStandardProperties(display,window,title,icon_title,
			   None,argv,argc,NULL);

    gc = XCreateGC(display,window,0,0);

    XSetBackground(display,gc,background);
    XSetForeground(display,gc,foreground);

    XMapRaised(display,window);

    XSelectInput(display,window,ExposureMask);

    while (1){
	XEvent event;
        XNextEvent(display,&event);
        switch ( event.type ){
          case Expose:
	    XDrawImageString(display,window,gc,20,50,message,strlen(message));
            break;
        }
    }
}
示例#24
0
int XInit(char * WndTitle, int Width, int Height)
{
	dpy = XOpenDisplay(NULL);
	if (dpy == NULL) {
		dbgprintf(0, MSK_COLORTYPE_ERROR, "- Error: Could not open display\n");
		return EXIT_FAILURE; }
	if(!glXQueryExtension(dpy, &dummy, &dummy)) {
		dbgprintf(0, MSK_COLORTYPE_ERROR, "- Error: X server has no OpenGL GLX extension\n");
		return EXIT_FAILURE; }

	vi = glXChooseVisual(dpy, DefaultScreen(dpy), dblBuf);
	if (vi == NULL) {
		vi = glXChooseVisual(dpy, DefaultScreen(dpy), snglBuf);
		if (vi == NULL) {
			dbgprintf(0, MSK_COLORTYPE_ERROR, "- Error: No RGB visual with depth buffer\n");
			return EXIT_FAILURE; }
	}
	if(vi->class != TrueColor) {
		dbgprintf(0, MSK_COLORTYPE_ERROR, "- Error: TrueColor visual required for this program\n");
		return EXIT_FAILURE; }

	cx = glXCreateContext(dpy, vi, None, GL_TRUE);
	if (cx == NULL) {
		dbgprintf(0, MSK_COLORTYPE_ERROR, "- Error: Could not create rendering context\n");
		return EXIT_FAILURE; }

	cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);
	swa.colormap = cmap;
	swa.border_pixel = 0;
	swa.event_mask = KeyPressMask | ExposureMask | ButtonPressMask | StructureNotifyMask;
	win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, Width, Height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa);
	XSetStandardProperties(dpy, win, WndTitle, WndTitle, None, NULL, 0, NULL);

	glXMakeCurrent(dpy, win, cx);

	XMapWindow(dpy, win);

	XSelectInput(dpy, win, ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | Button1MotionMask | StructureNotifyMask);

	return EXIT_SUCCESS;
}
示例#25
0
static t_app *init_app(t_x11 *x11, int argc, char *argv[])
{
    static const char *but_nm[ebutNR] = { "Quit", "Start", "Stop", "Rewind", "Toggle Gly" };
    XSizeHints         hints;
    Pixmap             pm;
    int                th;
    t_app             *app;
    t_windata         *wd;
    int                i, dx;

    snew(app, 1);
    th = XTextHeight(x11->font)+4;
    InitWin(&(app->wd), 0, 0, MAXDEG+6, MAXDEG+6+th+6, 0, "Ramachandran Movie");
    dx           = app->wd.width/ebutNR;
    app->wd.self = XCreateSimpleWindow(x11->disp, x11->root, app->wd.x, app->wd.y,
                                       app->wd.width, app->wd.height,
                                       app->wd.bwidth, x11->fg, x11->bg);
    x11->RegisterCallback(x11, app->wd.self, x11->root, mainCallBack, app);
    x11->SetInputMask(x11, app->wd.self, StructureNotifyMask);
    hints.flags = 0;
    pm          = XCreatePixmapFromBitmapData(x11->disp, x11->root, (char *)rama_bits,
                                              rama_width, rama_height, WHITE, BLACK, 1);
    XSetStandardProperties(x11->disp, app->wd.self, app->wd.text,
                           "Rama", pm, argv, argc, &hints);
    x11->RegisterCallback(x11, app->wd.self, x11->root, appCallBack, app);
    x11->SetInputMask(x11, app->wd.self, ButtonPressMask | ExposureMask |
                      StructureNotifyMask);

    app->xr = init_xrama(x11, app->wd.self, th+6, app);
    for (i = 0; (i < ebutNR); i++)
    {
        wd = &(app->but[i]);
        InitWin(wd, i*dx+2, 2, dx-4, th, 1, but_nm[i]);
        wd->self = XCreateSimpleWindow(x11->disp, app->wd.self,
                                       wd->x, wd->y, wd->width, wd->height,
                                       wd->bwidth, x11->fg, x11->bg);
        x11->RegisterCallback(x11, wd->self, app->wd.self, appCallBack, app);
        x11->SetInputMask(x11, wd->self, ButtonPressMask | ExposureMask);
    }
    return app;
}
示例#26
0
文件: gui.c 项目: Firewiz/nterm
void init_x() {
  unsigned long black, white;
  xv.dis = XOpenDisplay((char *) 0);
  xv.screen = DefaultScreen(xv.dis);
  black = BlackPixel(xv.dis, xv.screen);
  white = WhitePixel(xv.dis, xv.screen);
  xv.win = XCreateSimpleWindow(xv.dis, DefaultRootWindow(xv.dis), 0, 0, 480, 288, 5, white, black);
  XSetStandardProperties(xv.dis, xv.win, "NTerm", "NT", None, NULL, 0, NULL);
  XSelectInput(xv.dis, xv.win, ExposureMask | ButtonPressMask | KeyPressMask);
  xv.ft = XLoadQueryFont(xv.dis, "6x12");
  xv.gc = XCreateGC(xv.dis, xv.win, 0, 0);
  XSetBackground(xv.dis, xv.gc, black);
  XSetForeground(xv.dis, xv.gc, white);
  XSetFont(xv.dis, xv.gc, xv.ft->fid);
  
  XClearWindow(xv.dis, xv.win);
  XMapRaised(xv.dis, xv.win);

  Atom WM_DELETE_WINDOW = XInternAtom(xv.dis, "WM_DELETE_WINDOW", False);
  XSetWMProtocols(xv.dis, xv.win, &WM_DELETE_WINDOW, 1);
}
示例#27
0
static Window
make_gl_window(Display *dpy, XVisualInfo *visinfo, int width, int height)
{
   int scrnum;
   XSetWindowAttributes attr;
   unsigned long mask;
   Window root;
   Window win;
   int x = 0, y = 0;
   char *name = NULL;

   scrnum = DefaultScreen( dpy );
   root = RootWindow( dpy, scrnum );

   /* window attributes */
   attr.background_pixel = 0;
   attr.border_pixel = 0;
   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

   win = XCreateWindow( dpy, root, x, y, width, height,
		        0, visinfo->depth, InputOutput,
		        visinfo->visual, mask, &attr );

   /* set hints and properties */
   {
      XSizeHints sizehints;
      sizehints.x = x;
      sizehints.y = y;
      sizehints.width  = width;
      sizehints.height = height;
      sizehints.flags = USSize | USPosition;
      XSetNormalHints(dpy, win, &sizehints);
      XSetStandardProperties(dpy, win, name, name,
                              None, (char **)NULL, 0, &sizehints);
   }

   return win;
}
示例#28
0
::Window WindowedWindow::create_window()
{
        assert(this->display);

        ::Window parent = RootWindow(this->display, this->vi->screen);
        ::Window window = XCreateWindow(this->display, parent,
                                        this->bounds.x, this->bounds.y,
                                        this->bounds.width, this->bounds.height,
                                        0,
                                        this->vi->depth, InputOutput,
                                        this->vi->visual, Window::VALUE_MASK,
                                        &this->attr);
        Atom wm_delete = XInternAtom(this->display, "WM_DELETE_WINDOW", True);

        const int num_protocols = 1;
        XSetWMProtocols(this->display, window, &wm_delete, num_protocols);
        XSetStandardProperties(this->display, window, "Futile", "Futile", None,
                               NULL, 0, NULL);
        XMapRaised(this->display, window);

        return window;
}
示例#29
0
文件: window.c 项目: AsamQi/ejoy2d
void
init_x() {
    unsigned long black,white;
    Display *dis;
    int screen;
    static Window win;

    dis=XOpenDisplay(NULL);
    screen=DefaultScreen(dis);
    black=BlackPixel(dis,screen);
    white=WhitePixel(dis, screen);

    
    win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0,
                            WIDTH, HEIGHT, 5,white, black);

    XSetStandardProperties(dis,win,"ejoy2d",NULL,None,NULL,0,NULL);
    XSelectInput(dis, win,
                 ExposureMask|KeyPressMask|KeyReleaseMask
                 |ButtonPressMask|ButtonReleaseMask|ButtonMotionMask);
    gc=XCreateGC(dis, win, 0,0);        
    XSetBackground(dis,gc,white);
    XSetForeground(dis,gc,black);
    XClearWindow(dis, win);
    XMapRaised(dis, win);

    g_X.display = dis;
    g_X.screen_num = screen;
    g_X.wnd = win;
    
    if (glx_init(&g_X)){
        printf("glx init failed\n");
        exit(1);
    }
    if ( glewInit() != GLEW_OK ) {
        printf("glew init failed");
		exit(1);
	}
};
示例#30
0
文件: linux.c 项目: zhoukk/pixel
static void init_x(void) {
	unsigned long black,white;
	Display *dis;
	int screen;
	static Window win;

	dis = XOpenDisplay(NULL);
	screen = DefaultScreen(dis);
	black = BlackPixel(dis, screen);
	white = WhitePixel(dis, screen);
	win = XCreateSimpleWindow(dis, DefaultRootWindow(dis), 0, 0, WIDTH, HEIGHT, 5, white, black);
	XMapWindow(dis, win);
	wm_delete_window = XInternAtom(dis, "WM_DELETE_WINDOW", False);
	XSetWMProtocols(dis, win, &wm_delete_window, 1);

	XSetStandardProperties(dis, win, "pixel", NULL, None, NULL, 0, NULL);
	XSelectInput(dis, win, ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask);
	gc=XCreateGC(dis, win, 0, 0);
	XSetBackground(dis, gc, white);
	XSetForeground(dis, gc, black);
	XClearWindow(dis, win);
	XMapRaised(dis, win);
	g_X.display = dis;
	g_X.screen_num = screen;
	g_X.wnd = win;
	if (glx_init(&g_X)) {
		exit(1);
	}
	if (glewInit() != GLEW_OK) {
		exit(1);
	}
	fprintf(stdout, "GL_VERSION:%s\n", glGetString(GL_VERSION));
	fprintf(stdout, "GL_VENDOR:%s\n", glGetString(GL_VENDOR));
	fprintf(stdout, "GL_RENDERER:%s\n", glGetString(GL_RENDERER));
	fprintf(stdout, "GL_SHADING_LANGUAGE_VERSION:%s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
}