Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Expose user's mouse settings #66

Merged
merged 5 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
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
59 changes: 59 additions & 0 deletions data/io.elementary.SettingsDaemon.AccountsService.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,64 @@
<annotation name="org.freedesktop.Accounts.DefaultValue" value="false"/>
</property>

<!--
AccelProfile matches org.gnome.desktop.peripherals.mouse accel-profile
-->

<property name="AccelProfile" type="i" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
</property>

<property name="MouseNaturalScroll" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="false"/>
</property>

<property name="MouseSpeed" type="d" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0.0"/>
</property>

<!--
TouchpadClickMethod matches org.gnome.desktop.peripherals.touchpad click-method
-->

<property name="TouchpadClickMethod" type="i" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="3"/>
</property>

<property name="TouchpadDisableWhileTyping" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="true"/>
</property>

<property name="TouchpadEdgeScrolling" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="false"/>
</property>

<property name="TouchpadNaturalScroll" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="false"/>
</property>

<!--
TouchpadSendEvents matches org.gnome.desktop.peripherals.touchpad send-events
-->

<property name="TouchpadSendEvents" type="i" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
</property>

<property name="TouchpadSpeed" type="d" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0.0"/>
</property>

<property name="TouchpadTapToClick" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="true"/>
</property>

<property name="TouchpadTwoFingerScrolling" type="b" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="true"/>
</property>

<property name="CursorSize" type="i" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="24"/>
</property>
</interface>
</node>
16 changes: 16 additions & 0 deletions src/AccountsService.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@ public interface SettingsDaemon.AccountsService : Object {

public abstract KeyboardLayout[] keyboard_layouts { owned get; set; }
public abstract uint active_keyboard_layout { get; set; }

public abstract bool left_handed { get; set; }
public abstract int accel_profile { get; set; }

public abstract bool mouse_natural_scroll { get; set; }
public abstract double mouse_speed { get; set; }

public abstract int touchpad_click_method { get; set; }
public abstract bool touchpad_disable_while_typing { get; set; }
public abstract bool touchpad_edge_scrolling { get; set; }
public abstract bool touchpad_natural_scroll { get; set; }
public abstract int touchpad_send_events { get; set; }
public abstract double touchpad_speed { get; set; }
public abstract bool touchpad_tap_to_click { get; set; }
public abstract bool touchpad_two_finger_scrolling { get; set; }

public abstract int cursor_size { get; set; }
}

[DBus (name = "io.elementary.pantheon.AccountsService")]
Expand Down
49 changes: 41 additions & 8 deletions src/Backends/MouseSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,65 @@ public class SettingsDaemon.Backends.MouseSettings : GLib.Object {
public unowned AccountsService accounts_service { get; construct; }

private GLib.Settings mouse_settings;
private GLib.Settings touchpad_settings;
private GLib.Settings interface_settings;

public MouseSettings (AccountsService accounts_service) {
Object (accounts_service: accounts_service);
}

construct {
mouse_settings = new GLib.Settings ("org.gnome.desktop.peripherals.mouse");

if (accounts_service.left_handed != mouse_settings.get_boolean ("left-handed")) {
sync_accountsservice_to_gsettings ();
}
touchpad_settings = new GLib.Settings ("org.gnome.desktop.peripherals.touchpad");
interface_settings = new GLib.Settings ("org.gnome.desktop.interface");

sync_gsettings_to_accountsservice ();

mouse_settings.changed.connect ((key) => {
if (key == "left-handed") {
if (key == "accel-profile" ||
key == "left-handed" ||
key == "natural-scroll" ||
key == "speed") {
sync_gsettings_to_accountsservice ();
}
});

touchpad_settings.changed.connect ((key) => {
if (key == "click-method" ||
key == "disable-while-typing" ||
key == "edge-scrolling-enabled" ||
key == "natural-scroll" ||
key == "send-events" ||
key == "speed" ||
key == "tap-to-click" ||
key == "two-finger-scrolling-enabled") {
sync_gsettings_to_accountsservice ();
}
});
}

private void sync_accountsservice_to_gsettings () {
mouse_settings.set_boolean ("left-handed", accounts_service.left_handed);
interface_settings.changed.connect ((key) => {
if (key == "cursor-size") {
sync_gsettings_to_accountsservice ();
}
});
}

private void sync_gsettings_to_accountsservice () {
accounts_service.left_handed = mouse_settings.get_boolean ("left-handed");
accounts_service.accel_profile = mouse_settings.get_enum ("accel-profile");

accounts_service.mouse_natural_scroll = mouse_settings.get_boolean ("natural-scroll");
accounts_service.mouse_speed = mouse_settings.get_double ("speed");

accounts_service.touchpad_click_method = touchpad_settings.get_enum ("click-method");
accounts_service.touchpad_disable_while_typing = touchpad_settings.get_boolean ("disable-while-typing");
accounts_service.touchpad_edge_scrolling = touchpad_settings.get_boolean ("edge-scrolling-enabled");
accounts_service.touchpad_natural_scroll = touchpad_settings.get_boolean ("natural-scroll");
accounts_service.touchpad_send_events = touchpad_settings.get_enum ("send-events");
accounts_service.touchpad_speed = touchpad_settings.get_double ("speed");
accounts_service.touchpad_tap_to_click = touchpad_settings.get_boolean ("tap-to-click");
accounts_service.touchpad_two_finger_scrolling = touchpad_settings.get_boolean ("two-finger-scrolling-enabled");

accounts_service.cursor_size = interface_settings.get_int ("cursor-size");
}
}