コード例 #1
0
ファイル: XDPSshare.c プロジェクト: narenas/nx-libs
static DisplayInfo AllocDisplayInfo(
    Display *display,
    DPSContext context)
{
    DisplayInfo d = (DisplayInfo) malloc(sizeof(DisplayInfoRec));
    register int i;

    if (d == NULL) return NULL;
    d->next = displayList;
    displayList = d;

    d->display = display;
    d->defaultContext = context;
    d->extensionPresent = (context == NULL) ? ext_no_idea : ext_yes;

    d->depthsForScreen = (int *) calloc(ScreenCount(display), sizeof(int));
    d->validDepths = (int **) calloc(ScreenCount(display), sizeof(int *));
    d->gcForDepth = (GC **) calloc(ScreenCount(display), sizeof(GC *));

    for (i = 0; i < ScreenCount(display); i++) {
        d->validDepths[i] = XListDepths(display, i, &d->depthsForScreen[i]);
	d->gcForDepth[i] = (GC *) calloc(d->depthsForScreen[i], sizeof(GC));
    }

    return d;
}
コード例 #2
0
void PsychGetScreenDepths(int screenNumber, PsychDepthType *depths)
{
  int* x11_depths;
  int  i, count;

  if(screenNumber>=numDisplays) PsychErrorExitMsg(PsychError_internal, "screenNumber is out of range"); //also checked within SCREENPixelSizes

  x11_depths = XListDepths(displayCGIDs[screenNumber], PsychGetXScreenIdForScreen(screenNumber), &count);
  if (depths && count>0) {
    // Query successful: Add all values to depth struct:
    for(i=0; i<count; i++) PsychAddValueToDepthStruct(x11_depths[i], depths);
    XFree(x11_depths);
  }
  else {
    // Query failed: Assume at least 32 bits is available.
    printf("PTB-WARNING: Couldn't query available display depths values! Returning a made up list...\n");
    fflush(NULL);
    PsychAddValueToDepthStruct(32, depths);
    PsychAddValueToDepthStruct(24, depths);
    PsychAddValueToDepthStruct(16, depths); 
  }
}
コード例 #3
0
std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
{
    std::vector<VideoMode> modes;

    // Open a connection with the X server
    Display* display = OpenDisplay();
    if (display)
    {
        // Retrieve the default screen number
        int screen = DefaultScreen(display);

        // Check if the XRandR extension is present
        int version;
        if (XQueryExtension(display, "RANDR", &version, &version, &version))
        {
            // Get the current configuration
            XRRScreenConfiguration* config = XRRGetScreenInfo(display, RootWindow(display, screen));
            if (config)
            {
                // Get the available screen sizes
                int nbSizes;
                XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
                if (sizes && (nbSizes > 0))
                {
                    // Get the list of supported depths
                    int nbDepths = 0;
                    int* depths = XListDepths(display, screen, &nbDepths);
                    if (depths && (nbDepths > 0))
                    {
                        // Combine depths and sizes to fill the array of supported modes
                        for (int i = 0; i < nbDepths; ++i)
                        {
                            for (int j = 0; j < nbSizes; ++j)
                            {
                                // Convert to VideoMode
                                VideoMode mode(sizes[j].width, sizes[j].height, depths[i]);
            
                                // Add it only if it is not already in the array
                                if (std::find(modes.begin(), modes.end(), mode) == modes.end())
                                    modes.push_back(mode);
                            }
                        }

                        // Free the array of depths
                        XFree(depths);
                    }
                }

                // Free the configuration instance
                XRRFreeScreenConfigInfo(config);
            }
            else
            {
                // Failed to get the screen configuration
                err() << "Failed to retrieve the screen configuration while trying to get the supported video modes" << std::endl;
            }
        }
        else
        {
            // XRandr extension is not supported : we cannot get the video modes
            err() << "Failed to use the XRandR extension while trying to get the supported video modes" << std::endl;
        }

        // Close the connection with the X server
        CloseDisplay(display);
    }
    else
    {
        // We couldn't connect to the X server
        err() << "Failed to connect to the X server while trying to get the supported video modes" << std::endl;
    }

    return modes;
}
コード例 #4
0
ファイル: gdkdrawable-x11.c プロジェクト: chipx86/gtk
gboolean
_gdk_x11_have_render (GdkDisplay *display)
{
  Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
  GdkDisplayX11 *x11display = GDK_DISPLAY_X11 (display);

  if (x11display->have_render == GDK_UNKNOWN)
    {
      int event_base, error_base;
      x11display->have_render =
	XRenderQueryExtension (xdisplay, &event_base, &error_base)
	? GDK_YES : GDK_NO;

      if (x11display->have_render == GDK_YES)
	{
	  /*
	   * Sun advertises RENDER, but fails to support 32-bit pixmaps.
	   * That is just no good.  Therefore, we check all screens
	   * for proper support.
	   */

	  int screen;
	  for (screen = 0; screen < ScreenCount (xdisplay); screen++)
	    {
	      int count;
	      int *depths = XListDepths (xdisplay, screen, &count);
	      gboolean has_8 = FALSE, has_32 = FALSE;

	      if (depths)
		{
		  int i;

		  for (i = 0; i < count; i++)
		    {
		      if (depths[i] == 8)
			has_8 = TRUE;
		      else if (depths[i] == 32)
			has_32 = TRUE;
		    }
		  XFree (depths);
		}

	      /* At this point, we might have a false positive;
	       * buggy versions of Xinerama only report depths for
	       * which there is an associated visual; so we actually
	       * go ahead and try create pixmaps.
	       */
	      if (!(has_8 && has_32))
		{
		  gdk_error_trap_push ();
		  if (!has_8)
		    try_pixmap (xdisplay, screen, 8);
		  if (!has_32)
		    try_pixmap (xdisplay, screen, 32);
		  XSync (xdisplay, False);
		  if (gdk_error_trap_pop () == 0)
		    {
		      has_8 = TRUE;
		      has_32 = TRUE;
		    }
		}
	      
	      if (!(has_8 && has_32))
		{
		  g_warning ("The X server advertises that RENDER support is present,\n"
			     "but fails to supply the necessary pixmap support.  In\n"
			     "other words, it is buggy.");
		  x11display->have_render = GDK_NO;
		  break;
		}
	    }
	}
    }

  return x11display->have_render == GDK_YES;
}
コード例 #5
0
unsigned long (*colorCvtFunc)(int, int, int);    /* Color convererter - translate javaRGB -> nativeRGB */
unsigned long (*colorDeCvtFunc)(int, int);    /* Color DEconvererter - translate javaRGB <- nativeRGB */


#ifdef CVM_DEBUG
JavaVM *jvm;
#endif


JNIEXPORT jintArray JNICALL
Java_java_awt_X11GraphicsDevice_getDepths(JNIEnv *env, jobject this, jint screen)
{
  int numDepths;
  jintArray depthArray;
  int *depths = XListDepths(xawt_display, screen, &numDepths);

  if(numDepths>0) {
    depthArray = (*env)->NewIntArray(env, numDepths);

    (*env)->SetIntArrayRegion(env, depthArray, 0, numDepths, (jint *)depths);

    XFree(depths);
  }
    
  return depthArray;
}


JNIEXPORT jintArray JNICALL
Java_java_awt_X11GraphicsDevice_getVisualIDs(JNIEnv *env, jobject this, jint screen, jint depth)
コード例 #6
0
ファイル: palette.c プロジェクト: klickverbot/wine
/***********************************************************************
 *           COLOR_Init
 *
 * Initialize color management.
 */
int X11DRV_PALETTE_Init(void)
{
    int	mask, white, black;
    int monoPlane;
    int *mapping;
    PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS];

    TRACE("initializing palette manager...\n");

    wine_tsx11_lock();
    palette_context = XUniqueContext();
    wine_tsx11_unlock();
    white = WhitePixel( gdi_display, DefaultScreen(gdi_display) );
    black = BlackPixel( gdi_display, DefaultScreen(gdi_display) );
    monoPlane = 1;
    for( mask = 1; !((white & mask)^(black & mask)); mask <<= 1 )
	 monoPlane++;
    X11DRV_PALETTE_PaletteFlags = (white & mask) ? X11DRV_PALETTE_WHITESET : 0;
    palette_size = visual->map_entries;

    switch(visual->class)
    {
    case DirectColor:
	X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_VIRTUAL;
    case GrayScale:
    case PseudoColor:
        wine_tsx11_lock();
	if (private_color_map)
	{
	    XSetWindowAttributes win_attr;

	    X11DRV_PALETTE_PaletteXColormap = XCreateColormap( gdi_display, root_window,
                                                               visual, AllocAll );
	    if (X11DRV_PALETTE_PaletteXColormap)
	    {
	        X11DRV_PALETTE_PaletteFlags |= (X11DRV_PALETTE_PRIVATE | X11DRV_PALETTE_WHITESET);

		monoPlane = 1;
		for( white = palette_size - 1; !(white & 1); white >>= 1 )
		     monoPlane++;

	        if( root_window != DefaultRootWindow(gdi_display) )
	        {
		    win_attr.colormap = X11DRV_PALETTE_PaletteXColormap;
		    XChangeWindowAttributes( gdi_display, root_window, CWColormap, &win_attr );
		}
	    }
	} else {
	  X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
							    visual, AllocNone);
	}
        wine_tsx11_unlock();
        break;

    case StaticGray:
        wine_tsx11_lock();
        X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
                                                          visual, AllocNone);
	X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_FIXED;
        X11DRV_PALETTE_Graymax = (1 << screen_depth)-1;
        wine_tsx11_unlock();
        break;

    case TrueColor:
	X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_VIRTUAL;
    case StaticColor: {
    	int *depths,nrofdepths;
	/* FIXME: hack to detect XFree32 XF_VGA16 ... We just have
	 * depths 1 and 4
	 */
        wine_tsx11_lock();
        depths = XListDepths(gdi_display,DefaultScreen(gdi_display),&nrofdepths);
	if ((nrofdepths==2) && ((depths[0]==4) || depths[1]==4)) {
	    monoPlane = 1;
	    for( white = palette_size - 1; !(white & 1); white >>= 1 )
	        monoPlane++;
    	    X11DRV_PALETTE_PaletteFlags = (white & mask) ? X11DRV_PALETTE_WHITESET : 0;
            X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
                                                              visual, AllocNone);
	}
        else
        {
コード例 #7
0
ファイル: gui_main.c プロジェクト: likev/CodeOrpgPub
void setup_gui_colors() 
{
  XColor kolor,unused;
  int *depths, num_depths;

  display = XtDisplay(shell);
  window = XtWindow(shell);

  if((depths = XListDepths(display, XScreenNumberOfScreen(XtScreen(shell)), 
               &num_depths))==NULL) {
      printf("XListDepths() failed.\n");
      exit(0);
  }

  cmap = DefaultColormap(display, 0); 

  XAllocNamedColor(display,cmap,"black",&kolor,&unused);
  black_color = kolor.pixel;

  XAllocNamedColor(display,cmap,"white",&kolor,&unused);
  white_color = kolor.pixel;

  XAllocNamedColor(display,cmap,"lawngreen",&kolor,&unused);
  green_color = kolor.pixel;

  XAllocNamedColor(display,cmap,"red",&kolor,&unused);
  red_color = kolor.pixel;

  XAllocNamedColor(display,cmap,"blue",&kolor,&unused);
  blue_color = kolor.pixel;

  XAllocNamedColor(display,cmap,"grey",&kolor,&unused);
  grey_color = kolor.pixel;

  XAllocNamedColor(display,cmap,"yellow",&kolor,&unused);
  yellow_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"orange",&kolor,&unused);
  orange_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"magenta",&kolor,&unused);
  magenta_color = kolor.pixel;  
  
  XAllocNamedColor(display,cmap,"cyan",&kolor,&unused);
  cyan_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"brown",&kolor,&unused);
  brown_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"light grey",&kolor,&unused);
  light_grey_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"snow",&kolor,&unused);
  snow_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"indian red",&kolor,&unused);
  indian_red_color = kolor.pixel;
  
  XAllocNamedColor(display,cmap,"ghost white",&kolor,&unused);
  ghost_white_color = kolor.pixel;
  
  gcv.foreground = white_color;
  gcv.background = black_color;
  gcv.graphics_exposures = FALSE;
  gc = XCreateGC(display, window, GCBackground|GCForeground|GCGraphicsExposures, &gcv);
  
}