- /* If the key handling is turned off, don't do anything */
- if (handle == HANDLE_IGNORE) {
- log_debug("Refusing key handling, as it is turned off.");
- return 0;
- }
-
- /* If the key handling is inhibited, don't do anything */
- if (manager_is_inhibited(b->manager, inhibit_key, INHIBIT_BLOCK, NULL, true, false, 0)) {
- log_debug("Refusing key handling, %s is inhibited.", inhibit_what_to_string(inhibit_key));
- return 0;
- }
-
- /* Locking is handled differently from the rest. */
- if (handle == HANDLE_LOCK) {
- log_info("Locking sessions...");
- session_send_lock_all(b->manager, true);
- return 1;
- }
-
- inhibit_operation = handle == HANDLE_SUSPEND || handle == HANDLE_HIBERNATE || handle == HANDLE_HYBRID_SLEEP ? INHIBIT_SLEEP : INHIBIT_SHUTDOWN;
-
- /* If the actual operation is inhibited, warn and fail */
- if (!ignore_inhibited &&
- manager_is_inhibited(b->manager, inhibit_operation, INHIBIT_BLOCK, NULL, false, false, 0)) {
-
+ r = manager_handle_action(b->manager, inhibit_key, handle, ignore_inhibited, is_edge);
+ if (r > 0)
+ /* We are executing the operation, so make sure we don't
+ * execute another one until the lid is opened/closed again */
+ b->lid_close_queued = false;