Commit 002c5b8f authored by Jasper St. Pierre's avatar Jasper St. Pierre

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.
parent 1d3dbea2
......@@ -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",
......
......@@ -80,7 +80,7 @@ struct _MetaWaylandCompositor
struct wl_resource *xserver_resource;
MetaLauncher *launcher;
int drm_fd;
gboolean native;
MetaWaylandSeat *seat;
};
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment