/**
 * Do deferred logging after initialisation
 */
void doXKeyboardLogging(Display *dpy)
{
    if (((1 == gfByTypeOK) || (1 == gfByXkbOK)) && (gfByLayoutOK != 1))
        dumpLayout(dpy);
    if (((1 == gfByLayoutOK) || (1 == gfByXkbOK)) && (gfByTypeOK != 1))
        dumpType(dpy);
    if ((gfByLayoutOK != 1) && (gfByTypeOK != 1) && (gfByXkbOK != 1))
    {
        LogRel(("Failed to recognize the keyboard mapping or to guess it based on\n"
                "the keyboard layout.  It is very likely that some keys will not\n"
                "work correctly in the guest.  If this is the case, please submit\n"
                "a bug report, giving us information about your keyboard type,\n"
                "its layout and other relevant information such as whether you\n"
                "are using a remote X server or something similar. \n"));
        unsigned *keyc2scan = X11DRV_getKeyc2scan();

        LogRel(("The keycode-to-scancode table is: %d=%d",0,keyc2scan[0]));
        for (int i = 1; i < 256; i++)
            LogRel((",%d=%d",i,keyc2scan[i]));
        LogRel(("\n"));
    }
    LogRel(("X Server details: vendor: %s, release: %d, protocol version: %d.%d, display string: %s\n",
            ServerVendor(dpy), VendorRelease(dpy), ProtocolVersion(dpy),
            ProtocolRevision(dpy), DisplayString(dpy)));
    LogRel(("Using %s for keycode to scan code conversion\n",
              gfByXkbOK ? "XKB"
            : gfByTypeOK ? "known keycode mapping"
            : "host keyboard layout detection"));
}
int NvCtrlGetProtocolRevision(NvCtrlAttributeHandle *handle)
{
    NvCtrlAttributePrivateHandle *h;

    if (!handle) return -1;

    h = (NvCtrlAttributePrivateHandle *) handle;

    if (!h->dpy) return -1;
    return ProtocolRevision(h->dpy);

} /* NvCtrlGetProtocolRevision() */
Exemple #3
0
void
TkGetServerInfo(
    Tcl_Interp *interp,		/* The server information is returned in this
				 * interpreter's result. */
    Tk_Window tkwin)		/* Token for window; this selects a particular
				 * display and server. */
{
    Tcl_SetObjResult(interp, Tcl_ObjPrintf("X%dR%d %s %d",
	    ProtocolVersion(Tk_Display(tkwin)),
	    ProtocolRevision(Tk_Display(tkwin)),
	    ServerVendor(Tk_Display(tkwin)),
	    VendorRelease(Tk_Display(tkwin))));
}
Exemple #4
0
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
{
    // get X protocol version
    Display *display = wxGlobalDisplay();
    if (display)
    {
        if ( verMaj )
            *verMaj = ProtocolVersion (display);
        if ( verMin )
            *verMin = ProtocolRevision (display);
    }

    return wxPORT_X11;
}
void
TkGetServerInfo(
    Tcl_Interp *interp,		/* The server information is returned in this
				 * interpreter's result. */
    Tk_Window tkwin)		/* Token for window; this selects a particular
				 * display and server. */
{
    char buffer[8 + TCL_INTEGER_SPACE * 2];
    char buffer2[TCL_INTEGER_SPACE];

    sprintf(buffer, "X%dR%d ", ProtocolVersion(Tk_Display(tkwin)),
	    ProtocolRevision(Tk_Display(tkwin)));
    sprintf(buffer2, " %d", VendorRelease(Tk_Display(tkwin)));
    Tcl_AppendResult(interp, buffer, ServerVendor(Tk_Display(tkwin)),
	    buffer2, (char *) NULL);
}
Exemple #6
0
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
{
    static wxToolkitInfo info;

    info.shortName = _T("motif");
    info.name = _T("wxMotif");
#ifdef __WXUNIVERSAL__
    info.shortName << _T("univ");
    info.name << _T("/wxUniversal");
#endif
    // FIXME TODO
    // This code is WRONG!! Does NOT return the
    // Motif version of the libs but the X protocol
    // version!
    Display *display = wxGlobalDisplay();
    info.versionMajor = ProtocolVersion (display);
    info.versionMinor = ProtocolRevision (display);
    info.os = wxMOTIF_X;
    return info;
}
Exemple #7
0
static ALLEGRO_SYSTEM *xglx_initialize(int flags)
{
   Display *x11display;
   Display *gfxdisplay;
   ALLEGRO_SYSTEM_XGLX *s;

   (void)flags;

#ifdef DEBUG_X11
   _Xdebug = 1;
#endif

   XInitThreads();

   /* Get an X11 display handle. */
   x11display = XOpenDisplay(0);
   if (x11display) {
      /* Never ask. */
      gfxdisplay = XOpenDisplay(0);
      if (!gfxdisplay) {
         ALLEGRO_ERROR("XOpenDisplay failed second time.\n");
         XCloseDisplay(x11display);
         return NULL;
      }
   }
   else {
      ALLEGRO_INFO("XOpenDisplay failed; assuming headless mode.\n");
      gfxdisplay = NULL;
   }
   
   _al_unix_init_time();

   s = al_calloc(1, sizeof *s);

   _al_mutex_init_recursive(&s->lock);
   _al_cond_init(&s->resized);
   s->inhibit_screensaver = false;

   _al_vector_init(&s->system.displays, sizeof (ALLEGRO_DISPLAY_XGLX *));

   s->system.vt = xglx_vt;

   s->gfxdisplay = gfxdisplay;
   s->x11display = x11display;

   if (s->x11display) {
      ALLEGRO_INFO("XGLX driver connected to X11 (%s %d).\n",
         ServerVendor(s->x11display), VendorRelease(s->x11display));
      ALLEGRO_INFO("X11 protocol version %d.%d.\n",
         ProtocolVersion(s->x11display), ProtocolRevision(s->x11display));

      /* We need to put *some* atom into the ClientMessage we send for
       * faking mouse movements with al_set_mouse_xy - so let's ask X11
       * for one here.
       */
      s->AllegroAtom = XInternAtom(x11display, "AllegroAtom", False);

      /* Message type for XEmbed protocol. */
      s->XEmbedAtom = XInternAtom(x11display, "_XEMBED", False);

      _al_thread_create(&s->xevents_thread, _al_xwin_background_thread, s);
      s->have_xevents_thread = true;
      ALLEGRO_INFO("events thread spawned.\n");
   }

   return &s->system;
}
void
check_AfterStep_dirtree ( char * ashome, Bool create_non_conf )
{
	char         *fullfilename;
	/* Create missing directories & put there defaults */
	if (CheckDir (ashome) != 0)
	{
		CheckOrCreate (ashome);

#if defined(DO_SEND_POSTCARD) /*&& defined(HAVE_POPEN) */
		/* send some info to sasha @ aftercode.net */
		{
			FILE *p;
			char *filename = make_file_name(ashome, ".postcard");
			/*p = popen ("mail -s \"AfterStep installation info\" [email protected]", "w");*/
			p = fopen( filename, "wt" );
			free(filename);
			if (p)
			{
				fprintf( p, "AfterStep_Version=\"%s\";\n", VERSION );
				fprintf( p, "CanonicalBuild=\"%s\";\n", CANONICAL_BUILD );
				fprintf( p, "CanonicalOS=\"%s\";\n", CANONICAL_BUILD_OS );
				fprintf( p, "CanonicalCPU=\"%s\";\n", CANONICAL_BUILD_CPU );
				fprintf( p, "CanonicalVendor=\"%s\";\n", CANONICAL_BUILD_VENDOR );
				if( dpy )
				{
					fprintf (p, "X_DefaultScreenNumber=%d;\n", DefaultScreen (dpy));
					fprintf (p, "X_NumberOfScreens=%d;\n", ScreenCount (dpy));
					fprintf (p, "X_Display=\"%s\";\n", DisplayString (dpy));
					fprintf (p, "X_ProtocolVersion=%d.%d;\n", ProtocolVersion (dpy), ProtocolRevision (dpy));
					fprintf (p, "X_Vendor=\"%s\";\n", ServerVendor (dpy));
					fprintf (p, "X_VendorRelease=%d;\n", VendorRelease (dpy));
					if (strstr(ServerVendor (dpy), "XFree86"))
					{
						int vendrel = VendorRelease(dpy);
						fprintf(p, "X_XFree86Version=");
						if (vendrel < 336)
						{
							fprintf(p, "%d.%d.%d", vendrel / 100, (vendrel / 10) % 10, vendrel       % 10);
						} else if (vendrel < 3900)
						{
							fprintf(p, "%d.%d", vendrel / 1000,  (vendrel /  100) % 10);
							if (((vendrel / 10) % 10) || (vendrel % 10))
							{
								fprintf(p, ".%d", (vendrel / 10) % 10);
								if (vendrel % 10)
									fprintf(p, ".%d", vendrel % 10);
							}
						} else if (vendrel < 40000000)
						{
							fprintf(p, "%d.%d", vendrel/1000,  (vendrel/10) % 10);
							if (vendrel % 10)
								fprintf(p, ".%d", vendrel % 10);
						} else
						{
							fprintf(p, "%d.%d.%d", vendrel/10000000,(vendrel/100000)%100, (vendrel/1000)%100);
							if (vendrel % 1000)
								fprintf(p, ".%d", vendrel % 1000);
						}
						fprintf(p, ";\n");
					}
					if( ASDefaultScrWidth > 0 )
					{
						fprintf( p, "AS_Screen=%ld;\n", ASDefaultScr->screen );
						fprintf( p, "AS_RootGeometry=%dx%d;\n", ASDefaultScrWidth, ASDefaultScrHeight );
					}
					if( ASDefaultVisual )
					{
						fprintf( p, "AS_Visual=0x%lx;\n", ASDefaultVisual->visual_info.visualid );
						fprintf( p, "AS_Colordepth=%d;\n", ASDefaultVisual->visual_info.depth );
						fprintf( p, "AS_RedMask=0x%lX;\n", ASDefaultVisual->visual_info.red_mask );
						fprintf( p, "AS_GreenMask=0x%lX;\n", ASDefaultVisual->visual_info.green_mask );
						fprintf( p, "AS_BlueMask=0x%lX;\n", ASDefaultVisual->visual_info.blue_mask );
						fprintf( p, "AS_ByteOrdering=%s;\n", (ImageByteOrder(ASDefaultVisual->dpy)==MSBFirst)?"MSBFirst":"LSBFirst" );
					}
				}
				fclose(p);
				/*pclose (p);*/
			/*p = popen ("mail -s \"AfterStep installation info\" [email protected]", "w");*/
			}
		}
#endif
	}
	fullfilename = make_file_name (ashome, AFTER_SAVE);
	CheckOrCreateFile (fullfilename);
	free( fullfilename );

#if 0
	fullfilename = make_file_name (ashome, THEME_FILE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, LOOK_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, FEEL_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, THEME_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, COLORSCHEME_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, BACK_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );
#endif
	fullfilename = make_file_name (ashome, DESKTOP_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, ICON_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, FONT_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, TILE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, WEBCACHE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );
	
	if( create_non_conf )
	{
		char *postcard_fname ;
		FILE *f ;
		fullfilename = make_file_name (ashome, AFTER_NONCF);
		/* legacy non-configurable dir: */
		CheckOrCreate(fullfilename);
		postcard_fname = make_file_name( fullfilename, "send_postcard.sh" );
		free( fullfilename );
		
		f = fopen( postcard_fname, "wt" );
		if( f ) 
		{
			fprintf( f, "#!/bin/sh\n\n" );
			fprintf( f, "if [ -r %s/.postcard ] \nthen echo -n \nelse rm %s \nexit\nfi\n", ashome, postcard_fname );
			fprintf( f, "x-terminal-emulator -e \"%s/tools/postcard.sh\"\n", AFTER_SHAREDIR );
			fprintf( f, "if [ -r %s/.postcard ] \nthen echo -n \nelse rm %s \nfi\n", ashome, postcard_fname );
			fclose( f );
		}
		chmod (postcard_fname, 0700);
		free(postcard_fname);
	}

	char *cachefilename = make_file_name(ashome, THUMBNAILS_DIR);
	CheckOrCreate(cachefilename);
	extern void set_asimage_thumbnails_cache_dir(const char*);
	set_asimage_thumbnails_cache_dir(cachefilename);
	free( cachefilename );
}
Exemple #9
0
/* Create a new system object for the dummy X11 driver. */
static ALLEGRO_SYSTEM *xglx_initialize(int flags)
{
   Display *x11display;
   Display *gfxdisplay;
   ALLEGRO_SYSTEM_XGLX *s;

   (void)flags;

#ifdef DEBUG_X11
   _Xdebug = 1;
#endif

   XInitThreads();

   /* Get an X11 display handle. */
   x11display = XOpenDisplay(0);
   if (!x11display) {
      ALLEGRO_ERROR("XOpenDisplay failed.\n");
      return NULL;
   }

   /* Never ask. */
   gfxdisplay = XOpenDisplay(0);
   if (!gfxdisplay) {
      ALLEGRO_ERROR("XOpenDisplay failed.\n");
      XCloseDisplay(x11display);
      return NULL;
   }

   _al_unix_init_time();

   s = _AL_MALLOC(sizeof *s);
   memset(s, 0, sizeof *s);

   /* We need to put *some* atom into the ClientMessage we send for
    * faking mouse movements with al_set_mouse_xy - so lets ask X11
    * for one here.
    */
   s->AllegroAtom = XInternAtom(x11display, "AllegroAtom", False);

   _al_mutex_init_recursive(&s->lock);
   _al_cond_init(&s->resized);
   s->inhibit_screensaver = false;

   _al_vector_init(&s->system.displays, sizeof (ALLEGRO_DISPLAY_XGLX *));

   s->gfxdisplay = gfxdisplay;
   s->x11display = x11display;

   s->system.vt = xglx_vt;

   ALLEGRO_INFO("XGLX driver connected to X11 (%s %d).\n",
      ServerVendor(s->x11display), VendorRelease(s->x11display));
   ALLEGRO_INFO("X11 protocol version %d.%d.\n",
      ProtocolVersion(s->x11display), ProtocolRevision(s->x11display));

#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA
   _al_xsys_xinerama_init(s);
#endif

   _al_xglx_store_video_mode(s);
   
   _al_thread_create(&s->thread, xglx_background_thread, s);

   ALLEGRO_INFO("events thread spawned.\n");

   return &s->system;
}
Exemple #10
0
int main(int argc, char *argv[]) {
  Display  *display;
  char     *display_name;
  int      c = 0;
  int      operation = 0;
  int      long_index = 0;

  /*-- parse arguments and decide what to do */
  while (operation == 0) {
    c = getopt_long(argc, argv, "xyzmnrs:vkhV", long_options, &long_index);
    switch (c) {
    case 's':
      screen_number = strtol(optarg, NULL, 10);
      break;
    case 'x':
    case 'y':
    case 'z':
    case 'm':
    case 'n':
    case 'r':
    case 'v':
    case 'k':
      operation = c;
      break;
    case 'h':
      usage(argv[0]);
      exit(0);
    case 'V':
      printf("%s\n", VERSION);
      exit(0);
    case -1:
      operation = -1;
      break;
    case '?':
      usage(argv[0]);
      exit(1);
    }
  }

  /* check whether operation is set yet */
  if (operation < 1) {
    usage(argv[0]);
    exit(1);
  }

  /* check that we have a DISPLAY environment variable */
  if (!(display_name = getenv(DISPLAY))) {
    fprintf(stderr, "Cannot locate display - DISPLAY variable not set.\n\n");
    exit(1);
  }

  /* check that we have access to the display */
  if (!(display = XOpenDisplay(display_name))) {
    fprintf(stderr, "Cannot open display from DISPLAY variable.\n\n");
    exit(1);
  }

  /* check screen number */
  if (screen_number >= ScreenCount(display)) {
    fprintf(stderr, "cannot use screen %d, only %d screen(s) available.\n", screen_number, ScreenCount(display));
    usage(argv[0]);
    exit(1);
  }

  switch (operation) {
  case 'x':
    printf("%d\n", DisplayWidth(display, screen_number));
    break;
  case 'y':
    printf("%d\n", DisplayHeight(display, screen_number));
    break;
  case 'z':
    printf("%d\n", DefaultDepth(display, screen_number));
    break;
  case 'm':
    printf("%s\n", ServerVendor(display));
    break;
  case 'n':
    printf("%d\n", ScreenCount(display));
    break;
  case 'r':
    printf("%d\n", VendorRelease(display));
    break;
  case 'v':
    printf("%d.%d\n", ProtocolVersion(display), ProtocolRevision(display));
    break;
  case 'k':
    printf("%s\n", keyboard_guess(display));
    break;
  }

  exit(0);
}
Exemple #11
0
int XProtocolRevision(Display *dpy) { return (ProtocolRevision(dpy));}