mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 03:22:04 +00:00
wayland/surface: Connect to "output-destroyed" in surface_entered_output
Since we're now connecting to one more signal of MetaWaylandOutput, keep signal connections in one place and move connecting the "output-destroyed" signal to surface_entered_output() and disconnecting it to surface_left_output(). This also allows us to use the "outputs_to_destroy_notify_id" as a simple set and rename it to "outputs". While at it, also use g_hash_table_destroy() instead of g_hash_table_unref() since destroy is more clear than unref and does the same thing in this case. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
This commit is contained in:
parent
696b534570
commit
d9fb6b5ca2
@ -120,6 +120,11 @@ meta_wayland_surface_role_is_on_logical_monitor (MetaWaylandSurfaceRole *surface
|
||||
static MetaWaylandSurface *
|
||||
meta_wayland_surface_role_get_toplevel (MetaWaylandSurfaceRole *surface_role);
|
||||
|
||||
static void
|
||||
set_surface_is_on_output (MetaWaylandSurface *surface,
|
||||
MetaWaylandOutput *wayland_output,
|
||||
gboolean is_on_output);
|
||||
|
||||
static MetaWaylandBufferRef *
|
||||
meta_wayland_buffer_ref_new (void)
|
||||
{
|
||||
@ -1162,6 +1167,13 @@ static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
|
||||
wl_surface_damage_buffer,
|
||||
};
|
||||
|
||||
static void
|
||||
handle_output_destroyed (MetaWaylandOutput *wayland_output,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
set_surface_is_on_output (surface, wayland_output, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_output_bound (MetaWaylandOutput *wayland_output,
|
||||
struct wl_resource *output_resource,
|
||||
@ -1179,6 +1191,10 @@ surface_entered_output (MetaWaylandSurface *surface,
|
||||
GList *iter;
|
||||
struct wl_resource *resource;
|
||||
|
||||
g_signal_connect (wayland_output, "output-destroyed",
|
||||
G_CALLBACK (handle_output_destroyed),
|
||||
surface);
|
||||
|
||||
for (iter = wayland_output->resources; iter != NULL; iter = iter->next)
|
||||
{
|
||||
resource = iter->data;
|
||||
@ -1202,6 +1218,10 @@ surface_left_output (MetaWaylandSurface *surface,
|
||||
GList *iter;
|
||||
struct wl_resource *resource;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (wayland_output,
|
||||
G_CALLBACK (handle_output_destroyed),
|
||||
surface);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (wayland_output,
|
||||
G_CALLBACK (handle_output_bound),
|
||||
surface);
|
||||
@ -1218,43 +1238,23 @@ surface_left_output (MetaWaylandSurface *surface,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_surface_is_on_output (MetaWaylandSurface *surface,
|
||||
MetaWaylandOutput *wayland_output,
|
||||
gboolean is_on_output);
|
||||
|
||||
static void
|
||||
surface_handle_output_destroy (MetaWaylandOutput *wayland_output,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
set_surface_is_on_output (surface, wayland_output, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
set_surface_is_on_output (MetaWaylandSurface *surface,
|
||||
MetaWaylandOutput *wayland_output,
|
||||
gboolean is_on_output)
|
||||
{
|
||||
gpointer orig_id;
|
||||
gboolean was_on_output = g_hash_table_lookup_extended (surface->outputs_to_destroy_notify_id,
|
||||
wayland_output,
|
||||
NULL, &orig_id);
|
||||
gboolean was_on_output;
|
||||
|
||||
was_on_output = g_hash_table_contains (surface->outputs, wayland_output);
|
||||
|
||||
if (!was_on_output && is_on_output)
|
||||
{
|
||||
gulong id;
|
||||
|
||||
id = g_signal_connect (wayland_output, "output-destroyed",
|
||||
G_CALLBACK (surface_handle_output_destroy),
|
||||
surface);
|
||||
g_hash_table_insert (surface->outputs_to_destroy_notify_id, wayland_output,
|
||||
GSIZE_TO_POINTER ((gsize)id));
|
||||
g_hash_table_add (surface->outputs, wayland_output);
|
||||
surface_entered_output (surface, wayland_output);
|
||||
}
|
||||
else if (was_on_output && !is_on_output)
|
||||
{
|
||||
g_hash_table_remove (surface->outputs_to_destroy_notify_id, wayland_output);
|
||||
g_signal_handler_disconnect (wayland_output, (gulong) GPOINTER_TO_SIZE (orig_id));
|
||||
g_hash_table_remove (surface->outputs, wayland_output);
|
||||
surface_left_output (surface, wayland_output);
|
||||
}
|
||||
}
|
||||
@ -1290,8 +1290,10 @@ surface_output_disconnect_signals (gpointer key,
|
||||
MetaWaylandOutput *wayland_output = key;
|
||||
MetaWaylandSurface *surface = user_data;
|
||||
|
||||
g_signal_handler_disconnect (wayland_output,
|
||||
(gulong) GPOINTER_TO_SIZE (value));
|
||||
g_signal_handlers_disconnect_by_func (wayland_output,
|
||||
G_CALLBACK (handle_output_destroyed),
|
||||
surface);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (wayland_output,
|
||||
G_CALLBACK (handle_output_bound),
|
||||
surface);
|
||||
@ -1364,10 +1366,10 @@ wl_surface_destructor (struct wl_resource *resource)
|
||||
|
||||
meta_wayland_compositor_destroy_frame_callbacks (compositor, surface);
|
||||
|
||||
g_hash_table_foreach (surface->outputs_to_destroy_notify_id,
|
||||
g_hash_table_foreach (surface->outputs,
|
||||
surface_output_disconnect_signals,
|
||||
surface);
|
||||
g_hash_table_unref (surface->outputs_to_destroy_notify_id);
|
||||
g_hash_table_destroy (surface->outputs);
|
||||
|
||||
wl_list_for_each_safe (cb, next, &surface->pending_frame_callback_list, link)
|
||||
wl_resource_destroy (cb->resource);
|
||||
@ -1418,7 +1420,7 @@ meta_wayland_surface_create (MetaWaylandCompositor *compositor,
|
||||
|
||||
wl_list_init (&surface->pending_frame_callback_list);
|
||||
|
||||
surface->outputs_to_destroy_notify_id = g_hash_table_new (NULL, NULL);
|
||||
surface->outputs = g_hash_table_new (NULL, NULL);
|
||||
surface->shortcut_inhibited_seats = g_hash_table_new (NULL, NULL);
|
||||
|
||||
meta_wayland_compositor_notify_surface_id (compositor, id, surface);
|
||||
|
@ -157,7 +157,7 @@ struct _MetaWaylandSurface
|
||||
int32_t offset_x, offset_y;
|
||||
GNode *subsurface_branch_node;
|
||||
GNode *subsurface_leaf_node;
|
||||
GHashTable *outputs_to_destroy_notify_id;
|
||||
GHashTable *outputs;
|
||||
MetaMonitorTransform buffer_transform;
|
||||
|
||||
CoglTexture *texture;
|
||||
|
Loading…
Reference in New Issue
Block a user