mirror of
https://github.com/brl/mutter.git
synced 2025-06-13 16:59:30 +00:00
stage-view: Add API to inhibit cursor overlay painting
This adds some plumbing to get the "default" paint flags for regular stage painting, where one either wants to paint the overlay, or not. If inhibited, the 'no-cursors' paint flag is used, otherwise the 'none' flag. This will be used to allow having a per stage view hw cursor state. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
@ -28,16 +28,10 @@
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "clutter/clutter-mutter.h"
|
||||
#include "backends/meta-stage-view.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define META_TYPE_STAGE_VIEW (meta_stage_view_get_type ())
|
||||
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaStageView,
|
||||
meta_stage_view,
|
||||
META, STAGE_VIEW,
|
||||
ClutterStageView)
|
||||
|
||||
struct _MetaStageViewClass
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ typedef struct _MetaStageViewPrivate
|
||||
guint notify_presented_handle_id;
|
||||
|
||||
CoglFrameClosure *frame_cb_closure;
|
||||
|
||||
int inhibit_cursor_overlay_count;
|
||||
} MetaStageViewPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaStageView, meta_stage_view,
|
||||
@ -130,6 +132,19 @@ meta_stage_view_constructed (GObject *object)
|
||||
G_OBJECT_CLASS (meta_stage_view_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static ClutterPaintFlag
|
||||
meta_stage_view_get_default_paint_flags (ClutterStageView *clutter_view)
|
||||
{
|
||||
MetaStageView *view = META_STAGE_VIEW (clutter_view);
|
||||
MetaStageViewPrivate *priv =
|
||||
meta_stage_view_get_instance_private (view);
|
||||
|
||||
if (priv->inhibit_cursor_overlay_count > 0)
|
||||
return CLUTTER_PAINT_FLAG_NO_CURSORS;
|
||||
else
|
||||
return CLUTTER_PAINT_FLAG_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_stage_view_init (MetaStageView *view)
|
||||
{
|
||||
@ -143,9 +158,13 @@ static void
|
||||
meta_stage_view_class_init (MetaStageViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterStageViewClass *view_class = CLUTTER_STAGE_VIEW_CLASS (klass);
|
||||
|
||||
object_class->constructed = meta_stage_view_constructed;
|
||||
object_class->dispose = meta_stage_view_dispose;
|
||||
|
||||
view_class->get_default_paint_flags =
|
||||
meta_stage_view_get_default_paint_flags;
|
||||
}
|
||||
|
||||
ClutterDamageHistory *
|
||||
@ -202,3 +221,23 @@ meta_stage_view_perform_fake_swap (MetaStageView *view,
|
||||
notify_presented_idle,
|
||||
closure, g_free);
|
||||
}
|
||||
|
||||
void
|
||||
meta_stage_view_inhibit_cursor_overlay (MetaStageView *view)
|
||||
{
|
||||
MetaStageViewPrivate *priv =
|
||||
meta_stage_view_get_instance_private (view);
|
||||
|
||||
priv->inhibit_cursor_overlay_count++;
|
||||
}
|
||||
|
||||
void
|
||||
meta_stage_view_uninhibit_cursor_overlay (MetaStageView *view)
|
||||
{
|
||||
MetaStageViewPrivate *priv =
|
||||
meta_stage_view_get_instance_private (view);
|
||||
|
||||
g_return_if_fail (priv->inhibit_cursor_overlay_count > 0);
|
||||
|
||||
priv->inhibit_cursor_overlay_count--;
|
||||
}
|
||||
|
33
src/backends/meta-stage-view.h
Normal file
33
src/backends/meta-stage-view.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Red Hat Inc.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef META_STAGE_VIEW_H
|
||||
#define META_STAGE_VIEW_H
|
||||
|
||||
#include "clutter/clutter-mutter.h"
|
||||
|
||||
#define META_TYPE_STAGE_VIEW (meta_stage_view_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaStageView,
|
||||
meta_stage_view,
|
||||
META, STAGE_VIEW,
|
||||
ClutterStageView)
|
||||
|
||||
void meta_stage_view_inhibit_cursor_overlay (MetaStageView *view);
|
||||
|
||||
void meta_stage_view_uninhibit_cursor_overlay (MetaStageView *view);
|
||||
|
||||
#endif /* META_STAGE_VIEW_H */
|
@ -379,13 +379,33 @@ queue_redraw_clutter_rect (MetaStage *stage,
|
||||
.width = ceilf (rect->size.width),
|
||||
.height = ceilf (rect->size.height)
|
||||
};
|
||||
GList *l;
|
||||
|
||||
/* 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;
|
||||
|
||||
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
|
||||
for (l = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
|
||||
l;
|
||||
l = l->next)
|
||||
{
|
||||
ClutterStageView *view = l->data;
|
||||
cairo_rectangle_int_t view_layout;
|
||||
cairo_rectangle_int_t view_clip;
|
||||
|
||||
if (clutter_stage_view_get_default_paint_flags (view) &
|
||||
CLUTTER_PAINT_FLAG_NO_CURSORS)
|
||||
continue;
|
||||
|
||||
clutter_stage_view_get_layout (view, &view_layout);
|
||||
|
||||
if (meta_rectangle_intersect (&clip, &view_layout, &view_clip))
|
||||
{
|
||||
clutter_stage_view_add_redraw_clip (view, &view_clip);
|
||||
clutter_stage_view_schedule_update (view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user