2 * WindowMaker window manager
4 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 #include <X11/Xutil.h>
32 #include "WindowMaker.h"
34 #include "superfluous.h"
41 extern WPreferences wPreferences
;
46 play(Display
*dpy
, int pitch
, int delay
)
50 kc
.bell_pitch
= pitch
;
52 kc
.bell_duration
= delay
;
53 XChangeKeyboardControl(dpy
, KBBellPitch
|KBBellDuration
|KBBellPercent
,&kc
);
62 DoKaboom(WScreen
*scr
, Window win
, int x
, int y
)
65 int sw
=scr
->scr_width
, sh
=scr
->scr_height
;
66 short px
[PIECES
], py
[PIECES
];
67 char pvx
[PIECES
], pvy
[PIECES
];
68 char ax
[PIECES
], ay
[PIECES
];
72 img
=XGetImage(dpy
, win
, 0, 0, wPreferences
.icon_size
,
73 wPreferences
.icon_size
, AllPlanes
, ZPixmap
);
74 XUnmapWindow(dpy
,win
);
77 XSetClipMask(dpy
, scr
->copy_gc
, None
);
78 tmp
= XCreatePixmap(dpy
, scr
->root_win
, wPreferences
.icon_size
,
79 wPreferences
.icon_size
, scr
->depth
);
80 XPutImage(dpy
, tmp
, scr
->copy_gc
, img
, 0, 0, 0, 0, wPreferences
.icon_size
,
81 wPreferences
.icon_size
);
83 for (i
=0,k
=0; i
<wPreferences
.icon_size
/PSIZE
; i
++) {
84 for (j
=0; j
<wPreferences
.icon_size
/PSIZE
; j
++) {
104 for (i
=0; i
<j
; i
++) {
109 pvx
[i
]+=(pvx
[i
]>0 ? 2 : -2);
110 pvy
[i
]+=(pvy
[i
]>0 ? 2 : -2);
111 /* The following are nice, but too slow.
112 * The animation can have an unknown duration, depending
113 * on what rand() returns. Until the animation ends, the user
114 * cannot do anything, which is not too good. -Dan
116 /*pvx[i]+=rand()%5-2;
117 pvy[i]+=rand()%5-2;*/
122 if (px
[i
]<-wPreferences
.icon_size
|| px
[i
]>sw
|| py
[i
]>sh
124 || px
[i
]<0 || py
[i
]<0
130 XCopyArea(dpy
, tmp
, scr
->root_win
, scr
->copy_gc
,
131 ax
[i
]*PSIZE
, ay
[i
]*PSIZE
,
132 PSIZE
, PSIZE
, px
[i
], py
[i
]);
137 play(dpy
, 100+rand()%250, 12);
139 # if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
140 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
*2);
143 for (i
=0; i
<j
; i
++) {
145 XClearArea(dpy
, scr
->root_win
, px
[i
], py
[i
], PSIZE
, PSIZE
, 1);
149 XFreePixmap(dpy
, tmp
);
155 MakeGhostDock(WDock
*dock
, int sx
, int dx
, int y
)
157 WScreen
*scr
= dock
->screen_ptr
;
159 RImage
*back
, *dock_image
;
161 int i
, virtual_tiles
, h
, j
, n
;
162 unsigned long red_mask
, green_mask
, blue_mask
;
165 for (i
=0; i
<dock
->max_icons
; i
++) {
166 if (dock
->icon_array
[i
]!=NULL
&&
167 dock
->icon_array
[i
]->yindex
> virtual_tiles
)
168 virtual_tiles
= dock
->icon_array
[i
]->yindex
;
171 h
= virtual_tiles
* wPreferences
.icon_size
;
172 h
= (y
+ h
> scr
->scr_height
) ? scr
->scr_height
-y
: h
;
173 virtual_tiles
= h
/ wPreferences
.icon_size
; /* The visible ones */
174 if (h
% wPreferences
.icon_size
)
175 virtual_tiles
++; /* There is one partially visible tile at end */
177 img
=XGetImage(dpy
, scr
->root_win
, dx
, y
, wPreferences
.icon_size
, h
,
182 red_mask
= img
->red_mask
;
183 green_mask
= img
->green_mask
;
184 blue_mask
= img
->blue_mask
;
186 back
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
192 for (i
=0;i
<dock
->max_icons
;i
++) {
193 if (dock
->icon_array
[i
]!=NULL
&&
194 dock
->icon_array
[i
]->yindex
< virtual_tiles
) {
196 j
= dock
->icon_array
[i
]->yindex
* wPreferences
.icon_size
;
197 n
= (h
- j
< wPreferences
.icon_size
) ? h
- j
:
198 wPreferences
.icon_size
;
199 if (dock
->icon_array
[i
]->icon
->pixmap
)
200 which
= dock
->icon_array
[i
]->icon
->pixmap
;
202 which
= dock
->icon_array
[i
]->icon
->core
->window
;
204 img
=XGetImage(dpy
, which
, 0, 0, wPreferences
.icon_size
, n
,
211 img
->red_mask
= red_mask
;
212 img
->green_mask
= green_mask
;
213 img
->blue_mask
= blue_mask
;
215 dock_image
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
221 RCombineAreaWithOpaqueness(back
, dock_image
, 0, 0,
222 wPreferences
.icon_size
, n
,
223 0, j
, 30 * 256 / 100);
224 RDestroyImage(dock_image
);
229 RConvertImage(scr
->rcontext
, back
, &pixmap
);
238 MakeGhostIcon(WScreen
*scr
, Drawable drawable
)
248 back
= RCreateImageFromDrawable(scr
->rcontext
, drawable
, None
);
257 RClearImage(back
, &color
);
258 RConvertImage(scr
->rcontext
, back
, &pixmap
);
267 #ifdef WINDOW_BIRTH_ZOOM
269 DoWindowBirth(WWindow
*wwin
)
271 int width
= wwin
->frame
->core
->width
;
272 int height
= wwin
->frame
->core
->height
;
273 int w
= WMIN(width
, 20);
274 int h
= WMIN(height
, 20);
279 dw
= (width
-w
)/WINDOW_BIRTH_STEPS
;
280 dh
= (height
-h
)/WINDOW_BIRTH_STEPS
;
282 x
= wwin
->frame_x
+ (width
-w
)/2;
283 y
= wwin
->frame_y
+ (height
-h
)/2;
285 XMoveResizeWindow(dpy
, wwin
->frame
->core
->window
, x
, y
, w
, h
);
287 XMapWindow(dpy
, wwin
->frame
->core
->window
);
290 for (i
=0; i
<WINDOW_BIRTH_STEPS
; i
++) {
295 XMoveResizeWindow(dpy
, wwin
->frame
->core
->window
, x
, y
, w
, h
);
299 XMoveResizeWindow(dpy
, wwin
->frame
->core
->window
,
300 wwin
->frame_x
, wwin
->frame_y
, width
, height
);
305 DoWindowBirth(WWindow
*wwin
)