Fandom

Sawfish

Window prop list & prop del

773pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Browse all patches

Author Edit

Teika kazura and Timo Korvola

Synopsis Edit

This patch defines two functions, `window-plist' and `window-prop-del'.

  • `window-plist' returns the property list of a window.
  • `window-prop-del' deletes a property of a window.

Both lack in the current sawfish.

The idea is suggested by Timo Korvola in the page of Focus policy improvement. The author thanks him.

Patch testing Edit

  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 Edit

diff -ur sawfish-1.3.3.orig/man/sawmill.texi sawfish-1.3.3/man/sawmill.texi
--- sawfish-1.3.3.orig/man/sawmill.texi	2007-07-29 23:33:15.000000000 +0900
+++ sawfish-1.3.3/man/sawmill.texi	2008-07-15 17:13:47.000000000 +0900
@@ -837,6 +837,22 @@
 @code{map-window-properties} returns @code{nil} immediately.
 @end defun
 
+@defun window-plist window
+Returns the property list of the window @var{window} which is of the form
+@code{(prop value prop value ...)}. 
+
+The returned list is ``copied once'', i.e., its structure is copied,
+but elements other than symbol, lists for example, are the original ones.
+Do NOT modify them to change the property value. Use @code{window-put}
+instead.
+@end defun
+
+@defun window-prop-del window property
+Delete @var{property} of @var{window}. Returs @code{t} for success,
+otherwise @code{nil}.
+
+Do NOT delete keymap with this function. Use @code{window-put} instead.
+@end defun
 
 @node Window Types, Window Attributes, Window Property Lists, Windows
 @section Window Types
diff -ur sawfish-1.3.3.orig/src/sawmill_subrs.h sawfish-1.3.3/src/sawmill_subrs.h
--- sawfish-1.3.3.orig/src/sawmill_subrs.h	2008-01-19 20:58:51.000000000 +0900
+++ sawfish-1.3.3/src/sawmill_subrs.h	2008-07-10 17:36:10.000000000 +0900
@@ -322,6 +322,8 @@
 extern void register_property_monitor (repv prop, void (*callback)
 				       (Lisp_Window *, repv, repv, repv));
 extern repv Fwindow_put (repv win, repv prop, repv value);
+extern repv Fwindow_prop_del (repv win, repv prop);
+extern repv Fwindow_plist (repv win);
 extern repv Fwindow_name (repv win);
 extern repv Fwindow_full_name (repv win);
 extern repv Fwindow_icon_name (repv win);
diff -ur sawfish-1.3.3.orig/src/windows.c sawfish-1.3.3/src/windows.c
--- sawfish-1.3.3.orig/src/windows.c	2008-02-19 04:27:34.000000000 +0900
+++ sawfish-1.3.3/src/windows.c	2008-07-15 17:03:04.000000000 +0900
@@ -80,6 +80,7 @@
 
 static repv gravity_map[StaticGravity+1];
 
+// In sawfish-1.3.3, the only callback used is keymap_prop_change. 
 struct prop_handler {
     struct prop_handler *next;
     repv prop;
@@ -738,6 +739,51 @@
     return val;
 }
 
+DEFUN("window-prop-del", Fwindow_prop_del, Swindow_prop_del,
+      (repv win, repv prop), rep_Subr2) /*
+::doc:sawfish.wm.windows.subrs#window-prop-del::
+window-put WINDOW PROPERTY
+
+Delete PROPERTY of WINDOW. Returs t for success, otherwise nil.
+
+Do NOT delete keymap with this function. Use `window-put' instead.
+::end:: */
+{
+    repv plist;
+    rep_DECLARE1(win, XWINDOWP);
+    plist = VWIN(win)->plist;
+    while (rep_CONSP(plist) && rep_CONSP(rep_CDR(plist)))
+    {
+	if (rep_CAR(plist) == prop
+	    || (!rep_SYMBOLP(prop)
+		&& rep_value_cmp (rep_CAR(plist), prop) == 0))
+	{
+            rep_CAR(plist) = rep_CADDR(plist);
+	    rep_CDR(plist) = rep_CDDDR(plist);
+	    return Qt;
+	}
+	plist = rep_CDDR(plist);
+    }
+    return Qnil;
+}
+
+DEFUN("window-plist", Fwindow_plist, Swindow_plist,
+      (repv win), rep_Subr1) /*
+::doc:sawfish.wm.windows.subrs#window-plist::
+window-plist WINDOW
+
+Returns the property list of the window window which is of the form
+(prop value prop value ...).
+
+The returned list is ``copied once'', i.e., its structure is copied,
+but elements other than atom, lists for example, are the original ones.
+Do NOT modify them to change the property value. Use window-put instead.
+::end:: */
+{
+    rep_DECLARE1(win, XWINDOWP);
+    return Fcopy_sequence (VWIN(win)->plist);
+}
+
 DEFUN("window-name", Fwindow_name, Swindow_name, (repv win), rep_Subr1) /*
 ::doc:sawfish.wm.windows.subrs#window-name::
 window-name WINDOW
@@ -1591,6 +1637,8 @@
     rep_ADD_SUBR(Swindow_get);
     rep_ADD_SUBR(Smap_window_properties);
     rep_ADD_SUBR(Swindow_put);
+    rep_ADD_SUBR(Swindow_prop_del);
+    rep_ADD_SUBR(Swindow_plist);
     rep_ADD_SUBR(Swindow_name);
     rep_ADD_SUBR(Swindow_full_name);
     rep_ADD_SUBR(Swindow_icon_name);

And a second patch by Timo Korvola against 1.3.4rc1. The second patch changes the name of window-prop-del to window-remprop and fixes some other stuff. It consists of commits r4251, r4260 and r4261 in svn.

diff --git a/ChangeLog b/ChangeLog
index 93560e2..b0d6dff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-08-04  Timo Korvola  <tkorvola@svn.gnome.org>
+       * src/windows.c, src/sawmill_subrs.h, man/sawmill.texi: Rename
+       window-prop-del to window-remprop.
+
 2008-08-04  Janek Kozicki <cosurgi@gmail.com>
        * mark all subdir */Changelog as deprecated
 
diff --git a/man/sawmill.texi b/man/sawmill.texi
index 761a3ba..43d2f0c 100644
--- a/man/sawmill.texi
+++ b/man/sawmill.texi
@@ -845,17 +845,13 @@ Lisp properties bound to @var{window}.  Returns the value 
of the last
 Returns the property list of the window @var{window} which is of the form
 @code{(prop value prop value ...)}. 
 
-The returned list is ``copied once'', i.e., its structure is copied,
-but elements other than symbol, lists for example, are the original ones.
-Do NOT modify them to change the property value. Use @code{window-put}
-instead.
+Do not attempt to change properties by modifying the property list in place.
+Use window-put instead.
 @end defun
 
-@defun window-prop-del window property
-Delete @var{property} of @var{window}. Returs @code{t} for success,
-otherwise @code{nil}.
-
-Do NOT delete keymap with this function. Use @code{window-put} instead.
+@defun window-remprop window property
+Remove @var{property} of @var{window}. Returns @code{t} for success,
+@code{nil} if the property did not exist.
 @end defun
 
 @node Window Types, Window Attributes, Window Property Lists, Windows
diff --git a/src/sawmill_subrs.h b/src/sawmill_subrs.h
index e6204e3..f4444ff 100644
--- a/src/sawmill_subrs.h
+++ b/src/sawmill_subrs.h
@@ -322,7 +322,7 @@ extern repv Fwindow_get (repv win, repv prop, repv checker);
 extern void register_property_monitor (repv prop, void (*callback)
                                       (Lisp_Window *, repv, repv, repv));
 extern repv Fwindow_put (repv win, repv prop, repv value);
-extern repv Fwindow_prop_del (repv win, repv prop);
+extern repv Fwindow_remprop (repv win, repv prop);
 extern repv Fwindow_plist (repv win);
 extern repv Fwindow_name (repv win);
 extern repv Fwindow_full_name (repv win);
diff --git a/src/windows.c b/src/windows.c
index b0610c9..1258f83 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -733,10 +733,10 @@ Note that these are Lisp properties not X properties.
                if (ph->prop == prop && old != val)
                    ph->callback (VWIN (win), prop, old, val);
            }
-           rep_CAR(rep_CDR(plist)) = val;
+           rep_CADR(plist) = val;
            return val;
        }
-       plist = rep_CDR(rep_CDR(plist));
+       plist = rep_CDDR(plist);
     }
     plist = Fcons(prop, Fcons(val, VWIN(win)->plist));
     if (plist != rep_NULL)
@@ -744,30 +744,34 @@ Note that these are Lisp properties not X properties.
     return val;
 }
 
-DEFUN("window-prop-del", Fwindow_prop_del, Swindow_prop_del,
+DEFUN("window-remprop", Fwindow_remprop, Swindow_remprop,
       (repv win, repv prop), rep_Subr2) /*
 ::doc:sawfish.wm.windows.subrs#window-prop-del::
 window-put WINDOW PROPERTY
 
-Delete PROPERTY of WINDOW. Returs t for success, otherwise nil.
-
-Do NOT delete keymap with this function. Use `window-put' instead.
+Delete PROPERTY of WINDOW. Return t for success, nil if WINDOW
+did not have PROPERTY.
 ::end:: */
 {
-    repv plist;
+    repv *pplist;
     rep_DECLARE1(win, XWINDOWP);
-    plist = VWIN(win)->plist;
-    while (rep_CONSP(plist) && rep_CONSP(rep_CDR(plist)))
+    pplist = &VWIN(win)->plist;
+    while (rep_CONSP(*pplist) && rep_CONSP(rep_CDR(*pplist)))
     {
-       if (rep_CAR(plist) == prop
+       if (rep_CAR(*pplist) == prop
            || (!rep_SYMBOLP(prop)
-               && rep_value_cmp (rep_CAR(plist), prop) == 0))
+               && rep_value_cmp (rep_CAR(*pplist), prop) == 0))
        {
-            rep_CAR(plist) = rep_CADDR(plist);
-           rep_CDR(plist) = rep_CDDDR(plist);
+           struct prop_handler *ph;
+            repv old = rep_CADR(*pplist);
+            if (old != Qnil)
+                for (ph = prop_handlers; ph != 0; ph = ph->next)
+                    if (ph->prop == prop)
+                        ph->callback(VWIN (win), prop, old, Qnil);
+            *pplist = rep_CDDR(*pplist);
            return Qt;
        }
-       plist = rep_CDDR(plist);
+       pplist = &rep_CDDR(*pplist);
     }
     return Qnil;
 }
@@ -780,13 +784,12 @@ window-plist WINDOW
 Returns the property list of the window window which is of the form
 (prop value prop value ...).
 
-The returned list is ``copied once'', i.e., its structure is copied,
-but elements other than atom, lists for example, are the original ones.
-Do NOT modify them to change the property value. Use window-put instead.
+Do not attempt to change properties by modifying the property list in place.
+Use window-put instead.
 ::end:: */
 {
     rep_DECLARE1(win, XWINDOWP);
-    return Fcopy_sequence (VWIN(win)->plist);
+    return VWIN(win)->plist;
 }
 
 DEFUN("window-name", Fwindow_name, Swindow_name, (repv win), rep_Subr1) /*
@@ -1642,7 +1645,7 @@ windows_init (void)
     rep_ADD_SUBR(Swindow_get);
     rep_ADD_SUBR(Smap_window_properties);
     rep_ADD_SUBR(Swindow_put);
-    rep_ADD_SUBR(Swindow_prop_del);
+    rep_ADD_SUBR(Swindow_remprop);
     rep_ADD_SUBR(Swindow_plist);
     rep_ADD_SUBR(Swindow_name);
     rep_ADD_SUBR(Swindow_full_name);

The manual entry is included.

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

  • Use one of :Yes vote: yes., No vote: no. or Wtf vote: pondering..
  • Yes vote: yes.: The author's vote. This gives more power in window handling, so no reason to reject. - Teika kazura 08:11, 17 July 2008 (UTC)
  • Yes vote: yes. I think this is in fact a good thing to have. -Ferk(talk!) 02:45, 21 July 2008 (UTC)
  • Yes vote: yes. Patch applied, to be sure - this is what Timo pointed out as missing patches: window-remprop and window-plist. Which means that we still need window-setplist, right? Janek Kozicki 13:21, 4 August 2008 (UTC)
  • Yes vote: yes. I think this should be OK with my changes (second patch above or see svn).
    • Renamed window-prop-del to window-remprop for consistency with other Lisp dialects.
    • window-remprop calls property handlers as if the property were set to nil. It should work with keymaps now.
    • Fixed possible memory corruption in window-remprop if the last property in the plist is deleted.
    • window-plist now returns the plist itself, not a shallow copy. It is generally the responsibility of the user of rplaca and rplacd to ensure that the effects of destructive modification are contained.
Tkorvola 21:21, 5 August 2008 (UTC)

Also on Fandom

Random Wiki