[mutter/wip/surface-content: 6/18] Move _NET_WM_WINDOW_OPACITY handling to the standard window-props interface
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/surface-content: 6/18] Move _NET_WM_WINDOW_OPACITY handling to the standard window-props interface
- Date: Fri, 6 Dec 2013 22:47:34 +0000 (UTC)
commit e51786c25b9b93061dcef99655a8d335766778bc
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Dec 6 13:44:31 2013 -0500
Move _NET_WM_WINDOW_OPACITY handling to the standard window-props interface
src/compositor/compositor-private.h | 1 -
src/compositor/compositor.c | 79 ++++++++++------------------------
src/compositor/meta-window-actor.c | 43 ++++++++-----------
src/core/window-private.h | 6 +++
src/core/window-props.c | 15 +++++++
src/core/window.c | 12 +++++
src/meta/atomnames.h | 1 +
src/meta/compositor.h | 2 +
8 files changed, 77 insertions(+), 82 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 494a77b..2e8d85f 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -17,7 +17,6 @@ struct _MetaCompositor
{
MetaDisplay *display;
- Atom atom_net_wm_window_opacity;
guint repaint_func_id;
ClutterActor *shadow_src;
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index e6eaff8..d2598f4 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -179,31 +179,6 @@ process_damage (MetaCompositor *compositor,
meta_window_actor_process_x11_damage (window_actor, event);
}
-static void
-process_property_notify (MetaCompositor *compositor,
- XPropertyEvent *event,
- MetaWindow *window)
-{
- MetaWindowActor *window_actor;
-
- if (window == NULL)
- return;
-
- window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
- if (window_actor == NULL)
- return;
-
- /* Check for the opacity changing */
- if (event->atom == compositor->atom_net_wm_window_opacity)
- {
- meta_window_actor_update_opacity (window_actor);
- DEBUG_TRACE ("process_property_notify: net_wm_window_opacity\n");
- return;
- }
-
- DEBUG_TRACE ("process_property_notify: unknown\n");
-}
-
static Window
get_output_window (MetaScreen *screen)
{
@@ -998,6 +973,18 @@ meta_compositor_window_shape_changed (MetaCompositor *compositor,
meta_window_actor_update_shape (window_actor);
}
+void
+meta_compositor_window_opacity_changed (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+ MetaWindowActor *window_actor;
+ window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
+ if (!window_actor)
+ return;
+
+ meta_window_actor_update_opacity (window_actor);
+}
+
/* Clutter makes the assumption that there is only one X window
* per stage, which is a valid assumption to make for a generic
* application toolkit. As such, it will ignore any events sent
@@ -1102,29 +1089,20 @@ meta_compositor_process_event (MetaCompositor *compositor,
}
}
- switch (event->type)
+ if (!meta_is_wayland_compositor () &&
+ event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify)
{
- case PropertyNotify:
- process_property_notify (compositor, (XPropertyEvent *) event, window);
- break;
-
- default:
- if (!meta_is_wayland_compositor () &&
- event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify)
+ /* Core code doesn't handle damage events, so we need to extract the MetaWindow
+ * ourselves
+ */
+ if (window == NULL)
{
- /* Core code doesn't handle damage events, so we need to extract the MetaWindow
- * ourselves
- */
- if (window == NULL)
- {
- Window xwin = ((XDamageNotifyEvent *) event)->drawable;
- window = meta_display_lookup_x_window (compositor->display, xwin);
- }
-
- DEBUG_TRACE ("meta_compositor_process_event (process_damage)\n");
- process_damage (compositor, (XDamageNotifyEvent *) event, window);
+ Window xwin = ((XDamageNotifyEvent *) event)->drawable;
+ window = meta_display_lookup_x_window (compositor->display, xwin);
}
- break;
+
+ DEBUG_TRACE ("meta_compositor_process_event (process_damage)\n");
+ process_damage (compositor, (XDamageNotifyEvent *) event, window);
}
/* Clutter needs to know about MapNotify events otherwise it will
@@ -1649,12 +1627,7 @@ on_shadow_factory_changed (MetaShadowFactory *factory,
MetaCompositor *
meta_compositor_new (MetaDisplay *display)
{
- char *atom_names[] = {
- "_NET_WM_WINDOW_OPACITY",
- };
- Atom atoms[G_N_ELEMENTS(atom_names)];
MetaCompositor *compositor;
- Display *xdisplay = meta_display_get_xdisplay (display);
if (!composite_at_least_version (display, 0, 3))
return NULL;
@@ -1666,17 +1639,11 @@ meta_compositor_new (MetaDisplay *display)
if (g_getenv("META_DISABLE_MIPMAPS"))
compositor->no_mipmaps = TRUE;
- meta_verbose ("Creating %d atoms\n", (int) G_N_ELEMENTS (atom_names));
- XInternAtoms (xdisplay, atom_names, G_N_ELEMENTS (atom_names),
- False, atoms);
-
g_signal_connect (meta_shadow_factory_get_default (),
"changed",
G_CALLBACK (on_shadow_factory_changed),
compositor);
- compositor->atom_net_wm_window_opacity = atoms[1];
-
compositor->repaint_func_id = clutter_threads_add_repaint_func (meta_repaint_func,
compositor,
NULL);
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index 6945b6a..b178ab1 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -70,8 +70,6 @@ struct _MetaWindowActorPrivate
MetaShadow *focused_shadow;
MetaShadow *unfocused_shadow;
- guint8 opacity;
-
/* A region that matches the shape of the window, including frame bounds */
cairo_region_t *shape_region;
/* The region we should clip to when painting the shadow */
@@ -302,7 +300,6 @@ meta_window_actor_init (MetaWindowActor *self)
MetaWindowActorPrivate);
priv->surface_allocation_changed_id = 0;
- priv->opacity = 0xff;
priv->shadow_class = NULL;
}
@@ -375,6 +372,15 @@ surface_allocation_changed_notify (ClutterActor *actor,
g_signal_emit (self, signals[SIZE_CHANGED], 0);
}
+static gboolean
+is_transparent (MetaWindowActor *self)
+{
+ MetaWindowActorPrivate *priv = self->priv;
+ MetaWindow *window = priv->window;
+
+ return priv->argb32 || (window->opacity != 0xFF);
+}
+
static void
meta_window_actor_constructed (GObject *object)
{
@@ -682,7 +688,7 @@ clip_shadow_under_window (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
- return (priv->argb32 || priv->opacity != 0xff) && priv->window->frame;
+ return is_transparent (self) && priv->window->frame;
}
static void
@@ -708,6 +714,7 @@ meta_window_actor_paint (ClutterActor *actor)
MetaShadowParams params;
cairo_rectangle_int_t shape_bounds;
cairo_region_t *clip = priv->shadow_clip;
+ MetaWindow *window = priv->window;
meta_window_actor_get_shape_bounds (self, &shape_bounds);
meta_window_actor_get_shadow_params (self, appears_focused, ¶ms);
@@ -731,7 +738,7 @@ meta_window_actor_paint (ClutterActor *actor)
params.y_offset + shape_bounds.y,
shape_bounds.width,
shape_bounds.height,
- (clutter_actor_get_paint_opacity (actor) * params.opacity * priv->opacity) / (255 *
255),
+ (clutter_actor_get_paint_opacity (actor) * params.opacity * window->opacity) / (255
* 255),
clip,
clip_shadow_under_window (self)); /* clip_strictly - not just as an optimization */
@@ -818,10 +825,10 @@ meta_window_actor_has_shadow (MetaWindowActor *self)
return TRUE;
/*
- * Do not add shadows to ARGB windows; eventually we should generate a
- * shadow from the input shape for such windows.
+ * Do not add shadows to transparent windows; eventually we should generate
+ * a shadow from the input shape for such windows.
*/
- if (priv->argb32 || priv->opacity != 0xff)
+ if (is_transparent (self))
return FALSE;
/*
@@ -1389,7 +1396,7 @@ meta_window_actor_should_unredirect (MetaWindowActor *self)
if (meta_window_requested_dont_bypass_compositor (metaWindow))
return FALSE;
- if (priv->opacity != 0xff)
+ if (metaWindow->opacity != 0xFF)
return FALSE;
if (metaWindow->shape_region != NULL)
@@ -2665,23 +2672,9 @@ void
meta_window_actor_update_opacity (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
- MetaDisplay *display = meta_screen_get_display (priv->screen);
- MetaCompositor *compositor = meta_display_get_compositor (display);
- Window xwin = meta_window_get_xwindow (priv->window);
- gulong value;
- guint8 opacity;
-
- if (meta_prop_get_cardinal (display, xwin,
- compositor->atom_net_wm_window_opacity,
- &value))
- {
- opacity = (guint8)((gfloat)value * 255.0 / ((gfloat)0xffffffff));
- }
- else
- opacity = 255;
+ MetaWindow *window = priv->window;
- self->priv->opacity = opacity;
- clutter_actor_set_opacity (CLUTTER_ACTOR (self->priv->surface), opacity);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (self->priv->surface), window->opacity);
}
void
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 307129c..6740a1d 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -367,6 +367,9 @@ struct _MetaWindow
/* the input shape region for picking */
cairo_region_t *input_region;
+ /* _NET_WM_WINDOW_OPACITY */
+ guint opacity;
+
/* if TRUE, the we have the new form of sync request counter which
* also handles application frames */
guint extended_sync_request_counter : 1;
@@ -735,6 +738,9 @@ void meta_window_set_gtk_dbus_properties (MetaWindow *window,
void meta_window_set_transient_for (MetaWindow *window,
MetaWindow *parent);
+void meta_window_set_opacity (MetaWindow *window,
+ guint opacity);
+
void meta_window_handle_enter (MetaWindow *window,
guint32 timestamp,
guint root_x,
diff --git a/src/core/window-props.c b/src/core/window-props.c
index cd4d012..447ac3e 100644
--- a/src/core/window-props.c
+++ b/src/core/window-props.c
@@ -1655,6 +1655,20 @@ reload_bypass_compositor (MetaWindow *window,
window->bypass_compositor = requested_value;
}
+static void
+reload_window_opacity (MetaWindow *window,
+ MetaPropValue *value,
+ gboolean initial)
+
+{
+ int requested_value = 0xFF;
+
+ if (value->type != META_PROP_VALUE_INVALID)
+ requested_value = (int) value->v.cardinal;
+
+ meta_window_set_opacity (window, requested_value);
+}
+
#define RELOAD_STRING(var_name, propname) \
static void \
reload_ ## var_name (MetaWindow *window, \
@@ -1757,6 +1771,7 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
{ display->atom__NET_WM_STRUT, META_PROP_VALUE_INVALID, reload_struts, FALSE, FALSE },
{ display->atom__NET_WM_STRUT_PARTIAL, META_PROP_VALUE_INVALID, reload_struts, FALSE, FALSE },
{ display->atom__NET_WM_BYPASS_COMPOSITOR, META_PROP_VALUE_CARDINAL, reload_bypass_compositor, FALSE,
FALSE },
+ { display->atom__NET_WM_WINDOW_OPACITY, META_PROP_VALUE_CARDINAL, reload_window_opacity, TRUE, TRUE },
{ 0 },
};
diff --git a/src/core/window.c b/src/core/window.c
index 3a3fde0..9a8225a 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1077,6 +1077,8 @@ meta_window_new_shared (MetaDisplay *display,
else
meta_display_register_wayland_window (display, window);
+ window->opacity = 0xFF;
+
/* assign the window to its group, or create a new group if needed
*/
window->group = NULL;
@@ -11959,6 +11961,16 @@ meta_window_set_transient_for (MetaWindow *window,
meta_window_propagate_focus_appearance (window, TRUE);
}
+void
+meta_window_set_opacity (MetaWindow *window,
+ guint opacity)
+{
+ window->opacity = opacity;
+
+ if (window->display->compositor)
+ meta_compositor_window_opacity_changed (window->display->compositor, window);
+}
+
static void
reset_ignored_crossing_serials (MetaDisplay *display)
{
diff --git a/src/meta/atomnames.h b/src/meta/atomnames.h
index e90b0ab..f83ff8c 100644
--- a/src/meta/atomnames.h
+++ b/src/meta/atomnames.h
@@ -180,6 +180,7 @@ item(_NET_WM_BYPASS_COMPOSITOR)
item(_NET_WM_OPAQUE_REGION)
item(_NET_WM_FRAME_DRAWN)
item(_NET_WM_FRAME_TIMINGS)
+item(_NET_WM_WINDOW_OPACITY)
#if 0
/* We apparently never use: */
diff --git a/src/meta/compositor.h b/src/meta/compositor.h
index 13143c9..b0e5455 100644
--- a/src/meta/compositor.h
+++ b/src/meta/compositor.h
@@ -66,6 +66,8 @@ void meta_compositor_unmanage_screen (MetaCompositor *compositor,
void meta_compositor_window_shape_changed (MetaCompositor *compositor,
MetaWindow *window);
+void meta_compositor_window_opacity_changed (MetaCompositor *compositor,
+ MetaWindow *window);
gboolean meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]