core: Untangle meta_window_shared_new
The constructor used to take Wayland/X11 specific types which makes building without Wayland/X11 not possible. Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
This commit is contained in:

committed by
Marge Bot

parent
58e89b3a5d
commit
c3a01e4e18
@ -121,6 +121,7 @@ static void set_net_wm_state (MetaWindow *window);
|
||||
static void meta_window_set_above (MetaWindow *window,
|
||||
gboolean new_value);
|
||||
|
||||
static void meta_window_constructed (GObject *object);
|
||||
static void meta_window_show (MetaWindow *window);
|
||||
static void meta_window_hide (MetaWindow *window);
|
||||
|
||||
@ -194,6 +195,10 @@ enum
|
||||
PROP_GTK_MENUBAR_OBJECT_PATH,
|
||||
PROP_ON_ALL_WORKSPACES,
|
||||
PROP_IS_ALIVE,
|
||||
PROP_DISPLAY,
|
||||
PROP_EFFECT,
|
||||
PROP_SURFACE,
|
||||
PROP_XWINDOW,
|
||||
|
||||
PROP_LAST,
|
||||
};
|
||||
@ -407,6 +412,18 @@ meta_window_get_property(GObject *object,
|
||||
case PROP_ON_ALL_WORKSPACES:
|
||||
g_value_set_boolean (value, win->on_all_workspaces);
|
||||
break;
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, win->display);
|
||||
break;
|
||||
case PROP_EFFECT:
|
||||
g_value_set_int (value, win->pending_compositor_effect);
|
||||
break;
|
||||
case PROP_SURFACE:
|
||||
g_value_set_pointer (value, win->surface);
|
||||
break;
|
||||
case PROP_XWINDOW:
|
||||
g_value_set_ulong (value, win->xwindow);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -419,8 +436,22 @@ meta_window_set_property(GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaWindow *win = META_WINDOW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DISPLAY:
|
||||
win->display = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_EFFECT:
|
||||
win->pending_compositor_effect = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_SURFACE:
|
||||
win->surface = g_value_get_pointer (value);
|
||||
break;
|
||||
case PROP_XWINDOW:
|
||||
win->xwindow = g_value_get_ulong (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -432,6 +463,7 @@ meta_window_class_init (MetaWindowClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = meta_window_constructed;
|
||||
object_class->finalize = meta_window_finalize;
|
||||
|
||||
object_class->get_property = meta_window_get_property;
|
||||
@ -603,6 +635,29 @@ meta_window_class_init (MetaWindowClass *klass)
|
||||
TRUE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_props[PROP_DISPLAY] =
|
||||
g_param_spec_object ("display",
|
||||
"Display",
|
||||
"The display the window is attached to",
|
||||
META_TYPE_DISPLAY,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
|
||||
|
||||
obj_props[PROP_EFFECT] =
|
||||
g_param_spec_int ("effect",
|
||||
"Compositor effect",
|
||||
"The compositor effect",
|
||||
META_COMP_EFFECT_CREATE,
|
||||
META_COMP_EFFECT_NONE,
|
||||
META_COMP_EFFECT_NONE,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
|
||||
|
||||
obj_props[PROP_XWINDOW] =
|
||||
g_param_spec_ulong ("xwindow",
|
||||
"X Window",
|
||||
"The corresponding X Window",
|
||||
0, G_MAXULONG, 0,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
||||
|
||||
window_signals[WORKSPACE_CHANGED] =
|
||||
@ -946,54 +1001,21 @@ meta_window_manage (MetaWindow *window)
|
||||
META_WINDOW_GET_CLASS (window)->manage (window);
|
||||
}
|
||||
|
||||
MetaWindow *
|
||||
_meta_window_shared_new (MetaDisplay *display,
|
||||
MetaWindowClientType client_type,
|
||||
MetaWaylandSurface *surface,
|
||||
Window xwindow,
|
||||
gulong existing_wm_state,
|
||||
MetaCompEffect effect,
|
||||
XWindowAttributes *attrs)
|
||||
static void
|
||||
meta_window_constructed (GObject *object)
|
||||
{
|
||||
MetaWindow *window = META_WINDOW (object);
|
||||
MetaDisplay *display = window->display;
|
||||
MetaContext *context = meta_display_get_context (display);
|
||||
MetaBackend *backend = meta_context_get_backend (context);
|
||||
MetaWorkspaceManager *workspace_manager = display->workspace_manager;
|
||||
MetaWindow *window;
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaWindowSharedNew,
|
||||
"Window (new)");
|
||||
|
||||
g_assert (attrs != NULL);
|
||||
|
||||
meta_verbose ("attrs->map_state = %d (%s)",
|
||||
attrs->map_state,
|
||||
(attrs->map_state == IsUnmapped) ?
|
||||
"IsUnmapped" :
|
||||
(attrs->map_state == IsViewable) ?
|
||||
"IsViewable" :
|
||||
(attrs->map_state == IsUnviewable) ?
|
||||
"IsUnviewable" :
|
||||
"(unknown)");
|
||||
|
||||
if (client_type == META_WINDOW_CLIENT_TYPE_X11 && !meta_is_wayland_compositor ())
|
||||
window = g_object_new (META_TYPE_WINDOW_X11, NULL);
|
||||
#ifdef HAVE_WAYLAND
|
||||
else if (client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||
window = g_object_new (META_TYPE_WINDOW_XWAYLAND, NULL);
|
||||
else if (client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
|
||||
window = g_object_new (META_TYPE_WINDOW_WAYLAND, NULL);
|
||||
#endif
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaWindowSharedInit,
|
||||
"Window (init)");
|
||||
|
||||
window->constructing = TRUE;
|
||||
|
||||
window->client_type = client_type;
|
||||
window->surface = surface;
|
||||
window->xwindow = xwindow;
|
||||
|
||||
window->display = display;
|
||||
meta_display_register_stamp (window->display, &window->stamp, window);
|
||||
meta_display_register_stamp (display, &window->stamp, window);
|
||||
|
||||
window->workspace = NULL;
|
||||
|
||||
@ -1005,21 +1027,9 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
meta_window_update_sandboxed_app_id (window);
|
||||
meta_window_update_desc (window);
|
||||
|
||||
window->override_redirect = attrs->override_redirect;
|
||||
|
||||
/* avoid tons of stack updates */
|
||||
meta_stack_freeze (window->display->stack);
|
||||
meta_stack_freeze (display->stack);
|
||||
|
||||
window->rect.x = attrs->x;
|
||||
window->rect.y = attrs->y;
|
||||
window->rect.width = attrs->width;
|
||||
window->rect.height = attrs->height;
|
||||
|
||||
/* size_hints are the "request" */
|
||||
window->size_hints.x = attrs->x;
|
||||
window->size_hints.y = attrs->y;
|
||||
window->size_hints.width = attrs->width;
|
||||
window->size_hints.height = attrs->height;
|
||||
/* initialize the remaining size_hints as if size_hints.flags were zero */
|
||||
meta_set_normal_hints (window, NULL);
|
||||
|
||||
@ -1028,9 +1038,6 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
window->saved_rect_fullscreen = window->rect;
|
||||
window->unconstrained_rect = window->rect;
|
||||
|
||||
window->depth = attrs->depth;
|
||||
window->xvisual = attrs->visual;
|
||||
|
||||
window->title = NULL;
|
||||
|
||||
window->frame = NULL;
|
||||
@ -1056,10 +1063,8 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
window->minimized = FALSE;
|
||||
window->tab_unminimized = FALSE;
|
||||
window->iconic = FALSE;
|
||||
window->mapped = attrs->map_state != IsUnmapped;
|
||||
window->known_to_compositor = FALSE;
|
||||
window->visible_to_compositor = FALSE;
|
||||
window->pending_compositor_effect = effect;
|
||||
/* if already mapped, no need to worry about focus-on-first-time-showing */
|
||||
window->showing_for_first_time = !window->mapped;
|
||||
/* if already mapped we don't want to do the placement thing;
|
||||
@ -1092,18 +1097,6 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
window->mwm_has_move_func = TRUE;
|
||||
window->mwm_has_resize_func = TRUE;
|
||||
|
||||
switch (client_type)
|
||||
{
|
||||
case META_WINDOW_CLIENT_TYPE_X11:
|
||||
window->decorated = TRUE;
|
||||
window->hidden = FALSE;
|
||||
break;
|
||||
case META_WINDOW_CLIENT_TYPE_WAYLAND:
|
||||
window->decorated = FALSE;
|
||||
window->hidden = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
window->has_close_func = TRUE;
|
||||
window->has_minimize_func = TRUE;
|
||||
window->has_maximize_func = TRUE;
|
||||
@ -1190,23 +1183,10 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
meta_verbose ("Window %s asked to start out minimized", window->desc);
|
||||
}
|
||||
|
||||
if (existing_wm_state == IconicState)
|
||||
{
|
||||
/* WM_STATE said minimized */
|
||||
window->minimized = TRUE;
|
||||
meta_verbose ("Window %s had preexisting WM_STATE = IconicState, minimizing",
|
||||
window->desc);
|
||||
|
||||
/* Assume window was previously placed, though perhaps it's
|
||||
* been iconic its whole life, we have no way of knowing.
|
||||
*/
|
||||
window->placed = TRUE;
|
||||
}
|
||||
|
||||
/* Apply any window attributes such as initial workspace
|
||||
* based on startup notification
|
||||
*/
|
||||
meta_display_apply_startup_properties (window->display, window);
|
||||
meta_display_apply_startup_properties (display, window);
|
||||
|
||||
/* Try to get a "launch timestamp" for the window. If the window is
|
||||
* a transient, we'd like to be able to get a last-usage timestamp
|
||||
@ -1230,7 +1210,7 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
* being recorded as a fallback for potential transients
|
||||
*/
|
||||
window->net_wm_user_time =
|
||||
meta_display_get_current_time_roundtrip (window->display);
|
||||
meta_display_get_current_time_roundtrip (display);
|
||||
}
|
||||
|
||||
window->attached = meta_window_should_attach_to_parent (window);
|
||||
@ -1338,8 +1318,7 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
* means restacking it.
|
||||
*/
|
||||
if (meta_window_is_stackable (window))
|
||||
meta_stack_add (window->display->stack,
|
||||
window);
|
||||
meta_stack_add (display->stack, window);
|
||||
else if (window->override_redirect)
|
||||
window->layer = META_LAYER_OVERRIDE_REDIRECT; /* otherwise set by MetaStack */
|
||||
|
||||
@ -1352,18 +1331,18 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
set_net_wm_state (window);
|
||||
}
|
||||
|
||||
meta_compositor_add_window (window->display->compositor, window);
|
||||
meta_compositor_add_window (display->compositor, window);
|
||||
window->known_to_compositor = TRUE;
|
||||
|
||||
/* Sync stack changes */
|
||||
meta_stack_thaw (window->display->stack);
|
||||
meta_stack_thaw (display->stack);
|
||||
|
||||
/* Usually the we'll have queued a stack sync anyways, because we've
|
||||
* added a new frame window or restacked. But if an undecorated
|
||||
* window is mapped, already stacked in the right place, then we
|
||||
* might need to do this explicitly.
|
||||
*/
|
||||
meta_stack_tracker_queue_sync_stack (window->display->stack_tracker);
|
||||
meta_stack_tracker_queue_sync_stack (display->stack_tracker);
|
||||
|
||||
/* disable show desktop mode unless we're a desktop component */
|
||||
maybe_leave_show_desktop_mode (window);
|
||||
@ -1395,9 +1374,7 @@ _meta_window_shared_new (MetaDisplay *display,
|
||||
meta_display_notify_window_created (display, window);
|
||||
|
||||
if (window->wm_state_demands_attention)
|
||||
g_signal_emit_by_name (window->display, "window-demands-attention", window);
|
||||
|
||||
return window;
|
||||
g_signal_emit_by_name (display, "window-demands-attention", window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Reference in New Issue
Block a user