2013-08-30 16:03:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef META_WAYLAND_SURFACE_H
|
|
|
|
#define META_WAYLAND_SURFACE_H
|
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include <cairo.h>
|
|
|
|
#include <glib.h>
|
2013-08-30 16:03:30 +00:00
|
|
|
#include <wayland-server.h>
|
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
2015-07-08 08:14:00 +00:00
|
|
|
#include "backends/meta-monitor-manager-private.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "clutter/clutter.h"
|
2018-11-26 18:40:57 +00:00
|
|
|
#include "compositor/meta-shaped-texture-private.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "compositor/meta-surface-actor.h"
|
|
|
|
#include "meta/meta-cursor-tracker.h"
|
|
|
|
#include "wayland/meta-wayland-pointer-constraints.h"
|
|
|
|
#include "wayland/meta-wayland-types.h"
|
2015-07-08 08:14:00 +00:00
|
|
|
|
2015-07-08 03:21:23 +00:00
|
|
|
#define META_TYPE_WAYLAND_SURFACE (meta_wayland_surface_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (MetaWaylandSurface,
|
|
|
|
meta_wayland_surface,
|
|
|
|
META, WAYLAND_SURFACE,
|
|
|
|
GObject);
|
|
|
|
|
2015-07-08 08:14:00 +00:00
|
|
|
#define META_TYPE_WAYLAND_SURFACE_ROLE (meta_wayland_surface_role_get_type ())
|
|
|
|
G_DECLARE_DERIVABLE_TYPE (MetaWaylandSurfaceRole, meta_wayland_surface_role,
|
|
|
|
META, WAYLAND_SURFACE_ROLE, GObject);
|
|
|
|
|
2019-03-13 12:27:25 +00:00
|
|
|
#define META_TYPE_WAYLAND_SURFACE_STATE (meta_wayland_surface_state_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceState,
|
|
|
|
meta_wayland_surface_state,
|
|
|
|
META, WAYLAND_SURFACE_STATE,
|
|
|
|
GObject)
|
2015-12-14 09:13:35 +00:00
|
|
|
|
2015-07-08 08:14:00 +00:00
|
|
|
struct _MetaWaylandSurfaceRoleClass
|
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
|
|
|
void (*assigned) (MetaWaylandSurfaceRole *surface_role);
|
2022-11-01 15:43:03 +00:00
|
|
|
void (*commit_state) (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandTransaction *transaction,
|
|
|
|
MetaWaylandSurfaceState *pending);
|
2019-07-11 09:20:44 +00:00
|
|
|
void (*pre_apply_state) (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending);
|
|
|
|
void (*apply_state) (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending);
|
2020-06-08 07:13:44 +00:00
|
|
|
void (*post_apply_state) (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending);
|
2016-11-25 06:38:28 +00:00
|
|
|
gboolean (*is_on_logical_monitor) (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaLogicalMonitor *logical_monitor);
|
2016-01-14 09:43:47 +00:00
|
|
|
MetaWaylandSurface * (*get_toplevel) (MetaWaylandSurfaceRole *surface_role);
|
2021-06-05 14:46:56 +00:00
|
|
|
gboolean (*is_synchronized) (MetaWaylandSurfaceRole *surface_role);
|
2019-10-08 21:32:37 +00:00
|
|
|
void (*notify_subsurface_state_changed) (MetaWaylandSurfaceRole *surface_role);
|
2019-10-09 07:47:23 +00:00
|
|
|
void (*get_relative_coordinates) (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
float abs_x,
|
|
|
|
float abs_y,
|
|
|
|
float *out_sx,
|
|
|
|
float *out_sy);
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 07:57:40 +00:00
|
|
|
MetaWindow * (*get_window) (MetaWaylandSurfaceRole *surface_role);
|
2015-07-08 08:14:00 +00:00
|
|
|
};
|
|
|
|
|
2019-03-13 12:27:25 +00:00
|
|
|
struct _MetaWaylandSurfaceState
|
2013-08-30 16:03:30 +00:00
|
|
|
{
|
2015-12-14 09:13:35 +00:00
|
|
|
GObject parent;
|
|
|
|
|
2013-08-30 16:03:30 +00:00
|
|
|
/* wl_surface.attach */
|
|
|
|
gboolean newly_attached;
|
|
|
|
MetaWaylandBuffer *buffer;
|
2022-07-13 15:10:05 +00:00
|
|
|
CoglTexture *texture;
|
2016-03-15 04:46:06 +00:00
|
|
|
gulong buffer_destroy_handler_id;
|
2013-09-03 10:00:29 +00:00
|
|
|
int32_t dx;
|
|
|
|
int32_t dy;
|
2013-08-30 16:03:30 +00:00
|
|
|
|
2014-04-26 08:27:34 +00:00
|
|
|
int scale;
|
|
|
|
|
2013-08-30 16:03:30 +00:00
|
|
|
/* wl_surface.damage */
|
2017-06-05 12:08:04 +00:00
|
|
|
cairo_region_t *surface_damage;
|
|
|
|
/* wl_surface.damage_buffer */
|
|
|
|
cairo_region_t *buffer_damage;
|
2013-08-30 16:03:30 +00:00
|
|
|
|
|
|
|
cairo_region_t *input_region;
|
2015-08-04 06:58:26 +00:00
|
|
|
gboolean input_region_set;
|
2013-08-30 16:03:30 +00:00
|
|
|
cairo_region_t *opaque_region;
|
2015-08-04 06:58:26 +00:00
|
|
|
gboolean opaque_region_set;
|
2013-08-30 16:03:30 +00:00
|
|
|
|
|
|
|
/* wl_surface.frame */
|
|
|
|
struct wl_list frame_callback_list;
|
2014-02-09 23:23:07 +00:00
|
|
|
|
2014-07-17 18:07:38 +00:00
|
|
|
MetaRectangle new_geometry;
|
|
|
|
gboolean has_new_geometry;
|
2016-04-06 12:07:08 +00:00
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
gboolean has_acked_configure_serial;
|
|
|
|
uint32_t acked_configure_serial;
|
|
|
|
|
2016-04-06 12:07:08 +00:00
|
|
|
/* pending min/max size in window geometry coordinates */
|
|
|
|
gboolean has_new_min_size;
|
|
|
|
int new_min_width;
|
|
|
|
int new_min_height;
|
|
|
|
gboolean has_new_max_size;
|
|
|
|
int new_max_width;
|
|
|
|
int new_max_height;
|
2018-11-26 18:40:57 +00:00
|
|
|
|
|
|
|
gboolean has_new_buffer_transform;
|
|
|
|
MetaMonitorTransform buffer_transform;
|
2018-11-24 19:25:38 +00:00
|
|
|
gboolean has_new_viewport_src_rect;
|
2019-02-20 15:23:04 +00:00
|
|
|
graphene_rect_t viewport_src_rect;
|
2018-11-24 19:25:38 +00:00
|
|
|
gboolean has_new_viewport_dst_size;
|
|
|
|
int viewport_dst_width;
|
|
|
|
int viewport_dst_height;
|
2020-10-07 09:02:41 +00:00
|
|
|
|
2021-03-09 21:24:13 +00:00
|
|
|
GSList *subsurface_placement_ops;
|
|
|
|
|
2020-10-07 09:02:41 +00:00
|
|
|
/* presentation-time */
|
|
|
|
struct wl_list presentation_feedback_list;
|
2022-09-28 15:01:50 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
gboolean surface_size_changed;
|
|
|
|
} derived;
|
2022-11-01 16:30:00 +00:00
|
|
|
|
|
|
|
/* xdg_popup */
|
|
|
|
MetaWaylandXdgPositioner *xdg_positioner;
|
|
|
|
uint32_t xdg_popup_reposition_token;
|
2015-07-08 08:14:00 +00:00
|
|
|
};
|
2013-08-30 07:40:36 +00:00
|
|
|
|
2015-05-18 11:24:27 +00:00
|
|
|
struct _MetaWaylandDragDestFuncs
|
|
|
|
{
|
|
|
|
void (* focus_in) (MetaWaylandDataDevice *data_device,
|
|
|
|
MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandDataOffer *offer);
|
|
|
|
void (* focus_out) (MetaWaylandDataDevice *data_device,
|
|
|
|
MetaWaylandSurface *surface);
|
|
|
|
void (* motion) (MetaWaylandDataDevice *data_device,
|
|
|
|
MetaWaylandSurface *surface,
|
|
|
|
const ClutterEvent *event);
|
|
|
|
void (* drop) (MetaWaylandDataDevice *data_device,
|
|
|
|
MetaWaylandSurface *surface);
|
2015-09-28 12:16:20 +00:00
|
|
|
void (* update) (MetaWaylandDataDevice *data_device,
|
|
|
|
MetaWaylandSurface *surface);
|
2015-05-18 11:24:27 +00:00
|
|
|
};
|
|
|
|
|
2013-08-30 16:03:30 +00:00
|
|
|
struct _MetaWaylandSurface
|
|
|
|
{
|
2015-07-08 03:21:23 +00:00
|
|
|
GObject parent;
|
|
|
|
|
2014-10-07 03:15:18 +00:00
|
|
|
/* Generic stuff */
|
2013-08-30 16:03:30 +00:00
|
|
|
struct wl_resource *resource;
|
|
|
|
MetaWaylandCompositor *compositor;
|
2015-07-08 08:14:00 +00:00
|
|
|
MetaWaylandSurfaceRole *role;
|
2015-03-02 14:56:35 +00:00
|
|
|
cairo_region_t *input_region;
|
|
|
|
cairo_region_t *opaque_region;
|
2014-10-07 03:15:18 +00:00
|
|
|
int scale;
|
|
|
|
int32_t offset_x, offset_y;
|
2020-05-07 14:44:04 +00:00
|
|
|
GHashTable *outputs;
|
2018-11-26 18:40:57 +00:00
|
|
|
MetaMonitorTransform buffer_transform;
|
2014-10-07 03:15:18 +00:00
|
|
|
|
2016-03-16 06:47:53 +00:00
|
|
|
/* Buffer reference state. */
|
wayland/surface: Overhaul handling of buffer use count
Move the use count from a separate MetaWaylandBufferRef struct to the
MetaWaylandBuffer class, and remove the former.
The buffer use count is now incremented already in
meta_wayland_surface_commit, since the Wayland protocol defines the
buffer to be in use by the compositor at that point. If the buffer
attachment ends up being dropped again before it is applied to the
surface state (e.g. because another buffer is committed to a
synchronized sub-surface before the parent surface is committed),
the use count is now decremented, and a buffer release event is sent if
the use count drops to 0.
Buffer release events were previously incorrectly not sent under these
circumstances. Test case: Run the weston-subsurfaces demo with the -r1
and/or -t1 command line parameter. Resize the window. Before this
change, weston-subsurfaces would freeze or abort after a few resize
operations, because mutter failed to send release events and the
client ran out of usable buffers.
v2:
* Handle NULL priv->buffer_ref in
meta_wayland_cursor_surface_apply_state.
v3:
* Remove MetaWaylandBufferRef altogether, move the use count tracking
to MetaWaylandBuffer itself. Much simpler, and doesn't run into
lifetime issues when mutter shuts down.
v4:
* Warn if use count isn't 0 in meta_wayland_buffer_finalize.
* Keep pending_buffer_resource_destroyed for attached but not yet
committed buffers. If the client attaches a buffer and then destroys
it before commit, we ignore the buffer attachement, same as before
this MR.
v5:
* Rebase on top of new commit which splits up surface->texture.
* MetaWaylandSurfaceState::buffer can only be non-NULL if
::newly_attached is TRUE, simplify accordingly.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880>
2022-06-22 16:43:11 +00:00
|
|
|
MetaWaylandBuffer *buffer;
|
2016-03-16 06:47:53 +00:00
|
|
|
|
|
|
|
/* Buffer renderer state. */
|
|
|
|
gboolean buffer_held;
|
|
|
|
|
2016-03-16 06:55:51 +00:00
|
|
|
/* Intermediate state for when no role has been assigned. */
|
|
|
|
struct {
|
2020-04-27 13:43:19 +00:00
|
|
|
struct wl_list pending_frame_callback_list;
|
2016-03-16 06:55:51 +00:00
|
|
|
MetaWaylandBuffer *buffer;
|
|
|
|
} unassigned;
|
|
|
|
|
2015-05-18 11:24:27 +00:00
|
|
|
struct {
|
|
|
|
const MetaWaylandDragDestFuncs *funcs;
|
|
|
|
} dnd;
|
|
|
|
|
2014-10-07 03:15:18 +00:00
|
|
|
/* All the pending state that wl_surface.commit will apply. */
|
2019-03-13 12:27:25 +00:00
|
|
|
MetaWaylandSurfaceState *pending_state;
|
2014-10-07 03:15:18 +00:00
|
|
|
|
2021-07-23 14:01:37 +00:00
|
|
|
struct MetaWaylandSurfaceSubState {
|
|
|
|
MetaWaylandSurface *parent;
|
|
|
|
GNode *subsurface_branch_node;
|
|
|
|
GNode *subsurface_leaf_node;
|
2022-07-13 15:10:05 +00:00
|
|
|
CoglTexture *texture;
|
2021-07-23 14:01:37 +00:00
|
|
|
} output_state, protocol_state;
|
|
|
|
|
2014-10-07 17:44:16 +00:00
|
|
|
/* Extension resources. */
|
|
|
|
struct wl_resource *wl_subsurface;
|
2014-02-03 23:36:46 +00:00
|
|
|
|
2014-10-07 03:15:18 +00:00
|
|
|
/* wl_subsurface stuff. */
|
2014-01-12 21:02:09 +00:00
|
|
|
struct {
|
2015-03-05 03:11:09 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
|
2014-04-18 22:12:54 +00:00
|
|
|
/* When the surface is synchronous, its state will be applied
|
|
|
|
* when the parent is committed. This is done by moving the
|
|
|
|
* "real" pending state below to here when this surface is
|
|
|
|
* committed and in synchronous mode.
|
|
|
|
*
|
|
|
|
* When the parent surface is committed, we apply the pending
|
|
|
|
* state here.
|
|
|
|
*/
|
2014-01-13 22:31:25 +00:00
|
|
|
gboolean synchronous;
|
|
|
|
|
2021-06-07 13:19:47 +00:00
|
|
|
/* Transaction which contains all synchronized state for this sub-surface.
|
|
|
|
* This can include state for nested sub-surfaces.
|
|
|
|
*/
|
|
|
|
MetaWaylandTransaction *transaction;
|
2014-01-12 21:02:09 +00:00
|
|
|
} sub;
|
2017-03-17 12:34:52 +00:00
|
|
|
|
2018-11-24 19:25:38 +00:00
|
|
|
/* wp_viewport */
|
|
|
|
struct {
|
|
|
|
struct wl_resource *resource;
|
|
|
|
gulong destroy_handler_id;
|
|
|
|
|
|
|
|
gboolean has_src_rect;
|
2019-02-20 15:23:04 +00:00
|
|
|
graphene_rect_t src_rect;
|
2018-11-24 19:25:38 +00:00
|
|
|
|
|
|
|
gboolean has_dst_size;
|
|
|
|
int dst_width;
|
|
|
|
int dst_height;
|
|
|
|
} viewport;
|
|
|
|
|
2017-03-17 12:34:52 +00:00
|
|
|
/* table of seats for which shortcuts are inhibited */
|
|
|
|
GHashTable *shortcut_inhibited_seats;
|
2020-10-07 09:02:41 +00:00
|
|
|
|
|
|
|
/* presentation-time */
|
|
|
|
struct {
|
|
|
|
struct wl_list feedback_list;
|
2020-10-08 12:39:22 +00:00
|
|
|
MetaWaylandOutput *last_output;
|
|
|
|
unsigned int last_output_sequence;
|
|
|
|
gboolean is_last_output_sequence_valid;
|
|
|
|
gboolean needs_sequence_update;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sequence has an undefined base, but is guaranteed to monotonically
|
|
|
|
* increase. DRM only gives us a 32-bit sequence, so we compute our own
|
|
|
|
* delta to update our own 64-bit sequence.
|
|
|
|
*/
|
|
|
|
uint64_t sequence;
|
2020-10-07 09:02:41 +00:00
|
|
|
} presentation_time;
|
2021-08-06 15:00:19 +00:00
|
|
|
|
|
|
|
/* dma-buf feedback */
|
|
|
|
MetaCrtc *scanout_candidate;
|
2021-05-30 13:00:13 +00:00
|
|
|
|
|
|
|
/* Transactions */
|
|
|
|
struct {
|
|
|
|
/* First & last committed transaction which has an entry for this surface */
|
|
|
|
MetaWaylandTransaction *first_committed;
|
|
|
|
MetaWaylandTransaction *last_committed;
|
|
|
|
} transaction;
|
2013-08-30 16:03:30 +00:00
|
|
|
};
|
|
|
|
|
2014-04-22 22:05:44 +00:00
|
|
|
void meta_wayland_shell_init (MetaWaylandCompositor *compositor);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
|
|
|
MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *compositor,
|
2014-04-22 22:22:13 +00:00
|
|
|
struct wl_client *client,
|
|
|
|
struct wl_resource *compositor_resource,
|
|
|
|
guint32 id);
|
2014-02-18 21:39:23 +00:00
|
|
|
|
2021-06-07 13:19:47 +00:00
|
|
|
void meta_wayland_surface_state_reset (MetaWaylandSurfaceState *state);
|
|
|
|
|
|
|
|
void meta_wayland_surface_state_merge_into (MetaWaylandSurfaceState *from,
|
|
|
|
MetaWaylandSurfaceState *to);
|
|
|
|
|
2021-07-23 14:01:37 +00:00
|
|
|
void meta_wayland_surface_apply_placement_ops (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSurfaceState *state);
|
|
|
|
|
2022-06-10 15:23:08 +00:00
|
|
|
void meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSurfaceState *state);
|
|
|
|
|
2019-03-13 12:27:25 +00:00
|
|
|
MetaWaylandSurfaceState *
|
2019-03-13 11:47:48 +00:00
|
|
|
meta_wayland_surface_get_pending_state (MetaWaylandSurface *surface);
|
|
|
|
|
2021-06-07 13:19:47 +00:00
|
|
|
MetaWaylandTransaction *
|
|
|
|
meta_wayland_surface_ensure_transaction (MetaWaylandSurface *surface);
|
2017-12-20 09:40:22 +00:00
|
|
|
|
2015-07-08 08:14:00 +00:00
|
|
|
gboolean meta_wayland_surface_assign_role (MetaWaylandSurface *surface,
|
2016-01-28 09:14:06 +00:00
|
|
|
GType role_type,
|
|
|
|
const char *first_property_name,
|
|
|
|
...);
|
2015-02-06 08:12:21 +00:00
|
|
|
|
2016-03-16 06:47:53 +00:00
|
|
|
MetaWaylandBuffer *meta_wayland_surface_get_buffer (MetaWaylandSurface *surface);
|
|
|
|
|
2014-04-02 14:37:08 +00:00
|
|
|
void meta_wayland_surface_set_window (MetaWaylandSurface *surface,
|
|
|
|
MetaWindow *window);
|
2014-02-18 21:39:23 +00:00
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
void meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandWindowConfiguration *configuration);
|
2013-11-12 20:52:03 +00:00
|
|
|
|
2013-11-21 19:20:52 +00:00
|
|
|
void meta_wayland_surface_ping (MetaWaylandSurface *surface,
|
|
|
|
guint32 serial);
|
2014-02-07 22:28:33 +00:00
|
|
|
void meta_wayland_surface_delete (MetaWaylandSurface *surface);
|
2013-11-21 19:20:52 +00:00
|
|
|
|
2015-05-18 11:24:27 +00:00
|
|
|
/* Drag dest functions */
|
|
|
|
void meta_wayland_surface_drag_dest_focus_in (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandDataOffer *offer);
|
|
|
|
void meta_wayland_surface_drag_dest_motion (MetaWaylandSurface *surface,
|
|
|
|
const ClutterEvent *event);
|
|
|
|
void meta_wayland_surface_drag_dest_focus_out (MetaWaylandSurface *surface);
|
|
|
|
void meta_wayland_surface_drag_dest_drop (MetaWaylandSurface *surface);
|
2015-09-28 12:16:20 +00:00
|
|
|
void meta_wayland_surface_drag_dest_update (MetaWaylandSurface *surface);
|
2015-05-18 11:24:27 +00:00
|
|
|
|
wayland: Send wl_surface.enter and wl_surface.leave
Whenever a MetaSurfaceActor is painted, update the list of what outputs
the surface is being drawed upon. Since we do this on paint, we
effectively avoids this whenever the surface is not drawn, for example
being minimized, on a non-active workspace, or simply outside of the
damage region of a frame.
DND icons and cursors are not affected by this patch, since they are not
drawn as MetaSurfaceActors. If a MetaSurfaceActor or a parent is cloned,
then we'll check the position of the original actor again when the clone is
drawn, which is slightly expensive, but harmless. If the MetaShapedTexture
instead is cloned, as GNOME Shell does in many cases, then these clones
will not cause duplicate position checks.
https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-02-03 07:49:52 +00:00
|
|
|
void meta_wayland_surface_update_outputs (MetaWaylandSurface *surface);
|
|
|
|
|
2016-01-14 09:43:47 +00:00
|
|
|
MetaWaylandSurface *meta_wayland_surface_get_toplevel (MetaWaylandSurface *surface);
|
|
|
|
|
2022-05-21 16:17:31 +00:00
|
|
|
META_EXPORT_TEST
|
2019-10-09 07:37:04 +00:00
|
|
|
MetaWindow * meta_wayland_surface_get_window (MetaWaylandSurface *surface);
|
|
|
|
|
2021-06-05 14:46:56 +00:00
|
|
|
gboolean meta_wayland_surface_is_synchronized (MetaWaylandSurface *surface);
|
2019-03-13 11:26:22 +00:00
|
|
|
|
2015-03-23 13:10:20 +00:00
|
|
|
MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface);
|
|
|
|
|
2015-06-17 02:16:02 +00:00
|
|
|
void meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
|
|
|
|
float abs_x,
|
|
|
|
float abs_y,
|
|
|
|
float *sx,
|
|
|
|
float *sy);
|
|
|
|
|
2015-06-17 04:10:52 +00:00
|
|
|
void meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
|
|
|
|
float sx,
|
|
|
|
float sy,
|
|
|
|
float *x,
|
|
|
|
float *y);
|
|
|
|
|
2015-07-08 08:14:00 +00:00
|
|
|
MetaWaylandSurface * meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role);
|
|
|
|
|
2016-02-23 13:26:52 +00:00
|
|
|
cairo_region_t * meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface);
|
|
|
|
|
2016-01-14 09:49:57 +00:00
|
|
|
|
2022-10-21 17:52:35 +00:00
|
|
|
gboolean meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSeat *seat,
|
|
|
|
MetaGrabOp grab_op,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
gfloat x,
|
|
|
|
gfloat y);
|
2015-12-15 14:09:20 +00:00
|
|
|
|
|
|
|
void meta_wayland_surface_window_managed (MetaWaylandSurface *surface,
|
|
|
|
MetaWindow *window);
|
|
|
|
|
2017-03-17 12:34:52 +00:00
|
|
|
void meta_wayland_surface_inhibit_shortcuts (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSeat *seat);
|
|
|
|
|
|
|
|
void meta_wayland_surface_restore_shortcuts (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSeat *seat);
|
|
|
|
|
|
|
|
gboolean meta_wayland_surface_is_shortcuts_inhibited (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSeat *seat);
|
|
|
|
|
wayland: Move surface texture ownership to MetaWaylandSurface
Prior to this commit, MetaWaylandSurface held a reference to
MetaWaylandBuffer, who owned the texture drawn by the surface. When
switching buffer, the texture change with it.
This is problematic when dealing with SHM buffer damage management, as
when having one texture per buffer, damaged regions uploaded to one,
will not follow along to the next one attached. It also wasted GPU
memory as there would be one texture per buffer, instead of one one
texture per surface.
Instead, move the texture ownership to MetaWaylandSurface, and have the
SHM buffer damage management update the surface texture. This ensures
damage is processed properly, and that we won't end up with stale
texture content when doing partial texture uploads. If the same SHM
buffer is attached to multiple surfaces, each surface will get their own
copy, and damage is tracked and uploaded separately.
Non-SHM types of buffers still has their own texture reference, as the
texture is just a representation of the GPU memory associated with the
buffer. When such a buffer is attached to a surface, instead the surface
just gets a reference to that texture, instead of a separately allocated
one.
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-08 10:46:48 +00:00
|
|
|
CoglTexture * meta_wayland_surface_get_texture (MetaWaylandSurface *surface);
|
|
|
|
|
2021-09-07 08:35:27 +00:00
|
|
|
META_EXPORT_TEST
|
2018-04-06 10:29:37 +00:00
|
|
|
MetaSurfaceActor * meta_wayland_surface_get_actor (MetaWaylandSurface *surface);
|
|
|
|
|
2018-04-06 10:35:34 +00:00
|
|
|
void meta_wayland_surface_notify_geometry_changed (MetaWaylandSurface *surface);
|
|
|
|
|
2019-10-08 21:32:37 +00:00
|
|
|
void meta_wayland_surface_notify_subsurface_state_changed (MetaWaylandSurface *surface);
|
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 07:57:40 +00:00
|
|
|
void meta_wayland_surface_notify_unmapped (MetaWaylandSurface *surface);
|
|
|
|
|
2022-09-28 18:51:32 +00:00
|
|
|
META_EXPORT_TEST
|
2018-06-29 15:45:28 +00:00
|
|
|
int meta_wayland_surface_get_width (MetaWaylandSurface *surface);
|
2022-09-28 18:51:32 +00:00
|
|
|
|
|
|
|
META_EXPORT_TEST
|
2018-06-29 15:45:28 +00:00
|
|
|
int meta_wayland_surface_get_height (MetaWaylandSurface *surface);
|
|
|
|
|
2019-09-12 09:44:59 +00:00
|
|
|
CoglScanout * meta_wayland_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
|
|
|
CoglOnscreen *onscreen);
|
|
|
|
|
2021-08-06 15:00:19 +00:00
|
|
|
MetaCrtc * meta_wayland_surface_get_scanout_candidate (MetaWaylandSurface *surface);
|
|
|
|
|
|
|
|
void meta_wayland_surface_set_scanout_candidate (MetaWaylandSurface *surface,
|
|
|
|
MetaCrtc *crtc);
|
|
|
|
|
2022-02-08 19:23:27 +00:00
|
|
|
gboolean
|
|
|
|
meta_wayland_surface_can_scanout_untransformed (MetaWaylandSurface *surface,
|
|
|
|
MetaRendererView *view,
|
|
|
|
int geometry_scale);
|
|
|
|
|
2022-06-13 08:25:02 +00:00
|
|
|
int meta_wayland_surface_get_geometry_scale (MetaWaylandSurface *surface);
|
|
|
|
|
2023-01-27 20:45:35 +00:00
|
|
|
META_EXPORT_TEST
|
|
|
|
struct wl_resource * meta_wayland_surface_get_resource (MetaWaylandSurface *surface);
|
|
|
|
|
2023-02-01 16:54:19 +00:00
|
|
|
MetaWaylandCompositor * meta_wayland_surface_get_compositor (MetaWaylandSurface *surface);
|
|
|
|
|
2021-05-28 10:39:48 +00:00
|
|
|
static inline MetaWaylandSurfaceState *
|
|
|
|
meta_wayland_surface_state_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_WAYLAND_SURFACE_STATE, NULL);
|
|
|
|
}
|
|
|
|
|
2019-12-06 17:22:47 +00:00
|
|
|
static inline GNode *
|
|
|
|
meta_get_next_subsurface_sibling (GNode *n)
|
|
|
|
{
|
|
|
|
GNode *next;
|
|
|
|
|
|
|
|
if (!n)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
next = g_node_next_sibling (n);
|
|
|
|
if (!next)
|
|
|
|
return NULL;
|
|
|
|
if (!G_NODE_IS_LEAF (next))
|
|
|
|
return next;
|
|
|
|
else
|
|
|
|
return meta_get_next_subsurface_sibling (next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline GNode *
|
2021-07-23 14:01:37 +00:00
|
|
|
meta_get_first_subsurface_node (struct MetaWaylandSurfaceSubState *sub)
|
2019-12-06 17:22:47 +00:00
|
|
|
{
|
|
|
|
GNode *n;
|
|
|
|
|
2021-07-23 14:01:37 +00:00
|
|
|
n = g_node_first_child (sub->subsurface_branch_node);
|
wayland: Fix null pointer deference in meta_get_first_subsurface_node.
In fcfe90aa, multiple for loops were replaced with
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE.
However, this substitution was not side-effect free, and introduced a
null-pointer dereference risk as shown in the example below:
Old:
for (n = g_node_first_child (surface->subsurface_branch_node);
n;
n = g_node_next_sibling (n))
{
if (G_NODE_IS_LEAF (n))
continue;
meta_wayland_surface_update_outputs_recursively (n->data);
}
n is checked for NULL during each loop in the condition expression.
Therefore, when `G_NODE_IS_LEAF (n)` is called, `n` is guaranteed not to
be NULL. Note also that g_node_first_child is also NULL-safe since it
performs a NULL check internally.
New:
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
meta_wayland_surface_update_outputs_recursively (subsurface_surface);
=
for (GNode *G_PASTE(__n, __LINE__) = meta_get_first_subsurface_node ((surface)); \
(subsurface = (G_PASTE (__n, __LINE__) ? G_PASTE (__n, __LINE__)->data : NULL)); \
G_PASTE (__n, __LINE__) = meta_get_next_subsurface_sibling (G_PASTE (__n, __LINE__)))
In the new logic `subsurface` is still checked for NULL in the loop
condition. However, in the new loop init:
...
meta_get_first_subsurface_node (MetaWaylandSurface *surface)
...
n = g_node_first_child (surface->subsurface_branch_node);
if (!G_NODE_IS_LEAF (n))
...
The above implementation performs a `G_NODE_IS_LEAF` call, which
performs a dereference on `n`, without first checking for NULLs.
This NULL dereference triggers the following gnome-shell crash:
Core was generated by `/usr/bin/gnome-shell'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 meta_get_first_subsurface_node (surface=0x55d589623450) at ../src/wayland/meta-wayland-surface.h:399
#1 pointer_can_grab_surface (pointer=0x7f6dc4012700, surface=0x55d589623450) at ../src/wayland/meta-wayland-pointer.c:1306
#2 0x00007f6ddb94d509 in meta_wayland_pointer_can_grab_surface (pointer=<optimized out>, surface=surface@entry=0x55d589623450, serial=serial@entry=996) at ../src/wayland/meta-wayland-pointer.c:1321
#3 0x00007f6ddb950d05 in meta_wayland_seat_get_grab_info (seat=seat@entry=0x55d586c24f20, surface=0x55d589623450, serial=996, require_pressed=require_pressed@entry=0, x=x@entry=0x0, y=y@entry=0x0)
at ../src/wayland/meta-wayland-seat.c:467
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2655>
2022-10-12 04:41:05 +00:00
|
|
|
if (!n)
|
|
|
|
return NULL;
|
|
|
|
else if (!G_NODE_IS_LEAF (n))
|
2019-12-06 17:22:47 +00:00
|
|
|
return n;
|
|
|
|
else
|
|
|
|
return meta_get_next_subsurface_sibling (n);
|
|
|
|
}
|
|
|
|
|
2021-07-23 14:01:37 +00:00
|
|
|
#define META_WAYLAND_SURFACE_FOREACH_SUBSURFACE(state, subsurface) \
|
|
|
|
for (GNode *G_PASTE(__n, __LINE__) = meta_get_first_subsurface_node (state), \
|
|
|
|
*G_PASTE(__next, __LINE__) = meta_get_next_subsurface_sibling (G_PASTE (__n, __LINE__)); \
|
2019-12-06 17:22:47 +00:00
|
|
|
(subsurface = (G_PASTE (__n, __LINE__) ? G_PASTE (__n, __LINE__)->data : NULL)); \
|
2021-07-23 14:01:37 +00:00
|
|
|
G_PASTE (__n, __LINE__) = G_PASTE (__next, __LINE__), \
|
|
|
|
G_PASTE (__next, __LINE__) = meta_get_next_subsurface_sibling (G_PASTE (__n, __LINE__)))
|
2019-12-06 17:22:47 +00:00
|
|
|
|
2013-08-30 16:03:30 +00:00
|
|
|
#endif
|