MetaWindowActor: replace MetaSurfaceActorEmpty with no MSA at all

Have MetaWindowActor cope with having a NULL surface actor, and
drop the Empty class.
This commit is contained in:
Giovanni Campagna 2014-02-24 22:40:43 +01:00
parent 89ca36818a
commit bdbeafc222
4 changed files with 53 additions and 180 deletions

View File

@ -80,8 +80,6 @@ libmutter_wayland_la_SOURCES = \
compositor/meta-shaped-texture-private.h \
compositor/meta-surface-actor.c \
compositor/meta-surface-actor.h \
compositor/meta-surface-actor-empty.c \
compositor/meta-surface-actor-empty.h \
compositor/meta-surface-actor-x11.c \
compositor/meta-surface-actor-x11.h \
compositor/meta-surface-actor-wayland.c \

View File

@ -1,96 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2013 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jasper St. Pierre <jstpierre@mecheye.net>
*/
#include "config.h"
#include "meta-surface-actor-empty.h"
G_DEFINE_TYPE (MetaSurfaceActorEmpty, meta_surface_actor_empty, META_TYPE_SURFACE_ACTOR)
static void
meta_surface_actor_empty_process_damage (MetaSurfaceActor *actor,
int x, int y, int width, int height)
{
}
static void
meta_surface_actor_empty_pre_paint (MetaSurfaceActor *actor)
{
}
static gboolean
meta_surface_actor_empty_is_argb32 (MetaSurfaceActor *actor)
{
return FALSE;
}
static gboolean
meta_surface_actor_empty_is_visible (MetaSurfaceActor *actor)
{
return FALSE;
}
static gboolean
meta_surface_actor_empty_should_unredirect (MetaSurfaceActor *actor)
{
return FALSE;
}
static void
meta_surface_actor_empty_set_unredirected (MetaSurfaceActor *actor,
gboolean unredirected)
{
}
static gboolean
meta_surface_actor_empty_is_unredirected (MetaSurfaceActor *actor)
{
return FALSE;
}
static void
meta_surface_actor_empty_class_init (MetaSurfaceActorEmptyClass *klass)
{
MetaSurfaceActorClass *surface_actor_class = META_SURFACE_ACTOR_CLASS (klass);
surface_actor_class->process_damage = meta_surface_actor_empty_process_damage;
surface_actor_class->pre_paint = meta_surface_actor_empty_pre_paint;
surface_actor_class->is_argb32 = meta_surface_actor_empty_is_argb32;
surface_actor_class->is_visible = meta_surface_actor_empty_is_visible;
surface_actor_class->should_unredirect = meta_surface_actor_empty_should_unredirect;
surface_actor_class->set_unredirected = meta_surface_actor_empty_set_unredirected;
surface_actor_class->is_unredirected = meta_surface_actor_empty_is_unredirected;
}
static void
meta_surface_actor_empty_init (MetaSurfaceActorEmpty *self)
{
}
MetaSurfaceActor *
meta_surface_actor_empty_new (void)
{
return g_object_new (META_TYPE_SURFACE_ACTOR_EMPTY, NULL);
}

View File

@ -1,60 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2013 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jasper St. Pierre <jstpierre@mecheye.net>
*/
#ifndef __META_SURFACE_ACTOR_EMPTY_H__
#define __META_SURFACE_ACTOR_EMPTY_H__
#include <glib-object.h>
#include "meta-surface-actor.h"
G_BEGIN_DECLS
#define META_TYPE_SURFACE_ACTOR_EMPTY (meta_surface_actor_empty_get_type ())
#define META_SURFACE_ACTOR_EMPTY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_SURFACE_ACTOR_EMPTY, MetaSurfaceActorEmpty))
#define META_SURFACE_ACTOR_EMPTY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_SURFACE_ACTOR_EMPTY, MetaSurfaceActorEmptyClass))
#define META_IS_SURFACE_ACTOR_EMPTY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_SURFACE_ACTOR_EMPTY))
#define META_IS_SURFACE_ACTOR_EMPTY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_SURFACE_ACTOR_EMPTY))
#define META_SURFACE_ACTOR_EMPTY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_SURFACE_ACTOR_EMPTY, MetaSurfaceActorEmptyClass))
typedef struct _MetaSurfaceActorEmpty MetaSurfaceActorEmpty;
typedef struct _MetaSurfaceActorEmptyClass MetaSurfaceActorEmptyClass;
struct _MetaSurfaceActorEmpty
{
MetaSurfaceActor parent;
};
struct _MetaSurfaceActorEmptyClass
{
MetaSurfaceActorClass parent_class;
};
GType meta_surface_actor_empty_get_type (void);
MetaSurfaceActor * meta_surface_actor_empty_new (void);
G_END_DECLS
#endif /* __META_SURFACE_ACTOR_EMPTY_H__ */

View File

@ -34,7 +34,6 @@
#include "meta-surface-actor.h"
#include "meta-surface-actor-x11.h"
#include "meta-surface-actor-empty.h"
struct _MetaWindowActorPrivate
{
@ -255,7 +254,15 @@ static gboolean
is_argb32 (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
return meta_surface_actor_is_argb32 (priv->surface);
/* assume we're argb until we get the window (because
in practice we're drawing nothing, so we're fully
transparent)
*/
if (priv->surface)
return meta_surface_actor_is_argb32 (priv->surface);
else
return TRUE;
}
static gboolean
@ -272,7 +279,7 @@ is_frozen (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
return priv->freeze_count > 0;
return priv->surface == NULL || priv->freeze_count > 0;
}
static void
@ -280,7 +287,7 @@ meta_window_actor_freeze (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
if (priv->freeze_count == 0)
if (priv->freeze_count == 0 && priv->surface)
meta_surface_actor_set_frozen (priv->surface, TRUE);
priv->freeze_count ++;
@ -298,7 +305,8 @@ meta_window_actor_thaw (MetaWindowActor *self)
if (priv->freeze_count > 0)
return;
meta_surface_actor_set_frozen (priv->surface, FALSE);
if (priv->surface)
meta_surface_actor_set_frozen (priv->surface, FALSE);
/* We sometimes ignore moves and resizes on frozen windows */
meta_window_actor_sync_actor_geometry (self, FALSE);
@ -355,7 +363,7 @@ meta_window_actor_update_surface (MetaWindowActor *self)
else if (!meta_is_wayland_compositor ())
surface_actor = meta_surface_actor_x11_new (window);
else
surface_actor = meta_surface_actor_empty_new ();
surface_actor = NULL;
set_surface (self, surface_actor);
}
@ -662,8 +670,11 @@ meta_window_actor_get_paint_volume (ClutterActor *actor,
meta_window_actor_get_shape_bounds (self, &bounds);
if (meta_surface_actor_get_unobscured_bounds (priv->surface, &unobscured_bounds))
gdk_rectangle_intersect (&bounds, &unobscured_bounds, &bounds);
if (priv->surface)
{
if (meta_surface_actor_get_unobscured_bounds (priv->surface, &unobscured_bounds))
gdk_rectangle_intersect (&bounds, &unobscured_bounds, &bounds);
}
if (appears_focused ? priv->focused_shadow : priv->unfocused_shadow)
{
@ -774,21 +785,26 @@ meta_window_actor_get_meta_window (MetaWindowActor *self)
* meta_window_actor_get_texture:
* @self: a #MetaWindowActor
*
* Gets the ClutterActor that is used to display the contents of the window
* Gets the ClutterActor that is used to display the contents of the window,
* or NULL if no texture is shown yet, because the window is not mapped.
*
* Return value: (transfer none): the #ClutterActor for the contents
*/
ClutterActor *
meta_window_actor_get_texture (MetaWindowActor *self)
{
return CLUTTER_ACTOR (meta_surface_actor_get_texture (self->priv->surface));
if (self->priv->surface)
return CLUTTER_ACTOR (meta_surface_actor_get_texture (self->priv->surface));
else
return NULL;
}
/**
* meta_window_actor_get_surface:
* @self: a #MetaWindowActor
*
* Gets the MetaSurfaceActor that draws the content of this window
* Gets the MetaSurfaceActor that draws the content of this window,
* or NULL if there is no surface yet associated with this window.
*
* Return value: (transfer none): the #MetaSurfaceActor for the contents
*/
@ -887,7 +903,12 @@ meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
if (!priv->repaint_scheduled)
{
gboolean is_obscured = meta_surface_actor_is_obscured (priv->surface);
gboolean is_obscured;
if (priv->surface)
is_obscured = meta_surface_actor_is_obscured (priv->surface);
else
is_obscured = FALSE;
/* A frame was marked by the client without actually doing any
* damage or any unobscured, or while we had the window frozen
@ -903,9 +924,12 @@ meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
}
else
{
const cairo_rectangle_int_t clip = { 0, 0, 1, 1 };
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (priv->surface), &clip);
priv->repaint_scheduled = TRUE;
if (priv->surface)
{
const cairo_rectangle_int_t clip = { 0, 0, 1, 1 };
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (priv->surface), &clip);
priv->repaint_scheduled = TRUE;
}
}
}
}
@ -1078,7 +1102,10 @@ gboolean
meta_window_actor_should_unredirect (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
return meta_surface_actor_should_unredirect (priv->surface);
if (priv->surface)
return meta_surface_actor_should_unredirect (priv->surface);
else
return FALSE;
}
void
@ -1086,6 +1113,8 @@ meta_window_actor_set_unredirected (MetaWindowActor *self,
gboolean unredirected)
{
MetaWindowActorPrivate *priv = self->priv;
g_assert(priv->surface); /* because otherwise should_unredirect() is FALSE */
meta_surface_actor_set_unredirected (priv->surface, unredirected);
}
@ -1531,11 +1560,12 @@ meta_window_actor_process_x11_damage (MetaWindowActor *self,
{
MetaWindowActorPrivate *priv = self->priv;
meta_surface_actor_process_damage (priv->surface,
event->area.x,
event->area.y,
event->area.width,
event->area.height);
if (priv->surface)
meta_surface_actor_process_damage (priv->surface,
event->area.x,
event->area.y,
event->area.width,
event->area.height);
}
void
@ -2038,7 +2068,8 @@ meta_window_actor_update_opacity (MetaWindowActor *self)
MetaWindowActorPrivate *priv = self->priv;
MetaWindow *window = priv->window;
clutter_actor_set_opacity (CLUTTER_ACTOR (self->priv->surface), window->opacity);
if (priv->surface)
clutter_actor_set_opacity (CLUTTER_ACTOR (priv->surface), window->opacity);
}
void