[mutter/wayland] wayland: Don't keep track of the drm FD in the WaylandCompositor
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wayland] wayland: Don't keep track of the drm FD in the WaylandCompositor
- Date: Wed, 1 Jan 2014 01:06:55 +0000 (UTC)
commit 002c5b8f876fb16eaf2342503e8123e649651de3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Dec 31 19:12:44 2013 -0500
wayland: Don't keep track of the drm FD in the WaylandCompositor
As logind can give us a new FD at any time when it resumes. Theoretically,
this is still technically wrong, as the MetaCursorTracker holds onto it.
We'll fix this after we port to logind.
src/core/meta-cursor-tracker.c | 9 ++++--
src/wayland/meta-wayland-private.h | 2 +-
src/wayland/meta-wayland.c | 50 +++++++++++++++++++++--------------
3 files changed, 37 insertions(+), 24 deletions(-)
---
diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c
index 67528c2..550abff 100644
--- a/src/core/meta-cursor-tracker.c
+++ b/src/core/meta-cursor-tracker.c
@@ -616,9 +616,12 @@ make_wayland_cursor_tracker (MetaScreen *screen)
compositor = meta_wayland_compositor_get_default ();
compositor->seat->cursor_tracker = self;
- self->drm_fd = compositor->drm_fd;
- if (self->drm_fd >= 0)
- self->gbm = gbm_create_device (compositor->drm_fd);
+ if (meta_wayland_compositor_is_native (compositor))
+ {
+ CoglRenderer *cogl_renderer = cogl_display_get_renderer (cogl_context_get_display (ctx));
+ self->drm_fd = cogl_kms_renderer_get_kms_fd (cogl_renderer);
+ self->gbm = gbm_create_device (self->drm_fd);
+ }
monitors = meta_monitor_manager_get ();
g_signal_connect_object (monitors, "monitors-changed",
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index 3533034..26cd88e 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -80,7 +80,7 @@ struct _MetaWaylandCompositor
struct wl_resource *xserver_resource;
MetaLauncher *launcher;
- int drm_fd;
+ gboolean native;
MetaWaylandSeat *seat;
};
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 74e709a..84b51ed 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -623,15 +623,31 @@ meta_wayland_log_func (const char *fmt,
g_free (str);
}
+static gboolean
+are_we_native (int *out_drm_fd)
+{
+ ClutterBackend *backend = clutter_get_default_backend ();
+ CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
+ CoglRenderer *cogl_renderer = cogl_display_get_renderer (cogl_context_get_display (cogl_context));
+
+ if (cogl_renderer_get_winsys_id (cogl_renderer) == COGL_WINSYS_ID_EGL_KMS)
+ {
+ *out_drm_fd = cogl_kms_renderer_get_kms_fd (cogl_renderer);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
void
meta_wayland_init (void)
{
MetaWaylandCompositor *compositor = &_meta_wayland_compositor;
MetaMonitorManager *monitors;
- ClutterBackend *backend;
- CoglContext *cogl_context;
- CoglRenderer *cogl_renderer;
char *display_name;
+ int drm_fd;
memset (compositor, 0, sizeof (MetaWaylandCompositor));
@@ -676,25 +692,20 @@ meta_wayland_init (void)
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
g_error ("Failed to initialize Clutter");
- backend = clutter_get_default_backend ();
- cogl_context = clutter_backend_get_cogl_context (backend);
- cogl_renderer = cogl_display_get_renderer (cogl_context_get_display (cogl_context));
-
- if (cogl_renderer_get_winsys_id (cogl_renderer) == COGL_WINSYS_ID_EGL_KMS)
- compositor->drm_fd = cogl_kms_renderer_get_kms_fd (cogl_renderer);
- else
- compositor->drm_fd = -1;
-
- if (compositor->drm_fd >= 0)
+ if (are_we_native (&drm_fd))
{
- GError *error;
-
- error = NULL;
- if (!meta_launcher_set_drm_fd (compositor->launcher, compositor->drm_fd, &error))
+ GError *error = NULL;
+ if (!meta_launcher_set_drm_fd (compositor->launcher, drm_fd, &error))
{
g_error ("Failed to set DRM fd to weston-launch and become DRM master: %s", error->message);
g_error_free (error);
}
+
+ compositor->native = TRUE;
+ }
+ else
+ {
+ compositor->native = FALSE;
}
meta_monitor_manager_initialize ();
@@ -711,8 +722,7 @@ meta_wayland_init (void)
meta_wayland_data_device_manager_init (compositor->wayland_display);
- compositor->seat = meta_wayland_seat_new (compositor->wayland_display,
- compositor->drm_fd >= 0);
+ compositor->seat = meta_wayland_seat_new (compositor->wayland_display, compositor->native);
meta_wayland_init_shell (compositor);
@@ -757,5 +767,5 @@ meta_wayland_finalize (void)
gboolean
meta_wayland_compositor_is_native (MetaWaylandCompositor *compositor)
{
- return compositor->drm_fd >= 0;
+ return compositor->native;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]