diff --git a/src/api/wayfire/config-backend.hpp b/src/api/wayfire/config-backend.hpp index 8a47601e7..54db71bb6 100644 --- a/src/api/wayfire/config-backend.hpp +++ b/src/api/wayfire/config-backend.hpp @@ -49,7 +49,7 @@ class config_backend_t * described in input-device.xml */ virtual std::shared_ptr get_input_device_section( - wlr_input_device *device); + std::string const & prefix, wlr_input_device *device); virtual ~config_backend_t() = default; diff --git a/src/api/wayfire/plugin.hpp b/src/api/wayfire/plugin.hpp index 3d4779ac2..2d21cbcd1 100644 --- a/src/api/wayfire/plugin.hpp +++ b/src/api/wayfire/plugin.hpp @@ -105,7 +105,7 @@ class plugin_interface_t using wayfire_plugin_load_func = wf::plugin_interface_t * (*)(); /** The version of Wayfire's API/ABI */ -constexpr uint32_t WAYFIRE_API_ABI_VERSION = 2024'10'01; +constexpr uint32_t WAYFIRE_API_ABI_VERSION = 2024'11'21; /** * Each plugin must also provide a function which returns the Wayfire API/ABI diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index 5f149d292..614e11217 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -44,7 +44,7 @@ static struct udev_property_and_desc }; std::shared_ptr wf::config_backend_t::get_input_device_section( - wlr_input_device *device) + std::string const & prefix, wlr_input_device *device) { auto& config = wf::get_core().config; std::shared_ptr section; @@ -65,7 +65,7 @@ std::shared_ptr wf::config_backend_t::get_input_device_sectio continue; } - std::string name = std::string("input-device:") + nonull(value); + std::string name = prefix + ":" + nonull(value); LOGC(INPUT_DEVICES, "Checking for config section [", name, "] ", pd.property_name, " (", pd.description, ")"); section = config.get_section(name); @@ -80,7 +80,7 @@ std::shared_ptr wf::config_backend_t::get_input_device_sectio } std::string name = nonull(device->name); - name = "input-device:" + name; + name = prefix + ":" + name; LOGC(INPUT_DEVICES, "Checking for config section [", name, "]"); section = config.get_section(name); if (section) @@ -90,7 +90,7 @@ std::shared_ptr wf::config_backend_t::get_input_device_sectio } config.merge_section( - config.get_section("input-device")->clone_with_name(name)); + config.get_section(prefix)->clone_with_name(name)); LOGC(INPUT_DEVICES, "Using config section [", name, "]"); return config.get_section(name); diff --git a/src/core/seat/input-manager.cpp b/src/core/seat/input-manager.cpp index a9b4a57a4..fbf0b09ed 100644 --- a/src/core/seat/input-manager.cpp +++ b/src/core/seat/input-manager.cpp @@ -60,7 +60,7 @@ void wf::input_manager_t::configure_input_device(std::unique_ptrget_wlr_handle(); auto cursor = wf::get_core().get_wlr_cursor(); auto section = - wf::get_core().config_backend->get_input_device_section(dev); + wf::get_core().config_backend->get_input_device_section("input-device", dev); auto mapped_output = section->get_option("output")->get_value_str(); if (mapped_output.empty()) @@ -152,8 +152,6 @@ void load_locked_mods_from_config(xkb_mod_mask_t& locked_mods) wf::input_manager_t::input_manager_t() { - wf::pointing_device_t::config.load(); - load_locked_mods_from_config(locked_mods); input_device_created.set_callback([&] (void *data) diff --git a/src/core/seat/keyboard.cpp b/src/core/seat/keyboard.cpp index ad3ab71b1..51a964dea 100644 --- a/src/core/seat/keyboard.cpp +++ b/src/core/seat/keyboard.cpp @@ -121,14 +121,18 @@ void wf::keyboard_t::setup_listeners() wf::keyboard_t::keyboard_t(wlr_input_device *dev) : handle(wlr_keyboard_from_input_device(dev)), device(dev) { - model.load_option("input/xkb_model"); - variant.load_option("input/xkb_variant"); - layout.load_option("input/xkb_layout"); - options.load_option("input/xkb_options"); - rules.load_option("input/xkb_rules"); - - repeat_rate.load_option("input/kb_repeat_rate"); - repeat_delay.load_option("input/kb_repeat_delay"); + auto section = + wf::get_core().config_backend->get_input_device_section("input", dev); + auto section_name = section->get_name(); + + model.load_option(section_name + "/xkb_model"); + variant.load_option(section_name + "/xkb_variant"); + layout.load_option(section_name + "/xkb_layout"); + options.load_option(section_name + "/xkb_options"); + rules.load_option(section_name + "/xkb_rules"); + + repeat_rate.load_option(section_name + "/kb_repeat_rate"); + repeat_delay.load_option(section_name + "/kb_repeat_delay"); // When the configuration options change, mark them as dirty. // They are applied at the config-reloaded signal. diff --git a/src/core/seat/pointing-device.cpp b/src/core/seat/pointing-device.cpp index 725d5dc37..3df748b43 100644 --- a/src/core/seat/pointing-device.cpp +++ b/src/core/seat/pointing-device.cpp @@ -3,32 +3,37 @@ wf::pointing_device_t::pointing_device_t(wlr_input_device *dev) : input_device_impl_t(dev) { + load_options(); update_options(); } wf::pointing_device_t::config_t wf::pointing_device_t::config; -void wf::pointing_device_t::config_t::load() +void wf::pointing_device_t::load_options() { - left_handed_mode.load_option("input/left_handed_mode"); - middle_emulation.load_option("input/middle_emulation"); - - mouse_scroll_speed.load_option("input/mouse_scroll_speed"); - mouse_cursor_speed.load_option("input/mouse_cursor_speed"); - touchpad_cursor_speed.load_option("input/touchpad_cursor_speed"); - touchpad_scroll_speed.load_option("input/touchpad_scroll_speed"); - - mouse_natural_scroll_enabled.load_option("input/mouse_natural_scroll"); - touchpad_tap_enabled.load_option("input/tap_to_click"); - touchpad_dwt_enabled.load_option("input/disable_touchpad_while_typing"); - touchpad_dwmouse_enabled.load_option("input/disable_touchpad_while_mouse"); - touchpad_natural_scroll_enabled.load_option("input/natural_scroll"); - touchpad_drag_lock_enabled.load_option("input/drag_lock"); - - mouse_accel_profile.load_option("input/mouse_accel_profile"); - touchpad_accel_profile.load_option("input/touchpad_accel_profile"); - - touchpad_click_method.load_option("input/click_method"); - touchpad_scroll_method.load_option("input/scroll_method"); + auto section = + wf::get_core().config_backend->get_input_device_section("input", get_wlr_handle()); + auto section_name = section->get_name(); + + config.left_handed_mode.load_option(section_name + "/left_handed_mode"); + config.middle_emulation.load_option(section_name + "/middle_emulation"); + + config.mouse_scroll_speed.load_option(section_name + "/mouse_scroll_speed"); + config.mouse_cursor_speed.load_option(section_name + "/mouse_cursor_speed"); + config.touchpad_cursor_speed.load_option(section_name + "/touchpad_cursor_speed"); + config.touchpad_scroll_speed.load_option(section_name + "/touchpad_scroll_speed"); + + config.mouse_natural_scroll_enabled.load_option(section_name + "/mouse_natural_scroll"); + config.touchpad_tap_enabled.load_option(section_name + "/tap_to_click"); + config.touchpad_dwt_enabled.load_option(section_name + "/disable_touchpad_while_typing"); + config.touchpad_dwmouse_enabled.load_option(section_name + "/disable_touchpad_while_mouse"); + config.touchpad_natural_scroll_enabled.load_option(section_name + "/natural_scroll"); + config.touchpad_drag_lock_enabled.load_option(section_name + "/drag_lock"); + + config.mouse_accel_profile.load_option(section_name + "/mouse_accel_profile"); + config.touchpad_accel_profile.load_option(section_name + "/touchpad_accel_profile"); + + config.touchpad_click_method.load_option(section_name + "/click_method"); + config.touchpad_scroll_method.load_option(section_name + "/scroll_method"); } static void set_libinput_accel_profile(libinput_device *dev, std::string name) diff --git a/src/core/seat/pointing-device.hpp b/src/core/seat/pointing-device.hpp index 1a74e376a..7d1309c5e 100644 --- a/src/core/seat/pointing-device.hpp +++ b/src/core/seat/pointing-device.hpp @@ -10,6 +10,7 @@ struct pointing_device_t : public input_device_impl_t pointing_device_t(wlr_input_device *dev); virtual ~pointing_device_t() = default; + void load_options(); void update_options() override; static struct config_t @@ -31,7 +32,6 @@ struct pointing_device_t : public input_device_impl_t wf::option_wrapper_t touchpad_natural_scroll_enabled; wf::option_wrapper_t mouse_natural_scroll_enabled; wf::option_wrapper_t touchpad_drag_lock_enabled; - void load(); } config; }; }