After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 769179 - settings: Support mouse and trackball accel profile
settings: Support mouse and trackball accel profile
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
: 763293 (view as bug list)
Depends on: 765218
Blocks:
 
 
Reported: 2016-07-26 08:21 UTC by Jonas Ådahl
Modified: 2016-09-13 11:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
settings: Support mouse and trackball accel profile (19.15 KB, patch)
2016-07-26 08:21 UTC, Jonas Ådahl
committed Details | Review
MetaInputSettings: Don't initialize the same setting twice (1.41 KB, patch)
2016-07-29 01:29 UTC, Jonas Ådahl
committed Details | Review
MetaInputSettings: Initialize the accel-profile setting (1.48 KB, patch)
2016-07-29 01:30 UTC, Jonas Ådahl
none Details | Review
MetaInputSettings: Initialize the accel-profile setting (1.68 KB, patch)
2016-07-29 04:36 UTC, Jonas Ådahl
committed Details | Review

Description Jonas Ådahl 2016-07-26 08:21:29 UTC
Hooks up to org.gnome.desktop.peripherals.[mouse|trackball].accel-profile.
Depends on bug 765218.
Comment 1 Jonas Ådahl 2016-07-26 08:21:33 UTC
Created attachment 332130 [details] [review]
settings: Support mouse and trackball accel profile

Support changing the mouse and trackball acceleration profile. This
makes it possible to for example disable pointer acceleration by
choosing the 'flat' profile.

This adds an optional dependency on gudev. Gudev is used by the X11
backend to detect whether a device is a mouse or not. Without gudev
support, the accel profile settings has have effect for mouse devices.

Trackball still uses the "strstr" approach, since udev doesn't support
tagging devices as trackball devices yet.
Comment 2 Florian Müllner 2016-07-28 10:01:17 UTC
Review of attachment 332130 [details] [review]:

"Without gudev support, the accel profile settings has have effect for mouse devices"

"has have" => "has no"?

::: src/backends/x11/meta-input-settings-x11.c
@@ +479,3 @@
+    meta_input_settings_x11_get_instance_private (settings_x11);
+
+  g_object_unref (&priv->udev_client);

Shouldn't references be released in dispose()? Could use g_clear_object().
Comment 3 Jonas Ådahl 2016-07-28 10:04:41 UTC
(In reply to Florian Müllner from comment #2)
> Review of attachment 332130 [details] [review] [review]:
> 
> "Without gudev support, the accel profile settings has have effect for mouse
> devices"
> 
> "has have" => "has no"?

Oops. Seems I "fixed" my grammar by making it worse.

> 
> ::: src/backends/x11/meta-input-settings-x11.c
> @@ +479,3 @@
> +    meta_input_settings_x11_get_instance_private (settings_x11);
> +
> +  g_object_unref (&priv->udev_client);
> 
> Shouldn't references be released in dispose()? Could use g_clear_object().

I thought that only mattered if there was a risk of circular dependencies, which there are no here. I could change it to a dispose I guess.
Comment 4 Florian Müllner 2016-07-28 10:31:46 UTC
(In reply to Jonas Ådahl from comment #3)
> > Shouldn't references be released in dispose()? Could use g_clear_object().
> 
> I thought that only mattered if there was a risk of circular dependencies,
> which there are no here.

Yeah, I just have the habit of using the "right" function in all cases to avoid mistakes when later additions would require dispose() but are just added to the existing function. It's unlikely that this will ever be an issue in this case, so up to you if you want to change it or not.
Comment 5 Jonas Ådahl 2016-07-28 12:16:12 UTC
Changed to g_clear_object() and dispose instead of finalize.

Attachment 332130 [details] pushed as 23c4ac6 - settings: Support mouse and trackball accel profile
Comment 6 Alberts Muktupāvels 2016-07-28 18:14:35 UTC
update_pointer_accel_profile (input_settings, mouse_settings, device);
update_pointer_accel_profile (input_settings, trackball_settings, device);

Should not above lines be added in apply_device_settings? Like other update_* functions...
Comment 7 Jonas Ådahl 2016-07-29 01:29:35 UTC
(In reply to Alberts Muktupāvels from comment #6)
> update_pointer_accel_profile (input_settings, mouse_settings, device);
> update_pointer_accel_profile (input_settings, trackball_settings, device);
> 
> Should not above lines be added in apply_device_settings? Like other
> update_* functions...

Well spotted. Attaching patches.
Comment 8 Jonas Ådahl 2016-07-29 01:29:58 UTC
Created attachment 332324 [details] [review]
MetaInputSettings: Don't initialize the same setting twice

Two settings were set twice on the same device. Now instead group the
generic update functions together, removing the redundant calls.
Comment 9 Jonas Ådahl 2016-07-29 01:30:04 UTC
Created attachment 332325 [details] [review]
MetaInputSettings: Initialize the accel-profile setting

Shouldn't just update them when they change; they also need to be
set when initializing.
Comment 10 Jonas Ådahl 2016-07-29 04:36:52 UTC
Created attachment 332328 [details] [review]
MetaInputSettings: Initialize the accel-profile setting

Shouldn't just update them when they change; they also need to be
set when initializing.

---

Now actually compile tested.
Comment 11 Carlos Garnacho 2016-08-01 20:59:01 UTC
Comment on attachment 332324 [details] [review]
MetaInputSettings: Don't initialize the same setting twice

LGTM
Comment 12 Carlos Garnacho 2016-08-01 21:16:48 UTC
Comment on attachment 332328 [details] [review]
MetaInputSettings: Initialize the accel-profile setting

...but here in turn you seem to add doubly calls on the same device, just with different settings :)

Reading through code I see a similar problem in meta_input_settings_changed_cb(), update_pointer_accel_profile(..., NULL) is called from mouse/trackball settings, but no check is performed when iterating through the devices, that looks like it will result in all devices being updated to whatever setting was changed last.

I'll suggest splitting the device ==/!= NULL cases into 2 functions:

- update_pointer_accel_profile(MetaInputSettings*, ClutterInputDevice*) that looks up the right settings based on the device type
- update_pointer_accel_profile_from_settings(MetaInputSettings,GSettings) (or _foreach maybe?) that iterates through devices and skips the ones where the given GSettings don't apply.
Comment 13 Jonas Ådahl 2016-08-02 04:25:20 UTC
(In reply to Carlos Garnacho from comment #12)
> Comment on attachment 332328 [details] [review] [review]
> MetaInputSettings: Initialize the accel-profile setting
> 
> ...but here in turn you seem to add doubly calls on the same device, just
> with different settings :)

Right. The passed settings is used to determine the device that gets updated.

> 
> Reading through code I see a similar problem in
> meta_input_settings_changed_cb(), update_pointer_accel_profile(..., NULL) is
> called from mouse/trackball settings, but no check is performed when
> iterating through the devices, that looks like it will result in all devices
> being updated to whatever setting was changed last.

Since the check is backend specific, it is checked there, in the backend. In the -native backend we use the struct udev_device from libinput_device, while in the -x11 backend we use the device node from the X11 device and create a GUdevDevice from it. So, only the correct device will get updated still, even if update_pointer_accel_profile is called with it passed.

Maybe we should consider moving device class tagging to ClutterInputDevice and have the clutter backneds deal with it. The API we have is awkward though, we have "device type" which can be "pointer" or "touchpad" etc, and if we introduce "trackball" and "mouse", we'd break things here and there. The reasonable thing, I think, would be to introduce another API next to device type (and remove the touchpad device type). If so, that should be a follow up though IMHO.

> 
> I'll suggest splitting the device ==/!= NULL cases into 2 functions:
> 
> - update_pointer_accel_profile(MetaInputSettings*, ClutterInputDevice*) that
> looks up the right settings based on the device type
> - update_pointer_accel_profile_from_settings(MetaInputSettings,GSettings)
> (or _foreach maybe?) that iterates through devices and skips the ones where
> the given GSettings don't apply.

I suppose we could. update_pointer_accel_profil() would still need the GSettings though, if we don't want to have the backend find the proper GSetting and fetch the value itself (which we don't seem to do anywhere yet). It'd do the exact same thing passing NULL vs not NULL as input device.
Comment 14 Carlos Garnacho 2016-08-02 10:40:44 UTC
(In reply to Jonas Ådahl from comment #13)
> (In reply to Carlos Garnacho from comment #12)
> > Comment on attachment 332328 [details] [review] [review] [review]
> > MetaInputSettings: Initialize the accel-profile setting
> > 
> > ...but here in turn you seem to add doubly calls on the same device, just
> > with different settings :)
> 
> Right. The passed settings is used to determine the device that gets updated.

Ah, the thing I missed is that it's x11/native implementations which perform the check on the device. This makes the problems I saw somewhat moot.

> 
> > 
> > Reading through code I see a similar problem in
> > meta_input_settings_changed_cb(), update_pointer_accel_profile(..., NULL) is
> > called from mouse/trackball settings, but no check is performed when
> > iterating through the devices, that looks like it will result in all devices
> > being updated to whatever setting was changed last.
> 
> Since the check is backend specific, it is checked there, in the backend. In
> the -native backend we use the struct udev_device from libinput_device,
> while in the -x11 backend we use the device node from the X11 device and
> create a GUdevDevice from it. So, only the correct device will get updated
> still, even if update_pointer_accel_profile is called with it passed.

Uhm... This is the first precedence of device checks being performed in the vfunc. It was an original design choice to keep these checks out from vfuncs, and make those only about applying the configuration. 

Back then, ClutterInputDeviceType was "sufficient" too... When adding later trackball-specific configuration, I added this meta_input_device_is_trackball() helper in meta-input-settings.c. I agree your backend-specific checks are far more correct, but I kinda expected this to be used when reading your patch last evening :).

> 
> Maybe we should consider moving device class tagging to ClutterInputDevice
> and have the clutter backneds deal with it. The API we have is awkward
> though, we have "device type" which can be "pointer" or "touchpad" etc, and
> if we introduce "trackball" and "mouse", we'd break things here and there.
> The reasonable thing, I think, would be to introduce another API next to
> device type (and remove the touchpad device type). If so, that should be a
> follow up though IMHO.

I agree, previously thinking about this I came up to the conclusion we should split capabilities (eg. rel/abs,key,...) from device type (trackball, touchpad, "test",...). Still, I don't think ClutterInputDeviceType can be reused in a compatible manner :(.

> 
> > 
> > I'll suggest splitting the device ==/!= NULL cases into 2 functions:
> > 
> > - update_pointer_accel_profile(MetaInputSettings*, ClutterInputDevice*) that
> > looks up the right settings based on the device type
> > - update_pointer_accel_profile_from_settings(MetaInputSettings,GSettings)
> > (or _foreach maybe?) that iterates through devices and skips the ones where
> > the given GSettings don't apply.
> 
> I suppose we could. update_pointer_accel_profil() would still need the
> GSettings though, if we don't want to have the backend find the proper
> GSetting and fetch the value itself (which we don't seem to do anywhere
> yet). It'd do the exact same thing passing NULL vs not NULL as input device.

In other places where this happens (mouse vs touchpad, basically), we have this get_settings_for_device_type() helper. Unfortunately I don't think we can make this helper cover the trackball case, as trackballs want to use priv->mouse_settings for most other settings, and we don't have a "trackball" device type.
Comment 15 Jonas Ådahl 2016-08-02 11:19:38 UTC
(In reply to Carlos Garnacho from comment #14)
> (In reply to Jonas Ådahl from comment #13)
> > (In reply to Carlos Garnacho from comment #12)
> > > Reading through code I see a similar problem in
> > > meta_input_settings_changed_cb(), update_pointer_accel_profile(..., NULL) is
> > > called from mouse/trackball settings, but no check is performed when
> > > iterating through the devices, that looks like it will result in all devices
> > > being updated to whatever setting was changed last.
> > 
> > Since the check is backend specific, it is checked there, in the backend. In
> > the -native backend we use the struct udev_device from libinput_device,
> > while in the -x11 backend we use the device node from the X11 device and
> > create a GUdevDevice from it. So, only the correct device will get updated
> > still, even if update_pointer_accel_profile is called with it passed.
> 
> Uhm... This is the first precedence of device checks being performed in the
> vfunc. It was an original design choice to keep these checks out from
> vfuncs, and make those only about applying the configuration. 
> 
> Back then, ClutterInputDeviceType was "sufficient" too... When adding later
> trackball-specific configuration, I added this
> meta_input_device_is_trackball() helper in meta-input-settings.c. I agree
> your backend-specific checks are far more correct, but I kinda expected this
> to be used when reading your patch last evening :).

Well, could use is-trackball() but then half of the device type checking would in be -native/x11 and half in the generic, which seemed wrong. FWIW, I talked to Peter about trackball identification, and we concluded that we should just put it in udev with the rest of all the identification.

> 
> > 
> > Maybe we should consider moving device class tagging to ClutterInputDevice
> > and have the clutter backneds deal with it. The API we have is awkward
> > though, we have "device type" which can be "pointer" or "touchpad" etc, and
> > if we introduce "trackball" and "mouse", we'd break things here and there.
> > The reasonable thing, I think, would be to introduce another API next to
> > device type (and remove the touchpad device type). If so, that should be a
> > follow up though IMHO.
> 
> I agree, previously thinking about this I came up to the conclusion we
> should split capabilities (eg. rel/abs,key,...) from device type (trackball,
> touchpad, "test",...). Still, I don't think ClutterInputDeviceType can be
> reused in a compatible manner :(.

Right. I think the clutter device type should just be 'keyboard', 'pointer', 'touch', 'tablet' and then we introduce another thing... hmm. clutter_input_device_pointer_type()? I.e. something that'd be 'mouse', 'touchpad', 'trackball', 'trackpoint' maybe. That way we don't need to duplicate 'keyboard' and 'touch' in a new type since those don't have that many differnet type of hardware incarnations

> 
> > 
> > > 
> > > I'll suggest splitting the device ==/!= NULL cases into 2 functions:
> > > 
> > > - update_pointer_accel_profile(MetaInputSettings*, ClutterInputDevice*) that
> > > looks up the right settings based on the device type
> > > - update_pointer_accel_profile_from_settings(MetaInputSettings,GSettings)
> > > (or _foreach maybe?) that iterates through devices and skips the ones where
> > > the given GSettings don't apply.
> > 
> > I suppose we could. update_pointer_accel_profil() would still need the
> > GSettings though, if we don't want to have the backend find the proper
> > GSetting and fetch the value itself (which we don't seem to do anywhere
> > yet). It'd do the exact same thing passing NULL vs not NULL as input device.
> 
> In other places where this happens (mouse vs touchpad, basically), we have
> this get_settings_for_device_type() helper. Unfortunately I don't think we
> can make this helper cover the trackball case, as trackballs want to use
> priv->mouse_settings for most other settings, and we don't have a
> "trackball" device type.

So what do you suggest?
Comment 16 Carlos Garnacho 2016-08-02 13:26:41 UTC
Comment on attachment 332328 [details] [review]
MetaInputSettings: Initialize the accel-profile setting

The patch looks alright to me after seeing the x11/native specific code checks the device type. There's improvements to do here, but let's take those to a different bug.
Comment 17 Carlos Garnacho 2016-08-02 13:27:29 UTC
Comment on attachment 332328 [details] [review]
MetaInputSettings: Initialize the accel-profile setting

The patch looks alright to me after seeing the x11/native specific code checks the device type. There's improvements to do here, but let's take those to a different bug.
Comment 18 Jonas Ådahl 2016-08-03 02:49:52 UTC
Attachment 332324 [details] pushed as 53e3d0d - MetaInputSettings: Don't initialize the same setting twice
Attachment 332328 [details] pushed as 53061c7 - MetaInputSettings: Initialize the accel-profile setting
Comment 19 Carlos Garnacho 2016-08-03 10:20:54 UTC
Filed bug #769460 about the device type detection.
Comment 20 Rui Matos 2016-09-13 11:28:02 UTC
*** Bug 763293 has been marked as a duplicate of this bug. ***