mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
wayland: Adds basic hybrid X + Wayland support
This adds support for running mutter as a hybrid X and Wayland compositor. It runs a headless XWayland server for X applications that presents wayland surfaces back to mutter which mutter can then composite. This aims to not break Mutter's existing support for the traditional X compositing model which means a single build of Mutter can be distributed supporting the traditional model and the new Wayland based compositing model. TODO: although building with --disable-wayland has at least been tested, I still haven't actually verified that running as a traditional compositor isn't broken currently. Note: At this point no input is supported Note: multiple authors have contributed to this patch: Authored-by: Robert Bragg <robert@linux.intel.com> Authored-by: Neil Roberts <neil@linux.intel.com> Authored-by: Rico Tzschichholz. Authored-by: Giovanni Campagna <gcampagna@src.gnome.org>
This commit is contained in:
parent
bd3c357212
commit
f9a11b3b18
@ -15,7 +15,7 @@ AC_INIT([mutter], [mutter_version],
|
|||||||
AC_CONFIG_SRCDIR(src/core/display.c)
|
AC_CONFIG_SRCDIR(src/core/display.c)
|
||||||
AC_CONFIG_HEADERS(config.h)
|
AC_CONFIG_HEADERS(config.h)
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz tar-ustar])
|
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz tar-ustar])
|
||||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
|
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
|
||||||
AM_MAINTAINER_MODE([enable])
|
AM_MAINTAINER_MODE([enable])
|
||||||
|
|
||||||
|
@ -39,6 +39,13 @@ mutter_built_sources = \
|
|||||||
mutter-enum-types.h \
|
mutter-enum-types.h \
|
||||||
mutter-enum-types.c
|
mutter-enum-types.c
|
||||||
|
|
||||||
|
if HAVE_WAYLAND
|
||||||
|
mutter_built_sources += \
|
||||||
|
wayland/xserver-protocol.c \
|
||||||
|
wayland/xserver-server-protocol.h \
|
||||||
|
wayland/xserver-client-protocol.h
|
||||||
|
endif
|
||||||
|
|
||||||
libmutter_la_SOURCES = \
|
libmutter_la_SOURCES = \
|
||||||
core/async-getprop.c \
|
core/async-getprop.c \
|
||||||
core/async-getprop.h \
|
core/async-getprop.h \
|
||||||
@ -167,6 +174,14 @@ libmutter_la_SOURCES = \
|
|||||||
ui/preview-widget.c \
|
ui/preview-widget.c \
|
||||||
$(mutter_built_sources)
|
$(mutter_built_sources)
|
||||||
|
|
||||||
|
if HAVE_WAYLAND
|
||||||
|
libmutter_la_SOURCES += \
|
||||||
|
wayland/meta-wayland.c \
|
||||||
|
wayland/meta-wayland-private.h \
|
||||||
|
wayland/meta-xwayland-private.h \
|
||||||
|
wayland/meta-xwayland.c
|
||||||
|
endif
|
||||||
|
|
||||||
libmutter_la_LDFLAGS = -no-undefined
|
libmutter_la_LDFLAGS = -no-undefined
|
||||||
libmutter_la_LIBADD = $(MUTTER_LIBS)
|
libmutter_la_LIBADD = $(MUTTER_LIBS)
|
||||||
|
|
||||||
|
@ -84,6 +84,9 @@
|
|||||||
#include "meta-window-group.h"
|
#include "meta-window-group.h"
|
||||||
#include "window-private.h" /* to check window->hidden */
|
#include "window-private.h" /* to check window->hidden */
|
||||||
#include "display-private.h" /* for meta_display_lookup_x_window() */
|
#include "display-private.h" /* for meta_display_lookup_x_window() */
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#endif
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#include <X11/extensions/Xcomposite.h>
|
#include <X11/extensions/Xcomposite.h>
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ process_damage (MetaCompositor *compositor,
|
|||||||
if (window_actor == NULL)
|
if (window_actor == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
meta_window_actor_process_damage (window_actor, event);
|
meta_window_actor_process_x11_damage (window_actor, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -326,6 +329,13 @@ do_set_stage_input_region (MetaScreen *screen,
|
|||||||
void
|
void
|
||||||
meta_set_stage_input_region (MetaScreen *screen,
|
meta_set_stage_input_region (MetaScreen *screen,
|
||||||
XserverRegion region)
|
XserverRegion region)
|
||||||
|
{
|
||||||
|
/* As a wayland compositor we can simply ignore all this trickery
|
||||||
|
* for setting an input region on the stage for capturing events in
|
||||||
|
* clutter since all input comes to us first and we get to choose
|
||||||
|
* who else sees them.
|
||||||
|
*/
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
{
|
{
|
||||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
MetaDisplay *display = meta_screen_get_display (screen);
|
MetaDisplay *display = meta_screen_get_display (screen);
|
||||||
@ -351,6 +361,7 @@ meta_set_stage_input_region (MetaScreen *screen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_empty_stage_input_region (MetaScreen *screen)
|
meta_empty_stage_input_region (MetaScreen *screen)
|
||||||
@ -562,6 +573,11 @@ redirect_windows (MetaCompositor *compositor,
|
|||||||
guint n_retries;
|
guint n_retries;
|
||||||
guint max_retries;
|
guint max_retries;
|
||||||
|
|
||||||
|
/* If we're running with wayland, connected to a headless xwayland
|
||||||
|
* server then all the windows are implicitly redirected offscreen
|
||||||
|
* already and it would generate an error to try and explicitly
|
||||||
|
* redirect them via XCompositeRedirectSubwindows() */
|
||||||
|
|
||||||
if (meta_get_replace_current_wm ())
|
if (meta_get_replace_current_wm ())
|
||||||
max_retries = 5;
|
max_retries = 5;
|
||||||
else
|
else
|
||||||
@ -604,6 +620,9 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||||
Window xwin;
|
Window xwin;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
MetaWaylandCompositor *wayland_compositor;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check if the screen is already managed */
|
/* Check if the screen is already managed */
|
||||||
if (meta_screen_get_compositor_data (screen))
|
if (meta_screen_get_compositor_data (screen))
|
||||||
@ -616,7 +635,14 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
* We have to initialize info->pending_input_region to an empty region explicitly,
|
* We have to initialize info->pending_input_region to an empty region explicitly,
|
||||||
* because None value is used to mean that the whole screen is an input region.
|
* because None value is used to mean that the whole screen is an input region.
|
||||||
*/
|
*/
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
info->pending_input_region = XFixesCreateRegion (xdisplay, NULL, 0);
|
info->pending_input_region = XFixesCreateRegion (xdisplay, NULL, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Stage input region trickery isn't needed when we're running as a
|
||||||
|
* wayland compositor. */
|
||||||
|
info->pending_input_region = None;
|
||||||
|
}
|
||||||
|
|
||||||
info->screen = screen;
|
info->screen = screen;
|
||||||
|
|
||||||
@ -627,15 +653,19 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
|
|
||||||
meta_screen_set_cm_selection (screen);
|
meta_screen_set_cm_selection (screen);
|
||||||
|
|
||||||
|
/* We will have already created a stage if running as a wayland
|
||||||
|
* compositor... */
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
wayland_compositor = meta_wayland_compositor_get_default ();
|
||||||
|
info->stage = wayland_compositor->stage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* HAVE_WAYLAND */
|
||||||
|
{
|
||||||
info->stage = clutter_stage_new ();
|
info->stage = clutter_stage_new ();
|
||||||
|
|
||||||
clutter_stage_set_paint_callback (CLUTTER_STAGE (info->stage),
|
|
||||||
after_stage_paint,
|
|
||||||
info,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
clutter_stage_set_sync_delay (CLUTTER_STAGE (info->stage), META_SYNC_DELAY);
|
|
||||||
|
|
||||||
meta_screen_get_size (screen, &width, &height);
|
meta_screen_get_size (screen, &width, &height);
|
||||||
clutter_actor_realize (info->stage);
|
clutter_actor_realize (info->stage);
|
||||||
|
|
||||||
@ -671,6 +701,14 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
|
|
||||||
XSelectInput (xdisplay, xwin, event_mask);
|
XSelectInput (xdisplay, xwin, event_mask);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clutter_stage_set_paint_callback (CLUTTER_STAGE (info->stage),
|
||||||
|
after_stage_paint,
|
||||||
|
info,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
clutter_stage_set_sync_delay (CLUTTER_STAGE (info->stage), META_SYNC_DELAY);
|
||||||
|
|
||||||
info->window_group = meta_window_group_new (screen);
|
info->window_group = meta_window_group_new (screen);
|
||||||
info->top_window_group = meta_window_group_new (screen);
|
info->top_window_group = meta_window_group_new (screen);
|
||||||
@ -680,6 +718,15 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
|
|
||||||
info->plugin_mgr = meta_plugin_manager_new (screen);
|
info->plugin_mgr = meta_plugin_manager_new (screen);
|
||||||
|
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
/* NB: When running as a wayland compositor we don't need an X
|
||||||
|
* composite overlay window, and we don't need to play any input
|
||||||
|
* region tricks to redirect events into clutter. */
|
||||||
|
info->output = None;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Delay the creation of the overlay window as long as we can, to avoid
|
* Delay the creation of the overlay window as long as we can, to avoid
|
||||||
* blanking out the screen. This means that during the plugin loading, the
|
* blanking out the screen. This means that during the plugin loading, the
|
||||||
@ -714,10 +761,13 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
|
|
||||||
redirect_windows (compositor, screen);
|
redirect_windows (compositor, screen);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
||||||
MetaScreen *screen)
|
MetaScreen *screen)
|
||||||
|
{
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
{
|
{
|
||||||
MetaDisplay *display = meta_screen_get_display (screen);
|
MetaDisplay *display = meta_screen_get_display (screen);
|
||||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||||
@ -728,6 +778,7 @@ meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
|||||||
* window manager won't be able to redirect subwindows */
|
* window manager won't be able to redirect subwindows */
|
||||||
XCompositeUnredirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
XCompositeUnredirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shapes the cow so that the given window is exposed,
|
* Shapes the cow so that the given window is exposed,
|
||||||
@ -798,6 +849,8 @@ meta_compositor_remove_window (MetaCompositor *compositor,
|
|||||||
if (!window_actor)
|
if (!window_actor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
screen = meta_window_get_screen (window);
|
screen = meta_window_get_screen (window);
|
||||||
info = meta_screen_get_compositor_data (screen);
|
info = meta_screen_get_compositor_data (screen);
|
||||||
|
|
||||||
@ -808,6 +861,7 @@ meta_compositor_remove_window (MetaCompositor *compositor,
|
|||||||
NULL);
|
NULL);
|
||||||
info->unredirected_window = NULL;
|
info->unredirected_window = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
meta_window_actor_destroy (window_actor);
|
meta_window_actor_destroy (window_actor);
|
||||||
}
|
}
|
||||||
@ -866,7 +920,7 @@ is_grabbed_event (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_compositor_window_shape_changed (MetaCompositor *compositor,
|
meta_compositor_window_x11_shape_changed (MetaCompositor *compositor,
|
||||||
MetaWindow *window)
|
MetaWindow *window)
|
||||||
{
|
{
|
||||||
MetaWindowActor *window_actor;
|
MetaWindowActor *window_actor;
|
||||||
@ -993,7 +1047,8 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify)
|
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
|
/* Core code doesn't handle damage events, so we need to extract the MetaWindow
|
||||||
* ourselves
|
* ourselves
|
||||||
@ -1012,7 +1067,7 @@ meta_compositor_process_event (MetaCompositor *compositor,
|
|||||||
|
|
||||||
/* Clutter needs to know about MapNotify events otherwise it will
|
/* Clutter needs to know about MapNotify events otherwise it will
|
||||||
think the stage is invisible */
|
think the stage is invisible */
|
||||||
if (event->type == MapNotify)
|
if (!meta_is_wayland_compositor () && event->type == MapNotify)
|
||||||
clutter_x11_handle_event (event);
|
clutter_x11_handle_event (event);
|
||||||
|
|
||||||
/* The above handling is basically just "observing" the events, so we return
|
/* The above handling is basically just "observing" the events, so we return
|
||||||
@ -1353,6 +1408,16 @@ meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
|||||||
MetaScreen *screen,
|
MetaScreen *screen,
|
||||||
guint width,
|
guint width,
|
||||||
guint height)
|
guint height)
|
||||||
|
{
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
/* It's not clear at the moment how we will be dealing with screen
|
||||||
|
* resizing as a Wayland compositor so for now just abort if we
|
||||||
|
* hit this code. */
|
||||||
|
g_critical ("Unexpected call to meta_compositor_sync_screen_size() "
|
||||||
|
"when running as a wayland compositor");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
MetaDisplay *display = meta_screen_get_display (screen);
|
MetaDisplay *display = meta_screen_get_display (screen);
|
||||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
@ -1371,6 +1436,7 @@ meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
|||||||
meta_screen_get_screen_number (screen),
|
meta_screen_get_screen_number (screen),
|
||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
frame_callback (CoglOnscreen *onscreen,
|
frame_callback (CoglOnscreen *onscreen,
|
||||||
@ -1433,6 +1499,8 @@ pre_paint_windows (MetaCompScreen *info)
|
|||||||
if (info->windows == NULL)
|
if (info->windows == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
top_window = g_list_last (info->windows)->data;
|
top_window = g_list_last (info->windows)->data;
|
||||||
|
|
||||||
if (meta_window_actor_should_unredirect (top_window) &&
|
if (meta_window_actor_should_unredirect (top_window) &&
|
||||||
@ -1457,6 +1525,7 @@ pre_paint_windows (MetaCompScreen *info)
|
|||||||
|
|
||||||
info->unredirected_window = expected_unredirected_window;
|
info->unredirected_window = expected_unredirected_window;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (l = info->windows; l; l = l->next)
|
for (l = info->windows; l; l = l->next)
|
||||||
meta_window_actor_pre_paint (l->data);
|
meta_window_actor_pre_paint (l->data);
|
||||||
|
@ -317,6 +317,16 @@ meta_plugin_manager_xevent_filter (MetaPluginManager *plugin_mgr,
|
|||||||
*/
|
*/
|
||||||
if (klass->xevent_filter)
|
if (klass->xevent_filter)
|
||||||
return klass->xevent_filter (plugin, xev);
|
return klass->xevent_filter (plugin, xev);
|
||||||
else
|
|
||||||
|
/* When mutter is running as a wayland compositor, things like input
|
||||||
|
* events just come directly from clutter so it won't have disabled
|
||||||
|
* clutter's event retrieval and won't need to forward it events (if
|
||||||
|
* it did it would lead to recursion). Also when running as a
|
||||||
|
* wayland compositor we shouldn't be assuming that we're running
|
||||||
|
* with the clutter x11 backend.
|
||||||
|
*/
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
|
return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,14 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <meta/meta-shaped-texture.h>
|
#include <meta/meta-shaped-texture.h>
|
||||||
|
#include <meta/util.h>
|
||||||
#include "meta-texture-tower.h"
|
#include "meta-texture-tower.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#include <cogl/cogl-wayland-server.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include <cogl/cogl.h>
|
#include <cogl/cogl.h>
|
||||||
#include <cogl/cogl-texture-pixmap-x11.h>
|
#include <cogl/cogl-texture-pixmap-x11.h>
|
||||||
@ -55,6 +61,15 @@ static void meta_shaped_texture_get_preferred_height (ClutterActor *self,
|
|||||||
|
|
||||||
static gboolean meta_shaped_texture_get_paint_volume (ClutterActor *self, ClutterPaintVolume *volume);
|
static gboolean meta_shaped_texture_get_paint_volume (ClutterActor *self, ClutterPaintVolume *volume);
|
||||||
|
|
||||||
|
typedef enum _MetaShapedTextureType
|
||||||
|
{
|
||||||
|
META_SHAPED_TEXTURE_TYPE_X11_PIXMAP,
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
META_SHAPED_TEXTURE_TYPE_WAYLAND_SURFACE,
|
||||||
|
#endif
|
||||||
|
} MetaShapedTextureType;
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaShapedTexture, meta_shaped_texture,
|
G_DEFINE_TYPE (MetaShapedTexture, meta_shaped_texture,
|
||||||
CLUTTER_TYPE_ACTOR);
|
CLUTTER_TYPE_ACTOR);
|
||||||
|
|
||||||
@ -65,8 +80,21 @@ G_DEFINE_TYPE (MetaShapedTexture, meta_shaped_texture,
|
|||||||
struct _MetaShapedTexturePrivate
|
struct _MetaShapedTexturePrivate
|
||||||
{
|
{
|
||||||
MetaTextureTower *paint_tower;
|
MetaTextureTower *paint_tower;
|
||||||
|
|
||||||
|
MetaShapedTextureType type;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
CoglTexturePixmapX11 *texture;
|
} x11;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
struct {
|
||||||
|
MetaWaylandSurface *surface;
|
||||||
|
} wayland;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
CoglTexture *texture;
|
||||||
|
|
||||||
CoglTexture *mask_texture;
|
CoglTexture *mask_texture;
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
CoglPipeline *pipeline_unshaped;
|
CoglPipeline *pipeline_unshaped;
|
||||||
@ -104,7 +132,10 @@ meta_shaped_texture_init (MetaShapedTexture *self)
|
|||||||
priv = self->priv = META_SHAPED_TEXTURE_GET_PRIVATE (self);
|
priv = self->priv = META_SHAPED_TEXTURE_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->paint_tower = meta_texture_tower_new ();
|
priv->paint_tower = meta_texture_tower_new ();
|
||||||
|
|
||||||
|
priv->type = META_SHAPED_TEXTURE_TYPE_X11_PIXMAP;
|
||||||
priv->texture = NULL;
|
priv->texture = NULL;
|
||||||
|
|
||||||
priv->mask_texture = NULL;
|
priv->mask_texture = NULL;
|
||||||
priv->create_mipmaps = TRUE;
|
priv->create_mipmaps = TRUE;
|
||||||
}
|
}
|
||||||
@ -129,6 +160,56 @@ meta_shaped_texture_dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object);
|
G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_cogl_texture (MetaShapedTexture *stex,
|
||||||
|
CoglTexture *cogl_tex)
|
||||||
|
{
|
||||||
|
MetaShapedTexturePrivate *priv;
|
||||||
|
guint width, height;
|
||||||
|
|
||||||
|
g_return_if_fail (META_IS_SHAPED_TEXTURE (stex));
|
||||||
|
|
||||||
|
priv = stex->priv;
|
||||||
|
|
||||||
|
if (priv->texture)
|
||||||
|
cogl_object_unref (priv->texture);
|
||||||
|
|
||||||
|
priv->texture = cogl_tex;
|
||||||
|
|
||||||
|
if (priv->pipeline != NULL)
|
||||||
|
cogl_pipeline_set_layer_texture (priv->pipeline, 0, COGL_TEXTURE (cogl_tex));
|
||||||
|
|
||||||
|
if (priv->pipeline_unshaped != NULL)
|
||||||
|
cogl_pipeline_set_layer_texture (priv->pipeline_unshaped, 0, COGL_TEXTURE (cogl_tex));
|
||||||
|
|
||||||
|
if (cogl_tex != NULL)
|
||||||
|
{
|
||||||
|
width = cogl_texture_get_width (COGL_TEXTURE (cogl_tex));
|
||||||
|
height = cogl_texture_get_height (COGL_TEXTURE (cogl_tex));
|
||||||
|
|
||||||
|
if (width != priv->tex_width ||
|
||||||
|
height != priv->tex_height)
|
||||||
|
{
|
||||||
|
priv->tex_width = width;
|
||||||
|
priv->tex_height = height;
|
||||||
|
|
||||||
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (stex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* size changed to 0 going to an invalid handle */
|
||||||
|
priv->tex_width = 0;
|
||||||
|
priv->tex_height = 0;
|
||||||
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (stex));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NB: We don't queue a redraw of the actor here because we don't
|
||||||
|
* know how much of the buffer has changed with respect to the
|
||||||
|
* previous buffer. We only queue a redraw in response to surface
|
||||||
|
* damage. */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_shaped_texture_paint (ClutterActor *actor)
|
meta_shaped_texture_paint (ClutterActor *actor)
|
||||||
{
|
{
|
||||||
@ -312,6 +393,7 @@ meta_shaped_texture_pick (ClutterActor *actor,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
n_rects = cairo_region_num_rectangles (priv->input_shape_region);
|
n_rects = cairo_region_num_rectangles (priv->input_shape_region);
|
||||||
|
rectangles = g_alloca (sizeof (float) * 4 * n_rects);
|
||||||
|
|
||||||
for (i = 0; i < n_rects; i++)
|
for (i = 0; i < n_rects; i++)
|
||||||
{
|
{
|
||||||
@ -380,12 +462,56 @@ meta_shaped_texture_get_paint_volume (ClutterActor *self,
|
|||||||
return clutter_paint_volume_set_from_allocation (volume, self);
|
return clutter_paint_volume_set_from_allocation (volume, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
ClutterActor *
|
ClutterActor *
|
||||||
meta_shaped_texture_new (void)
|
meta_shaped_texture_new_with_wayland_surface (MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
ClutterActor *self = g_object_new (META_TYPE_SHAPED_TEXTURE, NULL);
|
ClutterActor *actor = g_object_new (META_TYPE_SHAPED_TEXTURE, NULL);
|
||||||
|
MetaShapedTexturePrivate *priv = META_SHAPED_TEXTURE (actor)->priv;
|
||||||
|
|
||||||
return self;
|
/* XXX: it could probably be better to have a "type" construct-only
|
||||||
|
* property or create wayland/x11 subclasses */
|
||||||
|
priv->type = META_SHAPED_TEXTURE_TYPE_WAYLAND_SURFACE;
|
||||||
|
|
||||||
|
meta_shaped_texture_set_wayland_surface (META_SHAPED_TEXTURE (actor),
|
||||||
|
surface);
|
||||||
|
|
||||||
|
return actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_shaped_texture_set_wayland_surface (MetaShapedTexture *stex,
|
||||||
|
MetaWaylandSurface *surface)
|
||||||
|
{
|
||||||
|
MetaShapedTexturePrivate *priv = stex->priv;
|
||||||
|
|
||||||
|
priv->wayland.surface = surface;
|
||||||
|
|
||||||
|
if (surface && surface->buffer_ref.buffer)
|
||||||
|
meta_shaped_texture_attach_wayland_buffer (stex,
|
||||||
|
surface->buffer_ref.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaWaylandSurface *
|
||||||
|
meta_shaped_texture_get_wayland_surface (MetaShapedTexture *stex)
|
||||||
|
{
|
||||||
|
MetaShapedTexturePrivate *priv = stex->priv;
|
||||||
|
return priv->wayland.surface;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_WAYLAND */
|
||||||
|
|
||||||
|
ClutterActor *
|
||||||
|
meta_shaped_texture_new_with_xwindow (Window xwindow)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
MetaWaylandSurface *surface = meta_wayland_lookup_surface_for_xid (xwindow);
|
||||||
|
return meta_shaped_texture_new_with_wayland_surface (surface);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return g_object_new (META_TYPE_SHAPED_TEXTURE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -404,8 +530,7 @@ meta_shaped_texture_set_create_mipmaps (MetaShapedTexture *stex,
|
|||||||
{
|
{
|
||||||
CoglTexture *base_texture;
|
CoglTexture *base_texture;
|
||||||
priv->create_mipmaps = create_mipmaps;
|
priv->create_mipmaps = create_mipmaps;
|
||||||
base_texture = create_mipmaps ?
|
base_texture = create_mipmaps ? priv->texture : NULL;
|
||||||
COGL_TEXTURE (priv->texture) : NULL;
|
|
||||||
meta_texture_tower_set_base_texture (priv->paint_tower, base_texture);
|
meta_texture_tower_set_base_texture (priv->paint_tower, base_texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,6 +556,116 @@ meta_shaped_texture_set_mask_texture (MetaShapedTexture *stex,
|
|||||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (stex));
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
static void
|
||||||
|
wayland_surface_update_area (MetaShapedTexture *stex,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
MetaShapedTexturePrivate *priv;
|
||||||
|
MetaWaylandBuffer *buffer;
|
||||||
|
|
||||||
|
priv = stex->priv;
|
||||||
|
|
||||||
|
g_return_if_fail (priv->type == META_SHAPED_TEXTURE_TYPE_WAYLAND_SURFACE);
|
||||||
|
g_return_if_fail (priv->texture != NULL);
|
||||||
|
|
||||||
|
buffer = priv->wayland.surface->buffer_ref.buffer;
|
||||||
|
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
|
struct wl_resource *resource = buffer->resource;
|
||||||
|
struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get (resource);
|
||||||
|
|
||||||
|
if (shm_buffer)
|
||||||
|
{
|
||||||
|
CoglPixelFormat format;
|
||||||
|
|
||||||
|
switch (wl_shm_buffer_get_format (shm_buffer))
|
||||||
|
{
|
||||||
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
|
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
|
||||||
|
break;
|
||||||
|
case WL_SHM_FORMAT_XRGB8888:
|
||||||
|
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||||
|
break;
|
||||||
|
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
|
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
|
||||||
|
break;
|
||||||
|
case WL_SHM_FORMAT_XRGB8888:
|
||||||
|
format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
g_warn_if_reached ();
|
||||||
|
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||||
|
}
|
||||||
|
|
||||||
|
cogl_texture_set_region (priv->texture,
|
||||||
|
x, y,
|
||||||
|
x, y,
|
||||||
|
width, height,
|
||||||
|
width, height,
|
||||||
|
format,
|
||||||
|
wl_shm_buffer_get_stride (shm_buffer),
|
||||||
|
wl_shm_buffer_get_data (shm_buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* HAVE_WAYLAND */
|
||||||
|
|
||||||
|
static void
|
||||||
|
queue_damage_redraw_with_clip (MetaShapedTexture *stex,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
ClutterActor *self = CLUTTER_ACTOR (stex);
|
||||||
|
MetaShapedTexturePrivate *priv;
|
||||||
|
ClutterActorBox allocation;
|
||||||
|
float scale_x;
|
||||||
|
float scale_y;
|
||||||
|
cairo_rectangle_int_t clip;
|
||||||
|
|
||||||
|
/* NB: clutter_actor_queue_redraw_with_clip expects a box in the actor's
|
||||||
|
* coordinate space so we need to convert from surface coordinates to
|
||||||
|
* actor coordinates...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Calling clutter_actor_get_allocation_box() is enormously expensive
|
||||||
|
* if the actor has an out-of-date allocation, since it triggers
|
||||||
|
* a full redraw. clutter_actor_queue_redraw_with_clip() would redraw
|
||||||
|
* the whole stage anyways in that case, so just go ahead and do
|
||||||
|
* it here.
|
||||||
|
*/
|
||||||
|
if (!clutter_actor_has_allocation (self))
|
||||||
|
{
|
||||||
|
clutter_actor_queue_redraw (self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv = stex->priv;
|
||||||
|
|
||||||
|
if (priv->tex_width == 0 || priv->tex_height == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
clutter_actor_get_allocation_box (self, &allocation);
|
||||||
|
|
||||||
|
scale_x = (allocation.x2 - allocation.x1) / priv->tex_width;
|
||||||
|
scale_y = (allocation.y2 - allocation.y1) / priv->tex_height;
|
||||||
|
|
||||||
|
clip.x = x * scale_x;
|
||||||
|
clip.y = y * scale_y;
|
||||||
|
clip.width = width * scale_x;
|
||||||
|
clip.height = height * scale_y;
|
||||||
|
clutter_actor_queue_redraw_with_clip (self, &clip);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_shaped_texture_update_area (MetaShapedTexture *stex,
|
meta_shaped_texture_update_area (MetaShapedTexture *stex,
|
||||||
int x,
|
int x,
|
||||||
@ -439,66 +674,28 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
|
|||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
MetaShapedTexturePrivate *priv;
|
MetaShapedTexturePrivate *priv;
|
||||||
const cairo_rectangle_int_t clip = { x, y, width, height };
|
|
||||||
|
|
||||||
priv = stex->priv;
|
priv = stex->priv;
|
||||||
|
|
||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cogl_texture_pixmap_x11_update_area (priv->texture,
|
switch (priv->type)
|
||||||
|
{
|
||||||
|
case META_SHAPED_TEXTURE_TYPE_X11_PIXMAP:
|
||||||
|
cogl_texture_pixmap_x11_update_area (COGL_TEXTURE_PIXMAP_X11 (priv->texture),
|
||||||
x, y, width, height);
|
x, y, width, height);
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
case META_SHAPED_TEXTURE_TYPE_WAYLAND_SURFACE:
|
||||||
|
wayland_surface_update_area (stex, x, y, width, height);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
meta_texture_tower_update_area (priv->paint_tower, x, y, width, height);
|
meta_texture_tower_update_area (priv->paint_tower, x, y, width, height);
|
||||||
|
|
||||||
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stex), &clip);
|
queue_damage_redraw_with_clip (stex, x, y, width, height);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_cogl_texture (MetaShapedTexture *stex,
|
|
||||||
CoglTexturePixmapX11 *cogl_tex)
|
|
||||||
{
|
|
||||||
MetaShapedTexturePrivate *priv;
|
|
||||||
guint width, height;
|
|
||||||
|
|
||||||
g_return_if_fail (META_IS_SHAPED_TEXTURE (stex));
|
|
||||||
|
|
||||||
priv = stex->priv;
|
|
||||||
|
|
||||||
if (priv->texture != NULL)
|
|
||||||
cogl_object_unref (priv->texture);
|
|
||||||
|
|
||||||
priv->texture = cogl_tex;
|
|
||||||
|
|
||||||
if (priv->pipeline != NULL)
|
|
||||||
cogl_pipeline_set_layer_texture (priv->pipeline, 0, COGL_TEXTURE (cogl_tex));
|
|
||||||
|
|
||||||
if (priv->pipeline_unshaped != NULL)
|
|
||||||
cogl_pipeline_set_layer_texture (priv->pipeline_unshaped, 0, COGL_TEXTURE (cogl_tex));
|
|
||||||
|
|
||||||
if (cogl_tex != NULL)
|
|
||||||
{
|
|
||||||
width = cogl_texture_get_width (COGL_TEXTURE (cogl_tex));
|
|
||||||
height = cogl_texture_get_height (COGL_TEXTURE (cogl_tex));
|
|
||||||
|
|
||||||
if (width != priv->tex_width ||
|
|
||||||
height != priv->tex_height)
|
|
||||||
{
|
|
||||||
priv->tex_width = width;
|
|
||||||
priv->tex_height = height;
|
|
||||||
|
|
||||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (stex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* size changed to 0 going to an inavlid texture */
|
|
||||||
priv->tex_width = 0;
|
|
||||||
priv->tex_height = 0;
|
|
||||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (stex));
|
|
||||||
}
|
|
||||||
|
|
||||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (stex));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -516,16 +713,18 @@ meta_shaped_texture_set_pixmap (MetaShapedTexture *stex,
|
|||||||
|
|
||||||
priv = stex->priv;
|
priv = stex->priv;
|
||||||
|
|
||||||
if (priv->pixmap == pixmap)
|
if (priv->x11.pixmap == pixmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
priv->pixmap = pixmap;
|
priv->x11.pixmap = pixmap;
|
||||||
|
|
||||||
if (pixmap != None)
|
if (pixmap != None)
|
||||||
{
|
{
|
||||||
CoglContext *ctx =
|
CoglContext *ctx =
|
||||||
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||||
set_cogl_texture (stex, cogl_texture_pixmap_x11_new (ctx, pixmap, FALSE, NULL));
|
CoglTexture *texture =
|
||||||
|
COGL_TEXTURE (cogl_texture_pixmap_x11_new (ctx, pixmap, FALSE, NULL));
|
||||||
|
set_cogl_texture (stex, texture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
set_cogl_texture (stex, NULL);
|
set_cogl_texture (stex, NULL);
|
||||||
@ -535,6 +734,54 @@ meta_shaped_texture_set_pixmap (MetaShapedTexture *stex,
|
|||||||
COGL_TEXTURE (priv->texture));
|
COGL_TEXTURE (priv->texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
void
|
||||||
|
meta_shaped_texture_attach_wayland_buffer (MetaShapedTexture *stex,
|
||||||
|
MetaWaylandBuffer *buffer)
|
||||||
|
{
|
||||||
|
MetaShapedTexturePrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (META_IS_SHAPED_TEXTURE (stex));
|
||||||
|
|
||||||
|
priv = stex->priv;
|
||||||
|
|
||||||
|
/* TODO: we should change this api to be something like
|
||||||
|
* meta_shaped_texture_notify_buffer_attach() since we now maintain
|
||||||
|
* a reference to the MetaWaylandSurface where we can access the
|
||||||
|
* buffer without it being explicitly passed as an argument.
|
||||||
|
*/
|
||||||
|
g_return_if_fail (priv->wayland.surface->buffer_ref.buffer == buffer);
|
||||||
|
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
|
CoglContext *ctx =
|
||||||
|
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||||
|
CoglError *catch_error = NULL;
|
||||||
|
CoglTexture *texture =
|
||||||
|
COGL_TEXTURE (cogl_wayland_texture_2d_new_from_buffer (ctx,
|
||||||
|
buffer->resource,
|
||||||
|
&catch_error));
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
cogl_error_free (catch_error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer->width = cogl_texture_get_width (texture);
|
||||||
|
buffer->height = cogl_texture_get_height (texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_cogl_texture (stex, texture);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
set_cogl_texture (stex, NULL);
|
||||||
|
|
||||||
|
if (priv->create_mipmaps)
|
||||||
|
meta_texture_tower_set_base_texture (priv->paint_tower,
|
||||||
|
COGL_TEXTURE (priv->texture));
|
||||||
|
}
|
||||||
|
#endif /* HAVE_WAYLAND */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_shaped_texture_get_texture:
|
* meta_shaped_texture_get_texture:
|
||||||
* @stex: The #MetaShapedTexture
|
* @stex: The #MetaShapedTexture
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include <meta-wayland-private.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <X11/extensions/Xdamage.h>
|
#include <X11/extensions/Xdamage.h>
|
||||||
#include <meta/compositor-mutter.h>
|
#include <meta/compositor-mutter.h>
|
||||||
|
|
||||||
@ -24,9 +29,21 @@ void meta_window_actor_unmaximize (MetaWindowActor *self,
|
|||||||
MetaRectangle *old_rect,
|
MetaRectangle *old_rect,
|
||||||
MetaRectangle *new_rect);
|
MetaRectangle *new_rect);
|
||||||
|
|
||||||
void meta_window_actor_process_damage (MetaWindowActor *self,
|
void meta_window_actor_process_x11_damage (MetaWindowActor *self,
|
||||||
XDamageNotifyEvent *event);
|
XDamageNotifyEvent *event);
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
void meta_window_actor_process_wayland_damage (MetaWindowActor *self,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
void meta_window_actor_set_wayland_surface (MetaWindowActor *self,
|
||||||
|
MetaWaylandSurface *surface);
|
||||||
|
void meta_window_actor_attach_wayland_buffer (MetaWindowActor *self,
|
||||||
|
MetaWaylandBuffer *buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
void meta_window_actor_pre_paint (MetaWindowActor *self);
|
void meta_window_actor_pre_paint (MetaWindowActor *self);
|
||||||
void meta_window_actor_post_paint (MetaWindowActor *self);
|
void meta_window_actor_post_paint (MetaWindowActor *self);
|
||||||
void meta_window_actor_frame_complete (MetaWindowActor *self,
|
void meta_window_actor_frame_complete (MetaWindowActor *self,
|
||||||
|
@ -32,6 +32,9 @@
|
|||||||
#include "meta-window-actor-private.h"
|
#include "meta-window-actor-private.h"
|
||||||
#include "meta-texture-rectangle.h"
|
#include "meta-texture-rectangle.h"
|
||||||
#include "region-utils.h"
|
#include "region-utils.h"
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
POSITION_CHANGED,
|
POSITION_CHANGED,
|
||||||
@ -64,10 +67,6 @@ struct _MetaWindowActorPrivate
|
|||||||
MetaShadow *focused_shadow;
|
MetaShadow *focused_shadow;
|
||||||
MetaShadow *unfocused_shadow;
|
MetaShadow *unfocused_shadow;
|
||||||
|
|
||||||
Pixmap back_pixmap;
|
|
||||||
|
|
||||||
Damage damage;
|
|
||||||
|
|
||||||
guint8 opacity;
|
guint8 opacity;
|
||||||
|
|
||||||
/* A region that matches the shape of the window, including frame bounds */
|
/* A region that matches the shape of the window, including frame bounds */
|
||||||
@ -104,31 +103,41 @@ struct _MetaWindowActorPrivate
|
|||||||
/* List of FrameData for recent frames */
|
/* List of FrameData for recent frames */
|
||||||
GList *frames;
|
GList *frames;
|
||||||
|
|
||||||
|
Pixmap back_pixmap; /* Not used in wayland compositor mode */
|
||||||
|
Damage damage; /* Not used in wayland compositor mode */
|
||||||
|
|
||||||
guint visible : 1;
|
guint visible : 1;
|
||||||
guint mapped : 1;
|
guint mapped : 1;
|
||||||
guint argb32 : 1;
|
guint argb32 : 1;
|
||||||
guint disposed : 1;
|
guint disposed : 1;
|
||||||
guint redecorating : 1;
|
guint redecorating : 1;
|
||||||
|
|
||||||
guint needs_damage_all : 1;
|
|
||||||
guint received_damage : 1;
|
|
||||||
guint repaint_scheduled : 1;
|
|
||||||
|
|
||||||
/* If set, the client needs to be sent a _NET_WM_FRAME_DRAWN
|
/* If set, the client needs to be sent a _NET_WM_FRAME_DRAWN
|
||||||
* client message using the most recent frame in ->frames */
|
* client message using the most recent frame in ->frames */
|
||||||
guint needs_frame_drawn : 1;
|
guint needs_frame_drawn : 1;
|
||||||
|
guint repaint_scheduled : 1;
|
||||||
|
|
||||||
guint needs_pixmap : 1;
|
|
||||||
guint needs_reshape : 1;
|
guint needs_reshape : 1;
|
||||||
guint recompute_focused_shadow : 1;
|
guint recompute_focused_shadow : 1;
|
||||||
guint recompute_unfocused_shadow : 1;
|
guint recompute_unfocused_shadow : 1;
|
||||||
guint size_changed : 1;
|
|
||||||
guint updates_frozen : 1;
|
|
||||||
|
|
||||||
guint needs_destroy : 1;
|
guint needs_destroy : 1;
|
||||||
|
|
||||||
guint no_shadow : 1;
|
guint no_shadow : 1;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* None of these are used in wayland compositor mode...
|
||||||
|
*/
|
||||||
|
|
||||||
|
guint needs_damage_all : 1;
|
||||||
|
guint received_x11_damage : 1;
|
||||||
|
|
||||||
|
guint needs_pixmap : 1;
|
||||||
|
|
||||||
|
guint x11_size_changed : 1;
|
||||||
|
guint updates_frozen : 1;
|
||||||
|
|
||||||
guint unredirected : 1;
|
guint unredirected : 1;
|
||||||
|
|
||||||
/* This is used to detect fullscreen windows that need to be unredirected */
|
/* This is used to detect fullscreen windows that need to be unredirected */
|
||||||
@ -172,7 +181,7 @@ static gboolean meta_window_actor_get_paint_volume (ClutterActor *actor,
|
|||||||
ClutterPaintVolume *volume);
|
ClutterPaintVolume *volume);
|
||||||
|
|
||||||
|
|
||||||
static void meta_window_actor_detach (MetaWindowActor *self);
|
static void meta_window_actor_detach_x11_pixmap (MetaWindowActor *self);
|
||||||
static gboolean meta_window_actor_has_shadow (MetaWindowActor *self);
|
static gboolean meta_window_actor_has_shadow (MetaWindowActor *self);
|
||||||
|
|
||||||
static void meta_window_actor_handle_updates (MetaWindowActor *self);
|
static void meta_window_actor_handle_updates (MetaWindowActor *self);
|
||||||
@ -306,7 +315,9 @@ window_decorated_notify (MetaWindow *mw,
|
|||||||
else
|
else
|
||||||
new_xwindow = meta_window_get_xwindow (mw);
|
new_xwindow = meta_window_get_xwindow (mw);
|
||||||
|
|
||||||
meta_window_actor_detach (self);
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
meta_window_actor_detach_x11_pixmap (self);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First of all, clean up any resources we are currently using and will
|
* First of all, clean up any resources we are currently using and will
|
||||||
@ -319,6 +330,7 @@ window_decorated_notify (MetaWindow *mw,
|
|||||||
meta_error_trap_pop (display);
|
meta_error_trap_pop (display);
|
||||||
priv->damage = None;
|
priv->damage = None;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
priv->xwindow = new_xwindow;
|
priv->xwindow = new_xwindow;
|
||||||
|
|
||||||
@ -348,6 +360,7 @@ meta_window_actor_constructed (GObject *object)
|
|||||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||||
XRenderPictFormat *format;
|
XRenderPictFormat *format;
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
priv->damage = XDamageCreate (xdisplay, xwindow,
|
priv->damage = XDamageCreate (xdisplay, xwindow,
|
||||||
XDamageReportBoundingBox);
|
XDamageReportBoundingBox);
|
||||||
|
|
||||||
@ -358,7 +371,12 @@ meta_window_actor_constructed (GObject *object)
|
|||||||
|
|
||||||
if (!priv->actor)
|
if (!priv->actor)
|
||||||
{
|
{
|
||||||
priv->actor = meta_shaped_texture_new ();
|
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
|
priv->actor = meta_shaped_texture_new_with_xwindow (xwindow);
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
else
|
||||||
|
priv->actor = meta_shaped_texture_new_with_wayland_surface (window->surface);
|
||||||
|
#endif
|
||||||
|
|
||||||
clutter_actor_add_child (CLUTTER_ACTOR (self), priv->actor);
|
clutter_actor_add_child (CLUTTER_ACTOR (self), priv->actor);
|
||||||
|
|
||||||
@ -387,9 +405,10 @@ meta_window_actor_constructed (GObject *object)
|
|||||||
|
|
||||||
meta_window_actor_update_opacity (self);
|
meta_window_actor_update_opacity (self);
|
||||||
|
|
||||||
/* Start off with an empty region to maintain the invariant that
|
/* Start off with empty regions to maintain the invariant that
|
||||||
the shape region is always set */
|
these regions are always set */
|
||||||
priv->shape_region = cairo_region_create();
|
priv->shape_region = cairo_region_create();
|
||||||
|
priv->input_shape_region = cairo_region_create();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -408,11 +427,15 @@ meta_window_actor_dispose (GObject *object)
|
|||||||
priv->disposed = TRUE;
|
priv->disposed = TRUE;
|
||||||
|
|
||||||
screen = priv->screen;
|
screen = priv->screen;
|
||||||
display = meta_screen_get_display (screen);
|
|
||||||
xdisplay = meta_display_get_xdisplay (display);
|
|
||||||
info = meta_screen_get_compositor_data (screen);
|
info = meta_screen_get_compositor_data (screen);
|
||||||
|
|
||||||
meta_window_actor_detach (self);
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
display = meta_screen_get_display (screen);
|
||||||
|
xdisplay = meta_display_get_xdisplay (display);
|
||||||
|
|
||||||
|
meta_window_actor_detach_x11_pixmap (self);
|
||||||
|
}
|
||||||
|
|
||||||
g_clear_pointer (&priv->shape_region, cairo_region_destroy);
|
g_clear_pointer (&priv->shape_region, cairo_region_destroy);
|
||||||
g_clear_pointer (&priv->input_shape_region, cairo_region_destroy);
|
g_clear_pointer (&priv->input_shape_region, cairo_region_destroy);
|
||||||
@ -424,7 +447,7 @@ meta_window_actor_dispose (GObject *object)
|
|||||||
g_clear_pointer (&priv->unfocused_shadow, meta_shadow_unref);
|
g_clear_pointer (&priv->unfocused_shadow, meta_shadow_unref);
|
||||||
g_clear_pointer (&priv->shadow_shape, meta_window_shape_unref);
|
g_clear_pointer (&priv->shadow_shape, meta_window_shape_unref);
|
||||||
|
|
||||||
if (priv->damage != None)
|
if (!meta_is_wayland_compositor () && priv->damage != None)
|
||||||
{
|
{
|
||||||
meta_error_trap_push (display);
|
meta_error_trap_push (display);
|
||||||
XDamageDestroy (xdisplay, priv->damage);
|
XDamageDestroy (xdisplay, priv->damage);
|
||||||
@ -896,6 +919,7 @@ meta_window_actor_showing_on_its_workspace (MetaWindowActor *self)
|
|||||||
static void
|
static void
|
||||||
meta_window_actor_freeze (MetaWindowActor *self)
|
meta_window_actor_freeze (MetaWindowActor *self)
|
||||||
{
|
{
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
self->priv->freeze_count++;
|
self->priv->freeze_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,6 +948,8 @@ meta_window_actor_damage_all (MetaWindowActor *self)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_actor_thaw (MetaWindowActor *self)
|
meta_window_actor_thaw (MetaWindowActor *self)
|
||||||
|
{
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
{
|
{
|
||||||
self->priv->freeze_count--;
|
self->priv->freeze_count--;
|
||||||
|
|
||||||
@ -950,6 +976,7 @@ meta_window_actor_thaw (MetaWindowActor *self)
|
|||||||
if (self->priv->needs_damage_all)
|
if (self->priv->needs_damage_all)
|
||||||
meta_window_actor_damage_all (self);
|
meta_window_actor_damage_all (self);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
|
meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
|
||||||
@ -979,7 +1006,7 @@ meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
|
|||||||
* send a _NET_WM_FRAME_DRAWN. We do a 1-pixel redraw to get
|
* send a _NET_WM_FRAME_DRAWN. We do a 1-pixel redraw to get
|
||||||
* consistent timing with non-empty frames.
|
* consistent timing with non-empty frames.
|
||||||
*/
|
*/
|
||||||
if (priv->mapped && !priv->needs_pixmap)
|
if (priv->mapped && (!meta_is_wayland_compositor () || !priv->needs_pixmap))
|
||||||
{
|
{
|
||||||
const cairo_rectangle_int_t clip = { 0, 0, 1, 1 };
|
const cairo_rectangle_int_t clip = { 0, 0, 1, 1 };
|
||||||
clutter_actor_queue_redraw_with_clip (priv->actor, &clip);
|
clutter_actor_queue_redraw_with_clip (priv->actor, &clip);
|
||||||
@ -1005,7 +1032,7 @@ is_frozen (MetaWindowActor *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_actor_queue_create_pixmap (MetaWindowActor *self)
|
meta_window_actor_queue_create_x11_pixmap (MetaWindowActor *self)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
@ -1109,12 +1136,15 @@ meta_window_actor_after_effects (MetaWindowActor *self)
|
|||||||
meta_window_actor_sync_visibility (self);
|
meta_window_actor_sync_visibility (self);
|
||||||
meta_window_actor_sync_actor_geometry (self, FALSE);
|
meta_window_actor_sync_actor_geometry (self, FALSE);
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
if (!meta_window_is_mapped (priv->window))
|
if (!meta_window_is_mapped (priv->window))
|
||||||
meta_window_actor_detach (self);
|
meta_window_actor_detach_x11_pixmap (self);
|
||||||
|
|
||||||
if (priv->needs_pixmap)
|
if (priv->needs_pixmap)
|
||||||
clutter_actor_queue_redraw (priv->actor);
|
clutter_actor_queue_redraw (priv->actor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_actor_effect_completed (MetaWindowActor *self,
|
meta_window_actor_effect_completed (MetaWindowActor *self,
|
||||||
@ -1194,7 +1224,7 @@ meta_window_actor_effect_completed (MetaWindowActor *self,
|
|||||||
* pixmap for a new size.
|
* pixmap for a new size.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
meta_window_actor_detach (MetaWindowActor *self)
|
meta_window_actor_detach_x11_pixmap (MetaWindowActor *self)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
MetaScreen *screen = priv->screen;
|
MetaScreen *screen = priv->screen;
|
||||||
@ -1215,7 +1245,7 @@ meta_window_actor_detach (MetaWindowActor *self)
|
|||||||
XFreePixmap (xdisplay, priv->back_pixmap);
|
XFreePixmap (xdisplay, priv->back_pixmap);
|
||||||
priv->back_pixmap = None;
|
priv->back_pixmap = None;
|
||||||
|
|
||||||
meta_window_actor_queue_create_pixmap (self);
|
meta_window_actor_queue_create_x11_pixmap (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -1245,7 +1275,7 @@ meta_window_actor_should_unredirect (MetaWindowActor *self)
|
|||||||
if (meta_window_is_override_redirect (metaWindow))
|
if (meta_window_is_override_redirect (metaWindow))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (priv->does_full_damage)
|
if (!meta_is_wayland_compositor () && priv->does_full_damage)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1265,7 +1295,7 @@ meta_window_actor_set_redirected (MetaWindowActor *self, gboolean state)
|
|||||||
meta_error_trap_push (display);
|
meta_error_trap_push (display);
|
||||||
XCompositeRedirectWindow (xdisplay, xwin, CompositeRedirectManual);
|
XCompositeRedirectWindow (xdisplay, xwin, CompositeRedirectManual);
|
||||||
meta_error_trap_pop (display);
|
meta_error_trap_pop (display);
|
||||||
meta_window_actor_detach (self);
|
meta_window_actor_detach_x11_pixmap (self);
|
||||||
self->priv->unredirected = FALSE;
|
self->priv->unredirected = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1338,16 +1368,22 @@ meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
|
|||||||
|
|
||||||
meta_window_get_input_rect (priv->window, &window_rect);
|
meta_window_get_input_rect (priv->window, &window_rect);
|
||||||
|
|
||||||
|
/* When running as a display server then we instead catch size changes when
|
||||||
|
* new buffers are attached */
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
if (priv->last_width != window_rect.width ||
|
if (priv->last_width != window_rect.width ||
|
||||||
priv->last_height != window_rect.height)
|
priv->last_height != window_rect.height)
|
||||||
{
|
{
|
||||||
priv->size_changed = TRUE;
|
priv->x11_size_changed = TRUE;
|
||||||
meta_window_actor_queue_create_pixmap (self);
|
meta_window_actor_queue_create_x11_pixmap (self);
|
||||||
|
|
||||||
meta_window_actor_update_shape (self);
|
meta_window_actor_update_shape (self);
|
||||||
|
|
||||||
priv->last_width = window_rect.width;
|
priv->last_width = window_rect.width;
|
||||||
priv->last_height = window_rect.height;
|
priv->last_height = window_rect.height;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (meta_window_actor_effect_in_progress (self))
|
if (meta_window_actor_effect_in_progress (self))
|
||||||
return;
|
return;
|
||||||
@ -1510,9 +1546,11 @@ meta_window_actor_new (MetaWindow *window)
|
|||||||
MetaWindowActor *self;
|
MetaWindowActor *self;
|
||||||
MetaWindowActorPrivate *priv;
|
MetaWindowActorPrivate *priv;
|
||||||
MetaFrame *frame;
|
MetaFrame *frame;
|
||||||
Window top_window;
|
Window top_window = None;
|
||||||
ClutterActor *window_group;
|
ClutterActor *window_group;
|
||||||
|
|
||||||
|
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
|
{
|
||||||
frame = meta_window_get_frame (window);
|
frame = meta_window_get_frame (window);
|
||||||
if (frame)
|
if (frame)
|
||||||
top_window = meta_frame_get_xwindow (frame);
|
top_window = meta_frame_get_xwindow (frame);
|
||||||
@ -1520,6 +1558,15 @@ meta_window_actor_new (MetaWindow *window)
|
|||||||
top_window = meta_window_get_xwindow (window);
|
top_window = meta_window_get_xwindow (window);
|
||||||
|
|
||||||
meta_verbose ("add window: Meta %p, xwin 0x%x\n", window, (guint)top_window);
|
meta_verbose ("add window: Meta %p, xwin 0x%x\n", window, (guint)top_window);
|
||||||
|
}
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta_verbose ("add window: Meta %p, wayland surface %p\n",
|
||||||
|
window, window->surface);
|
||||||
|
top_window = None;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
self = g_object_new (META_TYPE_WINDOW_ACTOR,
|
self = g_object_new (META_TYPE_WINDOW_ACTOR,
|
||||||
"meta-window", window,
|
"meta-window", window,
|
||||||
@ -1529,12 +1576,14 @@ meta_window_actor_new (MetaWindow *window)
|
|||||||
|
|
||||||
priv = self->priv;
|
priv = self->priv;
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
priv->last_width = -1;
|
priv->last_width = -1;
|
||||||
priv->last_height = -1;
|
priv->last_height = -1;
|
||||||
|
|
||||||
priv->mapped = meta_window_toplevel_is_mapped (priv->window);
|
priv->mapped = meta_window_toplevel_is_mapped (priv->window);
|
||||||
if (priv->mapped)
|
if (priv->mapped)
|
||||||
meta_window_actor_queue_create_pixmap (self);
|
meta_window_actor_queue_create_x11_pixmap (self);
|
||||||
|
|
||||||
meta_window_actor_set_updates_frozen (self,
|
meta_window_actor_set_updates_frozen (self,
|
||||||
meta_window_updates_are_frozen (priv->window));
|
meta_window_updates_are_frozen (priv->window));
|
||||||
@ -1544,6 +1593,7 @@ meta_window_actor_new (MetaWindow *window)
|
|||||||
*/
|
*/
|
||||||
if (priv->window->extended_sync_request_counter && !priv->updates_frozen)
|
if (priv->window->extended_sync_request_counter && !priv->updates_frozen)
|
||||||
meta_window_actor_queue_frame_drawn (self, FALSE);
|
meta_window_actor_queue_frame_drawn (self, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
meta_window_actor_sync_actor_geometry (self, priv->window->placed);
|
meta_window_actor_sync_actor_geometry (self, priv->window->placed);
|
||||||
|
|
||||||
@ -1578,7 +1628,8 @@ meta_window_actor_mapped (MetaWindowActor *self)
|
|||||||
|
|
||||||
priv->mapped = TRUE;
|
priv->mapped = TRUE;
|
||||||
|
|
||||||
meta_window_actor_queue_create_pixmap (self);
|
if (!meta_is_wayland_compositor ())
|
||||||
|
meta_window_actor_queue_create_x11_pixmap (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1593,9 +1644,12 @@ meta_window_actor_unmapped (MetaWindowActor *self)
|
|||||||
if (meta_window_actor_effect_in_progress (self))
|
if (meta_window_actor_effect_in_progress (self))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
meta_window_actor_detach (self);
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
meta_window_actor_detach_x11_pixmap (self);
|
||||||
priv->needs_pixmap = FALSE;
|
priv->needs_pixmap = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_window_actor_get_obscured_region:
|
* meta_window_actor_get_obscured_region:
|
||||||
@ -1612,9 +1666,20 @@ meta_window_actor_get_obscured_region (MetaWindowActor *self)
|
|||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
if (priv->back_pixmap && priv->opacity == 0xff && !priv->window->shaded)
|
if (!priv->window->shaded)
|
||||||
|
{
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
if (priv->opacity == 0xff)
|
||||||
return priv->opaque_region;
|
return priv->opaque_region;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (priv->back_pixmap && priv->opacity == 0xff)
|
||||||
|
return priv->opaque_region;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1728,8 +1793,11 @@ meta_window_actor_reset_visible_regions (MetaWindowActor *self)
|
|||||||
g_clear_pointer (&priv->shadow_clip, cairo_region_destroy);
|
g_clear_pointer (&priv->shadow_clip, cairo_region_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* When running as a wayland compositor we don't make requests for
|
||||||
|
* replacement pixmaps when resizing windows, we will instead be
|
||||||
|
* asked to attach replacement buffers by the clients. */
|
||||||
static void
|
static void
|
||||||
check_needs_pixmap (MetaWindowActor *self)
|
check_needs_x11_pixmap (MetaWindowActor *self)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
MetaScreen *screen = priv->screen;
|
MetaScreen *screen = priv->screen;
|
||||||
@ -1751,10 +1819,10 @@ check_needs_pixmap (MetaWindowActor *self)
|
|||||||
|
|
||||||
compositor = meta_display_get_compositor (display);
|
compositor = meta_display_get_compositor (display);
|
||||||
|
|
||||||
if (priv->size_changed)
|
if (priv->x11_size_changed)
|
||||||
{
|
{
|
||||||
meta_window_actor_detach (self);
|
meta_window_actor_detach_x11_pixmap (self);
|
||||||
priv->size_changed = FALSE;
|
priv->x11_size_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_error_trap_push (display);
|
meta_error_trap_push (display);
|
||||||
@ -1886,13 +1954,13 @@ check_needs_shadow (MetaWindowActor *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_actor_process_damage (MetaWindowActor *self,
|
meta_window_actor_process_x11_damage (MetaWindowActor *self,
|
||||||
XDamageNotifyEvent *event)
|
XDamageNotifyEvent *event)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
MetaCompScreen *info = meta_screen_get_compositor_data (priv->screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (priv->screen);
|
||||||
|
|
||||||
priv->received_damage = TRUE;
|
priv->received_x11_damage = TRUE;
|
||||||
|
|
||||||
if (meta_window_is_fullscreen (priv->window) && g_list_last (info->windows)->data == self && !priv->unredirected)
|
if (meta_window_is_fullscreen (priv->window) && g_list_last (info->windows)->data == self && !priv->unredirected)
|
||||||
{
|
{
|
||||||
@ -1946,6 +2014,25 @@ meta_window_actor_process_damage (MetaWindowActor *self,
|
|||||||
priv->repaint_scheduled = TRUE;
|
priv->repaint_scheduled = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
void
|
||||||
|
meta_window_actor_process_wayland_damage (MetaWindowActor *self,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
|
if (!priv->mapped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
meta_shaped_texture_update_area (META_SHAPED_TEXTURE (priv->actor),
|
||||||
|
x, y, width, height);
|
||||||
|
priv->repaint_scheduled = TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_actor_sync_visibility (MetaWindowActor *self)
|
meta_window_actor_sync_visibility (MetaWindowActor *self)
|
||||||
{
|
{
|
||||||
@ -2106,7 +2193,7 @@ region_create_from_x_rectangles (const XRectangle *rects,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_actor_update_shape_region (MetaWindowActor *self,
|
meta_window_actor_update_x11_shape_region (MetaWindowActor *self,
|
||||||
cairo_rectangle_int_t *client_area)
|
cairo_rectangle_int_t *client_area)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
@ -2212,7 +2299,7 @@ meta_window_actor_update_shape_region (MetaWindowActor *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_actor_update_input_shape_region (MetaWindowActor *self,
|
meta_window_actor_update_x11_input_shape_region (MetaWindowActor *self,
|
||||||
cairo_rectangle_int_t *client_area)
|
cairo_rectangle_int_t *client_area)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
@ -2299,8 +2386,24 @@ check_needs_reshape (MetaWindowActor *self)
|
|||||||
else
|
else
|
||||||
client_area.height = priv->window->rect.height;
|
client_area.height = priv->window->rect.height;
|
||||||
|
|
||||||
meta_window_actor_update_shape_region (self, &client_area);
|
if (priv->window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
meta_window_actor_update_input_shape_region (self, &client_area);
|
{
|
||||||
|
meta_window_actor_update_x11_shape_region (self, &client_area);
|
||||||
|
meta_window_actor_update_x11_input_shape_region (self, &client_area);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* TODO: properly support setting an input region as specified
|
||||||
|
* via the wayland protocol */
|
||||||
|
|
||||||
|
g_clear_pointer (&priv->shape_region, cairo_region_destroy);
|
||||||
|
g_clear_pointer (&priv->opaque_region, cairo_region_destroy);
|
||||||
|
g_clear_pointer (&priv->input_shape_region, cairo_region_destroy);
|
||||||
|
|
||||||
|
priv->shape_region = cairo_region_create_rectangle (&client_area);
|
||||||
|
priv->opaque_region = cairo_region_reference (priv->shape_region);
|
||||||
|
priv->input_shape_region = cairo_region_reference (priv->shape_region);
|
||||||
|
}
|
||||||
|
|
||||||
priv->needs_reshape = FALSE;
|
priv->needs_reshape = FALSE;
|
||||||
}
|
}
|
||||||
@ -2318,6 +2421,69 @@ meta_window_actor_update_shape (MetaWindowActor *self)
|
|||||||
clutter_actor_queue_redraw (priv->actor);
|
clutter_actor_queue_redraw (priv->actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
static void
|
||||||
|
maybe_emit_size_changed (MetaWindowActor *self,
|
||||||
|
MetaWaylandBuffer *new_buffer)
|
||||||
|
{
|
||||||
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
int width = 0, height = 0;
|
||||||
|
|
||||||
|
if (new_buffer)
|
||||||
|
{
|
||||||
|
width = new_buffer->width;
|
||||||
|
height = new_buffer->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->last_width != width || priv->last_height != height)
|
||||||
|
{
|
||||||
|
meta_window_actor_update_shape (self);
|
||||||
|
|
||||||
|
/* ::size-changed is supposed to refer to meta_window_get_outer_rect()
|
||||||
|
* but here we are only looking at buffer size changes.
|
||||||
|
*
|
||||||
|
* Emitting it here works pretty much OK because a new buffer size (which
|
||||||
|
* will correspond to the outer rect with the addition of invisible
|
||||||
|
* borders) also normally implies a change to the outer rect. In the rare
|
||||||
|
* case where a change to the window size was exactly balanced by a
|
||||||
|
* change to the invisible borders, we would miss emitting the signal.
|
||||||
|
*/
|
||||||
|
g_signal_emit (self, signals[SIZE_CHANGED], 0);
|
||||||
|
|
||||||
|
priv->last_width = width;
|
||||||
|
priv->last_height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_window_actor_set_wayland_surface (MetaWindowActor *self,
|
||||||
|
MetaWaylandSurface *surface)
|
||||||
|
{
|
||||||
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
|
meta_shaped_texture_set_wayland_surface (META_SHAPED_TEXTURE (priv->actor),
|
||||||
|
surface);
|
||||||
|
if (surface->buffer_ref.buffer)
|
||||||
|
maybe_emit_size_changed (self, surface->buffer_ref.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_window_actor_attach_wayland_buffer (MetaWindowActor *self,
|
||||||
|
MetaWaylandBuffer *buffer)
|
||||||
|
{
|
||||||
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
MetaShapedTexture *stex = META_SHAPED_TEXTURE (priv->actor);
|
||||||
|
CoglTexture *prev_tex = meta_shaped_texture_get_texture (stex);
|
||||||
|
|
||||||
|
meta_shaped_texture_attach_wayland_buffer (stex, buffer);
|
||||||
|
|
||||||
|
if (!prev_tex)
|
||||||
|
meta_window_actor_sync_actor_geometry (self, FALSE);
|
||||||
|
|
||||||
|
maybe_emit_size_changed (self, buffer);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_WAYLAND */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_actor_handle_updates (MetaWindowActor *self)
|
meta_window_actor_handle_updates (MetaWindowActor *self)
|
||||||
{
|
{
|
||||||
@ -2333,13 +2499,15 @@ meta_window_actor_handle_updates (MetaWindowActor *self)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
if (priv->unredirected)
|
if (priv->unredirected)
|
||||||
{
|
{
|
||||||
/* Nothing to do here until/if the window gets redirected again */
|
/* Nothing to do here until/if the window gets redirected again */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->received_damage)
|
if (priv->received_x11_damage)
|
||||||
{
|
{
|
||||||
meta_error_trap_push (display);
|
meta_error_trap_push (display);
|
||||||
XDamageSubtract (xdisplay, priv->damage, None, None);
|
XDamageSubtract (xdisplay, priv->damage, None, None);
|
||||||
@ -2365,10 +2533,12 @@ meta_window_actor_handle_updates (MetaWindowActor *self)
|
|||||||
*/
|
*/
|
||||||
XSync (xdisplay, False);
|
XSync (xdisplay, False);
|
||||||
|
|
||||||
priv->received_damage = FALSE;
|
priv->received_x11_damage = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
check_needs_x11_pixmap (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_needs_pixmap (self);
|
|
||||||
check_needs_reshape (self);
|
check_needs_reshape (self);
|
||||||
check_needs_shadow (self);
|
check_needs_shadow (self);
|
||||||
}
|
}
|
||||||
@ -2546,6 +2716,9 @@ meta_window_actor_update_opacity (MetaWindowActor *self)
|
|||||||
void
|
void
|
||||||
meta_window_actor_set_updates_frozen (MetaWindowActor *self,
|
meta_window_actor_set_updates_frozen (MetaWindowActor *self,
|
||||||
gboolean updates_frozen)
|
gboolean updates_frozen)
|
||||||
|
{
|
||||||
|
/* On wayland we shouldn't need to ever freeze updates... */
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv = self->priv;
|
MetaWindowActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
@ -2560,3 +2733,4 @@ meta_window_actor_set_updates_frozen (MetaWindowActor *self,
|
|||||||
meta_window_actor_thaw (self);
|
meta_window_actor_thaw (self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "meta-window-group.h"
|
#include "meta-window-group.h"
|
||||||
#include "meta-background-actor-private.h"
|
#include "meta-background-actor-private.h"
|
||||||
#include "meta-background-group-private.h"
|
#include "meta-background-group-private.h"
|
||||||
|
#include "window-private.h"
|
||||||
|
|
||||||
struct _MetaWindowGroupClass
|
struct _MetaWindowGroupClass
|
||||||
{
|
{
|
||||||
@ -99,7 +100,7 @@ meta_window_group_paint (ClutterActor *actor)
|
|||||||
int paint_x_offset, paint_y_offset;
|
int paint_x_offset, paint_y_offset;
|
||||||
|
|
||||||
MetaWindowGroup *window_group = META_WINDOW_GROUP (actor);
|
MetaWindowGroup *window_group = META_WINDOW_GROUP (actor);
|
||||||
MetaCompScreen *info = meta_screen_get_compositor_data (window_group->screen);
|
MetaCompScreen *info;
|
||||||
|
|
||||||
/* Normally we expect an actor to be drawn at it's position on the screen.
|
/* Normally we expect an actor to be drawn at it's position on the screen.
|
||||||
* However, if we're inside the paint of a ClutterClone, that won't be the
|
* However, if we're inside the paint of a ClutterClone, that won't be the
|
||||||
@ -136,6 +137,9 @@ meta_window_group_paint (ClutterActor *actor)
|
|||||||
|
|
||||||
visible_region = cairo_region_create_rectangle (&visible_rect);
|
visible_region = cairo_region_create_rectangle (&visible_rect);
|
||||||
|
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
info = meta_screen_get_compositor_data (window_group->screen);
|
||||||
if (info->unredirected_window != NULL)
|
if (info->unredirected_window != NULL)
|
||||||
{
|
{
|
||||||
cairo_rectangle_int_t unredirected_rect;
|
cairo_rectangle_int_t unredirected_rect;
|
||||||
@ -144,6 +148,7 @@ meta_window_group_paint (ClutterActor *actor)
|
|||||||
meta_window_get_outer_rect (window, (MetaRectangle *)&unredirected_rect);
|
meta_window_get_outer_rect (window, (MetaRectangle *)&unredirected_rect);
|
||||||
cairo_region_subtract_rectangle (visible_region, &unredirected_rect);
|
cairo_region_subtract_rectangle (visible_region, &unredirected_rect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* We walk the list from top to bottom (opposite of painting order),
|
/* We walk the list from top to bottom (opposite of painting order),
|
||||||
* and subtract the opaque area of each window out of the visible
|
* and subtract the opaque area of each window out of the visible
|
||||||
@ -155,7 +160,8 @@ meta_window_group_paint (ClutterActor *actor)
|
|||||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (info->unredirected_window != NULL &&
|
if (!meta_is_wayland_compositor () &&
|
||||||
|
info->unredirected_window != NULL &&
|
||||||
child == CLUTTER_ACTOR (info->unredirected_window))
|
child == CLUTTER_ACTOR (info->unredirected_window))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -180,7 +186,8 @@ meta_window_group_paint (ClutterActor *actor)
|
|||||||
|
|
||||||
if (META_IS_WINDOW_ACTOR (child))
|
if (META_IS_WINDOW_ACTOR (child))
|
||||||
{
|
{
|
||||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (child);
|
MetaWindow *meta_window;
|
||||||
|
MetaWindowActor *window_actor = child;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if (!meta_actor_is_untransformed (CLUTTER_ACTOR (window_actor), &x, &y))
|
if (!meta_actor_is_untransformed (CLUTTER_ACTOR (window_actor), &x, &y))
|
||||||
@ -194,7 +201,14 @@ meta_window_group_paint (ClutterActor *actor)
|
|||||||
|
|
||||||
meta_window_actor_set_visible_region (window_actor, visible_region);
|
meta_window_actor_set_visible_region (window_actor, visible_region);
|
||||||
|
|
||||||
if (clutter_actor_get_paint_opacity (CLUTTER_ACTOR (window_actor)) == 0xff)
|
/* TODO: Track the opaque regions of wayland clients.
|
||||||
|
* Although wayland clients can report opaque window
|
||||||
|
* regions, for now we assume that all wayland clients are
|
||||||
|
* transparent... */
|
||||||
|
meta_window = meta_window_actor_get_meta_window (window_actor);
|
||||||
|
|
||||||
|
if (meta_window->client_type != META_WINDOW_CLIENT_TYPE_WAYLAND &&
|
||||||
|
clutter_actor_get_paint_opacity (CLUTTER_ACTOR (window_actor)) == 0xff)
|
||||||
{
|
{
|
||||||
cairo_region_t *obscured_region = meta_window_actor_get_obscured_region (window_actor);
|
cairo_region_t *obscured_region = meta_window_actor_get_obscured_region (window_actor);
|
||||||
if (obscured_region)
|
if (obscured_region)
|
||||||
|
@ -932,6 +932,22 @@ meta_display_open (void)
|
|||||||
{
|
{
|
||||||
MetaScreen *screen = tmp->data;
|
MetaScreen *screen = tmp->data;
|
||||||
|
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
/* Instead of explicitly enumerating all windows during
|
||||||
|
* initialization, when we run as a wayland compositor we can rely on
|
||||||
|
* xwayland notifying us of all top level windows so we create
|
||||||
|
* MetaWindows when we get those notifications.
|
||||||
|
*
|
||||||
|
* We still want a guard window so we can avoid
|
||||||
|
* unmapping/withdrawing minimized windows for live
|
||||||
|
* thumbnails...
|
||||||
|
*/
|
||||||
|
if (screen->guard_window == None)
|
||||||
|
screen->guard_window =
|
||||||
|
meta_screen_create_guard_window (screen->display->xdisplay, screen);
|
||||||
|
}
|
||||||
|
else
|
||||||
meta_screen_manage_all_windows (screen);
|
meta_screen_manage_all_windows (screen);
|
||||||
|
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
@ -2284,7 +2300,7 @@ event_callback (XEvent *event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (display->compositor)
|
if (display->compositor)
|
||||||
meta_compositor_window_shape_changed (display->compositor,
|
meta_compositor_window_x11_shape_changed (display->compositor,
|
||||||
window);
|
window);
|
||||||
}
|
}
|
||||||
else if (sev->kind == ShapeInput)
|
else if (sev->kind == ShapeInput)
|
||||||
@ -2311,7 +2327,7 @@ event_callback (XEvent *event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (display->compositor)
|
if (display->compositor)
|
||||||
meta_compositor_window_shape_changed (display->compositor,
|
meta_compositor_window_x11_shape_changed (display->compositor,
|
||||||
window);
|
window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
106
src/core/main.c
106
src/core/main.c
@ -55,6 +55,9 @@
|
|||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include <meta/prefs.h>
|
#include <meta/prefs.h>
|
||||||
#include <meta/compositor.h>
|
#include <meta/compositor.h>
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
@ -346,28 +349,74 @@ meta_finalize (void)
|
|||||||
if (display)
|
if (display)
|
||||||
meta_display_close (display,
|
meta_display_close (display,
|
||||||
CurrentTime); /* I doubt correct timestamps matter here */
|
CurrentTime); /* I doubt correct timestamps matter here */
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
meta_wayland_finalize ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sigterm_pipe_fds[2] = { -1, -1 };
|
static int signal_pipe_fds[2] = { -1, -1 };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigterm_handler (int signum)
|
signal_handler (int signum)
|
||||||
{
|
{
|
||||||
if (sigterm_pipe_fds[1] >= 0)
|
if (signal_pipe_fds[1] >= 0)
|
||||||
{
|
{
|
||||||
int G_GNUC_UNUSED dummy;
|
switch (signum)
|
||||||
|
{
|
||||||
dummy = write (sigterm_pipe_fds[1], "", 1);
|
case SIGTERM:
|
||||||
close (sigterm_pipe_fds[1]);
|
write (signal_pipe_fds[1], "T", 1);
|
||||||
sigterm_pipe_fds[1] = -1;
|
break;
|
||||||
|
case SIGCHLD:
|
||||||
|
write (signal_pipe_fds[1], "C", 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_sigterm (void)
|
on_signal (GIOChannel *source,
|
||||||
|
GIOCondition condition,
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
|
char signal;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
count = read (signal_pipe_fds[0], &signal, 1);
|
||||||
|
if (count == EINTR)
|
||||||
|
continue;
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
const char *msg = strerror (errno);
|
||||||
|
g_warning ("Error handling signal: %s", msg);
|
||||||
|
}
|
||||||
|
if (count != 1)
|
||||||
|
{
|
||||||
|
g_warning ("Unexpectedly failed to read byte from signal pipe\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (signal)
|
||||||
|
{
|
||||||
|
case 'T': /* SIGTERM */
|
||||||
meta_quit (META_EXIT_SUCCESS);
|
meta_quit (META_EXIT_SUCCESS);
|
||||||
return FALSE;
|
break;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
case 'C': /* SIGCHLD */
|
||||||
|
meta_wayland_handle_sig_child ();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
g_warning ("Spurious character '%c' read from signal pipe", signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,21 +445,28 @@ meta_init (void)
|
|||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pipe (sigterm_pipe_fds) != 0)
|
if (pipe (signal_pipe_fds) != 0)
|
||||||
g_printerr ("Failed to create SIGTERM pipe: %s\n",
|
g_printerr ("Failed to create signal pipe: %s\n",
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
|
|
||||||
channel = g_io_channel_unix_new (sigterm_pipe_fds[0]);
|
channel = g_io_channel_unix_new (signal_pipe_fds[0]);
|
||||||
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
||||||
g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_sigterm, NULL);
|
g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_signal, NULL);
|
||||||
g_io_channel_set_close_on_unref (channel, TRUE);
|
g_io_channel_set_close_on_unref (channel, TRUE);
|
||||||
g_io_channel_unref (channel);
|
g_io_channel_unref (channel);
|
||||||
|
|
||||||
act.sa_handler = &sigterm_handler;
|
act.sa_handler = &signal_handler;
|
||||||
if (sigaction (SIGTERM, &act, NULL) < 0)
|
if (sigaction (SIGTERM, &act, NULL) < 0)
|
||||||
g_printerr ("Failed to register SIGTERM handler: %s\n",
|
g_printerr ("Failed to register SIGTERM handler: %s\n",
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
|
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
if (sigaction (SIGCHLD, &act, NULL) < 0)
|
||||||
|
g_printerr ("Failed to register SIGCHLD handler: %s\n",
|
||||||
|
g_strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
if (g_getenv ("MUTTER_VERBOSE"))
|
if (g_getenv ("MUTTER_VERBOSE"))
|
||||||
meta_set_verbose (TRUE);
|
meta_set_verbose (TRUE);
|
||||||
if (g_getenv ("MUTTER_DEBUG"))
|
if (g_getenv ("MUTTER_DEBUG"))
|
||||||
@ -427,10 +483,19 @@ meta_init (void)
|
|||||||
g_irepository_prepend_search_path (MUTTER_PKGLIBDIR);
|
g_irepository_prepend_search_path (MUTTER_PKGLIBDIR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL));
|
#ifdef HAVE_WAYLAND
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
/* NB: When running as a hybrid wayland compositor we run our own headless X
|
||||||
|
* server so the user can't control the X display to connect too. */
|
||||||
|
meta_wayland_init ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
meta_select_display (opt_display_name);
|
meta_select_display (opt_display_name);
|
||||||
|
|
||||||
|
meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL));
|
||||||
|
|
||||||
if (opt_replace_wm)
|
if (opt_replace_wm)
|
||||||
meta_set_replace_current_wm (TRUE);
|
meta_set_replace_current_wm (TRUE);
|
||||||
|
|
||||||
@ -441,11 +506,18 @@ meta_init (void)
|
|||||||
|
|
||||||
meta_ui_init ();
|
meta_ui_init ();
|
||||||
|
|
||||||
|
/* If we are running with wayland then we don't wait until we have
|
||||||
|
* an X connection before initializing clutter we instead initialize
|
||||||
|
* it earlier since we need to initialize the GL driver so the driver
|
||||||
|
* can register any needed wayland extensions. */
|
||||||
|
if (!meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Clutter can only be initialized after the UI.
|
* Clutter can only be initialized after the UI.
|
||||||
*/
|
*/
|
||||||
meta_clutter_init ();
|
meta_clutter_init ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_register_with_session:
|
* meta_register_with_session:
|
||||||
|
@ -257,4 +257,6 @@ void meta_screen_workspace_switched (MetaScreen *screen,
|
|||||||
|
|
||||||
void meta_screen_set_active_workspace_hint (MetaScreen *screen);
|
void meta_screen_set_active_workspace_hint (MetaScreen *screen);
|
||||||
|
|
||||||
|
Window meta_screen_create_guard_window (Display *xdisplay, MetaScreen *screen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
#include <meta/compositor.h>
|
#include <meta/compositor.h>
|
||||||
#include "mutter-enum-types.h"
|
#include "mutter-enum-types.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
|
||||||
@ -603,8 +606,8 @@ reload_monitor_infos (MetaScreen *screen)
|
|||||||
* should effectively be forwarded to events on the background actor,
|
* should effectively be forwarded to events on the background actor,
|
||||||
* providing that the scene graph is set up correctly.
|
* providing that the scene graph is set up correctly.
|
||||||
*/
|
*/
|
||||||
static Window
|
Window
|
||||||
create_guard_window (Display *xdisplay, MetaScreen *screen)
|
meta_screen_create_guard_window (Display *xdisplay, MetaScreen *screen)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes attributes;
|
XSetWindowAttributes attributes;
|
||||||
Window guard_window;
|
Window guard_window;
|
||||||
@ -668,6 +671,9 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
guint32 manager_timestamp;
|
guint32 manager_timestamp;
|
||||||
gulong current_workspace;
|
gulong current_workspace;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
MetaWaylandCompositor *compositor;
|
||||||
|
#endif
|
||||||
|
|
||||||
replace_current_wm = meta_get_replace_current_wm ();
|
replace_current_wm = meta_get_replace_current_wm ();
|
||||||
|
|
||||||
@ -826,8 +832,21 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
screen->xscreen = ScreenOfDisplay (xdisplay, number);
|
screen->xscreen = ScreenOfDisplay (xdisplay, number);
|
||||||
screen->xroot = xroot;
|
screen->xroot = xroot;
|
||||||
screen->rect.x = screen->rect.y = 0;
|
screen->rect.x = screen->rect.y = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
{
|
||||||
|
compositor = meta_wayland_compositor_get_default ();
|
||||||
|
screen->rect.width = clutter_actor_get_width (compositor->stage);
|
||||||
|
screen->rect.height = clutter_actor_get_height (compositor->stage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
screen->rect.width = WidthOfScreen (screen->xscreen);
|
screen->rect.width = WidthOfScreen (screen->xscreen);
|
||||||
screen->rect.height = HeightOfScreen (screen->xscreen);
|
screen->rect.height = HeightOfScreen (screen->xscreen);
|
||||||
|
}
|
||||||
|
|
||||||
screen->current_cursor = -1; /* invalid/unset */
|
screen->current_cursor = -1; /* invalid/unset */
|
||||||
screen->default_xvisual = DefaultVisualOfScreen (screen->xscreen);
|
screen->default_xvisual = DefaultVisualOfScreen (screen->xscreen);
|
||||||
screen->default_depth = DefaultDepthOfScreen (screen->xscreen);
|
screen->default_depth = DefaultDepthOfScreen (screen->xscreen);
|
||||||
@ -1082,8 +1101,8 @@ meta_screen_manage_all_windows (MetaScreen *screen)
|
|||||||
meta_display_grab (screen->display);
|
meta_display_grab (screen->display);
|
||||||
|
|
||||||
if (screen->guard_window == None)
|
if (screen->guard_window == None)
|
||||||
screen->guard_window = create_guard_window (screen->display->xdisplay,
|
screen->guard_window =
|
||||||
screen);
|
meta_screen_create_guard_window (screen->display->xdisplay, screen);
|
||||||
|
|
||||||
windows = list_windows (screen);
|
windows = list_windows (screen);
|
||||||
|
|
||||||
|
@ -44,6 +44,17 @@
|
|||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* XXX: We should find a nicer approach to deal with the
|
||||||
|
* circular dependency we have with the current headers
|
||||||
|
* (meta-wayland-private.h which typedefs MetaWaylandSurface
|
||||||
|
* also includes window-private.h) */
|
||||||
|
#ifndef HAVE_META_WAYLAND_SURFACE_TYPE
|
||||||
|
typedef struct _MetaWaylandSurface MetaWaylandSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct _MetaWindowQueue MetaWindowQueue;
|
typedef struct _MetaWindowQueue MetaWindowQueue;
|
||||||
|
|
||||||
@ -69,6 +80,11 @@ typedef enum {
|
|||||||
_NET_WM_BYPASS_COMPOSITOR_HINT_OFF = 2,
|
_NET_WM_BYPASS_COMPOSITOR_HINT_OFF = 2,
|
||||||
} MetaBypassCompositorHintValue;
|
} MetaBypassCompositorHintValue;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
META_WINDOW_CLIENT_TYPE_WAYLAND,
|
||||||
|
META_WINDOW_CLIENT_TYPE_X11
|
||||||
|
} MetaWindowClientType;
|
||||||
|
|
||||||
struct _MetaWindow
|
struct _MetaWindow
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
@ -77,6 +93,10 @@ struct _MetaWindow
|
|||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
const MetaMonitorInfo *monitor;
|
const MetaMonitorInfo *monitor;
|
||||||
MetaWorkspace *workspace;
|
MetaWorkspace *workspace;
|
||||||
|
MetaWindowClientType client_type;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
MetaWaylandSurface *surface;
|
||||||
|
#endif
|
||||||
Window xwindow;
|
Window xwindow;
|
||||||
/* may be NULL! not all windows get decorated */
|
/* may be NULL! not all windows get decorated */
|
||||||
MetaFrame *frame;
|
MetaFrame *frame;
|
||||||
@ -489,6 +509,10 @@ MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
gboolean must_be_viewable,
|
gboolean must_be_viewable,
|
||||||
MetaCompEffect effect,
|
MetaCompEffect effect,
|
||||||
XWindowAttributes *attrs);
|
XWindowAttributes *attrs);
|
||||||
|
MetaWindow *meta_window_new_for_wayland (MetaDisplay *display,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
MetaWaylandSurface *surface);
|
||||||
void meta_window_unmanage (MetaWindow *window,
|
void meta_window_unmanage (MetaWindow *window,
|
||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
void meta_window_calc_showing (MetaWindow *window);
|
void meta_window_calc_showing (MetaWindow *window);
|
||||||
|
@ -713,7 +713,7 @@ meta_window_new (MetaDisplay *display,
|
|||||||
* Returns TRUE if window has been filtered out and should be ignored.
|
* Returns TRUE if window has been filtered out and should be ignored.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
maybe_filter_window (MetaDisplay *display,
|
maybe_filter_xwindow (MetaDisplay *display,
|
||||||
Window xwindow,
|
Window xwindow,
|
||||||
gboolean must_be_viewable,
|
gboolean must_be_viewable,
|
||||||
XWindowAttributes *attrs)
|
XWindowAttributes *attrs)
|
||||||
@ -812,81 +812,25 @@ meta_window_should_attach_to_parent (MetaWindow *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaWindow*
|
static MetaWindow*
|
||||||
meta_window_new_with_attrs (MetaDisplay *display,
|
meta_window_new_shared (MetaDisplay *display,
|
||||||
|
MetaScreen *screen,
|
||||||
|
MetaWindowClientType client_type,
|
||||||
|
MetaWaylandSurface *surface,
|
||||||
Window xwindow,
|
Window xwindow,
|
||||||
gboolean must_be_viewable,
|
gboolean must_be_viewable,
|
||||||
|
gulong existing_wm_state,
|
||||||
|
gboolean has_shape,
|
||||||
|
gboolean has_input_shape,
|
||||||
MetaCompEffect effect,
|
MetaCompEffect effect,
|
||||||
XWindowAttributes *attrs)
|
XWindowAttributes *attrs)
|
||||||
{
|
{
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
GSList *tmp;
|
|
||||||
MetaWorkspace *space;
|
MetaWorkspace *space;
|
||||||
gulong existing_wm_state;
|
|
||||||
gulong event_mask;
|
|
||||||
MetaMoveResizeFlags flags;
|
MetaMoveResizeFlags flags;
|
||||||
gboolean has_shape;
|
|
||||||
gboolean has_input_shape;
|
|
||||||
MetaScreen *screen;
|
|
||||||
|
|
||||||
g_assert (attrs != NULL);
|
g_assert (attrs != NULL);
|
||||||
|
|
||||||
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
|
||||||
|
|
||||||
if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
|
|
||||||
{
|
|
||||||
meta_verbose ("Not managing no_focus_window 0x%lx\n",
|
|
||||||
xwindow);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen = NULL;
|
|
||||||
for (tmp = display->screens; tmp != NULL; tmp = tmp->next)
|
|
||||||
{
|
|
||||||
MetaScreen *scr = tmp->data;
|
|
||||||
|
|
||||||
if (scr->xroot == attrs->root)
|
|
||||||
{
|
|
||||||
screen = tmp->data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_assert (screen);
|
|
||||||
|
|
||||||
/* A black list of override redirect windows that we don't need to manage: */
|
|
||||||
if (attrs->override_redirect &&
|
|
||||||
(xwindow == screen->no_focus_window ||
|
|
||||||
xwindow == screen->flash_window ||
|
|
||||||
xwindow == screen->wm_sn_selection_window ||
|
|
||||||
attrs->class == InputOnly ||
|
|
||||||
/* any windows created via meta_create_offscreen_window: */
|
|
||||||
(attrs->x == -100 && attrs->y == -100
|
|
||||||
&& attrs->width == 1 && attrs->height == 1) ||
|
|
||||||
xwindow == screen->wm_cm_selection_window ||
|
|
||||||
xwindow == screen->guard_window ||
|
|
||||||
(display->compositor &&
|
|
||||||
xwindow == XCompositeGetOverlayWindow (display->xdisplay,
|
|
||||||
screen->xroot)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
meta_verbose ("Not managing our own windows\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maybe_filter_window (display, xwindow, must_be_viewable, attrs))
|
|
||||||
{
|
|
||||||
meta_verbose ("Not managing filtered window\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Grab server */
|
|
||||||
meta_display_grab (display);
|
|
||||||
meta_error_trap_push (display); /* Push a trap over all of window
|
|
||||||
* creation, to reduce XSync() calls
|
|
||||||
*/
|
|
||||||
|
|
||||||
meta_verbose ("must_be_viewable = %d attrs->map_state = %d (%s)\n",
|
meta_verbose ("must_be_viewable = %d attrs->map_state = %d (%s)\n",
|
||||||
must_be_viewable,
|
must_be_viewable,
|
||||||
attrs->map_state,
|
attrs->map_state,
|
||||||
@ -898,150 +842,16 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
"IsUnviewable" :
|
"IsUnviewable" :
|
||||||
"(unknown)");
|
"(unknown)");
|
||||||
|
|
||||||
existing_wm_state = WithdrawnState;
|
|
||||||
if (must_be_viewable && attrs->map_state != IsViewable)
|
|
||||||
{
|
|
||||||
/* Only manage if WM_STATE is IconicState or NormalState */
|
|
||||||
gulong state;
|
|
||||||
|
|
||||||
/* WM_STATE isn't a cardinal, it's type WM_STATE, but is an int */
|
|
||||||
if (!(meta_prop_get_cardinal_with_atom_type (display, xwindow,
|
|
||||||
display->atom_WM_STATE,
|
|
||||||
display->atom_WM_STATE,
|
|
||||||
&state) &&
|
|
||||||
(state == IconicState || state == NormalState)))
|
|
||||||
{
|
|
||||||
meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow);
|
|
||||||
meta_error_trap_pop (display);
|
|
||||||
meta_display_ungrab (display);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
existing_wm_state = state;
|
|
||||||
meta_verbose ("WM_STATE of %lx = %s\n", xwindow,
|
|
||||||
wm_state_to_string (existing_wm_state));
|
|
||||||
}
|
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XAddToSaveSet can only be called on windows created by a different client.
|
|
||||||
* with Mutter we want to be able to create manageable windows from within
|
|
||||||
* the process (such as a dummy desktop window), so we do not want this
|
|
||||||
* call failing to prevent the window from being managed -- wrap it in its
|
|
||||||
* own error trap (we use the _with_return() version here to ensure that
|
|
||||||
* XSync() is done on the pop, otherwise the error will not get caught).
|
|
||||||
*/
|
|
||||||
meta_error_trap_push_with_return (display);
|
|
||||||
XAddToSaveSet (display->xdisplay, xwindow);
|
|
||||||
meta_error_trap_pop_with_return (display);
|
|
||||||
|
|
||||||
event_mask = PropertyChangeMask | ColormapChangeMask;
|
|
||||||
if (attrs->override_redirect)
|
|
||||||
event_mask |= StructureNotifyMask;
|
|
||||||
|
|
||||||
/* If the window is from this client (a menu, say) we need to augment
|
|
||||||
* the event mask, not replace it. For windows from other clients,
|
|
||||||
* attrs->your_event_mask will be empty at this point.
|
|
||||||
*/
|
|
||||||
XSelectInput (display->xdisplay, xwindow, attrs->your_event_mask | event_mask);
|
|
||||||
|
|
||||||
{
|
|
||||||
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
|
||||||
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
|
||||||
|
|
||||||
meta_core_add_old_event_mask (display->xdisplay, xwindow, &mask);
|
|
||||||
|
|
||||||
XISetMask (mask.mask, XI_Enter);
|
|
||||||
XISetMask (mask.mask, XI_Leave);
|
|
||||||
XISetMask (mask.mask, XI_FocusIn);
|
|
||||||
XISetMask (mask.mask, XI_FocusOut);
|
|
||||||
|
|
||||||
XISelectEvents (display->xdisplay, xwindow, &mask, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
has_shape = FALSE;
|
|
||||||
has_input_shape = FALSE;
|
|
||||||
#ifdef HAVE_SHAPE
|
|
||||||
if (META_DISPLAY_HAS_SHAPE (display))
|
|
||||||
{
|
|
||||||
int x_bounding, y_bounding, x_clip, y_clip;
|
|
||||||
unsigned w_bounding, h_bounding, w_clip, h_clip;
|
|
||||||
int bounding_shaped, clip_shaped;
|
|
||||||
XRectangle *input_rectangles;
|
|
||||||
int n_rects, ordering;
|
|
||||||
|
|
||||||
XShapeSelectInput (display->xdisplay, xwindow, ShapeNotifyMask);
|
|
||||||
|
|
||||||
XShapeQueryExtents (display->xdisplay, xwindow,
|
|
||||||
&bounding_shaped, &x_bounding, &y_bounding,
|
|
||||||
&w_bounding, &h_bounding,
|
|
||||||
&clip_shaped, &x_clip, &y_clip,
|
|
||||||
&w_clip, &h_clip);
|
|
||||||
|
|
||||||
has_shape = bounding_shaped != FALSE;
|
|
||||||
|
|
||||||
/* XXX: The x shape extension doesn't provide a way to only test if an
|
|
||||||
* input shape has been specified, so we have to query and throw away the
|
|
||||||
* rectangles. */
|
|
||||||
meta_error_trap_push (display);
|
|
||||||
input_rectangles = XShapeGetRectangles (display->xdisplay, xwindow,
|
|
||||||
ShapeInput, &n_rects, &ordering);
|
|
||||||
meta_error_trap_pop (display);
|
|
||||||
if (input_rectangles)
|
|
||||||
{
|
|
||||||
if (n_rects > 1 ||
|
|
||||||
(n_rects == 1 &&
|
|
||||||
(input_rectangles[0].x != x_bounding ||
|
|
||||||
input_rectangles[1].y != y_bounding ||
|
|
||||||
input_rectangles[2].width != w_bounding ||
|
|
||||||
input_rectangles[3].height != h_bounding)))
|
|
||||||
{
|
|
||||||
has_input_shape = TRUE;
|
|
||||||
}
|
|
||||||
XFree (input_rectangles);
|
|
||||||
}
|
|
||||||
|
|
||||||
meta_topic (META_DEBUG_SHAPES,
|
|
||||||
"Window has_shape = %d extents %d,%d %u x %u\n",
|
|
||||||
has_shape, x_bounding, y_bounding,
|
|
||||||
w_bounding, h_bounding);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get rid of any borders */
|
|
||||||
if (attrs->border_width != 0)
|
|
||||||
XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
|
|
||||||
|
|
||||||
/* Get rid of weird gravities */
|
|
||||||
if (attrs->win_gravity != NorthWestGravity)
|
|
||||||
{
|
|
||||||
XSetWindowAttributes set_attrs;
|
|
||||||
|
|
||||||
set_attrs.win_gravity = NorthWestGravity;
|
|
||||||
|
|
||||||
XChangeWindowAttributes (display->xdisplay,
|
|
||||||
xwindow,
|
|
||||||
CWWinGravity,
|
|
||||||
&set_attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (meta_error_trap_pop_with_return (display) != Success)
|
|
||||||
{
|
|
||||||
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
|
|
||||||
xwindow);
|
|
||||||
meta_error_trap_pop (display);
|
|
||||||
meta_display_ungrab (display);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
window = g_object_new (META_TYPE_WINDOW, NULL);
|
window = g_object_new (META_TYPE_WINDOW, NULL);
|
||||||
|
|
||||||
window->constructing = TRUE;
|
window->constructing = TRUE;
|
||||||
|
|
||||||
window->dialog_pid = -1;
|
window->dialog_pid = -1;
|
||||||
|
|
||||||
|
window->client_type = client_type;
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
window->surface = surface;
|
||||||
|
#endif
|
||||||
window->xwindow = xwindow;
|
window->xwindow = xwindow;
|
||||||
|
|
||||||
/* this is in window->screen->display, but that's too annoying to
|
/* this is in window->screen->display, but that's too annoying to
|
||||||
@ -1168,7 +978,11 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
window->mwm_has_move_func = TRUE;
|
window->mwm_has_move_func = TRUE;
|
||||||
window->mwm_has_resize_func = TRUE;
|
window->mwm_has_resize_func = TRUE;
|
||||||
|
|
||||||
|
if (client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
window->decorated = TRUE;
|
window->decorated = TRUE;
|
||||||
|
else
|
||||||
|
window->decorated = FALSE;
|
||||||
|
|
||||||
window->has_close_func = TRUE;
|
window->has_close_func = TRUE;
|
||||||
window->has_minimize_func = TRUE;
|
window->has_minimize_func = TRUE;
|
||||||
window->has_maximize_func = TRUE;
|
window->has_maximize_func = TRUE;
|
||||||
@ -1227,6 +1041,13 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
|
|
||||||
window->tile_match = NULL;
|
window->tile_match = NULL;
|
||||||
|
|
||||||
|
/* Assign this #MetaWindow a sequence number which can be used
|
||||||
|
* for sorting.
|
||||||
|
*/
|
||||||
|
window->stable_sequence = ++display->window_sequence_counter;
|
||||||
|
|
||||||
|
if (client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
|
{
|
||||||
if (window->override_redirect)
|
if (window->override_redirect)
|
||||||
{
|
{
|
||||||
window->decorated = FALSE;
|
window->decorated = FALSE;
|
||||||
@ -1238,11 +1059,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
meta_display_register_x_window (display, &window->xwindow, window);
|
meta_display_register_x_window (display, &window->xwindow, window);
|
||||||
|
}
|
||||||
/* Assign this #MetaWindow a sequence number which can be used
|
|
||||||
* for sorting.
|
|
||||||
*/
|
|
||||||
window->stable_sequence = ++display->window_sequence_counter;
|
|
||||||
|
|
||||||
/* assign the window to its group, or create a new group if needed
|
/* assign the window to its group, or create a new group if needed
|
||||||
*/
|
*/
|
||||||
@ -1252,7 +1069,8 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
|
|
||||||
meta_window_load_initial_properties (window);
|
meta_window_load_initial_properties (window);
|
||||||
|
|
||||||
if (!window->override_redirect)
|
if (!window->override_redirect &&
|
||||||
|
client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
{
|
{
|
||||||
update_sm_hints (window); /* must come after transient_for */
|
update_sm_hints (window); /* must come after transient_for */
|
||||||
|
|
||||||
@ -1526,11 +1344,14 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
!window->initially_iconic)
|
!window->initially_iconic)
|
||||||
unminimize_window_and_all_transient_parents (window);
|
unminimize_window_and_all_transient_parents (window);
|
||||||
|
|
||||||
meta_error_trap_pop (display); /* pop the XSync()-reducing trap */
|
|
||||||
meta_display_ungrab (display);
|
|
||||||
|
|
||||||
window->constructing = FALSE;
|
window->constructing = FALSE;
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_notify_window (MetaDisplay *display, MetaWindow *window)
|
||||||
|
{
|
||||||
meta_display_notify_window_created (display, window);
|
meta_display_notify_window_created (display, window);
|
||||||
|
|
||||||
if (window->wm_state_demands_attention)
|
if (window->wm_state_demands_attention)
|
||||||
@ -1538,6 +1359,309 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
|
|
||||||
if (window->wm_hints_urgent)
|
if (window->wm_hints_urgent)
|
||||||
g_signal_emit_by_name (window->display, "window-marked-urgent", window);
|
g_signal_emit_by_name (window->display, "window-marked-urgent", window);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
MetaWindow *
|
||||||
|
meta_window_new_for_wayland (MetaDisplay *display,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
MetaWaylandSurface *surface)
|
||||||
|
{
|
||||||
|
XWindowAttributes attrs;
|
||||||
|
MetaScreen *scr = display->screens->data;
|
||||||
|
MetaWindow *window;
|
||||||
|
|
||||||
|
attrs.x = 0;
|
||||||
|
attrs.y = 0;
|
||||||
|
attrs.width = width;
|
||||||
|
attrs.height = height;
|
||||||
|
attrs.border_width = 0;
|
||||||
|
attrs.depth = 24;
|
||||||
|
attrs.visual = NULL;
|
||||||
|
attrs.root = scr->xroot;
|
||||||
|
attrs.class = InputOutput;
|
||||||
|
attrs.bit_gravity = NorthWestGravity;
|
||||||
|
attrs.win_gravity = NorthWestGravity;
|
||||||
|
attrs.backing_store = 0;
|
||||||
|
attrs.backing_planes = ~0;
|
||||||
|
attrs.backing_pixel = 0;
|
||||||
|
attrs.save_under = 0;
|
||||||
|
attrs.colormap = 0;
|
||||||
|
attrs.map_installed = 1;
|
||||||
|
attrs.map_state = IsUnmapped;
|
||||||
|
attrs.all_event_masks = ~0;
|
||||||
|
attrs.your_event_mask = 0;
|
||||||
|
attrs.do_not_propagate_mask = 0;
|
||||||
|
attrs.override_redirect = 0;
|
||||||
|
attrs.screen = scr->xscreen;
|
||||||
|
|
||||||
|
/* XXX: Note: In the Wayland case we currently still grab the
|
||||||
|
* xserver and trap X errors while creating a MetaWindow because we
|
||||||
|
* will still be making various redundant X requests (passing a
|
||||||
|
* window xid of None) until we thoroughly audit all the code to
|
||||||
|
* make sure it knows about non X based clients...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Grab server */
|
||||||
|
meta_display_grab (display);
|
||||||
|
meta_error_trap_push (display); /* Push a trap over all of window
|
||||||
|
* creation, to reduce XSync() calls
|
||||||
|
*/
|
||||||
|
|
||||||
|
window = meta_window_new_shared (display,
|
||||||
|
scr,
|
||||||
|
META_WINDOW_CLIENT_TYPE_WAYLAND,
|
||||||
|
surface,
|
||||||
|
None,
|
||||||
|
TRUE,
|
||||||
|
WithdrawnState,
|
||||||
|
FALSE, /* has shape */
|
||||||
|
FALSE, /* has input shape */
|
||||||
|
META_COMP_EFFECT_NONE,
|
||||||
|
&attrs);
|
||||||
|
|
||||||
|
meta_error_trap_pop (display); /* pop the XSync()-reducing trap */
|
||||||
|
meta_display_ungrab (display);
|
||||||
|
|
||||||
|
/* XXX: Maybe this could be called in meta_window_new_shared() but
|
||||||
|
* before splitting the X11 specific code out it came after the
|
||||||
|
* meta_display_ungrab() and we wanted to minimize the risk of
|
||||||
|
* breaking something.
|
||||||
|
*/
|
||||||
|
display_notify_window (window->display, window);
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MetaWindow*
|
||||||
|
meta_window_new_with_attrs (MetaDisplay *display,
|
||||||
|
Window xwindow,
|
||||||
|
gboolean must_be_viewable,
|
||||||
|
MetaCompEffect effect,
|
||||||
|
XWindowAttributes *attrs)
|
||||||
|
{
|
||||||
|
MetaScreen *screen = NULL;
|
||||||
|
GSList *tmp;
|
||||||
|
gulong existing_wm_state;
|
||||||
|
MetaWindow *window;
|
||||||
|
gulong event_mask;
|
||||||
|
gboolean has_shape = FALSE;
|
||||||
|
gboolean has_input_shape = FALSE;
|
||||||
|
|
||||||
|
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
||||||
|
|
||||||
|
if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
|
||||||
|
{
|
||||||
|
meta_verbose ("Not managing no_focus_window 0x%lx\n",
|
||||||
|
xwindow);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = display->screens; tmp != NULL; tmp = tmp->next)
|
||||||
|
{
|
||||||
|
MetaScreen *scr = tmp->data;
|
||||||
|
|
||||||
|
if (scr->xroot == attrs->root)
|
||||||
|
{
|
||||||
|
screen = tmp->data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert (screen);
|
||||||
|
|
||||||
|
/* A black list of override redirect windows that we don't need to manage: */
|
||||||
|
if (attrs->override_redirect &&
|
||||||
|
(xwindow == screen->no_focus_window ||
|
||||||
|
xwindow == screen->flash_window ||
|
||||||
|
xwindow == screen->wm_sn_selection_window ||
|
||||||
|
attrs->class == InputOnly ||
|
||||||
|
/* any windows created via meta_create_offscreen_window: */
|
||||||
|
(attrs->x == -100 && attrs->y == -100
|
||||||
|
&& attrs->width == 1 && attrs->height == 1) ||
|
||||||
|
xwindow == screen->wm_cm_selection_window ||
|
||||||
|
xwindow == screen->guard_window ||
|
||||||
|
(display->compositor &&
|
||||||
|
xwindow == XCompositeGetOverlayWindow (display->xdisplay,
|
||||||
|
screen->xroot)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
meta_verbose ("Not managing our own windows\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maybe_filter_xwindow (display, xwindow, must_be_viewable, attrs))
|
||||||
|
{
|
||||||
|
meta_verbose ("Not managing filtered window\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab server */
|
||||||
|
meta_display_grab (display);
|
||||||
|
meta_error_trap_push (display); /* Push a trap over all of window
|
||||||
|
* creation, to reduce XSync() calls
|
||||||
|
*/
|
||||||
|
|
||||||
|
existing_wm_state = WithdrawnState;
|
||||||
|
if (must_be_viewable && attrs->map_state != IsViewable)
|
||||||
|
{
|
||||||
|
/* Only manage if WM_STATE is IconicState or NormalState */
|
||||||
|
gulong state;
|
||||||
|
|
||||||
|
/* WM_STATE isn't a cardinal, it's type WM_STATE, but is an int */
|
||||||
|
if (!(meta_prop_get_cardinal_with_atom_type (display, xwindow,
|
||||||
|
display->atom_WM_STATE,
|
||||||
|
display->atom_WM_STATE,
|
||||||
|
&state) &&
|
||||||
|
(state == IconicState || state == NormalState)))
|
||||||
|
{
|
||||||
|
meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow);
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
meta_display_ungrab (display);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
existing_wm_state = state;
|
||||||
|
meta_verbose ("WM_STATE of %lx = %s\n", xwindow,
|
||||||
|
wm_state_to_string (existing_wm_state));
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_error_trap_push_with_return (display);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XAddToSaveSet can only be called on windows created by a different
|
||||||
|
* client. with Mutter we want to be able to create manageable windows
|
||||||
|
* from within the process (such as a dummy desktop window), so we do not
|
||||||
|
* want this call failing to prevent the window from being managed -- wrap
|
||||||
|
* it in its own error trap (we use the _with_return() version here to
|
||||||
|
* ensure that XSync() is done on the pop, otherwise the error will not
|
||||||
|
* get caught).
|
||||||
|
*/
|
||||||
|
meta_error_trap_push_with_return (display);
|
||||||
|
XAddToSaveSet (display->xdisplay, xwindow);
|
||||||
|
meta_error_trap_pop_with_return (display);
|
||||||
|
|
||||||
|
event_mask = PropertyChangeMask | ColormapChangeMask;
|
||||||
|
if (attrs->override_redirect)
|
||||||
|
event_mask |= StructureNotifyMask;
|
||||||
|
|
||||||
|
/* If the window is from this client (a menu, say) we need to augment
|
||||||
|
* the event mask, not replace it. For windows from other clients,
|
||||||
|
* attrs->your_event_mask will be empty at this point.
|
||||||
|
*/
|
||||||
|
XSelectInput (display->xdisplay, xwindow, attrs->your_event_mask | event_mask);
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
||||||
|
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
||||||
|
|
||||||
|
meta_core_add_old_event_mask (display->xdisplay, xwindow, &mask);
|
||||||
|
|
||||||
|
XISetMask (mask.mask, XI_Enter);
|
||||||
|
XISetMask (mask.mask, XI_Leave);
|
||||||
|
XISetMask (mask.mask, XI_FocusIn);
|
||||||
|
XISetMask (mask.mask, XI_FocusOut);
|
||||||
|
|
||||||
|
XISelectEvents (display->xdisplay, xwindow, &mask, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SHAPE
|
||||||
|
if (META_DISPLAY_HAS_SHAPE (display))
|
||||||
|
{
|
||||||
|
int x_bounding, y_bounding, x_clip, y_clip;
|
||||||
|
unsigned w_bounding, h_bounding, w_clip, h_clip;
|
||||||
|
int bounding_shaped, clip_shaped;
|
||||||
|
XRectangle *input_rectangles;
|
||||||
|
int n_rects, ordering;
|
||||||
|
|
||||||
|
XShapeSelectInput (display->xdisplay, xwindow, ShapeNotifyMask);
|
||||||
|
|
||||||
|
XShapeQueryExtents (display->xdisplay, xwindow,
|
||||||
|
&bounding_shaped, &x_bounding, &y_bounding,
|
||||||
|
&w_bounding, &h_bounding,
|
||||||
|
&clip_shaped, &x_clip, &y_clip,
|
||||||
|
&w_clip, &h_clip);
|
||||||
|
|
||||||
|
has_shape = bounding_shaped != FALSE;
|
||||||
|
|
||||||
|
/* XXX: The x shape extension doesn't provide a way to only test if an
|
||||||
|
* input shape has been specified, so we have to query and throw away the
|
||||||
|
* rectangles. */
|
||||||
|
meta_error_trap_push (display);
|
||||||
|
input_rectangles = XShapeGetRectangles (display->xdisplay, xwindow,
|
||||||
|
ShapeInput, &n_rects, &ordering);
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
if (input_rectangles)
|
||||||
|
{
|
||||||
|
if (n_rects > 1 ||
|
||||||
|
(n_rects == 1 &&
|
||||||
|
(input_rectangles[0].x != x_bounding ||
|
||||||
|
input_rectangles[1].y != y_bounding ||
|
||||||
|
input_rectangles[2].width != w_bounding ||
|
||||||
|
input_rectangles[3].height != h_bounding)))
|
||||||
|
{
|
||||||
|
has_input_shape = TRUE;
|
||||||
|
}
|
||||||
|
XFree (input_rectangles);
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_SHAPES,
|
||||||
|
"Window has_shape = %d extents %d,%d %u x %u\n",
|
||||||
|
has_shape, x_bounding, y_bounding,
|
||||||
|
w_bounding, h_bounding);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Get rid of any borders */
|
||||||
|
if (attrs->border_width != 0)
|
||||||
|
XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
|
||||||
|
|
||||||
|
/* Get rid of weird gravities */
|
||||||
|
if (attrs->win_gravity != NorthWestGravity)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes set_attrs;
|
||||||
|
|
||||||
|
set_attrs.win_gravity = NorthWestGravity;
|
||||||
|
|
||||||
|
XChangeWindowAttributes (display->xdisplay,
|
||||||
|
xwindow,
|
||||||
|
CWWinGravity,
|
||||||
|
&set_attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta_error_trap_pop_with_return (display) != Success)
|
||||||
|
{
|
||||||
|
meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n",
|
||||||
|
xwindow);
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
meta_display_ungrab (display);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
window = meta_window_new_shared (display,
|
||||||
|
screen,
|
||||||
|
META_WINDOW_CLIENT_TYPE_X11,
|
||||||
|
NULL,
|
||||||
|
xwindow,
|
||||||
|
must_be_viewable,
|
||||||
|
existing_wm_state,
|
||||||
|
has_shape,
|
||||||
|
has_input_shape,
|
||||||
|
effect,
|
||||||
|
attrs);
|
||||||
|
|
||||||
|
meta_error_trap_pop (display); /* pop the XSync()-reducing trap */
|
||||||
|
meta_display_ungrab (display);
|
||||||
|
|
||||||
|
/* XXX: Maybe this could be called in meta_window_new_shared() but
|
||||||
|
* before splitting the X11 specific code out it came after the
|
||||||
|
* meta_display_ungrab() and we wanted to minimize the risk of
|
||||||
|
* breaking something.
|
||||||
|
*/
|
||||||
|
display_notify_window (display, window);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
@ -1914,9 +2038,10 @@ meta_window_unmanage (MetaWindow *window,
|
|||||||
meta_display_ungrab_window_buttons (window->display, window->xwindow);
|
meta_display_ungrab_window_buttons (window->display, window->xwindow);
|
||||||
meta_display_ungrab_focus_window_button (window->display, window);
|
meta_display_ungrab_focus_window_button (window->display, window);
|
||||||
|
|
||||||
|
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||||
|
{
|
||||||
meta_display_unregister_x_window (window->display, window->xwindow);
|
meta_display_unregister_x_window (window->display, window->xwindow);
|
||||||
|
|
||||||
|
|
||||||
meta_error_trap_push (window->display);
|
meta_error_trap_push (window->display);
|
||||||
|
|
||||||
/* Put back anything we messed up */
|
/* Put back anything we messed up */
|
||||||
@ -1956,6 +2081,7 @@ meta_window_unmanage (MetaWindow *window,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
meta_error_trap_pop (window->display);
|
meta_error_trap_pop (window->display);
|
||||||
|
}
|
||||||
|
|
||||||
meta_prefs_remove_listener (prefs_changed_callback, window);
|
meta_prefs_remove_listener (prefs_changed_callback, window);
|
||||||
|
|
||||||
@ -7697,7 +7823,7 @@ meta_window_update_opaque_region (MetaWindow *window)
|
|||||||
meta_XFree (region);
|
meta_XFree (region);
|
||||||
|
|
||||||
if (window->display->compositor)
|
if (window->display->compositor)
|
||||||
meta_compositor_window_shape_changed (window->display->compositor, window);
|
meta_compositor_window_x11_shape_changed (window->display->compositor, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -64,7 +64,7 @@ void meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
void meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
void meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
||||||
MetaScreen *screen);
|
MetaScreen *screen);
|
||||||
|
|
||||||
void meta_compositor_window_shape_changed (MetaCompositor *compositor,
|
void meta_compositor_window_x11_shape_changed (MetaCompositor *compositor,
|
||||||
MetaWindow *window);
|
MetaWindow *window);
|
||||||
|
|
||||||
gboolean meta_compositor_process_event (MetaCompositor *compositor,
|
gboolean meta_compositor_process_event (MetaCompositor *compositor,
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define META_TYPE_SHAPED_TEXTURE (meta_shaped_texture_get_type())
|
#define META_TYPE_SHAPED_TEXTURE (meta_shaped_texture_get_type())
|
||||||
@ -64,7 +69,13 @@ struct _MetaShapedTexture
|
|||||||
|
|
||||||
GType meta_shaped_texture_get_type (void) G_GNUC_CONST;
|
GType meta_shaped_texture_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
ClutterActor *meta_shaped_texture_new (void);
|
ClutterActor *meta_shaped_texture_new_with_xwindow (Window xwindow);
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
ClutterActor *meta_shaped_texture_new_with_wayland_surface (MetaWaylandSurface *surface);
|
||||||
|
void meta_shaped_texture_set_wayland_surface (MetaShapedTexture *stex,
|
||||||
|
MetaWaylandSurface *surface);
|
||||||
|
MetaWaylandSurface *meta_shaped_texture_get_wayland_surface (MetaShapedTexture *stex);
|
||||||
|
#endif
|
||||||
|
|
||||||
void meta_shaped_texture_set_create_mipmaps (MetaShapedTexture *stex,
|
void meta_shaped_texture_set_create_mipmaps (MetaShapedTexture *stex,
|
||||||
gboolean create_mipmaps);
|
gboolean create_mipmaps);
|
||||||
@ -77,6 +88,10 @@ void meta_shaped_texture_update_area (MetaShapedTexture *stex,
|
|||||||
|
|
||||||
void meta_shaped_texture_set_pixmap (MetaShapedTexture *stex,
|
void meta_shaped_texture_set_pixmap (MetaShapedTexture *stex,
|
||||||
Pixmap pixmap);
|
Pixmap pixmap);
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
void meta_shaped_texture_attach_wayland_buffer (MetaShapedTexture *stex,
|
||||||
|
MetaWaylandBuffer *buffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
CoglTexture * meta_shaped_texture_get_texture (MetaShapedTexture *stex);
|
CoglTexture * meta_shaped_texture_get_texture (MetaShapedTexture *stex);
|
||||||
|
|
||||||
|
171
src/wayland/meta-wayland-private.h
Normal file
171
src/wayland/meta-wayland-private.h
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2012 Intel Corporation
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_WAYLAND_PRIVATE_H
|
||||||
|
#define META_WAYLAND_PRIVATE_H
|
||||||
|
|
||||||
|
#include <wayland-server.h>
|
||||||
|
|
||||||
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <cairo.h>
|
||||||
|
|
||||||
|
#include "window-private.h"
|
||||||
|
|
||||||
|
typedef struct _MetaWaylandCompositor MetaWaylandCompositor;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct wl_resource *resource;
|
||||||
|
struct wl_signal destroy_signal;
|
||||||
|
struct wl_listener destroy_listener;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct wl_shm_buffer *shm_buffer;
|
||||||
|
struct wl_buffer *legacy_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t width, height;
|
||||||
|
uint32_t busy_count;
|
||||||
|
} MetaWaylandBuffer;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MetaWaylandBuffer *buffer;
|
||||||
|
struct wl_listener destroy_listener;
|
||||||
|
} MetaWaylandBufferReference;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct wl_resource *resource;
|
||||||
|
cairo_region_t *region;
|
||||||
|
} MetaWaylandRegion;
|
||||||
|
|
||||||
|
struct _MetaWaylandSurface
|
||||||
|
{
|
||||||
|
struct wl_resource *resource;
|
||||||
|
MetaWaylandCompositor *compositor;
|
||||||
|
guint32 xid;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
MetaWaylandBufferReference buffer_ref;
|
||||||
|
MetaWindow *window;
|
||||||
|
gboolean has_shell_surface;
|
||||||
|
|
||||||
|
/* All the pending state, that wl_surface.commit will apply. */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/* wl_surface.attach */
|
||||||
|
gboolean newly_attached;
|
||||||
|
MetaWaylandBuffer *buffer;
|
||||||
|
struct wl_listener buffer_destroy_listener;
|
||||||
|
int32_t sx;
|
||||||
|
int32_t sy;
|
||||||
|
|
||||||
|
/* wl_surface.damage */
|
||||||
|
cairo_region_t *damage;
|
||||||
|
|
||||||
|
/* wl_surface.frame */
|
||||||
|
struct wl_list frame_callback_list;
|
||||||
|
} pending;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef HAVE_META_WAYLAND_SURFACE_TYPE
|
||||||
|
typedef struct _MetaWaylandSurface MetaWaylandSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
MetaWaylandSurface *surface;
|
||||||
|
struct wl_resource *resource;
|
||||||
|
struct wl_listener surface_destroy_listener;
|
||||||
|
} MetaWaylandShellSurface;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
guint32 flags;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int refresh;
|
||||||
|
} MetaWaylandMode;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct wl_object wayland_output;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width_mm;
|
||||||
|
int height_mm;
|
||||||
|
/* XXX: with sliced stages we'd reference a CoglFramebuffer here. */
|
||||||
|
|
||||||
|
GList *modes;
|
||||||
|
} MetaWaylandOutput;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GSource source;
|
||||||
|
GPollFD pfd;
|
||||||
|
struct wl_display *display;
|
||||||
|
} WaylandEventSource;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct wl_list link;
|
||||||
|
|
||||||
|
/* Pointer back to the compositor */
|
||||||
|
MetaWaylandCompositor *compositor;
|
||||||
|
|
||||||
|
struct wl_resource *resource;
|
||||||
|
} MetaWaylandFrameCallback;
|
||||||
|
|
||||||
|
struct _MetaWaylandCompositor
|
||||||
|
{
|
||||||
|
struct wl_display *wayland_display;
|
||||||
|
struct wl_event_loop *wayland_loop;
|
||||||
|
GMainLoop *init_loop;
|
||||||
|
ClutterActor *stage;
|
||||||
|
GList *outputs;
|
||||||
|
GSource *wayland_event_source;
|
||||||
|
GList *surfaces;
|
||||||
|
struct wl_list frame_callbacks;
|
||||||
|
|
||||||
|
int xwayland_display_index;
|
||||||
|
char *xwayland_lockfile;
|
||||||
|
int xwayland_abstract_fd;
|
||||||
|
int xwayland_unix_fd;
|
||||||
|
pid_t xwayland_pid;
|
||||||
|
struct wl_client *xwayland_client;
|
||||||
|
struct wl_resource *xserver_resource;
|
||||||
|
GHashTable *window_surfaces;
|
||||||
|
};
|
||||||
|
|
||||||
|
void meta_wayland_init (void);
|
||||||
|
void meta_wayland_finalize (void);
|
||||||
|
|
||||||
|
/* We maintain a singleton MetaWaylandCompositor which can be got at via this
|
||||||
|
* API after meta_wayland_init() has been called. */
|
||||||
|
MetaWaylandCompositor *meta_wayland_compositor_get_default (void);
|
||||||
|
|
||||||
|
void meta_wayland_handle_sig_child (void);
|
||||||
|
|
||||||
|
MetaWaylandSurface *meta_wayland_lookup_surface_for_xid (guint32 xid);
|
||||||
|
|
||||||
|
#endif /* META_WAYLAND_PRIVATE_H */
|
1145
src/wayland/meta-wayland.c
Normal file
1145
src/wayland/meta-wayland.c
Normal file
File diff suppressed because it is too large
Load Diff
33
src/wayland/meta-xwayland-private.h
Normal file
33
src/wayland/meta-xwayland-private.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Intel Corporation
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_XWAYLAND_PRIVATE_H
|
||||||
|
#define META_XWAYLAND_PRIVATE_H
|
||||||
|
|
||||||
|
#include "meta-wayland-private.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_xwayland_start (MetaWaylandCompositor *compositor);
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_xwayland_stop (MetaWaylandCompositor *compositor);
|
||||||
|
|
||||||
|
#endif /* META_XWAYLAND_PRIVATE_H */
|
310
src/wayland/meta-xwayland.c
Normal file
310
src/wayland/meta-xwayland.c
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
/*
|
||||||
|
* X Wayland Support
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Intel Corporation
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "meta-xwayland-private.h"
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
|
||||||
|
static char *
|
||||||
|
create_lockfile (int display, int *display_out)
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
int size;
|
||||||
|
char pid[11];
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
char *end;
|
||||||
|
pid_t other;
|
||||||
|
|
||||||
|
filename = g_strdup_printf ("/tmp/.X%d-lock", display);
|
||||||
|
fd = open (filename, O_WRONLY | O_CLOEXEC | O_CREAT | O_EXCL, 0444);
|
||||||
|
|
||||||
|
if (fd < 0 && errno == EEXIST)
|
||||||
|
{
|
||||||
|
fd = open (filename, O_CLOEXEC, O_RDONLY);
|
||||||
|
if (fd < 0 || read (fd, pid, 11) != 11)
|
||||||
|
{
|
||||||
|
const char *msg = strerror (errno);
|
||||||
|
g_warning ("can't read lock file %s: %s", filename, msg);
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
|
/* ignore error and try the next display number */
|
||||||
|
display++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
close (fd);
|
||||||
|
|
||||||
|
other = strtol (pid, &end, 0);
|
||||||
|
if (end != pid + 10)
|
||||||
|
{
|
||||||
|
g_warning ("can't parse lock file %s", filename);
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
|
/* ignore error and try the next display number */
|
||||||
|
display++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kill (other, 0) < 0 && errno == ESRCH)
|
||||||
|
{
|
||||||
|
g_warning ("unlinking stale lock file %s", filename);
|
||||||
|
if (unlink (filename) < 0)
|
||||||
|
{
|
||||||
|
const char *msg = strerror (errno);
|
||||||
|
g_warning ("failed to unlink stale lock file: %s", msg);
|
||||||
|
display++;
|
||||||
|
}
|
||||||
|
g_free (filename);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
|
display++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (fd < 0)
|
||||||
|
{
|
||||||
|
const char *msg = strerror (errno);
|
||||||
|
g_warning ("failed to create lock file %s: %s", filename , msg);
|
||||||
|
g_free (filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (1);
|
||||||
|
|
||||||
|
/* Subtle detail: we use the pid of the wayland compositor, not the xserver
|
||||||
|
* in the lock file. */
|
||||||
|
size = snprintf (pid, 11, "%10d\n", getpid ());
|
||||||
|
if (size != 11 || write (fd, pid, 11) != 11)
|
||||||
|
{
|
||||||
|
unlink (filename);
|
||||||
|
close (fd);
|
||||||
|
g_warning ("failed to write pid to lock file %s", filename);
|
||||||
|
g_free (filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
|
||||||
|
*display_out = display;
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bind_to_abstract_socket (int display)
|
||||||
|
{
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
socklen_t size, name_size;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = socket (PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
addr.sun_family = AF_LOCAL;
|
||||||
|
name_size = snprintf (addr.sun_path, sizeof addr.sun_path,
|
||||||
|
"%c/tmp/.X11-unix/X%d", 0, display);
|
||||||
|
size = offsetof (struct sockaddr_un, sun_path) + name_size;
|
||||||
|
if (bind (fd, (struct sockaddr *) &addr, size) < 0)
|
||||||
|
{
|
||||||
|
g_warning ("failed to bind to @%s: %s\n",
|
||||||
|
addr.sun_path + 1, strerror (errno));
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen (fd, 1) < 0)
|
||||||
|
{
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bind_to_unix_socket (int display)
|
||||||
|
{
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
socklen_t size, name_size;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = socket (PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
addr.sun_family = AF_LOCAL;
|
||||||
|
name_size = snprintf (addr.sun_path, sizeof addr.sun_path,
|
||||||
|
"/tmp/.X11-unix/X%d", display) + 1;
|
||||||
|
size = offsetof (struct sockaddr_un, sun_path) + name_size;
|
||||||
|
unlink (addr.sun_path);
|
||||||
|
if (bind (fd, (struct sockaddr *) &addr, size) < 0)
|
||||||
|
{
|
||||||
|
char *msg = strerror (errno);
|
||||||
|
g_warning ("failed to bind to %s (%s)\n", addr.sun_path, msg);
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen (fd, 1) < 0) {
|
||||||
|
unlink (addr.sun_path);
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_xwayland_start (MetaWaylandCompositor *compositor)
|
||||||
|
{
|
||||||
|
int display = 0;
|
||||||
|
char *lockfile = NULL;
|
||||||
|
int sp[2];
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
lockfile = create_lockfile (display, &display);
|
||||||
|
if (!lockfile)
|
||||||
|
{
|
||||||
|
g_warning ("Failed to create an X lock file");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
compositor->xwayland_abstract_fd = bind_to_abstract_socket (display);
|
||||||
|
if (compositor->xwayland_abstract_fd < 0)
|
||||||
|
{
|
||||||
|
unlink (lockfile);
|
||||||
|
|
||||||
|
if (errno == EADDRINUSE)
|
||||||
|
{
|
||||||
|
display++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
compositor->xwayland_unix_fd = bind_to_unix_socket (display);
|
||||||
|
if (compositor->xwayland_abstract_fd < 0)
|
||||||
|
{
|
||||||
|
unlink (lockfile);
|
||||||
|
close (compositor->xwayland_abstract_fd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (1);
|
||||||
|
|
||||||
|
compositor->xwayland_display_index = display;
|
||||||
|
compositor->xwayland_lockfile = lockfile;
|
||||||
|
|
||||||
|
/* We want xwayland to be a wayland client so we make a socketpair to setup a
|
||||||
|
* wayland protocol connection. */
|
||||||
|
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sp) < 0)
|
||||||
|
{
|
||||||
|
g_warning ("socketpair failed\n");
|
||||||
|
unlink (lockfile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ((pid = fork()))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
char *fd_string;
|
||||||
|
char *display_name;
|
||||||
|
/* Make sure the client end of the socket pair doesn't get closed
|
||||||
|
* when we exec xwayland. */
|
||||||
|
int flags = fcntl (sp[1], F_GETFD);
|
||||||
|
if (flags != -1)
|
||||||
|
fcntl (sp[1], F_SETFD, flags & ~FD_CLOEXEC);
|
||||||
|
|
||||||
|
fd_string = g_strdup_printf ("%d", sp[1]);
|
||||||
|
setenv ("WAYLAND_SOCKET", fd_string, 1);
|
||||||
|
g_free (fd_string);
|
||||||
|
|
||||||
|
display_name = g_strdup_printf (":%d",
|
||||||
|
compositor->xwayland_display_index);
|
||||||
|
|
||||||
|
if (execl (XWAYLAND_PATH,
|
||||||
|
XWAYLAND_PATH,
|
||||||
|
display_name,
|
||||||
|
"-wayland",
|
||||||
|
"-rootless",
|
||||||
|
"-retro",
|
||||||
|
"-noreset",
|
||||||
|
/* FIXME: does it make sense to log to the filesystem by
|
||||||
|
* default? */
|
||||||
|
"-logfile", "/tmp/xwayland.log",
|
||||||
|
"-nolisten", "all",
|
||||||
|
NULL) < 0)
|
||||||
|
{
|
||||||
|
char *msg = strerror (errno);
|
||||||
|
g_warning ("xwayland exec failed: %s", msg);
|
||||||
|
}
|
||||||
|
exit (-1);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
g_message ("forked X server, pid %d\n", pid);
|
||||||
|
|
||||||
|
close (sp[1]);
|
||||||
|
compositor->xwayland_client =
|
||||||
|
wl_client_create (compositor->wayland_display, sp[0]);
|
||||||
|
|
||||||
|
compositor->xwayland_pid = pid;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -1:
|
||||||
|
g_error ("Failed to fork for xwayland server");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_xwayland_stop (MetaWaylandCompositor *compositor)
|
||||||
|
{
|
||||||
|
char path[256];
|
||||||
|
|
||||||
|
snprintf (path, sizeof path, "/tmp/.X%d-lock",
|
||||||
|
compositor->xwayland_display_index);
|
||||||
|
unlink (path);
|
||||||
|
snprintf (path, sizeof path, "/tmp/.X11-unix/X%d",
|
||||||
|
compositor->xwayland_display_index);
|
||||||
|
unlink (path);
|
||||||
|
|
||||||
|
unlink (compositor->xwayland_lockfile);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user