A small twm patch

Eeri Kask Eeri.Kask at inf.tu-dresden.de
Mon Aug 18 01:08:44 PDT 2008


Alex Goncharov:
  > Based on my long experience with `twm', I would like to suggest
  > the following small patch to its code.
  >
  > I am not sure I am sending it to the correct place and therefore
  > not giving much explanation here, but if this *is* the place and
  > the patch will be considered, I can, of course, do more explaining.


Hello Alex,

being slightly in hurry, nevertheless may I attach some humble comments.


  > diff -ru twm-1.0.3/src.orig/util.c twm-1.0.3/src/util.c
  > [...]
  >      status = XmbTextPropertyToTextList(dpy, &text_prop, &list, &num);
  > -    if (status < Success || !num || !*list) {
  > +    if (status < Success || !num || !list || !*list) {
  >        *winname = NULL;
  >        return 0;
  >      }


Aa a side note, do you have any evidence that injecting '!list' above 
does anything the '!num'-test already doesn't?  I am in no way ruling 
out I am overlooking something.

The XmbTextPropertyToTextList() documentation states that 'num' in 
unisono reflects the number of elements in 'list', so if positive and if 
the same time 'list' is nevertheless zero, we have caught a bug in that 
function which should be rectified instead.  It probably is not a good 
idea to keep disguising this that way.  (Btw, the exact same 
if-statement is a dozen lines below in I18N_GetIconName().)

Though, nevertheless this if-statement needs correction. The 
documentation doesn't state anywhere that the set of return values of 
XmbTextPropertyToTextList() is an ordered set, so 'status < Success' is 
  not only confusing, it is wrong.

Apart from these issues I strongly suspect that both, I18N_FetchName() 
and I18N_GetIconName() as in the original twm-1.0.4 code, probably leak 
memory.


  > diff -ru twm-1.0.3/src.orig/events.c twm-1.0.3/src/events.c
  > [...]
  > -	if (Tmp_win->icon_name == NoName) {
  > +	if (Tmp_win->icon_name !=  Tmp_win->name) {
  >  	    Tmp_win->icon_name = Tmp_win->name;
  >  	    RedoIconName();
  >  	}


:-)   This looks a very courageous interpretation of the XA_WM_ICON_NAME 
  window property; in fact rendering void the sole purpose of its 
existing.  Sure XA_WM_NAME and XA_WM_ICON_NAME may be seen as related in 
  some sense but no more than window configuration parameters like size 
  and position:  consider a window manager, after dragging out the 
client to cover (w,h) pixels in size, then always places it at location 
(x,y) having integer values of w and h and delegates to the 
user/application the responsibility to always restore the location.

If you ask me, I would suggest to remove this if-statement entirely.  At 
  least even the traditional variant is arbitrary: if the icon name is 
missing, the 'class.res_name' or 'class.res_class' seem to be as good 
candidates for replacing 'NoName' as the 'name' currently is.
The above if-statement as it originally stands results in icons which 
stretch from the left to the right edge of a 30" monitor as e.g. often 
web page generators put the whole document into the HTML-title as well, 
now ending up rendered in the icon label.

Not utilising the XA_WM_ICON_NAME property is maybe 'Opera'-specific 
peculiarity; maybe Opera is meant never to be iconified. (E.g. as 
modern day gtk/qt applications are not meant to be run on a blank 
X11-server, i.e. in a window-manager-less environment; as the user in 
general lacks a way to influence basic configuration parameters for 
top-level 'normal' windows like location and border width.)

In any case, fortunately the functionality you suggest has not 
necessarily to be implemented in twm anyways; please find attached a 
trivial program which, if started in .xinitrc in the background prior 
to any other X-application, should do you have suggested: intercepts all 
XA_WM_NAME property calls from each client, and forks them to set their 
XA_WM_ICON_NAME accordingly.
Let count this as a counter-suggestion.  :-)

Greetings,

      Eeri Kask


P.S. Alex, maybe you find it interesting, take a look at
      http://www1.inf.tu-dresden.de/~ek1/TWM-Tweaked.sh
this downloads
      http://www1.inf.tu-dresden.de/~ek1/twm-1.0.4-tweaked-diffs.tar
and compiles a twm (I mostly added client sloppy focusing; and am nearly 
finalising the rest by others begun few decades ago).  The man-page is 
unfortunately not yet updated, so the dot.twmrc file enclosed is the 
only documentation to these improvements.
If one keeps the .twmrc as it is, twm will continue running in its
traditional fashion, though few parameters will result in
      http://www1.inf.tu-dresden.de/~ek1/Vim-ShapeExtension.png
Have fun!

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Title2IconName.c
URL: <http://lists.x.org/archives/xorg/attachments/20080818/21ef6fbd/attachment.c>


More information about the xorg mailing list