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"
38 #include "superfluous.h"
43 extern WPreferences wPreferences
;
45 #ifdef NORMAL_ICON_KABOOM
46 void DoKaboom(WScreen
* scr
, Window win
, int x
, int y
)
49 int sw
= scr
->scr_width
, sh
= scr
->scr_height
;
50 #define KAB_PRECISION 4
53 char pvx
[PIECES
], pvy
[PIECES
];
54 /* in MkLinux/PPC gcc seems to think that char is unsigned? */
55 signed char ax
[PIECES
], ay
[PIECES
];
58 XSetClipMask(dpy
, scr
->copy_gc
, None
);
59 tmp
= XCreatePixmap(dpy
, scr
->root_win
, wPreferences
.icon_size
, wPreferences
.icon_size
, scr
->depth
);
60 if (scr
->w_visual
== DefaultVisual(dpy
, scr
->screen
))
61 XCopyArea(dpy
, win
, tmp
, scr
->copy_gc
, 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
, 0, 0);
65 image
= XGetImage(dpy
, win
, 0, 0, wPreferences
.icon_size
,
66 wPreferences
.icon_size
, AllPlanes
, ZPixmap
);
68 XUnmapWindow(dpy
, win
);
71 XPutImage(dpy
, tmp
, scr
->copy_gc
, image
, 0, 0, 0, 0,
72 wPreferences
.icon_size
, wPreferences
.icon_size
);
76 for (i
= 0, k
= 0; i
< wPreferences
.icon_size
/ ICON_KABOOM_PIECE_SIZE
&& k
< PIECES
; i
++) {
77 for (j
= 0; j
< wPreferences
.icon_size
/ ICON_KABOOM_PIECE_SIZE
&& k
< PIECES
; j
++) {
81 px
[k
] = (x
+ i
* ICON_KABOOM_PIECE_SIZE
) << KAB_PRECISION
;
82 py
[k
] = y
+ j
* ICON_KABOOM_PIECE_SIZE
;
83 pvx
[k
] = rand() % (1 << (KAB_PRECISION
+ 3)) - (1 << (KAB_PRECISION
+ 3)) / 2;
84 pvy
[k
] = -15 - rand() % 7;
92 XUnmapWindow(dpy
, win
);
98 if (XCheckTypedEvent(dpy
, ButtonPress
, &foo
)) {
99 XPutBackEvent(dpy
, &foo
);
100 XClearWindow(dpy
, scr
->root_win
);
104 for (i
= 0; i
< j
; i
++) {
106 int _px
= px
[i
] >> KAB_PRECISION
;
107 XClearArea(dpy
, scr
->root_win
, _px
, py
[i
],
108 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, False
);
111 _px
= px
[i
] >> KAB_PRECISION
;
113 if (_px
< -wPreferences
.icon_size
|| _px
> sw
|| py
[i
] >= sh
) {
117 XCopyArea(dpy
, tmp
, scr
->root_win
, scr
->copy_gc
,
118 ax
[i
] * ICON_KABOOM_PIECE_SIZE
, ay
[i
] * ICON_KABOOM_PIECE_SIZE
,
119 ICON_KABOOM_PIECE_SIZE
, ICON_KABOOM_PIECE_SIZE
, _px
, py
[i
]);
125 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
* 2);
128 XFreePixmap(dpy
, tmp
);
130 #endif /* NORMAL_ICON_KABOOM */
132 Pixmap
MakeGhostDock(WDock
* dock
, int sx
, int dx
, int y
)
134 WScreen
*scr
= dock
->screen_ptr
;
136 RImage
*back
, *dock_image
;
138 int i
, virtual_tiles
, h
, j
, n
;
139 unsigned long red_mask
, green_mask
, blue_mask
;
142 for (i
= 0; i
< dock
->max_icons
; i
++) {
143 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
> virtual_tiles
)
144 virtual_tiles
= dock
->icon_array
[i
]->yindex
;
147 h
= virtual_tiles
* wPreferences
.icon_size
;
148 h
= (y
+ h
> scr
->scr_height
) ? scr
->scr_height
- y
: h
;
149 virtual_tiles
= h
/ wPreferences
.icon_size
; /* The visible ones */
150 if (h
% wPreferences
.icon_size
)
151 virtual_tiles
++; /* There is one partially visible tile at end */
153 img
= XGetImage(dpy
, scr
->root_win
, dx
, y
, wPreferences
.icon_size
, h
, AllPlanes
, ZPixmap
);
157 red_mask
= img
->red_mask
;
158 green_mask
= img
->green_mask
;
159 blue_mask
= img
->blue_mask
;
161 back
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
167 for (i
= 0; i
< dock
->max_icons
; i
++) {
168 if (dock
->icon_array
[i
] != NULL
&& dock
->icon_array
[i
]->yindex
< virtual_tiles
) {
170 j
= dock
->icon_array
[i
]->yindex
* wPreferences
.icon_size
;
171 n
= (h
- j
< wPreferences
.icon_size
) ? h
- j
: wPreferences
.icon_size
;
172 if (dock
->icon_array
[i
]->icon
->pixmap
)
173 which
= dock
->icon_array
[i
]->icon
->pixmap
;
175 which
= dock
->icon_array
[i
]->icon
->core
->window
;
177 img
= XGetImage(dpy
, which
, 0, 0, wPreferences
.icon_size
, n
, AllPlanes
, ZPixmap
);
183 img
->red_mask
= red_mask
;
184 img
->green_mask
= green_mask
;
185 img
->blue_mask
= blue_mask
;
187 dock_image
= RCreateImageFromXImage(scr
->rcontext
, img
, NULL
);
193 RCombineAreaWithOpaqueness(back
, dock_image
, 0, 0,
194 wPreferences
.icon_size
, n
, 0, j
, 30 * 256 / 100);
195 RReleaseImage(dock_image
);
199 RConvertImage(scr
->rcontext
, back
, &pixmap
);
206 Pixmap
MakeGhostIcon(WScreen
* scr
, Drawable drawable
)
215 back
= RCreateImageFromDrawable(scr
->rcontext
, drawable
, None
);
224 RClearImage(back
, &color
);
225 RConvertImage(scr
->rcontext
, back
, &pixmap
);
232 #ifdef WINDOW_BIRTH_ZOOM
234 void DoWindowBirth(WWindow
*wwin
)
236 int center_x
, center_y
;
237 int width
= wwin
->frame
->core
->width
;
238 int height
= wwin
->frame
->core
->height
;
239 int w
= WMIN(width
, 20);
240 int h
= WMIN(height
, 20);
241 WScreen
*scr
= wwin
->screen_ptr
;
243 center_x
= wwin
->frame_x
+ (width
- w
) / 2;
244 center_y
= wwin
->frame_y
+ (height
- h
) / 2;
246 animateResize(scr
, center_x
, center_y
, 1, 1, wwin
->frame_x
, wwin
->frame_y
, width
, height
);
249 void DoWindowBirth(WWindow
*wwin
)