On Sun, 20 Oct 2013, Rodolfo García Peñas wrote:
1. Icon possition.
The icon is created here (I removed lines that doesn't matter for the issue)::
---8<---
static WAppIcon *mainIconCreate(WScreen *scr, int type, const char *name)
{
int x_pos;
switch(type) {
case WM_CLIP:
btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip",
TILE_CLIP);
x_pos = 0;
case WM_DOCK:
default: /* to avoid a warning about btn and x_pos, basically */
btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMDock",
TILE_NORMAL);
x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE;
case WM_DRAWER:
btn = wAppIconCreateForDock(scr, NULL, name, "WMDrawer",
TILE_DRAWER);
x_pos = 0;
}
btn->x_pos = x_pos;
btn->y_pos = 0;
---8<---
And then, is mapped here:
---8<---
WDock *wDockCreate(WScreen *scr, int type, const char *name)
{
btn = mainIconCreate(scr, type, name);
dock->x_pos = btn->x_pos;
dock->y_pos = btn->y_pos;
XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos);
---8<---
We creates the icons at 0,0 and the move it to the rigth possition. Why?
Because we create the icon on the screen (mapped).
What if you move the XMapWindow call from mainIconCreate and place it
after the XMoveWindow call? Then the icon is not mapped until it's at the
correct position.
2. Icons depends on the screen, always.
Why this function, that reads the icon from the database, needs the
screen? Because the icon is painted on the screen when is created. All
things are created on the screen, mapped, then we show them (or are
hidden).
---8<---
void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const
char *wm_class, const char *command)
{
file = get_icon_filename(wm_instance, wm_class, command, False);
if (file) {
icon->file = wstrdup(file);
icon->file_image = get_rimage_from_file(icon->core->screen_ptr,
icon->file, wPreferences.icon_size);
wfree(file);
}
}
---8<---
Maybe it's not painted but it may be cached by the X server or it needs to
be converted to the visual of the screen so if you have multiple screens
with different visuals then you'll probably need multiple instances for
the same icon for different screens. It does not matter if you load the
icon image into memory first and then instantiate it on different screens
or you just load it from disk (actually the OS will cache it for you) and
instantiate it when needed. So I don't see the advantage in trying to
cache it ourselves when it cannot save the multiple instances for
different screens.
Regards,
BALATON Zoltan