static void
activation_error (void)
{
	char const *vendor;
	GtkWidget *dialog;

	vendor =
	    ServerVendor (GDK_DISPLAY_XDISPLAY
			  (gdk_display_get_default ()));

	/* VNC viewers will not work, do not barrage them with warnings */
	if (NULL != vendor && NULL != strstr (vendor, "VNC"))
		return;

	dialog = gtk_message_dialog_new_with_markup (NULL,
						     0,
						     GTK_MESSAGE_ERROR,
						     GTK_BUTTONS_CLOSE,
						     _
						     ("Error activating XKB configuration.\n"
						      "There can be various reasons for that.\n\n"
						      "If you report this situation as a bug, include the results of\n"
						      " • <b>%s</b>\n"
						      " • <b>%s</b>\n"
						      " • <b>%s</b>\n"
						      " • <b>%s</b>"),
						     "xprop -root | grep XKB",
						     "gsettings get org.gnome.libgnomekbd.keyboard model",
						     "gsettings get org.gnome.libgnomekbd.keyboard layouts",
						     "gsettings get org.gnome.libgnomekbd.keyboard options");
	g_signal_connect (dialog, "response",
			  G_CALLBACK (gtk_widget_destroy), NULL);
	csd_delayed_show_dialog (dialog);
}
Пример #2
0
/**
 * 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"));
}
static int isSunXServer() {
#ifdef __solaris__
  return (strcmp("Sun Microsystems, Inc.", ServerVendor(awt_display)) == 0 &&
          VendorRelease(awt_display) >= 6410);
#else
  return 0;
#endif /* __solaris__ */
}
Пример #4
0
static gboolean check_for_xwin(GdkDisplay *dpy)
{
	char *vendor = ServerVendor(gdk_x11_display_get_xdisplay(dpy));

	if (strstr(vendor, "Cygwin/X"))
		return TRUE;

	return FALSE;
}
Пример #5
0
static void gtkSetDrvGlobalAttrib(void)
{
  GdkDisplay* display = gdk_display_get_default();
  Display* xdisplay = GDK_DISPLAY_XDISPLAY(display);
  IupSetGlobal("XDISPLAY", (char*)xdisplay);
  IupSetGlobal("XSCREEN", (char*)XDefaultScreen(xdisplay));
  IupSetGlobal("XSERVERVENDOR", ServerVendor(xdisplay));
  IupSetfAttribute(NULL, "XVENDORRELEASE", "%d", VendorRelease(xdisplay));
}
Пример #6
0
char *NvCtrlGetServerVendor(NvCtrlAttributeHandle *handle)
{
    NvCtrlAttributePrivateHandle *h;

    if (!handle) return NULL;

    h = (NvCtrlAttributePrivateHandle *) handle;

    if (!h->dpy) return NULL;
    return ServerVendor(h->dpy);

} /* NvCtrlGetServerVendor() */
Пример #7
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))));
}
Пример #8
0
static int
ifSunCreator(void)
{
  char *xvendor, *glvendor, *renderer;
  int isSunCreator = 0; /* Until proven that it is. */
  int savedDisplayMode = 0;
  char *savedDisplayString = 0;
  GLUTwindow *window;

#define VENDOR_SUN "Sun Microsystems"
#define RENDERER_CREATOR "Creator"

  /* Check the X vendor string first.  It is easier to check
     than the OpenGL vendor and renderer strings since it
     doesn't require a valid OpenGL rendering context.  Bail
     early if not connected to a Sun. */
  xvendor = ServerVendor(__glutDisplay);
  if (!strncmp(xvendor, VENDOR_SUN, sizeof(VENDOR_SUN) - 1)) {

    /* We need a valid current OpenGL rendering context to be
       able to call glGetString successfully.  If there is not
       a current window, set up a temporary one just to call
       glGetString with (gag, expensive). */
    if (__glutCurrentWindow) {
      window = NULL;
    } else {
      savedDisplayMode = __glutDisplayMode;
      savedDisplayString = __glutDisplayString;
      __glutDisplayMode = GLUT_RGB | GLUT_SINGLE;
      __glutDisplayString = NULL;
      window = __glutCreateWindow(NULL, 0, 0, 1, 1, 0);
    }

    glvendor = (char *) glGetString(GL_VENDOR);
    if (!strncmp(glvendor, VENDOR_SUN, sizeof(VENDOR_SUN) - 1)) {
      renderer = (char *) glGetString(GL_RENDERER);
      if (!strncmp(renderer, RENDERER_CREATOR, sizeof(RENDERER_CREATOR) - 1)) {
        isSunCreator = 1;
      }
    }
    /* Destroy the temporary window for glGetString if one
       needed to be created. */
    if (window) {
      __glutDestroyWindow(window, window);
      __glutDisplayMode = savedDisplayMode;
      __glutDisplayString = savedDisplayString;
    }
  }
  return isSunCreator;
}
Пример #9
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. */
{
    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);
}
static void
activation_error (void)
{
	char const *vendor = ServerVendor (GDK_DISPLAY ());
	int release = VendorRelease (GDK_DISPLAY ());
	GtkWidget *dialog;
	gboolean badXFree430Release;

	badXFree430Release = (vendor != NULL)
	    && (0 == strcmp (vendor, "The XFree86 Project, Inc"))
	    && (release / 100000 == 403);

	/* VNC viewers will not work, do not barrage them with warnings */
	if (NULL != vendor && NULL != strstr (vendor, "VNC"))
		return;

	dialog = gtk_message_dialog_new_with_markup (NULL,
						     0,
						     GTK_MESSAGE_ERROR,
						     GTK_BUTTONS_CLOSE,
						     _
						     ("Error activating XKB configuration.\n"
						      "It can happen under various circumstances:\n"
						      "- a bug in libxklavier library\n"
						      "- a bug in X server (xkbcomp, xmodmap utilities)\n"
						      "- X server with incompatible libxkbfile implementation\n\n"
						      "X server version data:\n%s\n%d\n%s\n"
						      "If you report this situation as a bug, please include:\n"
						      "- The result of <b>%s</b>\n"
						      "- The result of <b>%s</b>"),
						     vendor,
						     release,
						     badXFree430Release
						     ?
						     _
						     ("You are using XFree 4.3.0.\n"
						      "There are known problems with complex XKB configurations.\n"
						      "Try using a simpler configuration or taking a fresher version of XFree software.")
						     : "",
						     "xprop -root | grep XKB",
						     "gconftool-2 -R /desktop/gnome/peripherals/keyboard/kbd");
	g_signal_connect (dialog, "response",
			  G_CALLBACK (gtk_widget_destroy), NULL);
	gsd_delayed_show_dialog (dialog);
}
Пример #11
0
static qint64 getXServerVersion()
{
    qint64 major, minor, patch;

    Display *dpy = display();
    if (dpy && strstr(ServerVendor(dpy), "X.Org")) {
        const int release  = VendorRelease(dpy);
        major = (release / 10000000);
        minor = (release /   100000) % 100;
        patch = (release /     1000) % 100;
    } else {
        major = 0;
        minor = 0;
        patch = 0;
    }

    return kVersionNumber(major, minor, patch);
}
main()
{
	Display * display;
	int       screen;
	char *    display_name=NULL;
	Window    root;
	Visual*   visual;

	/* Connect to X display server.		*/
	display=XOpenDisplay(display_name);

	/* Get screen ID			*/
	screen=DefaultScreen(display);


	printf("\n\tInformation extracted from the X server\n");
	printf("\t---------------------------------------\n\n");

	printf(" X server by \'%s\'\n",        ServerVendor(display));

	printf(" X Server protocol %d\n",      ProtocolVersion(display));

	printf(" X server Release %d\n",       VendorRelease(display));

	printf(" Screen is %dmm high.\n",      DisplayHeightMM(display, screen));

	printf(" Screen is %dmm wide.\n",      DisplayWidthMM(display, screen));

	printf(" Screen is %d pixels high.\n", DisplayHeight(display, screen));

	printf(" Screen is %d pixels wide.\n", DisplayWidth(display, screen));

	visual = DefaultVisual(display,screen);
	printf(" %3d Colour map entries", visual->map_entries);
	printf(" (Number of colours on the screen at one time).\n");

	printf(" %3d Display planes (bits per screen pixel).\n", DisplayPlanes(display, screen));

	printf(" There is %d screen(s).\n", ScreenCount (display));
}
Пример #13
0
bool Calibrator::has_xorgconfd_support(Display* dpy) {
    bool has_support = false;

    Display* display = dpy;
    if (dpy == NULL) // no connection to reuse
        display = XOpenDisplay(NULL);

    if (display == NULL) {
        fprintf(stderr, "Unable to connect to X server\n");
        exit(1);
    }

    if (strstr(ServerVendor(display), "X.Org") &&
        VendorRelease(display) >= 10800000) {
        has_support = true;
    }

    if (dpy == NULL) // no connection to reuse
        XCloseDisplay(display);

    return has_support;
}
Пример #14
0
char *XServerVendor(Display *dpy) { return (ServerVendor(dpy)); }
Пример #15
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;
}
Пример #16
0
char *keyboard_guess(Display *display) {
  XKeyEvent k;
  KeySym    key;
  char      *res, *vendor;
  char      **extensions;
  char      **ext_name;
  int       n_extensions, i;

  extensions = XListExtensions(display, &n_extensions);
  if (extensions) {

    /* Does the server have the X Keyboard (XKB) extension */
    for (i=0, ext_name = extensions; i < n_extensions; i++) {
      if (strcmp(*ext_name, XKB_EXTENSION_NAME) == 0) {
	if ((res = xguess_from_xkb())) {
	  return res;
	}
      }
      ext_name++;
    }

    /* Does the server have the Apple Window Manager (Apple-WM) extension */
    for (i=0,ext_name = extensions; i < n_extensions; i++) {
      if (strcmp(*ext_name, APPLEWM_EXTENSION_NAME) == 0) {
        if ((res = xguess_from_apple())) {
          return res;
        }
      }
      ext_name++;
    }
  }

  /*-- is hostname same as display host? */
  if (is_local_server(display)) {
    res = (char *)local_guess();
    if (res != NULL) {
      return res;
    }
  }

  /*-- dummy KeyEvent to test KeyCode->KeySym mappings */

  k.type = KeyPress;
  k.serial = 1;
  k.send_event = 0;
  k.display = display;
  k.window = (Window)NULL;
  k.root = (Window)NULL;
  k.subwindow = (Window)NULL;
  k.time = 1;
  k.x = 1;
  k.y = 1;
  k.x_root = 1;
  k.y_root = 1;
  k.state = 0x0;
  k.same_screen = 1;

  /*-- get X Server manufacturer string */
  vendor = ServerVendor(display);

  if (strcmp(vendor, "MIT X Consortium") == 0) {
    /* vanilla R4 or R5 */
  } else if (strcmp(vendor, "X Consortium") == 0) {
    /* vanilla R6 */

  } else if (strcmp(vendor, NCD) == 0) {
    return ncd_guess(display);

  } else if (strncmp(vendor, "DECWINDOWS", 10) == 0) {
    /* something with a Digital X Server */

    k.keycode = 88;  /* Control_R on a PC-style keyboard */
    key = XLookupKeysym(&k, 0);
    if ((int)key == 0xffe4) {
      /* standard PC layout, various models ... */
  
      k.keycode = 9;  /* F1 on a DEC PCXAL*/
      key = XLookupKeysym(&k, 0);
      if ((int)key == 0xffbe) {
        return strdup("pc101-dec-pcxal");  /* eg. DEC AlphaStation 250 4/266 */
      }
  
      k.keycode = 16;  /* F1 on a standard PC */
      key = XLookupKeysym(&k, 0);
      if ((int)key == 0xffbe) {
        return strdup("pc101-unknown-pc101");  /* Honeywell,DEC PC7XL */
      }
    }
  
    k.keycode = 173;  /* Compose_R on a DEC LK401 */
    key = XLookupKeysym(&k, 0);
    if ((int)key == 0xff20) {
      return strdup("lk401-dec-lk401");          /* eg. DEC 3000/400 */
    }
  
    k.keycode = 194;  /* 'a' on a DEC LK201 */
    key = XLookupKeysym(&k, 0);
    if ((int)key == 0x61) {
      return strdup("lk201-dec-lk201");          /* eg. DECstation 3100 */
    }
  }

  /*-- no idea? guesswork time ... */

  k.keycode = 120;  /* Compose_R on an NCD DEC-style keyboard */
                    /* 'F1' on an IBM PC-style */
  key = XLookupKeysym(&k, 0);
  if ((int)key == 0xff20) {
    return strdup("ncd-dec-n108lk");         /* vindaloo */
  }

  if ((int)key == 0xffbe) {
    return strdup("pc101-ibm-5168572M");        /* IBM RS/6000 C10 */
  }

  /*-- give up and go home ... */

  fprintf(stderr, "-k option unable to determine keyboard type.\n");
  return strdup("unknown-unknown-unknown");
}
Пример #17
0
static const char *getBuildInfo(void)
{
    static const char *bldFormat =
        "%s\n"
        "     Built on: %s, %s, %s\n"
        "     Built at: %s, %s\n"
        "   With Motif: %s%d.%d.%d [%s]\n"
        "Running Motif: %d.%d [%s]\n"
        "       Server: %s %d\n"
        "       Visual: %s\n"
        "       Locale: %s\n"
       ;

    static const char *visualClass[] = {"StaticGray",  "GrayScale",
                                        "StaticColor", "PseudoColor",
                                        "TrueColor",   "DirectColor"};

    static const char *const stabilities[] = {"", "(Untested) ", "(Known Bad) "};

    if (bldInfoString == NULL)
    {
        const char *locale;
        char visualStr[500] = "<unknown>";
        const enum MotifStability stab = GetMotifStability();

        if (TheDisplay) {
            Visual     *visual;
            int         depth;
            Colormap    map;
            Boolean usingDefaultVisual = FindBestVisual(TheDisplay, APP_NAME,
                                                        APP_CLASS, &visual,
                                                        &depth, &map);
            sprintf(visualStr,"%d-bit %s (ID %#lx%s)",
                    depth,
                    visualClass[visual->class],
                    visual->visualid,
                    usingDefaultVisual ? ", Default" : "");
        }

        bldInfoString = XtMalloc(strlen(bldFormat) + strlen(warning) + 1024);
        locale = setlocale(LC_MESSAGES, "");

        sprintf(bldInfoString, bldFormat,
             NEditVersion,
             COMPILE_OS, COMPILE_MACHINE, COMPILE_COMPILER,
             linkdate, linktime,
             stabilities[stab], XmVERSION, XmREVISION, XmUPDATE_LEVEL,
             XmVERSION_STRING, 
             xmUseVersion/1000, xmUseVersion%1000,
             _XmVersionString,
             (NULL == TheDisplay ? "<unknown>" : ServerVendor(TheDisplay)),
             (NULL == TheDisplay ? 0 : VendorRelease(TheDisplay)),
             visualStr,
             locale ? locale : "None");

        if (stab == MotifKnownBad)
            strcat(bldInfoString, warning);

        atexit(freeBuildInfo);
    }
    
    return bldInfoString;
}
Пример #18
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);
}
Пример #19
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;
}
Пример #20
0
cairo_xlib_display_t *
_cairo_xlib_display_get (Display *dpy)
{
    cairo_xlib_display_t *display;
    cairo_xlib_display_t **prev;
    XExtCodes *codes;
    int major_unused, minor_unused;

    /* There is an apparent deadlock between this mutex and the
     * mutex for the display, but it's actually safe. For the
     * app to call XCloseDisplay() while any other thread is
     * inside this function would be an error in the logic
     * app, and the CloseDisplay hook is the only other place we
     * acquire this mutex.
     */
    CAIRO_MUTEX_LOCK (_cairo_xlib_display_mutex);

    for (prev = &_cairo_xlib_display_list; (display = *prev); prev = &(*prev)->next)
    {
	if (display->display == dpy) {
	    /*
	     * MRU the list
	     */
	    if (prev != &_cairo_xlib_display_list) {
		*prev = display->next;
		display->next = _cairo_xlib_display_list;
		_cairo_xlib_display_list = display;
	    }
	    break;
	}
    }

    if (display != NULL) {
	display = _cairo_xlib_display_reference (display);
	goto UNLOCK;
    }

    display = malloc (sizeof (cairo_xlib_display_t));
    if (display == NULL) {
	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	goto UNLOCK;
    }

    /* Xlib calls out to the extension close_display hooks in LIFO
     * order. So we have to ensure that all extensions that we depend
     * on in our close_display hook are properly initialized before we
     * add our hook. For now, that means Render, so we call into its
     * QueryVersion function to ensure it gets initialized.
     */
    XRenderQueryVersion (dpy, &major_unused, &minor_unused);

    codes = XAddExtension (dpy);
    if (codes == NULL) {
	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	free (display);
	display = NULL;
	goto UNLOCK;
    }

    XESetCloseDisplay (dpy, codes->extension, _cairo_xlib_close_display);

    _cairo_freelist_init (&display->wq_freelist, sizeof (cairo_xlib_job_t));
    _cairo_freelist_init (&display->hook_freelist, sizeof (cairo_xlib_hook_t));

    CAIRO_REFERENCE_COUNT_INIT (&display->ref_count, 2); /* add one for the CloseDisplay */
    CAIRO_MUTEX_INIT (display->mutex);
    display->display = dpy;
    display->screens = NULL;
    display->workqueue = NULL;
    display->close_display_hooks = NULL;
    display->closed = FALSE;

    display->buggy_repeat = FALSE;
    if (strstr (ServerVendor (dpy), "X.Org") != NULL) {
	/* When modularized, the X.Org server VendorRelease was
	 * bogusly reset to a very small number, without any change in
	 * the ServerVendor string. We avoid considering the new
	 * servers with the small number as buggy by restricting the
	 * test to known bad releases. But there could be a problem
	 * again in the future if X.Org server versions ever climb
	 * back up to 6.7 or 6.8. */
	if (VendorRelease (dpy) >= 60700000 && VendorRelease (dpy) <= 60802000)
	    display->buggy_repeat = TRUE;

	/* But even the new modular server has bugs, (bad enough to
	 * crash the X server), that it so happens we can avoid with
	 * the exact same buggy_repeat workaround. We've verified that
	 * this bug exists as least as late as version 1.3.0.0, (which
	 * is in Fedora 8), and is gone again in version 1.4.99.901
	 * (from a Fedora 9 Beta). Versions between those are still
	 * unknown, but until we learn more, we'll assume that any 1.3
	 * version is buggy.  */
	if (VendorRelease (dpy) < 10400000)
	    display->buggy_repeat = TRUE;
    } else if (strstr (ServerVendor (dpy), "XFree86") != NULL) {
	if (VendorRelease (dpy) <= 40500000)
	    display->buggy_repeat = TRUE;
    }

    display->next = _cairo_xlib_display_list;
    _cairo_xlib_display_list = display;

UNLOCK:
    CAIRO_MUTEX_UNLOCK (_cairo_xlib_display_mutex);
    return display;
}
Пример #21
0
$NetBSD$

Recognize Xorg servers as well as X.org servers. From Chris Wilson (upstream);
fixes some more firefox issues.

--- src/cairo-xlib-surface-shm.c.orig	2012-10-21 08:13:41.000000000 +0000
+++ src/cairo-xlib-surface-shm.c
@@ -1141,7 +1141,8 @@ xorg_has_buggy_send_shm_completion_event
      *
      * Remove the SendEvent bit (0x80) before doing range checks on event type.
      */
-    return (strstr (ServerVendor (dpy), "X.Org") != NULL &&
+    return ((strstr (ServerVendor (dpy), "X.Org") != NULL ||
+    		strstr (ServerVendor (dpy), "Xorg") != NULL ) &&
 	    VendorRelease (dpy) < XORG_VERSION_ENCODE(1,11,0,1));
 }
 
Пример #22
0
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 );
}