X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-core.c;h=a6ff5add95910000709460b82b779a2299e394fc;hb=fed6df828d86c053a96d5b50af75c53eb8dd4666;hp=ca34d378ff02fdffdf0c98b93dbce61f7cba08ac;hpb=61376f96a98291b5421bfd79a15ca4db50c2a3fe;p=elogind.git diff --git a/src/login/logind-core.c b/src/login/logind-core.c index ca34d378f..a6ff5add9 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -101,7 +101,7 @@ int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User ** assert(m); assert(name); - u = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); + u = hashmap_get(m->users, UID_TO_PTR(uid)); if (!u) { u = user_new(m, uid, gid, name); if (!u) @@ -520,7 +520,7 @@ int manager_count_displays(Manager *m) { p = udev_device_get_parent(d); if (!p) - return -ENOMEM; + continue; /* If the parent shares the same subsystem as the * device we are looking at then it is a connector, @@ -537,3 +537,25 @@ int manager_count_displays(Manager *m) { return n; } + +bool manager_is_docked_or_multiple_displays(Manager *m) { + int n; + + /* If we are docked don't react to lid closing */ + if (manager_is_docked(m)) { + log_debug("System is docked."); + return true; + } + + /* If we have more than one display connected, + * assume that we are docked. */ + n = manager_count_displays(m); + if (n < 0) + log_warning_errno(n, "Display counting failed: %m"); + else if (n > 1) { + log_debug("Multiple (%i) displays connected.", n); + return true; + } + + return false; +}