[MPlayer-dev-eng] GUI's icon - a X11 issue?

Ingo Brückl ib at wupperonline.de
Fri Jun 10 19:25:39 CEST 2011


Anyone experienced in X11 programming?

For days now (and I mean *DAYS*), I'm trying to find a solution for the GUI
icon issue, but didn't succeed and am finally stumped now. Maybe someone with
X11 programming skill can help.

The two GUI windows (i.e. the GUI main window with all the buttons,
potentiometers and stuff, and the GUI sub window where the movie plays) are
pure X11 windows. They are created and managed only by X11 function. All the
other window stuff, like context menu, file selector, preferences and such,
are GTK windows - created and managed by GTK functions.

The icon for the GUI (currently) is a xpm file. Since there is no native X11
function to read other data than bitmaps, a GDK function is used to create a
GDK pixmap. The basis of the GDK pixmap is of course a X11 pixmap and there
is a GDK function to retrieve the X11 Pixmap ID. This ID is used to set the
WMHints for a every new window which makes the window manager show this icon.

The problem is: Every time gmplayer is called, the icon looks different. It
basically seems to be the right image, but somehow differently "distorted"
every time.

Well, currently, the icon is GDK'ed by creating a GTK window which is
destroyed right afterwards, and I thought that might be the problem. After
reading about visuals and colormaps, I tried an approach in regard to the X11
windows already created as follows:

  // make a GDK visual corresponding to the visual used for the subWindow
  vis = gdkx_visual_get(appMPlayer.subWindow.VisualInfo.visualid);

  // make a GDK colormap corresponding to the colormap created for the subWindow
  cmap = gdk_x11_colormap_foreign_new(vis, appMPlayer.subWindow.WindowAttrib.colormap);

  // render a GDK pixmap and mask
  gdk_pixbuf_render_pixmap_and_mask_for_colormap
  (
    gdk_pixbuf_new_from_xpm_data((const char **) mplayer_xpm),
    cmap,
    &gdkIcon,
    &gdkIconMask,
    128
  );

  // now we have a X11 pixmap and mask (with same colormap and depth as subWindow)
  guiIcon = GDK_PIXMAP_XID(gdkIcon);
  guiIconMask = GDK_PIXMAP_XID(gdkIconMask);

Unfortunately, the result didn't change. Although sometimes I get the right
icon on main or sub window, the sporadic distortion remains. Most amazingly,
on the GTK type windows the same icon (set with the same pure X11 method as
for main or sub) is perfectly OK all the time! (Indicating that the X11
Pixmap data itself seems to be ok.)

Then I tried libXpm to create the icon and everything's fine. (What I can see
from the code, it doesn't do any magic, just reading the data, creating a
colormap and returning a pixmap and mask.)

So, if I can't find the bug, the only way to go seems to be to add libXpm as
a dependency to --enable-gui. However, a GDK approach would have two
advantages: no further dependency and not only xpm files, but png also could
be used as icon file.

I really have no further idea what I could try else and I'd really appreciate
any help here.

Ingo


More information about the MPlayer-dev-eng mailing list