Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion platform/drm/cog-platform-drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct _CogDrmPlatform {
CogDrmRenderer *renderer;
CogGLRendererRotation rotation;
GList *rotatable_input_devices;
char *seat_name;
bool draw_cursor;
bool dispatch_pointer;
bool use_gles;
Expand Down Expand Up @@ -245,13 +246,26 @@ parse_bool(const char *value, bool *out)
return false;
}

static void
set_seat_name(CogDrmPlatform *self, const char *seat_name)
{
g_free(self->seat_name);
self->seat_name = g_strdup(seat_name);
}

static void
init_config(CogDrmPlatform *self, CogShell *shell, const char *params_string)
{
drm_data.device_scale = cog_shell_get_device_scale_factor (shell);
g_debug ("init_config: overriding device_scale value, using %.2f from shell",
drm_data.device_scale);

{
const char *env_seat_name = g_getenv("XDG_SEAT");
if (env_seat_name && *env_seat_name)
set_seat_name(self, env_seat_name);
}

self->draw_cursor = g_getenv("COG_PLATFORM_DRM_CURSOR") != NULL;
self->dispatch_pointer = g_getenv("COG_PLATFORM_DRM_POINTER") != NULL;

Expand Down Expand Up @@ -289,6 +303,12 @@ init_config(CogDrmPlatform *self, CogShell *shell, const char *params_string)
g_warning("Invalid renderer '%s', using default.", value);
}

{
g_autofree char *value = g_key_file_get_string(key_file, "drm", "seat", NULL);
if (value && *value)
set_seat_name(self, value);
}

{
g_autoptr(GError) lookup_error = NULL;
gboolean value = g_key_file_get_boolean(key_file, "drm", "cursor", &lookup_error);
Expand Down Expand Up @@ -331,6 +351,11 @@ init_config(CogDrmPlatform *self, CogShell *shell, const char *params_string)
g_warning("Invalid value '%s' for parameter '%s'.", v, k);
else
self->rotation = val;
} else if (g_strcmp0(k, "seat") == 0) {
if (*v)
set_seat_name(self, v);
else
g_warning("Invalid value '%s' for parameter '%s'.", v, k);
} else if (g_strcmp0(k, "cursor") == 0) {
if (!parse_bool(v, &self->draw_cursor))
g_warning("Invalid value '%s' for parameter '%s'.", v, k);
Expand Down Expand Up @@ -1343,7 +1368,9 @@ init_input(CogDrmPlatform *platform)
input_data.rotation = platform->rotation;
input_data.dispatch_pointer = platform->dispatch_pointer;

int ret = libinput_udev_assign_seat (input_data.libinput, "seat0");
g_debug("init_input: assigning libinput to seat '%s'", platform->seat_name);

int ret = libinput_udev_assign_seat(input_data.libinput, platform->seat_name);
if (ret)
return FALSE;
Comment on lines 1374 to 1375

This comment was marked as abuse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this change, separate issue


Expand Down Expand Up @@ -1604,6 +1631,8 @@ cog_drm_platform_finalize(GObject *object)
clear_cursor();
clear_drm();

g_clear_pointer(&self->seat_name, g_free);

G_OBJECT_CLASS(cog_drm_platform_parent_class)->finalize(object);
}

Expand Down Expand Up @@ -1756,6 +1785,7 @@ cog_drm_platform_class_finalize(CogDrmPlatformClass *klass)
static void
cog_drm_platform_init(CogDrmPlatform *self)
{
set_seat_name(self, "seat0");
}

G_MODULE_EXPORT void
Expand Down
Loading