diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-02-24 16:22:23 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-02-24 16:22:23 +0100 |
commit | 2d62c530d2b4c2730abff715b7342f1402114513 (patch) | |
tree | a04f57d94d9b01a958b922da5608ba9630efff26 /src/login/logind-button.c | |
parent | 539237644eef4dbb9e5428dd249d7ee8392427d0 (diff) |
logind: detect whether the system is docked, and if it is inhibit lid switch processing
This should make operation nicer with docking stations, but will not
cover anything that does not implement SW_DOCK.
Diffstat (limited to 'src/login/logind-button.c')
-rw-r--r-- | src/login/logind-button.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/login/logind-button.c b/src/login/logind-button.c index 720071a2a8..060978dd34 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -188,6 +188,14 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u b->lid_closed = true; manager_handle_action(b->manager, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, true); button_install_check_event_source(b); + + } else if (ev.code == SW_DOCK) { + log_struct(LOG_INFO, + "MESSAGE=System docked.", + MESSAGE_ID(SD_MESSAGE_SYSTEM_DOCKED), + NULL); + + b->docked = true; } } else if (ev.type == EV_SW && ev.value == 0) { @@ -200,6 +208,14 @@ 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); + + } else if (ev.code == SW_DOCK) { + log_struct(LOG_INFO, + "MESSAGE=System undocked.", + MESSAGE_ID(SD_MESSAGE_SYSTEM_UNDOCKED), + NULL); + + b->docked = false; } } @@ -247,7 +263,7 @@ fail: return r; } -int button_check_lid(Button *b) { +int button_check_switches(Button *b) { uint8_t switches[SW_MAX/8+1] = {}; assert(b); @@ -258,11 +274,10 @@ int button_check_lid(Button *b) { return -errno; b->lid_closed = (switches[SW_LID/8] >> (SW_LID % 8)) & 1; + b->docked = (switches[SW_DOCK/8] >> (SW_DOCK % 8)) & 1; - if (b->lid_closed) { - manager_handle_action(b->manager, INHIBIT_HANDLE_LID_SWITCH, b->manager->handle_lid_switch, b->manager->lid_switch_ignore_inhibited, true); + if (b->lid_closed) button_install_check_event_source(b); - } return 0; } |