Sawfish
Browse all patches

Author[]

Andrew Sayers <ug55aes@cs.bham.ac.uk>

(Submitted by RodrigoGallardo from debian bug 144434.)

Synopsis[]

As an alteration to Sawfish's "shade-hover" mode, I've written a bit of code that shades and unshades a window when it gains and loses the focus. Hitting the "shade" button on a temporarily-unshaded window will set it to be permanently unshaded. It does this by exploiting the fact that a window's "shade" property has a slightly odd relationship with the actual shaded state of a window (which, if not deliberate, I'd like filed as a non-bug :).

I suspect Sawfish's "shade-hover" mode is used mostly by people who prefer the focus to be updated on window-enter and window-exit (I prefer window-enter only). If so, shade-focus can be seen as a generalisation of shade-hover, because they behave exactly the same with enter-exit focus switching.

The code isn't that aesthetically pleasing - I've been using the WM for less than a week, so I'm not fully up on the guts of the system yet :) It works, though. An interesting extension would be allow windows to individually choose between "shade-hover", "shade-focus" and "no auto-shading", but that kind of thing is way beyond my current abilities :)

Patch testing[]

  1. Copy/paste the patch listed below into some file, eg. TEST.diff.
  2. If you don't have sawfish sources yet, have one, as described get it from GIT repo.
  3. Go into the directory where sawfish sources reside, eg. cd sawfish
  4. Test if the patch applies cleanly with this command:
    patch -p1 --ignore-whitespace --dry-run < TEST.diff
    in case of problems try also: -p0 or -p2
  5. If it applies cleanly, then remove the --dry-run from above command and run it again, otherwise ask on the mailing list.
  6. Compile sawfish: ./autogen.sh && make
  7. Install it for testing, but it depends on your linux distribution.
    1. It is always better to install sawfish as your distribution package, but it is different for each distribution.
    2. So you may try make install, which will install sawifish in /usr/local/share/sawfish/ (if you have write access). But then make sure that you run the correct version and delete it from that directory afterwards, to avoid any conflicts.
  8. Se also

PS: edit this template if you feel that those instructions can be improved.

Patch[]

(defun sync-shading (W) 
	"Synchronise window->shaded and actual window shading"
	(window-put W 'shaded (not (window-get W 'shaded)))
	(toggle-window-shaded W)
)

(defun non-updating-unshade-window (W)
	"Unshades a window without changing window->shaded"
	(let ((shading (window-get W 'shaded)))
		(unshade-window W)
		(window-put W 'shaded shading)
))

(setq focus-in-hook (cons non-updating-unshade-window focus-in-hook ))
(setq focus-out-hook (cons sync-shading focus-out-hook ))

Community's reasons for inclusion or rejection[]

Patch submitters, please vote also! Yes, obviosuly your vote will be positive, but it's the place to give your explanation why this patch is good for all Sawfish users, and why it is correct - good reasons for inclusion.

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: ~~~~.

  • Yes vote: yes., No vote: no. or Wtf vote: pondering.
  • Wtf vote: pondering. Shouldn't this go into the Scripts Section? [Obviously not a patch] Flashrider [Christopher Bratusek] 21:18, 11 May 2008 (UTC)
  • Wtf vote: pondering. The idea looks interesting, but it has to be refined.
    1. I couldn't find out the patch's effect, but I've understood from the synopsis that what is concerned is the timing. (In general, it isn't recommendable to rely on tricky behavior. Probably the original code is messy, so it is bug prone, and once a bug is there it will be hard to get rid of.) If that is the case, I suspect that you don't need new functions at all. Because shade-hover is triggered through:
      (add-hook 'enter-notify-hook shade-hover-enter)
      (add-hook 'leave-notify-hook shade-hover-leave)
      (add-hook 'focus-out-hook shade-hover-leave)

      (which is found at the bottom of sawfish-1.3.3/lisp/sawfish/wm/ext/shade-hover.jl), so you can tune it by `remove-hook' and `add-hook' in your favorite way.
    2. If it is to be accepted as a patch, it has to be presented as a configurable option with generality to some extent. Maybe something like:
      (define-special-variable shade-hover-define-trigger '(progn (add-hook...)))
      can be a candidate. - Teika kazura 05:33, 19 July 2008 (UTC)
  • Suspend wait for next release. It's impossible to apply this patch, because It's not a diff, you know. You can consider either fixing this problem ─ by making this patch a diff, or rather submitting it into the Scripts section, which I guess is what you really meant. I'm marking it as Category:Suspended patches, I hope that you will either refine your patch (make it possible to apply it, and change its category back to Category:Submitted patches) or put it into Scripts. Janek Kozicki 10:33, 4 August 2008 (UTC)
  • Wtf vote: pondering. that could be a yes. Teika suggestion about using different set of hooks seems to be working. It is a simple test, in sawfish-client just type
    ,in sawfish.wm.ext.shade-hover
    (add-hook 'focus-in-hook shade-hover-enter)
    (remove-hook 'enter-notify-hook shade-hover-enter)
    (remove-hook 'leave-notify-hook shade-hover-leave)
    So probably it can reformulated to be an option (let's say obey-focus-only) for shade-hover that removes and adds hooks as needed. This mode even makes opening menus fully work (current shade-hover only works for the first). GSR 17:48, 11 May 2009 (UTC)