xwayland: Move out surface role related logic
Does some needed naming cleanup while at it, to be more similar to other role types. In short, MetaWaylandSurfaceRoleXwayland was changed to MetaXwaylandSurface. https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
This commit is contained in:
parent
e51279dcf0
commit
f21595687f
@ -584,6 +584,8 @@ if have_wayland
|
|||||||
'wayland/meta-xwayland-private.h',
|
'wayland/meta-xwayland-private.h',
|
||||||
'wayland/meta-xwayland-dnd.c',
|
'wayland/meta-xwayland-dnd.c',
|
||||||
'wayland/meta-xwayland-dnd-private.h',
|
'wayland/meta-xwayland-dnd-private.h',
|
||||||
|
'wayland/meta-xwayland-surface.c',
|
||||||
|
'wayland/meta-xwayland-surface.h',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
160
src/wayland/meta-xwayland-surface.c
Normal file
160
src/wayland/meta-xwayland-surface.c
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Intel Corporation
|
||||||
|
* Copyright (C) 2013-2019 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "wayland/meta-xwayland-surface.h"
|
||||||
|
|
||||||
|
#include "compositor/meta-surface-actor-wayland.h"
|
||||||
|
#include "compositor/meta-window-actor-private.h"
|
||||||
|
#include "wayland/meta-wayland-actor-surface.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
WINDOW_ASSOCIATED,
|
||||||
|
|
||||||
|
N_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[N_SIGNALS];
|
||||||
|
|
||||||
|
struct _MetaXwaylandSurface
|
||||||
|
{
|
||||||
|
MetaWaylandActorSurface parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MetaXwaylandSurface,
|
||||||
|
meta_xwayland_surface,
|
||||||
|
META_TYPE_WAYLAND_ACTOR_SURFACE)
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surface,
|
||||||
|
MetaWindow *window)
|
||||||
|
{
|
||||||
|
MetaWaylandSurfaceRole *surface_role =
|
||||||
|
META_WAYLAND_SURFACE_ROLE (xwayland_surface);
|
||||||
|
MetaWaylandSurface *surface =
|
||||||
|
meta_wayland_surface_role_get_surface (surface_role);
|
||||||
|
MetaWindowActor *window_actor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the window has an existing surface, like if we're undecorating or
|
||||||
|
* decorating the window, then we need to detach the window from its old
|
||||||
|
* surface.
|
||||||
|
*/
|
||||||
|
if (window->surface)
|
||||||
|
{
|
||||||
|
meta_wayland_surface_set_window (window->surface, NULL);
|
||||||
|
window->surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->surface = surface;
|
||||||
|
meta_wayland_surface_set_window (surface, window);
|
||||||
|
g_signal_emit (xwayland_surface, signals[WINDOW_ASSOCIATED], 0);
|
||||||
|
|
||||||
|
window_actor = meta_window_actor_from_window (window);
|
||||||
|
if (window_actor)
|
||||||
|
{
|
||||||
|
MetaSurfaceActor *surface_actor;
|
||||||
|
|
||||||
|
surface_actor = meta_wayland_surface_get_actor (surface);
|
||||||
|
meta_window_actor_assign_surface_actor (window_actor, surface_actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MetaWaylandSurface *
|
||||||
|
meta_xwayland_surface_get_toplevel (MetaWaylandSurfaceRole *surface_role)
|
||||||
|
{
|
||||||
|
return meta_wayland_surface_role_get_surface (surface_role);
|
||||||
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
meta_xwayland_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_xwayland_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
||||||
|
{
|
||||||
|
MetaWaylandSurfaceRole *surface_role =
|
||||||
|
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
||||||
|
MetaWaylandSurface *surface =
|
||||||
|
meta_wayland_surface_role_get_surface (surface_role);
|
||||||
|
MetaWaylandActorSurfaceClass *actor_surface_class =
|
||||||
|
META_WAYLAND_ACTOR_SURFACE_CLASS (meta_xwayland_surface_parent_class);
|
||||||
|
|
||||||
|
if (surface->window)
|
||||||
|
actor_surface_class->sync_actor_state (actor_surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_xwayland_surface_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
MetaWaylandSurfaceRole *surface_role =
|
||||||
|
META_WAYLAND_SURFACE_ROLE (object);
|
||||||
|
MetaWaylandSurface *surface =
|
||||||
|
meta_wayland_surface_role_get_surface (surface_role);
|
||||||
|
GObjectClass *parent_object_class =
|
||||||
|
G_OBJECT_CLASS (meta_xwayland_surface_parent_class);
|
||||||
|
MetaWindow *window;
|
||||||
|
|
||||||
|
window = surface->window;
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
meta_wayland_surface_set_window (surface, NULL);
|
||||||
|
window->surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent_object_class->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_xwayland_surface_init (MetaXwaylandSurface *xwayland_surface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_xwayland_surface_class_init (MetaXwaylandSurfaceClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
MetaWaylandSurfaceRoleClass *surface_role_class =
|
||||||
|
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
|
||||||
|
MetaWaylandActorSurfaceClass *actor_surface_class =
|
||||||
|
META_WAYLAND_ACTOR_SURFACE_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = meta_xwayland_surface_finalize;
|
||||||
|
|
||||||
|
surface_role_class->get_toplevel = meta_xwayland_surface_get_toplevel;
|
||||||
|
|
||||||
|
actor_surface_class->get_geometry_scale =
|
||||||
|
meta_xwayland_surface_get_geometry_scale;
|
||||||
|
actor_surface_class->sync_actor_state =
|
||||||
|
meta_xwayland_surface_sync_actor_state;
|
||||||
|
|
||||||
|
signals[WINDOW_ASSOCIATED] =
|
||||||
|
g_signal_new ("window-associated",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0, NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
}
|
38
src/wayland/meta-xwayland-surface.h
Normal file
38
src/wayland/meta-xwayland-surface.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Intel Corporation
|
||||||
|
* Copyright (C) 2013-2019 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_XWAYLAND_SURFACE_H
|
||||||
|
#define META_XWAYLAND_SURFACE_H
|
||||||
|
|
||||||
|
#include "meta/types.h"
|
||||||
|
#include "wayland/meta-wayland-actor-surface.h"
|
||||||
|
|
||||||
|
#define META_TYPE_XWAYLAND_SURFACE (meta_xwayland_surface_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (MetaXwaylandSurface,
|
||||||
|
meta_xwayland_surface,
|
||||||
|
META, XWAYLAND_SURFACE,
|
||||||
|
MetaWaylandActorSurface)
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surface,
|
||||||
|
MetaWindow *window);
|
||||||
|
|
||||||
|
#endif /* META_XWAYLAND_SURFACE_H */
|
@ -39,37 +39,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <X11/Xauth.h>
|
#include <X11/Xauth.h>
|
||||||
|
|
||||||
#include "compositor/meta-surface-actor-wayland.h"
|
|
||||||
#include "compositor/meta-window-actor-private.h"
|
|
||||||
#include "core/main-private.h"
|
#include "core/main-private.h"
|
||||||
#include "meta/main.h"
|
#include "meta/main.h"
|
||||||
#include "wayland/meta-wayland-actor-surface.h"
|
#include "wayland/meta-xwayland-surface.h"
|
||||||
#include "x11/meta-x11-display-private.h"
|
#include "x11/meta-x11-display-private.h"
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
XWAYLAND_SURFACE_WINDOW_ASSOCIATED,
|
|
||||||
|
|
||||||
XWAYLAND_SURFACE_LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
guint xwayland_surface_signals[XWAYLAND_SURFACE_LAST_SIGNAL];
|
|
||||||
|
|
||||||
#define META_TYPE_WAYLAND_SURFACE_ROLE_XWAYLAND (meta_wayland_surface_role_xwayland_get_type ())
|
|
||||||
G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleXWayland,
|
|
||||||
meta_wayland_surface_role_xwayland,
|
|
||||||
META, WAYLAND_SURFACE_ROLE_XWAYLAND,
|
|
||||||
MetaWaylandActorSurface)
|
|
||||||
|
|
||||||
struct _MetaWaylandSurfaceRoleXWayland
|
|
||||||
{
|
|
||||||
MetaWaylandActorSurface parent;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaWaylandSurfaceRoleXWayland,
|
|
||||||
meta_wayland_surface_role_xwayland,
|
|
||||||
META_TYPE_WAYLAND_ACTOR_SURFACE)
|
|
||||||
|
|
||||||
static int display_number_override = -1;
|
static int display_number_override = -1;
|
||||||
|
|
||||||
static void meta_xwayland_stop_xserver (MetaXWaylandManager *manager);
|
static void meta_xwayland_stop_xserver (MetaXWaylandManager *manager);
|
||||||
@ -79,20 +53,10 @@ meta_xwayland_associate_window_with_surface (MetaWindow *window,
|
|||||||
MetaWaylandSurface *surface)
|
MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = window->display;
|
MetaDisplay *display = window->display;
|
||||||
MetaWindowActor *window_actor;
|
MetaXwaylandSurface *xwayland_surface;
|
||||||
|
|
||||||
/* If the window has an existing surface, like if we're
|
|
||||||
* undecorating or decorating the window, then we need
|
|
||||||
* to detach the window from its old surface.
|
|
||||||
*/
|
|
||||||
if (window->surface)
|
|
||||||
{
|
|
||||||
meta_wayland_surface_set_window (window->surface, NULL);
|
|
||||||
window->surface = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!meta_wayland_surface_assign_role (surface,
|
if (!meta_wayland_surface_assign_role (surface,
|
||||||
META_TYPE_WAYLAND_SURFACE_ROLE_XWAYLAND,
|
META_TYPE_XWAYLAND_SURFACE,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
wl_resource_post_error (surface->resource,
|
wl_resource_post_error (surface->resource,
|
||||||
@ -102,20 +66,8 @@ meta_xwayland_associate_window_with_surface (MetaWindow *window,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->surface = surface;
|
xwayland_surface = META_XWAYLAND_SURFACE (surface->role);
|
||||||
meta_wayland_surface_set_window (surface, window);
|
meta_xwayland_surface_associate_with_window (xwayland_surface, window);
|
||||||
g_signal_emit (surface->role,
|
|
||||||
xwayland_surface_signals[XWAYLAND_SURFACE_WINDOW_ASSOCIATED],
|
|
||||||
0);
|
|
||||||
|
|
||||||
window_actor = meta_window_actor_from_window (window);
|
|
||||||
if (window_actor)
|
|
||||||
{
|
|
||||||
MetaSurfaceActor *surface_actor;
|
|
||||||
|
|
||||||
surface_actor = meta_wayland_surface_get_actor (surface);
|
|
||||||
meta_window_actor_assign_surface_actor (window_actor, surface_actor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now that we have a surface check if it should have focus. */
|
/* Now that we have a surface check if it should have focus. */
|
||||||
meta_display_sync_wayland_input_focus (display);
|
meta_display_sync_wayland_input_focus (display);
|
||||||
@ -853,80 +805,3 @@ meta_xwayland_shutdown (MetaXWaylandManager *manager)
|
|||||||
g_clear_pointer (&manager->lock_file, g_free);
|
g_clear_pointer (&manager->lock_file, g_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaWaylandSurface *
|
|
||||||
xwayland_surface_get_toplevel (MetaWaylandSurfaceRole *surface_role)
|
|
||||||
{
|
|
||||||
return meta_wayland_surface_role_get_surface (surface_role);
|
|
||||||
}
|
|
||||||
|
|
||||||
static double
|
|
||||||
xwayland_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xwayland_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
|
||||||
{
|
|
||||||
MetaWaylandSurfaceRole *surface_role =
|
|
||||||
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
|
||||||
MetaWaylandSurface *surface =
|
|
||||||
meta_wayland_surface_role_get_surface (surface_role);
|
|
||||||
MetaWaylandActorSurfaceClass *actor_surface_class =
|
|
||||||
META_WAYLAND_ACTOR_SURFACE_CLASS (meta_wayland_surface_role_xwayland_parent_class);
|
|
||||||
|
|
||||||
if (surface->window)
|
|
||||||
actor_surface_class->sync_actor_state (actor_surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xwayland_surface_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
MetaWaylandSurfaceRole *surface_role =
|
|
||||||
META_WAYLAND_SURFACE_ROLE (object);
|
|
||||||
MetaWaylandSurface *surface =
|
|
||||||
meta_wayland_surface_role_get_surface (surface_role);
|
|
||||||
GObjectClass *parent_object_class =
|
|
||||||
G_OBJECT_CLASS (meta_wayland_surface_role_xwayland_parent_class);
|
|
||||||
MetaWindow *window;
|
|
||||||
|
|
||||||
window = surface->window;
|
|
||||||
if (window)
|
|
||||||
{
|
|
||||||
meta_wayland_surface_set_window (surface, NULL);
|
|
||||||
window->surface = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent_object_class->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
meta_wayland_surface_role_xwayland_init (MetaWaylandSurfaceRoleXWayland *role)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
meta_wayland_surface_role_xwayland_class_init (MetaWaylandSurfaceRoleXWaylandClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
||||||
MetaWaylandSurfaceRoleClass *surface_role_class =
|
|
||||||
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
|
|
||||||
MetaWaylandActorSurfaceClass *actor_surface_class =
|
|
||||||
META_WAYLAND_ACTOR_SURFACE_CLASS (klass);
|
|
||||||
|
|
||||||
object_class->finalize = xwayland_surface_finalize;
|
|
||||||
|
|
||||||
surface_role_class->get_toplevel = xwayland_surface_get_toplevel;
|
|
||||||
|
|
||||||
actor_surface_class->get_geometry_scale = xwayland_surface_get_geometry_scale;
|
|
||||||
actor_surface_class->sync_actor_state = xwayland_surface_sync_actor_state;
|
|
||||||
|
|
||||||
xwayland_surface_signals[XWAYLAND_SURFACE_WINDOW_ASSOCIATED] =
|
|
||||||
g_signal_new ("window-associated",
|
|
||||||
G_TYPE_FROM_CLASS (klass),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
0, NULL, NULL,
|
|
||||||
g_cclosure_marshal_VOID__VOID,
|
|
||||||
G_TYPE_NONE, 0);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user