Skip to content

Commit

Permalink
drm: Update logical input area size on property changes
Browse files Browse the repository at this point in the history
In addition to setting the logical input area size during initialization
in init_input(), also update the size in cog_drm_platform_set_property().
The code that picks the correct dimensions depending on the rotation is
moved into its own function and reused in both locations.

(cherry picked from commit 461efed)
  • Loading branch information
aperezdc committed Nov 14, 2023
1 parent 1193462 commit 5e76ebb
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions platform/drm/cog-platform-drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,9 +1195,28 @@ clear_input(CogDrmPlatform *platform)
g_clear_pointer (&input_data.udev, udev_unref);
}

static void
update_logical_input_size(CogGLRendererRotation rotation)
{
switch (rotation) {
case COG_GL_RENDERER_ROTATION_0:
case COG_GL_RENDERER_ROTATION_180:
input_data.input_width = drm_data.mode->hdisplay;
input_data.input_height = drm_data.mode->vdisplay;
break;
case COG_GL_RENDERER_ROTATION_90:
case COG_GL_RENDERER_ROTATION_270:
input_data.input_width = drm_data.mode->vdisplay;
input_data.input_height = drm_data.mode->hdisplay;
break;
}
}

static gboolean
init_input(CogDrmPlatform *platform)
{
update_logical_input_size(platform->rotation);

static struct libinput_interface interface = {
.open_restricted = input_interface_open_restricted,
.close_restricted = input_interface_close_restricted,
Expand All @@ -1215,14 +1234,6 @@ init_input(CogDrmPlatform *platform)
if (ret)
return FALSE;

input_data.input_width = drm_data.mode->hdisplay;
input_data.input_height = drm_data.mode->vdisplay;

if (platform->rotation == COG_GL_RENDERER_ROTATION_90 || platform->rotation == COG_GL_RENDERER_ROTATION_270){
input_data.input_width = drm_data.mode->vdisplay;
input_data.input_height = drm_data.mode->hdisplay;
}

for (int i = 0; i < G_N_ELEMENTS (input_data.touch_points); ++i) {
struct wpe_input_touch_event_raw *touch_point = &input_data.touch_points[i];

Expand Down Expand Up @@ -1526,9 +1537,9 @@ cog_drm_platform_set_property(GObject *object, unsigned prop_id, const GValue *v
return;

if (!self->renderer) {
self->rotation = rotation;
update_logical_input_size(self->rotation = rotation);
} else if (cog_drm_renderer_set_rotation(self->renderer, rotation)) {
self->rotation = rotation;
update_logical_input_size(self->rotation = rotation);
if (self->rotatable_input_devices)
g_list_foreach(self->rotatable_input_devices, (GFunc) input_configure_device, self);
} else {
Expand Down

0 comments on commit 5e76ebb

Please sign in to comment.