forked from drath/libratbag
Align resolution creation with the button/profile/led creation bits
Resolutions were still stored in an array over a linked list like the buttons/leds/profiles and initializing them from a driver was different than buttons or leds. This brings the resolutions in line with the buttons and leds. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
d5dc8eccd6
commit
e9008eeaba
@@ -35,7 +35,6 @@ test_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
struct ratbag_test_device *d = ratbag_get_drv_data(profile->device);
|
||||
struct ratbag_test_profile *p;
|
||||
struct ratbag_test_resolution *r;
|
||||
struct ratbag_resolution *res;
|
||||
unsigned int i;
|
||||
bool active_set = false;
|
||||
bool default_set = false;
|
||||
@@ -44,9 +43,13 @@ test_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
|
||||
p = &d->profiles[index];
|
||||
for (i = 0; i < d->num_resolutions; i++) {
|
||||
_cleanup_resolution_ struct ratbag_resolution *res;
|
||||
|
||||
r = &p->resolutions[i];
|
||||
res = ratbag_resolution_init(profile, i, r->xres, r->yres, r->hz);
|
||||
|
||||
res = ratbag_profile_get_resolution(profile, i);
|
||||
assert(res);
|
||||
ratbag_resolution_set_resolution(res, r->xres, r->yres, r->hz);
|
||||
res->is_active = r->active;
|
||||
if (r->active)
|
||||
active_set = true;
|
||||
@@ -59,13 +62,14 @@ test_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
|
||||
/* special case triggered by the test suite when num_resolutions is 0 */
|
||||
if (d->num_resolutions) {
|
||||
_cleanup_resolution_ struct ratbag_resolution *res;
|
||||
|
||||
res = ratbag_profile_get_resolution(profile, 0);
|
||||
assert(res);
|
||||
if (!active_set)
|
||||
res->is_active = true;
|
||||
if (!default_set)
|
||||
res->is_default = true;
|
||||
ratbag_resolution_unref(res);
|
||||
}
|
||||
|
||||
profile->is_active = p->active;
|
||||
@@ -225,6 +229,7 @@ test_probe(struct ratbag_device *device, const void *data)
|
||||
test_device->num_resolutions,
|
||||
test_device->num_buttons,
|
||||
test_device->num_leds);
|
||||
|
||||
if (test_device->num_profiles > 1) {
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_DISABLE_PROFILE);
|
||||
|
||||
Reference in New Issue
Block a user