|
3 | 3 | wf::pointing_device_t::pointing_device_t(wlr_input_device *dev) :
|
4 | 4 | input_device_impl_t(dev)
|
5 | 5 | {
|
| 6 | + dev->data = this; |
| 7 | + load_options(); |
6 | 8 | update_options();
|
7 | 9 | }
|
8 | 10 |
|
9 |
| -wf::pointing_device_t::config_t wf::pointing_device_t::config; |
10 |
| -void wf::pointing_device_t::config_t::load() |
| 11 | +void wf::pointing_device_t::load_options() |
11 | 12 | {
|
12 |
| - left_handed_mode.load_option("input/left_handed_mode"); |
13 |
| - middle_emulation.load_option("input/middle_emulation"); |
14 |
| - |
15 |
| - mouse_scroll_speed.load_option("input/mouse_scroll_speed"); |
16 |
| - mouse_cursor_speed.load_option("input/mouse_cursor_speed"); |
17 |
| - touchpad_cursor_speed.load_option("input/touchpad_cursor_speed"); |
18 |
| - touchpad_scroll_speed.load_option("input/touchpad_scroll_speed"); |
19 |
| - |
20 |
| - mouse_natural_scroll_enabled.load_option("input/mouse_natural_scroll"); |
21 |
| - touchpad_tap_enabled.load_option("input/tap_to_click"); |
22 |
| - touchpad_dwt_enabled.load_option("input/disable_touchpad_while_typing"); |
23 |
| - touchpad_dwmouse_enabled.load_option("input/disable_touchpad_while_mouse"); |
24 |
| - touchpad_natural_scroll_enabled.load_option("input/natural_scroll"); |
25 |
| - touchpad_drag_lock_enabled.load_option("input/drag_lock"); |
26 |
| - |
27 |
| - mouse_accel_profile.load_option("input/mouse_accel_profile"); |
28 |
| - touchpad_accel_profile.load_option("input/touchpad_accel_profile"); |
29 |
| - |
30 |
| - touchpad_click_method.load_option("input/click_method"); |
31 |
| - touchpad_scroll_method.load_option("input/scroll_method"); |
| 13 | + auto section = |
| 14 | + wf::get_core().config_backend->get_input_device_section("input", get_wlr_handle()); |
| 15 | + auto section_name = section->get_name(); |
| 16 | + |
| 17 | + left_handed_mode.load_option(section_name + "/left_handed_mode"); |
| 18 | + middle_emulation.load_option(section_name + "/middle_emulation"); |
| 19 | + |
| 20 | + mouse_scroll_speed.load_option(section_name + "/mouse_scroll_speed"); |
| 21 | + mouse_cursor_speed.load_option(section_name + "/mouse_cursor_speed"); |
| 22 | + touchpad_cursor_speed.load_option(section_name + "/touchpad_cursor_speed"); |
| 23 | + touchpad_scroll_speed.load_option(section_name + "/touchpad_scroll_speed"); |
| 24 | + |
| 25 | + mouse_natural_scroll_enabled.load_option(section_name + "/mouse_natural_scroll"); |
| 26 | + touchpad_tap_enabled.load_option(section_name + "/tap_to_click"); |
| 27 | + touchpad_dwt_enabled.load_option(section_name + "/disable_touchpad_while_typing"); |
| 28 | + touchpad_dwmouse_enabled.load_option(section_name + "/disable_touchpad_while_mouse"); |
| 29 | + touchpad_natural_scroll_enabled.load_option(section_name + "/natural_scroll"); |
| 30 | + touchpad_drag_lock_enabled.load_option(section_name + "/drag_lock"); |
| 31 | + |
| 32 | + mouse_accel_profile.load_option(section_name + "/mouse_accel_profile"); |
| 33 | + touchpad_accel_profile.load_option(section_name + "/touchpad_accel_profile"); |
| 34 | + |
| 35 | + touchpad_click_method.load_option(section_name + "/click_method"); |
| 36 | + touchpad_scroll_method.load_option(section_name + "/scroll_method"); |
32 | 37 | }
|
33 | 38 |
|
34 | 39 | static void set_libinput_accel_profile(libinput_device *dev, std::string name)
|
@@ -63,93 +68,104 @@ void wf::pointing_device_t::update_options()
|
63 | 68 | auto dev = wlr_libinput_get_device_handle(get_wlr_handle());
|
64 | 69 | assert(dev);
|
65 | 70 |
|
66 |
| - libinput_device_config_left_handed_set(dev, config.left_handed_mode); |
| 71 | + libinput_device_config_left_handed_set(dev, left_handed_mode); |
67 | 72 |
|
68 | 73 | libinput_device_config_middle_emulation_set_enabled(dev,
|
69 |
| - config.middle_emulation ? |
| 74 | + middle_emulation ? |
70 | 75 | LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED :
|
71 | 76 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
72 | 77 |
|
73 | 78 | /* we are configuring a touchpad */
|
74 | 79 | if (libinput_device_config_tap_get_finger_count(dev) > 0)
|
75 | 80 | {
|
76 | 81 | libinput_device_config_accel_set_speed(dev,
|
77 |
| - config.touchpad_cursor_speed); |
| 82 | + touchpad_cursor_speed); |
78 | 83 |
|
79 |
| - set_libinput_accel_profile(dev, config.touchpad_accel_profile); |
| 84 | + set_libinput_accel_profile(dev, touchpad_accel_profile); |
80 | 85 | libinput_device_config_tap_set_enabled(dev,
|
81 |
| - config.touchpad_tap_enabled ? |
| 86 | + touchpad_tap_enabled ? |
82 | 87 | LIBINPUT_CONFIG_TAP_ENABLED : LIBINPUT_CONFIG_TAP_DISABLED);
|
83 | 88 |
|
84 |
| - if ((std::string)config.touchpad_click_method == "default") |
| 89 | + if ((std::string)touchpad_click_method == "default") |
85 | 90 | {
|
86 | 91 | libinput_device_config_click_set_method(dev,
|
87 | 92 | libinput_device_config_click_get_default_method(dev));
|
88 |
| - } else if ((std::string)config.touchpad_click_method == "none") |
| 93 | + } else if ((std::string)touchpad_click_method == "none") |
89 | 94 | {
|
90 | 95 | libinput_device_config_click_set_method(dev,
|
91 | 96 | LIBINPUT_CONFIG_CLICK_METHOD_NONE);
|
92 |
| - } else if ((std::string)config.touchpad_click_method == "button-areas") |
| 97 | + } else if ((std::string)touchpad_click_method == "button-areas") |
93 | 98 | {
|
94 | 99 | libinput_device_config_click_set_method(dev,
|
95 | 100 | LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
|
96 |
| - } else if ((std::string)config.touchpad_click_method == "clickfinger") |
| 101 | + } else if ((std::string)touchpad_click_method == "clickfinger") |
97 | 102 | {
|
98 | 103 | libinput_device_config_click_set_method(dev,
|
99 | 104 | LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
|
100 | 105 | }
|
101 | 106 |
|
102 |
| - if ((std::string)config.touchpad_scroll_method == "default") |
| 107 | + if ((std::string)touchpad_scroll_method == "default") |
103 | 108 | {
|
104 | 109 | libinput_device_config_scroll_set_method(dev,
|
105 | 110 | libinput_device_config_scroll_get_default_method(dev));
|
106 |
| - } else if ((std::string)config.touchpad_scroll_method == "none") |
| 111 | + } else if ((std::string)touchpad_scroll_method == "none") |
107 | 112 | {
|
108 | 113 | libinput_device_config_scroll_set_method(dev,
|
109 | 114 | LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
|
110 |
| - } else if ((std::string)config.touchpad_scroll_method == "two-finger") |
| 115 | + } else if ((std::string)touchpad_scroll_method == "two-finger") |
111 | 116 | {
|
112 | 117 | libinput_device_config_scroll_set_method(dev,
|
113 | 118 | LIBINPUT_CONFIG_SCROLL_2FG);
|
114 |
| - } else if ((std::string)config.touchpad_scroll_method == "edge") |
| 119 | + } else if ((std::string)touchpad_scroll_method == "edge") |
115 | 120 | {
|
116 | 121 | libinput_device_config_scroll_set_method(dev,
|
117 | 122 | LIBINPUT_CONFIG_SCROLL_EDGE);
|
118 |
| - } else if ((std::string)config.touchpad_scroll_method == "on-button-down") |
| 123 | + } else if ((std::string)touchpad_scroll_method == "on-button-down") |
119 | 124 | {
|
120 | 125 | libinput_device_config_scroll_set_method(dev,
|
121 | 126 | LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
|
122 | 127 | }
|
123 | 128 |
|
124 | 129 | libinput_device_config_dwt_set_enabled(dev,
|
125 |
| - config.touchpad_dwt_enabled ? |
| 130 | + touchpad_dwt_enabled ? |
126 | 131 | LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED);
|
127 | 132 |
|
128 | 133 | libinput_device_config_send_events_set_mode(dev,
|
129 |
| - config.touchpad_dwmouse_enabled ? |
| 134 | + touchpad_dwmouse_enabled ? |
130 | 135 | LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE :
|
131 | 136 | LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
|
132 | 137 |
|
133 | 138 | libinput_device_config_tap_set_drag_lock_enabled(dev,
|
134 |
| - config.touchpad_drag_lock_enabled ? |
| 139 | + touchpad_drag_lock_enabled ? |
135 | 140 | LIBINPUT_CONFIG_DRAG_LOCK_ENABLED :
|
136 | 141 | LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
|
137 | 142 |
|
138 | 143 | if (libinput_device_config_scroll_has_natural_scroll(dev) > 0)
|
139 | 144 | {
|
140 | 145 | libinput_device_config_scroll_set_natural_scroll_enabled(dev,
|
141 |
| - (bool)config.touchpad_natural_scroll_enabled); |
| 146 | + (bool)touchpad_natural_scroll_enabled); |
142 | 147 | }
|
143 | 148 | } else
|
144 | 149 | {
|
145 | 150 | libinput_device_config_accel_set_speed(dev,
|
146 |
| - config.mouse_cursor_speed); |
147 |
| - set_libinput_accel_profile(dev, config.mouse_accel_profile); |
| 151 | + mouse_cursor_speed); |
| 152 | + set_libinput_accel_profile(dev, mouse_accel_profile); |
148 | 153 |
|
149 | 154 | if (libinput_device_config_scroll_has_natural_scroll(dev) > 0)
|
150 | 155 | {
|
151 | 156 | libinput_device_config_scroll_set_natural_scroll_enabled(dev,
|
152 |
| - (bool)config.mouse_natural_scroll_enabled); |
| 157 | + (bool)mouse_natural_scroll_enabled); |
153 | 158 | }
|
154 | 159 | }
|
155 | 160 | }
|
| 161 | + |
| 162 | +double wf::pointing_device_t::get_scroll_speed(wlr_input_device *dev, bool touchpad) |
| 163 | +{ |
| 164 | + if ((touchpad && (dev->type != WLR_INPUT_DEVICE_TABLET_PAD)) || |
| 165 | + (!touchpad && (dev->type != WLR_INPUT_DEVICE_POINTER))) |
| 166 | + { |
| 167 | + return 1.0; |
| 168 | + } |
| 169 | + |
| 170 | + return touchpad ? touchpad_scroll_speed : mouse_scroll_speed; |
| 171 | +} |
0 commit comments