Avoid errors on windows with no class

773pages on
this wiki
Add New Page
Add New Page Talk0
Browse all patches

Author Edit

Martin Mares,

Synopsis Edit

When an application sets the WM_CLASS property in a way that it contains only the application name, but no class, Sawfish catches a bad argument signal and leaves the window undecorated. This happens for example with version 7.0 of Mathematica. I have hunted the problem down to two calls of aref on the string array representing WM_CLASS. The fix is simple: always check that the array has at least two elements when asking for the 2nd one.

Patch Edit

Index: lisp/sawfish/wm/ext/match-window.jl
--- lisp/sawfish/wm/ext/match-window.jl (revision 4402)
+++ lisp/sawfish/wm/ext/match-window.jl (working copy)
@@ -312,7 +312,7 @@
   (define-match-window-formatter 'WM_CLASS
    (lambda (vec)
-     (format nil "%s/%s" (aref vec 1) (aref vec 0))))
+     (format nil "%s/%s" (and (> (length vec) 1) (aref vec 1)) (aref vec 0))))
   (define-match-window-formatter 'WM_COMMAND
    (lambda (vec)
Index: lisp/sawfish/wm/windows.jl
--- lisp/sawfish/wm/windows.jl  (revision 4402)
+++ lisp/sawfish/wm/windows.jl  (working copy)
@@ -201,7 +201,7 @@
     "Return the class that window W belongs to, as a string. Returns `nil' if W
 has no associated class."
     (let ((prop (get-x-text-property w 'WM_CLASS)))
-      (and prop (aref prop 1))))
+      (and prop (> (length prop) 1) (aref prop 1))))
   (define (get-window-wm-protocols w)
     "Return a list of symbols defining the X11 window manager protocols

Community's reasons for inclusion or rejection Edit

When voting anonymously please write your name, so that it can be associated with your posts on the mailing list. If you are logged in you can sign yourself by typing four tilda characters: ~~~~.</small>

  • Please vote with: Yes vote: yes., No vote: no., Try vote: let's try in experimental., Wtf vote: pondering. or Suspend wait for next release.

Yes vote: yes. Martin Mares (author's vote). It fixes an annoying bug. While it is not clear that the fix is complete, it definitely helps in all cases known to me.

Yes vote: yes. The bug is really in Mathematica but unfortunately we cannot fix it there and have to settle for this. The diff appears to be broken so I had to apply it by hand. Formatting could be improved by adding newlines to break long lisp expressions. Tkorvola 19:11, 9 March 2009 (UTC)

Also on Fandom

Random Wiki