logind: Mark LidClosed property as "emits change"

It may be useful for DEs to follow changes on this property, esp. now that
recent UPower has removed its own lid handling code.

Related: 07565ef6a1
This commit is contained in:
Carlos Garnacho
2024-01-03 13:51:02 +01:00
committed by Luca Boccassi
parent 09263532b6
commit 501d8b8bc6
3 changed files with 5 additions and 2 deletions

View File

@@ -257,7 +257,6 @@ node /org/freedesktop/login1 {
readonly (st) ScheduledShutdown = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b Docked = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b LidClosed = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly b OnExternalPower = ...;

View File

@@ -11,6 +11,7 @@
#include "async.h"
#include "fd-util.h"
#include "logind-button.h"
#include "logind-dbus.h"
#include "missing_input.h"
#include "string-util.h"
@@ -343,6 +344,7 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
b->lid_closed = true;
button_lid_switch_handle_action(b->manager, true);
button_install_check_event_source(b);
manager_send_changed(b->manager, "LidClosed", NULL);
} else if (ev.code == SW_DOCK) {
log_struct(LOG_INFO,
@@ -361,6 +363,7 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u
b->lid_closed = false;
b->check_event_source = sd_event_source_unref(b->check_event_source);
manager_send_changed(b->manager, "LidClosed", NULL);
} else if (ev.code == SW_DOCK) {
log_struct(LOG_INFO,
@@ -514,6 +517,7 @@ int button_check_switches(Button *b) {
b->lid_closed = bitset_get(switches, SW_LID);
b->docked = bitset_get(switches, SW_DOCK);
manager_send_changed(b->manager, "LidClosed", NULL);
if (b->lid_closed)
button_install_check_event_source(b);

View File

@@ -3576,7 +3576,7 @@ static const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("PreparingForSleep", "b", property_get_preparing, 0, 0),
SD_BUS_PROPERTY("ScheduledShutdown", "(st)", property_get_scheduled_shutdown, 0, 0),
SD_BUS_PROPERTY("Docked", "b", property_get_docked, 0, 0),
SD_BUS_PROPERTY("LidClosed", "b", property_get_lid_closed, 0, 0),
SD_BUS_PROPERTY("LidClosed", "b", property_get_lid_closed, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("OnExternalPower", "b", property_get_on_external_power, 0, 0),
SD_BUS_PROPERTY("RemoveIPC", "b", bus_property_get_bool, offsetof(Manager, remove_ipc), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("RuntimeDirectorySize", "t", NULL, offsetof(Manager, runtime_dir_size), SD_BUS_VTABLE_PROPERTY_CONST),