Skip to content
  • Jon Turney's avatar
    hw/xwin: Make winOverrideIcon() thread-safe for icon data access · 527cf131
    Jon Turney authored
    
    
    winOverrideIcon() is called from the internal WM client thread.
    
    Accessing server-internal data structures to get icon data or window hints is
    not safe, as there is no lock to ensure we do not collide with these data
    structures being updated in the server thread.
    
    Rewrite so the internal client thread uses X client calls to obtain this data
    safely
    
    We used to also set the icon inside the server when the window was initially
    created.  For simplicity, we simply send a message to the internal WM to update
    the icon when the window is created (rather than writing different icon update
    code which can work in the server thread for that one case...)
    
    extwm mode used to do the icon update in the server. I'm not sure that actually
    made much sense.  Let's assume the external WM client can do it instead...
    
    v2
    Make sure that WM_WM_ICON_EVENT does nothing for override-redirect windows
    
    v3
    Reinstate check that native window actually has expected properties for an X
    window before trying to update it's icon; some auxiliary windows owned by the
    XWin process don't, which would cause a crash
    
    v4
    Various fixes to pixmap icon conversion:
    - remove left-over malloc in winScaleXimageToWindowsIcon causing a memory leak
    - don't recalculate DDBitmap stride in winScaleXimageToWindowsIcon, when we already have worked it out
    - properly check that XGetWindowProperty(NET_WM_ICON) returned some data
    - don't try to retrieve WM_HINTS icon_mask if it isn't set
    - restore accidentally dropped calculation of effBpp, stride, maskStride of output DDBitmap
    - make sure imageMask is zero-initalized before we use it to mask the DDBitmap
    
    v5
    Remove a left-over unused variable
    
    v6
    Avoid XDestroyImage(NULL) crash if XGetImage failed for icon_pixmap
    
    Signed-off-by: default avatarJon TURNEY <jon.turney@dronecode.org.uk>
    Reviewed-by: default avatarColin Harrison <colin.harrison@virgin.net>
    527cf131