2014-04-21 19:13:04 -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-native
|
|
|
|
* @title: MetaBackendNative
|
|
|
|
* @short_description: A native (KMS/evdev) MetaBackend
|
|
|
|
*
|
|
|
|
* MetaBackendNative is an implementation of #MetaBackend that uses "native"
|
|
|
|
* technologies like DRM/KMS and libinput/evdev to perform the necessary
|
|
|
|
* functions.
|
|
|
|
*/
|
|
|
|
|
2014-04-21 19:13:04 -04:00
|
|
|
#include "config.h"
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/native/meta-backend-native.h"
|
|
|
|
#include "backends/native/meta-backend-native-private.h"
|
2015-01-16 03:50:51 -05:00
|
|
|
|
2019-02-27 13:02:25 -05:00
|
|
|
#include <sched.h>
|
2018-07-10 04:36:24 -04:00
|
|
|
#include <stdlib.h>
|
2014-04-21 19:13:04 -04:00
|
|
|
|
2015-07-10 05:01:22 -04:00
|
|
|
#include "backends/meta-cursor-tracker-private.h"
|
2018-03-20 05:59:04 -04:00
|
|
|
#include "backends/meta-idle-monitor-private.h"
|
2016-12-12 21:37:11 -05:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
2016-11-30 23:59:47 -05:00
|
|
|
#include "backends/meta-monitor-manager-private.h"
|
2015-06-17 00:10:52 -04:00
|
|
|
#include "backends/meta-pointer-constraint.h"
|
2019-02-27 13:02:25 -05:00
|
|
|
#include "backends/meta-settings-private.h"
|
2018-05-02 12:53:11 -04:00
|
|
|
#include "backends/meta-stage-private.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/native/meta-barrier-native.h"
|
2016-05-04 04:19:23 -04:00
|
|
|
#include "backends/native/meta-clutter-backend-native.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/native/meta-cursor-renderer-native.h"
|
2019-03-29 17:03:27 -04:00
|
|
|
#include "backends/native/meta-event-native.h"
|
2017-04-10 05:31:50 -04:00
|
|
|
#include "backends/native/meta-input-settings-native.h"
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
#include "backends/native/meta-kms.h"
|
|
|
|
#include "backends/native/meta-kms-device.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/native/meta-launcher.h"
|
|
|
|
#include "backends/native/meta-monitor-manager-kms.h"
|
2016-05-07 11:07:46 -04:00
|
|
|
#include "backends/native/meta-renderer-native.h"
|
2019-09-25 17:04:25 -04:00
|
|
|
#include "backends/native/meta-seat-native.h"
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
#include "backends/native/meta-stage-native.h"
|
2019-08-27 06:11:07 -04:00
|
|
|
#include "cogl/cogl-trace.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "core/meta-border.h"
|
|
|
|
#include "meta/main.h"
|
2015-10-28 10:45:20 -04:00
|
|
|
|
2016-11-30 05:46:20 -05:00
|
|
|
struct _MetaBackendNative
|
|
|
|
{
|
|
|
|
MetaBackend parent;
|
|
|
|
|
2014-04-21 19:47:04 -04:00
|
|
|
MetaLauncher *launcher;
|
2019-01-10 05:30:02 -05:00
|
|
|
MetaUdev *udev;
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
MetaKms *kms;
|
2015-01-16 03:50:51 -05:00
|
|
|
MetaBarrierManagerNative *barrier_manager;
|
2019-01-11 09:35:42 -05:00
|
|
|
|
2019-11-15 19:25:52 -05:00
|
|
|
gulong udev_device_added_handler_id;
|
2014-04-21 19:47:04 -04:00
|
|
|
};
|
|
|
|
|
2017-07-24 00:31:32 -04:00
|
|
|
static GInitableIface *initable_parent_iface;
|
|
|
|
|
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaBackendNative, meta_backend_native, META_TYPE_BACKEND,
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
|
|
|
initable_iface_init))
|
2014-04-21 19:13:04 -04:00
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
static void
|
|
|
|
disconnect_udev_device_added_handler (MetaBackendNative *native);
|
|
|
|
|
2014-09-19 11:25:22 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (object);
|
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
if (native->udev_device_added_handler_id)
|
|
|
|
disconnect_udev_device_added_handler (native);
|
|
|
|
|
2019-01-10 05:30:02 -05:00
|
|
|
g_clear_object (&native->udev);
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
g_clear_object (&native->kms);
|
2018-09-06 08:14:59 -04:00
|
|
|
meta_launcher_free (native->launcher);
|
2014-09-19 11:25:22 -04:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
static void
|
|
|
|
constrain_to_barriers (ClutterInputDevice *device,
|
|
|
|
guint32 time,
|
|
|
|
float *new_x,
|
|
|
|
float *new_y)
|
|
|
|
{
|
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (meta_get_backend ());
|
|
|
|
|
2018-09-06 08:14:59 -04:00
|
|
|
meta_barrier_manager_native_process (native->barrier_manager,
|
2015-01-16 03:50:51 -05:00
|
|
|
device,
|
|
|
|
time,
|
|
|
|
new_x, new_y);
|
|
|
|
}
|
|
|
|
|
2015-06-17 00:10:52 -04:00
|
|
|
static void
|
|
|
|
constrain_to_client_constraint (ClutterInputDevice *device,
|
|
|
|
guint32 time,
|
|
|
|
float prev_x,
|
|
|
|
float prev_y,
|
|
|
|
float *x,
|
|
|
|
float *y)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
2016-12-01 03:15:16 -05:00
|
|
|
MetaPointerConstraint *constraint =
|
|
|
|
meta_backend_get_client_pointer_constraint (backend);
|
2015-06-17 00:10:52 -04:00
|
|
|
|
|
|
|
if (!constraint)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_pointer_constraint_constrain (constraint, device,
|
|
|
|
time, prev_x, prev_y, x, y);
|
|
|
|
}
|
|
|
|
|
2014-04-21 20:45:24 -04:00
|
|
|
/*
|
|
|
|
* The pointer constrain code is mostly a rip-off of the XRandR code from Xorg.
|
|
|
|
* (from xserver/randr/rrcrtc.c, RRConstrainCursorHarder)
|
|
|
|
*
|
|
|
|
* Copyright © 2006 Keith Packard
|
|
|
|
* Copyright 2010 Red Hat, Inc
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
constrain_all_screen_monitors (ClutterInputDevice *device,
|
2016-12-02 03:00:03 -05:00
|
|
|
MetaMonitorManager *monitor_manager,
|
2016-11-25 01:31:38 -05:00
|
|
|
float *x,
|
|
|
|
float *y)
|
2014-04-21 20:45:24 -04:00
|
|
|
{
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t current;
|
2015-03-02 07:46:16 -05:00
|
|
|
float cx, cy;
|
2016-12-02 03:00:03 -05:00
|
|
|
GList *logical_monitors, *l;
|
2014-04-21 20:45:24 -04:00
|
|
|
|
|
|
|
clutter_input_device_get_coords (device, NULL, ¤t);
|
|
|
|
|
2015-03-02 07:46:16 -05:00
|
|
|
cx = current.x;
|
|
|
|
cy = current.y;
|
|
|
|
|
2014-04-21 20:45:24 -04:00
|
|
|
/* if we're trying to escape, clamp to the CRTC we're coming from */
|
2016-12-02 03:00:03 -05:00
|
|
|
|
|
|
|
logical_monitors =
|
|
|
|
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
|
|
|
for (l = logical_monitors; l; l = l->next)
|
2014-04-21 20:45:24 -04:00
|
|
|
{
|
2016-12-02 03:00:03 -05:00
|
|
|
MetaLogicalMonitor *logical_monitor = l->data;
|
2014-04-21 20:45:24 -04:00
|
|
|
int left, right, top, bottom;
|
|
|
|
|
2016-11-25 01:31:38 -05:00
|
|
|
left = logical_monitor->rect.x;
|
|
|
|
right = left + logical_monitor->rect.width;
|
|
|
|
top = logical_monitor->rect.y;
|
|
|
|
bottom = top + logical_monitor->rect.height;
|
2014-04-21 20:45:24 -04:00
|
|
|
|
2015-03-02 07:46:16 -05:00
|
|
|
if ((cx >= left) && (cx < right) && (cy >= top) && (cy < bottom))
|
2018-07-10 04:36:24 -04:00
|
|
|
{
|
|
|
|
if (*x < left)
|
|
|
|
*x = left;
|
|
|
|
if (*x >= right)
|
|
|
|
*x = right - 1;
|
|
|
|
if (*y < top)
|
|
|
|
*y = top;
|
|
|
|
if (*y >= bottom)
|
|
|
|
*y = bottom - 1;
|
|
|
|
|
|
|
|
return;
|
2014-04-21 20:45:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_constrain_callback (ClutterInputDevice *device,
|
2015-07-07 01:10:41 -04:00
|
|
|
guint32 time,
|
|
|
|
float prev_x,
|
|
|
|
float prev_y,
|
|
|
|
float *new_x,
|
|
|
|
float *new_y,
|
|
|
|
gpointer user_data)
|
2014-04-21 20:45:24 -04:00
|
|
|
{
|
2016-12-02 03:00:03 -05:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2014-04-21 20:45:24 -04:00
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
/* Constrain to barriers */
|
|
|
|
constrain_to_barriers (device, time, new_x, new_y);
|
|
|
|
|
2015-06-17 00:10:52 -04:00
|
|
|
/* Constrain to pointer lock */
|
|
|
|
constrain_to_client_constraint (device, time, prev_x, prev_y, new_x, new_y);
|
|
|
|
|
2014-04-21 20:45:24 -04:00
|
|
|
/* if we're moving inside a monitor, we're fine */
|
2016-12-01 02:37:32 -05:00
|
|
|
if (meta_monitor_manager_get_logical_monitor_at (monitor_manager,
|
|
|
|
*new_x, *new_y))
|
2014-04-21 20:45:24 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* if we're trying to escape, clamp to the CRTC we're coming from */
|
2016-12-02 03:00:03 -05:00
|
|
|
constrain_all_screen_monitors (device, monitor_manager, new_x, new_y);
|
2014-04-21 20:45:24 -04:00
|
|
|
}
|
|
|
|
|
2017-03-17 11:12:37 -04:00
|
|
|
static void
|
|
|
|
relative_motion_across_outputs (MetaMonitorManager *monitor_manager,
|
|
|
|
MetaLogicalMonitor *current,
|
|
|
|
float cur_x,
|
|
|
|
float cur_y,
|
|
|
|
float *dx_inout,
|
|
|
|
float *dy_inout)
|
|
|
|
{
|
|
|
|
MetaLogicalMonitor *cur = current;
|
|
|
|
float x = cur_x, y = cur_y;
|
2019-12-08 06:02:51 -05:00
|
|
|
float target_x = cur_x, target_y = cur_y;
|
2017-03-17 11:12:37 -04:00
|
|
|
float dx = *dx_inout, dy = *dy_inout;
|
2017-08-26 15:22:34 -04:00
|
|
|
MetaDisplayDirection direction = -1;
|
2017-03-17 11:12:37 -04:00
|
|
|
|
|
|
|
while (cur)
|
|
|
|
{
|
|
|
|
MetaLine2 left, right, top, bottom, motion;
|
|
|
|
MetaVector2 intersection;
|
|
|
|
|
|
|
|
motion = (MetaLine2) {
|
2018-07-10 04:36:24 -04:00
|
|
|
.a = { x, y },
|
|
|
|
.b = { x + (dx * cur->scale), y + (dy * cur->scale) }
|
2017-03-17 11:12:37 -04:00
|
|
|
};
|
|
|
|
left = (MetaLine2) {
|
2018-07-10 04:36:24 -04:00
|
|
|
{ cur->rect.x, cur->rect.y },
|
|
|
|
{ cur->rect.x, cur->rect.y + cur->rect.height }
|
2017-03-17 11:12:37 -04:00
|
|
|
};
|
|
|
|
right = (MetaLine2) {
|
2018-07-10 04:36:24 -04:00
|
|
|
{ cur->rect.x + cur->rect.width, cur->rect.y },
|
|
|
|
{ cur->rect.x + cur->rect.width, cur->rect.y + cur->rect.height }
|
2017-03-17 11:12:37 -04:00
|
|
|
};
|
|
|
|
top = (MetaLine2) {
|
2018-07-10 04:36:24 -04:00
|
|
|
{ cur->rect.x, cur->rect.y },
|
|
|
|
{ cur->rect.x + cur->rect.width, cur->rect.y }
|
2017-03-17 11:12:37 -04:00
|
|
|
};
|
|
|
|
bottom = (MetaLine2) {
|
2018-07-10 04:36:24 -04:00
|
|
|
{ cur->rect.x, cur->rect.y + cur->rect.height },
|
|
|
|
{ cur->rect.x + cur->rect.width, cur->rect.y + cur->rect.height }
|
2017-03-17 11:12:37 -04:00
|
|
|
};
|
|
|
|
|
2019-12-08 06:02:51 -05:00
|
|
|
target_x = motion.b.x;
|
|
|
|
target_y = motion.b.y;
|
|
|
|
|
2017-08-26 15:22:34 -04:00
|
|
|
if (direction != META_DISPLAY_RIGHT &&
|
2017-03-17 11:12:37 -04:00
|
|
|
meta_line2_intersects_with (&motion, &left, &intersection))
|
2017-08-26 15:22:34 -04:00
|
|
|
direction = META_DISPLAY_LEFT;
|
|
|
|
else if (direction != META_DISPLAY_LEFT &&
|
2017-03-17 11:12:37 -04:00
|
|
|
meta_line2_intersects_with (&motion, &right, &intersection))
|
2017-08-26 15:22:34 -04:00
|
|
|
direction = META_DISPLAY_RIGHT;
|
|
|
|
else if (direction != META_DISPLAY_DOWN &&
|
2017-03-17 11:12:37 -04:00
|
|
|
meta_line2_intersects_with (&motion, &top, &intersection))
|
2017-08-26 15:22:34 -04:00
|
|
|
direction = META_DISPLAY_UP;
|
|
|
|
else if (direction != META_DISPLAY_UP &&
|
2017-03-17 11:12:37 -04:00
|
|
|
meta_line2_intersects_with (&motion, &bottom, &intersection))
|
2017-08-26 15:22:34 -04:00
|
|
|
direction = META_DISPLAY_DOWN;
|
2017-03-17 11:12:37 -04:00
|
|
|
else
|
2019-12-08 06:02:51 -05:00
|
|
|
/* We reached the dest logical monitor */
|
|
|
|
break;
|
2017-03-17 11:12:37 -04:00
|
|
|
|
|
|
|
x = intersection.x;
|
|
|
|
y = intersection.y;
|
|
|
|
dx -= intersection.x - motion.a.x;
|
|
|
|
dy -= intersection.y - motion.a.y;
|
|
|
|
|
|
|
|
cur = meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
|
|
|
|
cur, direction);
|
|
|
|
}
|
|
|
|
|
2019-12-08 06:02:51 -05:00
|
|
|
*dx_inout = target_x - cur_x;
|
|
|
|
*dy_inout = target_y - cur_y;
|
2017-03-17 11:12:37 -04:00
|
|
|
}
|
|
|
|
|
2017-02-03 00:12:01 -05:00
|
|
|
static void
|
|
|
|
relative_motion_filter (ClutterInputDevice *device,
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
float *dx,
|
|
|
|
float *dy,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaMonitorManager *monitor_manager = user_data;
|
2017-03-17 11:12:37 -04:00
|
|
|
MetaLogicalMonitor *logical_monitor, *dest_logical_monitor;
|
|
|
|
float new_dx, new_dy;
|
2017-02-03 00:12:01 -05:00
|
|
|
|
2017-06-07 05:32:59 -04:00
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
return;
|
|
|
|
|
2017-02-03 00:12:01 -05:00
|
|
|
logical_monitor = meta_monitor_manager_get_logical_monitor_at (monitor_manager,
|
|
|
|
x, y);
|
|
|
|
if (!logical_monitor)
|
|
|
|
return;
|
|
|
|
|
2017-03-17 11:12:37 -04:00
|
|
|
new_dx = (*dx) * logical_monitor->scale;
|
|
|
|
new_dy = (*dy) * logical_monitor->scale;
|
|
|
|
|
|
|
|
dest_logical_monitor = meta_monitor_manager_get_logical_monitor_at (monitor_manager,
|
|
|
|
x + new_dx,
|
|
|
|
y + new_dy);
|
|
|
|
if (dest_logical_monitor &&
|
|
|
|
dest_logical_monitor != logical_monitor)
|
|
|
|
{
|
|
|
|
/* If we are crossing monitors, attempt to bisect the distance on each
|
|
|
|
* axis and apply the relative scale for each of them.
|
|
|
|
*/
|
|
|
|
new_dx = *dx;
|
|
|
|
new_dy = *dy;
|
|
|
|
relative_motion_across_outputs (monitor_manager, logical_monitor,
|
|
|
|
x, y, &new_dx, &new_dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
*dx = new_dx;
|
|
|
|
*dy = new_dy;
|
2017-02-03 00:12:01 -05:00
|
|
|
}
|
|
|
|
|
2016-05-04 04:19:23 -04:00
|
|
|
static ClutterBackend *
|
|
|
|
meta_backend_native_create_clutter_backend (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_CLUTTER_BACKEND_NATIVE, NULL);
|
|
|
|
}
|
|
|
|
|
2014-04-22 12:40:51 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_post_init (MetaBackend *backend)
|
|
|
|
{
|
2019-09-25 17:04:25 -04:00
|
|
|
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
|
|
|
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
|
2019-02-27 13:02:25 -05:00
|
|
|
MetaSettings *settings = meta_backend_get_settings (backend);
|
2014-04-23 09:42:49 -04:00
|
|
|
|
|
|
|
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
|
|
|
|
|
2019-09-25 17:04:25 -04:00
|
|
|
meta_seat_native_set_pointer_constrain_callback (META_SEAT_NATIVE (seat),
|
|
|
|
pointer_constrain_callback,
|
|
|
|
NULL, NULL);
|
|
|
|
meta_seat_native_set_relative_motion_filter (META_SEAT_NATIVE (seat),
|
|
|
|
relative_motion_filter,
|
|
|
|
meta_backend_get_monitor_manager (backend));
|
2019-02-27 13:02:25 -05:00
|
|
|
|
|
|
|
if (meta_settings_is_experimental_feature_enabled (settings,
|
|
|
|
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
struct sched_param sp = {
|
|
|
|
.sched_priority = sched_get_priority_min (SCHED_RR)
|
|
|
|
};
|
|
|
|
|
|
|
|
retval = sched_setscheduler (0, SCHED_RR | SCHED_RESET_ON_FORK, &sp);
|
|
|
|
|
|
|
|
if (retval != 0)
|
|
|
|
g_warning ("Failed to set RT scheduler: %m");
|
|
|
|
}
|
2014-04-22 12:40:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static MetaMonitorManager *
|
2017-07-06 04:00:56 -04:00
|
|
|
meta_backend_native_create_monitor_manager (MetaBackend *backend,
|
|
|
|
GError **error)
|
2014-04-22 12:40:51 -04:00
|
|
|
{
|
2017-07-10 05:39:07 -04:00
|
|
|
return g_initable_new (META_TYPE_MONITOR_MANAGER_KMS, NULL, error,
|
|
|
|
"backend", backend,
|
|
|
|
NULL);
|
2014-04-22 12:40:51 -04:00
|
|
|
}
|
|
|
|
|
2014-04-22 15:15:11 -04:00
|
|
|
static MetaCursorRenderer *
|
|
|
|
meta_backend_native_create_cursor_renderer (MetaBackend *backend)
|
|
|
|
{
|
2017-07-07 04:12:07 -04:00
|
|
|
return META_CURSOR_RENDERER (meta_cursor_renderer_native_new (backend));
|
2014-04-22 15:15:11 -04:00
|
|
|
}
|
|
|
|
|
2016-05-07 11:07:46 -04:00
|
|
|
static MetaRenderer *
|
2017-07-05 06:01:47 -04:00
|
|
|
meta_backend_native_create_renderer (MetaBackend *backend,
|
|
|
|
GError **error)
|
2016-05-07 11:07:46 -04:00
|
|
|
{
|
2019-01-11 09:35:42 -05:00
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
2016-05-09 09:22:01 -04:00
|
|
|
MetaRendererNative *renderer_native;
|
2016-05-07 11:09:59 -04:00
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
renderer_native = meta_renderer_native_new (native, error);
|
2016-05-09 09:22:01 -04:00
|
|
|
if (!renderer_native)
|
2017-07-05 06:01:47 -04:00
|
|
|
return NULL;
|
2016-05-09 09:22:01 -04:00
|
|
|
|
|
|
|
return META_RENDERER (renderer_native);
|
2016-05-07 11:07:46 -04:00
|
|
|
}
|
|
|
|
|
2017-04-10 05:31:50 -04:00
|
|
|
static MetaInputSettings *
|
|
|
|
meta_backend_native_create_input_settings (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE, NULL);
|
|
|
|
}
|
|
|
|
|
2014-05-27 14:21:54 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_warp_pointer (MetaBackend *backend,
|
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
2019-10-04 15:57:26 -04:00
|
|
|
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
|
|
|
ClutterInputDevice *device = clutter_seat_get_pointer (seat);
|
2016-11-29 07:30:22 -05:00
|
|
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
2014-05-27 14:21:54 -04:00
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
guint32 time_ = 0;
|
|
|
|
|
2015-07-10 05:01:22 -04:00
|
|
|
/* Warp the input device pointer state. */
|
2019-09-25 17:04:25 -04:00
|
|
|
meta_seat_native_warp_pointer (device, time_, x, y);
|
2015-07-10 05:01:22 -04:00
|
|
|
|
|
|
|
/* Warp displayed pointer cursor. */
|
2016-11-29 07:30:22 -05:00
|
|
|
meta_cursor_tracker_update_position (cursor_tracker, x, y);
|
2014-05-27 14:21:54 -04:00
|
|
|
}
|
|
|
|
|
2016-11-30 23:59:47 -05:00
|
|
|
static MetaLogicalMonitor *
|
|
|
|
meta_backend_native_get_current_logical_monitor (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
|
|
|
|
return meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y);
|
|
|
|
}
|
|
|
|
|
2014-08-04 10:47:35 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_set_keymap (MetaBackend *backend,
|
|
|
|
const char *layouts,
|
|
|
|
const char *variants,
|
|
|
|
const char *options)
|
|
|
|
{
|
|
|
|
struct xkb_rule_names names;
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
struct xkb_context *context;
|
2019-10-04 09:44:27 -04:00
|
|
|
ClutterSeat *seat;
|
2014-08-04 10:47:35 -04:00
|
|
|
|
|
|
|
names.rules = DEFAULT_XKB_RULES_FILE;
|
|
|
|
names.model = DEFAULT_XKB_MODEL;
|
|
|
|
names.layout = layouts;
|
|
|
|
names.variant = variants;
|
|
|
|
names.options = options;
|
|
|
|
|
|
|
|
context = xkb_context_new (XKB_CONTEXT_NO_FLAGS);
|
|
|
|
keymap = xkb_keymap_new_from_names (context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
|
|
|
xkb_context_unref (context);
|
|
|
|
|
2019-10-04 09:44:27 -04:00
|
|
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
|
|
|
meta_seat_native_set_keyboard_map (META_SEAT_NATIVE (seat), keymap);
|
2014-08-04 10:47:35 -04:00
|
|
|
|
2017-03-29 02:30:10 -04:00
|
|
|
meta_backend_notify_keymap_changed (backend);
|
2014-08-04 10:47:35 -04:00
|
|
|
|
|
|
|
xkb_keymap_unref (keymap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct xkb_keymap *
|
|
|
|
meta_backend_native_get_keymap (MetaBackend *backend)
|
|
|
|
{
|
2019-10-04 09:44:27 -04:00
|
|
|
ClutterSeat *seat;
|
|
|
|
|
|
|
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
|
|
|
return meta_seat_native_get_keyboard_map (META_SEAT_NATIVE (seat));
|
2014-08-04 10:47:35 -04:00
|
|
|
}
|
|
|
|
|
2017-08-17 05:01:50 -04:00
|
|
|
static xkb_layout_index_t
|
|
|
|
meta_backend_native_get_keymap_layout_group (MetaBackend *backend)
|
|
|
|
{
|
2019-10-04 09:44:27 -04:00
|
|
|
ClutterSeat *seat;
|
2017-08-17 05:01:50 -04:00
|
|
|
|
2019-10-04 09:44:27 -04:00
|
|
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
|
|
|
return meta_seat_native_get_keyboard_layout_index (META_SEAT_NATIVE (seat));
|
2017-08-17 05:01:50 -04:00
|
|
|
}
|
|
|
|
|
2014-08-04 10:47:35 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_lock_layout_group (MetaBackend *backend,
|
|
|
|
guint idx)
|
|
|
|
{
|
2017-08-21 02:37:52 -04:00
|
|
|
xkb_layout_index_t old_idx;
|
2019-10-04 09:44:27 -04:00
|
|
|
ClutterSeat *seat;
|
2017-08-21 02:37:52 -04:00
|
|
|
|
|
|
|
old_idx = meta_backend_native_get_keymap_layout_group (backend);
|
|
|
|
if (old_idx == idx)
|
|
|
|
return;
|
2017-03-29 02:30:10 -04:00
|
|
|
|
2019-10-04 09:44:27 -04:00
|
|
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
|
|
|
meta_seat_native_set_keyboard_layout_index (META_SEAT_NATIVE (seat), idx);
|
2017-03-29 02:30:10 -04:00
|
|
|
meta_backend_notify_keymap_layout_group_changed (backend, idx);
|
2014-08-04 10:47:35 -04:00
|
|
|
}
|
|
|
|
|
2016-09-08 03:55:44 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_set_numlock (MetaBackend *backend,
|
|
|
|
gboolean numlock_state)
|
|
|
|
{
|
2019-10-04 09:44:27 -04:00
|
|
|
ClutterSeat *seat;
|
|
|
|
|
|
|
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
|
|
|
meta_seat_native_set_keyboard_numlock (META_SEAT_NATIVE (seat),
|
|
|
|
numlock_state);
|
2016-09-08 03:55:44 -04:00
|
|
|
}
|
|
|
|
|
2016-05-20 03:36:05 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_update_screen_size (MetaBackend *backend,
|
|
|
|
int width, int height)
|
|
|
|
{
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
|
|
|
MetaStageNative *stage_native;
|
2016-05-20 03:36:05 -04:00
|
|
|
ClutterActor *stage = meta_backend_get_stage (backend);
|
|
|
|
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
stage_native = meta_clutter_backend_native_get_stage_native (clutter_backend);
|
2017-07-24 00:31:32 -04:00
|
|
|
meta_stage_native_rebuild_views (stage_native);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2016-05-20 03:36:05 -04:00
|
|
|
clutter_actor_set_size (stage, width, height);
|
|
|
|
}
|
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
static MetaGpuKms *
|
|
|
|
create_gpu_from_udev_device (MetaBackendNative *native,
|
|
|
|
GUdevDevice *device,
|
|
|
|
GError **error)
|
|
|
|
{
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
MetaKmsDeviceFlag flags = META_KMS_DEVICE_FLAG_NONE;
|
2019-01-11 09:35:42 -05:00
|
|
|
const char *device_path;
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
MetaKmsDevice *kms_device;
|
2019-01-11 09:35:42 -05:00
|
|
|
|
|
|
|
if (meta_is_udev_device_platform_device (device))
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
flags |= META_KMS_DEVICE_FLAG_PLATFORM_DEVICE;
|
2019-01-11 09:35:42 -05:00
|
|
|
|
|
|
|
if (meta_is_udev_device_boot_vga (device))
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
flags |= META_KMS_DEVICE_FLAG_BOOT_VGA;
|
2019-01-11 09:35:42 -05:00
|
|
|
|
|
|
|
device_path = g_udev_device_get_device_file (device);
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
|
|
|
|
kms_device = meta_kms_create_device (native->kms, device_path, flags,
|
|
|
|
error);
|
|
|
|
if (!kms_device)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return meta_gpu_kms_new (native, kms_device, error);
|
2019-01-11 09:35:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_udev_device_added (MetaUdev *udev,
|
|
|
|
GUdevDevice *device,
|
|
|
|
MetaBackendNative *native)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (native);
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
const char *device_path;
|
|
|
|
MetaGpuKms *new_gpu_kms;
|
|
|
|
GList *gpus, *l;
|
|
|
|
|
|
|
|
if (!meta_udev_is_drm_device (udev, device))
|
|
|
|
return;
|
|
|
|
|
|
|
|
device_path = g_udev_device_get_device_file (device);
|
|
|
|
|
|
|
|
gpus = meta_backend_get_gpus (backend);;
|
|
|
|
for (l = gpus; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaGpuKms *gpu_kms = l->data;
|
|
|
|
|
|
|
|
if (!g_strcmp0 (device_path, meta_gpu_kms_get_file_path (gpu_kms)))
|
|
|
|
{
|
|
|
|
g_warning ("Failed to hotplug secondary gpu '%s': %s",
|
|
|
|
device_path, "device already present");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new_gpu_kms = create_gpu_from_udev_device (native, device, &error);
|
|
|
|
if (!new_gpu_kms)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to hotplug secondary gpu '%s': %s",
|
|
|
|
device_path, error->message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_backend_add_gpu (backend, META_GPU (new_gpu_kms));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connect_udev_device_added_handler (MetaBackendNative *native)
|
|
|
|
{
|
|
|
|
native->udev_device_added_handler_id =
|
|
|
|
g_signal_connect (native->udev, "device-added",
|
|
|
|
G_CALLBACK (on_udev_device_added), native);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disconnect_udev_device_added_handler (MetaBackendNative *native)
|
|
|
|
{
|
2019-11-15 19:25:52 -05:00
|
|
|
g_clear_signal_handler (&native->udev_device_added_handler_id, native->udev);
|
2019-01-11 09:35:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
init_gpus (MetaBackendNative *native,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (native);
|
|
|
|
MetaUdev *udev = meta_backend_native_get_udev (native);
|
|
|
|
GList *devices;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
devices = meta_udev_list_drm_devices (udev, error);
|
|
|
|
if (!devices)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (l = devices; l; l = l->next)
|
|
|
|
{
|
|
|
|
GUdevDevice *device = l->data;
|
|
|
|
MetaGpuKms *gpu_kms;
|
|
|
|
GError *local_error = NULL;
|
|
|
|
|
|
|
|
gpu_kms = create_gpu_from_udev_device (native, device, &local_error);
|
|
|
|
|
|
|
|
if (!gpu_kms)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to open gpu '%s': %s",
|
|
|
|
g_udev_device_get_device_file (device),
|
|
|
|
local_error->message);
|
|
|
|
g_clear_error (&local_error);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_backend_add_gpu (backend, META_GPU (gpu_kms));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free_full (devices, g_object_unref);
|
|
|
|
|
|
|
|
if (g_list_length (meta_backend_get_gpus (backend)) == 0)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
|
|
|
"No GPUs found");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
connect_udev_device_added_handler (native);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-07-24 00:31:32 -04:00
|
|
|
static gboolean
|
|
|
|
meta_backend_native_initable_init (GInitable *initable,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
|
|
|
{
|
2019-01-10 05:30:02 -05:00
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (initable);
|
|
|
|
|
2017-07-24 00:31:32 -04:00
|
|
|
if (!meta_is_stage_views_enabled ())
|
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
|
"The native backend requires stage views");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-10 05:54:07 -05:00
|
|
|
native->launcher = meta_launcher_new (error);
|
|
|
|
if (!native->launcher)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-01-10 12:07:12 -05:00
|
|
|
native->udev = meta_udev_new (native);
|
2019-01-10 05:54:07 -05:00
|
|
|
native->barrier_manager = meta_barrier_manager_native_new ();
|
2019-01-10 05:30:02 -05:00
|
|
|
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
native->kms = meta_kms_new (META_BACKEND (native), error);
|
|
|
|
if (!native->kms)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
if (!init_gpus (native, error))
|
|
|
|
return FALSE;
|
|
|
|
|
2017-07-24 00:31:32 -04:00
|
|
|
return initable_parent_iface->init (initable, cancellable, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
initable_iface_init (GInitableIface *initable_iface)
|
|
|
|
{
|
|
|
|
initable_parent_iface = g_type_interface_peek_parent (initable_iface);
|
|
|
|
|
|
|
|
initable_iface->init = meta_backend_native_initable_init;
|
|
|
|
}
|
|
|
|
|
2014-04-22 12:40:51 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_class_init (MetaBackendNativeClass *klass)
|
|
|
|
{
|
|
|
|
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
|
2014-09-19 11:25:22 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = meta_backend_native_finalize;
|
2014-04-22 12:40:51 -04:00
|
|
|
|
2016-05-04 04:19:23 -04:00
|
|
|
backend_class->create_clutter_backend = meta_backend_native_create_clutter_backend;
|
|
|
|
|
2014-04-22 12:40:51 -04:00
|
|
|
backend_class->post_init = meta_backend_native_post_init;
|
2016-05-04 04:19:23 -04:00
|
|
|
|
2014-04-22 12:40:51 -04:00
|
|
|
backend_class->create_monitor_manager = meta_backend_native_create_monitor_manager;
|
2014-04-22 15:15:11 -04:00
|
|
|
backend_class->create_cursor_renderer = meta_backend_native_create_cursor_renderer;
|
2016-05-07 11:07:46 -04:00
|
|
|
backend_class->create_renderer = meta_backend_native_create_renderer;
|
2017-04-10 05:31:50 -04:00
|
|
|
backend_class->create_input_settings = meta_backend_native_create_input_settings;
|
2014-05-27 14:21:54 -04:00
|
|
|
|
|
|
|
backend_class->warp_pointer = meta_backend_native_warp_pointer;
|
2016-11-30 23:59:47 -05:00
|
|
|
|
|
|
|
backend_class->get_current_logical_monitor = meta_backend_native_get_current_logical_monitor;
|
|
|
|
|
2014-08-04 10:47:35 -04:00
|
|
|
backend_class->set_keymap = meta_backend_native_set_keymap;
|
|
|
|
backend_class->get_keymap = meta_backend_native_get_keymap;
|
2017-08-17 05:01:50 -04:00
|
|
|
backend_class->get_keymap_layout_group = meta_backend_native_get_keymap_layout_group;
|
2014-08-04 10:47:35 -04:00
|
|
|
backend_class->lock_layout_group = meta_backend_native_lock_layout_group;
|
2016-05-20 03:36:05 -04:00
|
|
|
backend_class->update_screen_size = meta_backend_native_update_screen_size;
|
2016-09-08 03:55:44 -04:00
|
|
|
backend_class->set_numlock = meta_backend_native_set_numlock;
|
2014-04-22 12:40:51 -04:00
|
|
|
}
|
|
|
|
|
2014-04-21 19:13:04 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_init (MetaBackendNative *native)
|
|
|
|
{
|
2014-04-21 19:47:04 -04:00
|
|
|
}
|
|
|
|
|
2017-07-06 04:00:56 -04:00
|
|
|
MetaLauncher *
|
|
|
|
meta_backend_native_get_launcher (MetaBackendNative *native)
|
|
|
|
{
|
2018-09-06 08:14:59 -04:00
|
|
|
return native->launcher;
|
2017-07-06 04:00:56 -04:00
|
|
|
}
|
|
|
|
|
2019-01-10 05:30:02 -05:00
|
|
|
MetaUdev *
|
|
|
|
meta_backend_native_get_udev (MetaBackendNative *native)
|
|
|
|
{
|
|
|
|
return native->udev;
|
|
|
|
}
|
|
|
|
|
backends/native: Add basic KMS abstraction building blocks
The intention with KMS abstraction is to hide away accessing the drm
functions behind an API that allows us to have different kind of KMS
implementations, including legacy non-atomic and atomic. The intention
is also that the code interacting with the drm device should be able to
be run in a different thread than the main thread. This means that we
need to make sure that all drm*() API usage must only occur from within
tasks that eventually can be run in the dedicated thread.
The idea here is that MetaKms provides a outward facing API other places
of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
an internal implementation that only gets interacted with via "tasks"
posted via the MetaKms object. These tasks will in the future
potentially be run on the dedicated KMS thread. Initially, we don't
create any new threads.
Likewise, MetaKmsDevice is a outward facing representation of a KMS
device, while MetaKmsImplDevice is the corresponding implementation,
which only runs from within the MetaKmsImpl tasks.
This commit only moves opening and closing the device to this new API,
while leaking the fd outside of the impl enclosure, effectively making
the isolation for drm*() calls pointless. This, however, is necessary to
allow gradual porting of drm interaction, and eventually the file
descriptor in MetaGpuKms will be removed. For now, it's harmless, since
everything still run in the main thread.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-01-29 04:24:44 -05:00
|
|
|
MetaKms *
|
|
|
|
meta_backend_native_get_kms (MetaBackendNative *native)
|
|
|
|
{
|
|
|
|
return native->kms;
|
|
|
|
}
|
|
|
|
|
2014-04-21 19:47:04 -04:00
|
|
|
gboolean
|
|
|
|
meta_activate_vt (int vt, GError **error)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
2017-07-06 04:00:56 -04:00
|
|
|
MetaLauncher *launcher = meta_backend_native_get_launcher (native);
|
2014-04-21 19:47:04 -04:00
|
|
|
|
2017-07-06 04:00:56 -04:00
|
|
|
return meta_launcher_activate_vt (launcher, vt, error);
|
2014-04-21 19:47:04 -04:00
|
|
|
}
|
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
MetaBarrierManagerNative *
|
|
|
|
meta_backend_native_get_barrier_manager (MetaBackendNative *native)
|
|
|
|
{
|
2018-09-06 08:14:59 -04:00
|
|
|
return native->barrier_manager;
|
2015-01-16 03:50:51 -05:00
|
|
|
}
|
|
|
|
|
2014-04-21 19:47:04 -04:00
|
|
|
/**
|
|
|
|
* meta_activate_session:
|
|
|
|
*
|
|
|
|
* Tells mutter to activate the session. When mutter is a
|
2014-10-12 15:48:18 -04:00
|
|
|
* display server, this tells logind to switch over to
|
2014-04-21 19:47:04 -04:00
|
|
|
* the new session.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
meta_activate_session (void)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
|
|
|
|
/* Do nothing. */
|
|
|
|
if (!META_IS_BACKEND_NATIVE (backend))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
|
|
|
|
2018-09-06 08:14:59 -04:00
|
|
|
if (!meta_launcher_activate_session (native->launcher, &error))
|
2014-04-21 19:47:04 -04:00
|
|
|
{
|
|
|
|
g_warning ("Could not activate session: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2014-04-21 19:13:04 -04:00
|
|
|
}
|
2017-03-10 00:55:33 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_backend_native_pause (MetaBackendNative *native)
|
|
|
|
{
|
2017-03-10 03:29:11 -05:00
|
|
|
MetaBackend *backend = META_BACKEND (native);
|
2018-07-12 09:01:55 -04:00
|
|
|
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
|
2017-03-10 03:29:11 -05:00
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerKms *monitor_manager_kms =
|
|
|
|
META_MONITOR_MANAGER_KMS (monitor_manager);
|
2019-09-25 17:04:25 -04:00
|
|
|
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
|
|
|
MetaSeatNative *seat =
|
|
|
|
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
|
2017-03-10 03:29:11 -05:00
|
|
|
|
2019-08-27 06:11:07 -04:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativePause,
|
|
|
|
"Backend (pause)");
|
|
|
|
|
2019-09-25 17:04:25 -04:00
|
|
|
meta_seat_native_release_devices (seat);
|
2018-07-12 09:01:55 -04:00
|
|
|
clutter_stage_freeze_updates (stage);
|
2017-03-10 03:29:11 -05:00
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
disconnect_udev_device_added_handler (native);
|
|
|
|
|
2017-03-10 03:29:11 -05:00
|
|
|
meta_monitor_manager_kms_pause (monitor_manager_kms);
|
2017-03-10 00:55:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void meta_backend_native_resume (MetaBackendNative *native)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = META_BACKEND (native);
|
2018-07-12 09:01:55 -04:00
|
|
|
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
|
2017-03-10 03:29:11 -05:00
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
|
|
|
MetaMonitorManagerKms *monitor_manager_kms =
|
|
|
|
META_MONITOR_MANAGER_KMS (monitor_manager);
|
2019-05-23 11:55:20 -04:00
|
|
|
MetaInputSettings *input_settings;
|
2017-03-10 00:55:33 -05:00
|
|
|
MetaIdleMonitor *idle_monitor;
|
2019-09-25 17:04:25 -04:00
|
|
|
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
|
|
|
MetaSeatNative *seat =
|
|
|
|
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
|
2017-03-10 00:55:33 -05:00
|
|
|
|
2019-08-27 06:11:07 -04:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativeResume,
|
|
|
|
"Backend (resume)");
|
|
|
|
|
2017-03-10 03:29:11 -05:00
|
|
|
meta_monitor_manager_kms_resume (monitor_manager_kms);
|
2017-03-10 00:55:33 -05:00
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
connect_udev_device_added_handler (native);
|
|
|
|
|
2019-09-25 17:04:25 -04:00
|
|
|
meta_seat_native_reclaim_devices (seat);
|
2018-07-12 09:01:55 -04:00
|
|
|
clutter_stage_thaw_updates (stage);
|
2017-03-10 00:55:33 -05:00
|
|
|
|
2018-07-12 09:01:55 -04:00
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
2017-03-10 00:55:33 -05:00
|
|
|
|
|
|
|
idle_monitor = meta_backend_get_idle_monitor (backend, 0);
|
2018-03-20 05:59:04 -04:00
|
|
|
meta_idle_monitor_reset_idletime (idle_monitor);
|
2019-05-23 11:55:20 -04:00
|
|
|
|
|
|
|
input_settings = meta_backend_get_input_settings (backend);
|
|
|
|
meta_input_settings_maybe_restore_numlock_state (input_settings);
|
2019-08-28 03:55:16 -04:00
|
|
|
|
2019-10-02 07:42:51 -04:00
|
|
|
clutter_seat_ensure_a11y_state (CLUTTER_SEAT (seat));
|
2017-03-10 00:55:33 -05:00
|
|
|
}
|