Re: sawfish has lost a window - window is found with xdotool



Jeremy Hankins said:     (by the date of Sat, 30 Oct 2010 12:49:03 -0500)

> Don't know.  But I guess it could be falling off the bottom of a stack
> someplace.

e.g. a 128MB-sized stack?
 
> > Could we think of some lisp 'debug script' that scans xwininfo output
> > and compares it with windows known to sawfish - trying to detect those
> > that are no longer mapped? I know there are lots of windows that
> > aren't mapped at all, but if a window was mapped, and suddenly it is
> > not - then maybe it isn't normal.
> 
> I think the hook snooper script would provide some of this info, by
> snooping add-window-hook and destroy-notify-hook, maybe.  But that's
> only if sawfish creates and removes the window in something like the
> normal way.
> 
> Ok, how about this.  It uses debug-utils (from the wiki).

wow, impressive. Now if I only knew how to run that :)
Do I need to restart sawfish to run it?

Let's say that I download http://sawfish.wikia.com/wiki/Debug-utils
script, put the file  debug-utils.jl somewhere, and then I save your
script as debug-utils-window-spy.jl

How do I proceed next? Maybe I can run it from sawfish-client?
How do I unload this script afterwards?

Will this script work, even if there is already some window lost
(before starting this script)? I mean - would it detect that my xterm
was lost last week?

I have so many windows that it is nearly impossible to remember them
all, I noticed that this xterm was lost, because it's one of those
windows that I have open _always_. So if, for instance I lost some
temporary xterm, that I just opened for something, I would never
notice this.

thanks again for your help!

> --------------------------------
> (require 'rep.io.timers)
> (require 'debug-utils)
> (define window-list nil)
> (define window-list-delay 60)
> (define window-list-timer nil)
> 
> (define (window-logger-poll)
>   (let ((windows (managed-windows)))
>     (let loop ((rest window-list))
>          (when rest
>            (cond
>             ((not (member (caar rest) windows))
>              (warn (format nil "Lost(!) window named \"%s\"" (cdar rest)))
>              (setq window-list
>                    (delete-if (lambda (e)
>                                 (equal (cdr e) (cdar rest)))
>                               window-list)))
>             (t
>              (setq windows (delete (caar rest) windows))
>              (rplacd (car rest) (window-name (caar rest)))))
>            (loop (cdr rest))))
>     (let loop ((rest windows))
>          (when rest
>            (let ((name (window-name (car rest))))
>              (warn (format nil "Found new window named \"%s\"" name))
>              (setq window-list (cons (cons (car rest) name) window-list)))
>            (loop (cdr rest)))))
>   (if window-list-timer
>       (set-timer window-list-timer)
>     (setq window-list-timer
>           (make-timer window-logger-poll window-list-delay))))
> 
> (define (window-logger-destroy-window w)
>   (warn (format nil "Destroyed window named \"%s\"" (window-name w)))
>   (setq window-list
>         (delete-if (lambda (e)
>                      (equal (car e) w))
>                    window-list)))
> 
> (define (window-logger-add-window w)
>   (warn (format nil "Created new window named \"%s\"" (window-name w)))
>   (setq window-list (cons (cons w (window-name w)) window-list)))
> 
> (define (window-logger-init)
>   (window-logger-poll)
>   (add-hook 'destroy-notify-hook window-logger-destroy-window)
>   (add-hook 'after-add-window-hook window-logger-add-window))
> 
> (add-hook 'after-initialization-hook window-logger-init)
> --------------------------------
> 
> From my very brief testing it seems to work.  It keeps a list of managed
> windows, and logs the creation or destruction of windows.  It also
> periodically (every window-list-delay seconds) polls the managed windows
> for any unexpected additions or missing windows.  Note that it wont be
> unusual for the name for created windows to be wrong --
> e.g., when the app resets its name while starting up but after the hook
> is called.
> 
> In fact, I can think of other situations where I'd want a log of window
> creation/destruction, so I think I'll go ahead and add this to
> debug-utils.
> 
> Let me know if this works for you.  My windows are most all xterms and
> emacs windows and the like -- quite well-behaved compared to complicated
> guis with lots of dialogs and such.
> 
> -- 
> Jeremy Hankins <nowan nowan org>
> 


-- 
Janek Kozicki                               http://janek.kozicki.pl/  |


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]