🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #13642

Re: SunView - Processing whilst Iconized

#13642
From: Mark Weiser
Date: Mon, 05 Feb 1990 07:08
65 lines
2411 bytes
Timothy Stone complains:
"No matter how I do it, the window closes but the icon doesn't show until
after the long-running function completes even with
notify_next_event_func() and window_release_event_lock(frame)."

This is a common trouble.  You have to give the notifier time to run after
you tell it things.  I have a function I use all the time to schedule
something to do later.  For instance, if I want something to happen or
something to start running immediately when a window first appears, I
schedule the thing to start (using "do_with_delay", defined below) before
calling window_main_loop.

Anyway, here is the code I use.  In Timothy's case, I think he wants to
say 
	do_with_delay(very_long_running_func, 1, 0, 0);

when he get notified of iconization, rather than calling the
very_long_running_func directly.

-mark
(I use X now, but still have a head filled with Sunview knowledge).
--------------here is the code---------------------------
/*
 * Call procedure f in a little while.
 */

struct call_wrapper {
  /* Dynamically allocating a wrapper ensures unique notifier id's. */
  void (*f)();
  long arg;
};

int
  do_with_delay(f, secs, usecs, arg)
void (*f)();
int secs, usecs;
{
  Notify_value do_the_call();
  struct call_wrapper *w;
  struct itimerval timer;

  /* Sigh, so much work just to wait a bit before starting up. */
  timer.it_interval.tv_usec = 0;
  timer.it_interval.tv_sec = 0;
  timer.it_value.tv_usec = usecs;
  timer.it_value.tv_sec = secs;
  w = (struct call_wrapper *)insider_calloc(sizeof(struct call_wrapper), 1);
  w->f = f;
  w->arg = arg;
  notify_set_itimer_func(w, do_the_call,
			 ITIMER_REAL, &timer, NULL);
}

/*
 * Wrapper to make sure procedures from do_with_delay return good values
 * to the notifier.
 */
Notify_value
  do_the_call(w, which)
struct call_wrapper *w;
{
  (*(w->f))(w->arg);
  free(w);
  return NOTIFY_DONE;
}
Technical Details
Message-ID: <4740@brazos.Rice.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!iuvax!mailrus!cs.utexas.edu!rice!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!iuvax!mailrus!cs.utexas.edu!rice!sun-spots-request
From: mark@arisia.xerox.com (Mark Weiser)
Newsgroups: comp.sys.sun
Subject: Re: SunView - Processing whilst Iconized
Keywords: Windows
Message-ID: <4740@brazos.Rice.edu>
Date: 5 Feb 90 07:08:41 GMT
Sender: root@rice.edu
Organization: Sun-Spots
Lines: 65
Approved: Sun-Spots@rice.edu
X-Refs:  Original: v9n17
X-Sun-Spots-Digest: Volume 9, Issue 28, message 2 of 11