2014-03-31 23:00:07 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Red Hat
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Jasper St. Pierre <jstpierre@mecheye.net>
|
|
|
|
*/
|
|
|
|
|
2018-10-19 03:15:54 -04:00
|
|
|
/**
|
|
|
|
* SECTION:meta-backend
|
|
|
|
* @title: MetaBackend
|
|
|
|
* @short_description: Handles monitor config, modesetting, cursor sprites, ...
|
|
|
|
*
|
|
|
|
* MetaBackend is the abstraction that deals with several things like:
|
|
|
|
* - Modesetting (depending on the backend, this can be done either by X or KMS)
|
|
|
|
* - Initializing the #MetaSettings
|
|
|
|
* - Setting up Monitor configuration
|
|
|
|
* - Input device configuration (using the #ClutterDeviceManager)
|
|
|
|
* - Creating the #MetaRenderer
|
|
|
|
* - Setting up the stage of the scene graph (using #MetaStage)
|
2020-08-26 05:49:50 -04:00
|
|
|
* - Creating the object that deals with the cursor (using #MetaCursorTracker)
|
2018-10-19 03:15:54 -04:00
|
|
|
* and its possible pointer constraint (using #MetaPointerConstraint)
|
|
|
|
* - Setting the cursor sprite (using #MetaCursorRenderer)
|
|
|
|
* - Interacting with logind (using the appropriate D-Bus interface)
|
|
|
|
* - Querying UPower (over D-Bus) to know when the lid is closed
|
|
|
|
* - Setup Remote Desktop / Screencasting (#MetaRemoteDesktop)
|
|
|
|
* - Setup the #MetaEgl object
|
|
|
|
*
|
|
|
|
* Note that the #MetaBackend is not a subclass of #ClutterBackend. It is
|
|
|
|
* responsible for creating the correct one, based on the backend that is
|
|
|
|
* used (#MetaBackendNative or #MetaBackendX11).
|
|
|
|
*/
|
|
|
|
|
2014-03-31 23:00:07 -04:00
|
|
|
#include "config.h"
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-backend-private.h"
|
|
|
|
|
2015-11-06 23:10:41 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-07-13 11:45:41 -04:00
|
|
|
#include "backends/meta-cursor-renderer.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-cursor-tracker-private.h"
|
2021-04-19 09:22:57 -04:00
|
|
|
#include "backends/meta-idle-manager.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-idle-monitor-private.h"
|
2020-08-04 08:17:39 -04:00
|
|
|
#include "backends/meta-input-mapper-private.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-input-settings-private.h"
|
|
|
|
#include "backends/meta-logical-monitor.h"
|
|
|
|
#include "backends/meta-monitor-manager-dummy.h"
|
|
|
|
#include "backends/meta-settings-private.h"
|
|
|
|
#include "backends/meta-stage-private.h"
|
2014-04-21 19:13:04 -04:00
|
|
|
#include "backends/x11/meta-backend-x11.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "clutter/clutter-mutter.h"
|
2021-03-12 02:34:30 -05:00
|
|
|
#include "clutter/clutter-seat-private.h"
|
2021-03-02 04:21:20 -05:00
|
|
|
#include "core/meta-context-private.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "meta/main.h"
|
|
|
|
#include "meta/meta-backend.h"
|
2021-03-03 08:31:56 -05:00
|
|
|
#include "meta/meta-context.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "meta/util.h"
|
2014-05-29 12:11:26 -04:00
|
|
|
|
2019-05-31 11:50:14 -04:00
|
|
|
#ifdef HAVE_PROFILER
|
|
|
|
#include "backends/meta-profiler.h"
|
|
|
|
#endif
|
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
#ifdef HAVE_REMOTE_DESKTOP
|
|
|
|
#include "backends/meta-dbus-session-watcher.h"
|
2018-07-20 10:37:37 -04:00
|
|
|
#include "backends/meta-remote-access-controller-private.h"
|
2017-06-21 02:23:44 -04:00
|
|
|
#include "backends/meta-remote-desktop.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-screen-cast.h"
|
2017-06-21 02:23:44 -04:00
|
|
|
#endif
|
|
|
|
|
2014-05-29 12:11:26 -04:00
|
|
|
#ifdef HAVE_NATIVE_BACKEND
|
2014-04-21 19:13:04 -04:00
|
|
|
#include "backends/native/meta-backend-native.h"
|
2014-05-29 12:11:26 -04:00
|
|
|
#endif
|
2014-04-21 19:13:04 -04:00
|
|
|
|
2020-04-27 07:30:26 -04:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
#include "wayland/meta-wayland.h"
|
|
|
|
#endif
|
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_CONTEXT,
|
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *obj_props[N_PROPS];
|
|
|
|
|
2017-03-29 02:30:10 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
KEYMAP_CHANGED,
|
|
|
|
KEYMAP_LAYOUT_GROUP_CHANGED,
|
|
|
|
LAST_DEVICE_CHANGED,
|
2018-04-16 14:07:45 -04:00
|
|
|
LID_IS_CLOSED_CHANGED,
|
2019-01-11 09:35:42 -05:00
|
|
|
GPU_ADDED,
|
2021-02-03 04:59:06 -05:00
|
|
|
PREPARE_SHUTDOWN,
|
2017-03-29 02:30:10 -04:00
|
|
|
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS];
|
|
|
|
|
2014-04-21 19:03:22 -04:00
|
|
|
static MetaBackend *_backend;
|
|
|
|
|
2017-05-06 12:45:42 -04:00
|
|
|
static gboolean stage_views_disabled = FALSE;
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
|
|
|
* meta_get_backend:
|
|
|
|
*
|
|
|
|
* Accessor for the singleton MetaBackend.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The only #MetaBackend there is.
|
|
|
|
*/
|
2014-04-21 19:03:22 -04:00
|
|
|
MetaBackend *
|
|
|
|
meta_get_backend (void)
|
|
|
|
{
|
|
|
|
return _backend;
|
|
|
|
}
|
|
|
|
|
2014-04-21 19:41:11 -04:00
|
|
|
struct _MetaBackendPrivate
|
|
|
|
{
|
2021-03-03 08:31:56 -05:00
|
|
|
MetaContext *context;
|
|
|
|
|
2014-04-21 19:41:11 -04:00
|
|
|
MetaMonitorManager *monitor_manager;
|
2017-04-28 11:49:00 -04:00
|
|
|
MetaOrientationManager *orientation_manager;
|
2016-11-29 07:30:22 -05:00
|
|
|
MetaCursorTracker *cursor_tracker;
|
2020-08-04 08:17:39 -04:00
|
|
|
MetaInputMapper *input_mapper;
|
2021-04-19 09:22:57 -04:00
|
|
|
MetaIdleManager *idle_manager;
|
2016-05-07 11:07:46 -04:00
|
|
|
MetaRenderer *renderer;
|
2018-11-06 10:18:56 -05:00
|
|
|
#ifdef HAVE_EGL
|
2016-08-17 22:18:28 -04:00
|
|
|
MetaEgl *egl;
|
2018-11-06 10:18:56 -05:00
|
|
|
#endif
|
2017-04-21 04:40:51 -04:00
|
|
|
MetaSettings *settings;
|
2017-06-21 02:23:44 -04:00
|
|
|
#ifdef HAVE_REMOTE_DESKTOP
|
2018-07-20 10:37:37 -04:00
|
|
|
MetaRemoteAccessController *remote_access_controller;
|
2017-06-21 02:23:44 -04:00
|
|
|
MetaDbusSessionWatcher *dbus_session_watcher;
|
|
|
|
MetaScreenCast *screen_cast;
|
|
|
|
MetaRemoteDesktop *remote_desktop;
|
|
|
|
#endif
|
2019-05-31 11:50:14 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_PROFILER
|
2018-08-10 16:42:12 -04:00
|
|
|
MetaProfiler *profiler;
|
2019-05-31 11:50:14 -04:00
|
|
|
#endif
|
2017-02-24 04:48:19 -05:00
|
|
|
|
2020-03-06 08:12:59 -05:00
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
WacomDeviceDatabase *wacom_db;
|
|
|
|
#endif
|
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
ClutterContext *clutter_context;
|
2021-03-12 02:31:50 -05:00
|
|
|
ClutterSeat *default_seat;
|
2014-08-13 19:46:32 -04:00
|
|
|
ClutterActor *stage;
|
2016-02-25 18:45:50 -05:00
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
GList *gpus;
|
2020-07-13 11:45:41 -04:00
|
|
|
GList *hw_cursor_inhibitors;
|
2019-01-11 09:35:42 -05:00
|
|
|
|
2017-04-12 02:09:58 -04:00
|
|
|
gboolean is_pointer_position_initialized;
|
|
|
|
|
2016-02-25 18:45:50 -05:00
|
|
|
guint device_update_idle_id;
|
2016-12-01 03:15:16 -05:00
|
|
|
|
2019-10-04 12:23:49 -04:00
|
|
|
ClutterInputDevice *current_device;
|
2016-12-01 03:15:16 -05:00
|
|
|
|
|
|
|
MetaPointerConstraint *client_pointer_constraint;
|
2017-01-02 09:11:32 -05:00
|
|
|
MetaDnd *dnd;
|
2018-03-21 07:18:32 -04:00
|
|
|
|
2018-04-17 05:43:24 -04:00
|
|
|
guint upower_watch_id;
|
|
|
|
GDBusProxy *upower_proxy;
|
2018-04-16 14:07:45 -04:00
|
|
|
gboolean lid_is_closed;
|
2021-09-30 11:40:40 -04:00
|
|
|
gboolean on_battery;
|
2018-04-16 14:07:45 -04:00
|
|
|
|
2018-03-21 07:18:32 -04:00
|
|
|
guint sleep_signal_id;
|
|
|
|
GCancellable *cancellable;
|
|
|
|
GDBusConnection *system_bus;
|
2014-04-21 19:41:11 -04:00
|
|
|
};
|
|
|
|
typedef struct _MetaBackendPrivate MetaBackendPrivate;
|
|
|
|
|
2020-07-31 14:17:31 -04:00
|
|
|
typedef struct _MetaBackendSource MetaBackendSource;
|
|
|
|
|
|
|
|
struct _MetaBackendSource
|
|
|
|
{
|
|
|
|
GSource parent;
|
|
|
|
MetaBackend *backend;
|
|
|
|
};
|
|
|
|
|
2016-07-22 22:26:39 -04:00
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface);
|
|
|
|
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaBackend, meta_backend, G_TYPE_OBJECT,
|
|
|
|
G_ADD_PRIVATE (MetaBackend)
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
|
|
|
initable_iface_init));
|
2014-04-21 19:41:11 -04:00
|
|
|
|
2014-04-21 19:03:22 -04:00
|
|
|
static void
|
2021-01-19 16:14:01 -05:00
|
|
|
meta_backend_dispose (GObject *object)
|
2014-04-21 19:03:22 -04:00
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (object);
|
2014-04-21 19:41:11 -04:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2014-04-21 19:03:22 -04:00
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
_backend = NULL;
|
|
|
|
|
2021-04-09 18:44:45 -04:00
|
|
|
g_clear_pointer (&priv->cursor_tracker, meta_cursor_tracker_destroy);
|
2020-10-26 13:34:05 -04:00
|
|
|
g_clear_object (&priv->current_device);
|
2014-04-21 19:41:11 -04:00
|
|
|
g_clear_object (&priv->monitor_manager);
|
2017-04-28 11:49:00 -04:00
|
|
|
g_clear_object (&priv->orientation_manager);
|
2017-06-21 02:23:44 -04:00
|
|
|
#ifdef HAVE_REMOTE_DESKTOP
|
|
|
|
g_clear_object (&priv->remote_desktop);
|
|
|
|
g_clear_object (&priv->screen_cast);
|
|
|
|
g_clear_object (&priv->dbus_session_watcher);
|
2018-07-20 10:37:37 -04:00
|
|
|
g_clear_object (&priv->remote_access_controller);
|
2017-06-21 02:23:44 -04:00
|
|
|
#endif
|
2014-04-21 19:41:11 -04:00
|
|
|
|
2020-03-06 08:12:59 -05:00
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
g_clear_pointer (&priv->wacom_db, libwacom_database_destroy);
|
|
|
|
#endif
|
|
|
|
|
2018-03-21 07:18:32 -04:00
|
|
|
if (priv->sleep_signal_id)
|
2021-01-19 16:14:01 -05:00
|
|
|
{
|
|
|
|
g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
|
|
|
|
priv->sleep_signal_id = 0;
|
|
|
|
}
|
|
|
|
|
2018-04-17 05:43:24 -04:00
|
|
|
if (priv->upower_watch_id)
|
2021-01-19 16:14:01 -05:00
|
|
|
{
|
|
|
|
g_bus_unwatch_name (priv->upower_watch_id);
|
|
|
|
priv->upower_watch_id = 0;
|
|
|
|
}
|
|
|
|
|
2018-03-21 07:18:32 -04:00
|
|
|
g_cancellable_cancel (priv->cancellable);
|
|
|
|
g_clear_object (&priv->cancellable);
|
|
|
|
g_clear_object (&priv->system_bus);
|
2018-04-17 05:43:24 -04:00
|
|
|
g_clear_object (&priv->upower_proxy);
|
2018-03-21 07:18:32 -04:00
|
|
|
|
2019-11-21 18:25:30 -05:00
|
|
|
g_clear_handle_id (&priv->device_update_idle_id, g_source_remove);
|
2016-02-25 18:45:50 -05:00
|
|
|
|
2017-04-21 04:40:51 -04:00
|
|
|
g_clear_object (&priv->settings);
|
2019-05-31 11:50:14 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_PROFILER
|
2018-08-10 16:42:12 -04:00
|
|
|
g_clear_object (&priv->profiler);
|
2019-05-31 11:50:14 -04:00
|
|
|
#endif
|
2017-04-21 04:40:51 -04:00
|
|
|
|
2021-03-12 02:34:30 -05:00
|
|
|
g_clear_pointer (&priv->default_seat, clutter_seat_destroy);
|
2021-03-12 02:41:02 -05:00
|
|
|
g_clear_pointer (&priv->stage, clutter_actor_destroy);
|
2021-04-19 09:22:57 -04:00
|
|
|
g_clear_pointer (&priv->idle_manager, meta_idle_manager_free);
|
2021-04-09 18:45:01 -04:00
|
|
|
g_clear_object (&priv->renderer);
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
g_clear_pointer (&priv->clutter_context, clutter_context_free);
|
2021-04-09 18:42:46 -04:00
|
|
|
g_clear_list (&priv->gpus, g_object_unref);
|
2020-11-21 08:05:08 -05:00
|
|
|
|
2021-01-19 16:14:01 -05:00
|
|
|
G_OBJECT_CLASS (meta_backend_parent_class)->dispose (object);
|
2014-04-21 19:03:22 -04:00
|
|
|
}
|
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
void
|
2021-03-12 02:39:53 -05:00
|
|
|
meta_backend_destroy (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
g_object_run_dispose (G_OBJECT (backend));
|
|
|
|
g_object_unref (backend);
|
|
|
|
}
|
|
|
|
|
2014-08-13 19:46:32 -04:00
|
|
|
static void
|
|
|
|
meta_backend_sync_screen_size (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
meta_monitor_manager_get_screen_size (priv->monitor_manager, &width, &height);
|
|
|
|
|
|
|
|
META_BACKEND_GET_CLASS (backend)->update_screen_size (backend, width, height);
|
|
|
|
}
|
|
|
|
|
2015-03-27 10:50:59 -04:00
|
|
|
static void
|
2018-04-24 16:32:24 -04:00
|
|
|
reset_pointer_position (MetaBackend *backend)
|
2015-03-27 10:50:59 -04:00
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2016-11-25 01:31:38 -05:00
|
|
|
MetaMonitorManager *monitor_manager = priv->monitor_manager;
|
2021-09-16 05:12:08 -04:00
|
|
|
ClutterSeat *seat = priv->default_seat;
|
2016-11-28 07:43:27 -05:00
|
|
|
MetaLogicalMonitor *primary;
|
|
|
|
|
|
|
|
primary =
|
|
|
|
meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
|
|
|
|
2018-04-24 16:32:24 -04:00
|
|
|
/* Move the pointer out of the way to avoid hovering over reactive
|
|
|
|
* elements (e.g. users list at login) causing undesired behaviour. */
|
2019-10-09 12:01:34 -04:00
|
|
|
clutter_seat_warp_pointer (seat,
|
2018-04-24 16:32:24 -04:00
|
|
|
primary->rect.x + primary->rect.width * 0.9,
|
|
|
|
primary->rect.y + primary->rect.height * 0.9);
|
2015-03-27 10:50:59 -04:00
|
|
|
}
|
|
|
|
|
2020-07-10 17:28:50 -04:00
|
|
|
static gboolean
|
|
|
|
should_have_cursor_renderer (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
switch (clutter_input_device_get_device_type (device))
|
|
|
|
{
|
|
|
|
case CLUTTER_POINTER_DEVICE:
|
|
|
|
if (clutter_input_device_get_device_mode (device) ==
|
|
|
|
CLUTTER_INPUT_MODE_LOGICAL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
case CLUTTER_TABLET_DEVICE:
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_cursors (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2021-09-16 05:12:08 -04:00
|
|
|
ClutterSeat *seat = priv->default_seat;
|
2020-07-10 17:28:50 -04:00
|
|
|
MetaCursorRenderer *cursor_renderer;
|
|
|
|
ClutterInputDevice *pointer, *device;
|
|
|
|
GList *devices, *l;
|
|
|
|
|
|
|
|
pointer = clutter_seat_get_pointer (seat);
|
|
|
|
devices = clutter_seat_list_devices (seat);
|
|
|
|
devices = g_list_prepend (devices, pointer);
|
|
|
|
|
|
|
|
for (l = devices; l; l = l->next)
|
|
|
|
{
|
|
|
|
device = l->data;
|
|
|
|
|
|
|
|
if (!should_have_cursor_renderer (device))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cursor_renderer = meta_backend_get_cursor_renderer_for_device (backend,
|
|
|
|
device);
|
|
|
|
if (cursor_renderer)
|
|
|
|
meta_cursor_renderer_force_update (cursor_renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (devices);
|
|
|
|
}
|
|
|
|
|
2016-07-06 03:27:45 -04:00
|
|
|
void
|
|
|
|
meta_backend_monitors_changed (MetaBackend *backend)
|
2014-08-13 19:46:32 -04:00
|
|
|
{
|
2017-04-21 04:40:51 -04:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2016-07-06 03:27:45 -04:00
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2021-09-16 05:12:08 -04:00
|
|
|
ClutterSeat *seat = priv->default_seat;
|
2019-10-04 15:57:26 -04:00
|
|
|
ClutterInputDevice *device = clutter_seat_get_pointer (seat);
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t point;
|
2015-03-27 10:50:59 -04:00
|
|
|
|
2014-08-13 19:46:32 -04:00
|
|
|
meta_backend_sync_screen_size (backend);
|
2015-03-27 10:50:59 -04:00
|
|
|
|
2020-11-18 09:49:02 -05:00
|
|
|
if (clutter_seat_query_state (seat, device, NULL, &point, NULL))
|
2015-03-27 10:50:59 -04:00
|
|
|
{
|
|
|
|
/* If we're outside all monitors, warp the pointer back inside */
|
2017-04-12 02:09:58 -04:00
|
|
|
if ((!meta_monitor_manager_get_logical_monitor_at (monitor_manager,
|
|
|
|
point.x, point.y) ||
|
|
|
|
!priv->is_pointer_position_initialized) &&
|
2017-01-12 00:49:36 -05:00
|
|
|
!meta_monitor_manager_is_headless (monitor_manager))
|
2017-04-12 02:09:58 -04:00
|
|
|
{
|
2018-04-24 16:32:24 -04:00
|
|
|
reset_pointer_position (backend);
|
2017-04-12 02:09:58 -04:00
|
|
|
priv->is_pointer_position_initialized = TRUE;
|
|
|
|
}
|
2015-03-27 10:50:59 -04:00
|
|
|
}
|
2017-10-13 01:12:50 -04:00
|
|
|
|
2020-07-10 17:28:50 -04:00
|
|
|
update_cursors (backend);
|
2014-08-13 19:46:32 -04:00
|
|
|
}
|
|
|
|
|
2015-02-11 11:04:13 -05:00
|
|
|
static inline gboolean
|
2019-10-04 15:57:26 -04:00
|
|
|
check_has_pointing_device (ClutterSeat *seat)
|
2015-02-11 11:04:13 -05:00
|
|
|
{
|
2019-10-04 15:57:26 -04:00
|
|
|
GList *l, *devices;
|
|
|
|
gboolean found = FALSE;
|
2015-02-11 11:04:13 -05:00
|
|
|
|
2019-10-04 15:57:26 -04:00
|
|
|
devices = clutter_seat_list_devices (seat);
|
2015-02-11 11:04:13 -05:00
|
|
|
|
2019-10-04 15:57:26 -04:00
|
|
|
for (l = devices; l; l = l->next)
|
2015-02-11 11:04:13 -05:00
|
|
|
{
|
2019-10-04 15:57:26 -04:00
|
|
|
ClutterInputDevice *device = l->data;
|
2015-02-11 11:04:13 -05:00
|
|
|
|
2020-08-31 12:47:23 -04:00
|
|
|
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
|
2015-02-11 11:04:13 -05:00
|
|
|
continue;
|
|
|
|
if (clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE ||
|
|
|
|
clutter_input_device_get_device_type (device) == CLUTTER_KEYBOARD_DEVICE)
|
|
|
|
continue;
|
|
|
|
|
2019-10-04 15:57:26 -04:00
|
|
|
found = TRUE;
|
|
|
|
break;
|
2015-02-11 11:04:13 -05:00
|
|
|
}
|
|
|
|
|
2019-10-04 15:57:26 -04:00
|
|
|
g_list_free (devices);
|
|
|
|
|
|
|
|
return found;
|
2015-02-11 11:04:13 -05:00
|
|
|
}
|
|
|
|
|
2020-10-30 10:44:52 -04:00
|
|
|
static void
|
|
|
|
on_device_added (ClutterSeat *seat,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (user_data);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2020-08-04 08:17:39 -04:00
|
|
|
ClutterInputDeviceType device_type;
|
2020-10-30 10:44:52 -04:00
|
|
|
|
2021-01-28 09:04:11 -05:00
|
|
|
if (clutter_input_device_get_device_mode (device) ==
|
|
|
|
CLUTTER_INPUT_MODE_LOGICAL)
|
|
|
|
return;
|
2020-08-04 08:17:39 -04:00
|
|
|
|
|
|
|
device_type = clutter_input_device_get_device_type (device);
|
|
|
|
|
2021-01-28 09:04:11 -05:00
|
|
|
if (device_type == CLUTTER_TOUCHSCREEN_DEVICE)
|
|
|
|
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, FALSE);
|
2021-01-28 09:08:15 -05:00
|
|
|
else if (device_type == CLUTTER_POINTER_DEVICE &&
|
|
|
|
!clutter_seat_has_touchscreen (seat))
|
|
|
|
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, TRUE);
|
2021-01-28 09:04:11 -05:00
|
|
|
|
2020-08-04 08:17:39 -04:00
|
|
|
if (device_type == CLUTTER_TOUCHSCREEN_DEVICE ||
|
|
|
|
device_type == CLUTTER_TABLET_DEVICE ||
|
|
|
|
device_type == CLUTTER_PEN_DEVICE ||
|
|
|
|
device_type == CLUTTER_ERASER_DEVICE ||
|
|
|
|
device_type == CLUTTER_CURSOR_DEVICE ||
|
|
|
|
device_type == CLUTTER_PAD_DEVICE)
|
|
|
|
meta_input_mapper_add_device (priv->input_mapper, device);
|
2020-10-30 10:44:52 -04:00
|
|
|
}
|
|
|
|
|
2014-09-04 15:06:03 -04:00
|
|
|
static void
|
2019-10-04 15:57:26 -04:00
|
|
|
on_device_removed (ClutterSeat *seat,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
gpointer user_data)
|
2014-09-04 15:06:03 -04:00
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (user_data);
|
2016-12-01 03:15:16 -05:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2014-09-04 15:06:03 -04:00
|
|
|
|
2021-01-28 09:04:11 -05:00
|
|
|
if (clutter_input_device_get_device_mode (device) ==
|
|
|
|
CLUTTER_INPUT_MODE_LOGICAL)
|
|
|
|
return;
|
|
|
|
|
2020-08-04 08:17:39 -04:00
|
|
|
meta_input_mapper_remove_device (priv->input_mapper, device);
|
|
|
|
|
2015-02-11 11:04:13 -05:00
|
|
|
/* If the device the user last interacted goes away, check again pointer
|
|
|
|
* visibility.
|
|
|
|
*/
|
2019-10-04 12:23:49 -04:00
|
|
|
if (priv->current_device == device)
|
2015-02-11 11:04:13 -05:00
|
|
|
{
|
2016-11-29 07:30:22 -05:00
|
|
|
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
2015-02-11 11:04:13 -05:00
|
|
|
gboolean has_touchscreen, has_pointing_device;
|
|
|
|
ClutterInputDeviceType device_type;
|
|
|
|
|
2020-10-26 13:34:05 -04:00
|
|
|
g_clear_object (&priv->current_device);
|
2020-07-14 18:49:08 -04:00
|
|
|
g_clear_handle_id (&priv->device_update_idle_id, g_source_remove);
|
2017-10-25 16:13:30 -04:00
|
|
|
|
2015-02-11 11:04:13 -05:00
|
|
|
device_type = clutter_input_device_get_device_type (device);
|
2020-10-15 09:41:55 -04:00
|
|
|
has_touchscreen = clutter_seat_has_touchscreen (seat);
|
2015-02-11 11:04:13 -05:00
|
|
|
|
|
|
|
if (device_type == CLUTTER_TOUCHSCREEN_DEVICE && has_touchscreen)
|
|
|
|
{
|
|
|
|
/* There's more touchscreens left, keep the pointer hidden */
|
|
|
|
meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE);
|
|
|
|
}
|
|
|
|
else if (device_type != CLUTTER_KEYBOARD_DEVICE)
|
|
|
|
{
|
2019-10-04 15:57:26 -04:00
|
|
|
has_pointing_device = check_has_pointing_device (seat);
|
2015-02-11 11:04:13 -05:00
|
|
|
meta_cursor_tracker_set_pointer_visible (cursor_tracker,
|
|
|
|
has_pointing_device &&
|
|
|
|
!has_touchscreen);
|
|
|
|
}
|
|
|
|
}
|
2020-09-25 12:51:37 -04:00
|
|
|
|
|
|
|
if (priv->current_device == device)
|
|
|
|
meta_backend_update_last_device (backend, NULL);
|
2014-09-04 15:06:03 -04:00
|
|
|
}
|
|
|
|
|
2020-08-04 08:17:39 -04:00
|
|
|
static void
|
|
|
|
input_mapper_device_mapped_cb (MetaInputMapper *mapper,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
float matrix[6],
|
2020-11-19 10:00:12 -05:00
|
|
|
MetaInputSettings *input_settings)
|
2020-08-04 08:17:39 -04:00
|
|
|
{
|
|
|
|
meta_input_settings_set_device_matrix (input_settings, device, matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
input_mapper_device_enabled_cb (MetaInputMapper *mapper,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
gboolean enabled,
|
2020-11-19 10:00:12 -05:00
|
|
|
MetaInputSettings *input_settings)
|
2020-08-04 08:17:39 -04:00
|
|
|
{
|
|
|
|
meta_input_settings_set_device_enabled (input_settings, device, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
input_mapper_device_aspect_ratio_cb (MetaInputMapper *mapper,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
double aspect_ratio,
|
2020-11-19 10:00:12 -05:00
|
|
|
MetaInputSettings *input_settings)
|
2020-08-04 08:17:39 -04:00
|
|
|
{
|
|
|
|
meta_input_settings_set_device_aspect_ratio (input_settings, device, aspect_ratio);
|
|
|
|
}
|
|
|
|
|
2020-10-28 14:41:40 -04:00
|
|
|
static void
|
|
|
|
on_stage_shown_cb (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2021-09-16 05:12:08 -04:00
|
|
|
ClutterSeat *seat = priv->default_seat;
|
2021-01-28 09:08:15 -05:00
|
|
|
g_autoptr (GList) devices = NULL;
|
|
|
|
const GList *l;
|
|
|
|
|
|
|
|
devices = clutter_seat_list_devices (seat);
|
|
|
|
for (l = devices; l; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterInputDevice *device = l->data;
|
|
|
|
|
|
|
|
if (clutter_input_device_get_device_mode (device) ==
|
|
|
|
CLUTTER_INPUT_MODE_LOGICAL)
|
|
|
|
continue;
|
2020-10-28 14:41:40 -04:00
|
|
|
|
2021-01-28 09:08:15 -05:00
|
|
|
if (clutter_input_device_get_device_type (device) !=
|
|
|
|
CLUTTER_POINTER_DEVICE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, TRUE);
|
|
|
|
break;
|
|
|
|
}
|
2020-10-28 14:41:40 -04:00
|
|
|
}
|
|
|
|
|
2014-04-22 10:14:59 -04:00
|
|
|
static void
|
|
|
|
meta_backend_real_post_init (MetaBackend *backend)
|
|
|
|
{
|
2014-04-22 14:32:55 -04:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2021-09-16 05:12:08 -04:00
|
|
|
ClutterSeat *seat = priv->default_seat;
|
2020-11-19 10:00:12 -05:00
|
|
|
MetaInputSettings *input_settings;
|
2014-04-22 14:32:55 -04:00
|
|
|
|
2019-03-25 05:24:46 -04:00
|
|
|
priv->stage = meta_stage_new (backend);
|
2014-08-13 19:46:32 -04:00
|
|
|
clutter_actor_realize (priv->stage);
|
|
|
|
META_BACKEND_GET_CLASS (backend)->select_stage_events (backend);
|
2020-10-28 14:41:40 -04:00
|
|
|
g_signal_connect_object (priv->stage, "show",
|
|
|
|
G_CALLBACK (on_stage_shown_cb), backend,
|
|
|
|
G_CONNECT_SWAPPED);
|
2014-08-13 19:46:32 -04:00
|
|
|
|
2017-07-05 06:06:06 -04:00
|
|
|
meta_monitor_manager_setup (priv->monitor_manager);
|
2014-08-13 19:46:32 -04:00
|
|
|
|
|
|
|
meta_backend_sync_screen_size (backend);
|
|
|
|
|
2021-04-19 09:22:57 -04:00
|
|
|
priv->idle_manager = meta_idle_manager_new (backend);
|
2014-09-04 15:06:03 -04:00
|
|
|
|
2019-10-04 15:57:26 -04:00
|
|
|
g_signal_connect_object (seat, "device-added",
|
2017-04-10 04:33:00 -04:00
|
|
|
G_CALLBACK (on_device_added), backend, 0);
|
2019-10-04 15:57:26 -04:00
|
|
|
g_signal_connect_object (seat, "device-removed",
|
2020-07-15 11:52:37 -04:00
|
|
|
G_CALLBACK (on_device_removed), backend,
|
|
|
|
G_CONNECT_AFTER);
|
2015-02-11 11:04:13 -05:00
|
|
|
|
2020-08-04 08:17:39 -04:00
|
|
|
priv->input_mapper = meta_input_mapper_new ();
|
2020-11-19 10:00:12 -05:00
|
|
|
|
|
|
|
input_settings = meta_backend_get_input_settings (backend);
|
|
|
|
|
|
|
|
if (input_settings)
|
|
|
|
{
|
|
|
|
g_signal_connect (priv->input_mapper, "device-mapped",
|
|
|
|
G_CALLBACK (input_mapper_device_mapped_cb),
|
|
|
|
input_settings);
|
|
|
|
g_signal_connect (priv->input_mapper, "device-enabled",
|
|
|
|
G_CALLBACK (input_mapper_device_enabled_cb),
|
|
|
|
input_settings);
|
|
|
|
g_signal_connect (priv->input_mapper, "device-aspect-ratio",
|
|
|
|
G_CALLBACK (input_mapper_device_aspect_ratio_cb),
|
|
|
|
input_settings);
|
|
|
|
}
|
2020-08-04 08:17:39 -04:00
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
#ifdef HAVE_REMOTE_DESKTOP
|
|
|
|
priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL);
|
2018-12-12 05:35:58 -05:00
|
|
|
priv->screen_cast = meta_screen_cast_new (backend,
|
|
|
|
priv->dbus_session_watcher);
|
2021-02-23 02:59:43 -05:00
|
|
|
priv->remote_desktop = meta_remote_desktop_new (backend,
|
|
|
|
priv->dbus_session_watcher);
|
2020-04-21 09:44:32 -04:00
|
|
|
priv->remote_access_controller =
|
|
|
|
meta_remote_access_controller_new (priv->remote_desktop, priv->screen_cast);
|
2017-06-21 02:23:44 -04:00
|
|
|
#endif /* HAVE_REMOTE_DESKTOP */
|
2017-04-12 02:09:58 -04:00
|
|
|
|
|
|
|
if (!meta_monitor_manager_is_headless (priv->monitor_manager))
|
|
|
|
{
|
2018-04-24 16:32:24 -04:00
|
|
|
reset_pointer_position (backend);
|
2017-04-12 02:09:58 -04:00
|
|
|
priv->is_pointer_position_initialized = TRUE;
|
|
|
|
}
|
2020-06-11 12:18:37 -04:00
|
|
|
|
|
|
|
meta_monitor_manager_post_init (priv->monitor_manager);
|
2014-04-22 15:15:11 -04:00
|
|
|
}
|
|
|
|
|
2014-04-23 10:50:07 -04:00
|
|
|
static gboolean
|
|
|
|
meta_backend_real_grab_device (MetaBackend *backend,
|
|
|
|
int device_id,
|
|
|
|
uint32_t timestamp)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_backend_real_ungrab_device (MetaBackend *backend,
|
|
|
|
int device_id,
|
|
|
|
uint32_t timestamp)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-08-13 19:46:32 -04:00
|
|
|
static void
|
|
|
|
meta_backend_real_select_stage_events (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
|
|
|
|
2018-04-16 14:07:45 -04:00
|
|
|
static gboolean
|
|
|
|
meta_backend_real_is_lid_closed (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->lid_is_closed;
|
|
|
|
}
|
|
|
|
|
2020-07-29 05:06:43 -04:00
|
|
|
static MetaCursorTracker *
|
|
|
|
meta_backend_real_create_cursor_tracker (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_CURSOR_TRACKER,
|
|
|
|
"backend", backend,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2018-04-16 14:07:45 -04:00
|
|
|
gboolean
|
|
|
|
meta_backend_is_lid_closed (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->is_lid_closed (backend);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-17 05:43:24 -04:00
|
|
|
upower_properties_changed (GDBusProxy *proxy,
|
|
|
|
GVariant *changed_properties,
|
|
|
|
GStrv invalidated_properties,
|
|
|
|
gpointer user_data)
|
2018-04-16 14:07:45 -04:00
|
|
|
{
|
|
|
|
MetaBackend *backend = user_data;
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2018-04-17 05:43:24 -04:00
|
|
|
GVariant *v;
|
2021-09-30 11:39:28 -04:00
|
|
|
gboolean reset_idle_time = FALSE;
|
2018-04-16 14:07:45 -04:00
|
|
|
|
2018-04-17 05:43:24 -04:00
|
|
|
v = g_variant_lookup_value (changed_properties,
|
|
|
|
"LidIsClosed",
|
|
|
|
G_VARIANT_TYPE_BOOLEAN);
|
2021-09-30 11:39:28 -04:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
gboolean lid_is_closed;
|
2018-04-17 05:43:24 -04:00
|
|
|
|
2021-09-30 11:39:28 -04:00
|
|
|
lid_is_closed = g_variant_get_boolean (v);
|
|
|
|
g_variant_unref (v);
|
2018-04-17 05:43:24 -04:00
|
|
|
|
2021-09-30 11:39:28 -04:00
|
|
|
if (lid_is_closed != priv->lid_is_closed)
|
|
|
|
{
|
|
|
|
priv->lid_is_closed = lid_is_closed;
|
|
|
|
g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
|
|
|
|
priv->lid_is_closed);
|
2018-04-16 14:07:45 -04:00
|
|
|
|
2021-09-30 11:39:28 -04:00
|
|
|
if (lid_is_closed)
|
|
|
|
reset_idle_time = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2018-04-16 14:07:45 -04:00
|
|
|
|
2021-09-30 11:40:40 -04:00
|
|
|
v = g_variant_lookup_value (changed_properties,
|
|
|
|
"OnBattery",
|
|
|
|
G_VARIANT_TYPE_BOOLEAN);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
gboolean on_battery;
|
|
|
|
|
|
|
|
on_battery = g_variant_get_boolean (v);
|
|
|
|
g_variant_unref (v);
|
|
|
|
|
|
|
|
if (on_battery != priv->on_battery)
|
|
|
|
{
|
|
|
|
priv->on_battery = on_battery;
|
|
|
|
reset_idle_time = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-30 11:39:28 -04:00
|
|
|
if (reset_idle_time)
|
|
|
|
meta_idle_manager_reset_idle_time (priv->idle_manager);
|
2018-04-16 14:07:45 -04:00
|
|
|
}
|
|
|
|
|
2018-04-17 05:43:24 -04:00
|
|
|
static void
|
|
|
|
upower_ready_cb (GObject *source_object,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaBackend *backend;
|
|
|
|
MetaBackendPrivate *priv;
|
|
|
|
GDBusProxy *proxy;
|
|
|
|
GError *error = NULL;
|
|
|
|
GVariant *v;
|
|
|
|
|
|
|
|
proxy = g_dbus_proxy_new_finish (res, &error);
|
|
|
|
if (!proxy)
|
|
|
|
{
|
|
|
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
g_warning ("Failed to create UPower proxy: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
backend = META_BACKEND (user_data);
|
|
|
|
priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
priv->upower_proxy = proxy;
|
|
|
|
g_signal_connect (proxy, "g-properties-changed",
|
|
|
|
G_CALLBACK (upower_properties_changed), backend);
|
|
|
|
|
|
|
|
v = g_dbus_proxy_get_cached_property (proxy, "LidIsClosed");
|
2021-09-30 11:39:28 -04:00
|
|
|
if (v)
|
2018-04-17 05:43:24 -04:00
|
|
|
{
|
2021-09-30 11:39:28 -04:00
|
|
|
priv->lid_is_closed = g_variant_get_boolean (v);
|
|
|
|
g_variant_unref (v);
|
|
|
|
|
|
|
|
if (priv->lid_is_closed)
|
|
|
|
{
|
|
|
|
g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
|
|
|
|
priv->lid_is_closed);
|
|
|
|
}
|
2018-04-17 05:43:24 -04:00
|
|
|
}
|
2021-09-30 11:40:40 -04:00
|
|
|
|
|
|
|
v = g_dbus_proxy_get_cached_property (proxy, "OnBattery");
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
priv->on_battery = g_variant_get_boolean (v);
|
|
|
|
g_variant_unref (v);
|
|
|
|
}
|
2018-04-17 05:43:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
upower_appeared (GDBusConnection *connection,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *name_owner,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (user_data);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
g_dbus_proxy_new (connection,
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
NULL,
|
|
|
|
"org.freedesktop.UPower",
|
|
|
|
"/org/freedesktop/UPower",
|
|
|
|
"org.freedesktop.UPower",
|
|
|
|
priv->cancellable,
|
|
|
|
upower_ready_cb,
|
|
|
|
backend);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
upower_vanished (GDBusConnection *connection,
|
|
|
|
const gchar *name,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (user_data);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
g_clear_object (&priv->upower_proxy);
|
|
|
|
}
|
|
|
|
|
2018-04-16 14:07:45 -04:00
|
|
|
static void
|
|
|
|
meta_backend_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (object);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
MetaBackendClass *backend_class =
|
|
|
|
META_BACKEND_GET_CLASS (backend);
|
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
g_assert (priv->context);
|
|
|
|
|
2020-03-06 08:12:59 -05:00
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
priv->wacom_db = libwacom_database_new ();
|
|
|
|
if (!priv->wacom_db)
|
|
|
|
{
|
|
|
|
g_warning ("Could not create database of Wacom devices, "
|
|
|
|
"expect tablets to misbehave");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-04-16 14:07:45 -04:00
|
|
|
if (backend_class->is_lid_closed != meta_backend_real_is_lid_closed)
|
|
|
|
return;
|
|
|
|
|
2018-04-17 05:43:24 -04:00
|
|
|
priv->upower_watch_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
|
|
|
|
"org.freedesktop.UPower",
|
|
|
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
|
|
|
upower_appeared,
|
|
|
|
upower_vanished,
|
|
|
|
backend,
|
|
|
|
NULL);
|
2018-04-16 14:07:45 -04:00
|
|
|
}
|
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
static void
|
|
|
|
meta_backend_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (object);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
priv->context = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_backend_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (object);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, priv->context);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-21 19:03:22 -04:00
|
|
|
static void
|
|
|
|
meta_backend_class_init (MetaBackendClass *klass)
|
|
|
|
{
|
2017-05-06 12:45:42 -04:00
|
|
|
const gchar *mutter_stage_views;
|
2014-04-21 19:03:22 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2021-01-19 16:14:01 -05:00
|
|
|
object_class->dispose = meta_backend_dispose;
|
2018-04-16 14:07:45 -04:00
|
|
|
object_class->constructed = meta_backend_constructed;
|
2021-03-03 08:31:56 -05:00
|
|
|
object_class->set_property = meta_backend_set_property;
|
|
|
|
object_class->get_property = meta_backend_get_property;
|
2014-04-22 10:14:59 -04:00
|
|
|
|
|
|
|
klass->post_init = meta_backend_real_post_init;
|
2014-04-23 10:50:07 -04:00
|
|
|
klass->grab_device = meta_backend_real_grab_device;
|
|
|
|
klass->ungrab_device = meta_backend_real_ungrab_device;
|
2014-08-13 19:46:32 -04:00
|
|
|
klass->select_stage_events = meta_backend_real_select_stage_events;
|
2018-04-16 14:07:45 -04:00
|
|
|
klass->is_lid_closed = meta_backend_real_is_lid_closed;
|
2020-07-29 05:06:43 -04:00
|
|
|
klass->create_cursor_tracker = meta_backend_real_create_cursor_tracker;
|
2014-08-14 17:32:41 -04:00
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
obj_props[PROP_CONTEXT] =
|
|
|
|
g_param_spec_object ("context",
|
|
|
|
"context",
|
|
|
|
"MetaContext",
|
|
|
|
META_TYPE_CONTEXT,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
|
|
|
|
2017-03-29 02:30:10 -04:00
|
|
|
signals[KEYMAP_CHANGED] =
|
|
|
|
g_signal_new ("keymap-changed",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
signals[KEYMAP_LAYOUT_GROUP_CHANGED] =
|
|
|
|
g_signal_new ("keymap-layout-group-changed",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_UINT);
|
|
|
|
signals[LAST_DEVICE_CHANGED] =
|
|
|
|
g_signal_new ("last-device-changed",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
2019-10-04 12:23:49 -04:00
|
|
|
G_TYPE_NONE, 1, CLUTTER_TYPE_INPUT_DEVICE);
|
2018-04-16 14:07:45 -04:00
|
|
|
signals[LID_IS_CLOSED_CHANGED] =
|
|
|
|
g_signal_new ("lid-is-closed-changed",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
2019-01-11 09:35:42 -05:00
|
|
|
/**
|
|
|
|
* MetaBackend::gpu-added: (skip)
|
|
|
|
* @backend: the #MetaBackend
|
|
|
|
* @gpu: the #MetaGpu
|
|
|
|
*/
|
|
|
|
signals[GPU_ADDED] =
|
|
|
|
g_signal_new ("gpu-added",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1, META_TYPE_GPU);
|
2021-02-03 04:59:06 -05:00
|
|
|
signals[PREPARE_SHUTDOWN] =
|
|
|
|
g_signal_new ("prepare-shutdown",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
2017-05-06 12:45:42 -04:00
|
|
|
|
|
|
|
mutter_stage_views = g_getenv ("MUTTER_STAGE_VIEWS");
|
|
|
|
stage_views_disabled = g_strcmp0 (mutter_stage_views, "0") == 0;
|
2014-04-21 19:03:22 -04:00
|
|
|
}
|
|
|
|
|
2017-07-05 06:06:06 -04:00
|
|
|
static MetaMonitorManager *
|
2017-07-06 04:00:56 -04:00
|
|
|
meta_backend_create_monitor_manager (MetaBackend *backend,
|
|
|
|
GError **error)
|
2017-07-05 06:06:06 -04:00
|
|
|
{
|
2017-07-06 04:00:56 -04:00
|
|
|
return META_BACKEND_GET_CLASS (backend)->create_monitor_manager (backend,
|
|
|
|
error);
|
2017-07-05 06:06:06 -04:00
|
|
|
}
|
|
|
|
|
2017-07-05 06:01:47 -04:00
|
|
|
static MetaRenderer *
|
|
|
|
meta_backend_create_renderer (MetaBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->create_renderer (backend, error);
|
|
|
|
}
|
|
|
|
|
2018-03-21 07:18:32 -04:00
|
|
|
static void
|
|
|
|
prepare_for_sleep_cb (GDBusConnection *connection,
|
|
|
|
const gchar *sender_name,
|
|
|
|
const gchar *object_path,
|
|
|
|
const gchar *interface_name,
|
|
|
|
const gchar *signal_name,
|
|
|
|
GVariant *parameters,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2021-04-19 09:22:57 -04:00
|
|
|
MetaBackend *backend = user_data;
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2018-03-21 07:18:32 -04:00
|
|
|
gboolean suspending;
|
|
|
|
|
|
|
|
g_variant_get (parameters, "(b)", &suspending);
|
|
|
|
if (suspending)
|
|
|
|
return;
|
2021-04-19 09:22:57 -04:00
|
|
|
|
|
|
|
meta_idle_manager_reset_idle_time (priv->idle_manager);
|
2018-03-21 07:18:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
system_bus_gotten_cb (GObject *object,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2021-04-19 09:22:57 -04:00
|
|
|
MetaBackend *backend = user_data;
|
2018-03-21 07:18:32 -04:00
|
|
|
MetaBackendPrivate *priv;
|
|
|
|
GDBusConnection *bus;
|
|
|
|
|
|
|
|
bus = g_bus_get_finish (res, NULL);
|
|
|
|
if (!bus)
|
|
|
|
return;
|
|
|
|
|
2021-04-19 09:22:57 -04:00
|
|
|
priv = meta_backend_get_instance_private (backend);
|
2018-03-21 07:18:32 -04:00
|
|
|
priv->system_bus = bus;
|
|
|
|
priv->sleep_signal_id =
|
|
|
|
g_dbus_connection_signal_subscribe (priv->system_bus,
|
|
|
|
"org.freedesktop.login1",
|
|
|
|
"org.freedesktop.login1.Manager",
|
|
|
|
"PrepareForSleep",
|
|
|
|
"/org/freedesktop/login1",
|
|
|
|
NULL,
|
|
|
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
|
|
|
prepare_for_sleep_cb,
|
2021-04-19 09:22:57 -04:00
|
|
|
backend,
|
2018-03-21 07:18:32 -04:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2020-04-27 07:30:26 -04:00
|
|
|
/* Mutter is responsible for pulling events off the X queue, so Clutter
|
|
|
|
* doesn't need (and shouldn't) run its normal event source which polls
|
|
|
|
* the X fd, but we do have to deal with dispatching events that accumulate
|
|
|
|
* in the clutter queue. This happens, for example, when clutter generate
|
|
|
|
* enter/leave events on mouse motion - several events are queued in the
|
|
|
|
* clutter queue but only one dispatched. It could also happen because of
|
|
|
|
* explicit calls to clutter_event_put(). We add a very simple custom
|
|
|
|
* event loop source which is simply responsible for pulling events off
|
|
|
|
* of the queue and dispatching them before we block for new events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_source_prepare (GSource *source,
|
|
|
|
int *timeout)
|
|
|
|
{
|
|
|
|
*timeout = -1;
|
|
|
|
|
|
|
|
return clutter_events_pending ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_source_check (GSource *source)
|
|
|
|
{
|
|
|
|
return clutter_events_pending ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_source_dispatch (GSource *source,
|
|
|
|
GSourceFunc callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2020-07-31 14:17:31 -04:00
|
|
|
MetaBackendSource *backend_source = (MetaBackendSource *) source;
|
2020-04-27 07:30:26 -04:00
|
|
|
ClutterEvent *event = clutter_event_get ();
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
{
|
2020-07-31 14:17:31 -04:00
|
|
|
event->any.stage =
|
|
|
|
CLUTTER_STAGE (meta_backend_get_stage (backend_source->backend));
|
2020-04-27 07:30:26 -04:00
|
|
|
clutter_do_event (event);
|
|
|
|
clutter_event_free (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GSourceFuncs clutter_source_funcs = {
|
|
|
|
clutter_source_prepare,
|
|
|
|
clutter_source_check,
|
|
|
|
clutter_source_dispatch
|
|
|
|
};
|
|
|
|
|
|
|
|
static ClutterBackend *
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
meta_clutter_backend_constructor (gpointer user_data)
|
2020-04-27 07:30:26 -04:00
|
|
|
{
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
MetaBackend *backend = META_BACKEND (user_data);
|
2020-04-27 07:30:26 -04:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
return META_BACKEND_GET_CLASS (backend)->create_clutter_backend (backend);
|
2020-04-27 07:30:26 -04:00
|
|
|
}
|
|
|
|
|
2021-03-12 02:31:50 -05:00
|
|
|
static ClutterSeat *
|
|
|
|
meta_backend_create_default_seat (MetaBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->create_default_seat (backend, error);
|
|
|
|
}
|
|
|
|
|
2020-04-27 07:30:26 -04:00
|
|
|
static gboolean
|
|
|
|
init_clutter (MetaBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2021-03-12 02:31:50 -05:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2020-07-31 14:17:31 -04:00
|
|
|
MetaBackendSource *backend_source;
|
2020-04-27 07:30:26 -04:00
|
|
|
GSource *source;
|
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
priv->clutter_context = clutter_context_new (meta_clutter_backend_constructor,
|
|
|
|
backend,
|
|
|
|
error);
|
|
|
|
if (!priv->clutter_context)
|
2021-09-14 10:51:57 -04:00
|
|
|
return FALSE;
|
2020-04-27 07:30:26 -04:00
|
|
|
|
2021-03-12 02:31:50 -05:00
|
|
|
priv->default_seat = meta_backend_create_default_seat (backend, error);
|
|
|
|
if (!priv->default_seat)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-07-31 14:17:31 -04:00
|
|
|
source = g_source_new (&clutter_source_funcs, sizeof (MetaBackendSource));
|
|
|
|
backend_source = (MetaBackendSource *) source;
|
|
|
|
backend_source->backend = backend;
|
2020-04-27 07:30:26 -04:00
|
|
|
g_source_attach (source, NULL);
|
|
|
|
g_source_unref (source);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_backend_post_init (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
META_BACKEND_GET_CLASS (backend)->post_init (backend);
|
|
|
|
|
|
|
|
meta_settings_post_init (priv->settings);
|
|
|
|
}
|
|
|
|
|
2016-07-22 22:26:39 -04:00
|
|
|
static gboolean
|
|
|
|
meta_backend_initable_init (GInitable *initable,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (initable);
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
2017-04-21 04:40:51 -04:00
|
|
|
priv->settings = meta_settings_new (backend);
|
2017-02-24 04:48:19 -05:00
|
|
|
|
2018-11-06 10:18:56 -05:00
|
|
|
#ifdef HAVE_EGL
|
2016-08-17 22:18:28 -04:00
|
|
|
priv->egl = g_object_new (META_TYPE_EGL, NULL);
|
2018-11-06 10:18:56 -05:00
|
|
|
#endif
|
2016-08-17 22:18:28 -04:00
|
|
|
|
2017-07-05 06:06:06 -04:00
|
|
|
priv->orientation_manager = g_object_new (META_TYPE_ORIENTATION_MANAGER, NULL);
|
|
|
|
|
2017-07-06 04:00:56 -04:00
|
|
|
priv->monitor_manager = meta_backend_create_monitor_manager (backend, error);
|
|
|
|
if (!priv->monitor_manager)
|
|
|
|
return FALSE;
|
|
|
|
|
2017-07-05 06:01:47 -04:00
|
|
|
priv->renderer = meta_backend_create_renderer (backend, error);
|
2016-07-22 22:26:39 -04:00
|
|
|
if (!priv->renderer)
|
2017-07-05 06:01:47 -04:00
|
|
|
return FALSE;
|
2016-07-22 22:26:39 -04:00
|
|
|
|
2020-07-29 05:06:43 -04:00
|
|
|
priv->cursor_tracker =
|
|
|
|
META_BACKEND_GET_CLASS (backend)->create_cursor_tracker (backend);
|
2016-11-29 07:30:22 -05:00
|
|
|
|
2017-01-02 09:11:32 -05:00
|
|
|
priv->dnd = g_object_new (META_TYPE_DND, NULL);
|
2017-04-28 11:49:00 -04:00
|
|
|
|
2018-03-21 07:18:32 -04:00
|
|
|
priv->cancellable = g_cancellable_new ();
|
|
|
|
g_bus_get (G_BUS_TYPE_SYSTEM,
|
|
|
|
priv->cancellable,
|
|
|
|
system_bus_gotten_cb,
|
|
|
|
backend);
|
|
|
|
|
2019-05-31 11:50:14 -04:00
|
|
|
#ifdef HAVE_PROFILER
|
2018-08-10 16:42:12 -04:00
|
|
|
priv->profiler = meta_profiler_new ();
|
2019-05-31 11:50:14 -04:00
|
|
|
#endif
|
2018-08-10 16:42:12 -04:00
|
|
|
|
2020-04-27 07:30:26 -04:00
|
|
|
if (!init_clutter (backend, error))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
meta_backend_post_init (backend);
|
|
|
|
|
2016-07-22 22:26:39 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface)
|
|
|
|
{
|
|
|
|
initable_iface->init = meta_backend_initable_init;
|
|
|
|
}
|
|
|
|
|
2014-04-21 19:03:22 -04:00
|
|
|
static void
|
|
|
|
meta_backend_init (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
_backend = backend;
|
|
|
|
}
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_idle_monitor: (skip)
|
|
|
|
*/
|
2014-04-21 19:03:22 -04:00
|
|
|
MetaIdleMonitor *
|
2019-10-09 10:03:24 -04:00
|
|
|
meta_backend_get_idle_monitor (MetaBackend *backend,
|
|
|
|
ClutterInputDevice *device)
|
2014-04-21 19:03:22 -04:00
|
|
|
{
|
2016-12-01 03:15:16 -05:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
2021-04-19 09:22:57 -04:00
|
|
|
return meta_idle_manager_get_monitor (priv->idle_manager, device);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_backend_get_core_idle_monitor:
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): the #MetaIdleMonitor that tracks server-global
|
|
|
|
* idle time for all devices.
|
|
|
|
*/
|
|
|
|
MetaIdleMonitor *
|
|
|
|
meta_backend_get_core_idle_monitor (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return meta_idle_manager_get_core_monitor (priv->idle_manager);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_backend_get_idle_manager: (skip)
|
|
|
|
*/
|
|
|
|
MetaIdleManager *
|
|
|
|
meta_backend_get_idle_manager (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->idle_manager;
|
2014-04-21 19:03:22 -04:00
|
|
|
}
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
2021-12-02 16:02:02 -05:00
|
|
|
* meta_backend_get_monitor_manager:
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): A #MetaMonitorManager
|
2014-08-05 08:11:59 -04:00
|
|
|
*/
|
2014-04-21 19:41:11 -04:00
|
|
|
MetaMonitorManager *
|
|
|
|
meta_backend_get_monitor_manager (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->monitor_manager;
|
|
|
|
}
|
|
|
|
|
2017-04-28 11:49:00 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_orientation_manager: (skip)
|
|
|
|
*/
|
|
|
|
MetaOrientationManager *
|
|
|
|
meta_backend_get_orientation_manager (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->orientation_manager;
|
|
|
|
}
|
|
|
|
|
2016-11-29 07:30:22 -05:00
|
|
|
MetaCursorTracker *
|
|
|
|
meta_backend_get_cursor_tracker (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->cursor_tracker;
|
|
|
|
}
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_cursor_renderer: (skip)
|
|
|
|
*/
|
2014-04-22 14:32:55 -04:00
|
|
|
MetaCursorRenderer *
|
|
|
|
meta_backend_get_cursor_renderer (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2020-07-10 17:28:50 -04:00
|
|
|
ClutterInputDevice *pointer;
|
|
|
|
|
2021-09-16 05:12:08 -04:00
|
|
|
pointer = clutter_seat_get_pointer (priv->default_seat);
|
2020-07-10 17:28:50 -04:00
|
|
|
|
|
|
|
return meta_backend_get_cursor_renderer_for_device (backend, pointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaCursorRenderer *
|
|
|
|
meta_backend_get_cursor_renderer_for_device (MetaBackend *backend,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (META_IS_BACKEND (backend), NULL);
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
g_return_val_if_fail (clutter_input_device_get_device_type (device) !=
|
|
|
|
CLUTTER_KEYBOARD_DEVICE, NULL);
|
2014-04-22 14:32:55 -04:00
|
|
|
|
2020-07-10 17:28:50 -04:00
|
|
|
return META_BACKEND_GET_CLASS (backend)->get_cursor_renderer (backend,
|
|
|
|
device);
|
2014-04-22 14:32:55 -04:00
|
|
|
}
|
|
|
|
|
2016-05-07 11:07:46 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_renderer: (skip)
|
|
|
|
*/
|
2017-04-18 08:43:09 -04:00
|
|
|
MetaRenderer *
|
|
|
|
meta_backend_get_renderer (MetaBackend *backend)
|
2016-05-07 11:07:46 -04:00
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->renderer;
|
|
|
|
}
|
|
|
|
|
2018-11-06 10:18:56 -05:00
|
|
|
#ifdef HAVE_EGL
|
2016-08-17 22:18:28 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_egl: (skip)
|
|
|
|
*/
|
2017-04-18 08:43:09 -04:00
|
|
|
MetaEgl *
|
|
|
|
meta_backend_get_egl (MetaBackend *backend)
|
2016-08-17 22:18:28 -04:00
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->egl;
|
|
|
|
}
|
2018-11-06 10:18:56 -05:00
|
|
|
#endif /* HAVE_EGL */
|
2016-08-17 22:18:28 -04:00
|
|
|
|
2017-04-21 04:40:51 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_settings: (skip)
|
|
|
|
*/
|
|
|
|
MetaSettings *
|
|
|
|
meta_backend_get_settings (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->settings;
|
|
|
|
}
|
|
|
|
|
2017-06-21 02:23:44 -04:00
|
|
|
#ifdef HAVE_REMOTE_DESKTOP
|
|
|
|
/**
|
|
|
|
* meta_backend_get_remote_desktop: (skip)
|
|
|
|
*/
|
|
|
|
MetaRemoteDesktop *
|
|
|
|
meta_backend_get_remote_desktop (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->remote_desktop;
|
|
|
|
}
|
2020-06-17 11:46:25 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_backend_get_screen_cast: (skip)
|
|
|
|
*/
|
|
|
|
MetaScreenCast *
|
|
|
|
meta_backend_get_screen_cast (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->screen_cast;
|
|
|
|
}
|
2017-06-21 02:23:44 -04:00
|
|
|
#endif /* HAVE_REMOTE_DESKTOP */
|
|
|
|
|
2018-07-20 10:37:37 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_remote_access_controller:
|
|
|
|
* @backend: A #MetaBackend
|
|
|
|
*
|
|
|
|
* Return Value: (transfer none): The #MetaRemoteAccessController
|
|
|
|
*/
|
|
|
|
MetaRemoteAccessController *
|
|
|
|
meta_backend_get_remote_access_controller (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_REMOTE_DESKTOP
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->remote_access_controller;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-10-01 05:53:57 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_is_rendering_hardware_accelerated:
|
|
|
|
* @backend: A #MetaBackend
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the rendering is hardware accelerated, otherwise
|
|
|
|
* %FALSE.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
|
|
|
|
|
return meta_renderer_is_hardware_accelerated (renderer);
|
|
|
|
}
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_grab_device: (skip)
|
|
|
|
*/
|
2014-04-23 10:50:07 -04:00
|
|
|
gboolean
|
|
|
|
meta_backend_grab_device (MetaBackend *backend,
|
|
|
|
int device_id,
|
|
|
|
uint32_t timestamp)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->grab_device (backend, device_id, timestamp);
|
|
|
|
}
|
|
|
|
|
2021-03-03 08:31:56 -05:00
|
|
|
/**
|
|
|
|
* meta_backend_get_context:
|
|
|
|
* @backend: the #MetaBackend
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The #MetaContext
|
|
|
|
*/
|
|
|
|
MetaContext *
|
|
|
|
meta_backend_get_context (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->context;
|
|
|
|
}
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_ungrab_device: (skip)
|
|
|
|
*/
|
2014-04-23 10:50:07 -04:00
|
|
|
gboolean
|
|
|
|
meta_backend_ungrab_device (MetaBackend *backend,
|
|
|
|
int device_id,
|
|
|
|
uint32_t timestamp)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->ungrab_device (backend, device_id, timestamp);
|
|
|
|
}
|
|
|
|
|
2019-10-24 15:19:36 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_finish_touch_sequence: (skip)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
meta_backend_finish_touch_sequence (MetaBackend *backend,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
MetaSequenceState state)
|
|
|
|
{
|
|
|
|
if (META_BACKEND_GET_CLASS (backend)->finish_touch_sequence)
|
|
|
|
META_BACKEND_GET_CLASS (backend)->finish_touch_sequence (backend,
|
|
|
|
sequence,
|
|
|
|
state);
|
|
|
|
}
|
|
|
|
|
2016-11-30 23:59:47 -05:00
|
|
|
MetaLogicalMonitor *
|
|
|
|
meta_backend_get_current_logical_monitor (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->get_current_logical_monitor (backend);
|
|
|
|
}
|
|
|
|
|
2014-08-04 10:47:35 -04:00
|
|
|
void
|
|
|
|
meta_backend_set_keymap (MetaBackend *backend,
|
|
|
|
const char *layouts,
|
|
|
|
const char *variants,
|
|
|
|
const char *options)
|
|
|
|
{
|
|
|
|
META_BACKEND_GET_CLASS (backend)->set_keymap (backend, layouts, variants, options);
|
|
|
|
}
|
|
|
|
|
2014-08-05 08:11:59 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_keymap: (skip)
|
|
|
|
*/
|
2014-08-04 10:47:35 -04:00
|
|
|
struct xkb_keymap *
|
|
|
|
meta_backend_get_keymap (MetaBackend *backend)
|
|
|
|
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->get_keymap (backend);
|
|
|
|
}
|
|
|
|
|
2017-08-17 05:01:50 -04:00
|
|
|
xkb_layout_index_t
|
|
|
|
meta_backend_get_keymap_layout_group (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return META_BACKEND_GET_CLASS (backend)->get_keymap_layout_group (backend);
|
|
|
|
}
|
|
|
|
|
2014-08-04 10:47:35 -04:00
|
|
|
void
|
|
|
|
meta_backend_lock_layout_group (MetaBackend *backend,
|
|
|
|
guint idx)
|
|
|
|
{
|
|
|
|
META_BACKEND_GET_CLASS (backend)->lock_layout_group (backend, idx);
|
|
|
|
}
|
|
|
|
|
2014-08-13 19:46:32 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_get_stage:
|
|
|
|
* @backend: A #MetaBackend
|
|
|
|
*
|
|
|
|
* Gets the global #ClutterStage that's managed by this backend.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): the #ClutterStage
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
|
|
|
meta_backend_get_stage (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
return priv->stage;
|
|
|
|
}
|
|
|
|
|
2021-03-12 02:31:50 -05:00
|
|
|
ClutterSeat *
|
|
|
|
meta_backend_get_default_seat (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->default_seat;
|
|
|
|
}
|
|
|
|
|
2016-02-25 18:45:50 -05:00
|
|
|
static gboolean
|
|
|
|
update_last_device (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2016-11-29 07:30:22 -05:00
|
|
|
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
|
2016-02-25 18:45:50 -05:00
|
|
|
ClutterInputDeviceType device_type;
|
|
|
|
|
|
|
|
priv->device_update_idle_id = 0;
|
2019-10-04 12:23:49 -04:00
|
|
|
device_type = clutter_input_device_get_device_type (priv->current_device);
|
2016-02-25 18:45:50 -05:00
|
|
|
|
2017-03-29 02:30:10 -04:00
|
|
|
g_signal_emit (backend, signals[LAST_DEVICE_CHANGED], 0,
|
2019-10-04 12:23:49 -04:00
|
|
|
priv->current_device);
|
2016-02-25 18:45:50 -05:00
|
|
|
|
|
|
|
switch (device_type)
|
|
|
|
{
|
|
|
|
case CLUTTER_KEYBOARD_DEVICE:
|
|
|
|
break;
|
|
|
|
case CLUTTER_TOUCHSCREEN_DEVICE:
|
|
|
|
meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
meta_cursor_tracker_set_pointer_visible (cursor_tracker, TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
2015-02-11 08:59:21 -05:00
|
|
|
void
|
2019-10-04 12:23:49 -04:00
|
|
|
meta_backend_update_last_device (MetaBackend *backend,
|
|
|
|
ClutterInputDevice *device)
|
2015-02-11 08:59:21 -05:00
|
|
|
{
|
2016-02-25 18:45:50 -05:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
2015-02-11 08:59:21 -05:00
|
|
|
|
2019-10-04 12:23:49 -04:00
|
|
|
if (priv->current_device == device)
|
2015-02-11 08:59:21 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!device ||
|
2020-08-31 12:47:23 -04:00
|
|
|
clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
|
2015-02-11 08:59:21 -05:00
|
|
|
return;
|
|
|
|
|
2020-10-26 13:34:05 -04:00
|
|
|
g_set_object (&priv->current_device, device);
|
2015-02-11 08:59:21 -05:00
|
|
|
|
2016-02-25 18:45:50 -05:00
|
|
|
if (priv->device_update_idle_id == 0)
|
2015-02-11 08:59:21 -05:00
|
|
|
{
|
2016-02-25 18:45:50 -05:00
|
|
|
priv->device_update_idle_id =
|
|
|
|
g_idle_add ((GSourceFunc) update_last_device, backend);
|
|
|
|
g_source_set_name_by_id (priv->device_update_idle_id,
|
|
|
|
"[mutter] update_last_device");
|
2015-02-11 08:59:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 03:15:16 -05:00
|
|
|
MetaPointerConstraint *
|
|
|
|
meta_backend_get_client_pointer_constraint (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->client_pointer_constraint;
|
|
|
|
}
|
|
|
|
|
2018-10-19 03:15:54 -04:00
|
|
|
/**
|
|
|
|
* meta_backend_set_client_pointer_constraint:
|
|
|
|
* @backend: a #MetaBackend object.
|
|
|
|
* @constraint: (nullable): the client constraint to follow.
|
|
|
|
*
|
|
|
|
* Sets the current pointer constraint and removes (and unrefs) the previous
|
2020-08-26 05:49:50 -04:00
|
|
|
* one. If @constraint is %NULL, this means that there is no
|
2018-10-19 03:15:54 -04:00
|
|
|
* #MetaPointerConstraint active.
|
|
|
|
*/
|
2015-06-17 00:10:52 -04:00
|
|
|
void
|
|
|
|
meta_backend_set_client_pointer_constraint (MetaBackend *backend,
|
|
|
|
MetaPointerConstraint *constraint)
|
|
|
|
{
|
2016-12-01 03:15:16 -05:00
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
2020-07-08 12:17:13 -04:00
|
|
|
META_BACKEND_GET_CLASS (backend)->set_pointer_constraint (backend, constraint);
|
|
|
|
g_set_object (&priv->client_pointer_constraint, constraint);
|
2015-06-17 00:10:52 -04:00
|
|
|
}
|
|
|
|
|
2016-07-06 05:05:56 -04:00
|
|
|
ClutterBackend *
|
2016-05-04 04:19:23 -04:00
|
|
|
meta_backend_get_clutter_backend (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
ClutterContext *clutter_context;
|
2016-05-04 04:19:23 -04:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
clutter_context = priv->clutter_context;
|
|
|
|
if (!clutter_context)
|
|
|
|
return NULL;
|
2016-05-04 04:19:23 -04:00
|
|
|
|
Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.
The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().
During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.
This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.
This function now explicitly creates the backend, without having to go
via the previously set global vfunc.
This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.
The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.
This also removed the unused option parsing that existed in clutter.
In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.
The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-09-16 05:38:49 -04:00
|
|
|
return clutter_context_get_backend (clutter_context);
|
2016-05-04 04:19:23 -04:00
|
|
|
}
|
|
|
|
|
2021-02-03 04:59:06 -05:00
|
|
|
void
|
|
|
|
meta_backend_prepare_shutdown (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
g_signal_emit (backend, signals[PREPARE_SHUTDOWN], 0);
|
|
|
|
}
|
|
|
|
|
2018-10-19 03:15:54 -04:00
|
|
|
/**
|
|
|
|
* meta_is_stage_views_enabled:
|
|
|
|
*
|
|
|
|
* Returns whether the #ClutterStage can be rendered using multiple stage views.
|
|
|
|
* In practice, this means we can define a separate framebuffer for each
|
|
|
|
* #MetaLogicalMonitor, rather than rendering everything into a single
|
|
|
|
* framebuffer. For example: in X11, onle one single framebuffer is allowed.
|
|
|
|
*/
|
2016-06-08 05:05:31 -04:00
|
|
|
gboolean
|
|
|
|
meta_is_stage_views_enabled (void)
|
|
|
|
{
|
|
|
|
if (!meta_is_wayland_compositor ())
|
|
|
|
return FALSE;
|
|
|
|
|
2017-05-06 12:45:42 -04:00
|
|
|
return !stage_views_disabled;
|
2016-06-08 05:05:31 -04:00
|
|
|
}
|
2016-05-13 07:31:52 -04:00
|
|
|
|
2017-02-24 05:10:52 -05:00
|
|
|
gboolean
|
|
|
|
meta_is_stage_views_scaled (void)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaLogicalMonitorLayoutMode layout_mode;
|
|
|
|
|
|
|
|
if (!meta_is_stage_views_enabled ())
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
layout_mode = monitor_manager->layout_mode;
|
|
|
|
|
|
|
|
return layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL;
|
|
|
|
}
|
|
|
|
|
2020-08-04 08:17:39 -04:00
|
|
|
MetaInputMapper *
|
|
|
|
meta_backend_get_input_mapper (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->input_mapper;
|
|
|
|
}
|
|
|
|
|
2016-05-13 07:31:52 -04:00
|
|
|
MetaInputSettings *
|
|
|
|
meta_backend_get_input_settings (MetaBackend *backend)
|
|
|
|
{
|
2020-11-19 10:00:12 -05:00
|
|
|
return META_BACKEND_GET_CLASS (backend)->get_input_settings (backend);
|
2016-05-13 07:31:52 -04:00
|
|
|
}
|
2017-01-02 09:11:32 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_backend_get_dnd:
|
|
|
|
* @backend: A #MetaDnd
|
|
|
|
*
|
|
|
|
* Gets the global #MetaDnd that's managed by this backend.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): the #MetaDnd
|
|
|
|
*/
|
|
|
|
MetaDnd *
|
|
|
|
meta_backend_get_dnd (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->dnd;
|
|
|
|
}
|
2017-03-29 02:30:10 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_backend_notify_keymap_changed (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
g_signal_emit (backend, signals[KEYMAP_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_backend_notify_keymap_layout_group_changed (MetaBackend *backend,
|
|
|
|
unsigned int locked_group)
|
|
|
|
{
|
|
|
|
g_signal_emit (backend, signals[KEYMAP_LAYOUT_GROUP_CHANGED], 0,
|
|
|
|
locked_group);
|
|
|
|
}
|
2019-01-11 09:35:42 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_backend_add_gpu (MetaBackend *backend,
|
|
|
|
MetaGpu *gpu)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
priv->gpus = g_list_append (priv->gpus, gpu);
|
|
|
|
|
|
|
|
g_signal_emit (backend, signals[GPU_ADDED], 0, gpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
meta_backend_get_gpus (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->gpus;
|
|
|
|
}
|
2020-03-06 08:12:59 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
WacomDeviceDatabase *
|
|
|
|
meta_backend_get_wacom_database (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
return priv->wacom_db;
|
|
|
|
}
|
|
|
|
#endif
|
2020-07-13 11:45:41 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend,
|
|
|
|
MetaHwCursorInhibitor *inhibitor)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors,
|
|
|
|
inhibitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend,
|
|
|
|
MetaHwCursorInhibitor *inhibitor)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
|
|
|
|
priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors,
|
|
|
|
inhibitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_backend_is_hw_cursors_inhibited (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaHwCursorInhibitor *inhibitor = l->data;
|
|
|
|
|
|
|
|
if (meta_hw_cursor_inhibitor_is_cursor_inhibited (inhibitor))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|