Beispiel #1
0
static void
free_widget_value_tree (widget_value *wv)
{
  if (!wv)
    return;

  xfree (wv->name);
  xfree (wv->value);
  xfree (wv->key);

  wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;

  if (wv->toolkit_data && wv->free_toolkit_data)
    {
      XtFree (wv->toolkit_data);
      wv->toolkit_data = (void *) 0xDEADBEEF;
    }

  if (wv->contents && (wv->contents != (widget_value*)1))
    {
      free_widget_value_tree (wv->contents);
      wv->contents = (widget_value *) 0xDEADBEEF;
    }
  if (wv->next)
    {
      free_widget_value_tree (wv->next);
      wv->next = (widget_value *) 0xDEADBEEF;
    }
  xfree (wv);
}
Beispiel #2
0
static void free_widget_value_contents(widget_value * wv)
{
	if (wv->name)
		xfree(wv->name);
	if (wv->value)
		xfree(wv->value);
	if (wv->key)
		xfree(wv->key);

	/* #### - all of this 0xDEADBEEF stuff should be unnecessary
	   in production code...  it should be conditionalized. */
	wv->name = wv->value = wv->key = (char *)0xDEADBEEF;

	if (wv->toolkit_data && wv->free_toolkit_data) {
		XtFree((char *)wv->toolkit_data);
		wv->toolkit_data = (void *)0xDEADBEEF;
	}
#ifdef NEED_SCROLLBARS
	if (wv->scrollbar_data) {
		xfree(wv->scrollbar_data);
		wv->scrollbar_data = NULL;
	}
#endif
	if (wv->contents && (wv->contents != (widget_value *) 1)) {
		free_widget_value_tree(wv->contents);
		wv->contents = (widget_value *) 0xDEADBEEF;
	}

	free_widget_value_args(wv);

	if (wv->next) {
		free_widget_value_tree(wv->next);
		wv->next = (widget_value *) 0xDEADBEEF;
	}
}
Beispiel #3
0
Lisp_Object widget_value_unwind(Lisp_Object closure)
{
	widget_value *wv = (widget_value *) get_opaque_ptr(closure);
	free_opaque_ptr(closure);
	if (wv)
		free_widget_value_tree(wv);
	return Qnil;
}
Beispiel #4
0
static void
free_widget_info (widget_info *info)
{
  xfree (info->type);
  xfree (info->name);
  free_widget_value_tree (info->val);
  memset ((void*)info, 0xDEADBEEF, sizeof (widget_info));
  xfree (info);
}
Beispiel #5
0
/* A device method. */
static void
x_update_scrollbar_instance_status (struct window *w, int active, int size,
				    struct scrollbar_instance *instance)
{
  struct frame *f = XFRAME (w->frame);
  Boolean managed = XtIsManaged (SCROLLBAR_X_WIDGET (instance));

  if (active && size)
    {
      widget_value *wv = scrollbar_instance_to_widget_value (instance);

      if (instance->scrollbar_instance_changed)
	{
	  lw_modify_all_widgets (SCROLLBAR_X_ID (instance), wv, 0);
	  instance->scrollbar_instance_changed = 0;
	}

      if (!managed)
	{
	  XtManageChild (SCROLLBAR_X_WIDGET (instance));
	  if (XtWindow (SCROLLBAR_X_WIDGET (instance)))
	    {
	      /* Raise this window so that it's visible on top of the
                 text window below it. */
	      XRaiseWindow (XtDisplay (SCROLLBAR_X_WIDGET (instance)),
			    XtWindow (SCROLLBAR_X_WIDGET (instance)));
	      update_one_widget_scrollbar_pointer
		(w, SCROLLBAR_X_WIDGET (instance));
	      if (!SCROLLBAR_X_BACKING_STORE_INITIALIZED (instance))
		{
		  update_one_scrollbar_bs (f, SCROLLBAR_X_WIDGET (instance));
		  SCROLLBAR_X_BACKING_STORE_INITIALIZED (instance) = 1;
		}
	    }
	}

      if (!wv->scrollbar_data) ABORT ();
      free_widget_value_tree (wv);
    }
  else if (managed)
    {
#if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID)
      /* This isn't needed with Athena Scrollbars.  It might not be needed */
      /* with Motif scrollbars (it is apparently needed with Lesstif). */
      XtUngrabKeyboard (SCROLLBAR_X_WIDGET (instance), CurrentTime);
#endif
      XtUnmanageChild (SCROLLBAR_X_WIDGET (instance));
    }
}
Beispiel #6
0
static widget_value *gui_items_to_widget_values_1(Lisp_Object
						  gui_object_instance,
						  Lisp_Object items,
						  widget_value * parent,
						  widget_value * prev,
						  int accel_p)
{
	widget_value *wv = 0;

	assert((parent || prev) && !(parent && prev));
	/* now walk the tree creating widget_values as appropriate */
	if (!CONSP(items)) {
		wv = xmalloc_widget_value();
		if (parent)
			parent->contents = wv;
		else
			prev->next = wv;
		if (!button_item_to_widget_value(gui_object_instance,
						 items, wv, 0, 1, 0, accel_p)) {
			free_widget_value_tree(wv);
			if (parent)
				parent->contents = 0;
			else
				prev->next = 0;
		} else
			wv->value = xstrdup(wv->name);	/* what a mess... */
	} else {
		/* first one is the parent */
		if (CONSP(XCAR(items)))
			syntax_error("parent item must not be a list",
				     XCAR(items));

		if (parent)
			wv = gui_items_to_widget_values_1(gui_object_instance,
							  XCAR(items), parent,
							  0, accel_p);
		else
			wv = gui_items_to_widget_values_1(gui_object_instance,
							  XCAR(items), 0, prev,
							  accel_p);
		/* the rest are the children */
		gui_item_children_to_widget_values(gui_object_instance,
						   XCDR(items), wv, accel_p);
	}
	return wv;
}
Beispiel #7
0
static widget_value *
merge_widget_value (widget_value *val1,
                    widget_value *val2,
                    int level,
                    int *change_p)
{
  change_type change, this_one_change;
  widget_value* merged_next;
  widget_value* merged_contents;

  if (!val1)
    {
      if (val2)
	{
	  *change_p = 1;
	  return copy_widget_value_tree (val2, STRUCTURAL_CHANGE);
	}
      else
	return NULL;
    }
  if (!val2)
    {
      *change_p = 1;
      free_widget_value_tree (val1);
      return NULL;
    }

  change = NO_CHANGE;

  if (safe_strcmp (val1->name, val2->name))
    {
      EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change",
	       val1->name, val2->name);
      change = max (change, STRUCTURAL_CHANGE);
      dupstring (&val1->name, val2->name);
    }
  if (safe_strcmp (val1->value, val2->value))
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change",
	       val1->value, val2->value);
      change = max (change, VISIBLE_CHANGE);
      dupstring (&val1->value, val2->value);
    }
  if (safe_strcmp (val1->key, val2->key))
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change",
	       val1->key, val2->key);
      change = max (change, VISIBLE_CHANGE);
      dupstring (&val1->key, val2->key);
    }
  if (! EQ (val1->help, val2->help))
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "help change",
	       val1->help, val2->help);
      change = max (change, VISIBLE_CHANGE);
      val1->help = val2->help;
    }
  if (val1->enabled != val2->enabled)
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "enablement change",
	       val1->enabled, val2->enabled);
      change = max (change, VISIBLE_CHANGE);
      val1->enabled = val2->enabled;
    }
  if (val1->button_type != val2->button_type)
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "button type change",
	       val1->button_type, val2->button_type);
      change = max (change, VISIBLE_CHANGE);
      val1->button_type = val2->button_type;
    }
  if (val1->selected != val2->selected)
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "selection change",
	       val1->selected, val2->selected);
      change = max (change, VISIBLE_CHANGE);
      val1->selected = val2->selected;
    }
  if (val1->call_data != val2->call_data)
    {
      EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "call-data change",
	       val1->call_data, val2->call_data);
      change = max (change, INVISIBLE_CHANGE);
      val1->call_data = val2->call_data;
    }

  if (level > 0)
    {
      merged_contents =
	merge_widget_value (val1->contents, val2->contents, level - 1,
			    change_p);

      if (val1->contents && !merged_contents)
	{
	  /* This used to say INVISIBLE_CHANGE,
	     but it is visible and vitally important when
	     the contents of the menu bar itself are entirely deleted.

	     But maybe it doesn't matter.  This fails to fix the bug.  */
	  EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(contents gone)",
		   0, 0);
	  change = max (change, STRUCTURAL_CHANGE);
	}
      else if (merged_contents && merged_contents->change != NO_CHANGE)
	{
	  EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents change)",
		   0, 0);
	  change = max (change, INVISIBLE_CHANGE);
#if 0 /* This was replaced by the August 9 1996 change in lwlib-Xm.c.  */
#ifdef USE_MOTIF
	  change = max (merged_contents->change, change);
#endif
#endif
	}

      val1->contents = merged_contents;
    }

  this_one_change = change;

  merged_next = merge_widget_value (val1->next, val2->next, level, change_p);

  if (val1->next && !merged_next)
    {
      EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(following gone)",
	       0, 0);
      change = max (change, STRUCTURAL_CHANGE);
    }
  else if (merged_next)
    {
      if (merged_next->change)
	EXPLAIN (val1->name, change, merged_next->change, "(following change)",
		 0, 0);
      change = max (change, merged_next->change);
    }

  val1->next = merged_next;

  val1->this_one_change = this_one_change;
  val1->change = change;

  if (change > NO_CHANGE && val1->toolkit_data)
    {
      *change_p = 1;
      if (val1->free_toolkit_data)
	XtFree (val1->toolkit_data);
      val1->toolkit_data = NULL;
    }

  return val1;
}