Icons in the wininfo when cycling



Hello.

I've gotten around to tackling with my small problem: when I cycle with
Alt-Tab, some of the icons show in the little window in the middle of the
screen are ugly (they are generally 8x8 or 16x16 icons sized-up to 32x32 so
it's blocky).

So I modified display-wininfo.jl so that I can specify which icon I want
displayed according to the window name.

Here is the patch (I set the icon size to 48x48, prettier in my sense):

--- display-wininfo.jl_ori	2009-12-29 11:00:31.000000000 +0100
+++ display-wininfo.jl	2009-12-29 16:14:52.000000000 +0100
@@ -21,8 +21,9 @@
 (define-structure sawfish.wm.util.display-wininfo
 
     (export display-wininfo)
-
+    
     (open rep
+	  rep.regexp
 	  rep.system
 	  rep.data.records
 	  sawfish.wm.colors
@@ -40,7 +41,7 @@
   (defconst x-margin 10)
   (defconst y-margin 10)
 
-  (defconst icon-size (32 . 32))
+  (defconst icon-size (48 . 48))
 
   (defvar display-wininfo-show-workspace nil)
 
@@ -97,6 +98,23 @@
   ;;  * The window icon at left.
   ;;  * At right, the window's title and (maybe) its class.
 
+  (define (find-value-by-regexp-key string-to-match list)
+    (if (equal list ()) ()
+      (if (string-match (car (car list)) string-to-match)
+	  (cdr (car list))
+	(find-value-by-regexp-key string-to-match (cdr list))
+	)
+      )
+    )
+  
+  (define (find-in-window-cycle-icon-list s)
+    (find-value-by-regexp-key s window-cycle-icon-list)
+    )
+  
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
   (define (display-wininfo w)
     "Shows window information about W. Includes at least window name and
 icon (if available). With a null W any displayed information is removed."
@@ -108,7 +126,13 @@
 
     (when w
       (let* ((text (make-text-item (window-info w) default-font))
-	     (icon (let ((i (window-icon-image w)))
+	     (icon-file-name
+	      (if (equal window-cycle-icon-list ()) ()
+		(find-in-window-cycle-icon-list (window-name w))))
+	     (icon (let ((i
+			  (if (equal icon-file-name ())
+			      (window-icon-image w)
+			    (make-image icon-file-name))))
 		     (and i (scale-image i (car icon-size) (cdr icon-size)))))
 	     (icon-dims (if icon icon-size '(0 . 0)))
 	     (win-size (cons (+ (car icon-dims)
@@ -116,13 +140,13 @@
 				(* x-margin (if icon 3 2)))
 			     (+ (* 2 y-margin)
 				(max (cdr icon-dims) (ti-height text))))))
-
+	
 	(define (event-handler type xw)
 	  ;; XW is the handle of the X drawable to draw in
 	  (case type
 	    ((expose)
 	     (x-clear-window xw)
-
+	     
 	     ;; draw the icon
 	     (when icon
 	       (x-draw-image icon xw

In ~/.sawfish/rc, I put this declaration:

(defvar window-cycle-icon-list
  '(
    ("Namoroka 3.6 Beta 5" . "/home/fab/firefox.png")
    ("^(UTF8-)?emacs" . "/home/fab/emacs.png")
    ("^[Mm][Pp]player" . "/home/fab/mplayer.png")
    ("(^Toolbox$|^GNU Image Manipulation Program|^GIMP)" . "/home/fab/gimp.png")
    )
  )

so that any window containing the "Namoroka 3.6 Beta 5" string shows the
firefox.png icon when cycling, any window starting with "UTF8-emacs" or
simply "emacs" shows emacs.png, etc.

The window-cycle-icon-list is a list of cell containing in the head a regexp
and in the tail the filename of the icon to be displayed.

It's an ugly hack (I'm no lisp coder!) but I hope somebody enjoys it :^)

-- 
Fabrice DELENTE


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