[gtk/wip.win32.fixes: 248/255] partial WIP port of GDK4-Broadway to Windows...
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip.win32.fixes: 248/255] partial WIP port of GDK4-Broadway to Windows...
- Date: Mon, 4 Oct 2021 10:15:03 +0000 (UTC)
commit 22b809c67eef640ca590e88ecda5bd1f6ade8394
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jun 21 11:26:45 2021 +0800
partial WIP port of GDK4-Broadway to Windows...
gdk/broadway/broadwayd.c | 30 ++++++++++++++++++++++++++++--
gdk/broadway/gdkbroadway-server.c | 29 ++++++++++++++++++++++++++---
2 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/gdk/broadway/broadwayd.c b/gdk/broadway/broadwayd.c
index 9cfa48f138..4f7057f5dc 100644
--- a/gdk/broadway/broadwayd.c
+++ b/gdk/broadway/broadwayd.c
@@ -17,6 +17,10 @@
#include <gio/gunixfdmessage.h>
#endif
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
+
#include "broadway-server.h"
BroadwayServer *server;
@@ -570,13 +574,32 @@ main (int argc, char *argv[])
}
if (display == NULL)
- display = ":0";
+ {
+#ifdef G_OS_UNIX
+ display = ":0";
+#elif defined (G_OS_WIN32)
+ display = ":tcp";
+#endif
+ }
+
+ if (g_str_has_prefix (display, ":tcp"))
+ {
+ GInetAddress *inet;
- if (display[0] == ':' && g_ascii_isdigit(display[1]))
+ port = 9090 + strtol (display + strlen (":tcp"), NULL, 10);
+
+ inet = g_inet_address_new_from_string ("127.0.0.1");
+ address = g_inet_socket_address_new (inet, port);
+ g_object_unref (inet);
+ }
+
+#ifdef G_OS_UNIX
+ else if (display[0] == ':' && g_ascii_isdigit(display[1]))
{
char *path, *basename;
port = strtol (display + strlen (":"), NULL, 10);
+
basename = g_strdup_printf ("broadway%d.socket", port + 1);
path = g_build_filename (g_get_user_runtime_dir (), basename, NULL);
g_free (basename);
@@ -588,6 +611,7 @@ main (int argc, char *argv[])
G_UNIX_SOCKET_ADDRESS_PATH);
g_free (path);
}
+#endif
else
{
g_printerr ("Failed to parse display %s\n", display);
@@ -597,9 +621,11 @@ main (int argc, char *argv[])
if (http_port == 0)
http_port = 8080 + port;
+#ifdef G_OS_UNIX
if (unixsocket_address != NULL)
server = broadway_server_on_unix_socket_new (unixsocket_address, &error);
else
+#endif
server = broadway_server_new (http_address,
http_port,
ssl_cert,
diff --git a/gdk/broadway/gdkbroadway-server.c b/gdk/broadway/gdkbroadway-server.c
index e6b96ff0b9..bed2598632 100644
--- a/gdk/broadway/gdkbroadway-server.c
+++ b/gdk/broadway/gdkbroadway-server.c
@@ -19,8 +19,12 @@
#include <glib.h>
#include <glib/gprintf.h>
+
+#ifdef G_OS_UNIX
#include <gio/gunixsocketaddress.h>
#include <gio/gunixfdmessage.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -113,10 +117,28 @@ _gdk_broadway_server_new (GdkDisplay *display,
char *local_socket_type = NULL;
int port;
- if (display_name == NULL)
- display_name = ":0";
+ if (display == NULL)
+ {
+#ifdef G_OS_UNIX
+ display_name = ":0";
+#elif defined (G_OS_WIN32)
+ display_name = ":tcp";
+#endif
+ }
- if (display_name[0] == ':' && g_ascii_isdigit(display_name[1]))
+ if (g_str_has_prefix (display_name, ":tcp"))
+ {
+ GInetAddress *inet;
+
+ port = 9090 + strtol (display_name + strlen (":tcp"), NULL, 10);
+
+ inet = g_inet_address_new_from_string ("127.0.0.1");
+ address = g_inet_socket_address_new (inet, port);
+ g_object_unref (inet);
+ }
+
+#ifdef G_OS_UNIX
+ else if (display_name[0] == ':' && g_ascii_isdigit(display_name[1]))
{
char *path, *basename;
@@ -129,6 +151,7 @@ _gdk_broadway_server_new (GdkDisplay *display,
G_UNIX_SOCKET_ADDRESS_PATH);
g_free (path);
}
+#endif
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]