Disable logic during suspend to avoid race conditions

master
Werner Sembach 3 months ago
parent fe34fb63f7
commit ec2f276ef9

@ -31,10 +31,12 @@ using std::endl;
int lockfile;
gboolean isMousePluggedInPrev;
gboolean isEnabledSave;
gboolean isSuspending;
GDBusProxy *kded_modules_touchpad = NULL;
GDBusProxy *solid_power_management = NULL;
static void kded_modules_touchpad_handler(GDBusProxy *proxy, __attribute__((unused)) char *sender_name, char *signal_name, GVariant *parameters, __attribute__((unused)) gpointer user_data) {
if (!isSuspending) {
if (!strcmp("enabledChanged", signal_name) && g_variant_is_of_type(parameters, (const GVariantType *)"(b)") && g_variant_n_children(parameters)) {
GVariant *enabledChanged = g_variant_get_child_value(parameters, 0);
@ -80,9 +82,12 @@ static void kded_modules_touchpad_handler(GDBusProxy *proxy, __attribute__((unus
}
}
}
}
static void solid_power_management_handler(__attribute__((unused)) GDBusProxy *proxy, __attribute__((unused)) char *sender_name, char *signal_name, __attribute__((unused)) GVariant *parameters, __attribute__((unused)) gpointer user_data) {
if (!strcmp("aboutToSuspend", signal_name)) {
isSuspending = true;
if (set_touchpad_state(1)) {
cerr << "solid_power_management_handler(...): set_touchpad_state(...) failed." << endl;
}
@ -91,6 +96,8 @@ static void solid_power_management_handler(__attribute__((unused)) GDBusProxy *p
}
}
else if (!strcmp("resumingFromSuspend", signal_name)) {
isSuspending = false;
if (flock(lockfile, LOCK_EX)) {
cerr << "solid_power_management_handler(...): flock(...) failed." << endl;
}

Loading…
Cancel
Save