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 NORMAL_ICON_KABOOM
49 void DoKaboom(WScreen
* scr
, Window win
, int x
, int y
)
52 int sw
= scr
->scr_width
, sh
= scr
->scr_height
;
53 #define KAB_PRECISION 4
56 #ifdef ICON_KABOOM_EXTRA
57 short ptx
[2][PIECES
], pty
[2][PIECES
];
60 char pvx
[PIECES
], pvy
[PIECES
];
61 /* in MkLinux/PPC gcc seems to think that char is unsigned? */
62 signed char ax
[PIECES
], ay
[PIECES
];
65 XSetClipMask(dpy
, scr
->copy_gc
, None
);
66 tmp
= XCreatePixmap(dpy
, scr
->root_win
, wPreferences
.icon_size
, wPreferences
.icon_size
, scr
->depth
);
67 if (scr
->w_visual
== DefaultVisual(dpy
, scr
->screen
))
68 XCopyArea(dpy
, win
, tmp
, scr
->copy_gc
, 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
, 0, 0);
72 image
= XGetImage(dpy
, win
, 0, 0, wPreferences
.icon_size
,
73 wPreferences
.icon_size
, AllPlanes
, ZPixmap
);
75 XUnmapWindow(dpy
, win
);
78 XPutImage(dpy
, tmp
, scr
->copy_gc
, image
, 0, 0, 0, 0,
79 wPreferences
.icon_size
, wPreferences
.icon_size
);
83 for (i
= 0, k
= 0; i
< wPreferences
.icon_size
/ ICON_KABOOM_PIECE_SIZE
&& k
< PIECES
; i
++) {
84 for (j
= 0; j
< wPreferences
.icon_size
/ ICON_KABOOM_PIECE_SIZE
&& k
< PIECES
; j
++) {
88 px
[k
] = (x
+ i
* ICON_KABOOM_PIECE_SIZE
) << KAB_PRECISION
;
89 py
[k
] = y
+ j
* ICON_KABOOM_PIECE_SIZE
;
90 pvx
[k
] = rand() % (1 << (KAB_PRECISION
+ 3)) - (1 << (KAB_PRECISION
+ 3)) / 2;
91 pvy
[k
] = -15 - rand() % 7;
92 #ifdef ICON_KABOOM_EXTRA
93 for (ll
= 0; ll
< 2; ll
++) {
105 XUnmapWindow(dpy
, win
);
111 if (XCheckTypedEvent(dpy
, ButtonPress
, &foo
)) {
112 XPutBackEvent(dpy
, &foo
);
113 XClearWindow(dpy
, scr
->root_win
);
117 for (i
= 0; i
< j
; i
++) {
119 int _px
= px
[i
] >> KAB_PRECISION
;
120 #ifdef ICON_KABOOM_EXTRA
121 XClearArea(dpy
, scr
->root_win
, ptx
[1][i
], pty
[1][i
],
122 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, False
);
124 ptx
[1][i
] = ptx
[0][i
];
125 pty
[1][i
] = pty
[0][i
];
129 XClearArea(dpy
, scr
->root_win
, _px
, py
[i
],
130 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, False
);
134 _px
= px
[i
] >> KAB_PRECISION
;
136 if (_px
< -wPreferences
.icon_size
|| _px
> sw
|| py
[i
] >= sh
) {
137 #ifdef ICON_KABOOM_EXTRA
138 if (py
[i
] > sh
&& _px
< sw
&& _px
> 0) {
139 pvy
[i
] = -(pvy
[i
] / 2);
140 if (abs(pvy
[i
]) > 3) {
141 py
[i
] = sh
- ICON_KABOOM_PIECE_SIZE
;
142 XCopyArea(dpy
, tmp
, scr
->root_win
, scr
->copy_gc
,
143 ax
[i
] * ICON_KABOOM_PIECE_SIZE
,
144 ay
[i
] * ICON_KABOOM_PIECE_SIZE
,
145 ICON_KABOOM_PIECE_SIZE
,
146 ICON_KABOOM_PIECE_SIZE
, _px
, py
[i
]);
154 for (ll
= 0; ll
< 2; ll
++)
155 XClearArea(dpy
, scr
->root_win
, ptx
[ll
][i
], pty
[ll
][i
],
156 ICON_KABOOM_PIECE_SIZE
,
157 ICON_KABOOM_PIECE_SIZE
, False
);
160 #else /* !ICON_KABOOM_EXTRA */
163 #endif /* !ICON_KABOOM_EXTRA */
165 XCopyArea(dpy
, tmp
, scr
->root_win
, scr
->copy_gc
,
166 ax
[i
] * ICON_KABOOM_PIECE_SIZE
, ay
[i
] * ICON_KABOOM_PIECE_SIZE
,
167 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, _px
, py
[i
]);
173 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
* 2);
176 XFreePixmap(dpy
, tmp
);
178 #endif /* NORMAL_ICON_KABOOM */
180 Pixmap
MakeGhostDock(WDock
* dock
, int sx
, int dx
, int y
)
182 WScreen
*scr
= dock
->screen_ptr
;
184 RImage
*back
, *dock_image
;
186 int i
, virtual_tiles
, h
, j
, n
;
187 unsigned long red_mask
, green_mask
, blue_mask
;
190 for (i
= 0; i
< dock
->max_icons
; i
++) {
191 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
> virtual_tiles
)
192 virtual_tiles
= dock
->icon_array
[i
]->yindex
;
195 h
= virtual_tiles
* wPreferences
.icon_size
;
196 h
= (y
+ h
> scr
->scr_height
) ? scr
->scr_height
- y
: h
;
197 virtual_tiles
= h
/ wPreferences
.icon_size
; /* The visible ones */
198 if (h
% wPreferences
.icon_size
)
199 virtual_tiles
++; /* There is one partially visible tile at end */
201 img
= XGetImage(dpy
, scr
->root_win
, dx
, y
, wPreferences
.icon_size
, h
, AllPlanes
, ZPixmap
);
205 red_mask
= img
->red_mask
;
206 green_mask
= img
->green_mask
;
207 blue_mask
= img
->blue_mask
;
209 back
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
215 for (i
= 0; i
< dock
->max_icons
; i
++) {
216 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
< virtual_tiles
) {
218 j
= dock
->icon_array
[i
]->yindex
* wPreferences
.icon_size
;
219 n
= (h
- j
< wPreferences
.icon_size
) ? h
- j
: wPreferences
.icon_size
;
220 if (dock
->icon_array
[i
]->icon
->pixmap
)
221 which
= dock
->icon_array
[i
]->icon
->pixmap
;
223 which
= dock
->icon_array
[i
]->icon
->core
->window
;
225 img
= XGetImage(dpy
, which
, 0, 0, wPreferences
.icon_size
, n
, AllPlanes
, ZPixmap
);
231 img
->red_mask
= red_mask
;
232 img
->green_mask
= green_mask
;
233 img
->blue_mask
= blue_mask
;
235 dock_image
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
241 RCombineAreaWithOpaqueness(back
, dock_image
, 0, 0,
242 wPreferences
.icon_size
, n
, 0, j
, 30 * 256 / 100);
243 RReleaseImage(dock_image
);
247 RConvertImage(scr
->rcontext
, back
, &pixmap
);
254 Pixmap
MakeGhostIcon(WScreen
* scr
, Drawable drawable
)
263 back
= RCreateImageFromDrawable(scr
->rcontext
, drawable
, None
);
272 RClearImage(back
, &color
);
273 RConvertImage(scr
->rcontext
, back
, &pixmap
);
280 #ifdef WINDOW_BIRTH_ZOOM
282 void DoWindowBirth(WWindow
*wwin
)
284 int center_x
, center_y
;
285 int width
= wwin
->frame
->core
->width
;
286 int height
= wwin
->frame
->core
->height
;
287 int w
= WMIN(width
, 20);
288 int h
= WMIN(height
, 20);
289 WScreen
*scr
= wwin
->screen_ptr
;
291 center_x
= wwin
->frame_x
+ (width
- w
) / 2;
292 center_y
= wwin
->frame_y
+ (height
- h
) / 2;
294 animateResize(scr
, center_x
, center_y
, 1, 1, wwin
->frame_x
, wwin
->frame_y
, width
, height
);
297 void DoWindowBirth(WWindow
*wwin
)