Beispiel #1
0
/* The first time we grab an image, do it the default way.
   The second and subsequent times, add "-no-desktop" to the command.
   That way we don't have to watch the window un-map 5+ times in a row.
   Also, we end up with the desktop on only one channel, and pictures
   on all the others (or colorbars, if no imageDirectory is set.)
 */
static void
hack_resources (Display *dpy)
{
#ifndef HAVE_JWXYZ
  static int count = -1;
  count++;

  if (count == 0)
    return;
  else if (count == 1)
    {
      XrmDatabase db = XtDatabase (dpy);
      char *res = "desktopGrabber";
      char *val = get_string_resource (dpy, res, "DesktopGrabber");
      char buf1[255];
      char buf2[255];
      XrmValue value;
      sprintf (buf1, "%.100s.%.100s", progname, res);
      sprintf (buf2, "%.200s -no-desktop", val);
      value.addr = buf2;
      value.size = strlen(buf2);
      XrmPutResource (&db, buf1, "String", &value);
    }
#endif /* HAVE_JWXYZ */
}
Beispiel #2
0
/* Kludge to add "-v" to invocation of "xscreensaver-getimage" in -debug mode
 */
static void
hack_resources (void)
{
#if 0
  char *res = "desktopGrabber";
  char *val = get_string_resource (res, "DesktopGrabber");
  char buf1[255];
  char buf2[255];
  XrmValue value;
  sprintf (buf1, "%.100s.%.100s", progclass, res);
  sprintf (buf2, "%.200s -v", val);
  value.addr = buf2;
  value.size = strlen(buf2);
  XrmPutResource (&db, buf1, "String", &value);
#endif
}
/* Kludge to add "-v" to invocation of "xscreensaver-getimage" in -debug mode
 */
static void
hack_resources (Display *dpy)
{
# ifndef HAVE_COCOA
  char *res = "desktopGrabber";
  char *val = get_string_resource (dpy, res, "DesktopGrabber");
  char buf1[255];
  char buf2[255];
  XrmValue value;
  XrmDatabase db = XtDatabase (dpy);
  sprintf (buf1, "%.100s.%.100s", progname, res);
  sprintf (buf2, "%.200s -v", val);
  value.addr = buf2;
  value.size = strlen(buf2);
  XrmPutResource (&db, buf1, "String", &value);
# endif /* !HAVE_COCOA */
}
Beispiel #4
0
/*
 * ------------------------------------------------------------------------
 * Name: PdmShellCreate
 *
 * Description:
 *
 *     This function creates a top level application shell.
 *
 * Return value:
 *
 *     0 if successful; a PDM_EXIT code if not.
 *
 */
static int
PdmShellCreate(PdmShell* me,
	       const String* fallback_resources,
	       int* argc_in_out, String* argv_in_out)
{
    String app_class;
    String app_name;
    XmPixelSet pixelSets[XmCO_NUM_COLORS];
    XrmClass class_list[3];
    XrmDatabase db;
    XrmName name_list[3];
    XrmRepresentation rep_type;
    XrmValue value;
    int decor;
    int funcs;
    short secondary_id;
    /*
     * create the application context and open the video display
     */
    XtToolkitInitialize();
    XtSetLanguageProc((XtAppContext)NULL, (XtLanguageProc)NULL,
		      (XtPointer)NULL);
    me->app_context = XtCreateApplicationContext();

    XtAppSetFallbackResources(me->app_context, (String*)fallback_resources);

    me->display =
	XtOpenDisplay(me->app_context, (String)NULL,
		      (String)NULL, "Dtpdm",
		      PdmOptions, XtNumber(PdmOptions),
		      argc_in_out, argv_in_out);
    if((Display*)NULL == me->display)
	return PDM_EXIT_VXAUTH;
    XtGetApplicationNameAndClass(me->display, &app_name, &app_class);
    /*
     * the fallback resources are only intended for the video display, so
     * remove them from the application context
     */
    XtAppSetFallbackResources(me->app_context, (String*)NULL);
    /*
     * get the parent video window id from the display's resource database
     */
    db = XtDatabase(me->display);
    name_list[0] = XrmStringToQuark(app_name);
    name_list[1] = XrmStringToQuark("parentWindowStr");
    name_list[2] = NULLQUARK;
    class_list[0] = XrmStringToQuark(app_class);
    class_list[1] = XrmStringToQuark("ParentWindowStr");
    class_list[2] = NULLQUARK;
    XrmQGetResource(db, name_list, class_list, &rep_type, &value);
    if(!value.addr) return PDM_EXIT_ERROR;
    me->parent_window = (Window)strtoul((char*)value.addr, (char**)NULL, 0);
    /*
     * obtain the parent video window's attributes
     */
    if(!XGetWindowAttributes(me->display, me->parent_window, &me->parent_attr))
	return PDM_EXIT_ERROR;
    /*
     * register interest in the DestroyNotify event for the parent window
     */
    XSelectInput(me->display, me->parent_window, StructureNotifyMask);
    /*
     * create the application shell
     */
    decor = MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MINIMIZE
	| MWM_DECOR_MAXIMIZE;
    funcs = MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MINIMIZE
	| MWM_FUNC_MAXIMIZE;
    me->widget = 
	XtVaAppCreateShell(app_name, app_class,
			   applicationShellWidgetClass,
			   me->display,
			   XmNdeleteResponse, XmDESTROY,
			   XmNmappedWhenManaged, False,
			   XmNmwmDecorations, decor,
			   XmNmwmFunctions, funcs,
			   XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL,
			   XmNscreen, me->parent_attr.screen,
			   XmNtransient, True,
			   NULL);
    /*
     * pick up the secondary color set, so that the PDM presents the same
     * colors as a secondary window. (the XmColorObj is created by the
     * the XmDisplay object, which is created when the app shell is
     * created)
     */
    if(XmeGetColorObjData(XtScreen(me->widget), (int*)NULL,
			  pixelSets, XmCO_NUM_COLORS,
			  (short*)NULL, (short*)NULL, (short*)NULL,
			  &secondary_id, (short*)NULL))
    {
	/*
	 * In the Xrm database, reassign primary color resource values
	 * with the corresponding secondary color values. This will cause
	 * subsequently created widgets that utilize colors from the
	 * primary set to actually present secondary colors.
	 */
	db = XtScreenDatabase(XtScreen(me->widget));
	value.size = sizeof(Pixel);
	value.addr = (char*)&pixelSets[secondary_id].bg;
	XrmPutResource (&db, "*background", "Pixel", &value);
	XrmPutResource (&db, "*frameBackground", "Pixel", &value);
	value.addr = (char*)&pixelSets[secondary_id].fg;
	XrmPutResource (&db, "*foreground", "Pixel", &value);
	XrmPutResource (&db, "*backPageForeground", "Pixel", &value);
	value.addr = (char*)&pixelSets[secondary_id].bs;
	XrmPutResource (&db, "*bottomShadowColor", "Pixel", &value);
	value.addr = (char*)&pixelSets[secondary_id].ts;
	XrmPutResource (&db, "*topShadowColor", "Pixel", &value);
    }
    /*
     * get the application resources
     */
    XtGetApplicationResources(me->widget, me,
			      PdmResources, XtNumber(PdmResources),
			      NULL, 0);
    /*
     * return
     */
    return 0;
}