window: Move surface property to it subclasses

As we have specific window types per display server,
having it in the parent class makes building without wayland
harder to achieve

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
This commit is contained in:
Bilal Elmoussaoui
2022-05-18 13:51:44 +02:00
committed by Marge Bot
parent c3a01e4e18
commit 6b77532a23
13 changed files with 193 additions and 45 deletions

View File

@ -44,12 +44,25 @@
#include "wayland/meta-wayland-window-configuration.h"
#include "wayland/meta-wayland-xdg-shell.h"
enum
{
PROP_0,
PROP_SURFACE,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
struct _MetaWindowWayland
{
MetaWindow parent;
int geometry_scale;
MetaWaylandSurface *surface;
GList *pending_configurations;
gboolean has_pending_state_change;
@ -112,7 +125,7 @@ meta_window_wayland_manage (MetaWindow *window)
0);
}
meta_wayland_surface_window_managed (window->surface, window);
meta_wayland_surface_window_managed (wl_window->surface, window);
}
static void
@ -131,20 +144,24 @@ static void
meta_window_wayland_ping (MetaWindow *window,
guint32 serial)
{
meta_wayland_surface_ping (window->surface, serial);
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
meta_wayland_surface_ping (wl_window->surface, serial);
}
static void
meta_window_wayland_delete (MetaWindow *window,
guint32 timestamp)
{
meta_wayland_surface_delete (window->surface);
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
meta_wayland_surface_delete (wl_window->surface);
}
static void
meta_window_wayland_kill (MetaWindow *window)
{
MetaWaylandSurface *surface = window->surface;
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
struct wl_resource *resource = surface->resource;
/* Send the client an unrecoverable error to kill the client. */
@ -170,9 +187,7 @@ static void
meta_window_wayland_configure (MetaWindowWayland *wl_window,
MetaWaylandWindowConfiguration *configuration)
{
MetaWindow *window = META_WINDOW (wl_window);
meta_wayland_surface_configure_notify (window->surface, configuration);
meta_wayland_surface_configure_notify (wl_window->surface, configuration);
wl_window->pending_configurations =
g_list_prepend (wl_window->pending_configurations, configuration);
@ -378,7 +393,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
int bounds_width;
int bounds_height;
if (!meta_wayland_surface_get_buffer (window->surface) &&
if (!meta_wayland_surface_get_buffer (wl_window->surface) &&
!META_WINDOW_MAXIMIZED (window) &&
window->tile_mode == META_TILE_NONE &&
!meta_window_is_fullscreen (window))
@ -489,6 +504,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
MetaWindow *toplevel_window;
MetaLogicalMonitor *from;
MetaLogicalMonitor *to;
@ -501,7 +517,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
/* If the window is not a toplevel window (i.e. it's a popup window) just use
* the monitor of the toplevel. */
toplevel_window = meta_wayland_surface_get_toplevel_window (window->surface);
toplevel_window = meta_wayland_surface_get_toplevel_window (wl_window->surface);
if (toplevel_window != window)
{
meta_window_update_monitor (toplevel_window, flags);
@ -622,7 +638,7 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
window,
TRUE);
surface = window->surface;
surface = wl_window->surface;
if (surface)
{
MetaWaylandActorSurface *actor_surface =
@ -638,7 +654,7 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
static pid_t
meta_window_wayland_get_client_pid (MetaWindow *window)
{
MetaWaylandSurface *surface = window->surface;
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
struct wl_resource *resource = surface->resource;
pid_t pid;
@ -718,7 +734,8 @@ meta_window_wayland_can_ping (MetaWindow *window)
static gboolean
meta_window_wayland_is_stackable (MetaWindow *window)
{
return meta_wayland_surface_get_buffer (window->surface) != NULL;
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
return meta_wayland_surface_get_buffer (wl_window->surface) != NULL;
}
static gboolean
@ -735,6 +752,14 @@ meta_window_wayland_is_focus_async (MetaWindow *window)
return FALSE;
}
static MetaWaylandSurface *
meta_window_wayland_get_wayland_surface (MetaWindow *window)
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
return wl_window->surface;
}
static MetaStackLayer
meta_window_wayland_calculate_layer (MetaWindow *window)
{
@ -793,6 +818,44 @@ meta_window_wayland_finalize (GObject *object)
G_OBJECT_CLASS (meta_window_wayland_parent_class)->finalize (object);
}
static void
meta_window_wayland_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaWindowWayland *window = META_WINDOW_WAYLAND (object);
switch (prop_id)
{
case PROP_SURFACE:
g_value_set_object (value, window->surface);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_window_wayland_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaWindowWayland *window = META_WINDOW_WAYLAND (object);
switch (prop_id)
{
case PROP_SURFACE:
window->surface = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
{
@ -800,6 +863,8 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
object_class->finalize = meta_window_wayland_finalize;
object_class->get_property = meta_window_wayland_get_property;
object_class->set_property = meta_window_wayland_set_property;
object_class->constructed = meta_window_wayland_constructed;
window_class->manage = meta_window_wayland_manage;
@ -824,6 +889,16 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
window_class->map = meta_window_wayland_map;
window_class->unmap = meta_window_wayland_unmap;
window_class->is_focus_async = meta_window_wayland_is_focus_async;
window_class->get_wayland_surface = meta_window_wayland_get_wayland_surface;
obj_props[PROP_SURFACE] =
g_param_spec_object ("surface",
"Surface",
"The corresponding Wayland surface",
META_TYPE_WAYLAND_SURFACE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
}
MetaWindow *