当前位置: 首页>>代码示例>>C++>>正文


C++ DefaultScreen函数代码示例

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


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

示例1: xDrawLegendBox

void
xDrawLegendBox (Display *dpy, Window win,
	int x, int y, int width, int height,
	float bclip, float wclip, char *units, char *legendfont,
	char *labelfont, char *title, char *titlefont,
	char *axescolor, char *titlecolor, char *gridcolor,
	int style)
/*****************************************************************************
draw a labeled axes box
******************************************************************************
Input:
dpy		display pointer
win		window
x		x coordinate of upper left corner of box
y		y coordinate of upper left corner of box
width		width of box
height		height of box
units		label for legend
legendfont	name of font to use for legend labels
labelfont	name of font to use for axes labels
title		axes box title
titlefont	name of font to use for title
axescolor	name of color to use for axes
titlecolor	name of color to use for title
gridcolor	name of color to use for grid
int style	NORMAL (axis 1 on bottom, axis 2 on left)
		SEISMIC (axis 1 on left, axis 2 on top)
******************************************************************************
Notes:
xDrawLegendBox will determine the numbered tic incremenet and first
numbered tic automatically, if the specified increment is zero.

Pad values must be specified in the same units as the corresponding
axes values.  These pads are useful when the contents of the axes box
requires more space than implied by the axes values.  For example,
the first and last seismic wiggle traces plotted inside an axes box
will typically extend beyond the axes values corresponding to the
first and last traces.  However, all tics will lie within the limits
specified in the axes values (x1beg, x1end, x2beg, x2end).
******************************************************************************
Author:		Dave Hale, Colorado School of Mines, 01/27/90
Author:		Berend Scheffers , TNO Delft, 06/11/92
*****************************************************************************/
{
	GC gca,gct,gcg;
	XGCValues *values=NULL;
	XColor scolor,ecolor;
	XFontStruct *fa,*ft;
	XWindowAttributes wa;
	Colormap cmap;
	int labelca,labelcd,labelch,labelcw,titleca,titlecd,titlech,titlecw,
		xa,ya,tw,ticsize,ticb,numb,lstr,scr;
	float dnum=EPS,amin,amax,base,anum,azero;
	char str[256];

	/* get screen */
	scr = DefaultScreen(dpy);

	/* create graphics contexts */
	gca = XCreateGC(dpy,win,0,values);
	gct = XCreateGC(dpy,win,0,values);
	gcg = XCreateGC(dpy,win,0,values);

	/* get and set fonts and determine character dimensions */
	fa = XLoadQueryFont(dpy,legendfont);
	if (fa==NULL) fa = XLoadQueryFont(dpy,"fixed");
	if (fa==NULL) {
		fprintf(stderr,"Cannot load/query legendfont=%s\n",legendfont);
		exit(-1);
	}
	XSetFont(dpy,gca,fa->fid);
	labelca = fa->max_bounds.ascent;
	labelcd = fa->max_bounds.descent;
	labelch = fa->max_bounds.ascent+fa->max_bounds.descent;
	labelcw = fa->max_bounds.lbearing+fa->max_bounds.rbearing;
	ft = XLoadQueryFont(dpy,titlefont);
	if (ft==NULL) ft = XLoadQueryFont(dpy,"fixed");
	if (ft==NULL) {
		fprintf(stderr,"Cannot load/query titlefont=%s\n",titlefont);
		exit(-1);
	}
	XSetFont(dpy,gct,ft->fid);
	titleca = ft->max_bounds.ascent;
	titlecd = ft->max_bounds.descent;
	titlech = ft->max_bounds.ascent+ft->max_bounds.descent;
	titlecw = ft->max_bounds.lbearing+ft->max_bounds.rbearing;

	/* determine window's current colormap */
	XGetWindowAttributes(dpy,win,&wa);
	cmap = wa.colormap;

	/* get and set colors */
	if (XAllocNamedColor(dpy,cmap,axescolor,&scolor,&ecolor))
		XSetForeground(dpy,gca,ecolor.pixel);
	else
		XSetForeground(dpy,gca,1L);
	if (XAllocNamedColor(dpy,cmap,titlecolor,&scolor,&ecolor))
		XSetForeground(dpy,gct,ecolor.pixel);
	else
		XSetForeground(dpy,gct,1L);
//.........这里部分代码省略.........
开发者ID:JOravetz,项目名称:SeisUnix,代码行数:101,代码来源:legendbox.c

示例2: assert

Widget
XtNativePopupMenu::traverseBuild(
  Widget parent,
  MenuRecord * menu,
  int indent)
{
  assert(indent < 24);
  int i;
#if SOXT_POPUPMENU_DEBUG
  char pre[24];
  for (i = 0; i < indent; i++) pre[i] = ' ';
  pre[i] = '\0';
#endif // SOXT_POPUPMENU_DEBUG
  int j = 0;
  MenuRecord * sub;
  ItemRecord * item;
  do {
    sub = (MenuRecord *) NULL;
    item = (ItemRecord *) NULL;
    const int numMenus = this->menus->getLength();
    for (i = 0; i < numMenus; i++) {
      sub = (MenuRecord *) (*this->menus)[i];
      if ((sub->pos == j) && (sub->parent == menu)) {
#if SOXT_POPUPMENU_DEBUG
        fprintf(stderr, "%s%s {\n", pre, sub->name);
#endif // SOXT_POPUPMENU_DEBUG
        Display * dpy = SoXt::getDisplay();
        const int screen = DefaultScreen(dpy);
        Visual * visual = DefaultVisual(dpy, screen);
        Colormap colormap = DefaultColormap(dpy, screen);
        int depth = DefaultDepth(dpy, screen);
        Arg args[10];
        int argc = 0;
        XtSetArg(args[argc], XmNvisual, visual); argc++;
        XtSetArg(args[argc], XmNdepth, depth); argc++;
        XtSetArg(args[argc], XmNcolormap, colormap); argc++;
        Widget submenu = XmCreatePulldownMenu(parent, sub->name, args, argc);
        sub->menu = XtVaCreateManagedWidget(sub->name,
          xmCascadeButtonGadgetClass, parent,
          XmNsubMenuId, submenu,
          XtVaTypedArg,
            XmNlabelString, XmRString,
            sub->title, strlen(sub->title) + 1,
          NULL);
        this->traverseBuild(submenu, sub, indent + 2);
#if SOXT_POPUPMENU_DEBUG
        fprintf(stderr, "%s}\n", pre);
#endif // SOXT_POPUPMENU_DEBUG
        break;
      } else {
        sub = (MenuRecord *) NULL;
      }
    }
    if (sub == NULL) {
      const int numItems = this->items->getLength();
      for (i = 0; i < numItems; i++) {
        item = (ItemRecord *) (*this->items)[i];
        if ((item->pos == j) && (item->parent == menu)) {
#if SOXT_POPUPMENU_DEBUG
          fprintf(stderr, "%s%s\n", pre, item->name);
#endif // SOXT_POPUPMENU_DEBUG
          if (item->flags & ITEM_SEPARATOR) {
            item->item = XtVaCreateManagedWidget(item->title,
              xmSeparatorGadgetClass, parent, NULL);
          } else {
            item->item = XtVaCreateManagedWidget(item->title,
              xmToggleButtonGadgetClass, parent,
              XmNsensitive, (item->flags & ITEM_ENABLED) ? True : False,
              XtVaTypedArg,
                XmNlabelString, XmRString,
                item->title, strlen(item->title)+1,
              NULL);
            XtAddCallback(item->item, XmNvalueChangedCallback,
                XtNativePopupMenu::itemSelectionCallback, this);
            XmToggleButtonSetState(item->item,
              (item->flags & ITEM_MARKED) ? True : False,
              False);
          }
          break;
        } else {
          item = (ItemRecord *) NULL;
        }
      }
    }
    j++;
  } while ((sub != NULL) || (item != NULL));
  return parent;
} // traverseBuild()
开发者ID:ALLPix,项目名称:SoXt,代码行数:88,代码来源:XtNativePopupMenu.cpp

示例3: XScreenCount

void CWinSystemX11::UpdateResolutions()
{
  CWinSystemBase::UpdateResolutions();

  int numScreens = XScreenCount(m_dpy);
  g_xrandr.SetNumScreens(numScreens);

  bool switchOnOff = CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOSCREEN_BLANKDISPLAYS);
  m_userOutput = CSettings::GetInstance().GetString(CSettings::SETTING_VIDEOSCREEN_MONITOR);
  if (m_userOutput.compare("Default") == 0)
    switchOnOff = false;

  if(g_xrandr.Query(true, !switchOnOff))
  {
    XOutput *out = NULL;
    if (m_userOutput.compare("Default") != 0)
    {
      out = g_xrandr.GetOutput(m_userOutput);
      if (out)
      {
        XMode mode = g_xrandr.GetCurrentMode(m_userOutput);
        if (!mode.isCurrent && !switchOnOff)
        {
          out = NULL;
        }
      }
    }
    if (!out)
    {
      m_userOutput = g_xrandr.GetModes()[0].name;
      out = g_xrandr.GetOutput(m_userOutput);
    }

    if (switchOnOff)
    {
      // switch on output
      g_xrandr.TurnOnOutput(m_userOutput);

      // switch off other outputs
      std::vector<XOutput> outputs = g_xrandr.GetModes();
      for (size_t i=0; i<outputs.size(); i++)
      {
        if (StringUtils::EqualsNoCase(outputs[i].name, m_userOutput))
          continue;
        g_xrandr.TurnOffOutput(outputs[i].name);
      }
    }

    XMode mode = g_xrandr.GetCurrentMode(m_userOutput);
    if (mode.id.empty())
      mode = g_xrandr.GetPreferredMode(m_userOutput);
    m_bIsRotated = out->isRotated;
    if (!m_bIsRotated)
      UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), 0, mode.w, mode.h, mode.hz);
    else
      UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), 0, mode.h, mode.w, mode.hz);
    CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP).strId     = mode.id;
    CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP).strOutput = m_userOutput;
  }
  else
  {
    m_userOutput = "No Output";
    m_nScreen = DefaultScreen(m_dpy);
    int w = DisplayWidth(m_dpy, m_nScreen);
    int h = DisplayHeight(m_dpy, m_nScreen);
    UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), 0, w, h, 0.0);
  }

  // erase previous stored modes
  CDisplaySettings::GetInstance().ClearCustomResolutions();

  CLog::Log(LOGINFO, "Available videomodes (xrandr):");

  XOutput *out = g_xrandr.GetOutput(m_userOutput);
  if (out != NULL)
  {
    std::vector<XMode>::iterator modeiter;
    CLog::Log(LOGINFO, "Output '%s' has %" PRIdS" modes", out->name.c_str(), out->modes.size());

    for (modeiter = out->modes.begin() ; modeiter!=out->modes.end() ; modeiter++)
    {
      XMode mode = *modeiter;
      CLog::Log(LOGINFO, "ID:%s Name:%s Refresh:%f Width:%d Height:%d",
                mode.id.c_str(), mode.name.c_str(), mode.hz, mode.w, mode.h);
      RESOLUTION_INFO res;
      res.iScreen = 0; // not used by X11
      res.dwFlags = 0;
      res.iWidth  = mode.w;
      res.iHeight = mode.h;
      res.iScreenWidth  = mode.w;
      res.iScreenHeight = mode.h;
      if (mode.IsInterlaced())
        res.dwFlags |= D3DPRESENTFLAG_INTERLACED;

      if (!m_bIsRotated)
      {
        res.iWidth  = mode.w;
        res.iHeight = mode.h;
      }
      else
//.........这里部分代码省略.........
开发者ID:krattai,项目名称:sht_tv,代码行数:101,代码来源:WinSystemX11.cpp

示例4: lockscreen

static Lock *
lockscreen(Display *dpy, int screen) {
#if !TRANSPARENT
	char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
#endif
	unsigned int len;
	Lock *lock;
#if !TRANSPARENT
	XColor color, dummy;
#endif
	XSetWindowAttributes wa;
#if !TRANSPARENT
	Cursor invisible;
#endif
#if TRANSPARENT
	XVisualInfo vi;
#endif

	if(dpy == NULL || screen < 0)
		return NULL;

	lock = malloc(sizeof(Lock));
	if(lock == NULL)
		return NULL;

	lock->screen = screen;

	lock->root = RootWindow(dpy, lock->screen);

#if TRANSPARENT
	XMatchVisualInfo(dpy, DefaultScreen(dpy), 32, TrueColor, &vi);
	wa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vi.visual, AllocNone);
#endif

	/* init */
	wa.override_redirect = 1;
#if !TRANSPARENT
	wa.background_pixel = BlackPixel(dpy, lock->screen);
#else
	wa.border_pixel = 0;
	wa.background_pixel = 0xaa000000;
#endif
	lock->win = XCreateWindow(dpy, lock->root, 0, 0, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen),
#if !TRANSPARENT
			0, DefaultDepth(dpy, lock->screen), CopyFromParent,
			DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa);
#else
			0, vi.depth, CopyFromParent,
			vi.visual, CWOverrideRedirect | CWBackPixel | CWColormap | CWBorderPixel, &wa);
#endif

	Atom name_atom = XA_WM_NAME;
	XTextProperty name_prop = { "slock", name_atom, 8, 5 };
	XSetWMName(dpy, lock->win, &name_prop);

	// Atom name_ewmh_atom = XInternAtom(dpy, "_NET_WM_NAME", False);
	// XTextProperty name_ewmh_prop = { "slock", name_ewmh_atom, 8, 5 };
	// XSetTextProperty(dpy, lock->win, &name_ewmh_prop, name_ewmh_atom);
	// XSetWMName(dpy, lock->win, &name_ewmh_prop);

	XClassHint *hint = XAllocClassHint();
	if (hint) {
		hint->res_name = "slock";
		hint->res_class = "slock";
		XSetClassHint(dpy, lock->win, hint);
		XFree(hint);
	}

#if !TRANSPARENT
	XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR2, &color, &dummy);
	lock->colors[1] = color.pixel;
	XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR1, &color, &dummy);
	lock->colors[0] = color.pixel;
	lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
	invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
	XDefineCursor(dpy, lock->win, invisible);
#endif
	XMapRaised(dpy, lock->win);
	for(len = 1000; len; len--) {
		if(XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
#if !TRANSPARENT
			GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
#else
			GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess)
#endif
			break;
		usleep(1000);
	}
	if(running && (len > 0)) {
		for(len = 1000; len; len--) {
			if(XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
				== GrabSuccess)
				break;
			usleep(1000);
		}
	}

	running &= (len > 0);
	if(!running) {
		unlockscreen(dpy, lock);
//.........这里部分代码省略.........
开发者ID:coloradomountain,项目名称:slock,代码行数:101,代码来源:slock.c

示例5: main

main (int argc, char *argv[])
#endif
{
	XEvent ev;
	fd_set fd;
	int xfd;

	dd = XOpenDisplay (NULL);
	if (!dd)
		return 0;
	scr_screen = DefaultScreen (dd);
	scr_depth = DefaultDepth (dd, scr_screen);
	scr_height = DisplayHeight (dd, scr_screen);
	scr_width = DisplayWidth (dd, scr_screen);
	root_win = RootWindow (dd, scr_screen);

	/* helps us catch windows closing/opening */
	XSelectInput (dd, root_win, PropertyChangeMask);

	XSetErrorHandler ((XErrorHandler) handle_error);

	XInternAtoms (dd, atom_names, ATOM_COUNT, False, atoms);

	gui_init ();
	bzero (&tb, sizeof (struct taskbar));
	tb.win = gui_create_taskbar ();
	xfd = ConnectionNumber (dd);
	gui_sync ();

	while (1)
	{
		FD_ZERO (&fd);
		FD_SET (xfd, &fd);
		select (xfd + 1, &fd, 0, 0, 0);

		while (XPending (dd))
		{
			XNextEvent (dd, &ev);
			switch (ev.type)
			{
			case ButtonPress:
				handle_press (ev.xbutton.x, ev.xbutton.y, ev.xbutton.button);
				break;
			case DestroyNotify:
				del_task (ev.xdestroywindow.window);
				/* fall through */
			case Expose:
				gui_draw_taskbar ();
				break;
			case PropertyNotify:
				handle_propertynotify (ev.xproperty.window, ev.xproperty.atom);
				break;
			case FocusIn:
				handle_focusin (ev.xfocus.window);
				break;
			/*default:
				   printf ("unknown evt type: %d\n", ev.type);*/
			}
		}
	}

	/*XCloseDisplay (dd);

   return 0;*/
}
开发者ID:hoverisk,项目名称:fspanel-black,代码行数:65,代码来源:fspanel.c

示例6: createWindow

static Window createWindow(Window parent, Visual *visual, gulong mask, XSetWindowAttributes *attrib)
{
	return XCreateWindow(t_display, parent, 0, 0, 1, 1, 0, (visual ? 32 : DefaultDepth(t_display, DefaultScreen(t_display))), InputOutput,
		(visual ? visual : DefaultVisual(t_display, DefaultScreen(t_display))), mask, attrib);
}
开发者ID:sylware,项目名称:lboxwm,代码行数:5,代码来源:frame.c

示例7: winopen

void winopen(void)
{
	XWMHints *hints;

	xdpy = XOpenDisplay(nil);
	if (!xdpy)
		winerror(&gapp, "could not open display.");

	XA_TARGETS = XInternAtom(xdpy, "TARGETS", False);
	XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False);
	XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False);

	xscr = DefaultScreen(xdpy);

	ximage_init(xdpy, xscr, DefaultVisual(xdpy, xscr));

	xcarrow = XCreateFontCursor(xdpy, XC_left_ptr);
	xchand = XCreateFontCursor(xdpy, XC_hand2);
	xcwait = XCreateFontCursor(xdpy, XC_watch);

	xbgcolor.red = 0x7000;
	xbgcolor.green = 0x7000;
	xbgcolor.blue = 0x7000;

	xshcolor.red = 0x4000;
	xshcolor.green = 0x4000;
	xshcolor.blue = 0x4000;

	XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor);
	XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor);

	xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy),
			10, 10, 200, 100, 1,
			ximage_get_depth(),
			InputOutput,
			ximage_get_visual(),
			0,
			nil);

	XSetWindowColormap(xdpy, xwin, ximage_get_colormap());
	XSelectInput(xdpy, xwin,
			StructureNotifyMask | ExposureMask | KeyPressMask |
			PointerMotionMask | ButtonPressMask | ButtonReleaseMask);

	mapped = 0;

	xgc = XCreateGC(xdpy, xwin, 0, nil);

	XDefineCursor(xdpy, xwin, xcarrow);

	hints = XAllocWMHints();
	if (hints)
	{
		hints->flags = IconPixmapHint;
		hints->icon_pixmap = XCreateBitmapFromData(xdpy, xwin,
				gs_l_xbm_bits, gs_l_xbm_width, gs_l_xbm_height);
		if (hints->icon_pixmap)
		{
			XSetWMHints(xdpy, xwin, hints);
		}
		XFree(hints);
	}
}
开发者ID:wzhsunn,项目名称:SumatraPDF_0.6_Source,代码行数:63,代码来源:x11pdf.c

示例8: main

int main(int argc, char* argv[]) {

  int number_of_stars = 200;
  int iterations = 1000;
  prec time_unit = gdt;

  if(argc == 3)
    {
      number_of_stars = atoi(argv[1]);
      iterations = atoi(argv[2]);
    }
  struct star* star_array = malloc(sizeof(struct star) * number_of_stars);
  generate_init_values(number_of_stars, star_array);
  
  
  
  
  
#ifdef ANIMATE
  XPoint* points = malloc(sizeof(XPoint)*number_of_stars);
  Display* disp;
  Window window, rootwin;
  int screen;

  disp = XOpenDisplay(NULL);
  screen = DefaultScreen(disp);
  rootwin = RootWindow(disp,screen);
  window = XCreateSimpleWindow(disp,rootwin,
                               0,0,X_SIZE,Y_SIZE,1,0,0);
  GC gc = XCreateGC(disp, window, 0, 0);
  XSetForeground(disp, gc, WhitePixel(disp, screen));
  XSetBackground(disp, gc, BlackPixel(disp, screen));
  XMapWindow(disp,window);

  XClearWindow(disp,window);	
	
  copyToXBuffer(star_array, points, number_of_stars);
  XDrawPoints(disp, window, gc, points, number_of_stars, 0);

  XFlush(disp);

#endif

  clock_t start = clock();
  for(int i = 0; i < iterations; i++)
    {

#ifndef ANIMATE
      
      resetForces(number_of_stars, star_array);
      updateForces(number_of_stars, number_of_stars - 1, star_array);
      for(int j = 0; j < number_of_stars; ++j){
        update_position(&star_array[j], time_unit);
      }

#endif
     
#ifdef ANIMATE

      resetForces(number_of_stars, star_array);
      updateForces(number_of_stars, number_of_stars - 1, star_array);
      for(int j = 0; j < number_of_stars; ++j){
        update_position(&star_array[j], time_unit);


        copyToXBuffer(star_array, points,number_of_stars );
        XDrawPoints(disp, window, gc, points, number_of_stars, CoordModeOrigin);
	

      }
      XClearWindow(disp,window);

    
#endif
 
    }
  clock_t stop = clock();
  float diff = (float)(stop - start)/CLOCKS_PER_SEC;
  printf("Total: %lf seconds\n",diff);
  printf("Bodies: %d\n",number_of_stars);
  printf("Iterations: %d\n", iterations);

#ifdef ANIMATE
  free(points);
  XCloseDisplay(disp);
#endif
  free(star_array);
  return 0;
}
开发者ID:albohl,项目名称:nbody,代码行数:89,代码来源:main_rec.c

示例9: glXChooseVisual

bool GLWindow::CreateContextGL(int major, int minor)
{
	if (!NativeDisplay) return false;

	// Get visual information
	int attrListDbl[] =
	{
		// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X
		// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.
		GLX_X_RENDERABLE    , True,
		GLX_RED_SIZE        , 8,
		GLX_GREEN_SIZE      , 8,
		GLX_BLUE_SIZE       , 8,
		GLX_DEPTH_SIZE      , 24,
		GLX_DOUBLEBUFFER    , True,
		None
	};

	// Attribute are very sensible to the various implementation (intel, nvidia, amd)
	// Nvidia and Intel doesn't support previous attributes for opengl2.0
	int attrListDbl_2_0[] =
	{
		GLX_RGBA,
		GLX_DOUBLEBUFFER,
		GLX_RED_SIZE, 8,
		GLX_GREEN_SIZE, 8,
		GLX_BLUE_SIZE, 8,
		GLX_DEPTH_SIZE, 24,
		None
	};

	// Only keep for older card but NVIDIA and AMD both drop the support of those cards
	if (major <= 2) {
		XVisualInfo *vi = glXChooseVisual(NativeDisplay, DefaultScreen(NativeDisplay), attrListDbl_2_0);
		if (vi == NULL) return NULL;

		glxContext = glXCreateContext(NativeDisplay, vi, NULL, GL_TRUE);
        XFree(vi);

		if (!glxContext) return false;

		glXMakeCurrent(NativeDisplay, NativeWindow, glxContext);
		return true;
	}

	PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)GetProcAddress("glXChooseFBConfig");
	int fbcount = 0;
	GLXFBConfig *fbc = glXChooseFBConfig(NativeDisplay, DefaultScreen(NativeDisplay), attrListDbl, &fbcount);
	if (!fbc || fbcount < 1) {
		ZZLog::Error_Log("GLX: failed to find a framebuffer");
		return false;
	}

	PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)GetProcAddress("glXCreateContextAttribsARB");
	if (!glXCreateContextAttribsARB) return false;

	// Create a context
	int context_attribs[] =
	{
		GLX_CONTEXT_MAJOR_VERSION_ARB, major,
		GLX_CONTEXT_MINOR_VERSION_ARB, minor,
		// Keep compatibility for old cruft
		GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
		//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
		// FIXME : Request a debug context to ease opengl development
#if (defined(ZEROGS_DEVBUILD) || defined(_DEBUG)) && defined(OGL4_LOG)
		GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
#endif
		None
	};

	glxContext = glXCreateContextAttribsARB(NativeDisplay, fbc[0], 0, true, context_attribs);
	if (!glxContext) {
		ZZLog::Error_Log("GLX: failed to create an opengl context");
		return false;
	}

	XSync( NativeDisplay, false);

	if (!glXMakeCurrent(NativeDisplay, NativeWindow, glxContext)) {
		ZZLog::Error_Log("GLX: failed to attach the opengl context");
		return false;
	}

	return true;
}
开发者ID:ACanadianKernel,项目名称:pcsx2,代码行数:86,代码来源:GLWinX11.cpp

示例10: main

int main(int argc, char**argv)
{
	char **missing_charset_list;
	int missing_charset_count;
	XGCValues xgcv;
	unsigned long mask;
	Display* dpy;
	int scr;
	Window w, root;
	XSetWindowAttributes set_attr;
	int i;
	XIMStyle *style;
        static char buf[128];
        KeySym keysym = 0;
        Status status;
	XWMHints wm_hints;
    	XClassHint class_hints;
	XIMStyle input_style = 0;
	char **font_name_list;
	char *def_string;
	XFontStruct **font_struct_list;
	char **font_encoding_list;
	int nb_font;
	int len = 0;
	int no_xim = 0;

	printf ("A -> %c \n", XUtf8Tolower('A'));
    	if (!setlocale(LC_ALL, ""))
        	puts("locale not supported by C library, locale unchanged");

    	if (!XSetLocaleModifiers(""))
        	puts("X locale modifiers not supported, using default");
	
	dpy = XOpenDisplay(0);
	if (!dpy) { puts("cannot open display.\n"); exit(-1); }
	scr = DefaultScreen(dpy);
	root = RootWindow(dpy, scr);
	set_attr.event_mask = KeyPressMask|FocusChangeMask;
	set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
	set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
	w = XCreateWindow(dpy, root, 10,10,200,100,0, 
		DefaultDepth(dpy, DefaultScreen(dpy)),
		InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
		CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
	if (!w) { puts("cannot creat window.\n"); exit(-1); }

	class_hints.res_name = "test";
    	class_hints.res_class = "Test";
	wm_hints.input = True;
    	wm_hints.flags = InputHint;

    	XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
                       NULL, &wm_hints, &class_hints);

	XMapWindow(dpy, w);
	xim_im = XOpenIM(dpy, NULL, "test", "Test");
	if (!xim_im) { 
		puts("cannot Open Input Manager: Try default.\n"); 
		XSetLocaleModifiers("@im=");
		xim_im = XOpenIM(dpy, NULL, "test", "Test");
		if (!xim_im) { puts("Failed exiting.\n"); exit(-1); }
	}
	XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
    	for (i = 0, style = xim_styles->supported_styles;
         	i < xim_styles->count_styles; i++, style++)
	{
		if (i == 0 && *style == (XIMStatusNone|XIMPreeditNone)) {
			printf("this is not a XIM server !!!\n");
			no_xim = 1;
		}
        	printf("input style : 0x%X\n", *style);
	}

	xim_ic = XCreateIC(xim_im,
                        XNInputStyle, 
			(XIMPreeditNothing | XIMStatusNothing),
                        XNClientWindow, w,
			XNFocusWindow, w,
                        NULL);
	if (!xim_ic) { puts("cannot create Input Context.\n"); exit(-1);}
    	XFree(xim_styles);
	XSetICFocus(xim_ic);

	/***************************************************************/
	/** I don't recommand to use a font base name list similar 
	 *  to the following one in a real application ;-) 
	 *  You should use an iso8859-1 font, plus a single font for 
	 *  your language. */
	/***************************************************************/
        fontset = XCreateUtf8FontStruct(dpy, 
		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
		"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
		"-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-0,"
		"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific," 
		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
		"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
		"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
		"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
//.........这里部分代码省略.........
开发者ID:vovan888,项目名称:linux-on-sx1,代码行数:101,代码来源:test.c

示例11: DRI2FallbackPRESENTPixmap

BOOL
DRI2FallbackPRESENTPixmap(PRESENTpriv *present_priv, struct DRI2priv *dri2_priv,
                          int fd, int width, int height, int stride, int depth,
                          int bpp, PRESENTPixmapPriv **present_pixmap_priv)
{
    Window root = RootWindow(dri2_priv->dpy, DefaultScreen(dri2_priv->dpy));
    Pixmap pixmap;
    EGLImageKHR image;
    GLuint texture_read, texture_write, fbo_read, fbo_write;
    EGLint attribs[] = {
        EGL_WIDTH, 0,
        EGL_HEIGHT, 0,
        EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
        EGL_DMA_BUF_PLANE0_FD_EXT, 0,
        EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
        EGL_DMA_BUF_PLANE0_PITCH_EXT, 0,
        EGL_NONE
    };
    EGLenum current_api = 0;
    int status;

    pthread_mutex_lock(&present_priv->mutex_present);

    pixmap = XCreatePixmap(dri2_priv->dpy, root, width, height, 24);
    if (!pixmap)
        goto fail;

    attribs[1] = width;
    attribs[3] = height;
    attribs[7] = fd;
    attribs[11] = stride;

    current_api = eglQueryAPI();
    eglBindAPI(EGL_OPENGL_API);

    /* We bind the dma-buf to a EGLImage, then to a texture, and then to a fbo.
     * Note that we can delete the EGLImage, but we shouldn't delete the texture,
     * else the fbo is invalid */

    image = dri2_priv->eglCreateImageKHR_func(dri2_priv->display,
                              EGL_NO_CONTEXT,
                              EGL_LINUX_DMA_BUF_EXT,
                              NULL, attribs);

    if (image == EGL_NO_IMAGE_KHR)
        goto fail;
    close(fd);

    if(eglMakeCurrent(dri2_priv->display, EGL_NO_SURFACE, EGL_NO_SURFACE, dri2_priv->context)) {
        glGenTextures(1, &texture_read);
        glBindTexture(GL_TEXTURE_2D, texture_read);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        dri2_priv->glEGLImageTargetTexture2DOES_func(GL_TEXTURE_2D, image);
        glGenFramebuffers(1, &fbo_read);
        glBindFramebuffer(GL_FRAMEBUFFER, fbo_read);
        glFramebufferTexture2D(GL_FRAMEBUFFER,
                               GL_COLOR_ATTACHMENT0,
                               GL_TEXTURE_2D, texture_read,
                               0);
        status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
        if (status != GL_FRAMEBUFFER_COMPLETE)
            goto fail;
        glBindTexture(GL_TEXTURE_2D, 0);
        dri2_priv->eglDestroyImageKHR_func(dri2_priv->display, image);

        /* We bind a newly created pixmap (to which we want to copy the content)
         * to an EGLImage, then to a texture, then to a fbo. */
        image = dri2_priv->eglCreateImageKHR_func(dri2_priv->display,
                                                  dri2_priv->context,
                                                  EGL_NATIVE_PIXMAP_KHR,
                                                  (void *)pixmap, NULL);
        if (image == EGL_NO_IMAGE_KHR)
            goto fail;

        glGenTextures(1, &texture_write);
        glBindTexture(GL_TEXTURE_2D, texture_write);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        dri2_priv->glEGLImageTargetTexture2DOES_func(GL_TEXTURE_2D, image);
        glGenFramebuffers(1, &fbo_write);
        glBindFramebuffer(GL_FRAMEBUFFER, fbo_write);
        glFramebufferTexture2D(GL_FRAMEBUFFER,
                               GL_COLOR_ATTACHMENT0,
                               GL_TEXTURE_2D, texture_write,
                               0);
        status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
        if (status != GL_FRAMEBUFFER_COMPLETE)
            goto fail;
        glBindTexture(GL_TEXTURE_2D, 0);
        dri2_priv->eglDestroyImageKHR_func(dri2_priv->display, image);
    } else {
        ERR("eglMakeCurrent failed with 0x%0X\n", eglGetError());
    }
    eglMakeCurrent(dri2_priv->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

    *present_pixmap_priv = (PRESENTPixmapPriv *) calloc(1, sizeof(PRESENTPixmapPriv));
    if (!*present_pixmap_priv) {
        goto fail;
    }
//.........这里部分代码省略.........
开发者ID:sarnex,项目名称:wine,代码行数:101,代码来源:dri3.c

示例12: DefaultRootWindow

	//-------------------------------------------------------------------------------------------------//
	void GLXWindow::create(const String& name, uint width, uint height,
			   bool fullScreen, const NameValuePairList *miscParams)
	{
		Display *xDisplay = mGLSupport->getXDisplay();
		String title = name;
		uint samples = 0;
		short frequency = 0;
		bool vsync = false;
		bool hidden = false;
		unsigned int vsyncInterval = 1;
		int gamma = 0;
		::GLXContext glxContext = 0;
		::GLXDrawable glxDrawable = 0;
		Window externalWindow = 0;
		Window parentWindow = DefaultRootWindow(xDisplay);
		int left = DisplayWidth(xDisplay, DefaultScreen(xDisplay))/2 - width/2;
		int top  = DisplayHeight(xDisplay, DefaultScreen(xDisplay))/2 - height/2;
		
		mIsFullScreen = fullScreen;
		
		if(miscParams)
		{
			NameValuePairList::const_iterator opt;
			NameValuePairList::const_iterator end = miscParams->end();
			
			// NB: Do not try to implement the externalGLContext option.
			//
			//	 Accepting a non-current context would expose us to the 
			//	 risk of segfaults when we made it current. Since the
			//	 application programmers would be responsible for these
			//	 segfaults, they are better discovering them in their code.
		
			if ((opt = miscParams->find("currentGLContext")) != end &&
				StringConverter::parseBool(opt->second))
			{
				if (! glXGetCurrentContext())
				{
					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "currentGLContext was specified with no current GL context", "GLXWindow::create");
				}
				
				glxContext = glXGetCurrentContext();
				glxDrawable = glXGetCurrentDrawable();
			}
			
			// Note: Some platforms support AA inside ordinary windows
			if((opt = miscParams->find("FSAA")) != end) 
				samples = StringConverter::parseUnsignedInt(opt->second);
			
			if((opt = miscParams->find("displayFrequency")) != end) 
				frequency = (short)StringConverter::parseInt(opt->second);
			
			if((opt = miscParams->find("vsync")) != end) 
				vsync = StringConverter::parseBool(opt->second);

			if((opt = miscParams->find("hidden")) != end)
				hidden = StringConverter::parseBool(opt->second);

			if((opt = miscParams->find("vsyncInterval")) != end) 
				vsyncInterval = StringConverter::parseUnsignedInt(opt->second);

			if ((opt = miscParams->find("gamma")) != end)
				gamma = StringConverter::parseBool(opt->second);

			if((opt = miscParams->find("left")) != end) 
				left = StringConverter::parseInt(opt->second);
			
			if((opt = miscParams->find("top")) != end) 
				top = StringConverter::parseInt(opt->second);
			
			if((opt = miscParams->find("title")) != end) 
				title = opt->second;
			
			if ((opt = miscParams->find("externalGLControl")) != end)
				mIsExternalGLControl = StringConverter::parseBool(opt->second);
			
			if((opt = miscParams->find("parentWindowHandle")) != end) 
			{
				vector<String>::type tokens = StringUtil::split(opt->second, " :");
				
				if (tokens.size() == 3)
				{
					// deprecated display:screen:xid format
					parentWindow = StringConverter::parseUnsignedLong(tokens[2]);
				}
				else
				{
					// xid format
					parentWindow = StringConverter::parseUnsignedLong(tokens[0]);
				}
			}
			else if((opt = miscParams->find("externalWindowHandle")) != end) 
			{
				vector<String>::type tokens = StringUtil::split(opt->second, " :");
				
				LogManager::getSingleton().logMessage(
													  "GLXWindow::create: The externalWindowHandle parameter is deprecated.\n"
													  "Use the parentWindowHandle or currentGLContext parameter instead.");
				
				if (tokens.size() == 3)
//.........这里部分代码省略.........
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:101,代码来源:OgreGLXWindow.cpp

示例13: OSWindow

X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,
                      X11Display &rDisplay, bool dragDrop, bool playOnDrop,
                      X11Window *pParentWindow, GenericWindow::WindowType_t type ):
    OSWindow( pIntf ), m_rDisplay( rDisplay ), m_pParent( pParentWindow ),
    m_dragDrop( dragDrop ), m_pDropTarget( NULL ), m_type ( type )
{
    XSetWindowAttributes attr;
    unsigned long valuemask;
    std::string name_type;

    if( type == GenericWindow::FullscreenWindow )
    {
        m_wnd_parent = DefaultRootWindow( XDISPLAY );

        int i_screen = DefaultScreen( XDISPLAY );

        attr.event_mask = ExposureMask | StructureNotifyMask;
        attr.background_pixel = BlackPixel( XDISPLAY, i_screen );
        attr.backing_store = Always;
        valuemask = CWBackingStore | CWBackPixel | CWEventMask;

        if( NET_WM_STATE_FULLSCREEN == None )
        {
            attr.override_redirect = True;
            valuemask = valuemask | CWOverrideRedirect;
        }

        name_type = "Fullscreen";
    }
    else if( type == GenericWindow::VoutWindow )
    {
        m_wnd_parent = pParentWindow->m_wnd;

        int i_screen = DefaultScreen( XDISPLAY );

        attr.event_mask = ExposureMask | StructureNotifyMask;
        attr.backing_store = Always;
        attr.background_pixel = BlackPixel( XDISPLAY, i_screen );
        valuemask = CWBackingStore | CWBackPixel | CWEventMask;

        name_type = "VoutWindow";
    }
    else if( type == GenericWindow::FscWindow )
    {
        m_wnd_parent = DefaultRootWindow( XDISPLAY );

        attr.event_mask = ExposureMask | StructureNotifyMask;
        valuemask = CWEventMask;

        name_type = "FscWindow";
    }
    else
    {
        m_wnd_parent = DefaultRootWindow( XDISPLAY );

        attr.event_mask = ExposureMask | StructureNotifyMask;
        valuemask = CWEventMask;

        name_type = "TopWindow";
    }

    // Create the window
    m_wnd = XCreateWindow( XDISPLAY, m_wnd_parent, -10, 0, 10, 10, 0, 0,
                           InputOutput, CopyFromParent, valuemask, &attr );

    // wait for X server to process the previous commands
    XSync( XDISPLAY, false );

    // Set the colormap for 8bpp mode
    if( XPIXELSIZE == 1 )
    {
        XSetWindowColormap( XDISPLAY, m_wnd, m_rDisplay.getColormap() );
    }

    // Select events received by the window
    long event_mask;
    if( type == GenericWindow::VoutWindow )
    {
        event_mask =  ExposureMask|KeyPressMask|
                      LeaveWindowMask|FocusChangeMask;
    }
    else
    {
        event_mask =  ExposureMask|KeyPressMask|
                      PointerMotionMask|ButtonPressMask|ButtonReleaseMask|
                      LeaveWindowMask|FocusChangeMask;
    }
    XSelectInput( XDISPLAY, m_wnd, event_mask );

    // Store a pointer on the generic window in a map
    X11Factory *pFactory = (X11Factory*)X11Factory::instance( getIntf() );
    pFactory->m_windowMap[m_wnd] = &rWindow;

    // Changing decorations
    struct {
        unsigned long flags;
        unsigned long functions;
        unsigned long decorations;
        signed   long input_mode;
        unsigned long status;
//.........这里部分代码省略.........
开发者ID:RamboLouis,项目名称:vlc,代码行数:101,代码来源:x11_window.cpp

示例14: DefaultScreen

const QRect XfitMan::availableGeometry(int screen) const
{
    QDesktopWidget *d = QApplication::desktop();

    if (screen < 0 || screen >= d->screenCount())
        screen = d->primaryScreen();

    QRect available = d->screenGeometry(screen);

    // Iterate over all the client windows and subtract from the available
    // area the space they reserved on the edges (struts).
    // Note: _NET_WORKAREA is not reliable as it exposes only one
    // rectangular area spanning all screens.
    Display *display = QX11Info::display();
    int x11Screen = d->isVirtualDesktop() ? DefaultScreen(display) : screen;

    Atom ret;
    int format, status;
    uchar* data = 0;
    ulong nitems, after;

    status = XGetWindowProperty(display, QX11Info::appRootWindow(x11Screen),
                                atom("_NET_CLIENT_LIST"), 0L, ~0L, False, XA_WINDOW,
                                &ret, &format, &nitems, &after, &data);

    if (status == Success && ret == XA_WINDOW && format == 32 && nitems)
    {
        const QRect desktopGeometry = d->rect();

        Window* xids = (Window*) data;
        for (quint32 i = 0; i < nitems; ++i)
        {
            ulong nitems2;
            uchar* data2 = 0;
            status = XGetWindowProperty(display, xids[i],
                                        atom("_NET_WM_STRUT_PARTIAL"), 0, 12, False, XA_CARDINAL,
                                        &ret, &format, &nitems2, &after, &data2);

            if (status == Success && ret == XA_CARDINAL && format == 32 && nitems2 == 12)
            {
                ulong* struts = (ulong*) data2;

                QRect left(desktopGeometry.x(),
                           desktopGeometry.y() + struts[4],
                           struts[0],
                           struts[5] - struts[4]);
                if (available.intersects(left))
                    available.setX(left.width());

                QRect right(desktopGeometry.x() + desktopGeometry.width() - struts[1],
                            desktopGeometry.y() + struts[6],
                            struts[1],
                            struts[7] - struts[6]);
                if (available.intersects(right))
                    available.setWidth(right.x() - available.x());

                QRect top(desktopGeometry.x() + struts[8],
                          desktopGeometry.y(),
                          struts[9] - struts[8],
                          struts[2]);
                if (available.intersects(top))
                    available.setY(top.height());

                QRect bottom(desktopGeometry.x() + struts[10],
                             desktopGeometry.y() + desktopGeometry.height() - struts[3],
                             struts[11] - struts[10],
                             struts[3]);
                if (available.intersects(bottom))
                    available.setHeight(bottom.y() - available.y());
            }
            if (data2)
                XFree(data2);
        }
    }
    if (data)
        XFree(data);

    return available;
}
开发者ID:Icenowy,项目名称:libsubway,代码行数:79,代码来源:xfitman.cpp

示例15: main

int main(int argc, char **argv){
	Display *dpy;
	Window w, quit, clearButton, drawButton;
	Window root;
    struct timespec wait;
	int    screen;
	unsigned long black, white;
	GC       gc;
	XEvent   e;
    float t;
    int isDraw;
    int pointNum;
    int i;
    XPoint usrPoints[20];
    XPoint bufPoints[20];
    XPoint selectedPoints[20];

    //*************************************init****
    
	dpy = XOpenDisplay("");
    
	root = DefaultRootWindow (dpy);
	screen = DefaultScreen (dpy);
	white = WhitePixel (dpy, screen);
	black = BlackPixel (dpy, screen);
    
	w = XCreateSimpleWindow(dpy, root, 100, 100, WIDTH, HEIGHT, BORDER, black, white);
    
    /* Make Buttons */
	quit = XCreateSimpleWindow(dpy, w, 10, 3, 30, 12, BORDER, black, white);
    clearButton = XCreateSimpleWindow(dpy, w, 52, 3, 37, 12, BORDER, black, white);
    drawButton = XCreateSimpleWindow(dpy, w, 100, 3, 35, 12, BORDER, black, white);

	gc = XCreateGC(dpy, w, 0, NULL);
    
    pointNum = 0;
    isDraw = 0;
    t = 0;
    wait.tv_sec = 0;
    wait.tv_nsec = NANOTIME;
    
    for (i = 0; i < 20; i++) {
        usrPoints[i].x = 0;
        usrPoints[i].y = 0;
        bufPoints[i].x = 0;
        bufPoints[i].y = 0;
    }
    
    //*********************************************
    
	XSelectInput(dpy, w, ButtonPressMask | ExposureMask);
    XSelectInput(dpy, quit, ButtonPressMask);
    XSelectInput(dpy, clearButton, ButtonPressMask);
    XSelectInput(dpy, drawButton, ButtonPressMask);

    
	XMapWindow(dpy, w);
	XMapSubwindows(dpy, w);
    XSetForeground(dpy, gc, white);
	XSetForeground(dpy, gc, black);

    //*************************************loop****
	while(1){
        if(XEventsQueued(dpy, QueuedAfterReading)){
            XDrawString(dpy, quit, gc, 4, 10, "Exit", 4);
            XDrawString(dpy, clearButton, gc, 4, 10, "Clear", 5);
            XDrawString(dpy, drawButton, gc, 4, 10, "Draw", 4);
            //***********************************event****
            XNextEvent(dpy, &e);
            switch(e.type){
                case ButtonPress : 
                    if (e.xany.window == quit) {
                        return 0;
                    } else if (e.xany.window == clearButton) {
                        XClearWindow(dpy, w);
                        t = 0;
                        isDraw = 0;
                        pointNum = 0;
                    } else if (e.xany.window == drawButton) {
                        if (!pointNum) break;
                        isDraw = 1;
                    } else {
                        if (0 < t && t < 1) XClearWindow(dpy, w);
                        selectedPoints[pointNum].x = e.xbutton.x;
                        selectedPoints[pointNum].y = e.xbutton.y;
                        bufPoints[pointNum] = selectedPoints[pointNum];
                        pointNum++;
                        drawPointDetail(dpy, w, gc, bufPoints, pointNum);
                        isDraw = 0;
                        t = 0;
                    }
                    break;
                case Expose:
                    drawPointDetail(dpy, w, gc, bufPoints, pointNum);
                    isDraw = 0;
                    t = 0;
            }
        } else {
            //********************************animation****
            if (t < 1 && isDraw) {
//.........这里部分代码省略.........
开发者ID:mactkg,项目名称:xbeizer,代码行数:101,代码来源:main.c


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