2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
5 * Copyright (c) 1998-2003 Dan Pascu
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 #include <X11/Xutil.h>
35 #include "WindowMaker.h"
37 #include "superfluous.h"
46 extern WPreferences wPreferences
;
48 #ifdef DEMATERIALIZE_ICON
49 void DoKaboom(WScreen
* scr
, Window win
, int x
, int y
)
63 h
= w
= wPreferences
.icon_size
;
64 if (x
< 0 || x
+ w
> scr
->scr_width
|| y
< 0 || y
+ h
> scr
->scr_height
)
67 icon
= RCreateImageFromDrawable(scr
->rcontext
, win
, None
);
71 gcv
.foreground
= scr
->white_pixel
;
72 gcv
.background
= scr
->black_pixel
;
73 gcv
.graphics_exposures
= False
;
74 gcv
.subwindow_mode
= IncludeInferiors
;
75 gc
= XCreateGC(dpy
, scr
->w_win
, GCForeground
| GCBackground
| GCSubwindowMode
| GCGraphicsExposures
, &gcv
);
78 RConvertImage(scr
->rcontext
, icon
, &pixmap
);
79 XUnmapWindow(dpy
, win
);
81 ximage
= XGetImage(dpy
, scr
->root_win
, x
, y
, w
, h
, AllPlanes
, ZPixmap
);
82 XCopyArea(dpy
, pixmap
, scr
->root_win
, gc
, 0, 0, w
, h
, x
, y
);
83 XFreePixmap(dpy
, pixmap
);
85 back
= RCreateImageFromXImage(scr
->rcontext
, ximage
, NULL
);
86 XDestroyImage(ximage
);
92 for (i
= 0, run
= 0; i
< DEMATERIALIZE_STEPS
; i
++) {
94 if (!run
&& XCheckTypedEvent(dpy
, ButtonPress
, &foo
)) {
96 XPutBackEvent(dpy
, &foo
);
98 image
= RCloneImage(back
);
99 RCombineImagesWithOpaqueness(image
, icon
,
100 (DEMATERIALIZE_STEPS
- 1 - i
) * 256 / (DEMATERIALIZE_STEPS
+ 2));
101 RConvertImage(scr
->rcontext
, image
, &pixmap
);
102 XCopyArea(dpy
, pixmap
, scr
->root_win
, gc
, 0, 0, w
, h
, x
, y
);
103 XFreePixmap(dpy
, pixmap
);
109 while (XCheckTypedEvent(dpy
, MotionNotify
, &event
)) {
118 #endif /* DEMATERIALIZE_ICON */
120 #ifdef NORMAL_ICON_KABOOM
121 void DoKaboom(WScreen
* scr
, Window win
, int x
, int y
)
124 int sw
= scr
->scr_width
, sh
= scr
->scr_height
;
125 #define KAB_PRECISION 4
128 #ifdef ICON_KABOOM_EXTRA
129 short ptx
[2][PIECES
], pty
[2][PIECES
];
132 char pvx
[PIECES
], pvy
[PIECES
];
133 /* in MkLinux/PPC gcc seems to think that char is unsigned? */
134 signed char ax
[PIECES
], ay
[PIECES
];
137 XSetClipMask(dpy
, scr
->copy_gc
, None
);
138 tmp
= XCreatePixmap(dpy
, scr
->root_win
, wPreferences
.icon_size
, wPreferences
.icon_size
, scr
->depth
);
139 if (scr
->w_visual
== DefaultVisual(dpy
, scr
->screen
))
140 XCopyArea(dpy
, win
, tmp
, scr
->copy_gc
, 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
, 0, 0);
144 image
= XGetImage(dpy
, win
, 0, 0, wPreferences
.icon_size
,
145 wPreferences
.icon_size
, AllPlanes
, ZPixmap
);
147 XUnmapWindow(dpy
, win
);
150 XPutImage(dpy
, tmp
, scr
->copy_gc
, image
, 0, 0, 0, 0,
151 wPreferences
.icon_size
, wPreferences
.icon_size
);
152 XDestroyImage(image
);
155 for (i
= 0, k
= 0; i
< wPreferences
.icon_size
/ ICON_KABOOM_PIECE_SIZE
&& k
< PIECES
; i
++) {
156 for (j
= 0; j
< wPreferences
.icon_size
/ ICON_KABOOM_PIECE_SIZE
&& k
< PIECES
; j
++) {
160 px
[k
] = (x
+ i
* ICON_KABOOM_PIECE_SIZE
) << KAB_PRECISION
;
161 py
[k
] = y
+ j
* ICON_KABOOM_PIECE_SIZE
;
162 pvx
[k
] = rand() % (1 << (KAB_PRECISION
+ 3)) - (1 << (KAB_PRECISION
+ 3)) / 2;
163 pvy
[k
] = -15 - rand() % 7;
164 #ifdef ICON_KABOOM_EXTRA
165 for (ll
= 0; ll
< 2; ll
++) {
177 XUnmapWindow(dpy
, win
);
183 if (XCheckTypedEvent(dpy
, ButtonPress
, &foo
)) {
184 XPutBackEvent(dpy
, &foo
);
185 XClearWindow(dpy
, scr
->root_win
);
189 for (i
= 0; i
< j
; i
++) {
191 int _px
= px
[i
] >> KAB_PRECISION
;
192 #ifdef ICON_KABOOM_EXTRA
193 XClearArea(dpy
, scr
->root_win
, ptx
[1][i
], pty
[1][i
],
194 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, False
);
196 ptx
[1][i
] = ptx
[0][i
];
197 pty
[1][i
] = pty
[0][i
];
201 XClearArea(dpy
, scr
->root_win
, _px
, py
[i
],
202 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, False
);
206 _px
= px
[i
] >> KAB_PRECISION
;
208 if (_px
< -wPreferences
.icon_size
|| _px
> sw
|| py
[i
] >= sh
) {
209 #ifdef ICON_KABOOM_EXTRA
210 if (py
[i
] > sh
&& _px
< sw
&& _px
> 0) {
211 pvy
[i
] = -(pvy
[i
] / 2);
212 if (abs(pvy
[i
]) > 3) {
213 py
[i
] = sh
- ICON_KABOOM_PIECE_SIZE
;
214 XCopyArea(dpy
, tmp
, scr
->root_win
, scr
->copy_gc
,
215 ax
[i
] * ICON_KABOOM_PIECE_SIZE
,
216 ay
[i
] * ICON_KABOOM_PIECE_SIZE
,
217 ICON_KABOOM_PIECE_SIZE
,
218 ICON_KABOOM_PIECE_SIZE
, _px
, py
[i
]);
226 for (ll
= 0; ll
< 2; ll
++)
227 XClearArea(dpy
, scr
->root_win
, ptx
[ll
][i
], pty
[ll
][i
],
228 ICON_KABOOM_PIECE_SIZE
,
229 ICON_KABOOM_PIECE_SIZE
, False
);
232 #else /* !ICON_KABOOM_EXTRA */
235 #endif /* !ICON_KABOOM_EXTRA */
237 XCopyArea(dpy
, tmp
, scr
->root_win
, scr
->copy_gc
,
238 ax
[i
] * ICON_KABOOM_PIECE_SIZE
, ay
[i
] * ICON_KABOOM_PIECE_SIZE
,
239 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, _px
, py
[i
]);
245 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
* 2);
248 XFreePixmap(dpy
, tmp
);
250 #endif /* NORMAL_ICON_KABOOM */
252 Pixmap
MakeGhostDock(WDock
* dock
, int sx
, int dx
, int y
)
254 WScreen
*scr
= dock
->screen_ptr
;
256 RImage
*back
, *dock_image
;
258 int i
, virtual_tiles
, h
, j
, n
;
259 unsigned long red_mask
, green_mask
, blue_mask
;
262 for (i
= 0; i
< dock
->max_icons
; i
++) {
263 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
> virtual_tiles
)
264 virtual_tiles
= dock
->icon_array
[i
]->yindex
;
267 h
= virtual_tiles
* wPreferences
.icon_size
;
268 h
= (y
+ h
> scr
->scr_height
) ? scr
->scr_height
- y
: h
;
269 virtual_tiles
= h
/ wPreferences
.icon_size
; /* The visible ones */
270 if (h
% wPreferences
.icon_size
)
271 virtual_tiles
++; /* There is one partially visible tile at end */
273 img
= XGetImage(dpy
, scr
->root_win
, dx
, y
, wPreferences
.icon_size
, h
, AllPlanes
, ZPixmap
);
277 red_mask
= img
->red_mask
;
278 green_mask
= img
->green_mask
;
279 blue_mask
= img
->blue_mask
;
281 back
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
287 for (i
= 0; i
< dock
->max_icons
; i
++) {
288 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
< virtual_tiles
) {
290 j
= dock
->icon_array
[i
]->yindex
* wPreferences
.icon_size
;
291 n
= (h
- j
< wPreferences
.icon_size
) ? h
- j
: wPreferences
.icon_size
;
292 if (dock
->icon_array
[i
]->icon
->pixmap
)
293 which
= dock
->icon_array
[i
]->icon
->pixmap
;
295 which
= dock
->icon_array
[i
]->icon
->core
->window
;
297 img
= XGetImage(dpy
, which
, 0, 0, wPreferences
.icon_size
, n
, AllPlanes
, ZPixmap
);
303 img
->red_mask
= red_mask
;
304 img
->green_mask
= green_mask
;
305 img
->blue_mask
= blue_mask
;
307 dock_image
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
313 RCombineAreaWithOpaqueness(back
, dock_image
, 0, 0,
314 wPreferences
.icon_size
, n
, 0, j
, 30 * 256 / 100);
315 RReleaseImage(dock_image
);
319 RConvertImage(scr
->rcontext
, back
, &pixmap
);
326 Pixmap
MakeGhostIcon(WScreen
* scr
, Drawable drawable
)
335 back
= RCreateImageFromDrawable(scr
->rcontext
, drawable
, None
);
344 RClearImage(back
, &color
);
345 RConvertImage(scr
->rcontext
, back
, &pixmap
);
352 #ifdef WINDOW_BIRTH_ZOOM
354 void DoWindowBirth(WWindow
*wwin
)
356 int center_x
, center_y
;
357 int width
= wwin
->frame
->core
->width
;
358 int height
= wwin
->frame
->core
->height
;
359 int w
= WMIN(width
, 20);
360 int h
= WMIN(height
, 20);
361 WScreen
*scr
= wwin
->screen_ptr
;
363 center_x
= wwin
->frame_x
+ (width
- w
) / 2;
364 center_y
= wwin
->frame_y
+ (height
- h
) / 2;
366 animateResize(scr
, center_x
, center_y
, 1, 1, wwin
->frame_x
, wwin
->frame_y
, width
, height
);
369 void DoWindowBirth(WWindow
*wwin
)
376 static WMPixmap
*data
[12];
378 static Bool
loadData(WScreen
* scr
)
385 f
= fopen(PKGDATADIR
"/xtree.dat", "rb");
389 image
= RCreateImage(50, 50, False
);
395 for (i
= 0; i
< 12; i
++) {
396 if (fread(image
->data
, 50 * 50 * 3, 1, f
) != 1) {
399 if (!RConvertImage(scr
->rcontext
, image
, &(d
[i
]))) {
403 RReleaseImage(image
);
407 for (i
= 0; i
< 12; i
++) {
408 data
[i
] = WMCreatePixmapFromXPixmaps(scr
->wmscreen
, d
[i
], None
, 50, 50, scr
->w_depth
);
414 RReleaseImage(image
);
419 XFreePixmap(dpy
, d
[i
]);
425 WMPixmap
*DoXThing(WWindow
* wwin
)
427 static int order
= 0;
431 return data
[order
% 12];
434 Bool
InitXThing(WScreen
* scr
)
442 if ((l
->tm_mon
!= 11 || l
->tm_mday
< 24 || l
->tm_mday
> 26))
456 #endif /* SILLYNESS */