When laptop lid is closed, Mir continues to use internal display #2918
Replies: 4 comments
-
Here's the relevant part of the log. The internal display (eDP-1) is simply showing as connected:
|
Beta Was this translation helpful? Give feedback.
-
Some notes following discussion with Chris:
|
Beta Was this translation helpful? Give feedback.
-
Some more notes: I don't see any lid-related events with
So it looks as though acpi is what we should track. And for the current state:
I've seen LID1, LID0 and LID in different places, and I have read that the |
Beta Was this translation helpful? Give feedback.
-
And here's some POC code: #include <ext/stdio_filebuf.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <string.h>
#include <iostream>
namespace
{
int unix_socket_connect(const char *name)
{
struct sockaddr_un addr;
if (strnlen(name, sizeof(addr.sun_path)) > sizeof(addr.sun_path) - 1) {
printf("unix_socket_connect(): socket filename longer than %zu characters: %s",
sizeof(addr.sun_path) - 1, name);
errno = EINVAL;
return -1;
}
auto const fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (fd < 0) {
return fd;
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
sprintf(addr.sun_path, "%s", name);
if (auto const r = connect(fd, (struct sockaddr *)&addr, sizeof(addr))) {
close(fd);
return r;
}
return fd;
}
}
#ifndef ACPID_SOCKETFILE
#define ACPID_SOCKETFILE "/var/run/acpid.socket"
#endif
int main()
{
if (auto const socket_fd = unix_socket_connect(ACPID_SOCKETFILE))
{
// Yes, I know horribly non-standard. But OK for POC
__gnu_cxx::stdio_filebuf<char> filebuf(socket_fd, std::ios::in);
std::istream is(&filebuf);
std::string line;
while (getline(is, line))
{
std::cout << "line: " << line << std::endl;
}
return 0;
}
else
{
fprintf(stderr, "ERROR: can't open socket '%s': %s\n", ACPID_SOCKETFILE, strerror(errno));
exit(EXIT_FAILURE);
}
} |
Beta Was this translation helpful? Give feedback.
-
It isn't uncommon to plug an external display (or displays) and keyboard, mouse into a laptop and close the lid.
I can do this and then sign into a Mir based session (e.g. egmde).
Expect: only the external display(s) is used.
Actual: although the internal display is not lit, windows are placed on it. (And can be seen on opening the lid.)
The same happens if the lid is closed while the Mir session is active: Mir doesn't "see" the lid closing and reconfigure the outputs.
Beta Was this translation helpful? Give feedback.
All reactions