396 lines
12 KiB
Diff
396 lines
12 KiB
Diff
From 22e88d1d773bd71a62b70115c6ad5909d3128671 Mon Sep 17 00:00:00 2001
|
|
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
Date: Tue, 1 Oct 2024 15:49:34 +0200
|
|
Subject: [PATCH 03/10] window: Add a MetaWindowConfig type
|
|
|
|
This is intended to be used in place of the window rect and fullscreen
|
|
flags.
|
|
|
|
That will also allow for a pre-configuration signal to be added, passing
|
|
the configuration so that a plugin can tweak the configuration before it
|
|
gets applied first.
|
|
|
|
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
|
|
(cherry picked from commit 7e098ae671d1a580139fa65e18702d56f169082f)
|
|
---
|
|
src/core/meta-window-config-private.h | 23 +++
|
|
src/core/meta-window-config.c | 219 ++++++++++++++++++++++++++
|
|
src/meson.build | 2 +
|
|
src/meta/meson.build | 1 +
|
|
src/meta/meta-window-config.h | 72 +++++++++
|
|
src/meta/types.h | 1 +
|
|
6 files changed, 318 insertions(+)
|
|
create mode 100644 src/core/meta-window-config-private.h
|
|
create mode 100644 src/core/meta-window-config.c
|
|
create mode 100644 src/meta/meta-window-config.h
|
|
|
|
diff --git a/src/core/meta-window-config-private.h b/src/core/meta-window-config-private.h
|
|
new file mode 100644
|
|
index 0000000000..ea34b69998
|
|
--- /dev/null
|
|
+++ b/src/core/meta-window-config-private.h
|
|
@@ -0,0 +1,23 @@
|
|
+/*
|
|
+ * Copyright (C) 2024 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, see <http://www.gnu.org/licenses/>.
|
|
+ *
|
|
+ */
|
|
+
|
|
+#pragma once
|
|
+
|
|
+#include "meta/meta-window-config.h"
|
|
+
|
|
+MetaWindowConfig * meta_window_config_initial_new (void);
|
|
diff --git a/src/core/meta-window-config.c b/src/core/meta-window-config.c
|
|
new file mode 100644
|
|
index 0000000000..74f5aa81f4
|
|
--- /dev/null
|
|
+++ b/src/core/meta-window-config.c
|
|
@@ -0,0 +1,219 @@
|
|
+/*
|
|
+ * Copyright (C) 2024 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, see <http://www.gnu.org/licenses/>.
|
|
+ *
|
|
+ */
|
|
+
|
|
+#include "config.h"
|
|
+
|
|
+#include "core/meta-window-config-private.h"
|
|
+
|
|
+/**
|
|
+ * MetaWindowConfig:
|
|
+ *
|
|
+ * An object representing the configuration of a top-level window
|
|
+ *
|
|
+ */
|
|
+struct _MetaWindowConfig
|
|
+{
|
|
+ GObject parent;
|
|
+
|
|
+ /* Whether this is an initial window configuration, cannot be changed by the callee */
|
|
+ gboolean is_initial;
|
|
+
|
|
+ /* The window geometry */
|
|
+ MtkRectangle rect;
|
|
+
|
|
+ gboolean is_fullscreen;
|
|
+};
|
|
+
|
|
+G_DEFINE_FINAL_TYPE (MetaWindowConfig, meta_window_config, G_TYPE_OBJECT)
|
|
+
|
|
+enum
|
|
+{
|
|
+ PROP_0,
|
|
+
|
|
+ PROP_RECT,
|
|
+ PROP_IS_FULLSCREEN,
|
|
+
|
|
+ PROP_LAST,
|
|
+};
|
|
+
|
|
+static GParamSpec *obj_props[PROP_LAST];
|
|
+
|
|
+static void
|
|
+meta_window_config_get_property (GObject *object,
|
|
+ guint prop_id,
|
|
+ GValue *value,
|
|
+ GParamSpec *pspec)
|
|
+{
|
|
+ MetaWindowConfig *window_config = META_WINDOW_CONFIG (object);
|
|
+
|
|
+ switch (prop_id)
|
|
+ {
|
|
+ case PROP_RECT:
|
|
+ g_value_set_boxed (value, &window_config->rect);
|
|
+ break;
|
|
+ case PROP_IS_FULLSCREEN:
|
|
+ g_value_set_boolean (value, window_config->is_fullscreen);
|
|
+ break;
|
|
+ default:
|
|
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
+static void
|
|
+meta_window_config_set_property (GObject *object,
|
|
+ guint prop_id,
|
|
+ const GValue *value,
|
|
+ GParamSpec *pspec)
|
|
+{
|
|
+ MetaWindowConfig *window_config = META_WINDOW_CONFIG (object);
|
|
+ MtkRectangle *rect;
|
|
+
|
|
+ switch (prop_id)
|
|
+ {
|
|
+ case PROP_RECT:
|
|
+ rect = g_value_get_boxed (value);
|
|
+ window_config->rect = *rect;
|
|
+ break;
|
|
+ case PROP_IS_FULLSCREEN:
|
|
+ window_config->is_fullscreen = g_value_get_boolean (value);
|
|
+ break;
|
|
+ default:
|
|
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
+static void
|
|
+meta_window_config_class_init (MetaWindowConfigClass *klass)
|
|
+{
|
|
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
+
|
|
+ object_class->get_property = meta_window_config_get_property;
|
|
+ object_class->set_property = meta_window_config_set_property;
|
|
+
|
|
+ obj_props[PROP_RECT] =
|
|
+ g_param_spec_boxed ("rect", NULL, NULL,
|
|
+ MTK_TYPE_RECTANGLE,
|
|
+ G_PARAM_READWRITE |
|
|
+ G_PARAM_STATIC_STRINGS);
|
|
+
|
|
+ obj_props[PROP_IS_FULLSCREEN] =
|
|
+ g_param_spec_boolean ("is-fullscreen", NULL, NULL,
|
|
+ FALSE,
|
|
+ G_PARAM_READWRITE |
|
|
+ G_PARAM_STATIC_STRINGS);
|
|
+
|
|
+ g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
|
+}
|
|
+
|
|
+static void
|
|
+meta_window_config_init (MetaWindowConfig *window_config)
|
|
+{
|
|
+ window_config->rect = MTK_RECTANGLE_INIT (0, 0, 0, 0);
|
|
+}
|
|
+
|
|
+gboolean
|
|
+meta_window_config_get_is_initial (MetaWindowConfig *window_config)
|
|
+{
|
|
+ return window_config->is_initial;
|
|
+}
|
|
+
|
|
+void
|
|
+meta_window_config_set_rect (MetaWindowConfig *window_config,
|
|
+ MtkRectangle rect)
|
|
+{
|
|
+ window_config->rect = rect;
|
|
+}
|
|
+
|
|
+MtkRectangle
|
|
+meta_window_config_get_rect (MetaWindowConfig *window_config)
|
|
+{
|
|
+ return window_config->rect;
|
|
+}
|
|
+
|
|
+void
|
|
+meta_window_config_set_is_fullscreen (MetaWindowConfig *window_config,
|
|
+ gboolean is_fullscreen)
|
|
+{
|
|
+ window_config->is_fullscreen = is_fullscreen;
|
|
+}
|
|
+
|
|
+void
|
|
+meta_window_config_get_position (MetaWindowConfig *window_config,
|
|
+ int *x,
|
|
+ int *y)
|
|
+{
|
|
+ if (x)
|
|
+ *x = window_config->rect.x;
|
|
+ if (y)
|
|
+ *y = window_config->rect.y;
|
|
+}
|
|
+
|
|
+void
|
|
+meta_window_config_set_position (MetaWindowConfig *window_config,
|
|
+ int x,
|
|
+ int y)
|
|
+{
|
|
+ window_config->rect.x = x;
|
|
+ window_config->rect.y = y;
|
|
+}
|
|
+
|
|
+void
|
|
+meta_window_config_get_size (MetaWindowConfig *window_config,
|
|
+ int *width,
|
|
+ int *height)
|
|
+{
|
|
+ if (width)
|
|
+ *width = window_config->rect.width;
|
|
+ if (height)
|
|
+ *height = window_config->rect.height;
|
|
+}
|
|
+
|
|
+void
|
|
+meta_window_config_set_size (MetaWindowConfig *window_config,
|
|
+ int width,
|
|
+ int height)
|
|
+{
|
|
+ window_config->rect.width = width;
|
|
+ window_config->rect.height = height;
|
|
+}
|
|
+
|
|
+gboolean
|
|
+meta_window_config_get_is_fullscreen (MetaWindowConfig *window_config)
|
|
+{
|
|
+ return window_config->is_fullscreen;
|
|
+}
|
|
+
|
|
+MetaWindowConfig *
|
|
+meta_window_config_new (void)
|
|
+{
|
|
+ return g_object_new (META_TYPE_WINDOW_CONFIG,
|
|
+ NULL);
|
|
+}
|
|
+
|
|
+MetaWindowConfig *
|
|
+meta_window_config_initial_new (void)
|
|
+{
|
|
+ MetaWindowConfig *window_config;
|
|
+
|
|
+ window_config = meta_window_config_new ();
|
|
+ window_config->is_initial = TRUE;
|
|
+
|
|
+ return window_config;
|
|
+}
|
|
diff --git a/src/meson.build b/src/meson.build
|
|
index e3c92aaf27..cd47e10b98 100644
|
|
--- a/src/meson.build
|
|
+++ b/src/meson.build
|
|
@@ -377,6 +377,8 @@ mutter_sources = [
|
|
'core/meta-sound-player.c',
|
|
'core/meta-tablet-action-mapper.c',
|
|
'core/meta-tool-action-mapper.c',
|
|
+ 'core/meta-window-config.c',
|
|
+ 'core/meta-window-config-private.h',
|
|
'core/meta-workspace-manager.c',
|
|
'core/meta-workspace-manager-private.h',
|
|
'core/place.c',
|
|
diff --git a/src/meta/meson.build b/src/meta/meson.build
|
|
index 388b756682..bc9b82c8e1 100644
|
|
--- a/src/meta/meson.build
|
|
+++ b/src/meta/meson.build
|
|
@@ -40,6 +40,7 @@ mutter_public_headers = [
|
|
'meta-stage.h',
|
|
'meta-startup-notification.h',
|
|
'meta-window-actor.h',
|
|
+ 'meta-window-config.h',
|
|
'meta-window-group.h',
|
|
'meta-workspace-manager.h',
|
|
'prefs.h',
|
|
diff --git a/src/meta/meta-window-config.h b/src/meta/meta-window-config.h
|
|
new file mode 100644
|
|
index 0000000000..4e9d8ad3c3
|
|
--- /dev/null
|
|
+++ b/src/meta/meta-window-config.h
|
|
@@ -0,0 +1,72 @@
|
|
+/*
|
|
+ * Copyright (C) 2024 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, see <http://www.gnu.org/licenses/>.
|
|
+ *
|
|
+ */
|
|
+
|
|
+#pragma once
|
|
+
|
|
+#include <glib-object.h>
|
|
+
|
|
+#include "meta/common.h"
|
|
+
|
|
+#define META_TYPE_WINDOW_CONFIG (meta_window_config_get_type ())
|
|
+
|
|
+META_EXPORT
|
|
+G_DECLARE_FINAL_TYPE (MetaWindowConfig,
|
|
+ meta_window_config,
|
|
+ META,
|
|
+ WINDOW_CONFIG,
|
|
+ GObject)
|
|
+
|
|
+META_EXPORT
|
|
+MetaWindowConfig *meta_window_config_new (void);
|
|
+
|
|
+META_EXPORT
|
|
+gboolean meta_window_config_get_is_initial (MetaWindowConfig *window_config);
|
|
+
|
|
+META_EXPORT
|
|
+void meta_window_config_set_rect (MetaWindowConfig *window_config,
|
|
+ MtkRectangle rect);
|
|
+
|
|
+META_EXPORT
|
|
+MtkRectangle meta_window_config_get_rect (MetaWindowConfig *window_config);
|
|
+
|
|
+META_EXPORT
|
|
+void meta_window_config_get_position (MetaWindowConfig *window_config,
|
|
+ int *x,
|
|
+ int *y);
|
|
+
|
|
+META_EXPORT
|
|
+void meta_window_config_set_position (MetaWindowConfig *window_config,
|
|
+ int x,
|
|
+ int y);
|
|
+
|
|
+META_EXPORT
|
|
+void meta_window_config_get_size (MetaWindowConfig *window_config,
|
|
+ int *width,
|
|
+ int *height);
|
|
+
|
|
+META_EXPORT
|
|
+void meta_window_config_set_size (MetaWindowConfig *window_config,
|
|
+ int width,
|
|
+ int height);
|
|
+
|
|
+META_EXPORT
|
|
+void meta_window_config_set_is_fullscreen (MetaWindowConfig *window_config,
|
|
+ gboolean is_fullscreen);
|
|
+
|
|
+META_EXPORT
|
|
+gboolean meta_window_config_get_is_fullscreen (MetaWindowConfig *window_config);
|
|
diff --git a/src/meta/types.h b/src/meta/types.h
|
|
index 437ae609e2..cf7432ec48 100644
|
|
--- a/src/meta/types.h
|
|
+++ b/src/meta/types.h
|
|
@@ -36,3 +36,4 @@ typedef struct _MetaSettings MetaSettings;
|
|
typedef struct _MetaWorkspaceManager MetaWorkspaceManager;
|
|
typedef struct _MetaSelection MetaSelection;
|
|
typedef struct _MetaDebugControl MetaDebugControl;
|
|
+typedef struct _MetaWindowConfig MetaWindowConfig;
|
|
--
|
|
2.49.0
|
|
|