Hi,<br><br>The problem we talked about is mostly fixed now. John Maloney said that Scratch is going to handle being closed from the frame from the next release. Opening firefox opened two icons on the frame: the firefox icon and another black circle. There was a bug filed somewhere that said that that was because some X properties were not set before the window opened. There was something about how to solve this from the activity itself, but I couldn&#39;t understand most of it so I added the following fucntion to /usr/share/sugar/shell/model/homemodel.py and then called it from HomeModel._window_opened_cb() (eg. _fix_icons(&#39;org.laptop.FirefoxActivity&#39;, &#39;Mozilla Firefox&#39;, self._activities, window) doing this made the black little circle go away, and now closing the firefox icon from the frame works. But I&#39;m not sure if this is the best solution.<br>
<br>Thanks<br>Bibek<br><br>def _fix_icons(reg_exp, wm_name, activities, wnck_window):<br>    # reg_exp is the regular expression to match the service name<br>    # wm_name is the value of the WM_NAME property of the X window<br>
    # activities is the collection of the HomeActivity instances<br>    # wnck_window is the new X window<br><br>    window = gtk.gdk.window_foreign_new(wnck_window.get_xid())<br><br>    # Check if the new window is window with wm_name<br>
    if window.property_get(&#39;WM_NAME&#39; , &#39;STRING&#39;)[2] == wm_name:<br><br>        for i in activities:<br><br>            # find the HomeActivity instance with service name matching reg_exp<br><br>            if i.get_window() is not None:<br>
<br>                if re.match(reg_exp, str(i.get_type())) != None:<br><br>                    if str(_get_sugar_window_type(i.get_window())) == &#39;launcher&#39;:<br><br>                       # Set sugar specific X properties<br>
<br>                        window.property_change(&#39;_SUGAR_BUNDLE_ID&#39;, &#39;STRING&#39;, 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_type))<br>                        window.property_change(&#39;_SUGAR_ACTIVITY_ID&#39;, &#39;STRING&#39;, 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_activity_id()))<br>
                        window.property_change(&#39;_NET_WM_NAME&#39;, &#39;STRING&#39;, 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_title))<br>                        window.property_change(&#39;_NET_WM_PID&#39;, &#39;STRING&#39;, 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_pid))<br>
                        window.property_change(&#39;_SUGAR_WINDOW_TYPE&#39;, &#39;STRING&#39;, 8, gtk.gdk.PROPERTY_NEW_VALUE, &#39;Firefox&#39;)<br><br><br clear="all"><br>
<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Bernie Innocenti</b> <span dir="ltr">&lt;<a href="mailto:bernie@codewiz.org" target="_blank">bernie@codewiz.org</a>&gt;</span><br>




Date: Wed, Feb 25, 2009 at 3:33 AM<br>Subject: Re: Making activities close from the sugar frame<br>To: Bibek Kafle &lt;<a href="mailto:bibek.kafle@olenepal.org" target="_blank">bibek.kafle@olenepal.org</a>&gt;<br><br><br>



Any particular reason why this is off-list?  Can we forward it to<br>

sugar-devel@ so the other developers can see what we&#39;re up to?<br>
<div><br>
Bibek Kafle wrote:<br>
&gt; Hi,<br>
&gt; To make firefox and scratch close from the sugar frame I tried to change<br>
&gt; a method in the CurrentActivityPallete class in<br>
&gt; /usr/sugar/sugar/shell/view/palletes.py to send SIGKILL signal to the<br>
&gt; activity after getting the pid from the HomeActivity object, but it<br>
&gt; didn&#39;t work. The shell log said that the operation was not permitted.<br>
<br>
</div>It&#39;s Rainbow&#39;s fault!  Activities run with a different UID for isolation.<br>
<div><br>
<br>
&gt; Then I tried to use a c wrapper to make to set setuid for a python<br>
&gt; script that killed the pid, but it still said that the operation was not<br>
&gt; permitted. Even if that worked, Bryan says that simply killing the<br>
&gt; process will be dirty because firefox will say that the previous session<br>
&gt; was closed unexpectedly the next time it is run. I&#39;m out of ideas now!<br>
<br>
</div>Indeed, this is not how gnome and kde close applications.<br>
<div><br>
&gt; Bryan said that you had an idea about how I can go about making scratch<br>
&gt; and firefox close from the sugar frame. He said something about making a<br>
&gt; wrapper that handles X11 close events. How do I do that?<br>
&gt; Bibek<br>
<br>
</div>If you find the XID for the window somwewhere in the activity info managed by Sugar, you can send it a window close event.<br>
<br>
I&#39;m not sure about the details, but:<br>
<br>
 - see  &quot;man XSendEvent&quot;<br>
<br>
 - it seems you have to send an event called ClientMessage<br>
   <a href="http://tronche.com/gui/x/xlib/events/client-communication/client-message.html" target="_blank">http://tronche.com/gui/x/xlib/events/client-communication/client-message.html</a><br>
<br>
 - The ancient ICCCM specification tells what needs to be done<br>
   <a href="http://tronche.com/gui/x/icccm/sec-4.html#s-4.2.8.1" target="_blank">http://tronche.com/gui/x/icccm/sec-4.html#s-4.2.8.1</a><br>
<br>
I would just grab some example code (for example a window manager) instead<br>
of reading through the specs<br>
<font color="#888888"><br>
--<br>
   // Bernie Innocenti - <a href="http://www.codewiz.org/" target="_blank">http://www.codewiz.org/</a><br>
 \X/  Sugar Labs       - <a href="http://www.sugarlabs.org/" target="_blank">http://www.sugarlabs.org/</a><br>
</font></div><br>