示例#1
0
文件: main.c 项目: tlwg/xiterm-thai
Pixmap
set_bgPixmap (const char *file)
{
  char *f;

  assert (file != NULL);

  if (bgPixmap.pixmap != None)
    {
      XFreePixmap (Xdisplay, bgPixmap.pixmap);
      bgPixmap.pixmap = None;
    }
  XSetWindowBackground (Xdisplay, TermWin.vt, PixColors[bgColor]);

  if (*file != '\0')
    {
      XWindowAttributes attr;
      XGetWindowAttributes (Xdisplay, Xroot, &attr);

      xpmAttr.closeness = 30000;
      xpmAttr.colormap = attr.colormap;
      xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmSize | XpmReturnPixels);

      /* search environment variables here too */
      if ((f = search_path (rs_path, file, XPM_EXT)) == NULL)
#ifdef PATH_ENV
	if ((f = search_path (getenv (PATH_ENV), file, XPM_EXT)) == NULL)
#endif
	  f = search_path (getenv ("PATH"), file, XPM_EXT);

      if (f == NULL || XpmReadFileToPixmap (Xdisplay, Xroot, f,
					    &bgPixmap.pixmap,
					    NULL, &xpmAttr))
	{
	  char *p;
	  /* semi-colon delimited */
	  if ((p = strchr (file, ';')) == NULL)
	    p = strchr (file, '\0');

	  print_error ("couldn't load XPM file \"%.*s\"", (p - file), file);
	  resize_pixmap ();
	}
      else if (bgPixmap.pixmap != None)
	resize_pixmap ();
    }

  XClearWindow (Xdisplay, TermWin.vt);
  scr_touch ();
  XFlush (Xdisplay);
  return bgPixmap.pixmap;
}
示例#2
0
void Qt_widget::resizeEvent(QResizeEvent*)
{
  resize_pixmap();
  xmin = xmin_old;
  xmax = xmax_old;
  ymin = ymin_old;
  ymax = ymax_old;
  set_scales();
  redraw();
}
示例#3
0
文件: main.c 项目: tlwg/xiterm-thai
/*{{{ window resizing - assuming the parent window is the correct size */
static void
resize_subwindows (int width, int height)
{
  int x = 0, y = 0;
  int old_width = TermWin.width;
  int old_height = TermWin.height;

  TermWin.width = TermWin.ncol * TermWin.fwidth;
  TermWin.height = TermWin.nrow * TermWin.fheight;

  /* size and placement */
  if (scrollbar_visible ())
    {
      scrollBar.beg = 0;
      scrollBar.end = height;
#ifndef XTERM_SCROLLBAR
      /* arrows are as high as wide - leave 1 pixel gap */
      scrollBar.beg += (SB_WIDTH + 1);
      scrollBar.end -= (SB_WIDTH + 1);
#endif

      width -= SB_WIDTH;
      XMoveResizeWindow (Xdisplay, scrollBar.win,
#ifdef SCROLLBAR_RIGHT
			 width, 0,
#else
			 x, 0,
#endif
			 SB_WIDTH, height);

#ifndef SCROLLBAR_RIGHT
      x = SB_WIDTH;		/* placement of vt window */
#endif
    }

#ifndef NO_MENUBAR
  if (menubar_visible ())
    {
      y = menuBar_TotalHeight ();	/* for placement of vt window */
      XMoveResizeWindow (Xdisplay, menuBar.win,
			 x, 0,
			 width, y);
    }
#endif /* NO_MENUBAR */

  XMoveResizeWindow (Xdisplay, TermWin.vt,
		     x, y,
		     width, height + 1);

  if (old_width)
    Gr_Resize (old_width, old_height);
  XClearWindow (Xdisplay, TermWin.vt);
  resize_pixmap ();
  XSync (Xdisplay, 0);
}
示例#4
0
文件: main.c 项目: tlwg/xiterm-thai
/*
 * XTerm escape sequences: ESC ] Ps;Pt BEL
 *       0 = change iconName/title
 *       1 = change iconName
 *       2 = change title
 *      46 = change logfile (not implemented)
 *      50 = change font
 *
 * rxvt extensions:
 *      10 = menu
 *      20 = bg pixmap
 *      39 = change default fg color
 *      49 = change default bg color
 */
void
xterm_seq (int op, char *str)
{
  int changed = 0;

  assert (str != NULL);
  switch (op)
    {
    case XTerm_name:
      set_title (str);		/* drop */
    case XTerm_iconName:
      set_iconName (str);
      break;
    case XTerm_title:
      set_title (str);
      break;
    case XTerm_Menu:
      menubar_dispatch (str);
      break;
    case XTerm_Pixmap:
#ifdef XPM_BACKGROUND
      if (*str != ';')
	set_bgPixmap (str);

      while ((str = strchr (str, ';')) != NULL)
	{
	  str++;
	  changed += scale_pixmap (str);
	}
      if (changed)
	{
	  resize_pixmap ();
	  scr_touch ();
	}
#endif /* XPM_BACKGROUND */
      break;

    case XTerm_restoreFG:
      set_window_color (fgColor, str);
      break;
    case XTerm_restoreBG:
      set_window_color (bgColor, str);
      break;
    case XTerm_logfile:
      break;
    case XTerm_font:
      change_font (0, str);
      break;
    }
}
void 
resize_geometry (int new_width, int new_height)
{
    if (display.winW == new_width && display.winH == new_height) {
	/* Not a resize event. */
	return;
    }

    /* Update display info */
    display.winW = new_width;
    display.winH = new_height;

    /* Expand pixmap if necessary */
    new_width = new_width - 2*borderx;
    new_height = new_height - 2*bordery;
    resize_pixmap (new_width, new_height);

    /* Adjust items that need adjusting */
    initialize_geometry (&scr);
    scr.select_message.y = SELECT_BUTTON_MESSAGE_Y + (new_height - 480);
    scr.date.y = DATE_Y + (new_height - 480);
    scr.time_for_year.y = TIME_FOR_YEAR_Y + (new_height - 480);
    resize_main_win (new_width, new_height);

    scr.pbar_area.x = 56 + scr.main_win.w + 16 + 2;
    scr.pbar_pop.x = scr.pbar_area.x + 4;
    scr.pbar_tech.x = scr.pbar_area.x + 4;
    scr.pbar_food.x = scr.pbar_area.x + 4;
    scr.pbar_jobs.x = scr.pbar_area.x + 4;
    scr.pbar_money.x = scr.pbar_area.x + 4;
    scr.pbar_coal.x = scr.pbar_area.x + 4;
    scr.pbar_goods.x = scr.pbar_area.x + 4;
    scr.pbar_ore.x = scr.pbar_area.x + 4;
    scr.pbar_steel.x = scr.pbar_area.x + 4;

    scr.monthgraph.x = scr.pbar_area.x + 4;
    scr.mappoint_stats.x = scr.pbar_area.x + 4;
    scr.market_cb.x = scr.pbar_area.x;

    scr.mini_map_aux.x = scr.pbar_area.x + 4;
    scr.mini_map_area.x = scr.pbar_area.x + 4;
    scr.mini_map.x = scr.mini_map_aux.x 
	    + ((scr.mini_map_aux.w - scr.mini_map.w) / 2);

    /* Complete refresh of the screen required here */
    screen_full_refresh ();
}
示例#6
0
int
main (int argc, char **argv) {
  
    XEvent event;
    XSizeHints xsh;
    XSetWindowAttributes xswa;
    XVisualInfo *vinfo;

    glitz_drawable_format_t templ;
    glitz_drawable_format_t *dformat;
    unsigned long mask = 0;
    
    unsigned int width, height, window_width, window_height;
    int i;

    program_name = argv[0];
    
    for (i = 1; i < argc; i++) {
	if (!strcasecmp ("-image", argv[i]))
	    output_type = IMAGE_TYPE;

#ifdef CAIRO_HAS_XLIB_SURFACE
	else if (!strcasecmp ("-xrender", argv[i])) {
	    output_type = XRENDER_TYPE;
	} 
#endif

	else if (!strcasecmp ("-glx", argv[i])) {
	    output_type = GLX_TYPE;
	} else if (!strcasecmp ("-noaa", argv[i])) {
	    aa = 0;
	} else if (!strcasecmp ("-swaa", argv[i])) {
	    aa = 1;
	} else if (!strcasecmp ("-hwaa", argv[i])) {
	    aa = 3;
        } else {
            test_type = get_test_type (argv[i]);
        }
    }
  
    if (!test_type) {
	usage();
	exit(1);
    }

    if (output_type != GLX_TYPE && test_type >= OPENGL_TYPE) {
	printf ("Sorry, this test only works with OpenGL!\n");
	usage();
	exit(1);
    }

    window_width = width = WINDOW_WIDTH;
    window_height = height = WINDOW_HEIGHT;
    
    if (aa == 3)
	templ.samples = 4;
    else
	templ.samples = 1;
    
    templ.depth_size = 16;
    if (test_type == CUBE_TYPE)
	mask |= GLITZ_FORMAT_DEPTH_SIZE_MASK;

    mask |= GLITZ_FORMAT_SAMPLES_MASK;
    
    if ((dpy = XOpenDisplay (NULL)) == NULL) {
	fprintf(stderr, "%s: can't open display: %s\n", argv[0],
		XDisplayName (NULL));
	exit(1);
    }

    if (output_type != GLX_TYPE) {
	xsh.flags = PSize;
	xsh.width = width;
	xsh.height = height;
	xsh.x = 0;
	xsh.y = 0;
	
	win = XCreateWindow (dpy, RootWindow (dpy, DefaultScreen (dpy)), 
			     xsh.x, xsh.y, xsh.width, xsh.height,
			     0, CopyFromParent, CopyFromParent,
			     CopyFromParent, 0, &xswa);
  
	XSetStandardProperties (dpy, win, PACKAGE, PACKAGE, None,
				argv, argc, &xsh);
	XSetWMHints (dpy, win, &xwmh);

	XSelectInput (dpy, win, StructureNotifyMask);
	
    } else {

	xsh.flags = PSize;
	xsh.width = width;
	xsh.height = height;
	xsh.x = 0;
	xsh.y = 0;

	mask = 0;
	
	templ.doublebuffer = 1;
	mask |= GLITZ_FORMAT_DOUBLEBUFFER_MASK;
	
	dformat = glitz_glx_find_window_format (dpy, DefaultScreen (dpy),
						mask, &templ, 0);
	
	vinfo = glitz_glx_get_visual_info_from_format (dpy,
						       DefaultScreen (dpy),
						       dformat);
	xswa.colormap =
	    XCreateColormap (dpy,
			     RootWindow (dpy, DefaultScreen (dpy)), 
			     vinfo->visual, AllocNone);
	win = XCreateWindow (dpy, RootWindow (dpy, DefaultScreen (dpy)), 
			     xsh.x, xsh.y, xsh.width, xsh.height,
			     0, vinfo->depth, CopyFromParent,
			     vinfo->visual, CWColormap, &xswa);
  
	XSetStandardProperties (dpy, win, PACKAGE, PACKAGE, None,
				argv, argc, &xsh);
	XSetWMHints (dpy, win, &xwmh);

	XSelectInput (dpy, win, StructureNotifyMask);
    }
	
    switch (output_type) {
      
    case XRENDER_TYPE:
	resize_pixmap (width, height);
	break;
      
    case IMAGE_TYPE:
	resize_image (width, height);
	break;
    case GLX_TYPE:
	drawable =
	    glitz_glx_create_drawable_for_window (dpy, 0, dformat, win,
						  width, height);
	if (!drawable) {
	    printf ("failed to create glitz drawable\n");
	    exit (1);
	}
	break;
    }
  
    if (aa == 3 && dformat->samples < 2) {
	fprintf (stderr, "hardware multi-sampling not available\n");
	exit (1);
    }

    if (drawable) {
	surface = resize_glitz_drawable (drawable, dformat, width, height);
    }

    cr = cairo_create (surface);
    cairo_set_tolerance (cr, 0.5);

    setup (test_type);

    XMapWindow (dpy, win);

    for (;;) {
	if (XPending (dpy)) {
	    XNextEvent (dpy, &event);
	    if (event.type == ConfigureNotify) {
		width = event.xconfigure.width;
		height = event.xconfigure.height;
                
		switch (output_type) {
		    
#ifdef CAIRO_HAS_XLIB_SURFACE
		case XRENDER_TYPE:
		    resize_pixmap (width, height);
		    cairo_destroy (cr);
		    cr = cairo_create (surface);
		    cairo_set_tolerance (cr, 0.5);
		    break;
#endif
		    
		case IMAGE_TYPE:
		    resize_image (width, height);
		    cairo_destroy (cr);
		    cr = cairo_create (surface);
		    cairo_set_tolerance (cr, 0.5);
		    break;
		case GLX_TYPE:
		    cairo_surface_destroy (surface);
		    surface = resize_glitz_drawable (drawable, dformat, 
						     width, height);
		    cairo_destroy (cr);
		    cr = cairo_create (surface);
		    cairo_set_tolerance (cr, 0.5);
		    break;
		}
	    }
	} else {
	    render (test_type, output_type == GLX_TYPE);
       	    switch (output_type) {
		
#ifdef CAIRO_HAS_XLIB_SURFACE
	    case XRENDER_TYPE:
		XSetWindowBackgroundPixmap (dpy, win, pixmap);
		XClearWindow (dpy, win);
		break;
#endif
		
	    case IMAGE_TYPE: {
		GC gc;
		XImage *xim;

		pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy),
					width, height,
					DefaultDepth (dpy,
						      DefaultScreen (dpy)));
		xim = XCreateImage(dpy, DefaultVisual (dpy,
						       DefaultScreen (dpy)),
				   DefaultDepth(dpy, DefaultScreen (dpy)),
				   ZPixmap, 0, (char *) image,
				   width, height, 32, 0);
		gc = XCreateGC (dpy, pixmap, 0, NULL);
		XPutImage (dpy, pixmap, gc, xim, 0, 0, 0, 0, width, height);
                    
		XFreeGC (dpy, gc);
		xim->data = NULL;
		XDestroyImage (xim);

		XSetWindowBackgroundPixmap (dpy, win, pixmap);
		XClearWindow (dpy, win);
		XFreePixmap (dpy, pixmap);
	    } break;
	    }

	    XSync (dpy, 0);
	}
    }

    exit (1);
}