Re: FVWM: That thing I said last time: asynchronous

From: Mikhael Goikhman <migo_at_homemail.com>
Date: Tue, 6 Jul 2004 16:57:26 +0000

On 06 Jul 2004 11:09:49 -0500, Rusty Phillips wrote:
>
> Here's an implementation that makes icon captures based on Scott
> Smedley's suggestion and Tavis Ormandy's fvwm2rc file.
>
> It forks off the stuff that takes a long time and renices it to the
> lowest possible priority. The downside is that there's a small chance
> it will result in not getting an icon, and or the wrong icon because
> there is only one variable to store icon captures. I have yet to cause
> the second condition, though the first I can cause on my slow machine if
> I try real hard.
>
> I'll try to figure out how to make it thread-safe later on today.
>
> This uses FvwmPerl, along with this command for it:
> DestroyFunc eval
> AddToFunc eval I SendToModule FvwmPerl eval $*
>
> Enjoy!
>
> DestroyFunc CaptureIcon
> AddToFunc CaptureIcon
> + I raise
> + I eval open(TEMP12,"xwd -silent -id $[w.id] |"); \
> local $/; \
> $e=<TEMP12>; \
> close(TEMP12);

How is this last eval different from just:

  eval $e = `xwd -silent -id $[w.id]`

> DestroyFunc UseCaptured
> AddToFunc UseCaptured
> + I eval my $pid; $SIG{'CHLD'}='IGNORE'; if(!($pid=fork)) { \
> open(TEMP12, "|convert -scale $[fvwm_icon_size] -frame 1x1 \
> -mattecolor black -quality 0 xwd:- \
> png:$[HOME]/.fvwm/icon.tmp.$[w.id].png"); \
> print TEMP12 $e; close(TEMP12); \
> cmd("WindowId $[w.id] WindowStyle IconOverride, \
> Icon $[HOME]/.fvwm/icon.tmp.$[w.id].png, StaysOnBottom"); \
> } else { setpriority 0,$pid,19 }

Don't expect any random fork() to work in FvwmPerl. You probably want:

  DestroyFunc UseCaptured
  AddToFunc UseCaptured
  + I eval detach(); setpriority 0, 0, 19; \
        saveFile("$[FVWM_USERDIR]/capture-$[w.id].xwd", \\$e); \
        system("convert -scale $[fvwm_icon_size] -frame 1x1 -quality 0 \
                -mattecolor black $[FVWM_USERDIR]/capture-$[w.id].xwd \
                png:$[FVWM_USERDIR]/icon-$[w.id].png"); \
        cmd("WindowId $[w.id] WindowStyle IconOverride, StaysOnBottom \
                Icon $[FVWM_USERDIR]/icon-$[w.id].png");

Not tested, but something like this should work better.

Of course, you may cause xwd to save directly into the capture file to
save some megabytes of FvwmPerl's memory.

> DestroyFunc FastThumb
> AddToFunc FastThumb
> + I CaptureIcon
> #Use perl to store the pipe so that it can be used in asynchronous coding.
> + I Iconify
> + I UseCaptured

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Tue Jul 06 2004 - 12:00:06 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:56 BST