1 Index: plugins/minimize.c
2 ===================================================================
3 RCS file: /cvs/xorg/app/compiz/plugins/minimize.c,v
4 retrieving revision 1.3
5 diff -u -r1.3 minimize.c
6 --- plugins/minimize.c 31 Mar 2006 11:22:34 -0000 1.3
7 +++ plugins/minimize.c 1 Apr 2006 16:20:55 -0000
17 #define MIN_TIMESTEP_MAX 50.0f
18 #define MIN_TIMESTEP_PRECISION 0.1f
20 +#define FAKE_ICON_SIZE 4
22 static char *winType[] = {
26 #define MIN_SCREEN_OPTION_SPEED 0
27 #define MIN_SCREEN_OPTION_TIMESTEP 1
28 #define MIN_SCREEN_OPTION_WINDOW_TYPE 2
29 -#define MIN_SCREEN_OPTION_NUM 3
30 +#define MIN_SCREEN_OPTION_ON_CREATE 3
31 +#define MIN_SCREEN_OPTION_CENTER 4
32 +#define MIN_SCREEN_OPTION_NUM 5
34 typedef struct _MinScreen {
35 int windowPrivateIndex;
40 + Bool scaleInNewWindows;
41 + Bool scaleFromCenter;
44 typedef struct _MinWindow {
52 #define GET_MIN_DISPLAY(d) \
55 #define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
58 +getMousePointerXY(CompScreen *s, short *x, short *y)
64 + if (XQueryPointer (s->display->display, s->root, &w1, &w2, &xj, &yj, &xp, &yp, &m))
75 minGetScreenOptions (CompScreen *screen,
78 ms->wMask = compWindowTypeMaskFromStringList (&o->value);
82 + case MIN_SCREEN_OPTION_ON_CREATE:
83 + if (compSetBoolOption (o, value))
85 + ms->scaleInNewWindows = o->value.b;
88 + case MIN_SCREEN_OPTION_CENTER:
89 + if (compSetBoolOption (o, value))
91 + ms->scaleFromCenter = o->value.b;
98 o->value.list.value[i].s = strdup (winType[i]);
99 o->rest.s.string = windowTypeString;
100 o->rest.s.nString = nWindowTypeString;
102 ms->wMask = compWindowTypeMaskFromStringList (&o->value);
104 + o = &ms->opt[MIN_SCREEN_OPTION_ON_CREATE];
105 + o->name = "zoom_created_windows";
106 + o->shortDesc = "Zoom Created Windows";
107 + o->longDesc = "Zooms created windows in from cursor/center";
108 + o->type = CompOptionTypeBool;
111 + o = &ms->opt[MIN_SCREEN_OPTION_CENTER];
112 + o->name = "zoom_created_windows_from_center";
113 + o->shortDesc = "Zoom Created Windows from Center";
114 + o->longDesc = "Zooms created windows in from center instead of cursor";
115 + o->type = CompOptionTypeBool;
116 + o->value.b = FALSE;
125 - if (mw->newState == IconicState)
126 + if (mw->newState == IconicState || mw->newState == WithdrawnState)
131 mw->ty = y1 - w->attrib.y;
134 + if (mw->destroyCnt)
146 + case DestroyNotify:
147 + w = findWindowAtDisplay (d, event->xunmap.window);
148 + /* mark it for zooming out */
151 + MIN_SCREEN (w->screen);
152 + if (ms->wMask & w->type)
156 + w->destroyRefCnt++;
157 + addWindowDamage(w);
162 w = findWindowAtDisplay (d, event->xunmap.window);
164 @@ -564,13 +636,39 @@
165 else /* X -> Withdrawn */
169 - if (mw->state == IconicState)
171 - (*w->screen->setWindowScale) (w, 1.0f, 1.0f);
172 - mw->state = NormalState;
175 + if (ms->wMask & w->type)
177 + if (mw->state == IconicState)
179 + (*w->screen->setWindowScale) (w, 1.0f, 1.0f);
182 + mw->state = NormalState;
183 + mw->newState = WithdrawnState;
185 + /* let's zoom windows on hide */
186 + if (getMousePointerXY (w->screen, &mw->icon.x, &mw->icon.y) &&
187 + ms->scaleInNewWindows && (ms->wMask & w->type))
189 + mw->icon.width = FAKE_ICON_SIZE;
190 + mw->icon.height = FAKE_ICON_SIZE;
191 + mw->icon.x -= FAKE_ICON_SIZE/2;
192 + mw->icon.y -= FAKE_ICON_SIZE/2;
194 + if (ms->scaleFromCenter)
196 + mw->icon.x = w->attrib.x + w->attrib.width/2 - FAKE_ICON_SIZE/2;
197 + mw->icon.y = w->attrib.y + w->attrib.height/2 - FAKE_ICON_SIZE/2;
201 + ms->moreAdjust = TRUE;
204 + addWindowDamage (w);
212 (*w->screen->setWindowScale) (w, 1.0f, 1.0f);
215 + else if (mw->state != NormalState)
217 + if (getMousePointerXY(w->screen,&mw->icon.x,&mw->icon.y) && ms->scaleInNewWindows)
219 + mw->icon.width = FAKE_ICON_SIZE;
220 + mw->icon.height = FAKE_ICON_SIZE;
221 + mw->icon.x -= FAKE_ICON_SIZE/2;
222 + mw->icon.y -= FAKE_ICON_SIZE/2;
224 + if (ms->scaleFromCenter)
226 + mw->icon.x = w->attrib.x + w->attrib.width/2 - FAKE_ICON_SIZE/2;
227 + mw->icon.y = w->attrib.y + w->attrib.height/2 - FAKE_ICON_SIZE/2;
230 + mw->tx = mw->icon.x-w->attrib.x;
231 + mw->ty = mw->icon.y-w->attrib.y;
232 + mw->xScale = ((float)FAKE_ICON_SIZE) / w->attrib.width;
233 + mw->yScale = ((float)FAKE_ICON_SIZE) / w->attrib.height;
235 + mw->state = IconicState; /* we're doing this as a hack, it may not be necessary */
236 + mw->newState = NormalState;
238 + ms->moreAdjust = TRUE;
239 + addWindowDamage (w);
243 mw->newState = NormalState;
246 MIN_SCREEN (w->screen);
250 + if (mw->unmapCnt || mw->destroyCnt)
253 UNWRAP (ms, w->screen, focusWindow);
256 ms->speed = MIN_SPEED_DEFAULT;
257 ms->timestep = MIN_TIMESTEP_DEFAULT;
258 + ms->scaleInNewWindows = TRUE;
259 + ms->scaleFromCenter = FALSE;
261 minScreenInitOptions (ms);
263 @@ -775,11 +902,40 @@
264 mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;
267 + mw->destroyCnt = 0;
269 mw->state = mw->newState = minGetWindowState (w);
271 w->privates[ms->windowPrivateIndex].ptr = mw;
273 + /* use a 'virtual' icon of 32x32 at mpx-16,mpy-16 */
274 + /* TODO consider changing this to a configurable thing somehow */
275 + if (w->type & ms->wMask && ms->scaleInNewWindows && mw->state == NormalState)
277 + if (getMousePointerXY (w->screen, &mw->icon.x, &mw->icon.y))
279 + mw->icon.width = FAKE_ICON_SIZE;
280 + mw->icon.height = FAKE_ICON_SIZE;
281 + mw->icon.x -= FAKE_ICON_SIZE / 2;
282 + mw->icon.y -= FAKE_ICON_SIZE / 2;
283 + if (ms->scaleFromCenter)
285 + mw->icon.x = w->attrib.x + w->attrib.width/2 - FAKE_ICON_SIZE/2;
286 + mw->icon.y = w->attrib.y + w->attrib.height/2 - FAKE_ICON_SIZE/2;
289 + mw->tx = mw->icon.x - w->attrib.x;
290 + mw->ty = mw->icon.y - w->attrib.y;
291 + mw->xScale = ((float)FAKE_ICON_SIZE) / w->attrib.width;
292 + mw->yScale = ((float)FAKE_ICON_SIZE) / w->attrib.height;
293 + mw->state = IconicState; /* we're doing this as a hack, it may not be necessary */
294 + mw->newState = NormalState;
296 + ms->moreAdjust=TRUE;
297 + addWindowDamage (w);