mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 14:08:06 +01:00
WMCreateApplicationIconBlendedPixmap() to avoid confusion. This is because this function does generate a new WMPixmap from the available icon image by combining it with the specified color and you need to call WMReleasePixmap() on the generated pixmap after you're done with it. This is unlike the case of WMGetApplicationIconPixmap() where it just returns a pointer to the existing application icon pixmap that was set before and where you don't need to release it after you're done working with it. To avoid this confusion about when you need to release and when not, one is using Get (get existing, no release needed), while the other is now using Create (generate a new pixmap, release required) in their name. Since this change was made to a function that was just added to the API in the previous commit, no modification is needed to the existing applications that use WINGs.
186 lines
3.8 KiB
C
186 lines
3.8 KiB
C
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "WINGsP.h"
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
/* Xmd.h which is indirectly included by GNUstep.h defines BOOL,
|
|
* but libPropList also defines it. So we do this kluge to get rid of BOOL
|
|
* temporarily */
|
|
#ifdef BOOL
|
|
# define WINGS_BOOL
|
|
# undef BOOL
|
|
#endif
|
|
|
|
#include "GNUstep.h"
|
|
|
|
#ifdef WINGS_BOOL
|
|
# define BOOL
|
|
# undef WINGS_BOOL
|
|
#endif
|
|
|
|
|
|
extern struct W_Application WMApplication;
|
|
|
|
|
|
void
|
|
WMSetApplicationIconWindow(WMScreen *scr, Window window)
|
|
{
|
|
scr->applicationIconWindow = window;
|
|
|
|
if (scr->groupLeader) {
|
|
XWMHints *hints;
|
|
|
|
hints = XGetWMHints(scr->display, scr->groupLeader);
|
|
hints->flags |= IconWindowHint;
|
|
hints->icon_window = window;
|
|
|
|
XSetWMHints(scr->display, scr->groupLeader, hints);
|
|
XFree(hints);
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
WMSetApplicationIconImage(WMScreen *scr, RImage *image)
|
|
{
|
|
WMPixmap *icon;
|
|
|
|
if (scr->applicationIconImage == image)
|
|
return;
|
|
|
|
if (scr->applicationIconImage)
|
|
RReleaseImage(scr->applicationIconImage);
|
|
|
|
scr->applicationIconImage = RRetainImage(image);
|
|
|
|
/* TODO: check whether we should set the pixmap only if there's none yet */
|
|
if (image!=NULL && (icon=WMCreatePixmapFromRImage(scr, image, 128))!=NULL) {
|
|
WMSetApplicationIconPixmap(scr, icon);
|
|
WMReleasePixmap(icon);
|
|
}
|
|
}
|
|
|
|
|
|
RImage*
|
|
WMGetApplicationIconImage(WMScreen *scr)
|
|
{
|
|
return scr->applicationIconImage;
|
|
}
|
|
|
|
|
|
void
|
|
WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
|
|
{
|
|
if (scr->applicationIconPixmap == icon)
|
|
return;
|
|
|
|
if (scr->applicationIconPixmap)
|
|
WMReleasePixmap(scr->applicationIconPixmap);
|
|
|
|
scr->applicationIconPixmap = WMRetainPixmap(icon);
|
|
|
|
if (scr->groupLeader) {
|
|
XWMHints *hints;
|
|
|
|
hints = XGetWMHints(scr->display, scr->groupLeader);
|
|
hints->flags |= IconPixmapHint|IconMaskHint;
|
|
hints->icon_pixmap = (icon!=NULL ? icon->pixmap : None);
|
|
hints->icon_mask = (icon!=NULL ? icon->mask : None);
|
|
|
|
XSetWMHints(scr->display, scr->groupLeader, hints);
|
|
XFree(hints);
|
|
}
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMGetApplicationIconPixmap(WMScreen *scr)
|
|
{
|
|
return scr->applicationIconPixmap;
|
|
}
|
|
|
|
|
|
WMPixmap*
|
|
WMCreateApplicationIconBlendedPixmap(WMScreen *scr, RColor *color)
|
|
{
|
|
WMPixmap *pix;
|
|
|
|
if (scr->applicationIconImage) {
|
|
RColor gray;
|
|
|
|
gray.red = 0xae;
|
|
gray.green = 0xaa;
|
|
gray.blue = 0xae;
|
|
gray.alpha = 0;
|
|
|
|
if (!color)
|
|
color = &gray;
|
|
|
|
pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage,
|
|
color);
|
|
} else {
|
|
pix = NULL;
|
|
}
|
|
|
|
return pix;
|
|
}
|
|
|
|
|
|
void
|
|
WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
|
|
{
|
|
scr->aflags.hasAppIcon = flag;
|
|
}
|
|
|
|
|
|
void
|
|
W_InitApplication(WMScreen *scr)
|
|
{
|
|
Window leader;
|
|
XClassHint *classHint;
|
|
XWMHints *hints;
|
|
|
|
leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1,
|
|
1, 1, 0, 0, 0);
|
|
|
|
if (!scr->aflags.simpleApplication) {
|
|
classHint = XAllocClassHint();
|
|
classHint->res_name = "groupLeader";
|
|
classHint->res_class = WMApplication.applicationName;
|
|
XSetClassHint(scr->display, leader, classHint);
|
|
XFree(classHint);
|
|
|
|
XSetCommand(scr->display, leader, WMApplication.argv,
|
|
WMApplication.argc);
|
|
|
|
hints = XAllocWMHints();
|
|
|
|
hints->flags = WindowGroupHint;
|
|
hints->window_group = leader;
|
|
|
|
/* This code will never actually be reached, because to have
|
|
* scr->applicationIconPixmap set we need to have a screen first,
|
|
* but this function is called in the screen creation process.
|
|
* -Dan
|
|
*/
|
|
if (scr->applicationIconPixmap) {
|
|
hints->flags |= IconPixmapHint;
|
|
hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
|
|
if (scr->applicationIconPixmap->mask) {
|
|
hints->flags |= IconMaskHint;
|
|
hints->icon_mask = scr->applicationIconPixmap->mask;
|
|
}
|
|
}
|
|
|
|
XSetWMHints(scr->display, leader, hints);
|
|
|
|
XFree(hints);
|
|
}
|
|
scr->groupLeader = leader;
|
|
}
|
|
|
|
|