2008-10-24 05:07:24 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#define _XOPEN_SOURCE 500 /* for usleep() */
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
#include "../../core/window-private.h"
|
2008-06-04 08:58:36 -04:00
|
|
|
#include "display.h"
|
|
|
|
#include "screen.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "compositor-private.h"
|
2008-10-16 07:50:01 -04:00
|
|
|
#include "compositor-mutter.h"
|
|
|
|
#include "mutter-plugin-manager.h"
|
|
|
|
#include "tidy/tidy-texture-frame.h"
|
2008-06-04 08:58:36 -04:00
|
|
|
#include "xprops.h"
|
2008-10-24 05:07:24 -04:00
|
|
|
#include "prefs.h"
|
2008-10-16 07:50:01 -04:00
|
|
|
#include "mutter-shaped-texture.h"
|
2008-06-04 08:58:36 -04:00
|
|
|
#include <X11/Xatom.h>
|
2008-08-20 06:48:00 -04:00
|
|
|
#include <X11/Xlibint.h>
|
2008-06-04 08:58:36 -04:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
|
|
|
#include <X11/extensions/Xdamage.h>
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
|
|
|
|
#include <clutter/clutter.h>
|
2008-08-19 12:02:00 -04:00
|
|
|
#include <clutter/clutter-group.h>
|
2008-06-04 08:58:36 -04:00
|
|
|
#include <clutter/x11/clutter-x11.h>
|
2008-09-30 10:33:18 -04:00
|
|
|
#ifdef HAVE_GLX_TEXTURE_PIXMAP
|
2008-06-04 08:58:36 -04:00
|
|
|
#include <clutter/glx/clutter-glx.h>
|
2008-09-30 10:33:18 -04:00
|
|
|
#endif /* HAVE_GLX_TEXTURE_PIXMAP */
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-06-06 09:17:38 -04:00
|
|
|
#include <cogl/cogl.h>
|
2008-08-18 11:23:50 -04:00
|
|
|
#define SHADOW_RADIUS 8
|
2008-06-06 09:17:38 -04:00
|
|
|
#define SHADOW_OPACITY 0.9
|
2008-08-19 09:33:20 -04:00
|
|
|
#define SHADOW_OFFSET_X (SHADOW_RADIUS)
|
|
|
|
#define SHADOW_OFFSET_Y (SHADOW_RADIUS)
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-18 11:23:50 -04:00
|
|
|
#define MAX_TILE_SZ 8 /* Must be <= shaddow radius */
|
2008-06-06 09:17:38 -04:00
|
|
|
#define TILE_WIDTH (3*MAX_TILE_SZ)
|
|
|
|
#define TILE_HEIGHT (3*MAX_TILE_SZ)
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
#define CHECK_LIST_INTEGRITY_START(list) \
|
|
|
|
{int len2__; int len__ = g_list_length(list);
|
|
|
|
|
|
|
|
#define CHECK_LIST_INTEGRITY_END(list) \
|
|
|
|
len2__ = g_list_length(list); \
|
|
|
|
if (len__ != len2__) \
|
|
|
|
g_warning ("Integrity check of list failed at %s:%d\n", \
|
|
|
|
__FILE__, __LINE__); }
|
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
/* #define DEBUG_TRACE g_print */
|
2008-12-18 07:41:56 -05:00
|
|
|
#define DEBUG_TRACE(X)
|
2008-10-24 05:07:24 -04:00
|
|
|
|
2008-08-20 06:48:00 -04:00
|
|
|
/*
|
|
|
|
* Register GType wrapper for XWindowAttributes, so we do not have to
|
2008-10-16 07:50:01 -04:00
|
|
|
* query window attributes in the MutterWindow constructor but can pass
|
2008-08-20 06:48:00 -04:00
|
|
|
* them as a property to the constructor (so we can gracefully handle the case
|
|
|
|
* where no attributes can be retrieved).
|
|
|
|
*
|
2008-09-18 11:09:11 -04:00
|
|
|
* NB -- we only need a subset of the attributes; at some point we might want
|
2008-08-20 06:48:00 -04:00
|
|
|
* to just store the relevant values rather than the whole struct.
|
|
|
|
*/
|
|
|
|
#define META_TYPE_XATTRS (meta_xattrs_get_type ())
|
|
|
|
|
|
|
|
GType meta_xattrs_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
static XWindowAttributes *
|
|
|
|
meta_xattrs_copy (const XWindowAttributes *attrs)
|
|
|
|
{
|
|
|
|
XWindowAttributes *result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (attrs != NULL, NULL);
|
|
|
|
|
|
|
|
result = (XWindowAttributes*) Xmalloc (sizeof (XWindowAttributes));
|
|
|
|
*result = *attrs;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_xattrs_free (XWindowAttributes *attrs)
|
|
|
|
{
|
|
|
|
g_return_if_fail (attrs != NULL);
|
|
|
|
|
|
|
|
XFree (attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
meta_xattrs_get_type (void)
|
|
|
|
{
|
|
|
|
static GType our_type = 0;
|
|
|
|
|
|
|
|
if (!our_type)
|
|
|
|
our_type = g_boxed_type_register_static ("XWindowAttributes",
|
|
|
|
(GBoxedCopyFunc) meta_xattrs_copy,
|
|
|
|
(GBoxedFreeFunc) meta_xattrs_free);
|
|
|
|
return our_type;
|
|
|
|
}
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
static unsigned char* shadow_gaussian_make_tile (void);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
static inline gboolean
|
2008-08-20 04:33:39 -04:00
|
|
|
composite_at_least_version (MetaDisplay *display, int maj, int min)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
static int major = -1;
|
|
|
|
static int minor = -1;
|
|
|
|
|
|
|
|
if (major == -1)
|
|
|
|
meta_display_get_compositor_version (display, &major, &minor);
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return (major > maj || (major == maj && minor >= min));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
typedef struct _Mutter
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaCompositor compositor;
|
|
|
|
MetaDisplay *display;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
Atom atom_x_root_pixmap;
|
|
|
|
Atom atom_x_set_root;
|
|
|
|
Atom atom_net_wm_window_opacity;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-20 08:18:43 -04:00
|
|
|
ClutterActor *shadow_src;
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
gboolean show_redraw : 1;
|
|
|
|
gboolean debug : 1;
|
2008-11-05 06:48:07 -05:00
|
|
|
gboolean no_mipmaps : 1;
|
2008-10-16 07:50:01 -04:00
|
|
|
} Mutter;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
typedef struct _MetaCompScreen
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaScreen *screen;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
ClutterActor *stage, *window_group, *overlay_group;
|
2008-11-03 05:26:21 -05:00
|
|
|
ClutterActor *hidden_group;
|
2008-08-20 04:33:39 -04:00
|
|
|
GList *windows;
|
|
|
|
GHashTable *windows_by_xid;
|
|
|
|
MetaWindow *focus_window;
|
|
|
|
Window output;
|
|
|
|
GSList *dock_windows;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
gint switch_workspace_in_progress;
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPluginManager *plugin_mgr;
|
2008-06-04 08:58:36 -04:00
|
|
|
} MetaCompScreen;
|
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
/*
|
2008-10-16 07:50:01 -04:00
|
|
|
* MutterWindow implementation
|
2008-08-19 12:02:00 -04:00
|
|
|
*/
|
2008-10-16 07:50:01 -04:00
|
|
|
struct _MutterWindowPrivate
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-20 06:48:00 -04:00
|
|
|
XWindowAttributes attrs;
|
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
MetaWindow *window;
|
2008-08-19 12:02:00 -04:00
|
|
|
Window xwindow;
|
|
|
|
MetaScreen *screen;
|
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
ClutterActor *actor;
|
2008-06-06 09:17:38 -04:00
|
|
|
ClutterActor *shadow;
|
2008-06-04 15:51:08 -04:00
|
|
|
Pixmap back_pixmap;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
MetaCompWindowType type;
|
2008-08-18 10:44:26 -04:00
|
|
|
Damage damage;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 05:57:15 -04:00
|
|
|
guint8 opacity;
|
|
|
|
|
2008-10-30 04:30:42 -04:00
|
|
|
gchar * desc;
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
guint needs_shadow : 1;
|
|
|
|
guint shaped : 1;
|
|
|
|
guint destroy_pending : 1;
|
|
|
|
guint argb32 : 1;
|
|
|
|
guint disposed : 1;
|
|
|
|
guint is_minimized : 1;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
/* Desktop switching flags */
|
2008-11-23 14:28:40 -05:00
|
|
|
guint needs_map : 1;
|
|
|
|
guint needs_unmap : 1;
|
|
|
|
guint needs_repair : 1;
|
|
|
|
|
|
|
|
guint needs_destroy : 1;
|
2008-08-19 12:02:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
PROP_MCW_META_WINDOW = 1,
|
|
|
|
PROP_MCW_META_SCREEN,
|
|
|
|
PROP_MCW_X_WINDOW,
|
2008-08-20 06:48:00 -04:00
|
|
|
PROP_MCW_X_WINDOW_ATTRIBUTES
|
2008-08-19 12:02:00 -04:00
|
|
|
};
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
static void mutter_window_class_init (MutterWindowClass *klass);
|
|
|
|
static void mutter_window_init (MutterWindow *self);
|
|
|
|
static void mutter_window_dispose (GObject *object);
|
|
|
|
static void mutter_window_finalize (GObject *object);
|
|
|
|
static void mutter_window_constructed (GObject *object);
|
|
|
|
static void mutter_window_set_property (GObject *object,
|
2008-08-20 03:26:52 -04:00
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2008-10-16 07:50:01 -04:00
|
|
|
static void mutter_window_get_property (GObject *object,
|
2008-08-20 03:26:52 -04:00
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2008-10-16 07:50:01 -04:00
|
|
|
static void mutter_window_query_window_type (MutterWindow *self);
|
|
|
|
static void mutter_window_detach (MutterWindow *self);
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
G_DEFINE_TYPE (MutterWindow, mutter_window, CLUTTER_TYPE_GROUP);
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_class_init (MutterWindowClass *klass)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GParamSpec *pspec;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
g_type_class_add_private (klass, sizeof (MutterWindowPrivate));
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
object_class->dispose = mutter_window_dispose;
|
|
|
|
object_class->finalize = mutter_window_finalize;
|
|
|
|
object_class->set_property = mutter_window_set_property;
|
|
|
|
object_class->get_property = mutter_window_get_property;
|
|
|
|
object_class->constructed = mutter_window_constructed;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-11-07 04:57:00 -05:00
|
|
|
pspec = g_param_spec_object ("meta-window",
|
|
|
|
"MetaWindow",
|
|
|
|
"The displayed MetaWindow",
|
|
|
|
META_TYPE_WINDOW,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
2008-08-20 04:33:39 -04:00
|
|
|
PROP_MCW_META_WINDOW,
|
2008-08-19 12:02:00 -04:00
|
|
|
pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_pointer ("meta-screen",
|
|
|
|
"MetaScreen",
|
|
|
|
"MetaScreen",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
2008-08-20 04:33:39 -04:00
|
|
|
PROP_MCW_META_SCREEN,
|
2008-08-19 12:02:00 -04:00
|
|
|
pspec);
|
|
|
|
|
|
|
|
pspec = g_param_spec_ulong ("x-window",
|
|
|
|
"Window",
|
|
|
|
"Window",
|
|
|
|
0,
|
|
|
|
G_MAXULONG,
|
|
|
|
0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
2008-08-20 04:33:39 -04:00
|
|
|
PROP_MCW_X_WINDOW,
|
2008-08-19 12:02:00 -04:00
|
|
|
pspec);
|
2008-08-20 06:48:00 -04:00
|
|
|
|
|
|
|
pspec = g_param_spec_boxed ("x-window-attributes",
|
|
|
|
"XWindowAttributes",
|
|
|
|
"XWindowAttributes",
|
|
|
|
META_TYPE_XATTRS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_MCW_X_WINDOW_ATTRIBUTES,
|
|
|
|
pspec);
|
2008-08-19 12:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_init (MutterWindow *self)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
2008-10-16 07:50:01 -04:00
|
|
|
MUTTER_TYPE_COMP_WINDOW,
|
|
|
|
MutterWindowPrivate);
|
2008-08-19 12:02:00 -04:00
|
|
|
priv->opacity = 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean is_shaped (MetaDisplay *display, Window xwindow);
|
2008-10-16 07:50:01 -04:00
|
|
|
static gboolean mutter_window_has_shadow (MutterWindow *self);
|
|
|
|
static void update_shape (Mutter *compositor,
|
|
|
|
MutterWindow *cw);
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_constructed (GObject *object)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindow *self = MUTTER_WINDOW (object);
|
|
|
|
MutterWindowPrivate *priv = self->priv;
|
2008-08-20 08:01:40 -04:00
|
|
|
MetaScreen *screen = priv->screen;
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Window xwindow = priv->xwindow;
|
2008-08-20 04:33:39 -04:00
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
XRenderPictFormat *format;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_query_window_type (self);
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-09-25 08:30:34 -04:00
|
|
|
#ifdef HAVE_SHAPE
|
|
|
|
/* Listen for ShapeNotify events on the window */
|
|
|
|
if (meta_display_has_shape (display))
|
|
|
|
XShapeSelectInput (xdisplay, xwindow, ShapeNotifyMask);
|
|
|
|
#endif
|
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
priv->shaped = is_shaped (display, xwindow);
|
|
|
|
|
|
|
|
if (priv->attrs.class == InputOnly)
|
|
|
|
priv->damage = None;
|
|
|
|
else
|
|
|
|
priv->damage = XDamageCreate (xdisplay, xwindow, XDamageReportNonEmpty);
|
|
|
|
|
|
|
|
format = XRenderFindVisualFormat (xdisplay, priv->attrs.visual);
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
if (format && format->type == PictTypeDirect && format->direct.alphaMask)
|
|
|
|
priv->argb32 = TRUE;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
if (mutter_window_has_shadow (self))
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
Mutter *compositor =
|
|
|
|
(Mutter*)meta_display_get_compositor (display);
|
2008-08-20 08:18:43 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
priv->shadow =
|
2008-08-20 08:18:43 -04:00
|
|
|
tidy_texture_frame_new (CLUTTER_TEXTURE (compositor->shadow_src),
|
2008-08-19 12:02:00 -04:00
|
|
|
MAX_TILE_SZ,
|
|
|
|
MAX_TILE_SZ,
|
|
|
|
MAX_TILE_SZ,
|
|
|
|
MAX_TILE_SZ);
|
|
|
|
|
|
|
|
clutter_actor_set_position (priv->shadow,
|
|
|
|
SHADOW_OFFSET_X , SHADOW_OFFSET_Y);
|
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->shadow);
|
|
|
|
}
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
priv->actor = mutter_shaped_texture_new ();
|
2008-12-08 07:39:37 -05:00
|
|
|
|
|
|
|
if (!clutter_glx_texture_pixmap_using_extension (
|
|
|
|
CLUTTER_GLX_TEXTURE_PIXMAP (priv->actor)))
|
|
|
|
g_warning ("NOTE: Not using GLX TFP!\n");
|
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->actor);
|
2008-09-24 17:53:39 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
update_shape ((Mutter *)
|
2008-09-24 17:53:39 -04:00
|
|
|
meta_display_get_compositor (display),
|
|
|
|
self);
|
2008-08-19 12:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_dispose (GObject *object)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindow *self = MUTTER_WINDOW (object);
|
|
|
|
MutterWindowPrivate *priv = self->priv;
|
2008-08-20 03:26:52 -04:00
|
|
|
MetaScreen *screen;
|
|
|
|
MetaDisplay *display;
|
|
|
|
Display *xdisplay;
|
|
|
|
MetaCompScreen *info;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_detach (self);
|
2008-08-20 03:26:52 -04:00
|
|
|
|
|
|
|
if (priv->damage != None)
|
|
|
|
{
|
|
|
|
meta_error_trap_push (display);
|
|
|
|
XDamageDestroy (xdisplay, priv->damage);
|
|
|
|
meta_error_trap_pop (display, FALSE);
|
|
|
|
|
|
|
|
priv->damage = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check we are not in the dock list -- FIXME (do this in a cleaner way)
|
|
|
|
*/
|
|
|
|
if (priv->type == META_COMP_WINDOW_DOCK)
|
|
|
|
info->dock_windows = g_slist_remove (info->dock_windows, self);
|
|
|
|
|
|
|
|
info->windows = g_list_remove (info->windows, (gconstpointer) self);
|
|
|
|
g_hash_table_remove (info->windows_by_xid, (gpointer) priv->xwindow);
|
|
|
|
|
2008-10-30 04:30:42 -04:00
|
|
|
g_free (priv->desc);
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
G_OBJECT_CLASS (mutter_window_parent_class)->dispose (object);
|
2008-08-19 12:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_finalize (GObject *object)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
G_OBJECT_CLASS (mutter_window_parent_class)->finalize (object);
|
2008-08-19 12:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_set_property (GObject *object,
|
2008-08-20 04:33:39 -04:00
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = MUTTER_WINDOW (object)->priv;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
case PROP_MCW_META_WINDOW:
|
2008-11-07 04:57:00 -05:00
|
|
|
priv->window = g_value_get_object (value);
|
2008-08-19 12:02:00 -04:00
|
|
|
break;
|
2008-08-20 04:33:39 -04:00
|
|
|
case PROP_MCW_META_SCREEN:
|
2008-08-19 12:02:00 -04:00
|
|
|
priv->screen = g_value_get_pointer (value);
|
|
|
|
break;
|
2008-08-20 04:33:39 -04:00
|
|
|
case PROP_MCW_X_WINDOW:
|
2008-08-19 12:02:00 -04:00
|
|
|
priv->xwindow = g_value_get_ulong (value);
|
|
|
|
break;
|
2008-08-20 06:48:00 -04:00
|
|
|
case PROP_MCW_X_WINDOW_ATTRIBUTES:
|
|
|
|
priv->attrs = *((XWindowAttributes*)g_value_get_boxed (value));
|
|
|
|
break;
|
2008-08-19 12:02:00 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_get_property (GObject *object,
|
2008-08-20 04:33:39 -04:00
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2008-08-19 12:02:00 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = MUTTER_WINDOW (object)->priv;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
case PROP_MCW_META_WINDOW:
|
2008-11-07 04:57:00 -05:00
|
|
|
g_value_set_object (value, priv->window);
|
2008-08-19 12:02:00 -04:00
|
|
|
break;
|
2008-08-20 04:33:39 -04:00
|
|
|
case PROP_MCW_META_SCREEN:
|
2008-08-19 12:02:00 -04:00
|
|
|
g_value_set_pointer (value, priv->screen);
|
|
|
|
break;
|
2008-08-20 04:33:39 -04:00
|
|
|
case PROP_MCW_X_WINDOW:
|
2008-08-19 12:02:00 -04:00
|
|
|
g_value_set_ulong (value, priv->xwindow);
|
|
|
|
break;
|
2008-08-20 06:48:00 -04:00
|
|
|
case PROP_MCW_X_WINDOW_ATTRIBUTES:
|
|
|
|
g_value_set_boxed (value, &priv->attrs);
|
|
|
|
break;
|
2008-08-19 12:02:00 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
static MutterWindow*
|
2008-08-20 04:33:39 -04:00
|
|
|
find_window_for_screen (MetaScreen *screen, Window xwindow)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (info == NULL)
|
2008-10-24 05:07:24 -04:00
|
|
|
return NULL;
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return g_hash_table_lookup (info->windows_by_xid, (gpointer) xwindow);
|
|
|
|
}
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
static MutterWindow *
|
2008-08-20 04:33:39 -04:00
|
|
|
find_window_in_display (MetaDisplay *display, Window xwindow)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
GSList *index;
|
2008-10-31 05:10:10 -04:00
|
|
|
MetaWindow *window = meta_display_lookup_x_window (display, xwindow);
|
|
|
|
|
|
|
|
if (window)
|
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
void *priv = meta_window_get_compositor_private (window);
|
|
|
|
if (priv)
|
|
|
|
return priv;
|
2008-10-31 05:10:10 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
for (index = meta_display_get_screens (display);
|
|
|
|
index;
|
|
|
|
index = index->next)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindow *cw = find_window_for_screen (index->data, xwindow);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
if (cw != NULL)
|
|
|
|
return cw;
|
|
|
|
}
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
static MutterWindow *
|
2008-08-20 04:33:39 -04:00
|
|
|
find_window_for_child_window_in_display (MetaDisplay *display, Window xwindow)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
Window ignored1, *ignored2, parent;
|
|
|
|
guint ignored_children;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
XQueryTree (meta_display_get_xdisplay (display), xwindow, &ignored1,
|
|
|
|
&parent, &ignored2, &ignored_children);
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
if (parent != None)
|
|
|
|
return find_window_in_display (display, parent);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_query_window_type (MutterWindow *self)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
MutterWindowPrivate *priv = self->priv;
|
2008-12-18 07:46:53 -05:00
|
|
|
priv->type = (MetaCompWindowType) meta_window_get_window_type (priv->window);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2008-08-19 12:02:00 -04:00
|
|
|
is_shaped (MetaDisplay *display, Window xwindow)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
2008-08-20 04:33:39 -04:00
|
|
|
gint xws, yws, xbs, ybs;
|
|
|
|
guint wws, hws, wbs, hbs;
|
|
|
|
gint bounding_shaped, clip_shaped;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
if (meta_display_has_shape (display))
|
|
|
|
{
|
|
|
|
XShapeQueryExtents (xdisplay, xwindow, &bounding_shaped,
|
|
|
|
&xws, &yws, &wws, &hws, &clip_shaped,
|
|
|
|
&xbs, &ybs, &wbs, &hbs);
|
|
|
|
return (bounding_shaped != 0);
|
|
|
|
}
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-06-06 09:17:38 -04:00
|
|
|
static gboolean
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_has_shadow (MutterWindow *self)
|
2008-06-06 09:17:38 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate * priv = self->priv;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
/*
|
|
|
|
* Always put a shadow around windows with a frame - This should override
|
|
|
|
* the restriction about not putting a shadow around shaped windows
|
|
|
|
* as the frame might be the reason the window is shaped
|
|
|
|
*/
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->window)
|
2008-06-06 09:17:38 -04:00
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
if (meta_window_get_frame (priv->window))
|
|
|
|
{
|
2008-09-25 04:30:13 -04:00
|
|
|
meta_verbose ("Window 0x%x has shadow because it has a frame\n",
|
|
|
|
(guint)priv->xwindow);
|
2008-08-20 04:33:39 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-06-06 09:17:38 -04:00
|
|
|
}
|
|
|
|
|
2008-10-21 11:51:18 -04:00
|
|
|
/*
|
|
|
|
* Do not add shadows to ARGB windows (since they are probably transparent)
|
|
|
|
*/
|
|
|
|
if (priv->argb32 || priv->opacity != 0xff)
|
|
|
|
{
|
|
|
|
meta_verbose ("Window 0x%x has no shadow as it is ARGB\n",
|
|
|
|
(guint)priv->xwindow);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
/*
|
|
|
|
* Never put a shadow around shaped windows
|
|
|
|
*/
|
|
|
|
if (priv->shaped)
|
|
|
|
{
|
2008-09-25 04:30:13 -04:00
|
|
|
meta_verbose ("Window 0x%x has no shadow as it is shaped\n",
|
|
|
|
(guint)priv->xwindow);
|
2008-08-20 04:33:39 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-09-25 04:30:13 -04:00
|
|
|
/*
|
|
|
|
* Add shadows to override redirect windows (e.g., Gtk menus).
|
|
|
|
* This must have lower priority than window shape test.
|
|
|
|
*/
|
|
|
|
if (priv->attrs.override_redirect)
|
|
|
|
{
|
|
|
|
meta_verbose ("Window 0x%x has shadow because it is override redirect.\n",
|
|
|
|
(guint)priv->xwindow);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
/*
|
|
|
|
* Don't put shadow around DND icon windows
|
|
|
|
*/
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->type == META_COMP_WINDOW_DND ||
|
2008-08-20 04:33:39 -04:00
|
|
|
priv->type == META_COMP_WINDOW_DESKTOP)
|
|
|
|
{
|
2008-09-25 04:30:13 -04:00
|
|
|
meta_verbose ("Window 0x%x has no shadow as it is DND or Desktop\n",
|
|
|
|
(guint)priv->xwindow);
|
2008-08-20 04:33:39 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->type == META_COMP_WINDOW_MENU
|
2008-08-18 10:44:26 -04:00
|
|
|
#if 0
|
2008-11-23 14:28:40 -05:00
|
|
|
|| priv->type == META_COMP_WINDOW_DROPDOWN_MENU
|
2008-08-18 10:44:26 -04:00
|
|
|
#endif
|
2008-08-20 04:33:39 -04:00
|
|
|
)
|
|
|
|
{
|
2008-09-25 04:30:13 -04:00
|
|
|
meta_verbose ("Window 0x%x has shadow as it is a menu\n",
|
|
|
|
(guint)priv->xwindow);
|
2008-08-20 04:33:39 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
#if 0
|
2008-08-20 04:33:39 -04:00
|
|
|
if (priv->type == META_COMP_WINDOW_TOOLTIP)
|
|
|
|
{
|
2008-09-25 04:30:13 -04:00
|
|
|
meta_verbose ("Window 0x%x has shadow as it is a tooltip\n",
|
|
|
|
(guint)priv->xwindow);
|
2008-08-20 04:33:39 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-08-18 10:44:26 -04:00
|
|
|
#endif
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-09-25 04:30:13 -04:00
|
|
|
meta_verbose ("Window 0x%x has no shadow as it fell through\n",
|
|
|
|
(guint)priv->xwindow);
|
2008-06-06 09:17:38 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-07 09:52:21 -04:00
|
|
|
Window
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_get_x_window (MutterWindow *mcw)
|
2008-10-07 09:52:21 -04:00
|
|
|
{
|
|
|
|
if (!mcw)
|
|
|
|
return None;
|
|
|
|
|
|
|
|
return mcw->priv->xwindow;
|
|
|
|
}
|
|
|
|
|
2008-11-07 03:23:39 -05:00
|
|
|
/**
|
|
|
|
* mutter_window_get_meta_window:
|
|
|
|
*
|
|
|
|
* Gets the MetaWindow object that the the MutterWindow is displaying
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the displayed MetaWindow
|
|
|
|
*/
|
2008-10-24 05:07:24 -04:00
|
|
|
MetaWindow *
|
|
|
|
mutter_window_get_meta_window (MutterWindow *mcw)
|
|
|
|
{
|
|
|
|
return mcw->priv->window;
|
|
|
|
}
|
|
|
|
|
2008-11-07 03:23:39 -05:00
|
|
|
/**
|
|
|
|
* mutter_window_get_texture:
|
|
|
|
*
|
|
|
|
* Gets the ClutterActor that is used to display the contents of the window
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the ClutterActor for the contents
|
|
|
|
*/
|
2008-10-24 05:07:24 -04:00
|
|
|
ClutterActor *
|
|
|
|
mutter_window_get_texture (MutterWindow *mcw)
|
|
|
|
{
|
|
|
|
return mcw->priv->actor;
|
|
|
|
}
|
|
|
|
|
2008-10-07 09:52:21 -04:00
|
|
|
MetaCompWindowType
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_get_window_type (MutterWindow *mcw)
|
2008-10-07 09:52:21 -04:00
|
|
|
{
|
|
|
|
if (!mcw)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return mcw->priv->type;
|
|
|
|
}
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
gboolean
|
|
|
|
mutter_window_is_override_redirect (MutterWindow *mcw)
|
|
|
|
{
|
|
|
|
if (!mcw->priv->window)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 04:30:42 -04:00
|
|
|
const char *mutter_window_get_description (MutterWindow *mcw)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* For windows managed by the WM, we just defer to the WM for the window
|
|
|
|
* description. For override-redirect windows, we create the description
|
|
|
|
* ourselves, but only on demand.
|
|
|
|
*/
|
|
|
|
if (mcw->priv->window)
|
|
|
|
return meta_window_get_description (mcw->priv->window);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (mcw->priv->desc == NULL))
|
|
|
|
{
|
|
|
|
mcw->priv->desc = g_strdup_printf ("Override Redirect (0x%x)",
|
|
|
|
(guint) mcw->priv->xwindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mcw->priv->desc;
|
|
|
|
}
|
|
|
|
|
2008-10-07 09:52:21 -04:00
|
|
|
gint
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_get_workspace (MutterWindow *mcw)
|
2008-10-07 09:52:21 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv;
|
2008-10-30 04:30:42 -04:00
|
|
|
MetaWorkspace *workspace;
|
2008-10-07 09:52:21 -04:00
|
|
|
|
|
|
|
if (!mcw)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
priv = mcw->priv;
|
|
|
|
|
|
|
|
if (!priv->window || meta_window_is_on_all_workspaces (priv->window))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
workspace = meta_window_get_workspace (priv->window);
|
|
|
|
|
|
|
|
return meta_workspace_index (workspace);
|
|
|
|
}
|
|
|
|
|
2008-11-03 09:50:22 -05:00
|
|
|
gboolean
|
2008-11-03 09:45:28 -05:00
|
|
|
mutter_window_showing_on_its_workspace (MutterWindow *mcw)
|
|
|
|
{
|
2008-10-24 05:07:24 -04:00
|
|
|
if (!mcw)
|
|
|
|
return FALSE;
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2008-11-03 09:45:28 -05:00
|
|
|
/* If override redirect: */
|
|
|
|
if (!mcw->priv->window)
|
|
|
|
return TRUE;
|
2008-10-24 05:07:24 -04:00
|
|
|
|
2008-11-03 09:45:28 -05:00
|
|
|
return meta_window_showing_on_its_workspace (mcw->priv->window);
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
|
|
|
|
2008-11-03 09:50:22 -05:00
|
|
|
static void repair_win (MutterWindow *cw);
|
2008-10-16 07:50:01 -04:00
|
|
|
static void map_win (MutterWindow *cw);
|
|
|
|
static void unmap_win (MutterWindow *cw);
|
2008-11-23 14:28:40 -05:00
|
|
|
static void sync_actor_stacking (GList *windows);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_finish_workspace_switch (MetaCompScreen *info)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
#ifdef FIXME
|
2008-09-18 11:09:11 -04:00
|
|
|
GList *last = g_list_last (info->windows);
|
2008-10-24 05:07:24 -04:00
|
|
|
GList *l;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
/* printf ("FINISHING DESKTOP SWITCH\n"); */
|
|
|
|
|
|
|
|
if (!meta_prefs_get_live_hidden_windows ())
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-24 05:07:24 -04:00
|
|
|
/* When running in the traditional mode where hidden windows get
|
|
|
|
* unmapped, we need to fix up the map status for each window, since
|
|
|
|
* we are ignoring unmap requests during the effect.
|
|
|
|
*/
|
|
|
|
l = last;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
while (l)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-24 05:07:24 -04:00
|
|
|
MutterWindow *cw = l->data;
|
|
|
|
MutterWindowPrivate *priv = cw->priv;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
if (priv->needs_map && !priv->needs_unmap)
|
|
|
|
{
|
|
|
|
map_win (cw);
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
if (priv->needs_unmap)
|
|
|
|
{
|
|
|
|
unmap_win (cw);
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->prev;
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-11-23 14:28:40 -05:00
|
|
|
#endif
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
2008-10-24 05:07:24 -04:00
|
|
|
* Fix up stacking order in case the plugin messed it up.
|
2008-09-18 11:09:11 -04:00
|
|
|
*/
|
2008-11-23 14:28:40 -05:00
|
|
|
sync_actor_stacking (info->windows);
|
2008-10-24 05:07:24 -04:00
|
|
|
|
|
|
|
/* printf ("... FINISHED DESKTOP SWITCH\n"); */
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-10-24 05:07:24 -04:00
|
|
|
mutter_window_effect_completed (MutterWindow *cw, gulong event)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = cw->priv;
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaScreen *screen = priv->screen;
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (cw);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
case MUTTER_PLUGIN_MINIMIZE:
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
ClutterActor *a = CLUTTER_ACTOR (cw);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
priv->minimize_in_progress--;
|
|
|
|
if (priv->minimize_in_progress < 0)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
g_warning ("Error in minimize accounting.");
|
|
|
|
priv->minimize_in_progress = 0;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!priv->minimize_in_progress)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
priv->is_minimized = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We must ensure that the minimized actor is pushed down the stack
|
|
|
|
* (the XConfigureEvent has 'above' semantics, i.e., when a window
|
|
|
|
* is lowered, we get a bunch of 'raise' notifications, but might
|
|
|
|
* not get any notification for the window that has been lowered.
|
|
|
|
*/
|
|
|
|
clutter_actor_lower_bottom (a);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/* Make sure that after the effect finishes, the actor is
|
|
|
|
* made visible for sake of live previews.
|
|
|
|
*/
|
|
|
|
clutter_actor_show (a);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-11-23 14:28:40 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MUTTER_PLUGIN_MAP:
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!priv->map_in_progress && priv->window)
|
|
|
|
{
|
|
|
|
MetaRectangle rect;
|
|
|
|
meta_window_get_outer_rect (priv->window, &rect);
|
|
|
|
priv->is_minimized = FALSE;
|
|
|
|
clutter_actor_set_anchor_point (actor, 0, 0);
|
|
|
|
clutter_actor_set_position (actor, rect.x, rect.y);
|
|
|
|
clutter_actor_show_all (actor);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MUTTER_PLUGIN_DESTROY:
|
|
|
|
priv->destroy_in_progress--;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (priv->destroy_in_progress < 0)
|
|
|
|
{
|
|
|
|
g_warning ("Error in destroy accounting.");
|
|
|
|
priv->destroy_in_progress = 0;
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!priv->destroy_in_progress)
|
|
|
|
priv->needs_destroy = TRUE;
|
|
|
|
break;
|
|
|
|
case MUTTER_PLUGIN_UNMAXIMIZE:
|
|
|
|
priv->unmaximize_in_progress--;
|
|
|
|
if (priv->unmaximize_in_progress < 0)
|
|
|
|
{
|
|
|
|
g_warning ("Error in unmaximize accounting.");
|
|
|
|
priv->unmaximize_in_progress = 0;
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!priv->unmaximize_in_progress && priv->window)
|
|
|
|
{
|
|
|
|
MetaRectangle rect;
|
|
|
|
meta_window_get_outer_rect (priv->window, &rect);
|
|
|
|
clutter_actor_set_position (actor, rect.x, rect.y);
|
|
|
|
mutter_window_detach (cw);
|
|
|
|
repair_win (cw);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MUTTER_PLUGIN_MAXIMIZE:
|
|
|
|
priv->maximize_in_progress--;
|
|
|
|
if (priv->maximize_in_progress < 0)
|
|
|
|
{
|
|
|
|
g_warning ("Error in maximize accounting.");
|
|
|
|
priv->maximize_in_progress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->maximize_in_progress && priv->window)
|
|
|
|
{
|
|
|
|
MetaRectangle rect;
|
|
|
|
meta_window_get_outer_rect (priv->window, &rect);
|
|
|
|
clutter_actor_set_position (actor, rect.x, rect.y);
|
|
|
|
mutter_window_detach (cw);
|
|
|
|
repair_win (cw);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MUTTER_PLUGIN_SWITCH_WORKSPACE:
|
|
|
|
/* FIXME -- must redo stacking order */
|
|
|
|
info->switch_workspace_in_progress--;
|
|
|
|
if (info->switch_workspace_in_progress < 0)
|
|
|
|
{
|
|
|
|
g_warning ("Error in workspace_switch accounting!");
|
|
|
|
info->switch_workspace_in_progress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!info->switch_workspace_in_progress)
|
|
|
|
mutter_finish_workspace_switch (info);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case MUTTER_PLUGIN_MINIMIZE:
|
|
|
|
case MUTTER_PLUGIN_MAP:
|
|
|
|
case MUTTER_PLUGIN_DESTROY:
|
|
|
|
case MUTTER_PLUGIN_UNMAXIMIZE:
|
|
|
|
case MUTTER_PLUGIN_MAXIMIZE:
|
|
|
|
if (priv->needs_destroy)
|
|
|
|
{
|
|
|
|
if (priv->minimize_in_progress ||
|
|
|
|
priv->maximize_in_progress ||
|
|
|
|
priv->unmaximize_in_progress ||
|
|
|
|
priv->map_in_progress ||
|
|
|
|
priv->destroy_in_progress)
|
|
|
|
{
|
|
|
|
/* wait until last effect finished */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
clutter_actor_destroy (CLUTTER_ACTOR (cw));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_destroy (MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
#endif
|
2008-08-18 10:44:26 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* If force is TRUE, free the back pixmap; if FALSE, only free it if the
|
|
|
|
* backing pixmap has actually changed.
|
|
|
|
*/
|
2008-06-04 08:58:36 -04:00
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_detach (MutterWindow *self)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = self->priv;
|
2008-09-18 11:09:11 -04:00
|
|
|
MetaScreen *screen = priv->screen;
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
if (!priv->back_pixmap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
XFreePixmap (xdisplay, priv->back_pixmap);
|
|
|
|
priv->back_pixmap = None;
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
destroy_win (MutterWindow *cw)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-31 05:10:10 -04:00
|
|
|
MetaWindow *window;
|
2008-10-24 05:07:24 -04:00
|
|
|
MetaCompScreen *info;
|
|
|
|
MutterWindowPrivate *priv;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
priv = cw->priv;
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
window = priv->window;
|
|
|
|
meta_window_set_compositor_private (window, NULL);
|
2008-10-24 05:07:24 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We remove the window from internal lookup hashes and thus any other
|
|
|
|
* unmap events etc fail
|
|
|
|
*/
|
2008-11-23 14:28:40 -05:00
|
|
|
info = meta_screen_get_compositor_data (priv->screen);
|
2008-10-24 05:07:24 -04:00
|
|
|
info->windows = g_list_remove (info->windows, (gconstpointer) cw);
|
|
|
|
g_hash_table_remove (info->windows_by_xid, (gpointer)priv->xwindow);
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (priv->type == META_COMP_WINDOW_DROPDOWN_MENU ||
|
|
|
|
priv->type == META_COMP_WINDOW_POPUP_MENU ||
|
|
|
|
priv->type == META_COMP_WINDOW_TOOLTIP ||
|
|
|
|
priv->type == META_COMP_WINDOW_NOTIFICATION ||
|
|
|
|
priv->type == META_COMP_WINDOW_COMBO ||
|
|
|
|
priv->type == META_COMP_WINDOW_DND ||
|
|
|
|
priv->type == META_COMP_WINDOW_OVERRIDE_OTHER)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* No effects, just kill it.
|
|
|
|
*/
|
|
|
|
clutter_actor_destroy (CLUTTER_ACTOR (cw));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a plugin manager is present, try to run an effect; if no effect of this
|
|
|
|
* type is present, destroy the actor.
|
|
|
|
*/
|
|
|
|
priv->destroy_in_progress++;
|
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
|
|
|
!mutter_plugin_manager_event_simple (info->plugin_mgr,
|
|
|
|
cw,
|
|
|
|
MUTTER_PLUGIN_DESTROY))
|
|
|
|
{
|
|
|
|
priv->destroy_in_progress--;
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (priv->minimize_in_progress ||
|
|
|
|
priv->maximize_in_progress ||
|
|
|
|
priv->unmaximize_in_progress ||
|
|
|
|
priv->map_in_progress)
|
|
|
|
{
|
|
|
|
priv->needs_destroy = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
clutter_actor_destroy (CLUTTER_ACTOR (cw));
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
sync_actor_position (MutterWindow *cw)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = cw->priv;
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaRectangle window_rect;
|
|
|
|
|
|
|
|
meta_window_get_outer_rect (priv->window, &window_rect);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (priv->attrs.width != window_rect.width ||
|
|
|
|
priv->attrs.height != window_rect.height)
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_detach (cw);
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/* XXX deprecated: please use meta_window_get_outer_rect instead */
|
|
|
|
priv->attrs.width = window_rect.width;
|
|
|
|
priv->attrs.height = window_rect.height;
|
|
|
|
priv->attrs.x = window_rect.x;
|
|
|
|
priv->attrs.y = window_rect.y;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
if (priv->maximize_in_progress ||
|
|
|
|
priv->unmaximize_in_progress ||
|
2008-12-18 23:08:38 -05:00
|
|
|
priv->minimize_in_progress ||
|
2008-09-18 11:09:11 -04:00
|
|
|
priv->map_in_progress)
|
|
|
|
return;
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_actor_set_position (CLUTTER_ACTOR (cw),
|
|
|
|
window_rect.x, window_rect.y);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
map_win (MutterWindow *cw)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv;
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaCompScreen *info;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!cw)
|
2008-06-04 08:58:36 -04:00
|
|
|
return;
|
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
priv = cw->priv;
|
2008-09-18 11:09:11 -04:00
|
|
|
info = meta_screen_get_compositor_data (priv->screen);
|
|
|
|
|
|
|
|
if (priv->attrs.map_state == IsViewable)
|
|
|
|
return;
|
2008-08-19 12:02:00 -04:00
|
|
|
|
|
|
|
priv->attrs.map_state = IsViewable;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* Now repair the window; this ensures that the actor is correctly sized
|
|
|
|
* before we run any effects on it.
|
|
|
|
*/
|
|
|
|
priv->needs_map = FALSE;
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_detach (cw);
|
2008-09-18 11:09:11 -04:00
|
|
|
repair_win (cw);
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* Make sure the position is set correctly (we might have got moved while
|
|
|
|
* unmapped.
|
|
|
|
*/
|
|
|
|
if (!info->switch_workspace_in_progress)
|
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaRectangle rect;
|
|
|
|
meta_window_get_outer_rect (priv->window, &rect);
|
2008-09-18 11:09:11 -04:00
|
|
|
clutter_actor_set_anchor_point (CLUTTER_ACTOR (cw), 0, 0);
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_actor_set_position (CLUTTER_ACTOR (cw), rect.x, rect.y);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
priv->map_in_progress++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a plugin manager is present, try to run an effect; if no effect of this
|
|
|
|
* type is present, destroy the actor.
|
|
|
|
*/
|
|
|
|
if (info->switch_workspace_in_progress || !info->plugin_mgr ||
|
2008-10-16 07:50:01 -04:00
|
|
|
!mutter_plugin_manager_event_simple (info->plugin_mgr,
|
2008-10-07 11:29:03 -04:00
|
|
|
cw,
|
2008-10-16 07:50:01 -04:00
|
|
|
MUTTER_PLUGIN_MAP))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
clutter_actor_show_all (CLUTTER_ACTOR (cw));
|
|
|
|
priv->map_in_progress--;
|
|
|
|
priv->is_minimized = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
unmap_win (MutterWindow *cw)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv;
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaCompScreen *info;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!cw)
|
2008-08-19 12:02:00 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
priv = cw->priv;
|
2008-09-18 11:09:11 -04:00
|
|
|
info = meta_screen_get_compositor_data (priv->screen);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the needs_unmap flag is set, we carry on even if the winow is
|
|
|
|
* already marked as unmapped; this is necessary so windows temporarily
|
|
|
|
* shown during an effect (like desktop switch) are properly hidden again.
|
|
|
|
*/
|
|
|
|
if (priv->attrs.map_state == IsUnmapped && !priv->needs_unmap)
|
|
|
|
return;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->window && priv->window == info->focus_window)
|
2008-06-04 08:58:36 -04:00
|
|
|
info->focus_window = NULL;
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
if (info->switch_workspace_in_progress)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Cannot unmap windows while switching desktops effect is in progress.
|
|
|
|
*/
|
|
|
|
priv->needs_unmap = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
priv->attrs.map_state = IsUnmapped;
|
2008-10-24 05:07:24 -04:00
|
|
|
priv->needs_unmap = FALSE;
|
|
|
|
priv->needs_map = FALSE;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
if (!priv->minimize_in_progress &&
|
|
|
|
(!meta_prefs_get_live_hidden_windows () ||
|
2008-11-23 14:28:40 -05:00
|
|
|
priv->type == META_COMP_WINDOW_DROPDOWN_MENU ||
|
|
|
|
priv->type == META_COMP_WINDOW_POPUP_MENU ||
|
|
|
|
priv->type == META_COMP_WINDOW_TOOLTIP ||
|
|
|
|
priv->type == META_COMP_WINDOW_NOTIFICATION ||
|
|
|
|
priv->type == META_COMP_WINDOW_COMBO ||
|
|
|
|
priv->type == META_COMP_WINDOW_DND ||
|
|
|
|
priv->type == META_COMP_WINDOW_OVERRIDE_OTHER))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-24 05:07:24 -04:00
|
|
|
clutter_actor_hide (CLUTTER_ACTOR (cw));
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
add_win (MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-10-28 09:02:33 -04:00
|
|
|
MutterWindow *cw;
|
|
|
|
MutterWindowPrivate *priv;
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaFrame *frame;
|
|
|
|
Window top_window;
|
|
|
|
XWindowAttributes attrs;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
|
|
|
frame = meta_window_get_frame (window);
|
|
|
|
if (frame)
|
|
|
|
top_window = meta_frame_get_xwindow (frame);
|
|
|
|
else
|
|
|
|
top_window = meta_window_get_xwindow (window);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
meta_verbose ("add window: Meta %p, xwin 0x%x\n", window, (guint)top_window);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/* FIXME: Remove the redundant data we store in cw->priv->attrs, and
|
|
|
|
* simply query metacity core for the data. */
|
|
|
|
if (!XGetWindowAttributes (display->xdisplay, top_window, &attrs))
|
2008-10-24 05:07:24 -04:00
|
|
|
return;
|
2008-08-20 06:48:00 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
cw = g_object_new (MUTTER_TYPE_COMP_WINDOW,
|
2008-08-20 06:48:00 -04:00
|
|
|
"meta-window", window,
|
2008-11-23 14:28:40 -05:00
|
|
|
"x-window", top_window,
|
2008-08-20 06:48:00 -04:00
|
|
|
"meta-screen", screen,
|
|
|
|
"x-window-attributes", &attrs,
|
2008-08-19 12:02:00 -04:00
|
|
|
NULL);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
priv = cw->priv;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
clutter_actor_set_position (CLUTTER_ACTOR (cw),
|
|
|
|
priv->attrs.x, priv->attrs.y);
|
2008-10-28 09:02:33 -04:00
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (info->window_group),
|
2008-08-19 12:02:00 -04:00
|
|
|
CLUTTER_ACTOR (cw));
|
|
|
|
clutter_actor_hide (CLUTTER_ACTOR (cw));
|
2008-08-19 05:57:15 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->type == META_COMP_WINDOW_DOCK)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-11-23 14:28:40 -05:00
|
|
|
meta_verbose ("Appending 0x%x to dock windows\n", (guint)top_window);
|
2008-06-04 08:58:36 -04:00
|
|
|
info->dock_windows = g_slist_append (info->dock_windows, cw);
|
|
|
|
}
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
meta_verbose ("added 0x%x (%p) type:", (guint)top_window, cw);
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/* Hang our compositor window state off the MetaWindow for fast retrieval */
|
|
|
|
meta_window_set_compositor_private (window, cw);
|
2008-06-09 12:50:56 -04:00
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
/*
|
|
|
|
* Add this to the list at the top of the stack before it is mapped so that
|
|
|
|
* map_win can find it again
|
|
|
|
*/
|
2008-11-23 14:28:40 -05:00
|
|
|
info->windows = g_list_append (info->windows, cw);
|
|
|
|
g_hash_table_insert (info->windows_by_xid, (gpointer) top_window, cw);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->attrs.map_state == IsViewable)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
/* Need to reset the map_state for map_win() to work */
|
|
|
|
priv->attrs.map_state = IsUnmapped;
|
|
|
|
map_win (cw);
|
|
|
|
}
|
2008-11-23 14:28:40 -05:00
|
|
|
|
|
|
|
sync_actor_stacking (info->windows);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
repair_win (MutterWindow *cw)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = cw->priv;
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaScreen *screen = priv->screen;
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
Mutter *compositor;
|
|
|
|
Window xwindow = priv->xwindow;
|
|
|
|
gboolean full = FALSE;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (xwindow == meta_screen_get_xroot (screen) ||
|
|
|
|
xwindow == clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage)))
|
2008-06-04 08:58:36 -04:00
|
|
|
return;
|
|
|
|
|
2008-11-05 06:48:07 -05:00
|
|
|
compositor = (Mutter*)meta_display_get_compositor (display);
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_error_trap_push (display);
|
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->back_pixmap == None)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
gint pxm_width, pxm_height;
|
2008-09-18 11:09:11 -04:00
|
|
|
XWindowAttributes attr;
|
|
|
|
|
|
|
|
meta_error_trap_push (display);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
XGrabServer (xdisplay);
|
|
|
|
|
|
|
|
XGetWindowAttributes (xdisplay, xwindow, &attr);
|
|
|
|
|
|
|
|
if (attr.map_state == IsViewable)
|
|
|
|
priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
priv->back_pixmap = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
XUngrabServer (xdisplay);
|
|
|
|
meta_error_trap_pop (display, FALSE);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->back_pixmap == None)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-19 04:20:04 -04:00
|
|
|
meta_verbose ("Unable to get named pixmap for %p\n", cw);
|
2008-06-04 08:58:36 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 12:28:33 -04:00
|
|
|
/* MUST call before setting pixmap or serious performance issues
|
|
|
|
* seemingly caused by cogl_texture_set_filters() in set_filter
|
|
|
|
* Not sure if that call is actually needed.
|
|
|
|
*/
|
2008-11-05 06:48:07 -05:00
|
|
|
if (!compositor->no_mipmaps)
|
|
|
|
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (priv->actor),
|
|
|
|
CLUTTER_TEXTURE_QUALITY_HIGH );
|
2008-10-31 12:28:33 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
clutter_x11_texture_pixmap_set_pixmap
|
2008-08-19 12:02:00 -04:00
|
|
|
(CLUTTER_X11_TEXTURE_PIXMAP (priv->actor),
|
|
|
|
priv->back_pixmap);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
g_object_get (priv->actor,
|
2008-06-04 08:58:36 -04:00
|
|
|
"pixmap-width", &pxm_width,
|
|
|
|
"pixmap-height", &pxm_height,
|
|
|
|
NULL);
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
clutter_actor_set_size (priv->actor, pxm_width, pxm_height);
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (priv->shadow)
|
|
|
|
clutter_actor_set_size (priv->shadow, pxm_width, pxm_height);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
full = TRUE;
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
2008-11-03 12:49:24 -05:00
|
|
|
/*
|
2008-08-19 05:15:16 -04:00
|
|
|
* TODO -- on some gfx hardware updating the whole texture instead of
|
|
|
|
* the individual rectangles is actually quicker, so we might want to
|
|
|
|
* make this a configurable option (on desktop HW with multiple pipelines
|
|
|
|
* it is usually quicker to just update the damaged parts).
|
|
|
|
*
|
|
|
|
* If we are using TFP we update the whole texture (this simply trigers
|
|
|
|
* the texture rebind).
|
|
|
|
*/
|
2008-09-30 10:33:18 -04:00
|
|
|
if (full
|
|
|
|
#ifdef HAVE_GLX_TEXTURE_PIXMAP
|
|
|
|
|| (CLUTTER_GLX_IS_TEXTURE_PIXMAP (priv->actor) &&
|
|
|
|
clutter_glx_texture_pixmap_using_extension
|
|
|
|
(CLUTTER_GLX_TEXTURE_PIXMAP (priv->actor)))
|
|
|
|
#endif /* HAVE_GLX_TEXTURE_PIXMAP */
|
|
|
|
)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-19 12:02:00 -04:00
|
|
|
XDamageSubtract (xdisplay, priv->damage, None, None);
|
2008-08-19 05:15:16 -04:00
|
|
|
|
|
|
|
clutter_x11_texture_pixmap_update_area
|
2008-08-19 12:02:00 -04:00
|
|
|
(CLUTTER_X11_TEXTURE_PIXMAP (priv->actor),
|
2008-08-19 05:15:16 -04:00
|
|
|
0,
|
|
|
|
0,
|
2008-08-19 12:02:00 -04:00
|
|
|
clutter_actor_get_width (priv->actor),
|
|
|
|
clutter_actor_get_height (priv->actor));
|
2008-08-18 10:44:26 -04:00
|
|
|
}
|
|
|
|
else
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
XRectangle *r_damage;
|
|
|
|
XRectangle r_bounds;
|
|
|
|
XserverRegion parts;
|
2008-08-19 05:15:16 -04:00
|
|
|
int i, r_count;
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
parts = XFixesCreateRegion (xdisplay, 0, 0);
|
2008-08-19 12:02:00 -04:00
|
|
|
XDamageSubtract (xdisplay, priv->damage, None, parts);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-08-19 05:15:16 -04:00
|
|
|
r_damage = XFixesFetchRegionAndBounds (xdisplay,
|
|
|
|
parts,
|
|
|
|
&r_count,
|
|
|
|
&r_bounds);
|
2008-06-09 12:50:56 -04:00
|
|
|
|
2008-08-19 05:15:16 -04:00
|
|
|
if (r_damage)
|
|
|
|
{
|
|
|
|
for (i = 0; i < r_count; ++i)
|
|
|
|
{
|
|
|
|
clutter_x11_texture_pixmap_update_area
|
2008-08-19 12:02:00 -04:00
|
|
|
(CLUTTER_X11_TEXTURE_PIXMAP (priv->actor),
|
2008-08-19 05:15:16 -04:00
|
|
|
r_damage[i].x,
|
|
|
|
r_damage[i].y,
|
|
|
|
r_damage[i].width,
|
|
|
|
r_damage[i].height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree (r_damage);
|
|
|
|
XFixesDestroyRegion (xdisplay, parts);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
meta_error_trap_pop (display, FALSE);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
priv->needs_repair = FALSE;
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
process_damage (Mutter *compositor,
|
2008-06-04 08:58:36 -04:00
|
|
|
XDamageNotifyEvent *event)
|
|
|
|
{
|
2008-08-19 04:20:04 -04:00
|
|
|
XEvent next;
|
|
|
|
Display *dpy = event->display;
|
|
|
|
Drawable drawable = event->drawable;
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv;
|
|
|
|
MutterWindow *cw = find_window_in_display (compositor->display, drawable);
|
2008-08-19 04:20:04 -04:00
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
if (!cw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv = cw->priv;
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
if (priv->destroy_pending ||
|
|
|
|
priv->maximize_in_progress ||
|
|
|
|
priv->unmaximize_in_progress)
|
|
|
|
{
|
|
|
|
priv->needs_repair = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* Check if the event queue does not already contain DetstroyNotify for this
|
|
|
|
* window -- if it does, we need to stop updating the pixmap (to avoid damage
|
|
|
|
* notifications that come from the window teardown), and process the destroy
|
|
|
|
* immediately.
|
|
|
|
*/
|
2008-08-19 04:20:04 -04:00
|
|
|
if (XCheckTypedWindowEvent (dpy, drawable, DestroyNotify, &next))
|
|
|
|
{
|
2008-08-19 12:02:00 -04:00
|
|
|
priv->destroy_pending = TRUE;
|
2008-11-23 14:28:40 -05:00
|
|
|
destroy_win (cw);
|
2008-08-19 04:20:04 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
repair_win (cw);
|
|
|
|
}
|
|
|
|
|
2008-09-24 17:53:39 -04:00
|
|
|
static void
|
2008-10-16 07:50:01 -04:00
|
|
|
update_shape (Mutter *compositor,
|
|
|
|
MutterWindow *cw)
|
2008-09-24 17:53:39 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindowPrivate *priv = cw->priv;
|
2008-09-24 17:53:39 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_shaped_texture_clear_rectangles (MUTTER_SHAPED_TEXTURE (priv->actor));
|
2008-09-24 17:53:39 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_SHAPE
|
|
|
|
if (priv->shaped)
|
|
|
|
{
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (compositor->display);
|
|
|
|
XRectangle *rects;
|
|
|
|
int n_rects, ordering;
|
|
|
|
|
|
|
|
rects = XShapeGetRectangles (xdisplay,
|
|
|
|
priv->xwindow,
|
|
|
|
ShapeBounding,
|
|
|
|
&n_rects,
|
|
|
|
&ordering);
|
|
|
|
|
|
|
|
if (rects)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_shaped_texture_add_rectangles (MUTTER_SHAPED_TEXTURE (priv->actor),
|
2008-09-24 17:53:39 -04:00
|
|
|
n_rects, rects);
|
|
|
|
|
|
|
|
XFree (rects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_SHAPE
|
|
|
|
static void
|
2008-10-31 05:10:10 -04:00
|
|
|
process_shape (Mutter *compositor,
|
|
|
|
XShapeEvent *event)
|
2008-09-24 17:53:39 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindow *cw = find_window_in_display (compositor->display,
|
2008-10-31 05:10:10 -04:00
|
|
|
event->window);
|
2008-11-23 14:28:40 -05:00
|
|
|
MutterWindowPrivate *priv;
|
2008-09-24 17:53:39 -04:00
|
|
|
|
|
|
|
if (cw == NULL)
|
|
|
|
return;
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
priv = cw->priv;
|
|
|
|
|
2008-09-25 04:30:13 -04:00
|
|
|
if (event->kind == ShapeBounding)
|
2008-09-24 17:53:39 -04:00
|
|
|
{
|
2008-09-25 08:30:34 -04:00
|
|
|
priv->shaped = event->shaped;
|
2008-09-24 17:53:39 -04:00
|
|
|
update_shape (compositor, cw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
static void
|
2008-10-31 05:10:10 -04:00
|
|
|
process_property_notify (Mutter *compositor,
|
|
|
|
XPropertyEvent *event)
|
2008-06-04 15:51:08 -04:00
|
|
|
{
|
|
|
|
MetaDisplay *display = compositor->display;
|
|
|
|
|
|
|
|
/* Check for the opacity changing */
|
2008-08-18 10:44:26 -04:00
|
|
|
if (event->atom == compositor->atom_net_wm_window_opacity)
|
2008-06-04 15:51:08 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindow *cw = find_window_in_display (display, event->window);
|
2008-10-31 05:10:10 -04:00
|
|
|
gulong value;
|
2008-06-04 15:51:08 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
if (!cw)
|
2008-06-04 15:51:08 -04:00
|
|
|
{
|
|
|
|
/* Applications can set this for their toplevel windows, so
|
|
|
|
* this must be propagated to the window managed by the compositor
|
|
|
|
*/
|
2008-08-18 10:44:26 -04:00
|
|
|
cw = find_window_for_child_window_in_display (display,
|
2008-06-04 15:51:08 -04:00
|
|
|
event->window);
|
|
|
|
}
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
if (!cw)
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
|
|
|
DEBUG_TRACE ("process_property_notify: opacity, early exit\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-06-04 15:51:08 -04:00
|
|
|
|
|
|
|
if (meta_prop_get_cardinal (display, event->window,
|
|
|
|
compositor->atom_net_wm_window_opacity,
|
|
|
|
&value) == FALSE)
|
2008-08-19 05:57:15 -04:00
|
|
|
{
|
|
|
|
guint8 opacity;
|
2008-06-04 15:51:08 -04:00
|
|
|
|
2008-08-19 05:57:15 -04:00
|
|
|
opacity = (guint8)((gfloat)value * 255.0 / ((gfloat)0xffffffff));
|
|
|
|
|
2008-08-19 12:02:00 -04:00
|
|
|
cw->priv->opacity = opacity;
|
|
|
|
clutter_actor_set_opacity (CLUTTER_ACTOR (cw), opacity);
|
2008-08-19 05:57:15 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
return;
|
|
|
|
}
|
2008-08-20 04:33:39 -04:00
|
|
|
else if (event->atom == meta_display_get_atom (display,
|
|
|
|
META_ATOM__NET_WM_WINDOW_TYPE))
|
2008-06-04 15:51:08 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterWindow *cw = find_window_in_display (display, event->window);
|
2008-06-04 15:51:08 -04:00
|
|
|
|
|
|
|
if (!cw)
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
|
|
|
DEBUG_TRACE ("process_property_notify: net_wm_type, early exit\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-06-04 15:51:08 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_window_query_window_type (cw);
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("process_property_notify: net_wm_type\n");
|
2008-06-04 15:51:08 -04:00
|
|
|
return;
|
|
|
|
}
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("process_property_notify: unknown\n");
|
2008-06-04 15:51:08 -04:00
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
static void
|
2008-10-21 03:58:44 -04:00
|
|
|
show_overlay_window (Display *xdisplay, Window xstage, Window xoverlay)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
2008-08-20 04:33:39 -04:00
|
|
|
XserverRegion region;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
region = XFixesCreateRegion (xdisplay, NULL, 0);
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-10-21 03:58:44 -04:00
|
|
|
XFixesSetWindowShapeRegion (xdisplay, xoverlay, ShapeBounding, 0, 0, 0);
|
|
|
|
|
|
|
|
XFixesSetWindowShapeRegion (xdisplay, xoverlay, ShapeInput, 0, 0, region);
|
|
|
|
XFixesSetWindowShapeRegion (xdisplay, xstage, ShapeInput, 0, 0, region);
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
XFixesDestroyRegion (xdisplay, region);
|
2008-06-04 08:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static Window
|
|
|
|
get_output_window (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
2008-08-20 04:33:39 -04:00
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
Window output, xroot;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
xroot = meta_screen_get_xroot (screen);
|
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
output = XCompositeGetOverlayWindow (xdisplay, xroot);
|
2008-10-16 10:50:03 -04:00
|
|
|
XSelectInput (xdisplay,
|
|
|
|
output,
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeyPressMask | KeyReleaseMask);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2008-10-09 08:22:32 -04:00
|
|
|
ClutterActor *
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_get_stage_for_screen (MetaScreen *screen)
|
2008-10-09 08:22:32 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->stage;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterActor *
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_get_overlay_group_for_screen (MetaScreen *screen)
|
2008-10-09 08:22:32 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->overlay_group;
|
|
|
|
}
|
|
|
|
|
2008-10-28 07:30:29 -04:00
|
|
|
ClutterActor *
|
|
|
|
mutter_get_window_group_for_screen (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->window_group;
|
|
|
|
}
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
GList *
|
|
|
|
mutter_get_windows (MetaScreen *screen)
|
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return info->windows;
|
|
|
|
}
|
2008-10-09 08:22:32 -04:00
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_manage_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MetaCompScreen *info;
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
|
|
|
int screen_number = meta_screen_get_screen_number (screen);
|
|
|
|
Window xroot = meta_screen_get_xroot (screen);
|
|
|
|
Window xwin;
|
|
|
|
gint width, height;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
|
|
|
/* Check if the screen is already managed */
|
|
|
|
if (meta_screen_get_compositor_data (screen))
|
|
|
|
return;
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
meta_error_trap_push_with_return (display);
|
2008-06-04 08:58:36 -04:00
|
|
|
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
|
|
|
XSync (xdisplay, FALSE);
|
|
|
|
|
2008-08-20 04:33:39 -04:00
|
|
|
if (meta_error_trap_pop_with_return (display, FALSE))
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
g_warning ("Another compositing manager is running on screen %i",
|
|
|
|
screen_number);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = g_new0 (MetaCompScreen, 1);
|
|
|
|
info->screen = screen;
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_screen_set_compositor_data (screen, info);
|
|
|
|
|
|
|
|
info->output = get_output_window (screen);
|
|
|
|
|
|
|
|
info->windows = NULL;
|
|
|
|
info->windows_by_xid = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
|
|
|
info->focus_window = meta_display_get_focus_window (display);
|
|
|
|
|
|
|
|
XClearArea (xdisplay, info->output, 0, 0, 0, 0, TRUE);
|
|
|
|
|
|
|
|
meta_screen_set_cm_selection (screen);
|
|
|
|
|
|
|
|
info->stage = clutter_stage_get_default ();
|
|
|
|
|
|
|
|
meta_screen_get_size (screen, &width, &height);
|
|
|
|
clutter_actor_set_size (info->stage, width, height);
|
|
|
|
|
|
|
|
xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
|
|
|
|
|
|
|
|
XReparentWindow (xdisplay, xwin, info->output, 0, 0);
|
|
|
|
|
2008-10-16 10:50:03 -04:00
|
|
|
XSelectInput (xdisplay,
|
|
|
|
xwin,
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeyPressMask | KeyReleaseMask);
|
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
info->window_group = clutter_group_new ();
|
|
|
|
info->overlay_group = clutter_group_new ();
|
2008-11-03 05:26:21 -05:00
|
|
|
info->hidden_group = clutter_group_new ();
|
2008-10-02 07:16:15 -04:00
|
|
|
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (info->stage),
|
|
|
|
info->window_group,
|
|
|
|
info->overlay_group,
|
2008-11-03 05:26:21 -05:00
|
|
|
info->hidden_group,
|
2008-10-02 07:16:15 -04:00
|
|
|
NULL);
|
|
|
|
|
2008-11-03 05:26:21 -05:00
|
|
|
clutter_actor_hide (info->hidden_group);
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-10-21 03:58:44 -04:00
|
|
|
/*
|
|
|
|
* Must do this *before* creating the plugin manager, in case any of the
|
|
|
|
* plugins need to adjust the screen shape regions.
|
|
|
|
*/
|
|
|
|
show_overlay_window (xdisplay, xwin, info->output);
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
info->plugin_mgr =
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_new (screen);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-31 18:59:04 -04:00
|
|
|
clutter_actor_show (info->stage);
|
|
|
|
clutter_actor_show (info->overlay_group);
|
2008-06-04 08:58:36 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_unmanage_screen (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_add_window (MetaCompositor *compositor,
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaDisplay *display = meta_screen_get_display (screen);
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_add_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
meta_error_trap_push (display);
|
2008-10-24 05:07:24 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
add_win (window);
|
|
|
|
|
|
|
|
meta_error_trap_pop (display, FALSE);
|
2008-06-04 08:58:36 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_remove_window (MetaCompositor *compositor,
|
2008-11-23 14:28:40 -05:00
|
|
|
MetaWindow *window)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-11-23 14:28:40 -05:00
|
|
|
MutterWindow *cw = NULL;
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_remove_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
cw = meta_window_get_compositor_private (window);
|
|
|
|
if (!cw)
|
|
|
|
return;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
destroy_win (cw);
|
2008-06-04 08:58:36 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_set_updates (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean update)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_process_event (MetaCompositor *compositor,
|
|
|
|
XEvent *event,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-10-16 07:50:01 -04:00
|
|
|
Mutter *xrc = (Mutter *) compositor;
|
2008-10-02 07:16:15 -04:00
|
|
|
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
MetaCompScreen *info;
|
|
|
|
MetaScreen *screen;
|
|
|
|
|
|
|
|
screen = meta_window_get_screen (window);
|
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
if (mutter_plugin_manager_xevent_filter (info->plugin_mgr,
|
|
|
|
event) == TRUE)
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
|
|
|
DEBUG_TRACE ("clutter_cmp_process_event (filtered,window==NULL)\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-10-02 07:16:15 -04:00
|
|
|
}
|
2008-10-16 10:50:03 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GSList *l;
|
2008-10-16 18:02:34 -04:00
|
|
|
Mutter *clc = (Mutter*)compositor;
|
2008-10-16 10:50:03 -04:00
|
|
|
|
|
|
|
l = meta_display_get_screens (clc->display);
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
MetaScreen *screen = l->data;
|
|
|
|
MetaCompScreen *info;
|
|
|
|
|
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
2008-10-16 18:02:34 -04:00
|
|
|
if (mutter_plugin_manager_xevent_filter (info->plugin_mgr,
|
|
|
|
event) == TRUE)
|
2008-10-16 10:50:03 -04:00
|
|
|
{
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_process_event (filtered,window==NULL)\n");
|
2008-10-16 10:50:03 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
}
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
/*
|
|
|
|
* This trap is so that none of the compositor functions cause
|
|
|
|
* X errors. This is really a hack, but I'm afraid I don't understand
|
|
|
|
* enough about Metacity/X to know how else you are supposed to do it
|
|
|
|
*/
|
2008-06-09 12:50:56 -04:00
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_error_trap_push (xrc->display);
|
2008-08-18 10:44:26 -04:00
|
|
|
switch (event->type)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
case PropertyNotify:
|
2008-06-04 15:51:08 -04:00
|
|
|
process_property_notify (xrc, (XPropertyEvent *) event);
|
2008-06-04 08:58:36 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (event->type == meta_display_get_damage_event_base (xrc->display) + XDamageNotify)
|
|
|
|
{
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_process_event (process_damage)\n");
|
2008-06-04 08:58:36 -04:00
|
|
|
process_damage (xrc, (XDamageNotifyEvent *) event);
|
|
|
|
}
|
2008-09-24 17:53:39 -04:00
|
|
|
#ifdef HAVE_SHAPE
|
2008-09-25 04:30:13 -04:00
|
|
|
else if (event->type == meta_display_get_shape_event_base (xrc->display) + ShapeNotify)
|
2008-11-27 08:40:52 -05:00
|
|
|
{
|
|
|
|
DEBUG_TRACE ("clutter_cmp_process_event (process_shape)\n");
|
|
|
|
process_shape (xrc, (XShapeEvent *) event);
|
|
|
|
}
|
2008-09-24 17:53:39 -04:00
|
|
|
#endif /* HAVE_SHAPE */
|
2008-06-04 08:58:36 -04:00
|
|
|
break;
|
|
|
|
}
|
2008-08-18 10:44:26 -04:00
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_error_trap_pop (xrc->display, FALSE);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static Pixmap
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_get_window_pixmap (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
return None;
|
|
|
|
#else
|
|
|
|
return None;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-06-04 08:58:36 -04:00
|
|
|
clutter_cmp_set_active_window (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-18 10:44:26 -04:00
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_cmp_map_window (MetaCompositor *compositor, MetaWindow *window)
|
2008-06-09 12:50:56 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-11-23 14:28:40 -05:00
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_map_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!cw)
|
|
|
|
return;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
map_win (cw);
|
|
|
|
#endif
|
|
|
|
}
|
2008-06-09 12:50:56 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
static void
|
|
|
|
clutter_cmp_unmap_window (MetaCompositor *compositor, MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_unmap_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!cw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
unmap_win (cw);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_cmp_minimize_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *window_rect,
|
|
|
|
MetaRectangle *icon_rect)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_minimize_window\n");
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
g_return_if_fail (info);
|
2008-06-09 12:50:56 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
if (!cw)
|
|
|
|
return;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/*
|
|
|
|
* If there is a plugin manager, try to run an effect; if no effect is
|
|
|
|
* executed, hide the actor.
|
|
|
|
*/
|
|
|
|
cw->priv->minimize_in_progress++;
|
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
|
|
|
!mutter_plugin_manager_event_simple (info->plugin_mgr,
|
|
|
|
cw,
|
|
|
|
MUTTER_PLUGIN_MINIMIZE))
|
|
|
|
{
|
|
|
|
cw->priv->is_minimized = TRUE;
|
|
|
|
cw->priv->minimize_in_progress--;
|
|
|
|
}
|
2008-06-09 12:50:56 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-08-19 06:47:30 -04:00
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_cmp_unminimize_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *window_rect,
|
|
|
|
MetaRectangle *icon_rect)
|
2008-08-19 06:47:30 -04:00
|
|
|
{
|
2008-09-18 11:09:11 -04:00
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-11-23 14:28:40 -05:00
|
|
|
#if 0
|
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
g_return_if_fail (info);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
if (!cw)
|
|
|
|
return;
|
2008-08-19 06:47:30 -04:00
|
|
|
|
|
|
|
/*
|
2008-09-18 11:09:11 -04:00
|
|
|
* If there is a plugin manager, try to run an effect; if no effect is
|
|
|
|
* executed, hide the actor.
|
2008-08-19 06:47:30 -04:00
|
|
|
*/
|
2008-11-23 14:28:40 -05:00
|
|
|
cw->priv->unminimize_in_progress++;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
2008-10-16 07:50:01 -04:00
|
|
|
!mutter_plugin_manager_event_simple (info->plugin_mgr,
|
2008-11-23 14:28:40 -05:00
|
|
|
cw,
|
|
|
|
MUTTER_PLUGIN_UNMINIMIZE))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
cw->priv->is_minimized = TRUE;
|
|
|
|
cw->priv->minimize_in_progress--;
|
|
|
|
}
|
2008-11-23 14:28:40 -05:00
|
|
|
#else
|
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_unminimize_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!cw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
map_win (cw);
|
|
|
|
#endif
|
2008-09-18 11:09:11 -04:00
|
|
|
#endif
|
2008-08-19 06:47:30 -04:00
|
|
|
}
|
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
|
2008-08-19 06:47:30 -04:00
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_cmp_maximize_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *rect)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-11-23 14:28:40 -05:00
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_maximize_window\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
g_return_if_fail (info);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
if (!cw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cw->priv->maximize_in_progress++;
|
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
2008-10-16 07:50:01 -04:00
|
|
|
!mutter_plugin_manager_event_maximize (info->plugin_mgr,
|
2008-11-23 14:28:40 -05:00
|
|
|
cw,
|
|
|
|
MUTTER_PLUGIN_MAXIMIZE,
|
|
|
|
rect->x, rect->y,
|
|
|
|
rect->width, rect->height))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
cw->priv->maximize_in_progress--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_cmp_unmaximize_window (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *rect)
|
2008-08-19 06:47:30 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-11-23 14:28:40 -05:00
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-08-19 06:47:30 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
g_return_if_fail (info);
|
2008-08-19 06:47:30 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_unmaximize_window\n");
|
2008-08-19 06:47:30 -04:00
|
|
|
if (!cw)
|
|
|
|
return;
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
cw->priv->unmaximize_in_progress++;
|
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
2008-10-16 07:50:01 -04:00
|
|
|
!mutter_plugin_manager_event_maximize (info->plugin_mgr,
|
2008-11-23 14:28:40 -05:00
|
|
|
cw,
|
|
|
|
MUTTER_PLUGIN_UNMAXIMIZE,
|
|
|
|
rect->x, rect->y,
|
|
|
|
rect->width, rect->height))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
cw->priv->unmaximize_in_progress--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_cmp_update_workspace_geometry (MetaCompositor *compositor,
|
|
|
|
MetaWorkspace *workspace)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
2008-12-17 04:33:56 -05:00
|
|
|
#if 0
|
|
|
|
/* FIXME -- should do away with this function in favour of MetaWorkspace
|
|
|
|
* signal.
|
|
|
|
*/
|
2008-09-18 11:09:11 -04:00
|
|
|
MetaScreen *screen = meta_workspace_get_screen (workspace);
|
|
|
|
MetaCompScreen *info;
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPluginManager *mgr;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_update_workspace_geometry\n");
|
2008-09-18 11:09:11 -04:00
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
mgr = info->plugin_mgr;
|
|
|
|
|
|
|
|
if (!mgr || !workspace)
|
|
|
|
return;
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_update_workspace (mgr, workspace);
|
2008-09-18 11:09:11 -04:00
|
|
|
#endif
|
2008-12-17 04:33:56 -05:00
|
|
|
#endif
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_cmp_switch_workspace (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
MetaWorkspace *from,
|
2008-10-09 12:57:12 -04:00
|
|
|
MetaWorkspace *to,
|
|
|
|
MetaMotionDirection direction)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MetaCompScreen *info;
|
|
|
|
gint to_indx, from_indx;
|
|
|
|
|
|
|
|
info = meta_screen_get_compositor_data (screen);
|
|
|
|
to_indx = meta_workspace_index (to);
|
|
|
|
from_indx = meta_workspace_index (from);
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_switch_workspace\n");
|
2008-10-24 05:07:24 -04:00
|
|
|
if (!meta_prefs_get_live_hidden_windows ())
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-11-03 09:50:22 -05:00
|
|
|
GList *l;
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
/*
|
|
|
|
* We are in the traditional mode where hidden windows get unmapped,
|
|
|
|
* we need to pre-calculate the map status of each window so that once
|
|
|
|
* the effect finishes we can put everything into proper order
|
|
|
|
* (we need to ignore the map notifications during the effect so that
|
|
|
|
* actors do not just disappear while the effect is running).
|
|
|
|
*/
|
2008-11-03 09:50:22 -05:00
|
|
|
for (l = info->windows; l != NULL; l = l->next)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-24 05:07:24 -04:00
|
|
|
MutterWindow *cw = l->data;
|
2008-11-03 09:50:22 -05:00
|
|
|
MetaWindow *mw = cw->priv->window;
|
|
|
|
gboolean sticky;
|
|
|
|
gint workspace = -1;
|
2008-08-19 06:47:30 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
sticky = (!mw || meta_window_is_on_all_workspaces (mw));
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
if (!sticky)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-24 05:07:24 -04:00
|
|
|
MetaWorkspace *w;
|
|
|
|
|
|
|
|
w = meta_window_get_workspace (cw->priv->window);
|
|
|
|
workspace = meta_workspace_index (w);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the window is not on the target workspace, mark it for
|
|
|
|
* unmap.
|
|
|
|
*/
|
|
|
|
if (to_indx != workspace)
|
|
|
|
{
|
|
|
|
cw->priv->needs_unmap = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cw->priv->needs_map = TRUE;
|
|
|
|
cw->priv->needs_unmap = FALSE;
|
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
info->switch_workspace_in_progress++;
|
|
|
|
|
|
|
|
if (!info->plugin_mgr ||
|
2008-10-24 05:07:24 -04:00
|
|
|
!mutter_plugin_manager_switch_workspace (info->plugin_mgr,
|
|
|
|
(const GList **)&info->windows,
|
|
|
|
from_indx,
|
|
|
|
to_indx,
|
|
|
|
direction))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
info->switch_workspace_in_progress--;
|
2008-10-24 05:07:24 -04:00
|
|
|
|
|
|
|
/* We have to explicitely call this to fix up stacking order of the
|
|
|
|
* actors; this is because the abs stacking position of actors does not
|
|
|
|
* necessarily change during the window hiding/unhiding, only their
|
|
|
|
* relative position toward the destkop window.
|
|
|
|
*/
|
|
|
|
mutter_finish_workspace_switch (info);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-08-19 06:47:30 -04:00
|
|
|
#endif
|
|
|
|
}
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
static void
|
|
|
|
sync_actor_stacking (GList *windows)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-23 14:28:40 -05:00
|
|
|
/* NB: The first entry in the list is stacked the lowest */
|
|
|
|
|
|
|
|
for (tmp = g_list_last (windows); tmp != NULL; tmp = tmp->prev)
|
|
|
|
{
|
|
|
|
MutterWindow *cw = tmp->data;
|
|
|
|
|
|
|
|
clutter_actor_lower_bottom (CLUTTER_ACTOR (cw));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-24 05:07:24 -04:00
|
|
|
static void
|
2008-10-30 18:09:48 -04:00
|
|
|
clutter_cmp_sync_stack (MetaCompositor *compositor,
|
2008-11-03 09:50:22 -05:00
|
|
|
MetaScreen *screen,
|
2008-10-30 18:09:48 -04:00
|
|
|
GList *stack)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
2008-10-30 18:09:48 -04:00
|
|
|
GList *tmp;
|
2008-11-03 09:50:22 -05:00
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-11-27 08:40:52 -05:00
|
|
|
|
|
|
|
DEBUG_TRACE ("clutter_cmp_sync_stack\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
/* NB: The first entry in stack, is stacked the highest */
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2008-10-30 18:09:48 -04:00
|
|
|
for (tmp = stack; tmp != NULL; tmp = tmp->next)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
2008-10-31 05:10:10 -04:00
|
|
|
MetaWindow *window = tmp->data;
|
|
|
|
MutterWindow *cw = window->compositor_private;
|
2008-11-03 09:50:22 -05:00
|
|
|
|
2008-10-30 18:09:48 -04:00
|
|
|
if (!cw)
|
2008-10-24 05:07:24 -04:00
|
|
|
{
|
2008-10-30 18:09:48 -04:00
|
|
|
meta_verbose ("Failed to find corresponding MutterWindow "
|
2008-10-31 05:10:10 -04:00
|
|
|
"for window %p\n", window);
|
2008-10-30 18:09:48 -04:00
|
|
|
continue;
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
2008-11-07 05:13:40 -05:00
|
|
|
|
2008-11-03 09:50:22 -05:00
|
|
|
info->windows = g_list_remove (info->windows, (gconstpointer)cw);
|
|
|
|
info->windows = g_list_prepend (info->windows, cw);
|
|
|
|
}
|
2008-11-23 14:28:40 -05:00
|
|
|
|
|
|
|
sync_actor_stacking (info->windows);
|
2008-11-03 09:50:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_cmp_set_window_hidden (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
MetaWindow *window,
|
|
|
|
gboolean hidden)
|
|
|
|
{
|
|
|
|
MutterWindow *cw = window->compositor_private;
|
2008-11-03 05:26:21 -05:00
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
2008-11-03 09:50:22 -05:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
DEBUG_TRACE ("clutter_cmp_set_window_hidden\n");
|
2008-11-23 14:28:40 -05:00
|
|
|
if (!cw)
|
|
|
|
return;
|
2008-11-03 05:26:21 -05:00
|
|
|
|
2008-11-03 09:50:22 -05:00
|
|
|
if (hidden)
|
|
|
|
{
|
|
|
|
/* FIXME: There needs to be a way to queue this if there is an effect
|
|
|
|
* in progress for this window */
|
2008-11-03 05:26:21 -05:00
|
|
|
if (clutter_actor_get_parent (CLUTTER_ACTOR (cw)) != info->hidden_group)
|
|
|
|
clutter_actor_reparent (CLUTTER_ACTOR (cw),
|
|
|
|
info->hidden_group);
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
2008-11-03 09:50:22 -05:00
|
|
|
else
|
2008-11-03 05:26:21 -05:00
|
|
|
{
|
|
|
|
if (clutter_actor_get_parent (CLUTTER_ACTOR (cw)) != info->window_group)
|
|
|
|
clutter_actor_reparent (CLUTTER_ACTOR (cw),
|
|
|
|
info->window_group);
|
|
|
|
}
|
2008-10-24 05:07:24 -04:00
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
static void
|
|
|
|
clutter_cmp_sync_window_geometry (MetaCompositor *compositor,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MutterWindow *cw = meta_window_get_compositor_private (window);
|
|
|
|
MetaScreen *screen = meta_window_get_screen (window);
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
DEBUG_TRACE ("clutter_cmp_sync_window_geometry\n");
|
|
|
|
g_return_if_fail (info);
|
|
|
|
|
|
|
|
if (!cw)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sync_actor_position (cw);
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_cmp_sync_screen_size (MetaCompositor *compositor,
|
|
|
|
MetaScreen *screen,
|
|
|
|
guint width,
|
|
|
|
guint height)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
DEBUG_TRACE ("clutter_cmp_sync_screen_size\n");
|
|
|
|
g_return_if_fail (info);
|
|
|
|
|
|
|
|
clutter_actor_set_size (info->stage, width, height);
|
2008-12-18 07:41:56 -05:00
|
|
|
|
2008-11-27 08:40:52 -05:00
|
|
|
meta_verbose ("Changed size for stage on screen %d to %dx%d\n",
|
|
|
|
meta_screen_get_screen_number (screen),
|
|
|
|
width, height);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
static MetaCompositor comp_info = {
|
|
|
|
clutter_cmp_destroy,
|
|
|
|
clutter_cmp_manage_screen,
|
|
|
|
clutter_cmp_unmanage_screen,
|
|
|
|
clutter_cmp_add_window,
|
|
|
|
clutter_cmp_remove_window,
|
|
|
|
clutter_cmp_set_updates,
|
|
|
|
clutter_cmp_process_event,
|
|
|
|
clutter_cmp_get_window_pixmap,
|
2008-06-09 12:50:56 -04:00
|
|
|
clutter_cmp_set_active_window,
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_cmp_map_window,
|
|
|
|
clutter_cmp_unmap_window,
|
2008-09-18 11:09:11 -04:00
|
|
|
clutter_cmp_minimize_window,
|
2008-11-23 14:28:40 -05:00
|
|
|
clutter_cmp_unminimize_window,
|
2008-09-18 11:09:11 -04:00
|
|
|
clutter_cmp_maximize_window,
|
|
|
|
clutter_cmp_unmaximize_window,
|
|
|
|
clutter_cmp_update_workspace_geometry,
|
2008-10-24 05:07:24 -04:00
|
|
|
clutter_cmp_switch_workspace,
|
2008-11-03 09:50:22 -05:00
|
|
|
clutter_cmp_sync_stack,
|
2008-11-27 08:40:52 -05:00
|
|
|
clutter_cmp_set_window_hidden,
|
|
|
|
clutter_cmp_sync_window_geometry,
|
|
|
|
clutter_cmp_sync_screen_size
|
2008-06-04 08:58:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
MetaCompositor *
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_new (MetaDisplay *display)
|
2008-06-04 08:58:36 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
|
|
|
char *atom_names[] = {
|
|
|
|
"_XROOTPMAP_ID",
|
|
|
|
"_XSETROOT_ID",
|
|
|
|
"_NET_WM_WINDOW_OPACITY",
|
|
|
|
};
|
2008-08-20 04:33:39 -04:00
|
|
|
Atom atoms[G_N_ELEMENTS(atom_names)];
|
2008-10-16 07:50:01 -04:00
|
|
|
Mutter *clc;
|
2008-08-20 04:33:39 -04:00
|
|
|
MetaCompositor *compositor;
|
|
|
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
2008-08-20 08:18:43 -04:00
|
|
|
guchar *data;
|
2008-06-04 08:58:36 -04:00
|
|
|
|
2008-06-04 15:51:08 -04:00
|
|
|
if (!composite_at_least_version (display, 0, 3))
|
|
|
|
return NULL;
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
clc = g_new0 (Mutter, 1);
|
2008-06-04 08:58:36 -04:00
|
|
|
clc->compositor = comp_info;
|
|
|
|
|
|
|
|
compositor = (MetaCompositor *) clc;
|
|
|
|
|
|
|
|
clc->display = display;
|
|
|
|
|
2008-11-05 06:48:07 -05:00
|
|
|
if (g_getenv("MUTTER_DISABLE_MIPMAPS"))
|
|
|
|
clc->no_mipmaps = TRUE;
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
meta_verbose ("Creating %d atoms\n", (int) G_N_ELEMENTS (atom_names));
|
|
|
|
XInternAtoms (xdisplay, atom_names, G_N_ELEMENTS (atom_names),
|
|
|
|
False, atoms);
|
|
|
|
|
|
|
|
clc->atom_x_root_pixmap = atoms[0];
|
|
|
|
clc->atom_x_set_root = atoms[1];
|
|
|
|
clc->atom_net_wm_window_opacity = atoms[2];
|
|
|
|
|
2008-08-20 08:18:43 -04:00
|
|
|
/* Shadow setup */
|
|
|
|
|
|
|
|
data = shadow_gaussian_make_tile ();
|
|
|
|
|
|
|
|
clc->shadow_src = clutter_texture_new ();
|
|
|
|
|
|
|
|
clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (clc->shadow_src),
|
|
|
|
data,
|
|
|
|
TRUE,
|
|
|
|
TILE_WIDTH,
|
|
|
|
TILE_HEIGHT,
|
|
|
|
TILE_WIDTH*4,
|
|
|
|
4,
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
free (data);
|
|
|
|
|
2008-06-04 08:58:36 -04:00
|
|
|
return compositor;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
2008-06-06 09:17:38 -04:00
|
|
|
|
2008-10-16 02:50:49 -04:00
|
|
|
Window
|
2008-10-16 18:02:34 -04:00
|
|
|
mutter_get_overlay_window (MetaScreen *screen)
|
2008-10-16 02:50:49 -04:00
|
|
|
{
|
|
|
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
|
|
|
|
|
|
|
return info->output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-06 09:17:38 -04:00
|
|
|
/* ------------------------------- */
|
|
|
|
/* Shadow Generation */
|
|
|
|
|
|
|
|
typedef struct GaussianMap
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
double * data;
|
|
|
|
} GaussianMap;
|
|
|
|
|
|
|
|
static double
|
|
|
|
gaussian (double r, double x, double y)
|
|
|
|
{
|
|
|
|
return ((1 / (sqrt (2 * M_PI * r))) *
|
|
|
|
exp ((- (x * x + y * y)) / (2 * r * r)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GaussianMap *
|
|
|
|
make_gaussian_map (double r)
|
|
|
|
{
|
|
|
|
GaussianMap *c;
|
|
|
|
int size = ((int) ceil ((r * 3)) + 1) & ~1;
|
|
|
|
int center = size / 2;
|
|
|
|
int x, y;
|
|
|
|
double t = 0.0;
|
|
|
|
double g;
|
|
|
|
|
|
|
|
c = malloc (sizeof (GaussianMap) + size * size * sizeof (double));
|
|
|
|
c->size = size;
|
|
|
|
|
|
|
|
c->data = (double *) (c + 1);
|
|
|
|
|
|
|
|
for (y = 0; y < size; y++)
|
|
|
|
for (x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
g = gaussian (r, (double) (x - center), (double) (y - center));
|
|
|
|
t += g;
|
|
|
|
c->data[y * size + x] = g;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y = 0; y < size; y++)
|
|
|
|
for (x = 0; x < size; x++)
|
|
|
|
c->data[y*size + x] /= t;
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char
|
|
|
|
sum_gaussian (GaussianMap * map, double opacity,
|
|
|
|
int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
int fx, fy;
|
|
|
|
double * g_data;
|
|
|
|
double * g_line = map->data;
|
|
|
|
int g_size = map->size;
|
|
|
|
int center = g_size / 2;
|
|
|
|
int fx_start, fx_end;
|
|
|
|
int fy_start, fy_end;
|
|
|
|
double v;
|
|
|
|
unsigned int r;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute set of filter values which are "in range",
|
|
|
|
* that's the set with:
|
|
|
|
* 0 <= x + (fx-center) && x + (fx-center) < width &&
|
|
|
|
* 0 <= y + (fy-center) && y + (fy-center) < height
|
|
|
|
*
|
|
|
|
* 0 <= x + (fx - center) x + fx - center < width
|
|
|
|
* center - x <= fx fx < width + center - x
|
|
|
|
*/
|
|
|
|
|
|
|
|
fx_start = center - x;
|
|
|
|
if (fx_start < 0)
|
|
|
|
fx_start = 0;
|
|
|
|
fx_end = width + center - x;
|
|
|
|
if (fx_end > g_size)
|
|
|
|
fx_end = g_size;
|
|
|
|
|
|
|
|
fy_start = center - y;
|
|
|
|
if (fy_start < 0)
|
|
|
|
fy_start = 0;
|
|
|
|
fy_end = height + center - y;
|
|
|
|
if (fy_end > g_size)
|
|
|
|
fy_end = g_size;
|
|
|
|
|
|
|
|
g_line = g_line + fy_start * g_size + fx_start;
|
|
|
|
|
|
|
|
v = 0;
|
|
|
|
for (fy = fy_start; fy < fy_end; fy++)
|
|
|
|
{
|
|
|
|
g_data = g_line;
|
|
|
|
g_line += g_size;
|
|
|
|
|
|
|
|
for (fx = fx_start; fx < fx_end; fx++)
|
|
|
|
v += *g_data++;
|
|
|
|
}
|
|
|
|
if (v > 1)
|
|
|
|
v = 1;
|
|
|
|
|
|
|
|
v *= (opacity * 255.0);
|
|
|
|
|
|
|
|
r = (unsigned int) v;
|
|
|
|
|
|
|
|
return (unsigned char) r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char *
|
|
|
|
shadow_gaussian_make_tile ()
|
|
|
|
{
|
|
|
|
unsigned char * data;
|
|
|
|
int size;
|
|
|
|
int center;
|
|
|
|
int x, y;
|
|
|
|
unsigned char d;
|
|
|
|
int pwidth, pheight;
|
|
|
|
double opacity = SHADOW_OPACITY;
|
|
|
|
static GaussianMap * gaussian_map = NULL;
|
|
|
|
|
|
|
|
struct _mypixel
|
|
|
|
{
|
|
|
|
unsigned char r;
|
|
|
|
unsigned char g;
|
|
|
|
unsigned char b;
|
|
|
|
unsigned char a;
|
|
|
|
} * _d;
|
|
|
|
|
|
|
|
|
|
|
|
if (!gaussian_map)
|
|
|
|
gaussian_map =
|
|
|
|
make_gaussian_map (SHADOW_RADIUS);
|
|
|
|
|
|
|
|
size = gaussian_map->size;
|
|
|
|
center = size / 2;
|
|
|
|
|
|
|
|
/* Top & bottom */
|
|
|
|
|
|
|
|
pwidth = MAX_TILE_SZ;
|
|
|
|
pheight = MAX_TILE_SZ;
|
|
|
|
|
|
|
|
data = g_malloc0 (4 * TILE_WIDTH * TILE_HEIGHT);
|
|
|
|
|
|
|
|
_d = (struct _mypixel*) data;
|
|
|
|
|
|
|
|
/* N */
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
center, y - center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
{
|
|
|
|
_d[y*3*pwidth + x + pwidth].r = 0;
|
|
|
|
_d[y*3*pwidth + x + pwidth].g = 0;
|
|
|
|
_d[y*3*pwidth + x + pwidth].b = 0;
|
|
|
|
_d[y*3*pwidth + x + pwidth].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* S */
|
|
|
|
pwidth = MAX_TILE_SZ;
|
|
|
|
pheight = MAX_TILE_SZ;
|
|
|
|
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
center, y - center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
{
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x + pwidth].r = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x + pwidth].g = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x + pwidth].b = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x + pwidth].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* w */
|
|
|
|
pwidth = MAX_TILE_SZ;
|
|
|
|
pheight = MAX_TILE_SZ;
|
|
|
|
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
x - center, center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x].r = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x].g = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x].b = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* E */
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
x - center, center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + (pwidth-x-1) + 2*pwidth].r = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + (pwidth-x-1) + 2*pwidth].g = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + (pwidth-x-1) + 2*pwidth].b = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + (pwidth-x-1) + 2*pwidth].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NW */
|
|
|
|
pwidth = MAX_TILE_SZ;
|
|
|
|
pheight = MAX_TILE_SZ;
|
|
|
|
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
x-center, y-center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
|
|
|
|
_d[y*3*pwidth + x].r = 0;
|
|
|
|
_d[y*3*pwidth + x].g = 0;
|
|
|
|
_d[y*3*pwidth + x].b = 0;
|
|
|
|
_d[y*3*pwidth + x].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SW */
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
x-center, y-center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x].r = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x].g = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x].b = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + x].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SE */
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
x-center, y-center,
|
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + (pwidth-x-1) +
|
|
|
|
2*pwidth].r = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + (pwidth-x-1) +
|
|
|
|
2*pwidth].g = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + (pwidth-x-1) +
|
|
|
|
2*pwidth].b = 0;
|
|
|
|
_d[(pheight-y-1)*3*pwidth + 6*pwidth*pheight + (pwidth-x-1) +
|
|
|
|
2*pwidth].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NE */
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
2008-08-18 10:44:26 -04:00
|
|
|
x-center, y-center,
|
2008-06-06 09:17:38 -04:00
|
|
|
TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
|
|
|
|
_d[y*3*pwidth + (pwidth - x - 1) + 2*pwidth].r = 0;
|
|
|
|
_d[y*3*pwidth + (pwidth - x - 1) + 2*pwidth].g = 0;
|
|
|
|
_d[y*3*pwidth + (pwidth - x - 1) + 2*pwidth].b = 0;
|
|
|
|
_d[y*3*pwidth + (pwidth - x - 1) + 2*pwidth].a = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* center */
|
|
|
|
pwidth = MAX_TILE_SZ;
|
|
|
|
pheight = MAX_TILE_SZ;
|
|
|
|
|
|
|
|
d = sum_gaussian (gaussian_map, opacity,
|
|
|
|
center, center, TILE_WIDTH, TILE_HEIGHT);
|
|
|
|
|
|
|
|
for (x = 0; x < pwidth; x++)
|
|
|
|
for (y = 0; y < pheight; y++)
|
|
|
|
{
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x + pwidth].r = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x + pwidth].g = 0;
|
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x + pwidth].b = 0;
|
2008-10-21 11:51:18 -04:00
|
|
|
_d[y*3*pwidth + 3*pwidth*pheight + x + pwidth].a = 0;
|
2008-06-06 09:17:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|