Gtk+ html backend (broadway win32?)
- From: Hans Breuer <hans breuer org>
- To: Gtk-Devel <gtk-devel-list gnome org>
- Subject: Gtk+ html backend (broadway@win32?)
- Date: Sun, 10 Apr 2011 16:00:19 +0200
The Gtk+ html backend might be the killer feature motivating me to put more
effort in Dia's gtk3 porting. Getting it to compile on win32 was easy and I
could commit the initial bits soon.
Unfortunately the implementation appears to be relying on a Unix paradigm
(everything is a file) , which is not easily achievable for win32.
If I understood the code correctly broadway_output_write_raw() uses
write(socket_fd,...) to send data over the network. On Windows file handles
are not interchangeable with winsock handles. The following code could
overcome that limitation here:
#ifndef G_OS_WIN32
res = write(output->fd, ptr, count);
#else
res = send (output->fd, ptr, count, 0);
#endif
But there are also libz compressed streams used by:
output->zfd = gzdopen(fd, "wb");
res = gzwrite(output->zfd, ptr, count);
gzclose (output->zfd);
which can not work as is on win32 (though it does compile;)).
I see two potential options in solving this:
1) changing the broadway backend to optionally only use
uncommpressed network streams
2) making use of gio streams in gdk-broadway, and implement the platform
specific bits in gio, where the network abstraction already lives.
Which one would be the preferred one and who is able to write the specific
code (my experience with network APIs is only marginal) ?
Thanks,
Hans
-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it. -- Dilbert
diff --git a/gdk/broadway/broadway.c b/gdk/broadway/broadway.c
index 714905f..dff126f 100644
--- a/gdk/broadway/broadway.c
+++ b/gdk/broadway/broadway.c
@@ -1,3 +1,6 @@
+#include "config.h"
+#include <glib.h> /* get G_OS_* */
+
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -5,9 +8,17 @@
#include <errno.h>
#include <zlib.h>
#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifndef G_OS_WIN32
#include <netinet/in.h>
#include <netinet/tcp.h>
+#else
+#define _WIN32_WINNT 0x0501
+#include <winsock2.h>
+#include <io.h>
+#endif
#include "broadway.h"
@@ -469,7 +480,11 @@ broadway_output_write_raw (BroadwayOutput *output,
while (count > 0)
{
+#ifndef G_OS_WIN32
res = write(output->fd, ptr, count);
+#else
+ res = send (output->fd, ptr, count, 0);
+#endif
if (res == -1)
{
errsave = errno;
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 4651ed1..23b9643 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -39,7 +39,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#else
+#include <io.h> /* dup */
+#endif
static void gdk_broadway_display_dispose (GObject *object);
static void gdk_broadway_display_finalize (GObject *object);
@@ -325,11 +329,11 @@ _gdk_broadway_display_block_for_input (GdkDisplay *display, char op,
}
}
-#include <unistd.h>
#include <fcntl.h>
static void
set_fd_blocking (int fd)
{
+#ifdef F_GETFL
glong arg;
if ((arg = fcntl (fd, F_GETFL, NULL)) < 0)
@@ -338,6 +342,7 @@ set_fd_blocking (int fd)
arg = arg & ~O_NONBLOCK;
fcntl (fd, F_SETFL, arg);
+#endif
}
static char *
@@ -543,8 +548,11 @@ start_output (HttpRequest *request)
broadway_display->saved_serial = broadway_output_get_next_serial (broadway_display->output);
broadway_output_free (broadway_display->output);
}
-
+#ifndef G_OS_WIN32
broadway_display->output = broadway_output_new (dup(fd), broadway_display->saved_serial);
+#else
+ broadway_display->output = broadway_output_new (fd, broadway_display->saved_serial);
+#endif
_gdk_broadway_resync_windows ();
http_request_free (request);
}
diff --git a/gdk/broadway/gdkkeys-broadway.c b/gdk/broadway/gdkkeys-broadway.c
index 1d5f41a..b999351 100644
--- a/gdk/broadway/gdkkeys-broadway.c
+++ b/gdk/broadway/gdkkeys-broadway.c
@@ -35,7 +35,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <limits.h>
#include <errno.h>
diff --git a/gdk/broadway/gdkmain-broadway.c b/gdk/broadway/gdkmain-broadway.c
index f7a2817..5acb341 100644
--- a/gdk/broadway/gdkmain-broadway.c
+++ b/gdk/broadway/gdkmain-broadway.c
@@ -35,7 +35,9 @@
#include <glib/gprintf.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <limits.h>
#include <errno.h>
diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c
index 3518d40..1553368 100644
--- a/gdk/broadway/gdkwindow-broadway.c
+++ b/gdk/broadway/gdkwindow-broadway.c
@@ -41,8 +41,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifndef G_OS_WIN32
#include <netinet/in.h>
+#endif
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
/* Forward declarations */
static void gdk_window_broadway_set_background (GdkWindow *window,
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index 11b899c..8172c01 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -229,6 +229,7 @@ gdk_display_manager_get (void)
const gchar *backend;
backend = g_getenv ("GDK_BACKEND");
+ g_print ("Backend: '%s'\n", backend ? backend : "auto");
#ifdef GDK_WINDOWING_QUARTZ
if (backend == NULL || strcmp (backend, "quartz") == 0)
manager = g_object_new (gdk_quartz_display_manager_get_type (), NULL);
diff --git a/gdk/makefile.msc b/gdk/makefile.msc
index 0d88d1e..1fa90a1 100644
--- a/gdk/makefile.msc
+++ b/gdk/makefile.msc
@@ -33,7 +33,8 @@ DEFINES = \
-DHAVE_CONFIG_H \
-DGDK_VERSION=\"$(GTK_VER)\" \
-DG_LOG_DOMAIN=\"Gdk\" \
- -DGDK_COMPILATION -DG_LOG_DOMAIN=\"Gdk\"
+ -DGDK_COMPILATION -DG_LOG_DOMAIN=\"Gdk\" \
+ -DGDK_WINDOWING_BROADWAY
EXTRALIBS = \
$(WTKIT)\lib\i386\wntab32x.lib \
@@ -45,6 +46,11 @@ gdk-win32-backend :
cd win32
nmake -nologo -f makefile.msc
cd ..
+
+gdk-broadway-backend :
+ cd broadway
+ nmake -nologo -f makefile.msc
+ cd ..
all: \
..\config.h \
@@ -54,6 +60,7 @@ all: \
gdkmarshalers.h \
gdkmarshalers.c \
gdk-win32-backend \
+ gdk-broadway-backend \
libgdk-win32-$(GTK_VER)-0.dll \
# testgdk.exe \
# gdk-win32-$(GTK_VER)s.lib \
@@ -146,9 +153,10 @@ gdk.def: gdk.symbols
gdk.symbols >> gdk.def
# /force /verbose:lib
-libgdk-win32-$(GTK_VER)-0.dll : $(gdk_OBJECTS) gdk.def win32\gdk-win32.lib
+libgdk-win32-$(GTK_VER)-0.dll : $(gdk_OBJECTS) gdk.def win32\gdk-win32.lib broadway\gdk-broadway.lib
$(CC) $(CFLAGS) -LD -Fe$@ $(gdk_OBJECTS) win32\gdk-win32.lib $(EXTRALIBS) \
gdi32.lib user32.lib imm32.lib shell32.lib ole32.lib uuid.lib win32\gdk.res \
+ broadway\gdk-broadway.lib $(ZLIB_LIBS) wsock32.lib \
$(LDFLAGS) /implib:gdk-win32-$(GTK_VER).lib /def:gdk.def
gdk-win32-$(GTK_VER)s.lib : $(gdk_OBJECTS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]