Sawfish
Register
Advertisement
Browse all patches

Author[]

Helmut Eller <eller.helmut at gmail.com>

Synopsis[]

This patch adds minimal support for the _NET_WM_USER_TIME hint. If this property is 0, Sawfish shouldn't give focus to the window when it is mapped. GTK uses this hint to implement gtk_window_set_focus_on_map.

The patch looks at the _NET_WM_USER_TIME and if it is zero, puts a the new property inhibit-focus-when-mapped on the window. It seemed to me, that inhibit-focus-when-mapped makes the intention clearer than comparing the timestamp with 0.

The map-notify-hook in transient.jl ignores windows if the property is set.


Patch testing[]

To test the patch you could create a simple GTK application and which calls gtk_window_set_focus_on_map on a top-level window. Like this one:

#include <gtk/gtk.h>

int main (int argc, char *argv[]) {
  int flag;
  if (argc!=2) goto usage;
  if (strcmp ("true", argv[1]) == 0) flag = TRUE;
  else if (strcmp ("false", argv[1]) == 0) flag = FALSE;
  else goto usage;
  gtk_init (&argc, &argv);
  {
    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    GtkWidget *label = gtk_label_new (argv[1]);
    gtk_container_add (GTK_CONTAINER (window), label);
    gtk_window_set_focus_on_map (GTK_WINDOW (window), flag);
    gtk_widget_show_all (window);
    gtk_main ();
  }
  return 0;
  usage:
  printf ("Usage: %s true|false\n", argv[0]);
  return 1;
}

/*
** Local Variables:
** compile-command: "gcc `pkg-config --cflags --libs gtk+-2.0` focus-when-mapped.c"
** End:
*/

Without the patch, the new window always receives the focus, regardless of gtk_window_set_focus_on_map's argument. With the patch gtk_window_set_focus_on_map should work as expected.

Below follow generic instructions for applying a patch. Note that the patch contains a ^L in the line before ";;; helper functions". You probably have to fix that when copy&pasting.

  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[]

Index: lisp/sawfish/wm/state/wm-spec.jl
===================================================================
--- lisp/sawfish/wm/state/wm-spec.jl	(revision 4273)
+++ lisp/sawfish/wm/state/wm-spec.jl	(working copy)
@@ -123,8 +123,9 @@
      _NET_WM_WINDOW_TYPE_TOOLBAR
      _NET_WM_WINDOW_TYPE_MENU
      _NET_WM_WINDOW_TYPE_UTILITY
-     _NET_WM_WINDOW_TYPE_SPLASH])
-  
+     _NET_WM_WINDOW_TYPE_SPLASH
+     _NET_WM_USER_TIME])
+ 
   (defvar wm-spec-below-depth -2)
   (defvar wm-spec-above-depth +2)
 
@@ -322,8 +323,12 @@
 
     (let ((geom (get-x-property w '_NET_WM_ICON_GEOMETRY)))
       (when geom
-	(update-icon-geometry w (nth 2 geom)))))
+	(update-icon-geometry w (nth 2 geom))))
 
+    (when (equal (get-x-property w '_NET_WM_USER_TIME)
+		 '(CARDINAL 32 #(0)))
+      (window-put w 'inhibit-focus-when-mapped t)))
+
 �
 ;;; helper functions
 
Index: lisp/sawfish/wm/state/transient.jl
===================================================================
--- lisp/sawfish/wm/state/transient.jl	(revision 4273)
+++ lisp/sawfish/wm/state/transient.jl	(working copy)
@@ -166,7 +166,8 @@
 		(transient-of-p w (input-focus) #:allow-root t))
 	   (set-input-focus w))
 	  ((and (or (and focus-windows-when-mapped
-			 (not (window-get w 'never-focus)))
+			 (not (window-get w 'never-focus))
+			 (not (window-get w 'inhibit-focus-when-mapped)))
 		    (window-get w 'focus-when-mapped))
 		(or (not (window-transient-p w))
 		    (eql (window-transient-p w) (root-window-id)))

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

  • 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.
  • Wtf vote: pondering. Patch testing instructions are not clear for anyone who wants to test the patch. They should be as simple as bash copy/paste or such. Please improve ;) I mean, how should I "create a simple GTK application"? Isn't there any application out there which would allow testing this patch? Do you have a code for such test application? Janek Kozicki 13:09, 30 August 2008 (UTC)
  • Wtf vote: pondering. I'm unable to make any decision here. Dear sawfish users, please test this patch and put your votes :) Janek Kozicki 17:04, 17 September 2008 (UTC)
  • Try vote: let's try in experimental. I've tried it and after setting focus-windows-when-mapped to true it worked. Without the patch the windows also get focussed, even if the gtk-flag is set to FALSE, so this patch solves that issue Flashrider [Christopher Bratusek] 01:53, 29 September 2008 (UTC)
Advertisement