~profzoom/ubuntu/quantal/wmaker/bug-1079925

« back to all changes in this revision

Viewing changes to WINGs/wappresource.c

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2004-11-10 14:05:30 UTC
  • Revision ID: james.westby@ubuntu.com-20041110140530-qpd66b5lm38x7apk
Tags: upstream-0.91.0
ImportĀ upstreamĀ versionĀ 0.91.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
#include <unistd.h>
 
4
 
 
5
#include "WINGsP.h"
 
6
 
 
7
#include <X11/Xutil.h>
 
8
 
 
9
#include "GNUstep.h"
 
10
 
 
11
 
 
12
 
 
13
extern struct W_Application WMApplication;
 
14
 
 
15
 
 
16
void
 
17
WMSetApplicationIconWindow(WMScreen *scr, Window window)
 
18
{
 
19
    scr->applicationIconWindow = window;
 
20
 
 
21
    if (scr->groupLeader) {
 
22
        XWMHints *hints;
 
23
 
 
24
        hints = XGetWMHints(scr->display, scr->groupLeader);
 
25
        hints->flags |= IconWindowHint;
 
26
        hints->icon_window = window;
 
27
 
 
28
        XSetWMHints(scr->display, scr->groupLeader, hints);
 
29
        XFree(hints);
 
30
    }
 
31
}
 
32
 
 
33
 
 
34
void
 
35
WMSetApplicationIconImage(WMScreen *scr, RImage *image)
 
36
{
 
37
    WMPixmap *icon;
 
38
 
 
39
    if (scr->applicationIconImage == image)
 
40
        return;
 
41
 
 
42
    if (scr->applicationIconImage)
 
43
        RReleaseImage(scr->applicationIconImage);
 
44
 
 
45
    scr->applicationIconImage = RRetainImage(image);
 
46
 
 
47
    /* TODO: check whether we should set the pixmap only if there's none yet */
 
48
    if (image!=NULL && (icon=WMCreatePixmapFromRImage(scr, image, 128))!=NULL) {
 
49
        WMSetApplicationIconPixmap(scr, icon);
 
50
        WMReleasePixmap(icon);
 
51
    }
 
52
}
 
53
 
 
54
 
 
55
RImage*
 
56
WMGetApplicationIconImage(WMScreen *scr)
 
57
{
 
58
    return scr->applicationIconImage;
 
59
}
 
60
 
 
61
 
 
62
void
 
63
WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
 
64
{
 
65
    if (scr->applicationIconPixmap == icon)
 
66
        return;
 
67
 
 
68
    if (scr->applicationIconPixmap)
 
69
        WMReleasePixmap(scr->applicationIconPixmap);
 
70
 
 
71
    scr->applicationIconPixmap = WMRetainPixmap(icon);
 
72
 
 
73
    if (scr->groupLeader) {
 
74
        XWMHints *hints;
 
75
 
 
76
        hints = XGetWMHints(scr->display, scr->groupLeader);
 
77
        hints->flags |= IconPixmapHint|IconMaskHint;
 
78
        hints->icon_pixmap = (icon!=NULL ? icon->pixmap : None);
 
79
        hints->icon_mask = (icon!=NULL ? icon->mask : None);
 
80
 
 
81
        XSetWMHints(scr->display, scr->groupLeader, hints);
 
82
        XFree(hints);
 
83
    }
 
84
}
 
85
 
 
86
 
 
87
WMPixmap*
 
88
WMGetApplicationIconPixmap(WMScreen *scr)
 
89
{
 
90
    return scr->applicationIconPixmap;
 
91
}
 
92
 
 
93
 
 
94
WMPixmap*
 
95
WMCreateApplicationIconBlendedPixmap(WMScreen *scr, RColor *color)
 
96
{
 
97
    WMPixmap *pix;
 
98
 
 
99
    if (scr->applicationIconImage) {
 
100
        RColor gray;
 
101
 
 
102
        gray.red = 0xae;
 
103
        gray.green = 0xaa;
 
104
        gray.blue = 0xae;
 
105
        gray.alpha = 0xff;
 
106
 
 
107
        if (!color)
 
108
            color = &gray;
 
109
 
 
110
        pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage,
 
111
                                              color);
 
112
    } else {
 
113
        pix = NULL;
 
114
    }
 
115
 
 
116
    return pix;
 
117
}
 
118
 
 
119
 
 
120
void
 
121
WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
 
122
{
 
123
    scr->aflags.hasAppIcon = ((flag==0) ? 0 : 1);
 
124
}
 
125
 
 
126
 
 
127
void
 
128
W_InitApplication(WMScreen *scr)
 
129
{
 
130
    Window leader;
 
131
    XClassHint *classHint;
 
132
    XWMHints *hints;
 
133
 
 
134
    leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1,
 
135
                                 1, 1, 0, 0, 0);
 
136
 
 
137
    if (!scr->aflags.simpleApplication) {
 
138
        classHint = XAllocClassHint();
 
139
        classHint->res_name = "groupLeader";
 
140
        classHint->res_class = WMApplication.applicationName;
 
141
        XSetClassHint(scr->display, leader, classHint);
 
142
        XFree(classHint);
 
143
 
 
144
        XSetCommand(scr->display, leader, WMApplication.argv,
 
145
                    WMApplication.argc);
 
146
 
 
147
        hints = XAllocWMHints();
 
148
 
 
149
        hints->flags = WindowGroupHint;
 
150
        hints->window_group = leader;
 
151
 
 
152
        /* This code will never actually be reached, because to have
 
153
         * scr->applicationIconPixmap set we need to have a screen first,
 
154
         * but this function is called in the screen creation process.
 
155
         * -Dan
 
156
         */
 
157
        if (scr->applicationIconPixmap) {
 
158
            hints->flags |= IconPixmapHint;
 
159
            hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
 
160
            if (scr->applicationIconPixmap->mask) {
 
161
                hints->flags |= IconMaskHint;
 
162
                hints->icon_mask = scr->applicationIconPixmap->mask;
 
163
            }
 
164
        }
 
165
 
 
166
        XSetWMHints(scr->display, leader, hints);
 
167
 
 
168
        XFree(hints);
 
169
    }
 
170
    scr->groupLeader = leader;
 
171
}
 
172
 
 
173