<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>…for the adult in you &#187; ICCCM</title>
	<atom:link href="http://blogs.gnome.org/metacity/category/nargery/icccm/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.gnome.org/metacity</link>
	<description>"Many window managers are like Marshmallow Froot Loops; Metacity is like Cheerios."</description>
	<lastBuildDate>Wed, 04 Nov 2009 10:59:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>		<item>
		<title>Window matching</title>
		<link>http://blogs.gnome.org/metacity/2008/11/02/window-matching/</link>
		<comments>http://blogs.gnome.org/metacity/2008/11/02/window-matching/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 18:30:37 +0000</pubDate>
		<dc:creator>Thomas Thurman</dc:creator>
				<category><![CDATA[Bugs and issues]]></category>
		<category><![CDATA[EWMH]]></category>
		<category><![CDATA[ICCCM]]></category>
		<category><![CDATA[nargery]]></category>
		<category><![CDATA[overview]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/metacity/?p=171</guid>
		<description><![CDATA[Window matching is the process of identifying a new window as one we&#8217;ve seen before.  Of course every new window is new, and so we&#8217;ve never seen it before, but there&#8217;s an intuitive understanding that if you open a document in OpenOffice and then come back to it a week later that the window is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/chiperoni/239435850/" title="glass pane, shattered by nchenga, on Flickr"><img src="http://farm1.static.flickr.com/96/239435850_1a6e489521.jpg" width="500" height="375" alt="glass pane, shattered" align="right" /></a>Window matching is the process of identifying a new window as one we&#8217;ve seen before.  Of course every new window is <em>new</em>, and so we&#8217;ve never seen it before, but there&#8217;s an intuitive understanding that if you open a document in OpenOffice and then come back to it a week later that the window is in some way the same.</p>
<p>Some good properties to use for this are:</p>
<ul>
<li><a href="http://ring.u-toyama.ac.jp/pub/XFree86/4.1.0/doc/xsmp.TXT"><em>SM_CLIENT_ID</em></a>, which is set by the session manager for a particular instance of a running program. XSMP says that &#8220;a unique value called a client-ID is provided by the protocol for the purpose of disambiguating multiple instantiations of clients.&#8221;</li>
<li><a href="http://tronche.com/gui/x/icccm/sec-5.html"><em>WM_WINDOW_ROLE</em></a>, which is optional.  The ICCCM says that &#8220;the combination of SM_CLIENT_ID and WM_WINDOW_ROLE can be used by other clients to uniquely identify a window across sessions.&#8221;  If there is no WM_WINDOW_ROLE, the ICCCM tells us to fall back on WM_CLASS and WM_NAME&#8230;</li>
<li><em>WM_NAME</em> is the window title.</li>
<li><a href="http://tronche.com/gui/x/icccm/sec-4.html"><em>WM_CLASS</em></a> is a two-part property.  Let&#8217;s call these Instance and Class, although these aren&#8217;t the real names. <em>Instance</em> is generally the name of the program, although it can sometimes be set on the commandline.</li>
<li><em>Class</em> is &#8220;the general class of applications to which the client  that owns this window belongs&#8221;, i.e. the brand name of the program (rather than &#8220;editor&#8221;).</li>
</ul>
<p>Metacity does not currently do window matching for three good reasons.</p>
<p><strong>1. Separation of concerns: in-process or not?</strong></p>
<p>The EWMH allows us to do window matching outside the WM, and in fact this is what <a href="http://burtonini.com/blog/computers/devilspie">Devil&#8217;s Pie</a> and <a href="http://www.phaeronix.net/gDevilspie">gdevilspie</a> are for.  They have all the other problems, but they&#8217;re not part of the WM, and if they crash they don&#8217;t bring the WM down.  It appears that because this can be done outside the WM it should be.  (Isn&#8217;t this fun?  We can pretend we&#8217;re the Hurd.)  Feel free to argue the point, of course.</p>
<p><strong>2. Separation of concerns: app or WM?</strong></p>
<p>It is also possible that nobody except the application itself knows where its windows should be placed, and that everything should be left up to the apps (and in practice the toolkits).  This would allow us to do away with session management entirely.  Certainly it would mean that it was none of Metacity&#8217;s business.</p>
<p><strong>3. Paucity of distinguishability: who sets what?</strong></p>
<p>Devil&#8217;s Pie requires you to set up rules to identify windows.  Doing window matching at the window manager level implies that the rules are written for you automatically.  This wouldn&#8217;t be a problem, except that applications set the attributes above very inconsistently.  Although WM_NAME is always set, it isn&#8217;t necessarily reliable&#8211; for example, gedit adds a star to it when you begin editing a document. I believe therefore that we cannot use it in automated window matching.</p>
<p>As to the others, let&#8217;s introduce a notation: <strong>Role|Instance|Class</strong>.  If Role is missing, we write <strong>[NONE]|Instance|Class</strong>.  Here is a program called <a href="http://www.gnome.org/~tthurman/bugs/same.c">same.c</a> which will print these values for you.  Some common examples:</p>
<ul>
<li>Firefox sets <strong>browser|Navigator|Firefox</strong> in all cases.  It is therefore not possible to distinguish Firefox windows from one another except by WM_NAME.</li>
<li>Thunderbird sets <strong>[NONE]|gecko|Thunderbird-bin</strong>, but it usually only has one window open.</li>
<li>nautilus sets <strong>[NONE]|nautilus|Nautilus</strong> and it is therefore impossible to tell the difference between Nautilus windows except by WM_NAME.</li>
<li>inkscape sets <strong>[NONE]|inkscape|Inkscape</strong> similarly.</li>
<li>gnome-calculator sets <strong>[NONE]|gnome-calculator|Gnome-calculator</strong>.</li>
<li>gnome-terminal sets <strong>gnome-terminal-</strong><em>SOME-LONG-STRING-OF-NUMBERS</em><strong>|gnome-terminal|Gnome-terminal</strong> with the string of numbers different each time.  This gets an A.</li>
<li>epiphany sets <strong>epiphany-window-</strong><em>SOME-LONG-STRING-OF-NUMBERS</em><strong>|epiphany-browser|Epiphany-browser</strong> with the numbers differing.  Another A.</li>
<li>The GIMP sets <strong>gimp-</strong><em>XXX</em><strong>|gimp|Gimp</strong> where <em>XXX</em> is &#8220;toolbox&#8221;, &#8220;dock&#8221;, &#8220;tip-of-the-day&#8221;, etc.  This gets an A+.</li>
</ul>
<p>Please feel free to comment with more results and I&#8217;ll add them.</p>
<p><strong>Conclusion</strong></p>
<ul>
<li>People often complain that Metacity doesn&#8217;t do window matching.</li>
<li>There are many reasons why it shouldn&#8217;t (but feel free to disagree in comments).</li>
<li>Window matching of any kind is needlessly difficult because the important properties are set inconsistently.</li>
<li>Therefore for the sake of window matching in general, whether we do it in Metacity or not, it would be a useful exercise to patch all programs which don&#8217;t set roles as well as the GIMP does.  (<a href="http://library.gnome.org/devel/gtk/2.12/GtkWindow.html#gtk-window-set-role">gtk_window_set_role()</a> is the relevant GTK function; <a href="http://www.google.com/codesearch?q=gtk_window_set_role+-package%3Agtk%2B">it&#8217;s not widely used</a>.)  Perhaps this could become a <a href="http://live.gnome.org/GnomeGoals">GNOME Goal</a>.</li>
</ul>
<p><small>Photo: Glass pane, shattered, &copy; nchenga nchenga, cc-by-nc.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/metacity/2008/11/02/window-matching/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
