~ubuntu-branches/ubuntu/intrepid/compiz-fusion-plugins-main/intrepid-proposed

« back to all changes in this revision

Viewing changes to src/workarounds/workarounds.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2007-10-29 12:35:14 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20071029123514-3bsfje9dk1tyu099
Tags: 0.6.0+git20071027-0ubuntu1
* new snapshot of the 0.6 branch
* debian/patches/04_wall_animation_fix.diff:
  - dropped, part of the upstream source now

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
} WorkaroundsScreen;
46
46
 
47
47
typedef struct _WorkaroundsWindow {
48
 
    CompTimeoutHandle updateHandle;
49
 
 
50
48
    Bool adjustedWinType;
51
49
    Bool madeSticky;
 
50
    Bool madeFullscreen;
52
51
    Bool isFullscreen;
53
52
} WorkaroundsWindow;
54
53
 
168
167
 
169
168
    WORKAROUNDS_WINDOW (w);
170
169
 
171
 
    if (w->type & CompWindowTypeDesktopMask)
172
 
        return;
173
 
 
174
 
    /* get output region for window */
175
 
    output = outputDeviceForWindow (w);
176
 
    box = &w->screen->outputDev[output].region.extents;
177
 
 
178
 
    /* does the size match the output rectangle? */
179
 
    isFullSize = (w->serverX == box->x1) && (w->serverY == box->y1) &&
180
 
                 (w->serverWidth == (box->x2 - box->x1)) &&
181
 
                 (w->serverHeight == (box->y2 - box->y1));
182
 
 
183
 
    /* if not, check if it matches the whole screen */
184
 
    if (!isFullSize)
185
 
    {
186
 
        if ((w->serverX == 0) && (w->serverY == 0) &&
187
 
            (w->serverWidth == w->screen->width) &&
188
 
            (w->serverHeight == w->screen->height))
 
170
    if (w->wmType & CompWindowTypeDesktopMask)
 
171
    {
 
172
        /* desktop windows are implicitly fullscreen */
 
173
        isFullSize = FALSE;
 
174
    }
 
175
    else
 
176
    {
 
177
        /* get output region for window */
 
178
        output = outputDeviceForWindow (w);
 
179
        box = &w->screen->outputDev[output].region.extents;
 
180
 
 
181
        /* does the size match the output rectangle? */
 
182
        isFullSize = (w->serverX == box->x1) && (w->serverY == box->y1) &&
 
183
                     (w->serverWidth == (box->x2 - box->x1)) &&
 
184
                     (w->serverHeight == (box->y2 - box->y1));
 
185
 
 
186
        /* if not, check if it matches the whole screen */
 
187
        if (!isFullSize)
189
188
        {
190
 
            isFullSize = TRUE;
 
189
            if ((w->serverX == 0) && (w->serverY == 0) &&
 
190
                (w->serverWidth == w->screen->width) &&
 
191
                (w->serverHeight == w->screen->height))
 
192
            {
 
193
                isFullSize = TRUE;
 
194
            }
191
195
        }
192
196
    }
193
197
 
199
203
 
200
204
        if (isFullSize)
201
205
            state |= CompWindowStateFullscreenMask;
 
206
        ww->madeFullscreen = isFullSize;
202
207
 
203
208
        if (state != w->state)
204
209
        {
221
226
    /* FIXME: Is this the best way to detect a notification type window? */
222
227
    if (workaroundsGetNotificationDaemonFix (d))
223
228
    {
224
 
        if (w->wmType == CompWindowTypeNormalMask &&
 
229
        if (newWmType == CompWindowTypeNormalMask &&
225
230
            w->attrib.override_redirect && w->resName &&
226
231
            strcmp (w->resName, "notification-daemon") == 0)
227
232
        {
228
233
            newWmType = CompWindowTypeNotificationMask;
 
234
            goto AppliedFix;
229
235
        }
230
236
    }
231
237
 
232
 
    if ((w->wmType == newWmType) && workaroundsGetFirefoxMenuFix (d))
 
238
    if (workaroundsGetFirefoxMenuFix (d))
233
239
    {
234
 
        if (w->wmType == CompWindowTypeNormalMask &&
 
240
        if (newWmType == CompWindowTypeNormalMask &&
235
241
            w->attrib.override_redirect && w->resName)
236
242
        {
237
243
            if ((strcasecmp (w->resName, "gecko") == 0) ||
238
244
                (strcasecmp (w->resName, "popup") == 0))
239
245
            {
240
246
                newWmType = CompWindowTypeDropdownMenuMask;
 
247
                goto AppliedFix;
241
248
            }
242
249
        }
243
250
    }
244
251
 
245
252
    /* FIXME: Basic hack to get Java windows working correctly. */
246
 
    if ((w->wmType == newWmType) && workaroundsGetJavaFix (d) && w->resName)
 
253
    if (workaroundsGetJavaFix (d) && w->resName)
247
254
    {
248
255
        if ((strcmp (w->resName, "sun-awt-X11-XMenuWindow") == 0) ||
249
256
            (strcmp (w->resName, "sun-awt-X11-XWindowPeer") == 0))
250
257
        {
251
258
            newWmType = CompWindowTypeDropdownMenuMask;
 
259
            goto AppliedFix;
252
260
        }
253
261
        else if (strcmp (w->resName, "sun-awt-X11-XDialogPeer") == 0)
254
262
        {
255
263
            newWmType = CompWindowTypeDialogMask;
 
264
            goto AppliedFix;
256
265
        }
257
266
        else if (strcmp (w->resName, "sun-awt-X11-XFramePeer") == 0)
258
267
        {
259
268
            newWmType = CompWindowTypeNormalMask;
 
269
            goto AppliedFix;
260
270
        }
261
271
    }
262
272
 
263
 
    if ((newWmType == w->wmType) && workaroundsGetQtFix (d))
 
273
    if (workaroundsGetQtFix (d))
264
274
    {
265
275
        char *windowRole;
266
276
 
271
281
            if ((strcmp (windowRole, "toolTipTip") == 0) ||
272
282
                (strcmp (windowRole, "qtooltip_label") == 0))
273
283
            {
 
284
                free (windowRole);
274
285
                newWmType = CompWindowTypeTooltipMask;
 
286
                goto AppliedFix;
275
287
            }
276
 
 
277
 
            free (windowRole);
 
288
            else
 
289
            {
 
290
                free (windowRole);
 
291
            }
278
292
        }
279
293
 
280
294
        /* fix Qt transients - FIXME: is there a better way to detect them? */
281
 
        if (w->wmType == newWmType)
282
 
        {
283
 
            if (!w->resName && w->attrib.override_redirect &&
284
 
                (w->attrib.class == InputOutput) &&
285
 
                (w->wmType == CompWindowTypeUnknownMask))
286
 
            {
287
 
                newWmType = CompWindowTypeDropdownMenuMask;
288
 
            }
 
295
        if (!w->resName && w->attrib.override_redirect &&
 
296
            (w->attrib.class == InputOutput) &&
 
297
            (w->wmType == CompWindowTypeUnknownMask))
 
298
        {
 
299
            newWmType = CompWindowTypeDropdownMenuMask;
 
300
            goto AppliedFix;
289
301
        }
290
302
    }
291
303
 
 
304
AppliedFix:
292
305
    if (newWmType != w->wmType)
293
306
    {
294
307
        WORKAROUNDS_WINDOW (w);
306
319
        workaroundsFixupFullscreen (w);
307
320
}
308
321
 
309
 
static Bool
310
 
workaroundsUpdateTimeout (void *closure)
311
 
{
312
 
    CompWindow *w = (CompWindow *) closure;
313
 
 
314
 
    WORKAROUNDS_WINDOW (w);
315
 
 
316
 
    workaroundsUpdateSticky (w);
317
 
    workaroundsDoFixes (w);
318
 
 
319
 
    ww->updateHandle = 0;
320
 
 
321
 
    return FALSE;
322
 
}
323
 
 
324
322
static void
325
323
workaroundsDisplayOptionChanged (CompDisplay               *d,
326
324
                                 CompOption                *opt,
342
340
 
343
341
    WORKAROUNDS_DISPLAY (d);
344
342
 
 
343
    switch (event->type) {
 
344
    case ConfigureRequest:
 
345
        w = findWindowAtDisplay (d, event->xconfigurerequest.window);
 
346
        if (w)
 
347
        {
 
348
            WORKAROUNDS_WINDOW (w);
 
349
 
 
350
            if (ww->madeFullscreen)
 
351
                w->state &= ~CompWindowStateFullscreenMask;
 
352
        }
 
353
        break;
 
354
    case MapRequest:
 
355
        w = findWindowAtDisplay (d, event->xmaprequest.window);
 
356
        if (w)
 
357
        {
 
358
            workaroundsUpdateSticky (w);
 
359
            workaroundsDoFixes (w);
 
360
        }
 
361
        break;
 
362
    case MapNotify:
 
363
        w = findWindowAtDisplay (d, event->xmap.window);
 
364
        if (w && w->attrib.override_redirect)
 
365
            workaroundsDoFixes (w);
 
366
        break;
 
367
    }
 
368
 
345
369
    UNWRAP (wd, d, handleEvent);
346
370
    (*d->handleEvent) (d, event);
347
371
    WRAP (wd, d, handleEvent, workaroundsHandleEvent);
348
372
 
349
373
    switch (event->type) {
 
374
    case ConfigureRequest:
 
375
        w = findWindowAtDisplay (d, event->xconfigurerequest.window);
 
376
        if (w)
 
377
        {
 
378
            WORKAROUNDS_WINDOW (w);
 
379
 
 
380
            if (ww->madeFullscreen)
 
381
                w->state |= CompWindowStateFullscreenMask;
 
382
        }
 
383
        break;
350
384
    case ClientMessage:
351
385
        if (event->xclient.message_type == d->winDesktopAtom)
352
386
        {
356
390
        }
357
391
        break;
358
392
    case PropertyNotify:
359
 
        if (event->xproperty.atom == XA_WM_CLASS)
 
393
        if ((event->xproperty.atom == XA_WM_CLASS) ||
 
394
            (event->xproperty.atom == d->winTypeAtom))
360
395
        {
361
396
            w = findWindowAtDisplay (d, event->xproperty.window);
362
397
            if (w)
476
511
    ww->madeSticky = FALSE;
477
512
    ww->adjustedWinType = FALSE;
478
513
    ww->isFullscreen = FALSE;
 
514
    ww->madeFullscreen = FALSE;
479
515
 
480
516
    w->privates[ws->windowPrivateIndex].ptr = ww;
481
517
 
482
 
    ww->updateHandle = compAddTimeout (0, workaroundsUpdateTimeout, (void *) w);
483
 
 
484
518
    return TRUE;
485
519
}
486
520
 
500
534
        setWindowState (w->screen->display,
501
535
                        w->state & ~CompWindowStateStickyMask, w->id);
502
536
 
503
 
    if (ww->updateHandle)
504
 
        compRemoveTimeout (ww->updateHandle);
505
 
 
506
537
    free (ww);
507
538
}
508
539