Commit 1d838f58 authored by Hans Breuer's avatar Hans Breuer
Browse files

win32: gdk3 resurrection

There are sure regressions but basic stuff seems to be working
again after all the API breakage done with comments like
"Win32 and Quartz need to be ported still."
parent fc122305
...@@ -350,13 +350,16 @@ gdk_visual_get_type G_GNUC_CONST ...@@ -350,13 +350,16 @@ gdk_visual_get_type G_GNUC_CONST
gdk_visual_get_visual_type gdk_visual_get_visual_type
gdk_visual_type_get_type G_GNUC_CONST gdk_visual_type_get_type G_GNUC_CONST
#ifdef GDK_WINDOWING_WIN32 #ifdef GDK_WINDOWING_WIN32
gdk_win32_drawable_get_handle
gdk_win32_handle_table_lookup gdk_win32_handle_table_lookup
gdk_win32_icon_to_pixbuf_libgtk_only gdk_win32_icon_to_pixbuf_libgtk_only
gdk_win32_pixbuf_to_hicon_libgtk_only gdk_win32_pixbuf_to_hicon_libgtk_only
gdk_win32_selection_add_targets gdk_win32_selection_add_targets
gdk_win32_set_modal_dialog_libgtk_only gdk_win32_set_modal_dialog_libgtk_only
gdk_win32_window_is_win32 gdk_win32_window_is_win32
gdk_win32_window_get_handle
gdk_win32_display_get_type
gdk_win32_window_foreign_new_for_display
gdk_win32_window_lookup_for_display
#endif #endif
gdk_window_add_filter gdk_window_add_filter
gdk_window_at_pointer gdk_window_at_pointer
...@@ -429,7 +432,9 @@ gdk_window_hide ...@@ -429,7 +432,9 @@ gdk_window_hide
gdk_window_hints_get_type G_GNUC_CONST gdk_window_hints_get_type G_GNUC_CONST
gdk_window_iconify gdk_window_iconify
gdk_window_impl_get_type G_GNUC_CONST gdk_window_impl_get_type G_GNUC_CONST
#ifdef GDK_WINDOWING_X11
gdk_window_impl_x11_get_type G_GNUC_CONST gdk_window_impl_x11_get_type G_GNUC_CONST
#endif
gdk_window_input_shape_combine_region gdk_window_input_shape_combine_region
gdk_window_invalidate_maybe_recurse gdk_window_invalidate_maybe_recurse
gdk_window_invalidate_rect gdk_window_invalidate_rect
...@@ -508,6 +513,7 @@ gdk_window_unstick ...@@ -508,6 +513,7 @@ gdk_window_unstick
gdk_window_withdraw gdk_window_withdraw
gdk_wm_decoration_get_type G_GNUC_CONST gdk_wm_decoration_get_type G_GNUC_CONST
gdk_wm_function_get_type G_GNUC_CONST gdk_wm_function_get_type G_GNUC_CONST
#ifdef GDK_WINDOWING_X11
gdk_x11_app_launch_context_get_type gdk_x11_app_launch_context_get_type
gdk_x11_atom_to_xatom gdk_x11_atom_to_xatom
gdk_x11_atom_to_xatom_for_display gdk_x11_atom_to_xatom_for_display
...@@ -570,3 +576,4 @@ gdk_x11_window_move_to_current_desktop ...@@ -570,3 +576,4 @@ gdk_x11_window_move_to_current_desktop
gdk_x11_window_set_user_time gdk_x11_window_set_user_time
gdk_x11_xatom_to_atom gdk_x11_xatom_to_atom
gdk_x11_xatom_to_atom_for_display gdk_x11_xatom_to_atom_for_display
#endif
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
#include "quartz/gdkquartzdisplaymanager.h" #include "quartz/gdkquartzdisplaymanager.h"
#endif #endif
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
#endif
/** /**
* SECTION:gdkdisplaymanager * SECTION:gdkdisplaymanager
...@@ -194,6 +197,11 @@ gdk_display_manager_get (void) ...@@ -194,6 +197,11 @@ gdk_display_manager_get (void)
if (backend == NULL || strcmp (backend, "quartz") == 0) if (backend == NULL || strcmp (backend, "quartz") == 0)
manager = g_object_new (gdk_quartz_display_manager_get_type (), NULL); manager = g_object_new (gdk_quartz_display_manager_get_type (), NULL);
else else
#endif
#ifdef GDK_WINDOWING_WIN32
if (backend == NULL || strcmp (backend, "win32") == 0)
manager = g_object_new (gdk_win32_display_manager_get_type (), NULL);
else
#endif #endif
if (backend != NULL) if (backend != NULL)
g_error ("Unsupported GDK backend: %s", backend); g_error ("Unsupported GDK backend: %s", backend);
......
...@@ -19,8 +19,7 @@ WTKIT = $(TOP)\wtkit126 ...@@ -19,8 +19,7 @@ WTKIT = $(TOP)\wtkit126
# Nothing much configurable below # Nothing much configurable below
# overwrite version? # overwrite version?
GTK_VER=2.0 GTK_VER=3.0
GDK_PIXBUF_VER=$(GTK_VER)
!IFNDEF PERL !IFNDEF PERL
PERL = perl PERL = perl
...@@ -28,20 +27,19 @@ PERL = perl ...@@ -28,20 +27,19 @@ PERL = perl
INCLUDES = -FImsvc_recommended_pragmas.h \ INCLUDES = -FImsvc_recommended_pragmas.h \
-I . -I .. \ -I . -I .. \
$(GLIB_CFLAGS) $(PANGO_CFLAGS) $(CAIRO_CFLAGS) -I ../gdk-pixbuf \ $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(CAIRO_CFLAGS) $(GDK_PIXBUF_CFLAGS) \
DEFINES = \ DEFINES = \
-DHAVE_CONFIG_H -DGDK_ENABLE_BROKEN \ -DHAVE_CONFIG_H \
-DGDK_VERSION=\"$(GTK_VER)\" \ -DGDK_VERSION=\"$(GTK_VER)\" \
-DG_LOG_DOMAIN=\"Gdk\" \ -DG_LOG_DOMAIN=\"Gdk\" \
-DGDK_COMPILATION -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -DG_LOG_DOMAIN=\"Gdk\"
EXTRALIBS = \ EXTRALIBS = \
$(WTKIT)\lib\i386\wntab32x.lib \ $(WTKIT)\lib\i386\wntab32x.lib \
$(GLIB_LIBS) \ $(GLIB_LIBS) $(GDK_PIXBUF_LIBS) \
..\gdk-pixbuf\gdk_pixbuf-$(GDK_PIXBUF_VER).lib \ $(CAIRO_LIBS) $(CAIRO_GOBJECT_LIBS) \
$(PANGOWIN32_LIBS) $(PANGOCAIRO_LIBS) $(INTL_LIBS) $(CAIRO_LIBS) \ $(PANGOWIN32_LIBS) $(PANGOCAIRO_LIBS) $(INTL_LIBS)
$(PANGOCAIRO_LIBS)
gdk-win32-backend : gdk-win32-backend :
cd win32 cd win32
...@@ -57,8 +55,8 @@ all: \ ...@@ -57,8 +55,8 @@ all: \
gdkmarshalers.c \ gdkmarshalers.c \
gdk-win32-backend \ gdk-win32-backend \
libgdk-win32-$(GTK_VER)-0.dll \ libgdk-win32-$(GTK_VER)-0.dll \
testgdk.exe \ # testgdk.exe \
gdk-win32-$(GTK_VER)s.lib \ # gdk-win32-$(GTK_VER)s.lib \
# gdk-x11-$(GTK_VER).dll \ # gdk-x11-$(GTK_VER).dll \
gdk_OBJECTS = \ gdk_OBJECTS = \
...@@ -67,15 +65,14 @@ gdk_OBJECTS = \ ...@@ -67,15 +65,14 @@ gdk_OBJECTS = \
gdkcairo.obj \ gdkcairo.obj \
gdkcolor.obj \ gdkcolor.obj \
gdkcursor.obj \ gdkcursor.obj \
gdkdevice.obj \
gdkdevicemanager.obj \
gdkdisplay.obj \ gdkdisplay.obj \
gdkdisplaymanager.obj \ gdkdisplaymanager.obj \
gdkdnd.obj \ gdkdnd.obj \
gdkdraw.obj \
gdkenumtypes.obj \ gdkenumtypes.obj \
gdkevents.obj \ gdkevents.obj \
gdkgc.obj \
gdkglobals.obj \ gdkglobals.obj \
gdkwindowimpl.obj \
gdkkeynames.obj \ gdkkeynames.obj \
gdkkeys.obj \ gdkkeys.obj \
gdkkeyuni.obj \ gdkkeyuni.obj \
...@@ -83,31 +80,43 @@ gdk_OBJECTS = \ ...@@ -83,31 +80,43 @@ gdk_OBJECTS = \
gdkoffscreenwindow.obj \ gdkoffscreenwindow.obj \
gdkpango.obj \ gdkpango.obj \
gdkpixbuf-drawable.obj \ gdkpixbuf-drawable.obj \
gdkpixbuf-render.obj \
gdkrectangle.obj \ gdkrectangle.obj \
gdkrgba.obj \
gdkscreen.obj \ gdkscreen.obj \
gdkselection.obj \ gdkselection.obj \
gdkvisual.obj \ gdkvisual.obj \
gdkwindow.obj gdkwindow.obj \
gdkwindowimpl.obj \
gdk_public_h_sources = \
gdk.h \ gdk_public_h_sources = \
gdkcolor.h \ gdk.h \
gdkcursor.h \ gdkapplaunchcontext.h \
gdkdnd.h \ gdkcairo.h \
gdkdrawable.h \ gdkcolor.h \
gdkevents.h \ gdkcursor.h \
gdkgc.h \ gdkdevice.h \
gdkkeysyms.h \ gdkdevicemanager.h \
gdkinput.h \ gdkdisplay.h \
gdkkeys.h \ gdkdisplaymanager.h \
gdkpango.h \ gdkdnd.h \
gdkpixbuf.h \ gdkevents.h \
gdkproperty.h \ gdkkeys.h \
gdkselection.h \ gdkkeysyms.h \
gdktypes.h \ gdkkeysyms-compat.h \
gdkvisual.h \ gdkmain.h \
gdkwindow.h \ gdkpango.h \
gdkpixbuf.h \
gdkprivate.h \
gdkproperty.h \
gdkrectangle.h \
gdkrgba.h \
gdkscreen.h \
gdkselection.h \
gdktestutils.h \
gdkthreads.h \
gdktypes.h \
gdkvisual.h \
gdkwindow.h
# private marshalers # private marshalers
gdkmarshalers.h : gdkmarshalers.list gdkmarshalers.h : gdkmarshalers.list
...@@ -136,6 +145,7 @@ gdk.def: gdk.symbols ...@@ -136,6 +145,7 @@ gdk.def: gdk.symbols
-DG_GNUC_CONST= \ -DG_GNUC_CONST= \
gdk.symbols >> gdk.def 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
$(CC) $(CFLAGS) -LD -Fe$@ $(gdk_OBJECTS) win32\gdk-win32.lib $(EXTRALIBS) \ $(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 \ gdi32.lib user32.lib imm32.lib shell32.lib ole32.lib uuid.lib win32\gdk.res \
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "gdkscreen.h" #include "gdkscreen.h"
#include "gdkcursor.h" #include "gdkcursor.h"
#include "gdkprivate-win32.h" #include "gdkprivate-win32.h"
#include "gdkwin32cursor.h"
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <w32api.h> #include <w32api.h>
...@@ -135,25 +136,47 @@ hcursor_from_type (GdkCursorType cursor_type) ...@@ -135,25 +136,47 @@ hcursor_from_type (GdkCursorType cursor_type)
return rv; return rv;
} }
struct _GdkWin32CursorClass
{
GdkCursorClass cursor_class;
};
G_DEFINE_TYPE (GdkWin32Cursor, gdk_win32_cursor, GDK_TYPE_CURSOR)
static void
_gdk_win32_cursor_finalize (GObject *object)
{
GdkWin32Cursor *private = GDK_WIN32_CURSOR (object);
if (GetCursor () == private->hcursor)
SetCursor (NULL);
if (!DestroyCursor (private->hcursor))
WIN32_API_FAILED ("DestroyCursor");
G_OBJECT_CLASS (gdk_win32_cursor_parent_class)->finalize (object);
}
static GdkCursor* static GdkCursor*
cursor_new_from_hcursor (HCURSOR hcursor, cursor_new_from_hcursor (HCURSOR hcursor,
GdkCursorType cursor_type) GdkCursorType cursor_type)
{ {
GdkCursorPrivate *private; GdkWin32Cursor *private;
GdkCursor *cursor; GdkCursor *cursor;
private = g_new (GdkCursorPrivate, 1); private = g_object_new (GDK_TYPE_WIN32_CURSOR,
"cursor-type", cursor_type,
"display", _gdk_display,
NULL);
private->hcursor = hcursor; private->hcursor = hcursor;
cursor = (GdkCursor*) private; cursor = (GdkCursor*) private;
cursor->type = cursor_type;
cursor->ref_count = 1;
return cursor; return cursor;
} }
GdkCursor* GdkCursor*
gdk_cursor_new_for_display (GdkDisplay *display, _gdk_win32_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type) GdkCursorType cursor_type)
{ {
HCURSOR hcursor; HCURSOR hcursor;
...@@ -206,8 +229,8 @@ static struct { ...@@ -206,8 +229,8 @@ static struct {
}; };
GdkCursor* GdkCursor*
gdk_cursor_new_from_name (GdkDisplay *display, _gdk_win32_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name) const gchar *name)
{ {
HCURSOR hcursor = NULL; HCURSOR hcursor = NULL;
int i; int i;
...@@ -229,26 +252,6 @@ gdk_cursor_new_from_name (GdkDisplay *display, ...@@ -229,26 +252,6 @@ gdk_cursor_new_from_name (GdkDisplay *display,
return NULL; return NULL;
} }
void
_gdk_cursor_destroy (GdkCursor *cursor)
{
GdkCursorPrivate *private;
g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor;
GDK_NOTE (CURSOR, g_print ("_gdk_cursor_destroy: %p\n",
(cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->hcursor : 0));
if (GetCursor () == private->hcursor)
SetCursor (NULL);
if (!DestroyCursor (private->hcursor))
WIN32_API_FAILED ("DestroyCursor");
g_free (private);
}
GdkPixbuf * GdkPixbuf *
gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon) gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon)
{ {
...@@ -425,19 +428,19 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon) ...@@ -425,19 +428,19 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon)
return pixbuf; return pixbuf;
} }
GdkPixbuf* static GdkPixbuf *
gdk_cursor_get_image (GdkCursor *cursor) _gdk_win32_cursor_get_image (GdkCursor *cursor)
{ {
g_return_val_if_fail (cursor != NULL, NULL); g_return_val_if_fail (cursor != NULL, NULL);
return gdk_win32_icon_to_pixbuf_libgtk_only (((GdkCursorPrivate *) cursor)->hcursor); return gdk_win32_icon_to_pixbuf_libgtk_only (((GdkWin32Cursor *) cursor)->hcursor);
} }
GdkCursor * GdkCursor *
gdk_cursor_new_from_pixbuf (GdkDisplay *display, _gdk_win32_display_get_cursor_for_pixbuf (GdkDisplay *display,
GdkPixbuf *pixbuf, GdkPixbuf *pixbuf,
gint x, gint x,
gint y) gint y)
{ {
HCURSOR hcursor; HCURSOR hcursor;
...@@ -452,8 +455,8 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display, ...@@ -452,8 +455,8 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP); return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
} }
gboolean gboolean
gdk_display_supports_cursor_alpha (GdkDisplay *display) _gdk_win32_display_supports_cursor_alpha (GdkDisplay *display)
{ {
g_return_val_if_fail (display == _gdk_display, FALSE); g_return_val_if_fail (display == _gdk_display, FALSE);
...@@ -461,25 +464,30 @@ gdk_display_supports_cursor_alpha (GdkDisplay *display) ...@@ -461,25 +464,30 @@ gdk_display_supports_cursor_alpha (GdkDisplay *display)
} }
gboolean gboolean
gdk_display_supports_cursor_color (GdkDisplay *display) _gdk_win32_display_supports_cursor_color (GdkDisplay *display)
{ {
g_return_val_if_fail (display == _gdk_display, FALSE); g_return_val_if_fail (display == _gdk_display, FALSE);
return TRUE; return TRUE;
} }
guint void
gdk_display_get_default_cursor_size (GdkDisplay *display) _gdk_win32_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{ {
g_return_val_if_fail (display == _gdk_display, 0); g_return_if_fail (display == _gdk_display);
return MIN (GetSystemMetrics (SM_CXCURSOR), GetSystemMetrics (SM_CYCURSOR)); if (width)
*width = GetSystemMetrics (SM_CXCURSOR);
if (height)
*height = GetSystemMetrics (SM_CYCURSOR);
} }
void void
gdk_display_get_maximal_cursor_size (GdkDisplay *display, _gdk_win32_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width, guint *width,
guint *height) guint *height)
{ {
g_return_if_fail (display == _gdk_display); g_return_if_fail (display == _gdk_display);
...@@ -812,3 +820,18 @@ gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf) ...@@ -812,3 +820,18 @@ gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf)
{ {
return _gdk_win32_pixbuf_to_hicon (pixbuf); return _gdk_win32_pixbuf_to_hicon (pixbuf);
} }
static void
gdk_win32_cursor_init (GdkWin32Cursor *cursor)
{
}
static void
gdk_win32_cursor_class_init(GdkWin32CursorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
object_class->finalize = _gdk_win32_cursor_finalize;
cursor_class->get_image = _gdk_win32_cursor_get_image;
}
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <windowsx.h> #include <windowsx.h>
#include <objbase.h> #include <objbase.h>
#include "gdkdisplayprivate.h"
#include "gdkdevice-win32.h" #include "gdkdevice-win32.h"
#include "gdkwin32.h" #include "gdkwin32.h"
...@@ -134,14 +135,14 @@ gdk_device_win32_set_window_cursor (GdkDevice *device, ...@@ -134,14 +135,14 @@ gdk_device_win32_set_window_cursor (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
GdkCursor *cursor) GdkCursor *cursor)
{ {
GdkCursorPrivate *cursor_private; GdkWin32Cursor *cursor_private;
GdkWindowObject *parent_window; GdkWindow *parent_window;
GdkWindowImplWin32 *impl; GdkWindowImplWin32 *impl;
HCURSOR hcursor; HCURSOR hcursor;
HCURSOR hprevcursor; HCURSOR hprevcursor;
impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
cursor_private = (GdkCursorPrivate*) cursor; cursor_private = (GdkWin32Cursor*) cursor;
hprevcursor = impl->hcursor; hprevcursor = impl->hcursor;
...@@ -164,13 +165,11 @@ gdk_device_win32_set_window_cursor (GdkDevice *device, ...@@ -164,13 +165,11 @@ gdk_device_win32_set_window_cursor (GdkDevice *device,
* first ancestor that has cursor defined, and if so, set * first ancestor that has cursor defined, and if so, set
* new cursor. * new cursor.
*/ */
GdkWindowObject *curr_window_obj = GDK_WINDOW_OBJECT (curr_window); while (curr_window && curr_window->impl &&
!GDK_WINDOW_IMPL_WIN32 (curr_window->impl)->hcursor)
while (curr_window_obj &&
!GDK_WINDOW_IMPL_WIN32 (curr_window_obj->impl)->hcursor)
{ {
curr_window_obj = curr_window_obj->parent; curr_window = curr_window->parent;
if (curr_window_obj == GDK_WINDOW_OBJECT (window)) if (curr_window == GDK_WINDOW (window))
{ {
SetCursor (hcursor); SetCursor (hcursor);
break; break;
...@@ -188,7 +187,7 @@ gdk_device_win32_set_window_cursor (GdkDevice *device, ...@@ -188,7 +187,7 @@ gdk_device_win32_set_window_cursor (GdkDevice *device,
{ {
/* Look for a suitable cursor to use instead */ /* Look for a suitable cursor to use instead */
hcursor = NULL; hcursor = NULL;
parent_window = GDK_WINDOW_OBJECT (window)->parent; parent_window = GDK_WINDOW (window)->parent;
while (hcursor == NULL) while (hcursor == NULL)
{ {
...@@ -329,12 +328,19 @@ static void ...@@ -329,12 +328,19 @@ static void
gdk_device_win32_ungrab (GdkDevice *device, gdk_device_win32_ungrab (GdkDevice *device,
guint32 time_) guint32 time_)
{ {
GdkDeviceGrabInfo *info;
GdkDisplay *display; GdkDisplay *display;
display = gdk_device_get_display (device); display = gdk_device_get_display (device);
info = _gdk_display_get_last_device_grab (display, device);
if (info)
info->serial_end = 0;
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD) if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
ReleaseCapture (); ReleaseCapture ();
_gdk_display_device_grab_update (display, device, NULL, 0);
} }
static GdkWindow * static GdkWindow *
......
...@@ -372,7 +372,7 @@ _gdk_input_check_extension_events (GdkDevice *device) ...@@ -372,7 +372,7 @@ _gdk_input_check_extension_events (GdkDevice *device)
for (l = input_windows; l; l = l->next) for (l = input_windows; l; l = l->next)
{ {
GdkWindowObject *window_private; GdkWindow *window_private;
GdkEventMask event_mask = 0;