mirror of
https://github.com/brl/mutter.git
synced 2025-01-11 04:02:36 +00:00
Add MetaWorkspaceManager skeleton
https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
parent
390314adfb
commit
e05cd6009a
@ -293,6 +293,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 \
|
||||
@ -558,6 +561,7 @@ libmutterinclude_headers = \
|
||||
meta/meta-window-actor.h \
|
||||
meta/meta-window-group.h \
|
||||
meta/meta-window-shape.h \
|
||||
meta/meta-workspace-manager.h \
|
||||
meta/meta-x11-display.h \
|
||||
meta/meta-x11-errors.h \
|
||||
meta/prefs.h \
|
||||
|
@ -253,6 +253,7 @@ struct _MetaDisplay
|
||||
guint workspace_layout_overridden : 1;
|
||||
|
||||
MetaBell *bell;
|
||||
MetaWorkspaceManager *workspace_manager;
|
||||
};
|
||||
|
||||
struct _MetaDisplayClass
|
||||
|
@ -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>
|
||||
@ -731,6 +732,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
|
||||
@ -1045,6 +1049,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;
|
||||
@ -4383,3 +4388,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;
|
||||
}
|
||||
|
51
src/core/meta-workspace-manager-private.h
Normal file
51
src/core/meta-workspace-manager-private.h
Normal file
@ -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 */
|
165
src/core/meta-workspace-manager.c
Normal file
165
src/core/meta-workspace-manager.c
Normal file
@ -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);
|
||||
}
|
@ -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
|
||||
|
37
src/meta/meta-workspace-manager.h
Normal file
37
src/meta/meta-workspace-manager.h
Normal file
@ -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 */
|
@ -42,4 +42,6 @@ typedef struct _MetaCursorTracker MetaCursorTracker;
|
||||
typedef struct _MetaDnd MetaDnd;
|
||||
typedef struct _MetaSettings MetaSettings;
|
||||
|
||||
typedef struct _MetaWorkspaceManager MetaWorkspaceManager;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user