[mutter/wip/xwayland-on-demand: 30/32] Add MetaWorkspaceManager skeleton
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/xwayland-on-demand: 30/32] Add MetaWorkspaceManager skeleton
- Date: Mon, 28 Aug 2017 02:54:13 +0000 (UTC)
commit 26dde9dfe05a9668cb01a9b0c66dd43913e838ce
Author: Armin Krezović <krezovic armin gmail com>
Date: Sun Aug 27 20:52:42 2017 +0200
Add MetaWorkspaceManager skeleton
src/Makefile.am | 4 +
src/core/display-private.h | 1 +
src/core/display.c | 11 ++
src/core/meta-workspace-manager-private.h | 51 +++++++++
src/core/meta-workspace-manager.c | 165 +++++++++++++++++++++++++++++
src/meta/display.h | 2 +
src/meta/meta-workspace-manager.h | 37 +++++++
src/meta/types.h | 2 +
8 files changed, 273 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ce86ef0..df91e7e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -251,6 +251,9 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES = \
core/frame.h \
core/meta-gesture-tracker.c \
core/meta-gesture-tracker-private.h \
+ core/meta-workspace-manager.c \
+ core/meta-workspace-manager-private.h \
+ meta/meta-workspace-manager.h \
core/keybindings.c \
core/keybindings-private.h \
core/main-private.h \
@@ -469,6 +472,7 @@ libmutterinclude_headers = \
meta/meta-shadow-factory.h \
meta/meta-window-actor.h \
meta/meta-window-shape.h \
+ meta/meta-workspace-manager.h \
meta/meta-x11-display.h \
meta/meta-x11-errors.h \
meta/prefs.h \
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 26970ad..dca2533 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -252,6 +252,7 @@ struct _MetaDisplay
guint workspace_layout_overridden : 1;
MetaBell *bell;
+ MetaWorkspaceManager *workspace_manager;
};
struct _MetaDisplayClass
diff --git a/src/core/display.c b/src/core/display.c
index 7673956..3ebfab9 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -43,6 +43,7 @@
#include "keybindings-private.h"
#include <meta/prefs.h>
#include "workspace-private.h"
+#include "meta-workspace-manager-private.h"
#include "bell.h"
#include <meta/compositor.h>
#include <meta/compositor-mutter.h>
@@ -732,6 +733,7 @@ meta_display_open (void)
display->autoraise_timeout_id = 0;
display->autoraise_window = NULL;
display->focus_window = NULL;
+ display->workspace_manager = NULL;
display->x11_display = NULL;
display->current_cursor = -1; /* invalid/unset */
@@ -789,6 +791,8 @@ meta_display_open (void)
display->stack = meta_stack_new (display);
display->stack_tracker = meta_stack_tracker_new (display);
+ display->workspace_manager = meta_workspace_manager_new (display);
+
/* This is the default layout extracted from default
* variable values in update_num_workspaces ()
* This can be overriden using _NET_DESKTOP_LAYOUT in
@@ -1044,6 +1048,7 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->bell);
g_clear_object (&display->startup_notification);
+ g_clear_object (&display->workspace_manager);
g_object_unref (display);
the_display = NULL;
@@ -4374,3 +4379,9 @@ meta_display_workspace_switched (MetaDisplay *display,
g_signal_emit (display, display_signals[WORKSPACE_SWITCHED], 0,
from, to, direction);
}
+
+MetaWorkspaceManager *
+meta_display_get_workspace_manager (MetaDisplay *display)
+{
+ return display->workspace_manager;
+}
diff --git a/src/core/meta-workspace-manager-private.h b/src/core/meta-workspace-manager-private.h
new file mode 100644
index 0000000..1dafa50
--- /dev/null
+++ b/src/core/meta-workspace-manager-private.h
@@ -0,0 +1,51 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2002, 2003, 2004 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Rob Adams
+ * Copyright (C) 2004-2006 Elijah Newren
+ *
+ * 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/>.
+ */
+
+#ifndef META_WORKSPACE_MANAGER_PRIVATE_H
+#define META_WORKSPACE_MANAGER_PRIVATE_H
+
+#include <glib.h>
+
+#include "core/display-private.h"
+#include "meta/common.h"
+#include "meta/types.h"
+#include "meta/meta-workspace-manager.h"
+
+struct _MetaWorkspaceManager
+{
+ GObject parent;
+
+ MetaDisplay *display;
+ MetaWorkspace *active_workspace;
+
+ GList *workspaces;
+
+ int rows_of_workspaces;
+ int columns_of_workspaces;
+ MetaDisplayCorner starting_corner;
+ guint vertical_workspaces : 1;
+ guint workspace_layout_overridden : 1;
+};
+
+MetaWorkspaceManager *meta_workspace_manager_new (MetaDisplay *display);
+
+#endif /* META_WORKSPACE_MANAGER_PRIVATE_H */
diff --git a/src/core/meta-workspace-manager.c b/src/core/meta-workspace-manager.c
new file mode 100644
index 0000000..0521337
--- /dev/null
+++ b/src/core/meta-workspace-manager.c
@@ -0,0 +1,165 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2002, 2003, 2004 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Rob Adams
+ * Copyright (C) 2004-2006 Elijah Newren
+ *
+ * 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-workspace-manager-private.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "meta/meta-enum-types.h"
+
+G_DEFINE_TYPE (MetaWorkspaceManager, meta_workspace_manager, G_TYPE_OBJECT)
+
+enum
+{
+ WORKSPACE_ADDED,
+ WORKSPACE_REMOVED,
+ WORKSPACE_SWITCHED,
+ ACTIVE_WORKSPACE_CHANGED,
+ SHOWING_DESKTOP_CHANGED,
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_0,
+
+ PROP_N_WORKSPACES
+};
+
+static guint workspace_manager_signals [LAST_SIGNAL] = { 0 };
+
+static void
+meta_workspace_manager_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MetaWorkspaceManager *workspace_manager = META_WORKSPACE_MANAGER (object);
+
+ switch (prop_id)
+ {
+ case PROP_N_WORKSPACES:
+ g_value_set_int (value, meta_workspace_manager_get_n_workspaces (workspace_manager));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+meta_workspace_manager_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+meta_workspace_manager_class_init (MetaWorkspaceManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = meta_workspace_manager_get_property;
+ object_class->set_property = meta_workspace_manager_set_property;
+
+ workspace_manager_signals[WORKSPACE_ADDED] =
+ g_signal_new ("workspace-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
+ workspace_manager_signals[WORKSPACE_REMOVED] =
+ g_signal_new ("workspace-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
+ workspace_manager_signals[WORKSPACE_SWITCHED] =
+ g_signal_new ("workspace-switched",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 3,
+ G_TYPE_INT,
+ G_TYPE_INT,
+ META_TYPE_MOTION_DIRECTION);
+
+ workspace_manager_signals[ACTIVE_WORKSPACE_CHANGED] =
+ g_signal_new ("active-workspace-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ workspace_manager_signals[SHOWING_DESKTOP_CHANGED] =
+ g_signal_new ("showing-desktop-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+}
+
+static void
+meta_workspace_manager_init (MetaWorkspaceManager *workspace_manager)
+{
+}
+
+MetaWorkspaceManager *
+meta_workspace_manager_new (MetaDisplay *display)
+{
+ MetaWorkspaceManager *workspace_manager;
+
+ workspace_manager = g_object_new (META_TYPE_WORKSPACE_MANAGER, NULL);
+
+ workspace_manager->display = display;
+ workspace_manager->active_workspace = NULL;
+ workspace_manager->workspaces = NULL;
+ workspace_manager->rows_of_workspaces = 1;
+ workspace_manager->columns_of_workspaces = -1;
+ workspace_manager->vertical_workspaces = FALSE;
+ workspace_manager->starting_corner = META_DISPLAY_TOPLEFT;
+
+ return workspace_manager;
+}
+
+int
+meta_workspace_manager_get_n_workspaces (MetaWorkspaceManager *workspace_manager)
+{
+ return g_list_length (workspace_manager->workspaces);
+}
diff --git a/src/meta/display.h b/src/meta/display.h
index f688451..6d446a6 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -245,4 +245,6 @@ void meta_display_override_workspace_layout (MetaDisplay *display,
int n_rows,
int n_columns);
+MetaWorkspaceManager *meta_display_get_workspace_manager (MetaDisplay *display);
+
#endif
diff --git a/src/meta/meta-workspace-manager.h b/src/meta/meta-workspace-manager.h
new file mode 100644
index 0000000..29604f2
--- /dev/null
+++ b/src/meta/meta-workspace-manager.h
@@ -0,0 +1,37 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2002, 2003, 2004 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Rob Adams
+ * Copyright (C) 2004-2006 Elijah Newren
+ *
+ * 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/>.
+ */
+
+#ifndef META_WORKSPACE_MANAGER_H
+#define META_WORKSPACE_MANAGER_H
+
+#include <glib-object.h>
+
+#include <meta/common.h>
+#include <meta/prefs.h>
+#include <meta/types.h>
+
+#define META_TYPE_WORKSPACE_MANAGER (meta_workspace_manager_get_type ())
+G_DECLARE_FINAL_TYPE (MetaWorkspaceManager, meta_workspace_manager, META, WORKSPACE_MANAGER, GObject)
+
+int meta_workspace_manager_get_n_workspaces (MetaWorkspaceManager *workspace_manager);
+
+#endif /* META_WORKSPACE_MANAGER_H */
diff --git a/src/meta/types.h b/src/meta/types.h
index 2f286f9..f9ff90b 100644
--- a/src/meta/types.h
+++ b/src/meta/types.h
@@ -42,4 +42,6 @@ typedef struct _MetaCursorTracker MetaCursorTracker;
typedef struct _MetaDnd MetaDnd;
typedef struct _MetaSettings MetaSettings;
+typedef struct _MetaWorkspaceManager MetaWorkspaceManager;
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]