[mutter/bilelmoussaoui/untangle-window] core: Untangle meta_window_shared_new
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/untangle-window] core: Untangle meta_window_shared_new
- Date: Mon, 16 May 2022 14:50:10 +0000 (UTC)
commit d316611578f2386c191515ea9adea96fe259a2f0
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Mon May 16 16:48:01 2022 +0200
core: Untangle meta_window_shared_new
The constructor used to take Wayland/X11 specific types which makes
building without Wayland/X11 not possible.
Part of #2272
src/core/window-private.h | 10 ++---
src/core/window.c | 86 +++------------------------------------
src/wayland/meta-window-wayland.c | 40 ++++++++++--------
src/x11/window-x11.c | 67 ++++++++++++++++++++++++++----
4 files changed, 92 insertions(+), 111 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 8d2d4a0203..0ac9c780c7 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -647,13 +647,9 @@ struct _MetaWindowClass
#define META_WINDOW_ALLOWS_HORIZONTAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) &&
(w)->size_hints.min_width < (w)->size_hints.max_width)
#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) &&
(w)->size_hints.min_height < (w)->size_hints.max_height)
-MetaWindow * _meta_window_shared_new (MetaDisplay *display,
- MetaWindowClientType client_type,
- MetaWaylandSurface *surface,
- Window xwindow,
- gulong existing_wm_state,
- MetaCompEffect effect,
- XWindowAttributes *attrs);
+void _meta_window_shared_init (MetaWindow *window,
+ MetaDisplay *display,
+ MetaCompEffect effect);
void meta_window_unmanage (MetaWindow *window,
guint32 timestamp);
diff --git a/src/core/window.c b/src/core/window.c
index e22bd5a0e3..4d7019d66b 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -955,52 +955,20 @@ 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)
+void
+_meta_window_shared_init (MetaWindow *window,
+ MetaDisplay *display,
+ MetaCompEffect effect)
{
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);
@@ -1014,21 +982,10 @@ _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);
- 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);
@@ -1037,9 +994,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;
@@ -1065,7 +1019,6 @@ _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;
@@ -1101,18 +1054,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;
@@ -1199,19 +1140,6 @@ _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
*/
@@ -1405,8 +1333,6 @@ _meta_window_shared_new (MetaDisplay *display,
if (window->wm_state_demands_attention)
g_signal_emit_by_name (window->display, "window-demands-attention", window);
-
- return window;
}
static gboolean
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 2b389bfbf8..2bfd773f48 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -775,30 +775,36 @@ MetaWindow *
meta_window_wayland_new (MetaDisplay *display,
MetaWaylandSurface *surface)
{
- XWindowAttributes attrs = { 0 };
MetaWindowWayland *wl_window;
MetaWindow *window;
+ window = g_object_new (META_TYPE_WINDOW_WAYLAND, NULL);
+ window->client_type = META_WINDOW_CLIENT_TYPE_WAYLAND;
+ window->surface = surface;
+
/*
* Set attributes used by _meta_window_shared_new, don't bother trying to fake
* X11 window attributes with the rest, since they'll be ignored anyway.
*/
- attrs.x = 0;
- attrs.y = 0;
- attrs.width = 0;
- attrs.height = 0;
- attrs.depth = 24;
- attrs.visual = NULL;
- attrs.map_state = IsUnmapped;
- attrs.override_redirect = False;
-
- window = _meta_window_shared_new (display,
- META_WINDOW_CLIENT_TYPE_WAYLAND,
- surface,
- None,
- WithdrawnState,
- META_COMP_EFFECT_CREATE,
- &attrs);
+ window->override_redirect = False;
+ window->rect.x = 0;
+ window->rect.y = 0;
+ window->rect.width = 0;
+ window->rect.height = 0;
+ /* size_hints are the "request" */
+ window->size_hints.x = 0;
+ window->size_hints.y = 0;
+ window->size_hints.width = 0;
+ window->size_hints.height = 0;
+
+ window->depth = 24;
+ window->xvisual = NULL;
+
+ window->mapped = FALSE;
+
+ window->decorated = FALSE;
+ window->hidden = TRUE;
+ _meta_window_shared_init (window, display, META_COMP_EFFECT_CREATE);
wl_window = META_WINDOW_WAYLAND (window);
set_geometry_scale_for_window (wl_window, wl_window->geometry_scale);
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 617a1dfaa0..f64ae6012b 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -47,6 +47,11 @@
#include "meta/meta-later.h"
#include "meta/meta-x11-errors.h"
#include "meta/prefs.h"
+
+#ifdef HAVE_XWAYLAND
+#include "wayland/meta-window-xwayland.h"
+#endif
+
#include "x11/meta-x11-display-private.h"
#include "x11/session.h"
#include "x11/window-props.h"
@@ -3769,13 +3774,61 @@ meta_window_x11_new (MetaDisplay *display,
goto error;
}
- window = _meta_window_shared_new (display,
- META_WINDOW_CLIENT_TYPE_X11,
- NULL,
- xwindow,
- existing_wm_state,
- effect,
- &attrs);
+ if (!meta_is_wayland_compositor ())
+ window = g_object_new (META_TYPE_WINDOW_X11, NULL);
+ else
+#ifdef HAVE_XWAYLAND
+ window = g_object_new (META_TYPE_WINDOW_XWAYLAND, NULL);
+#else
+ g_assert_not_reached ();
+#endif
+ 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)");
+
+ window->client_type = META_WINDOW_CLIENT_TYPE_X11;
+ window->xwindow = xwindow;
+
+ window->override_redirect = attrs.override_redirect;
+
+ 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;
+
+ window->depth = attrs.depth;
+ window->xvisual = attrs.visual;
+ window->mapped = attrs.map_state != IsUnmapped;
+
+ window->decorated = TRUE;
+ window->hidden = FALSE;
+
+ _meta_window_shared_init (window, display, effect);
+
+ 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;
+ }
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]