New window-class proposal, and question on ICCCM & ewmh.



Hi. I'd like window-class to behave as follows:
(window-class w) ;; We have this now.
-> "Emacs"

(window-class w 'full) 
-> ["emacs" "Emacs" ""] ;; Probably cons is better.

(window-class w 'configurator)
-> "Emacs/emacs" ;; sawfish-config "window-rules" style, without ^$

The following code implements this:
(define (window-class w #!optional spec)
    (let ((prop (get-x-text-property w 'WM_CLASS)))
      (case spec
	    ((full)
	     prop)
	    ((configurator)
	     (concat (aref prop 1) "/" (aref prop 0)))
	    (t
	     (and prop (> (length prop) 1) (aref prop 1))))))

What's WM_CLASS? WM_CLASS has two elements, "instance" and "class",
but the current window-class returns the "class" only. This is not
convenient. Though I don't have GIMP now, it has three windows, so I
guess the class is common to all, and the instance varies for
each. Firefox example is "Navigator" for main window, and "Browser"
for config window, and so on. This will be good, including for
jump-or-exec. (But firefox is not a good example, since the latter
seems transient.) Some X applications, like terminals, accept -name
option which overrides instance.  This is useful for matching, because
usually terminals constantly change the title as you change the
directory, so the matching by instance is more reliable.

Now my question: It seems that ICCCM related functions are supposed to
return nil at failure, but at which point can it fail, and should it
be checked?

Same for planned "window pid function":
(define (window-pid win)
  (aref (caddr (get-x-property x '_NET_WM_PID)) 0))

It's defined in ewmh.

Second question: after above enhancement, good matching way for
get-window-by-class(-re) is like what? "spec" again?

I'm going to add new option 'ignore-case' for
get-window-by-name/class-re, too.

Thanks beforehand.
Teika (Teika kazura)



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