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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
#include "meta-backend-native.h"
|
|
|
|
#include "meta-backend-native-private.h"
|
|
|
|
|
2014-04-21 19:47:04 -04:00
|
|
|
#include <meta/main.h>
|
2014-04-21 20:45:24 -04:00
|
|
|
#include <clutter/evdev/clutter-evdev.h>
|
2015-05-20 11:05:37 -04:00
|
|
|
#include <libupower-glib/upower.h>
|
2014-04-21 19:13:04 -04:00
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
#include "meta-barrier-native.h"
|
2014-04-21 19:13:04 -04:00
|
|
|
#include "meta-idle-monitor-native.h"
|
2014-04-21 19:41:11 -04:00
|
|
|
#include "meta-monitor-manager-kms.h"
|
2014-04-22 15:15:11 -04:00
|
|
|
#include "meta-cursor-renderer-native.h"
|
2014-04-22 17:03:22 -04:00
|
|
|
#include "meta-launcher.h"
|
2015-07-10 05:01:22 -04:00
|
|
|
#include "backends/meta-cursor-tracker-private.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"
|
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/meta-stage.h"
|
2016-05-04 04:19:23 -04:00
|
|
|
#include "backends/native/meta-clutter-backend-native.h"
|
2016-05-07 11:07:46 -04:00
|
|
|
#include "backends/native/meta-renderer-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"
|
2014-04-21 19:13:04 -04:00
|
|
|
|
2015-10-28 10:45:20 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-11-30 05:46:20 -05:00
|
|
|
struct _MetaBackendNative
|
|
|
|
{
|
|
|
|
MetaBackend parent;
|
|
|
|
};
|
|
|
|
|
2014-04-21 19:47:04 -04:00
|
|
|
struct _MetaBackendNativePrivate
|
|
|
|
{
|
|
|
|
MetaLauncher *launcher;
|
2015-01-16 03:50:51 -05:00
|
|
|
MetaBarrierManagerNative *barrier_manager;
|
2015-05-20 11:05:37 -04:00
|
|
|
UpClient *up_client;
|
2015-05-27 14:10:51 -04:00
|
|
|
guint sleep_signal_id;
|
|
|
|
GCancellable *cancellable;
|
|
|
|
GDBusConnection *system_bus;
|
2014-04-21 19:47:04 -04:00
|
|
|
};
|
|
|
|
typedef struct _MetaBackendNativePrivate MetaBackendNativePrivate;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaBackendNative, meta_backend_native, META_TYPE_BACKEND);
|
2014-04-21 19:13:04 -04:00
|
|
|
|
2014-09-19 11:25:22 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (object);
|
|
|
|
MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
|
|
|
|
|
2014-12-08 06:32:38 -05:00
|
|
|
meta_launcher_free (priv->launcher);
|
2014-09-19 11:25:22 -04:00
|
|
|
|
2015-05-20 11:05:37 -04:00
|
|
|
g_object_unref (priv->up_client);
|
2015-05-27 14:10:51 -04:00
|
|
|
if (priv->sleep_signal_id)
|
|
|
|
g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
|
|
|
|
g_cancellable_cancel (priv->cancellable);
|
|
|
|
g_clear_object (&priv->cancellable);
|
|
|
|
g_clear_object (&priv->system_bus);
|
2015-05-20 11:05:37 -04:00
|
|
|
|
2014-09-19 11:25:22 -04:00
|
|
|
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2015-05-27 14:10:51 -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)
|
|
|
|
{
|
|
|
|
gboolean suspending;
|
|
|
|
g_variant_get (parameters, "(b)", &suspending);
|
|
|
|
if (suspending)
|
|
|
|
return;
|
|
|
|
meta_idle_monitor_native_reset_idletime (meta_idle_monitor_get_core ());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
system_bus_gotten_cb (GObject *object,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaBackendNativePrivate *priv;
|
|
|
|
GDBusConnection *bus;
|
|
|
|
|
|
|
|
bus = g_bus_get_finish (res, NULL);
|
|
|
|
if (!bus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv = meta_backend_native_get_instance_private (META_BACKEND_NATIVE (user_data));
|
|
|
|
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,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2015-05-20 11:05:37 -04:00
|
|
|
static void
|
|
|
|
lid_is_closed_changed_cb (UpClient *client,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (up_client_get_lid_is_closed (client))
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_idle_monitor_native_reset_idletime (meta_idle_monitor_get_core ());
|
|
|
|
}
|
|
|
|
|
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 ());
|
|
|
|
MetaBackendNativePrivate *priv =
|
|
|
|
meta_backend_native_get_instance_private (native);
|
|
|
|
|
|
|
|
meta_barrier_manager_native_process (priv->barrier_manager,
|
|
|
|
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-11-25 01:31:38 -05:00
|
|
|
MetaLogicalMonitor *logical_monitors,
|
|
|
|
unsigned int n_logical_monitors,
|
|
|
|
float *x,
|
|
|
|
float *y)
|
2014-04-21 20:45:24 -04:00
|
|
|
{
|
|
|
|
ClutterPoint current;
|
|
|
|
unsigned int i;
|
2015-03-02 07:46:16 -05:00
|
|
|
float cx, cy;
|
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-11-25 01:31:38 -05:00
|
|
|
for (i = 0; i < n_logical_monitors; i++)
|
2014-04-21 20:45:24 -04:00
|
|
|
{
|
2016-11-25 01:31:38 -05:00
|
|
|
MetaLogicalMonitor *logical_monitor = &logical_monitors[i];
|
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))
|
2014-04-21 20:45: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
MetaMonitorManager *monitor_manager;
|
2016-11-25 01:31:38 -05:00
|
|
|
MetaLogicalMonitor *logical_monitors;
|
|
|
|
unsigned int n_logical_monitors;
|
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
|
|
|
monitor_manager = meta_monitor_manager_get ();
|
2016-11-25 01:31:38 -05:00
|
|
|
logical_monitors =
|
|
|
|
meta_monitor_manager_get_logical_monitors (monitor_manager,
|
|
|
|
&n_logical_monitors);
|
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-11-25 01:31:38 -05:00
|
|
|
constrain_all_screen_monitors (device,
|
|
|
|
logical_monitors, n_logical_monitors,
|
|
|
|
new_x, new_y);
|
2014-04-21 20:45:24 -04: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)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
2014-04-23 09:42:49 -04:00
|
|
|
|
|
|
|
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
|
|
|
|
|
2014-04-22 12:40:51 -04:00
|
|
|
clutter_evdev_set_pointer_constrain_callback (manager, pointer_constrain_callback,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaIdleMonitor *
|
|
|
|
meta_backend_native_create_idle_monitor (MetaBackend *backend,
|
|
|
|
int device_id)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_IDLE_MONITOR_NATIVE,
|
|
|
|
"device-id", device_id,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaMonitorManager *
|
|
|
|
meta_backend_native_create_monitor_manager (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_MONITOR_MANAGER_KMS, NULL);
|
|
|
|
}
|
|
|
|
|
2014-04-22 15:15:11 -04:00
|
|
|
static MetaCursorRenderer *
|
|
|
|
meta_backend_native_create_cursor_renderer (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_CURSOR_RENDERER_NATIVE, NULL);
|
|
|
|
}
|
|
|
|
|
2016-05-07 11:07:46 -04:00
|
|
|
static MetaRenderer *
|
|
|
|
meta_backend_native_create_renderer (MetaBackend *backend)
|
|
|
|
{
|
2016-05-07 11:09:59 -04:00
|
|
|
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
|
|
|
MetaBackendNativePrivate *priv =
|
|
|
|
meta_backend_native_get_instance_private (native);
|
|
|
|
int kms_fd;
|
2016-08-17 23:22:42 -04:00
|
|
|
const char *kms_file_path;
|
2016-10-28 01:57:57 -04:00
|
|
|
GError *error = NULL;
|
2016-05-09 09:22:01 -04:00
|
|
|
MetaRendererNative *renderer_native;
|
2016-05-07 11:09:59 -04:00
|
|
|
|
|
|
|
kms_fd = meta_launcher_get_kms_fd (priv->launcher);
|
2016-08-17 23:22:42 -04:00
|
|
|
kms_file_path = meta_launcher_get_kms_file_path (priv->launcher);
|
|
|
|
renderer_native = meta_renderer_native_new (kms_fd, kms_file_path, &error);
|
2016-05-09 09:22:01 -04:00
|
|
|
if (!renderer_native)
|
|
|
|
{
|
|
|
|
meta_warning ("Failed to create renderer: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return META_RENDERER (renderer_native);
|
2016-05-07 11:07:46 -04:00
|
|
|
}
|
|
|
|
|
2014-05-27 14:21:54 -04:00
|
|
|
static void
|
|
|
|
meta_backend_native_warp_pointer (MetaBackend *backend,
|
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
|
|
|
ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
|
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. */
|
2014-05-27 14:21:54 -04:00
|
|
|
clutter_evdev_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)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
|
|
|
struct xkb_rule_names names;
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
struct xkb_context *context;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
clutter_evdev_set_keyboard_map (manager, keymap);
|
|
|
|
|
2014-08-14 17:32:41 -04:00
|
|
|
g_signal_emit_by_name (backend, "keymap-changed", 0);
|
2014-08-04 10:47:35 -04:00
|
|
|
|
|
|
|
xkb_keymap_unref (keymap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct xkb_keymap *
|
|
|
|
meta_backend_native_get_keymap (MetaBackend *backend)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
|
|
|
return clutter_evdev_get_keyboard_map (manager);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_backend_native_lock_layout_group (MetaBackend *backend,
|
|
|
|
guint idx)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
|
|
|
clutter_evdev_set_keyboard_layout_index (manager, idx);
|
2014-09-10 13:16:01 -04:00
|
|
|
g_signal_emit_by_name (backend, "keymap-layout-group-changed", idx, 0);
|
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)
|
|
|
|
{
|
|
|
|
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
|
|
|
clutter_evdev_set_keyboard_numlock (manager, numlock_state);
|
|
|
|
}
|
|
|
|
|
2015-06-02 04:26:34 -04:00
|
|
|
static gboolean
|
|
|
|
meta_backend_native_get_relative_motion_deltas (MetaBackend *backend,
|
|
|
|
const ClutterEvent *event,
|
|
|
|
double *dx,
|
|
|
|
double *dy,
|
|
|
|
double *dx_unaccel,
|
|
|
|
double *dy_unaccel)
|
|
|
|
{
|
|
|
|
return clutter_evdev_event_get_relative_motion (event,
|
|
|
|
dx, dy,
|
|
|
|
dx_unaccel, dy_unaccel);
|
|
|
|
}
|
|
|
|
|
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);
|
2016-06-08 05:05:31 -04:00
|
|
|
if (meta_is_stage_views_enabled ())
|
|
|
|
meta_stage_native_rebuild_views (stage_native);
|
|
|
|
else
|
|
|
|
meta_stage_native_legacy_set_size (stage_native, width, 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
|
|
|
|
2016-05-20 03:36:05 -04:00
|
|
|
clutter_actor_set_size (stage, width, height);
|
|
|
|
}
|
|
|
|
|
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_idle_monitor = meta_backend_native_create_idle_monitor;
|
|
|
|
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;
|
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;
|
|
|
|
backend_class->lock_layout_group = meta_backend_native_lock_layout_group;
|
2015-06-02 04:26:34 -04:00
|
|
|
backend_class->get_relative_motion_deltas = meta_backend_native_get_relative_motion_deltas;
|
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
|
|
|
MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
|
2015-10-28 10:45:20 -04:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
priv->launcher = meta_launcher_new (&error);
|
|
|
|
if (priv->launcher == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Can't initialize KMS backend: %s\n", error->message);
|
|
|
|
exit (1);
|
|
|
|
}
|
2014-04-21 19:47:04 -04:00
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
priv->barrier_manager = meta_barrier_manager_native_new ();
|
2015-05-20 11:05:37 -04:00
|
|
|
|
|
|
|
priv->up_client = up_client_new ();
|
|
|
|
g_signal_connect (priv->up_client, "notify::lid-is-closed",
|
|
|
|
G_CALLBACK (lid_is_closed_changed_cb), NULL);
|
2015-05-27 14:10:51 -04:00
|
|
|
|
|
|
|
priv->cancellable = g_cancellable_new ();
|
|
|
|
g_bus_get (G_BUS_TYPE_SYSTEM,
|
|
|
|
priv->cancellable,
|
|
|
|
system_bus_gotten_cb,
|
|
|
|
native);
|
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);
|
|
|
|
MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
|
|
|
|
|
|
|
|
return meta_launcher_activate_vt (priv->launcher, vt, error);
|
|
|
|
}
|
|
|
|
|
2015-01-16 03:50:51 -05:00
|
|
|
MetaBarrierManagerNative *
|
|
|
|
meta_backend_native_get_barrier_manager (MetaBackendNative *native)
|
|
|
|
{
|
|
|
|
MetaBackendNativePrivate *priv =
|
|
|
|
meta_backend_native_get_instance_private (native);
|
|
|
|
|
|
|
|
return priv->barrier_manager;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
|
|
|
|
|
2014-04-22 17:08:57 -04:00
|
|
|
if (!meta_launcher_activate_session (priv->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
|
|
|
}
|