summaryrefslogtreecommitdiff
path: root/LibGUI/GEventLoop.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-14 17:18:35 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-14 17:18:35 +0100
commitbf58241c11abf25ef4c7ed6be559089ed1fe1dc4 (patch)
treeb01060c118ed273032001c8fbe5cb994d1dc45fd /LibGUI/GEventLoop.cpp
parent00319c248c86bf8454cb1eb11104321d9a8bb671 (diff)
downloadserenity-bf58241c11abf25ef4c7ed6be559089ed1fe1dc4.zip
Port the WindowServer and LibGUI to communicate through local sockets.
This is really cool! :^) Apps currently refuse to start if the WindowServer isn't listening on the socket in /wsportal. This makes sense, but I guess it would also be nice to have some sort of "wait for server on startup" mode. This has performance issues, and I'll work on those, but this stuff seems to actually work and I'm very happy with that.
Diffstat (limited to 'LibGUI/GEventLoop.cpp')
-rw-r--r--LibGUI/GEventLoop.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp
index f7dfe73555..9ff3490ac2 100644
--- a/LibGUI/GEventLoop.cpp
+++ b/LibGUI/GEventLoop.cpp
@@ -11,8 +11,10 @@
#include <LibC/string.h>
#include <LibC/time.h>
#include <LibC/sys/select.h>
-#include <errno.h>
-#include <string.h>
+#include <LibC/sys/socket.h>
+#include <LibC/errno.h>
+#include <LibC/string.h>
+#include <LibC/stdlib.h>
//#define GEVENTLOOP_DEBUG
@@ -28,10 +30,20 @@ GEventLoop::GEventLoop()
if (!s_mainGEventLoop)
s_mainGEventLoop = this;
- m_event_fd = open("/dev/gui_events", O_RDWR | O_NONBLOCK | O_CLOEXEC);
+ m_event_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
if (m_event_fd < 0) {
- perror("GEventLoop(): open");
- exit(1);
+ perror("socket");
+ ASSERT_NOT_REACHED();
+ }
+
+ sockaddr_un address;
+ address.sun_family = AF_LOCAL;
+ strcpy(address.sun_path, "/wsportal");
+ int rc = connect(m_event_fd, (const sockaddr*)&address, sizeof(address));
+ if (rc < 0) {
+ dbgprintf("connect failed: %d, %s\n", errno, strerror(errno));
+ perror("connect");
+ ASSERT_NOT_REACHED();
}
}