2012-01-18 23:03:23 +00:00
|
|
|
/*
|
2014-04-22 18:46:57 +00:00
|
|
|
* Copyright (C) 2014 Red Hat
|
2012-01-18 23:03:23 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2014-04-22 18:46:57 +00:00
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Jasper St. Pierre <jstpierre@mecheye.net>
|
2012-01-18 23:03:23 +00:00
|
|
|
*/
|
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "config.h"
|
2012-01-18 23:03:23 +00:00
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "backends/meta-stage-private.h"
|
2014-04-22 00:49:38 +00:00
|
|
|
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-27 03:09:24 +00:00
|
|
|
#include "backends/meta-backend-private.h"
|
2020-07-29 09:43:44 +00:00
|
|
|
#include "backends/meta-cursor-tracker-private.h"
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-27 03:09:24 +00:00
|
|
|
#include "clutter/clutter-mutter.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "meta/meta-backend.h"
|
|
|
|
#include "meta/meta-monitor-manager.h"
|
|
|
|
#include "meta/util.h"
|
2012-01-18 23:03:23 +00:00
|
|
|
|
2019-06-18 00:43:05 +00:00
|
|
|
#define N_WATCH_MODES 4
|
|
|
|
|
2018-12-12 10:39:18 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ACTORS_PAINTED,
|
|
|
|
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS];
|
|
|
|
|
2019-06-18 00:43:05 +00:00
|
|
|
struct _MetaStageWatch
|
|
|
|
{
|
|
|
|
ClutterStageView *view;
|
|
|
|
MetaStageWatchFunc callback;
|
|
|
|
gpointer user_data;
|
|
|
|
};
|
|
|
|
|
2018-12-12 10:39:00 +00:00
|
|
|
struct _MetaOverlay
|
|
|
|
{
|
2020-07-29 08:32:58 +00:00
|
|
|
MetaStage *stage;
|
|
|
|
|
|
|
|
gboolean is_visible;
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2014-08-21 18:47:39 +00:00
|
|
|
CoglPipeline *pipeline;
|
|
|
|
CoglTexture *texture;
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2019-02-20 15:23:04 +00:00
|
|
|
graphene_rect_t current_rect;
|
|
|
|
graphene_rect_t previous_rect;
|
2014-04-22 19:06:42 +00:00
|
|
|
gboolean previous_is_valid;
|
2016-05-02 11:49:13 +00:00
|
|
|
};
|
2014-08-21 18:47:39 +00:00
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
struct _MetaStage
|
|
|
|
{
|
|
|
|
ClutterStage parent;
|
|
|
|
|
2020-07-29 08:11:08 +00:00
|
|
|
MetaBackend *backend;
|
|
|
|
|
2019-06-18 00:43:05 +00:00
|
|
|
GPtrArray *watchers[N_WATCH_MODES];
|
|
|
|
|
2016-05-02 11:49:13 +00:00
|
|
|
GList *overlays;
|
2015-03-24 16:40:10 +00:00
|
|
|
gboolean is_active;
|
2014-04-22 19:06:42 +00:00
|
|
|
};
|
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
G_DEFINE_TYPE (MetaStage, meta_stage, CLUTTER_TYPE_STAGE);
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2016-05-02 11:49:13 +00:00
|
|
|
static MetaOverlay *
|
2020-07-29 08:32:58 +00:00
|
|
|
meta_overlay_new (MetaStage *stage)
|
2014-04-22 19:06:42 +00:00
|
|
|
{
|
2020-07-29 08:32:58 +00:00
|
|
|
ClutterBackend *clutter_backend =
|
|
|
|
meta_backend_get_clutter_backend (stage->backend);
|
|
|
|
CoglContext *ctx = clutter_backend_get_cogl_context (clutter_backend);
|
2016-05-02 11:49:13 +00:00
|
|
|
MetaOverlay *overlay;
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2020-10-19 17:57:57 +00:00
|
|
|
overlay = g_new0 (MetaOverlay, 1);
|
2020-07-29 08:32:58 +00:00
|
|
|
overlay->stage = stage;
|
2014-08-21 18:47:39 +00:00
|
|
|
overlay->pipeline = cogl_pipeline_new (ctx);
|
2016-05-02 11:49:13 +00:00
|
|
|
|
|
|
|
return overlay;
|
2014-04-22 19:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-21 18:47:39 +00:00
|
|
|
meta_overlay_free (MetaOverlay *overlay)
|
2014-04-22 19:06:42 +00:00
|
|
|
{
|
2014-08-21 18:47:39 +00:00
|
|
|
if (overlay->pipeline)
|
|
|
|
cogl_object_unref (overlay->pipeline);
|
2016-05-02 11:49:13 +00:00
|
|
|
|
2020-10-19 17:57:57 +00:00
|
|
|
g_free (overlay);
|
2014-04-22 19:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-02-20 15:23:04 +00:00
|
|
|
meta_overlay_set (MetaOverlay *overlay,
|
|
|
|
CoglTexture *texture,
|
|
|
|
graphene_rect_t *rect)
|
2014-04-22 19:06:42 +00:00
|
|
|
{
|
2014-08-21 18:47:39 +00:00
|
|
|
if (overlay->texture != texture)
|
|
|
|
{
|
|
|
|
overlay->texture = texture;
|
|
|
|
|
|
|
|
if (texture)
|
2020-07-29 08:32:58 +00:00
|
|
|
cogl_pipeline_set_layer_texture (overlay->pipeline, 0, texture);
|
2014-08-21 18:47:39 +00:00
|
|
|
else
|
2020-07-29 08:32:58 +00:00
|
|
|
cogl_pipeline_set_layer_texture (overlay->pipeline, 0, NULL);
|
2014-08-21 18:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
overlay->current_rect = *rect;
|
|
|
|
}
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2014-08-21 18:47:39 +00:00
|
|
|
static void
|
2019-11-22 10:41:04 +00:00
|
|
|
meta_overlay_paint (MetaOverlay *overlay,
|
|
|
|
ClutterPaintContext *paint_context)
|
2014-08-21 18:47:39 +00:00
|
|
|
{
|
2019-11-22 10:41:04 +00:00
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
|
2020-07-29 08:32:58 +00:00
|
|
|
if (!overlay->texture)
|
2014-04-22 19:06:42 +00:00
|
|
|
return;
|
|
|
|
|
2020-07-29 09:43:44 +00:00
|
|
|
if (!overlay->is_visible &&
|
|
|
|
!(clutter_paint_context_get_paint_flags (paint_context) &
|
|
|
|
CLUTTER_PAINT_FLAG_FORCE_CURSORS))
|
2020-07-29 08:32:58 +00:00
|
|
|
return;
|
2014-08-21 22:03:03 +00:00
|
|
|
|
2019-11-22 10:41:04 +00:00
|
|
|
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
|
|
|
|
cogl_framebuffer_draw_rectangle (framebuffer,
|
2014-08-21 18:47:39 +00:00
|
|
|
overlay->pipeline,
|
2017-06-08 14:13:16 +00:00
|
|
|
overlay->current_rect.origin.x,
|
|
|
|
overlay->current_rect.origin.y,
|
|
|
|
(overlay->current_rect.origin.x +
|
|
|
|
overlay->current_rect.size.width),
|
|
|
|
(overlay->current_rect.origin.y +
|
|
|
|
overlay->current_rect.size.height));
|
2014-08-21 18:47:39 +00:00
|
|
|
|
2019-02-20 15:23:04 +00:00
|
|
|
if (!graphene_rect_equal (&overlay->previous_rect, &overlay->current_rect))
|
2019-02-28 22:02:59 +00:00
|
|
|
{
|
|
|
|
overlay->previous_rect = overlay->current_rect;
|
|
|
|
overlay->previous_is_valid = TRUE;
|
|
|
|
}
|
2014-08-21 18:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_stage_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaStage *stage = META_STAGE (object);
|
2018-07-12 12:59:18 +00:00
|
|
|
GList *l;
|
2019-06-18 00:43:05 +00:00
|
|
|
int i;
|
2014-08-21 18:47:39 +00:00
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
l = stage->overlays;
|
2016-05-02 11:49:13 +00:00
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
meta_overlay_free (l->data);
|
|
|
|
l = g_list_delete_link (l, l);
|
|
|
|
}
|
|
|
|
|
2019-06-18 00:43:05 +00:00
|
|
|
for (i = 0; i < N_WATCH_MODES; i++)
|
|
|
|
g_clear_pointer (&stage->watchers[i], g_ptr_array_unref);
|
|
|
|
|
2016-05-02 11:49:13 +00:00
|
|
|
G_OBJECT_CLASS (meta_stage_parent_class)->finalize (object);
|
2014-04-22 19:06:42 +00:00
|
|
|
}
|
2012-01-18 23:03:23 +00:00
|
|
|
|
2019-06-18 00:43:05 +00:00
|
|
|
static void
|
|
|
|
notify_watchers_for_mode (MetaStage *stage,
|
|
|
|
ClutterStageView *view,
|
2020-04-20 20:24:55 +00:00
|
|
|
ClutterPaintContext *paint_context,
|
2019-06-18 00:43:05 +00:00
|
|
|
MetaStageWatchPhase watch_phase)
|
|
|
|
{
|
|
|
|
GPtrArray *watchers;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
watchers = stage->watchers[watch_phase];
|
|
|
|
|
|
|
|
for (i = 0; i < watchers->len; i++)
|
|
|
|
{
|
|
|
|
MetaStageWatch *watch = g_ptr_array_index (watchers, i);
|
|
|
|
|
|
|
|
if (watch->view && view != watch->view)
|
|
|
|
continue;
|
|
|
|
|
2020-04-20 20:24:55 +00:00
|
|
|
watch->callback (stage, view, paint_context, watch->user_data);
|
2019-06-18 00:43:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 13:30:06 +00:00
|
|
|
static void
|
|
|
|
meta_stage_before_paint (ClutterStage *stage,
|
|
|
|
ClutterStageView *view)
|
|
|
|
{
|
|
|
|
MetaStage *meta_stage = META_STAGE (stage);
|
|
|
|
|
|
|
|
notify_watchers_for_mode (meta_stage, view, NULL,
|
|
|
|
META_STAGE_WATCH_BEFORE_PAINT);
|
|
|
|
}
|
|
|
|
|
2012-01-18 23:03:23 +00:00
|
|
|
static void
|
2019-11-13 21:21:58 +00:00
|
|
|
meta_stage_paint (ClutterActor *actor,
|
|
|
|
ClutterPaintContext *paint_context)
|
2012-01-18 23:03:23 +00:00
|
|
|
{
|
2014-04-22 19:06:42 +00:00
|
|
|
MetaStage *stage = META_STAGE (actor);
|
2020-04-20 20:24:55 +00:00
|
|
|
ClutterStageView *view;
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2019-11-13 21:21:58 +00:00
|
|
|
CLUTTER_ACTOR_CLASS (meta_stage_parent_class)->paint (actor, paint_context);
|
2012-01-18 23:03:23 +00:00
|
|
|
|
2020-04-20 20:24:55 +00:00
|
|
|
view = clutter_paint_context_get_stage_view (paint_context);
|
2020-04-20 20:39:08 +00:00
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
notify_watchers_for_mode (stage, view, paint_context,
|
|
|
|
META_STAGE_WATCH_AFTER_ACTOR_PAINT);
|
|
|
|
}
|
2019-06-18 00:43:05 +00:00
|
|
|
|
2018-12-12 10:39:18 +00:00
|
|
|
g_signal_emit (stage, signals[ACTORS_PAINTED], 0);
|
|
|
|
|
2020-07-29 09:43:44 +00:00
|
|
|
if ((clutter_paint_context_get_paint_flags (paint_context) &
|
|
|
|
CLUTTER_PAINT_FLAG_FORCE_CURSORS))
|
|
|
|
{
|
|
|
|
MetaCursorTracker *cursor_tracker =
|
|
|
|
meta_backend_get_cursor_tracker (stage->backend);
|
|
|
|
|
|
|
|
meta_cursor_tracker_track_position (cursor_tracker);
|
|
|
|
}
|
|
|
|
|
2020-04-20 20:41:12 +00:00
|
|
|
if (!(clutter_paint_context_get_paint_flags (paint_context) &
|
|
|
|
CLUTTER_PAINT_FLAG_NO_CURSORS))
|
2020-07-29 08:12:13 +00:00
|
|
|
g_list_foreach (stage->overlays, (GFunc) meta_overlay_paint, paint_context);
|
2019-06-18 00:43:05 +00:00
|
|
|
|
2020-07-29 09:43:44 +00:00
|
|
|
if ((clutter_paint_context_get_paint_flags (paint_context) &
|
|
|
|
CLUTTER_PAINT_FLAG_FORCE_CURSORS))
|
|
|
|
{
|
|
|
|
MetaCursorTracker *cursor_tracker =
|
|
|
|
meta_backend_get_cursor_tracker (stage->backend);
|
|
|
|
|
|
|
|
meta_cursor_tracker_untrack_position (cursor_tracker);
|
|
|
|
}
|
|
|
|
|
2020-04-20 20:39:08 +00:00
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
notify_watchers_for_mode (stage, view, paint_context,
|
|
|
|
META_STAGE_WATCH_AFTER_OVERLAY_PAINT);
|
|
|
|
}
|
2019-06-18 00:43:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-06 08:00:12 +00:00
|
|
|
meta_stage_paint_view (ClutterStage *stage,
|
|
|
|
ClutterStageView *view,
|
|
|
|
const cairo_region_t *redraw_clip)
|
2019-06-18 00:43:05 +00:00
|
|
|
{
|
|
|
|
MetaStage *meta_stage = META_STAGE (stage);
|
|
|
|
|
2020-02-06 08:00:12 +00:00
|
|
|
CLUTTER_STAGE_CLASS (meta_stage_parent_class)->paint_view (stage, view,
|
|
|
|
redraw_clip);
|
2019-06-18 00:43:05 +00:00
|
|
|
|
2020-04-20 20:24:55 +00:00
|
|
|
notify_watchers_for_mode (meta_stage, view, NULL,
|
|
|
|
META_STAGE_WATCH_AFTER_PAINT);
|
2012-01-18 23:03:23 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 16:40:10 +00:00
|
|
|
static void
|
|
|
|
meta_stage_activate (ClutterStage *actor)
|
|
|
|
{
|
|
|
|
MetaStage *stage = META_STAGE (actor);
|
|
|
|
|
|
|
|
CLUTTER_STAGE_CLASS (meta_stage_parent_class)->activate (actor);
|
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
stage->is_active = TRUE;
|
2015-03-24 16:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_stage_deactivate (ClutterStage *actor)
|
|
|
|
{
|
|
|
|
MetaStage *stage = META_STAGE (actor);
|
|
|
|
|
|
|
|
CLUTTER_STAGE_CLASS (meta_stage_parent_class)->deactivate (actor);
|
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
stage->is_active = FALSE;
|
2015-03-24 16:40:10 +00:00
|
|
|
}
|
|
|
|
|
2019-03-25 09:24:46 +00:00
|
|
|
static void
|
|
|
|
on_power_save_changed (MetaMonitorManager *monitor_manager,
|
|
|
|
MetaStage *stage)
|
|
|
|
{
|
|
|
|
if (meta_monitor_manager_get_power_save_mode (monitor_manager) ==
|
|
|
|
META_POWER_SAVE_ON)
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
|
|
|
}
|
|
|
|
|
2012-01-18 23:03:23 +00:00
|
|
|
static void
|
2014-04-22 18:46:57 +00:00
|
|
|
meta_stage_class_init (MetaStageClass *klass)
|
2012-01-18 23:03:23 +00:00
|
|
|
{
|
2015-03-24 16:40:10 +00:00
|
|
|
ClutterStageClass *stage_class = (ClutterStageClass *) klass;
|
2012-01-18 23:03:23 +00:00
|
|
|
ClutterActorClass *actor_class = (ClutterActorClass *) klass;
|
2014-04-22 19:06:42 +00:00
|
|
|
GObjectClass *object_class = (GObjectClass *) klass;
|
|
|
|
|
|
|
|
object_class->finalize = meta_stage_finalize;
|
2012-01-18 23:03:23 +00:00
|
|
|
|
2014-04-22 18:46:57 +00:00
|
|
|
actor_class->paint = meta_stage_paint;
|
2015-03-24 16:40:10 +00:00
|
|
|
|
|
|
|
stage_class->activate = meta_stage_activate;
|
|
|
|
stage_class->deactivate = meta_stage_deactivate;
|
2020-08-31 13:30:06 +00:00
|
|
|
stage_class->before_paint = meta_stage_before_paint;
|
2019-06-18 00:43:05 +00:00
|
|
|
stage_class->paint_view = meta_stage_paint_view;
|
2018-12-12 10:39:18 +00:00
|
|
|
|
|
|
|
signals[ACTORS_PAINTED] = g_signal_new ("actors-painted",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
2012-01-18 23:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-04-22 19:06:42 +00:00
|
|
|
meta_stage_init (MetaStage *stage)
|
2012-01-18 23:03:23 +00:00
|
|
|
{
|
2019-06-18 00:43:05 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < N_WATCH_MODES; i++)
|
|
|
|
stage->watchers[i] = g_ptr_array_new_with_free_func (g_free);
|
2012-01-18 23:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ClutterActor *
|
2019-03-25 09:24:46 +00:00
|
|
|
meta_stage_new (MetaBackend *backend)
|
2012-01-18 23:03:23 +00:00
|
|
|
{
|
2019-03-25 09:24:46 +00:00
|
|
|
MetaStage *stage;
|
|
|
|
MetaMonitorManager *monitor_manager;
|
|
|
|
|
2020-04-03 11:56:43 +00:00
|
|
|
stage = g_object_new (META_TYPE_STAGE, NULL);
|
2020-07-29 08:11:08 +00:00
|
|
|
stage->backend = backend;
|
2019-03-25 09:24:46 +00:00
|
|
|
|
|
|
|
monitor_manager = meta_backend_get_monitor_manager (backend);
|
|
|
|
g_signal_connect (monitor_manager, "power-save-mode-changed",
|
|
|
|
G_CALLBACK (on_power_save_changed),
|
|
|
|
stage);
|
|
|
|
|
|
|
|
return CLUTTER_ACTOR (stage);
|
2012-01-18 23:03:23 +00:00
|
|
|
}
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2019-02-28 21:48:46 +00:00
|
|
|
static void
|
2019-02-20 15:23:04 +00:00
|
|
|
queue_redraw_clutter_rect (MetaStage *stage,
|
|
|
|
MetaOverlay *overlay,
|
|
|
|
graphene_rect_t *rect)
|
2019-02-28 21:48:46 +00:00
|
|
|
{
|
|
|
|
cairo_rectangle_int_t clip = {
|
|
|
|
.x = floorf (rect->origin.x),
|
|
|
|
.y = floorf (rect->origin.y),
|
|
|
|
.width = ceilf (rect->size.width),
|
|
|
|
.height = ceilf (rect->size.height)
|
|
|
|
};
|
|
|
|
|
2019-02-28 21:50:50 +00:00
|
|
|
/* Since we're flooring the coordinates, we need to enlarge the clip by the
|
|
|
|
* difference between the actual coordinate and the floored value */
|
|
|
|
clip.width += ceilf (rect->origin.x - clip.x) * 2;
|
|
|
|
clip.height += ceilf (rect->origin.y - clip.y) * 2;
|
|
|
|
|
2019-02-28 21:48:46 +00:00
|
|
|
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
|
|
|
|
}
|
|
|
|
|
2014-04-22 19:06:42 +00:00
|
|
|
static void
|
2014-08-21 18:47:39 +00:00
|
|
|
queue_redraw_for_overlay (MetaStage *stage,
|
|
|
|
MetaOverlay *overlay)
|
2014-04-22 19:06:42 +00:00
|
|
|
{
|
2014-08-21 18:47:39 +00:00
|
|
|
/* Clear the location the overlay was at before, if we need to. */
|
|
|
|
if (overlay->previous_is_valid)
|
2014-04-22 19:06:42 +00:00
|
|
|
{
|
2019-02-28 21:48:46 +00:00
|
|
|
queue_redraw_clutter_rect (stage, overlay, &overlay->previous_rect);
|
2014-08-21 18:47:39 +00:00
|
|
|
overlay->previous_is_valid = FALSE;
|
2014-04-22 19:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-21 18:47:39 +00:00
|
|
|
/* Draw the overlay at the new position */
|
2020-07-29 08:32:58 +00:00
|
|
|
if (overlay->is_visible && overlay->texture)
|
2019-02-28 21:48:46 +00:00
|
|
|
queue_redraw_clutter_rect (stage, overlay, &overlay->current_rect);
|
2014-04-22 19:06:42 +00:00
|
|
|
}
|
|
|
|
|
2016-05-02 11:49:13 +00:00
|
|
|
MetaOverlay *
|
|
|
|
meta_stage_create_cursor_overlay (MetaStage *stage)
|
|
|
|
{
|
|
|
|
MetaOverlay *overlay;
|
|
|
|
|
2020-07-29 08:32:58 +00:00
|
|
|
overlay = meta_overlay_new (stage);
|
2018-07-12 12:59:18 +00:00
|
|
|
stage->overlays = g_list_prepend (stage->overlays, overlay);
|
2016-05-02 11:49:13 +00:00
|
|
|
|
|
|
|
return overlay;
|
|
|
|
}
|
|
|
|
|
2014-04-22 19:06:42 +00:00
|
|
|
void
|
2016-05-02 11:49:13 +00:00
|
|
|
meta_stage_remove_cursor_overlay (MetaStage *stage,
|
|
|
|
MetaOverlay *overlay)
|
2014-04-22 19:06:42 +00:00
|
|
|
{
|
2016-05-02 11:49:13 +00:00
|
|
|
GList *link;
|
2014-04-22 19:06:42 +00:00
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
link = g_list_find (stage->overlays, overlay);
|
2016-05-02 11:49:13 +00:00
|
|
|
if (!link)
|
|
|
|
return;
|
|
|
|
|
2018-07-12 12:59:18 +00:00
|
|
|
stage->overlays = g_list_delete_link (stage->overlays, link);
|
2016-05-02 11:49:13 +00:00
|
|
|
meta_overlay_free (overlay);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-02-20 15:23:04 +00:00
|
|
|
meta_stage_update_cursor_overlay (MetaStage *stage,
|
|
|
|
MetaOverlay *overlay,
|
|
|
|
CoglTexture *texture,
|
|
|
|
graphene_rect_t *rect)
|
2016-05-02 11:49:13 +00:00
|
|
|
{
|
|
|
|
meta_overlay_set (overlay, texture, rect);
|
|
|
|
queue_redraw_for_overlay (stage, overlay);
|
2014-04-22 19:06:42 +00:00
|
|
|
}
|
2015-03-24 16:40:10 +00:00
|
|
|
|
2020-07-29 08:32:58 +00:00
|
|
|
void
|
|
|
|
meta_overlay_set_visible (MetaOverlay *overlay,
|
|
|
|
gboolean is_visible)
|
|
|
|
{
|
|
|
|
if (overlay->is_visible == is_visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
overlay->is_visible = is_visible;
|
|
|
|
queue_redraw_for_overlay (overlay->stage, overlay);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_overlay_is_visible (MetaOverlay *overlay)
|
|
|
|
{
|
|
|
|
return overlay->is_visible;
|
|
|
|
}
|
|
|
|
|
2015-03-24 16:40:10 +00:00
|
|
|
void
|
|
|
|
meta_stage_set_active (MetaStage *stage,
|
|
|
|
gboolean is_active)
|
|
|
|
{
|
2018-07-12 12:59:18 +00:00
|
|
|
if (stage->is_active == is_active)
|
2015-03-24 16:40:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (is_active)
|
2020-12-08 02:38:14 +00:00
|
|
|
g_signal_emit_by_name (CLUTTER_STAGE (stage), "activate");
|
|
|
|
else
|
|
|
|
g_signal_emit_by_name (CLUTTER_STAGE (stage), "deactivate");
|
2015-03-24 16:40:10 +00:00
|
|
|
}
|
2019-06-18 00:43:05 +00:00
|
|
|
|
|
|
|
MetaStageWatch *
|
|
|
|
meta_stage_watch_view (MetaStage *stage,
|
|
|
|
ClutterStageView *view,
|
|
|
|
MetaStageWatchPhase watch_phase,
|
|
|
|
MetaStageWatchFunc callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaStageWatch *watch;
|
|
|
|
GPtrArray *watchers;
|
|
|
|
|
|
|
|
watch = g_new0 (MetaStageWatch, 1);
|
|
|
|
watch->view = view;
|
|
|
|
watch->callback = callback;
|
|
|
|
watch->user_data = user_data;
|
|
|
|
|
|
|
|
watchers = stage->watchers[watch_phase];
|
|
|
|
g_ptr_array_add (watchers, watch);
|
|
|
|
|
|
|
|
return watch;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_stage_remove_watch (MetaStage *stage,
|
|
|
|
MetaStageWatch *watch)
|
|
|
|
{
|
|
|
|
GPtrArray *watchers;
|
|
|
|
gboolean removed = FALSE;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < N_WATCH_MODES; i++)
|
|
|
|
{
|
|
|
|
watchers = stage->watchers[i];
|
|
|
|
removed = g_ptr_array_remove_fast (watchers, watch);
|
|
|
|
|
|
|
|
if (removed)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (removed);
|
|
|
|
}
|