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
]);
246 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
247 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
* 2);
251 XFreePixmap(dpy
, tmp
);
253 #endif /* NORMAL_ICON_KABOOM */
255 Pixmap
MakeGhostDock(WDock
* dock
, int sx
, int dx
, int y
)
257 WScreen
*scr
= dock
->screen_ptr
;
259 RImage
*back
, *dock_image
;
261 int i
, virtual_tiles
, h
, j
, n
;
262 unsigned long red_mask
, green_mask
, blue_mask
;
265 for (i
= 0; i
< dock
->max_icons
; i
++) {
266 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
> virtual_tiles
)
267 virtual_tiles
= dock
->icon_array
[i
]->yindex
;
270 h
= virtual_tiles
* wPreferences
.icon_size
;
271 h
= (y
+ h
> scr
->scr_height
) ? scr
->scr_height
- y
: h
;
272 virtual_tiles
= h
/ wPreferences
.icon_size
; /* The visible ones */
273 if (h
% wPreferences
.icon_size
)
274 virtual_tiles
++; /* There is one partially visible tile at end */
276 img
= XGetImage(dpy
, scr
->root_win
, dx
, y
, wPreferences
.icon_size
, h
, AllPlanes
, ZPixmap
);
280 red_mask
= img
->red_mask
;
281 green_mask
= img
->green_mask
;
282 blue_mask
= img
->blue_mask
;
284 back
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
290 for (i
= 0; i
< dock
->max_icons
; i
++) {
291 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
< virtual_tiles
) {
293 j
= dock
->icon_array
[i
]->yindex
* wPreferences
.icon_size
;
294 n
= (h
- j
< wPreferences
.icon_size
) ? h
- j
: wPreferences
.icon_size
;
295 if (dock
->icon_array
[i
]->icon
->pixmap
)
296 which
= dock
->icon_array
[i
]->icon
->pixmap
;
298 which
= dock
->icon_array
[i
]->icon
->core
->window
;
300 img
= XGetImage(dpy
, which
, 0, 0, wPreferences
.icon_size
, n
, AllPlanes
, ZPixmap
);
306 img
->red_mask
= red_mask
;
307 img
->green_mask
= green_mask
;
308 img
->blue_mask
= blue_mask
;
310 dock_image
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
316 RCombineAreaWithOpaqueness(back
, dock_image
, 0, 0,
317 wPreferences
.icon_size
, n
, 0, j
, 30 * 256 / 100);
318 RReleaseImage(dock_image
);
322 RConvertImage(scr
->rcontext
, back
, &pixmap
);
329 Pixmap
MakeGhostIcon(WScreen
* scr
, Drawable drawable
)
338 back
= RCreateImageFromDrawable(scr
->rcontext
, drawable
, None
);
347 RClearImage(back
, &color
);
348 RConvertImage(scr
->rcontext
, back
, &pixmap
);
355 #ifdef WINDOW_BIRTH_ZOOM
357 void DoWindowBirth(WWindow
*wwin
)
359 int center_x
, center_y
;
360 int width
= wwin
->frame
->core
->width
;
361 int height
= wwin
->frame
->core
->height
;
362 int w
= WMIN(width
, 20);
363 int h
= WMIN(height
, 20);
364 WScreen
*scr
= wwin
->screen_ptr
;
366 center_x
= wwin
->frame_x
+ (width
- w
) / 2;
367 center_y
= wwin
->frame_y
+ (height
- h
) / 2;
369 animateResize(scr
, center_x
, center_y
, 1, 1, wwin
->frame_x
, wwin
->frame_y
, width
, height
);
372 void DoWindowBirth(WWindow
*wwin
)
379 static WMPixmap
*data
[12];
381 static Bool
loadData(WScreen
* scr
)
388 f
= fopen(PKGDATADIR
"/xtree.dat", "rb");
392 image
= RCreateImage(50, 50, False
);
398 for (i
= 0; i
< 12; i
++) {
399 if (fread(image
->data
, 50 * 50 * 3, 1, f
) != 1) {
402 if (!RConvertImage(scr
->rcontext
, image
, &(d
[i
]))) {
406 RReleaseImage(image
);
410 for (i
= 0; i
< 12; i
++) {
411 data
[i
] = WMCreatePixmapFromXPixmaps(scr
->wmscreen
, d
[i
], None
, 50, 50, scr
->w_depth
);
417 RReleaseImage(image
);
422 XFreePixmap(dpy
, d
[i
]);
428 WMPixmap
*DoXThing(WWindow
* wwin
)
430 static int order
= 0;
434 return data
[order
% 12];
437 Bool
InitXThing(WScreen
* scr
)
445 if ((l
->tm_mon
!= 11 || l
->tm_mday
< 24 || l
->tm_mday
> 26))
459 #endif /* SILLYNESS */