Unity launcher doesn't work well with Python Pygame apps

Bug #777417 reported by Lukáš Machyán
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
BAMF
Invalid
Undecided
Marco Trevisan (Treviño)
Pygame
Unknown
Unknown
Unity
Fix Released
Undecided
Marco Trevisan (Treviño)
libsdl
Fix Released
Medium
unity-2d
Fix Released
Undecided
Marco Trevisan (Treviño)
bamf (Ubuntu)
Invalid
Undecided
Marco Trevisan (Treviño)
libsdl1.2 (Ubuntu)
Fix Released
Undecided
Marco Trevisan (Treviño)
pygame (Ubuntu)
Fix Released
Undecided
Marco Trevisan (Treviño)
unity (Ubuntu)
Fix Released
Undecided
Marco Trevisan (Treviño)

Bug Description

Binary package hint: unity

When I launch an application written in Python with Pygame modules (python-pygame), an icon labeled "Python (v2.7)" appears in Unity launcher instead of an icon of launched application. When I put application to launcher and run application again using icon from the launcher, a window of Gnome Terminal with Python interpreter is launched.

I test this with my own Pygame application (https://launchpad.net/noctua-vagus), Pygame example application (/usr/lib/python2.7/dist-packages/pygame/examples/chimp.py) and game from Ubuntu Software Center (lightyears).

I believe that Unity itself should take care about this matter. Another possibility could be modification of Pygame apps. But I don't know how.

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: unity 3.8.12-0ubuntu1
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic i686
NonfreeKernelModules: wl
Architecture: i386
CompizPlugins: [core,bailer,detection,composite,opengl,compiztoolbox,decor,regex,mousepoll,vpswitch,gnomecompat,text,wall,grid,move,place,session,snap,titleinfo,imgpng,resize,animation,workarounds,expo,unitymtgrabhandles,ezoom,staticswitcher,fade,scale,scalefilter,unityshell,scaleaddon]
Date: Wed May 4 21:51:12 2011
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release i386 (20100429)
ProcEnviron:
 LANGUAGE=cs_CZ:en
 LANG=cs_CZ.UTF-8
 SHELL=/bin/bash
SourcePackage: unity
UpgradeStatus: Upgraded to natty on 2011-04-28 (5 days ago)

Related branches

Revision history for this message
Lukáš Machyán (phobulos) wrote :
description: updated
description: updated
summary: - Unity launcher doesn't work well with Pygame apps
+ Unity launcher doesn't work well with Python Pygame apps
Changed in pygame:
status: New → Confirmed
Changed in bamf:
status: New → Opinion
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

The main problem here is that a pygame window doesn't set any window atom value for "_NET_WM_PID", so for libwnck it's impossible to find the PID related to the opened window, and so the launched command that would make BAMF associate the application with the proper .desktop file.

So I think that this is not a BAMF problem at all, but you need to set this value to make your application being recognized properly or (better) to fix pygame to make it set more informations related to a new window that it creates.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

However, about the "title thing", I guess that this should be fixed in this very particular case.
I mean: when there's a python app running, don't use the desktop title but the window title. However with the current architecture this can't be done easily in BAMF, since it just exports informations about the related desktop file, and I don't think that simply don't allowing to export a "Python-X.Y.desktop" file would be a good idea.

Revision history for this message
Lukáš Machyán (phobulos) wrote :

Thanks for your response. I'm not able to fix Pygame but I could find out how to improve my Pygame application. It would just be for testing purpose.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Well, looking more in the deep, this seems more related to libSDL (that is controlled by python-pygame).

Since one of the few things _WM atom parameters that libSDL sets is the WM_CLASS, you can easily associate your application to a desktop file by setting the environment variable (also inside the python script) SDL_VIDEO_X11_WMCLASS to a value that can be the basename of your .desktop file (i.e. if you run your python script with SDL_VIDEO_X11_WMCLASS="gedit" python mygame.py it will be considered as a gedit window, so just use your_deskto_basename and it will work).

However, I'm wondering how this could be improved directly in libSDL and/or pygame to make any pygame application work out of the box. Maybe the best solution would be making pygame always to export this environment variable (set to the program's basename) when running in X11.
If there aren't best suggestions, as soon as I can I will send a patch for implementing this in pygame.

Revision history for this message
Lukáš Machyán (phobulos) wrote :

I have put 'os.environ["SDL_VIDEO_X11_WMCLASS"] = "name of .desktop file"' to my Python code (before pygame.init() statement) and created .desktop file in ~/.local/share/applications. It works fine for my game now. Thanks for your advice - it helped my game to look better in Unity.

It would be better to implement this in Pygame of course. I can't suggest better solution for this. Good luck with solving this problem.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Pygame patch added to its bugzilla [1], just waiting the merge...

[1] http://pygame.motherhamster.org/bugzilla/show_bug.cgi?id=71

Changed in pygame:
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
status: Confirmed → Fix Committed
status: Fix Committed → In Progress
Changed in pygame:
assignee: Treviño (Marco Trevisan) (3v1n0) → nobody
importance: Undecided → Unknown
status: In Progress → Unknown
Changed in libsdl1.2 (Ubuntu):
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Changed in bamf:
status: Opinion → Invalid
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Changed in unity:
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Changed in unity-2d:
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Changed in bamf (Ubuntu):
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Changed in unity-2d:
status: New → In Progress
Changed in unity:
status: New → In Progress
Changed in libsdl1.2 (Ubuntu):
status: New → In Progress
Changed in unity (Ubuntu):
status: New → In Progress
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Changed in bamf (Ubuntu):
status: New → Invalid
Changed in pygame (Ubuntu):
status: New → In Progress
assignee: nobody → Treviño (Marco Trevisan) (3v1n0)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libsdl1.2 - 1.2.14-6.1ubuntu4

---------------
libsdl1.2 (1.2.14-6.1ubuntu4) oneiric; urgency=low

  * Added 321_x11_add_support_to__NET_WM_PID.diff to support pid exportation
    in each x11 SDL window, needed mostly by pygame and BAMF (LP: #777417).
 -- Marco Trevisan (Trevino) <mail@3v1n0.net> Wed, 06 Jul 2011 15:07:19 +0200

Changed in libsdl1.2 (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pygame - 1.9.1release-0ubuntu4

---------------
pygame (1.9.1release-0ubuntu4) oneiric; urgency=low

  [ Marco Trevisan (Treviño) ]
  * Added set_the_SDL_WM_CLASS_when_running_under_X11.diff to export the
    WM_CLASS of pygame applications avoiding that windows managers (BAMF)
    would get confused by different pygame apps (LP: #777417)

  [ Martin Pitt ]
  * debian/rules, debian/control: Convert to dh_python2.
 -- Martin Pitt <email address hidden> Wed, 06 Jul 2011 15:30:40 +0200

Changed in pygame (Ubuntu):
status: In Progress → Fix Released
Changed in unity (Ubuntu):
status: In Progress → Fix Released
Changed in unity-2d:
status: In Progress → Fix Released
Changed in unity:
status: In Progress → Fix Released
Revision history for this message
illume (illume) wrote :

Hi,

this is merged upstream. Here's the pygame issue:
    https://bitbucket.org/pygame/pygame/issue/71/pygame-needs-to-set-the-wm_class-when

Changed in libsdl:
importance: Unknown → Medium
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.