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'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('org.laptop.FirefoxActivity', 'Mozilla Firefox', self._activities, window) doing this made the black little circle go away, and now closing the firefox icon from the frame works. But I'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('WM_NAME' , 'STRING')[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())) == 'launcher':<br><br> # Set sugar specific X properties<br>
<br> window.property_change('_SUGAR_BUNDLE_ID', 'STRING', 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_type))<br> window.property_change('_SUGAR_ACTIVITY_ID', 'STRING', 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_activity_id()))<br>
window.property_change('_NET_WM_NAME', 'STRING', 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_title))<br> window.property_change('_NET_WM_PID', 'STRING', 8, gtk.gdk.PROPERTY_NEW_VALUE, str(i.get_pid))<br>
window.property_change('_SUGAR_WINDOW_TYPE', 'STRING', 8, gtk.gdk.PROPERTY_NEW_VALUE, 'Firefox')<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"><<a href="mailto:bernie@codewiz.org" target="_blank">bernie@codewiz.org</a>></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 <<a href="mailto:bibek.kafle@olenepal.org" target="_blank">bibek.kafle@olenepal.org</a>><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're up to?<br>
<div><br>
Bibek Kafle wrote:<br>
> Hi,<br>
> To make firefox and scratch close from the sugar frame I tried to change<br>
> a method in the CurrentActivityPallete class in<br>
> /usr/sugar/sugar/shell/view/palletes.py to send SIGKILL signal to the<br>
> activity after getting the pid from the HomeActivity object, but it<br>
> didn't work. The shell log said that the operation was not permitted.<br>
<br>
</div>It's Rainbow's fault! Activities run with a different UID for isolation.<br>
<div><br>
<br>
> Then I tried to use a c wrapper to make to set setuid for a python<br>
> script that killed the pid, but it still said that the operation was not<br>
> permitted. Even if that worked, Bryan says that simply killing the<br>
> process will be dirty because firefox will say that the previous session<br>
> was closed unexpectedly the next time it is run. I'm out of ideas now!<br>
<br>
</div>Indeed, this is not how gnome and kde close applications.<br>
<div><br>
> Bryan said that you had an idea about how I can go about making scratch<br>
> and firefox close from the sugar frame. He said something about making a<br>
> wrapper that handles X11 close events. How do I do that?<br>
> 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'm not sure about the details, but:<br>
<br>
- see "man XSendEvent"<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>