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

Janek Kozicki <janek_listy wp pl> writes:
> Jeremy Hankins said:     (by the date of Mon, 25 Oct 2010 16:18:43 -0500)

>> The only other avenue I can think of
>> would be to try to figure out what conditions trigger the problem.
>> Having lots and lots of windows is evidently one part, at least, but
>> evidently not enough in itself if you ran fine for a while without the
>> problem showing up.  Is this the first window that starts when you start
>> sawfish?
> One of the first few. They seem to appear in random order. So this
> could be a 1st one as well as a 5th one. I recall long time ago there
> was a problem with disappearing firefox windows and it was fixed.
> Maybe this one is related.

Don't know.  But I guess it could be falling off the bottom of a 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).

(require '
(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
            ((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)))
             (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))

(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)
  (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

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>

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