Files
wmaker/WINGs/wappresource.c
T

149 lines
3.3 KiB
C
Raw Normal View History

#include <unistd.h>
#include "WINGsP.h"
#include <X11/Xutil.h>
#include "GNUstep.h"
2009-08-20 00:59:40 +02:00
void WMSetApplicationIconWindow(WMScreen * scr, Window window)
2001-04-21 07:12:21 +00:00
{
2009-08-20 00:59:40 +02:00
scr->applicationIconWindow = window;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (scr->groupLeader) {
XWMHints *hints;
2000-09-25 19:21:45 +00:00
2009-08-20 00:59:40 +02:00
hints = XGetWMHints(scr->display, scr->groupLeader);
hints->flags |= IconWindowHint;
hints->icon_window = window;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
XSetWMHints(scr->display, scr->groupLeader, hints);
XFree(hints);
}
2000-09-25 19:21:45 +00:00
}
2009-08-20 00:59:40 +02:00
void WMSetApplicationIconImage(WMScreen * scr, RImage * image)
2001-04-21 07:12:21 +00:00
{
2009-08-20 00:59:40 +02:00
WMPixmap *icon;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (scr->applicationIconImage == image)
return;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (scr->applicationIconImage)
RReleaseImage(scr->applicationIconImage);
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
scr->applicationIconImage = RRetainImage(image);
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
/* 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);
}
2001-04-21 07:12:21 +00:00
}
2009-08-20 00:59:40 +02:00
RImage *WMGetApplicationIconImage(WMScreen * scr)
2001-04-21 07:12:21 +00:00
{
2009-08-20 00:59:40 +02:00
return scr->applicationIconImage;
2001-04-21 07:12:21 +00:00
}
2009-08-20 00:59:40 +02:00
void WMSetApplicationIconPixmap(WMScreen * scr, WMPixmap * icon)
2001-04-21 07:12:21 +00:00
{
2009-08-20 00:59:40 +02:00
if (scr->applicationIconPixmap == icon)
return;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (scr->applicationIconPixmap)
WMReleasePixmap(scr->applicationIconPixmap);
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
scr->applicationIconPixmap = WMRetainPixmap(icon);
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (scr->groupLeader) {
XWMHints *hints;
2009-08-20 00:59:40 +02:00
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);
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
XSetWMHints(scr->display, scr->groupLeader, hints);
XFree(hints);
}
}
2009-08-20 00:59:40 +02:00
WMPixmap *WMGetApplicationIconPixmap(WMScreen * scr)
{
2009-08-20 00:59:40 +02:00
return scr->applicationIconPixmap;
2001-04-21 07:12:21 +00:00
}
WMPixmap *WMCreateApplicationIconBlendedPixmap(WMScreen * scr, const RColor * color)
2001-04-21 07:12:21 +00:00
{
2009-08-20 00:59:40 +02:00
WMPixmap *pix;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (scr->applicationIconImage) {
static const RColor gray = {
/* red */ 0xAE,
/* green */ 0xAA,
/* blue */ 0xAE,
/* alpha */ 0xFF
};
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
if (!color)
color = &gray;
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage, color);
} else {
pix = NULL;
}
2001-04-21 07:12:21 +00:00
2009-08-20 00:59:40 +02:00
return pix;
}
2009-08-20 00:59:40 +02:00
void WMSetApplicationHasAppIcon(WMScreen * scr, Bool flag)
{
2009-08-20 00:59:40 +02:00
scr->aflags.hasAppIcon = ((flag == 0) ? 0 : 1);
}
2009-08-20 00:59:40 +02:00
void W_InitApplication(WMScreen * scr)
{
2009-08-20 00:59:40 +02:00
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;
}