meta-window-actor.c 76.7 KB
Newer Older
1 2
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */

3 4 5 6 7 8
/**
 * SECTION:meta-window-actor
 * @title: MetaWindowActor
 * @short_description: An actor representing a top-level window in the scene graph
 */

9 10
#include <config.h>

11 12
#include <math.h>

13 14 15 16 17
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrender.h>

#include <clutter/x11/clutter-x11.h>
18
#include <cogl/cogl-texture-pixmap-x11.h>
19
#include <gdk/gdk.h> /* for gdk_rectangle_union() */
20
#include <string.h>
21

22 23
#include <meta/display.h>
#include <meta/errors.h>
24
#include "frame.h"
25
#include <meta/window.h>
26
#include <meta/meta-shaped-texture.h>
27 28 29
#include "xprops.h"

#include "compositor-private.h"
30
#include "meta-shadow-factory-private.h"
31
#include "meta-window-actor-private.h"
32
#include "meta-texture-rectangle.h"
33
#include "region-utils.h"
34
#include "monitor-private.h"
35
#include "meta-cullable.h"
36

37
enum {
38
  POSITION_CHANGED,
39 40 41 42 43 44 45
  SIZE_CHANGED,
  LAST_SIGNAL
};

static guint signals[LAST_SIGNAL] = {0};


46
struct _MetaWindowActorPrivate
47 48 49 50 51
{
  MetaWindow       *window;
  MetaScreen       *screen;

  ClutterActor     *actor;
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

  /* MetaShadowFactory only caches shadows that are actually in use;
   * to avoid unnecessary recomputation we do two things: 1) we store
   * both a focused and unfocused shadow for the window. If the window
   * doesn't have different focused and unfocused shadow parameters,
   * these will be the same. 2) when the shadow potentially changes we
   * don't immediately unreference the old shadow, we just flag it as
   * dirty and recompute it when we next need it (recompute_focused_shadow,
   * recompute_unfocused_shadow.) Because of our extraction of
   * size-invariant window shape, we'll often find that the new shadow
   * is the same as the old shadow.
   */
  MetaShadow       *focused_shadow;
  MetaShadow       *unfocused_shadow;

67 68 69 70
  Pixmap            back_pixmap;

  Damage            damage;

71
  /* A region that matches the shape of the window, including frame bounds */
Owen W. Taylor's avatar
Owen W. Taylor committed
72
  cairo_region_t   *shape_region;
73 74
  /* The region we should clip to when painting the shadow */
  cairo_region_t   *shadow_clip;
75

76 77 78
  /* The region that is visible, used to optimize out redraws */
  cairo_region_t   *unobscured_region;

79 80 81
  guint              send_frame_messages_timer;
  gint64             frame_drawn_time;

82 83 84
  /* Extracted size-invariant shape used for shadows */
  MetaWindowShape  *shadow_shape;

85 86 87
  gint              last_width;
  gint              last_height;

88
  gint              freeze_count;
89

90
  char *            shadow_class;
91

92 93 94 95 96 97 98 99 100 101 102
  /*
   * These need to be counters rather than flags, since more plugins
   * can implement same effect; the practicality of stacking effects
   * might be dubious, but we have to at least handle it correctly.
   */
  gint              minimize_in_progress;
  gint              maximize_in_progress;
  gint              unmaximize_in_progress;
  gint              map_in_progress;
  gint              destroy_in_progress;

103 104
  /* List of FrameData for recent frames */
  GList            *frames;
105

106 107
  guint		    visible                : 1;
  guint		    mapped                 : 1;
108 109 110 111
  guint		    argb32                 : 1;
  guint		    disposed               : 1;
  guint             redecorating           : 1;

112
  guint		    needs_damage_all       : 1;
113
  guint		    received_damage        : 1;
114
  guint             repaint_scheduled      : 1;
115

116 117 118 119
  /* If set, the client needs to be sent a _NET_WM_FRAME_DRAWN
   * client message using the most recent frame in ->frames */
  guint             needs_frame_drawn      : 1;

120
  guint		    needs_pixmap           : 1;
121
  guint             needs_reshape          : 1;
122 123
  guint             recompute_focused_shadow   : 1;
  guint             recompute_unfocused_shadow : 1;
124
  guint		    size_changed           : 1;
125
  guint             updates_frozen         : 1;
126 127 128 129 130

  guint		    needs_destroy	   : 1;

  guint             no_shadow              : 1;

131
  guint             unredirected           : 1;
132 133 134 135

  /* This is used to detect fullscreen windows that need to be unredirected */
  guint             full_damage_frames_count;
  guint             does_full_damage  : 1;
136 137
};

138 139 140 141 142 143 144 145 146
typedef struct _FrameData FrameData;

struct _FrameData
{
  int64_t frame_counter;
  guint64 sync_request_serial;
  gint64 frame_drawn_time;
};

147 148
enum
{
149 150
  PROP_META_WINDOW = 1,
  PROP_NO_SHADOW,
151
  PROP_SHADOW_CLASS
152 153
};

154 155 156 157 158 159 160 161 162 163 164
static void meta_window_actor_dispose    (GObject *object);
static void meta_window_actor_finalize   (GObject *object);
static void meta_window_actor_constructed (GObject *object);
static void meta_window_actor_set_property (GObject       *object,
                                            guint         prop_id,
                                            const GValue *value,
                                            GParamSpec   *pspec);
static void meta_window_actor_get_property (GObject      *object,
                                            guint         prop_id,
                                            GValue       *value,
                                            GParamSpec   *pspec);
165

166
static void meta_window_actor_paint (ClutterActor *actor);
167

168 169
static gboolean meta_window_actor_get_paint_volume (ClutterActor       *actor,
                                                    ClutterPaintVolume *volume);
170

171

172 173
static void     meta_window_actor_detach     (MetaWindowActor *self);
static gboolean meta_window_actor_has_shadow (MetaWindowActor *self);
174

175 176
static void meta_window_actor_handle_updates (MetaWindowActor *self);

177 178
static void check_needs_reshape (MetaWindowActor *self);

179 180 181 182 183 184
static void do_send_frame_drawn (MetaWindowActor *self, FrameData *frame);
static void do_send_frame_timings (MetaWindowActor  *self,
                                   FrameData        *frame,
                                   gint             refresh_interval,
                                   gint64           presentation_time);

185 186 187 188
static void cullable_iface_init (MetaCullableInterface *iface);

G_DEFINE_TYPE_WITH_CODE (MetaWindowActor, meta_window_actor, CLUTTER_TYPE_ACTOR,
                         G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init));
189

190 191 192 193 194 195
static void
frame_data_free (FrameData *frame)
{
  g_slice_free (FrameData, frame);
}

196
static void
197
meta_window_actor_class_init (MetaWindowActorClass *klass)
198 199
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
200
  ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
201 202
  GParamSpec   *pspec;

203
  g_type_class_add_private (klass, sizeof (MetaWindowActorPrivate));
204

205 206 207 208 209
  object_class->dispose      = meta_window_actor_dispose;
  object_class->finalize     = meta_window_actor_finalize;
  object_class->set_property = meta_window_actor_set_property;
  object_class->get_property = meta_window_actor_get_property;
  object_class->constructed  = meta_window_actor_constructed;
210

211
  actor_class->paint = meta_window_actor_paint;
212
  actor_class->get_paint_volume = meta_window_actor_get_paint_volume;
213

214 215 216 217
  pspec = g_param_spec_object ("meta-window",
                               "MetaWindow",
                               "The displayed MetaWindow",
                               META_TYPE_WINDOW,
218
                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
219 220

  g_object_class_install_property (object_class,
221
                                   PROP_META_WINDOW,
222 223 224 225 226 227
                                   pspec);

  pspec = g_param_spec_boolean ("no-shadow",
                                "No shadow",
                                "Do not add shaddow to this window",
                                FALSE,
228
                                G_PARAM_READWRITE);
229 230

  g_object_class_install_property (object_class,
231
                                   PROP_NO_SHADOW,
232
                                   pspec);
233

234 235 236 237 238
  pspec = g_param_spec_string ("shadow-class",
                               "Name of the shadow class for this window.",
                               "NULL means to use the default shadow class for this window type",
                               NULL,
                               G_PARAM_READWRITE);
239 240

  g_object_class_install_property (object_class,
241
                                   PROP_SHADOW_CLASS,
242
                                   pspec);
243

244 245 246 247
  signals[POSITION_CHANGED] =
    g_signal_new ("position-changed",
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
248
                  0, NULL, NULL, NULL,
249
                  G_TYPE_NONE, 0);
250 251 252 253
  signals[SIZE_CHANGED] =
    g_signal_new ("size-changed",
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
254
                  0, NULL, NULL, NULL,
255
                  G_TYPE_NONE, 0);
256 257 258
}

static void
259
meta_window_actor_init (MetaWindowActor *self)
260
{
261
  MetaWindowActorPrivate *priv;
262 263

  priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
264 265
						   META_TYPE_WINDOW_ACTOR,
						   MetaWindowActorPrivate);
266
  priv->shadow_class = NULL;
267 268 269
}

static void
270 271 272
window_decorated_notify (MetaWindow *mw,
                         GParamSpec *arg1,
                         gpointer    data)
273
{
274 275 276 277 278
  MetaWindowActor        *self     = META_WINDOW_ACTOR (data);
  MetaWindowActorPrivate *priv     = self->priv;
  MetaScreen             *screen   = priv->screen;
  MetaDisplay            *display  = meta_screen_get_display (screen);
  Display                *xdisplay = meta_display_get_xdisplay (display);
279 280 281 282 283 284 285

  /*
   * Basically, we have to reconstruct the the internals of this object
   * from scratch, as everything has changed.
   */
  priv->redecorating = TRUE;

286
  meta_window_actor_detach (self);
287 288 289 290 291 292 293 294 295

  /*
   * First of all, clean up any resources we are currently using and will
   * be replacing.
   */
  if (priv->damage != None)
    {
      meta_error_trap_push (display);
      XDamageDestroy (xdisplay, priv->damage);
296
      meta_error_trap_pop (display);
297 298 299 300 301 302
      priv->damage = None;
    }

  /*
   * Recreate the contents.
   */
303
  meta_window_actor_constructed (G_OBJECT (self));
304 305
}

306 307 308 309 310 311 312 313
static void
window_appears_focused_notify (MetaWindow *mw,
                               GParamSpec *arg1,
                               gpointer    data)
{
  clutter_actor_queue_redraw (CLUTTER_ACTOR (data));
}

314 315 316 317 318 319 320 321 322
static gboolean
is_non_opaque (MetaWindowActor *self)
{
  MetaWindowActorPrivate *priv = self->priv;
  MetaWindow *window = priv->window;

  return priv->argb32 || (window->opacity != 0xFF);
}

323
static void
324
meta_window_actor_constructed (GObject *object)
325
{
326 327
  MetaWindowActor        *self     = META_WINDOW_ACTOR (object);
  MetaWindowActorPrivate *priv     = self->priv;
328
  MetaWindow             *window   = priv->window;
329 330
  MetaScreen             *screen   = meta_window_get_screen (window);
  MetaDisplay            *display  = meta_screen_get_display (screen);
331 332
  Display                *xdisplay = meta_display_get_xdisplay (display);
  XRenderPictFormat      *format;
333 334 335
  Window                  xwindow;

  xwindow = meta_window_get_toplevel_xwindow (window);
336

337
  priv->screen = screen;
338 339
  priv->damage = XDamageCreate (xdisplay, xwindow,
                                XDamageReportBoundingBox);
340

341
  format = XRenderFindVisualFormat (xdisplay, window->xvisual);
342 343 344 345 346 347

  if (format && format->type == PictTypeDirect && format->direct.alphaMask)
    priv->argb32 = TRUE;

  if (!priv->actor)
    {
348
      priv->actor = meta_shaped_texture_new ();
349

350
      clutter_actor_add_child (CLUTTER_ACTOR (self), priv->actor);
351

352 353 354 355 356 357 358 359
      /*
       * Since we are holding a pointer to this actor independently of the
       * ClutterContainer internals, and provide a public API to access it,
       * add a reference here, so that if someone is messing about with us
       * via the container interface, we do not end up with a dangling pointer.
       * We will release it in dispose().
       */
      g_object_ref (priv->actor);
360 361
    }

362
  meta_window_actor_update_opacity (self);
363

364 365
  /* Start off with an empty shape region to maintain the invariant
   * that it's always set */
366
  priv->shape_region = cairo_region_create ();
367 368 369
}

static void
370
meta_window_actor_dispose (GObject *object)
371
{
372 373 374 375 376 377
  MetaWindowActor        *self = META_WINDOW_ACTOR (object);
  MetaWindowActorPrivate *priv = self->priv;
  MetaScreen             *screen;
  MetaDisplay            *display;
  Display                *xdisplay;
  MetaCompScreen         *info;
378 379 380 381 382 383 384 385 386 387 388

  if (priv->disposed)
    return;

  priv->disposed = TRUE;

  screen   = priv->screen;
  display  = meta_screen_get_display (screen);
  xdisplay = meta_display_get_xdisplay (display);
  info     = meta_screen_get_compositor_data (screen);

389
  meta_window_actor_detach (self);
390

391 392 393 394 395 396
  if (priv->send_frame_messages_timer != 0)
    {
      g_source_remove (priv->send_frame_messages_timer);
      priv->send_frame_messages_timer = 0;
    }

397
  g_clear_pointer (&priv->unobscured_region, cairo_region_destroy);
398 399
  g_clear_pointer (&priv->shape_region, cairo_region_destroy);
  g_clear_pointer (&priv->shadow_clip, cairo_region_destroy);
400

401 402 403 404
  g_clear_pointer (&priv->shadow_class, g_free);
  g_clear_pointer (&priv->focused_shadow, meta_shadow_unref);
  g_clear_pointer (&priv->unfocused_shadow, meta_shadow_unref);
  g_clear_pointer (&priv->shadow_shape, meta_window_shape_unref);
405

406 407 408 409
  if (priv->damage != None)
    {
      meta_error_trap_push (display);
      XDamageDestroy (xdisplay, priv->damage);
410
      meta_error_trap_pop (display);
411 412 413 414 415 416

      priv->damage = None;
    }

  info->windows = g_list_remove (info->windows, (gconstpointer) self);

417
  g_clear_object (&priv->window);
418

419 420 421
  /*
   * Release the extra reference we took on the actor.
   */
422
  g_clear_object (&priv->actor);
423

424
  G_OBJECT_CLASS (meta_window_actor_parent_class)->dispose (object);
425 426 427
}

static void
428
meta_window_actor_finalize (GObject *object)
429
{
430 431
  MetaWindowActor        *self = META_WINDOW_ACTOR (object);
  MetaWindowActorPrivate *priv = self->priv;
432

433
  g_list_free_full (priv->frames, (GDestroyNotify) frame_data_free);
434

435
  G_OBJECT_CLASS (meta_window_actor_parent_class)->finalize (object);
436 437 438
}

static void
439 440 441 442
meta_window_actor_set_property (GObject      *object,
                                guint         prop_id,
                                const GValue *value,
                                GParamSpec   *pspec)
443
{
444 445
  MetaWindowActor        *self   = META_WINDOW_ACTOR (object);
  MetaWindowActorPrivate *priv = self->priv;
446 447 448

  switch (prop_id)
    {
449
    case PROP_META_WINDOW:
450
      priv->window = g_value_dup_object (value);
451 452 453 454 455

      g_signal_connect_object (priv->window, "notify::decorated",
                               G_CALLBACK (window_decorated_notify), self, 0);
      g_signal_connect_object (priv->window, "notify::appears-focused",
                               G_CALLBACK (window_appears_focused_notify), self, 0);
456
      break;
457
    case PROP_NO_SHADOW:
458 459 460
      {
        gboolean newv = g_value_get_boolean (value);

461
        if (newv == priv->no_shadow)
462 463 464 465
          return;

        priv->no_shadow = newv;

466
        meta_window_actor_invalidate_shadow (self);
467 468
      }
      break;
469
    case PROP_SHADOW_CLASS:
470
      {
471
        const char *newv = g_value_get_string (value);
472

473
        if (g_strcmp0 (newv, priv->shadow_class) == 0)
474
          return;
475

476 477
        g_free (priv->shadow_class);
        priv->shadow_class = g_strdup (newv);
478

479
        meta_window_actor_invalidate_shadow (self);
480 481 482 483 484 485 486 487 488
      }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
489 490 491 492
meta_window_actor_get_property (GObject      *object,
                                guint         prop_id,
                                GValue       *value,
                                GParamSpec   *pspec)
493
{
494
  MetaWindowActorPrivate *priv = META_WINDOW_ACTOR (object)->priv;
495 496 497

  switch (prop_id)
    {
498
    case PROP_META_WINDOW:
499 500
      g_value_set_object (value, priv->window);
      break;
501
    case PROP_NO_SHADOW:
502 503
      g_value_set_boolean (value, priv->no_shadow);
      break;
504 505
    case PROP_SHADOW_CLASS:
      g_value_set_string (value, priv->shadow_class);
506
      break;
507 508 509 510 511 512
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
static const char *
meta_window_actor_get_shadow_class (MetaWindowActor *self)
{
  MetaWindowActorPrivate *priv = self->priv;

  if (priv->shadow_class != NULL)
    return priv->shadow_class;
  else
    {
      MetaWindowType window_type = meta_window_get_window_type (priv->window);

      switch (window_type)
        {
        case META_WINDOW_DROPDOWN_MENU:
          return "dropdown-menu";
        case META_WINDOW_POPUP_MENU:
          return "popup-menu";
        default:
          {
            MetaFrameType frame_type = meta_window_get_frame_type (priv->window);
            return meta_frame_type_to_string (frame_type);
          }
        }
    }
}

static void
meta_window_actor_get_shadow_params (MetaWindowActor  *self,
                                     gboolean          appears_focused,
                                     MetaShadowParams *params)
{
  const char *shadow_class = meta_window_actor_get_shadow_class (self);

  meta_shadow_factory_get_params (meta_shadow_factory_get_default (),
                                  shadow_class, appears_focused,
                                  params);
}

551
void
552 553 554 555 556
meta_window_actor_get_shape_bounds (MetaWindowActor       *self,
                                    cairo_rectangle_int_t *bounds)
{
  MetaWindowActorPrivate *priv = self->priv;

557
  cairo_region_get_extents (priv->shape_region, bounds);
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
}

static void
meta_window_actor_get_shadow_bounds (MetaWindowActor       *self,
                                     gboolean               appears_focused,
                                     cairo_rectangle_int_t *bounds)
{
  MetaWindowActorPrivate *priv = self->priv;
  MetaShadow *shadow = appears_focused ? priv->focused_shadow : priv->unfocused_shadow;
  cairo_rectangle_int_t shape_bounds;
  MetaShadowParams params;

  meta_window_actor_get_shape_bounds (self, &shape_bounds);
  meta_window_actor_get_shadow_params (self, appears_focused, &params);

  meta_shadow_get_bounds (shadow,
                          params.x_offset + shape_bounds.x,
                          params.y_offset + shape_bounds.y,
                          shape_bounds.width,
                          shape_bounds.height,
                          bounds);
579 580
}

581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
/* If we have an ARGB32 window that we decorate with a frame, it's
 * probably something like a translucent terminal - something where
 * the alpha channel represents transparency rather than a shape.  We
 * don't want to show the shadow through the translucent areas since
 * the shadow is wrong for translucent windows (it should be
 * translucent itself and colored), and not only that, will /look/
 * horribly wrong - a misplaced big black blob. As a hack, what we
 * want to do is just draw the shadow as normal outside the frame, and
 * inside the frame draw no shadow.  This is also not even close to
 * the right result, but looks OK. We also apply this approach to
 * windows set to be partially translucent with _NET_WM_WINDOW_OPACITY.
 */
static gboolean
clip_shadow_under_window (MetaWindowActor *self)
{
  MetaWindowActorPrivate *priv = self->priv;

598
  return is_non_opaque (self) && priv->window->frame;
599 600
}

601 602 603 604 605
static void
meta_window_actor_paint (ClutterActor *actor)
{
  MetaWindowActor *self = META_WINDOW_ACTOR (actor);
  MetaWindowActorPrivate *priv = self->priv;
606 607
  gboolean appears_focused = meta_window_appears_focused (priv->window);
  MetaShadow *shadow = appears_focused ? priv->focused_shadow : priv->unfocused_shadow;
608

609 610 611 612 613 614 615 616 617 618
 /* This window got damage when obscured; we set up a timer
  * to send frame completion events, but since we're drawing
  * the window now (for some other reason) cancel the timer
  * and send the completion events normally */
  if (priv->send_frame_messages_timer != 0)
    {
      g_source_remove (priv->send_frame_messages_timer);
      priv->send_frame_messages_timer = 0;
    }

619
  if (shadow != NULL)
620
    {
621 622
      MetaShadowParams params;
      cairo_rectangle_int_t shape_bounds;
623
      cairo_region_t *clip = priv->shadow_clip;
624
      MetaWindow *window = priv->window;
625 626 627 628

      meta_window_actor_get_shape_bounds (self, &shape_bounds);
      meta_window_actor_get_shadow_params (self, appears_focused, &params);

629 630 631 632 633 634 635 636 637 638 639 640 641 642
      /* The frame bounds are already subtracted from priv->shadow_clip
       * if that exists.
       */
      if (!clip && clip_shadow_under_window (self))
        {
          cairo_region_t *frame_bounds = meta_window_get_frame_bounds (priv->window);
          cairo_rectangle_int_t bounds;

          meta_window_actor_get_shadow_bounds (self, appears_focused, &bounds);
          clip = cairo_region_create_rectangle (&bounds);

          cairo_region_subtract (clip, frame_bounds);
        }

643 644 645 646 647
      meta_shadow_paint (shadow,
                         params.x_offset + shape_bounds.x,
                         params.y_offset + shape_bounds.y,
                         shape_bounds.width,
                         shape_bounds.height,
648
                         (clutter_actor_get_paint_opacity (actor) * params.opacity * window->opacity) / (255 * 255),
649 650 651 652 653
                         clip,
                         clip_shadow_under_window (self)); /* clip_strictly - not just as an optimization */

      if (clip && clip != priv->shadow_clip)
        cairo_region_destroy (clip);
654 655 656 657 658
    }

  CLUTTER_ACTOR_CLASS (meta_window_actor_parent_class)->paint (actor);
}

659 660 661 662 663 664 665 666 667 668 669 670
static gboolean
meta_window_actor_get_paint_volume (ClutterActor       *actor,
                                    ClutterPaintVolume *volume)
{
  MetaWindowActor *self = META_WINDOW_ACTOR (actor);
  MetaWindowActorPrivate *priv = self->priv;
  cairo_rectangle_int_t bounds;
  gboolean appears_focused = meta_window_appears_focused (priv->window);
  ClutterVertex origin;

  /* The paint volume is computed before paint functions are called
   * so our bounds might not be updated yet. Force an update. */
671
  meta_window_actor_handle_updates (self);
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689

  meta_window_actor_get_shape_bounds (self, &bounds);

  if (appears_focused ? priv->focused_shadow : priv->unfocused_shadow)
    {
      cairo_rectangle_int_t shadow_bounds;

      /* We could compute an full clip region as we do for the window
       * texture, but the shadow is relatively cheap to draw, and
       * a little more complex to clip, so we just catch the case where
       * the shadow is completely obscured and doesn't need to be drawn
       * at all.
       */

      meta_window_actor_get_shadow_bounds (self, appears_focused, &shadow_bounds);
      gdk_rectangle_union (&bounds, &shadow_bounds, &bounds);
    }

690
  if (priv->unobscured_region)
691 692 693 694 695
    {
      cairo_rectangle_int_t unobscured_bounds;
      cairo_region_get_extents (priv->unobscured_region, &unobscured_bounds);
      gdk_rectangle_intersect (&bounds, &unobscured_bounds, &bounds);
    }
696

697 698 699 700 701 702 703 704 705 706 707
  origin.x = bounds.x;
  origin.y = bounds.y;
  origin.z = 0.0f;
  clutter_paint_volume_set_origin (volume, &origin);

  clutter_paint_volume_set_width (volume, bounds.width);
  clutter_paint_volume_set_height (volume, bounds.height);

  return TRUE;
}

708
static gboolean
709
meta_window_actor_has_shadow (MetaWindowActor *self)
710
{
711
  MetaWindowActorPrivate *priv = self->priv;
712
  MetaWindowType window_type = meta_window_get_window_type (priv->window);
713 714 715 716

  if (priv->no_shadow)
    return FALSE;

717 718 719 720 721 722 723
  /* Leaving out shadows for maximized and fullscreen windows is an effeciency
   * win and also prevents the unsightly effect of the shadow of maximized
   * window appearing on an adjacent window */
  if ((meta_window_get_maximized (priv->window) == (META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL)) ||
      meta_window_is_fullscreen (priv->window))
    return FALSE;

724 725 726 727 728 729 730
  /*
   * If we have two snap-tiled windows, we don't want the shadow to obstruct
   * the other window.
   */
  if (meta_window_get_tile_match (priv->window))
    return FALSE;

731 732
  /*
   * Always put a shadow around windows with a frame - This should override
733
   * the restriction about not putting a shadow around ARGB windows.
734
   */
735 736
  if (meta_window_get_frame (priv->window))
    return TRUE;
737 738

  /*
739 740
   * Do not add shadows to non-opaque windows; eventually we should generate
   * a shadow from the input shape for such windows.
741
   */
742
  if (is_non_opaque (self))
743
    return FALSE;
744 745 746 747

  /*
   * Add shadows to override redirect windows (e.g., Gtk menus).
   */
748
  if (priv->window->override_redirect)
749
    return TRUE;
750 751 752 753

  /*
   * Don't put shadow around DND icon windows
   */
754 755
  if (window_type == META_WINDOW_DND ||
      window_type == META_WINDOW_DESKTOP)
756
    return FALSE;
757

758
  if (window_type == META_WINDOW_MENU
759
#if 0
760
      || window_type == META_WINDOW_DROPDOWN_MENU
761 762
#endif
      )
763
    return TRUE;
764 765

#if 0
766
  if (window_type == META_WINDOW_TOOLTIP)
767
    return TRUE;
768 769 770 771 772 773
#endif

  return FALSE;
}

/**
774
 * meta_window_actor_get_meta_window:
775
 * @self: a #MetaWindowActor
776
 *
777
 * Gets the #MetaWindow object that the the #MetaWindowActor is displaying
778
 *
779
 * Return value: (transfer none): the displayed #MetaWindow
780 781
 */
MetaWindow *
782
meta_window_actor_get_meta_window (MetaWindowActor *self)
783 784 785 786 787
{
  return self->priv->window;
}

/**
788
 * meta_window_actor_get_texture:
789
 * @self: a #MetaWindowActor
790 791 792
 *
 * Gets the ClutterActor that is used to display the contents of the window
 *
793
 * Return value: (transfer none): the #ClutterActor for the contents
794 795
 */
ClutterActor *
796
meta_window_actor_get_texture (MetaWindowActor *self)
797 798 799 800
{
  return self->priv->actor;
}

801 802
/**
 * meta_window_actor_is_destroyed:
803
 * @self: a #MetaWindowActor
804 805 806 807 808 809 810 811 812 813 814
 *
 * Gets whether the X window that the actor was displaying has been destroyed
 *
 * Return value: %TRUE when the window is destroyed, otherwise %FALSE
 */
gboolean
meta_window_actor_is_destroyed (MetaWindowActor *self)
{
  return self->priv->disposed;
}

815
gboolean
816
meta_window_actor_is_override_redirect (MetaWindowActor *self)
817
{
818
  return meta_window_is_override_redirect (self->priv->window);
819 820
}

821
/**
822 823
 * meta_window_actor_get_workspace:
 * @self: #MetaWindowActor
824 825 826 827 828 829 830 831 832
 *
 * Returns the index of workspace on which this window is located; if the
 * window is sticky, or is not currently located on any workspace, returns -1.
 * This function is deprecated  and should not be used in newly written code;
 * meta_window_get_workspace() instead.
 *
 * Return value: (transfer none): index of workspace on which this window is
 * located.
 */
833
gint
834
meta_window_actor_get_workspace (MetaWindowActor *self)
835
{
836 837
  MetaWindowActorPrivate *priv;
  MetaWorkspace          *workspace;
838 839 840 841 842 843 844 845 846 847 848

  if (!self)
    return -1;

  priv = self->priv;

  if (!priv->window || meta_window_is_on_all_workspaces (priv->window))
    return -1;

  workspace = meta_window_get_workspace (priv->window);

849 850 851
  if (!workspace)
    return -1;

852 853 854 855
  return meta_workspace_index (workspace);
}

gboolean
856
meta_window_actor_showing_on_its_workspace (MetaWindowActor *self)
857 858 859 860 861 862 863 864 865 866 867
{
  if (!self)
    return FALSE;

  /* If override redirect: */
  if (!self->priv->window)
    return TRUE;

  return meta_window_showing_on_its_workspace (self->priv->window);
}

868
static void
869
meta_window_actor_freeze (MetaWindowActor *self)
870 871 872 873
{
  self->priv->freeze_count++;
}

874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
static
gboolean send_frame_messages_timeout (gpointer data)
{
  MetaWindowActor *self = (MetaWindowActor *) data;
  MetaWindowActorPrivate *priv = self->priv;
  FrameData *frame = g_slice_new0 (FrameData);

  frame->sync_request_serial = priv->window->sync_request_serial;

  do_send_frame_drawn (self, frame);
  do_send_frame_timings (self, frame, 0, 0);

  priv->needs_frame_drawn = FALSE;
  priv->send_frame_messages_timer = 0;
  frame_data_free (frame);

  return FALSE;
}

static void
queue_send_frame_messages_timeout (MetaWindowActor *self)
{
  MetaWindowActorPrivate *priv = self->priv;
  MetaScreen  *screen  = priv->screen;
  MetaDisplay *display = meta_screen_get_display (screen);
  gint64 current_time = meta_compositor_monotonic_time_to_server_time (display, g_get_monotonic_time ());
  MetaMonitorManager *monitor_manager = meta_monitor_manager_get ();
  MetaWindow *window = priv->window;

  MetaOutput *outputs;
  guint n_outputs, i;
  float refresh_rate = 60.0f;
  gint interval, offset;

  outputs = meta_monitor_manager_get_outputs (monitor_manager, &n_outputs);
  for (i = 0; i < n_outputs; i++)
    {
      if (outputs[i].output_id == window->monitor->output_id && outputs[i].crtc)
        {
          refresh_rate = outputs[i].crtc->current_mode->refresh_rate;
          break;
        }
    }

  interval = (int)(1000000 / refresh_rate) * 6;
919
  offset = MAX (0, priv->frame_drawn_time + interval - current_time) / 1000;
920 921 922 923 924 925 926 927

 /* The clutter master clock source has already been added with META_PRIORITY_REDRAW,
  * so the timer will run *after* the clutter frame handling, if a frame is ready
  * to be drawn when the timer expires.
  */
  priv->send_frame_messages_timer = g_timeout_add_full (META_PRIORITY_REDRAW, offset, send_frame_messages_timeout, self, NULL);
}

928
static void
929
meta_window_actor_damage_all (MetaWindowActor *self)
930
{
931
  MetaWindowActorPrivate *priv = self->priv;
932
  CoglTexture *texture;
933
  gboolean redraw_queued;
934 935 936 937

  if (!priv->needs_damage_all)
    return;

938
  texture = meta_shaped_texture_get_texture (META_SHAPED_TEXTURE (priv->actor));
939

940 941 942
  if (!priv->mapped || priv->needs_pixmap)
    return;

943 944 945 946 947 948 949 950
  redraw_queued = meta_shaped_texture_update_area (META_SHAPED_TEXTURE (priv->actor),
                                                   0, 0,
                                                   cogl_texture_get_width (texture),
                                                   cogl_texture_get_height (texture),
                                                   clutter_actor_has_mapped_clones (priv->actor) ?
                                                   NULL : priv->unobscured_region);

  priv->repaint_scheduled = priv->repaint_scheduled  || redraw_queued;
951 952 953 954 955

  priv->needs_damage_all = FALSE;
}

static void
956
meta_window_actor_thaw (MetaWindowActor *self)
957 958 959 960 961 962 963 964 965 966 967 968 969
{
  self->priv->freeze_count--;

  if (G_UNLIKELY (self->priv->freeze_count < 0))
    {
      g_warning ("Error in freeze/thaw accounting.");
      self->priv->freeze_count = 0;
      return;
    }

  if (self->priv->freeze_count)
    return;

970 971
  /* We sometimes ignore moves and resizes on frozen windows */
  meta_window_actor_sync_actor_geometry (self, FALSE);
972 973 974

  /* We do this now since we might be going right back into the
   * frozen state */
975
  meta_window_actor_handle_updates (self);
976

977 978 979 980
  /* Since we ignore damage events while a window is frozen for certain effects
   * we may need to issue an update_area() covering the whole pixmap if we
   * don't know what real damage has happened. */
  if (self->priv->needs_damage_all)
981
    meta_window_actor_damage_all (self);
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
}

void
meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
                                     gboolean         no_delay_frame)
{
  MetaWindowActorPrivate *priv = self->priv;
  FrameData *frame = g_slice_new0 (FrameData);

  priv->needs_frame_drawn = TRUE;

  frame->sync_request_serial = priv->window->sync_request_serial;

  priv->frames = g_list_prepend (priv->frames, frame);

  if (no_delay_frame)
    {
      ClutterActor *stage = clutter_actor_get_stage (CLUTTER_ACTOR (self));
      clutter_stage_skip_sync_delay (CLUTTER_STAGE (stage));
    }

  if (!priv->repaint_scheduled)
1004
    {
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
      gboolean is_obscured = FALSE;

      /* Find out whether the window is completly obscured */
      if (priv->unobscured_region)
        {
          cairo_region_t *unobscured_window_region;
          unobscured_window_region = cairo_region_copy (priv->shape_region);
          cairo_region_intersect (unobscured_window_region, priv->unobscured_region);
          is_obscured = cairo_region_is_empty (unobscured_window_region);
          cairo_region_destroy (unobscured_window_region);
        }

1017
      /* A frame was marked by the client without actually doing any
1018 1019
       * damage or any unobscured, or while we had the window frozen
       * (e.g. during an interactive resize.) We need to make sure that the
1020 1021
       * pre_paint/post_paint functions get called, enabling us to
       * send a _NET_WM_FRAME_DRAWN. We do a 1-pixel redraw to get
1022 1023
       * consistent timing with non-empty frames. If the window
       * is completely obscured we fire off the send_frame_messages timeout.
1024
       */
1025 1026 1027 1028 1029
      if (is_obscured)
        {
          queue_send_frame_messages_timeout (self);
        }
      else if (priv->mapped && !priv->needs_pixmap)
1030 1031
        {
          const cairo_rectangle_int_t clip = { 0, 0, 1, 1 };
1032 1033
          clutter_actor_queue_redraw_with_clip (priv->actor, &clip);
          priv->repaint_scheduled = TRUE;
1034 1035
        }
    }
1036 1037
}

1038
gboolean
1039
meta_window_actor_effect_in_progress (MetaWindowActor *self)
1040 1041 1042 1043 1044
{
  return (self->priv->minimize_in_progress ||
	  self->priv->maximize_in_progress ||
	  self->priv->unmaximize_in_progress ||
	  self->priv->map_in_progress ||
1045
	  self->priv->destroy_in_progress);
1046 1047
}

1048 1049 1050 1051 1052 1053
static gboolean
is_frozen (MetaWindowActor *self)
{
  return self->priv->freeze_count ? TRUE : FALSE;
}

1054
static void
1055
meta_window_actor_queue_create_pixmap (MetaWindowActor *self)
1056
{
1057
  MetaWindowActorPrivate *priv = self->priv;
1058

1059
  priv->needs_pixmap = TRUE;
1060

1061
  if (!priv->mapped)
1062 1063
    return;

1064 1065 1066
  if (is_frozen (self))
    return;

1067 1068 1069 1070 1071 1072 1073 1074
  /* This will cause the compositor paint function to be run
   * if the actor is visible or a clone of the actor is visible.
   * if the actor isn't visible in any way, then we don't
   * need to repair the window anyways, and can wait until
   * the stage is redrawn for some other reason
   *
   * The compositor paint function repairs all windows.
   */
1075
  clutter_actor_queue_redraw (priv->actor);
1076 1077
}

1078 1079 1080 1081 1082
static gboolean
is_freeze_thaw_effect (gulong event)
{
  switch (event)
  {
1083 1084 1085
  case META_PLUGIN_DESTROY:
  case META_PLUGIN_MAXIMIZE:
  case META_PLUGIN_UNMAXIMIZE:
1086 1087 1088 1089 1090 1091 1092
    return TRUE;
    break;
  default:
    return FALSE;
  }
}

1093
static gboolean
1094
start_simple_effect (MetaWindowActor *self,
1095 1096
                     gulong        event)
{
1097
  MetaWindowActorPrivate *priv = self->priv;
1098 1099
  MetaCompScreen *info = meta_screen_get_compositor_data (priv->screen);
  gint *counter = NULL;
1100
  gboolean use_freeze_thaw = FALSE;
1101 1102 1103 1104 1105 1106

  if (!info->plugin_mgr)
    return FALSE;

  switch (event)
  {
1107
  case META_PLUGIN_MINIMIZE:
1108 1109
    counter = &priv->minimize_in_progress;
    break;
1110
  case META_PLUGIN_MAP:
1111 1112
    counter = &priv->map_in_progress;
    break;
1113
  case META_PLUGIN_DESTROY:
1114 1115
    counter = &priv->destroy_in_progress;
    break;
1116 1117 1118
  case META_PLUGIN_UNMAXIMIZE:
  case META_PLUGIN_MAXIMIZE:
  case META_PLUGIN_SWITCH_WORKSPACE:
1119 1120 1121 1122 1123 1124
    g_assert_not_reached ();
    break;
  }

  g_assert (counter);

1125 1126 1127
  use_freeze_thaw = is_freeze_thaw_effect (event);

  if (use_freeze_thaw)
1128
    meta_window_actor_freeze (self);
1129

1130 1131
  (*counter)++;

1132 1133 1134
  if (!meta_plugin_manager_event_simple (info->plugin_mgr,
                                         self,
                                         event))
1135 1136
    {
      (*counter)--;
1137
      if (use_freeze_thaw)
1138
        meta_window_actor_thaw (self);
1139 1140 1141 1142 1143 1144 1145
      return FALSE;
    }

  return TRUE;
}

static void
1146
meta_window_actor_after_effects (MetaWindowActor *self)
1147
{
1148
  MetaWindowActorPrivate *priv = self->priv;
1149 1150 1151 1152 1153 1154 1155

  if (priv->needs_destroy)
    {
      clutter_actor_destroy (CLUTTER_ACTOR (self));
      return;
    }

1156
  meta_window_actor_sync_visibility (self);
1157
  meta_window_actor_sync_actor_geometry (self, FALSE);
1158

1159
  if (!meta_window_is_mapped (priv->window))
1160
    meta_window_actor_detach (self);
1161

1162
  if (priv->needs_pixmap)
1163
    clutter_actor_queue_redraw (priv->actor);
1164 1165
}

1166
void
1167 1168
meta_window_actor_effect_completed (MetaWindowActor *self,
                                    gulong           event)
1169
{
1170
  MetaWindowActorPrivate *priv   = self->priv;
1171 1172 1173 1174 1175 1176 1177

  /* NB: Keep in mind that when effects get completed it possible
   * that the corresponding MetaWindow may have be been destroyed.
   * In this case priv->window will == NULL */

  switch (event)
  {
1178
  case META_PLUGIN_MINIMIZE:
1179 1180 1181 1182 1183 1184 1185 1186 1187
    {
      priv->minimize_in_progress--;
      if (priv->minimize_in_progress < 0)
	{
	  g_warning ("Error in minimize accounting.");
	  priv->minimize_in_progress = 0;
	}
    }
    break;
1188
  case META_PLUGIN_MAP:
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
    /*
     * Make sure that the actor is at the correct place in case
     * the plugin fscked.
     */
    priv->map_in_progress--;

    if (priv->map_in_progress < 0)
      {
	g_warning ("Error in map accounting.");
	priv->map_in_progress = 0;
      }
    break;
1201
  case META_PLUGIN_DESTROY:
1202 1203 1204 1205 1206 1207 1208 1209
    priv->destroy_in_progress--;

    if (priv->destroy_in_progress < 0)
      {
	g_warning ("Error in destroy accounting.");
	priv->destroy_in_progress = 0;
      }
    break;
1210
  case META_PLUGIN_UNMAXIMIZE:
1211 1212 1213 1214 1215 1216 1217
    priv->unmaximize_in_progress--;
    if (priv->unmaximize_in_progress < 0)
      {
	g_warning ("Error in unmaximize accounting.");
	priv->unmaximize_in_progress = 0;
      }
    break;
1218
  case META_PLUGIN_MAXIMIZE:
1219 1220 1221 1222 1223 1224 1225
    priv->maximize_in_progress--;
    if (priv->maximize_in_progress < 0)
      {
	g_warning ("Error in maximize accounting.");
	priv->maximize_in_progress = 0;
      }
    break;
1226
  case META_PLUGIN_SWITCH_WORKSPACE:
1227 1228 1229 1230
    g_assert_not_reached ();
    break;
  }

1231
  if (is_freeze_thaw_effect (event))
1232
    meta_window_actor_thaw (self);
1233

1234 1235
  if (!meta_window_actor_effect_in_progress (self))
    meta_window_actor_after_effects (self);
1236 1237
}

1238 1239 1240 1241 1242
/* Called to drop our reference to a window backing pixmap that we
 * previously obtained with XCompositeNameWindowPixmap. We do this
 * when the window is unmapped or when we want to update to a new
 * pixmap for a new size.
 */
1243
static void
1244
meta_window_actor_detach (MetaWindowActor *self)
1245
{
1246
  MetaWindowActorPrivate *priv     = self->priv;
1247 1248 1249 1250 1251 1252 1253
  MetaScreen            *screen   = priv->screen;
  MetaDisplay           *display  = meta_screen_get_display (screen);
  Display               *xdisplay = meta_display_get_xdisplay (display);

  if (!priv->back_pixmap)
    return;

1254 1255 1256 1257
  /* Get rid of all references to the pixmap before freeing it; it's unclear whether
   * you are supposed to be able to free a GLXPixmap after freeing the underlying
   * pixmap, but it certainly doesn't work with current DRI/Mesa
   */
1258 1259
  meta_shaped_texture_set_pixmap (META_SHAPED_TEXTURE (priv->actor),
                                  None);
1260 1261
  cogl_flush();

1262
  XFreePixmap (xdisplay, priv->back_pixmap);
1263
  priv->back_pixmap = None;
1264

1265
  meta_window_actor_queue_create_pixmap (self);
1266 1267
}

1268 1269 1270 1271
gboolean
meta_window_actor_should_unredirect (MetaWindowActor *self)
{
  MetaWindow *metaWindow = meta_window_actor_get_meta_window (self);
1272
  MetaWindowActorPrivate *priv = self->priv;
1273

1274 1275 1276
  if (meta_window_requested_dont_bypass_compositor (metaWindow))
    return FALSE;

1277
  if (metaWindow->opacity != 0xFF)
1278 1279
    return FALSE;

1280
  if (metaWindow->shape_region != NULL)
1281 1282
    return FALSE;

1283
  if (priv->argb32 && !meta_window_requested_bypass_compositor (metaWindow))
1284 1285
    return FALSE;

1286
  if (!meta_window_is_monitor_sized (metaWindow))
1287 1288
    return FALSE;

1289
  if (meta_window_requested_bypass_compositor (metaWindow))
1290 1291
    return TRUE;

1292
  if (meta_window_is_override_redirect (metaWindow))
1293 1294
    return TRUE;

1295 1296
  if (priv->does_full_damage)
    return TRUE;
1297 1298 1299 1300 1301 1302 1303 1304

  return FALSE;
}

void
meta_window_actor_set_redirected (MetaWindowActor *self, gboolean state)
{
  MetaWindow *metaWindow = meta_window_actor_get_meta_window (self);
1305
  MetaDisplay *display = meta_window_get_display (metaWindow);
1306

1307
  Display *xdisplay = meta_display_get_xdisplay (display);
1308
  Window  xwin = meta_window_get_toplevel_xwindow (metaWindow);
1309 1310 1311

  if (state)
    {
1312
      meta_error_trap_push (display);
1313
      XCompositeRedirectWindow (xdisplay, xwin, CompositeRedirectManual);
1314
      meta_error_trap_pop (display);
1315
      meta_window_actor_detach (self);
1316 1317 1318 1319
      self->priv->unredirected = FALSE;
    }
  else
    {
1320
      meta_error_trap_push (display);
1321
      XCompositeUnredirectWindow (xdisplay, xwin, CompositeRedirectManual);
1322
      meta_error_trap_pop (display);
1323 1324 1325 1326
      self->priv->unredirected = TRUE;
    }
}

1327
void
1328
meta_window_actor_destroy (MetaWindowActor *self)
1329 1330 1331
{
  MetaWindow	      *window;
  MetaCompScreen      *info;
1332
  MetaWindowActorPrivate *priv;
1333
  MetaWindowType window_type;
1334 1335 1336 1337

  priv = self->priv;

  window = priv->window;
1338
  window_type = meta_window_get_window_type (window);
1339 1340 1341 1342 1343 1344 1345 1346 1347
  meta_window_set_compositor_private (window, NULL);

  /*
   * We remove the window from internal lookup hashes and thus any other
   * unmap events etc fail
   */
  info = meta_screen_get_compositor_data (priv->screen);
  info->windows = g_list_remove (info->windows, (gconstpointer) self);

1348 1349 1350 1351 1352 1353 1354
  if (window_type == META_WINDOW_DROPDOWN_MENU ||
      window_type == META_WINDOW_POPUP_MENU ||
      window_type == META_WINDOW_TOOLTIP ||
      window_type == META_WINDOW_NOTIFICATION ||
      window_type == META_WINDOW_COMBO ||
      window_type == META_WINDOW_DND ||
      window_type == META_WINDOW_OVERRIDE_OTHER)
1355 1356 1357 1358 1359 1360 1361 1362
    {
      /*
       * No effects, just kill it.
       */
      clutter_actor_destroy (CLUTTER_ACTOR (self));
      return;
    }

1363
  priv->needs_destroy = TRUE;
1364

1365
  if (!meta_window_actor_effect_in_progress (self))
1366
    clutter_actor_destroy (CLUTTER_ACTOR (self));
1367 1368 1369
}

void
1370 1371
meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
                                       gboolean         did_placement)
1372
{
1373
  MetaWindowActorPrivate *priv = self->priv;
1374 1375
  MetaRectangle window_rect;

1376 1377 1378 1379 1380 1381 1382 1383 1384 1385
  meta_window_get_input_rect (priv->window, &window_rect);

  if (priv->last_width != window_rect.width ||
      priv->last_height != window_rect.height)
    {
      priv->size_changed = TRUE;
      priv->last_width = window_rect.width;
      priv->last_height = window_rect.height;
    }

1386 1387 1388 1389 1390 1391 1392 1393 1394 1395
  /* Normally we want freezing a window to also freeze its position; this allows
   * windows to atomically move and resize together, either under app control,
   * or because the user is resizing from the left/top. But on initial placement
   * we need to assign a position, since immediately after the window
   * is shown, the map effect will go into effect and prevent further geometry
   * updates.
   */
  if (is_frozen (self) && !did_placement)
    return;

1396
  if (priv->size_changed)
1397
    {
1398
      meta_window_actor_queue_create_pixmap (self);
1399
      meta_window_actor_update_shape (self);
1400
    }
1401

1402
  if (meta_window_actor_effect_in_progress (self))
1403 1404 1405
    return;

  clutter_actor_set_position (CLUTTER_ACTOR (self),
1406 1407 1408
                              window_rect.x, window_rect.y);
  clutter_actor_set_size (CLUTTER_ACTOR (self),
                          window_rect.width, window_rect.height);