Commit 8e06c4d7 authored by Tor Lillqvist's avatar Tor Lillqvist
Browse files

Further hacking. Now actually compiles. Haven't tried yet whether

actually does anything useful... Time for bed.
parent b6524a84
......@@ -3,8 +3,6 @@ EXPORTS
gdk_atom_name
gdk_beep
gdk_bitmap_create_from_data
gdk_bitmap_ref
gdk_bitmap_unref
gdk_char_height
gdk_char_measure
gdk_char_width
......@@ -55,7 +53,6 @@ EXPORTS
gdk_draw_indexed_image
gdk_draw_line
gdk_draw_lines
gdk_draw_pixmap
gdk_draw_point
gdk_draw_points
gdk_draw_polygon
......@@ -103,7 +100,6 @@ EXPORTS
gdk_free_compound_text
gdk_free_text_list
gdk_gc_copy
gdk_gc_destroy
gdk_gc_get_values
gdk_gc_new
gdk_gc_new_with_values
......@@ -142,7 +138,6 @@ EXPORTS
gdk_im_ready
gdk_im_set_best_style
gdk_image_bitmap_new
gdk_image_destroy
gdk_image_get
gdk_image_get_pixel
gdk_image_new
......@@ -184,8 +179,6 @@ EXPORTS
gdk_pixmap_create_on_shared_image
gdk_pixmap_foreign_new
gdk_pixmap_new
gdk_pixmap_ref
gdk_pixmap_unref
gdk_pointer_grab
gdk_pointer_is_grabbed
gdk_pointer_ungrab
......@@ -212,18 +205,6 @@ EXPORTS
gdk_regions_subtract
gdk_regions_union
gdk_regions_xor
gdk_rgb_cmap_free
gdk_rgb_cmap_new
gdk_rgb_ditherable
gdk_rgb_gc_set_background
gdk_rgb_gc_set_foreground
gdk_rgb_get_cmap
gdk_rgb_get_visual
gdk_rgb_init
gdk_rgb_set_install
gdk_rgb_set_min_colors
gdk_rgb_set_verbose
gdk_rgb_xpixel_from_rgb
gdk_root_parent
gdk_screen_height
gdk_screen_height_mm
......@@ -291,7 +272,6 @@ EXPORTS
gdk_window_move_resize
gdk_window_new
gdk_window_raise
gdk_window_ref
gdk_window_register_dnd
gdk_window_remove_filter
gdk_window_reparent
......@@ -316,7 +296,6 @@ EXPORTS
gdk_window_set_user_data
gdk_window_shape_combine_mask
gdk_window_show
gdk_window_unref
gdk_window_withdraw
gdk_xid_table_insert
gdk_xid_table_lookup
......
......@@ -178,8 +178,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
if (source_image->depth != 1 || mask_image->depth != 1)
{
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
gdk_image_unref (source_image);
gdk_image_unref (mask_image);
g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
NULL);
}
......@@ -243,8 +243,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
g_free (XORmask);
g_free (ANDmask);
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
gdk_image_unref (source_image);
gdk_image_unref (mask_image);
private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor;
......
......@@ -741,7 +741,7 @@ gdk_dnd_init (void)
}
void
gdk_dnd_exit (void)
gdk_win32_dnd_exit (void)
{
#ifdef OLE2_DND
OleUninitialize ();
......
......@@ -69,8 +69,6 @@
typedef struct _GdkIOClosure GdkIOClosure;
typedef struct _GdkEventPrivate GdkEventPrivate;
gint gdk_event_func_from_window_proc = FALSE;
typedef enum
{
/* Following flag is set for events on the event queue during
......@@ -669,54 +667,6 @@ gdk_io_invoke (GIOChannel *source,
return TRUE;
}
gint
gdk_input_add_full (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data,
GdkDestroyNotify destroy)
{
guint result;
GdkIOClosure *closure = g_new (GdkIOClosure, 1);
GIOChannel *channel;
GIOCondition cond = 0;
closure->function = function;
closure->condition = condition;
closure->notify = destroy;
closure->data = data;
if (condition & GDK_INPUT_READ)
cond |= (G_IO_IN | G_IO_PRI);
if (condition & GDK_INPUT_WRITE)
cond |= G_IO_OUT;
if (condition & GDK_INPUT_EXCEPTION)
cond |= G_IO_ERR|G_IO_HUP|G_IO_NVAL;
channel = g_io_channel_unix_new (source);
result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, cond,
gdk_io_invoke,
closure, gdk_io_destroy);
g_io_channel_unref (channel);
return result;
}
gint
gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
{
return gdk_input_add_full (source, condition, function, data, NULL);
}
void
gdk_input_remove (gint tag)
{
g_source_remove (tag);
}
static GdkFilterReturn
gdk_event_apply_filters (MSG *xevent,
GdkEvent *event,
......@@ -4660,3 +4610,8 @@ gdk_event_send_clientmessage_toall (GdkEvent *event)
/* XXX */
}
void
gdk_flush (void)
{
GdiFlush ();
}
......@@ -917,6 +917,16 @@ _gdk_font_destroy (GdkFont *font)
g_free (font);
}
gint
_gdk_font_strlen (GdkFont *font,
const gchar *str)
{
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (str != NULL, -1);
return strlen (str);
}
gint
gdk_font_id (const GdkFont *font)
{
......
......@@ -155,7 +155,7 @@ _gdk_win32_gc_new (GdkDrawable *drawable,
if (values_mask & GDK_GC_TILE)
{
data->tile = values->tile;
gdk_pixmap_ref (data->tile);
gdk_drawable_ref (data->tile);
GDK_NOTE (MISC, g_print (" tile=%#x", GDK_DRAWABLE_XID (data->tile)));
}
else
......@@ -164,7 +164,7 @@ _gdk_win32_gc_new (GdkDrawable *drawable,
if (values_mask & GDK_GC_STIPPLE)
{
data->stipple = values->stipple;
gdk_pixmap_ref (data->stipple);
gdk_drawable_ref (data->stipple);
GDK_NOTE (MISC, g_print (" stipple=%#x", GDK_DRAWABLE_XID (data->stipple)));
}
else
......@@ -288,10 +288,10 @@ gdk_win32_gc_destroy (GdkGC *gc)
gdk_font_unref (data->font);
if (data->values_mask & GDK_GC_TILE)
gdk_pixmap_unref (data->tile);
gdk_drawable_unref (data->tile);
if (data->values_mask & GDK_GC_STIPPLE)
gdk_pixmap_unref (data->stipple);
gdk_drawable_unref (data->stipple);
if (data->values_mask & GDK_GC_CLIP_MASK)
DeleteObject (data->clip_region);
......@@ -506,13 +506,13 @@ gdk_win32_gc_set_values (GdkGC *gc,
if (values_mask & GDK_GC_TILE)
{
if (data->tile != NULL)
gdk_pixmap_unref (data->tile);
gdk_drawable_unref (data->tile);
data->tile = values->tile;
if (data->tile != NULL)
{
GDK_NOTE (MISC, g_print ("tile = %#x ",
GDK_DRAWABLE_XID (values->tile)));
gdk_pixmap_ref (data->tile);
gdk_drawable_ref (data->tile);
data->values_mask |= GDK_GC_TILE;
}
else
......@@ -525,13 +525,13 @@ gdk_win32_gc_set_values (GdkGC *gc,
if (values_mask & GDK_GC_STIPPLE)
{
if (data->stipple != NULL)
gdk_pixmap_unref (data->stipple);
gdk_drawable_unref (data->stipple);
data->stipple = values->stipple;
if (data->stipple != NULL)
{
GDK_NOTE (MISC, g_print ("stipple = %#x ",
GDK_DRAWABLE_XID (values->stipple)));
gdk_pixmap_ref (data->stipple);
gdk_drawable_ref (data->stipple);
data->values_mask |= GDK_GC_STIPPLE;
}
else
......@@ -741,18 +741,18 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
if (dst_data->font)
gdk_font_unref (dst_data->font);
if (dst_data->tile)
gdk_pixmap_unref (dst_data->tile);
gdk_drawable_unref (dst_data->tile);
if (dst_data->stipple)
gdk_pixmap_unref (dst_data->stipple);
gdk_drawable_unref (dst_data->stipple);
*dst_data = *src_data;
if (dst_data->font)
gdk_font_ref (dst_data->font);
if (dst_data->tile)
gdk_pixmap_ref (dst_data->tile);
gdk_drawable_ref (dst_data->tile);
if (dst_data->stipple)
gdk_pixmap_ref (dst_data->stipple);
gdk_drawable_ref (dst_data->stipple);
}
HDC
......
......@@ -25,12 +25,10 @@
*/
#include "gdktypes.h"
#include "gdkprivate.h"
#include "gdkprivate-win32.h"
guint gdk_debug_flags = 0;
HWND gdk_root_window = NULL;
HWND gdk_leader_window;
GDKVAR GdkWindowPrivate *gdk_root_parent = NULL;
gint gdk_event_func_from_window_proc = FALSE;
HDC gdk_DC;
HINSTANCE gdk_DLLInstance;
HINSTANCE gdk_ProgInstance;
......@@ -40,12 +38,7 @@ UINT gdk_selection_clear_msg;
GdkAtom gdk_clipboard_atom;
GdkAtom gdk_win32_dropfiles_atom;
GdkAtom gdk_ole2_dnd_atom;
Atom gdk_selection_property;
gchar *gdk_progclass = NULL;
gint gdk_error_code;
gint gdk_error_warnings = TRUE;
ATOM gdk_selection_property;
gint gdk_null_window_warnings = TRUE;
GMutex *gdk_threads_mutex = NULL;
DWORD windows_version = 0;
......@@ -29,17 +29,24 @@
#include "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */
#include "gdkimage.h"
#include "gdkprivate.h"
#include "gdkx.h"
static void gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
#include "gdkwin32.h"
static void gdk_win32_image_destroy (GdkImage *image);
static void gdk_image_put (GdkImage *image,
GdkDrawable *drawable,
GdkGC *gc,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static GdkImageClass image_class = {
gdk_win32_image_destroy,
gdk_image_put
};
static GList *image_list = NULL;
void
......@@ -50,7 +57,7 @@ gdk_image_exit (void)
while (image_list)
{
image = image_list->data;
gdk_image_destroy (image);
gdk_win32_image_destroy (image);
}
}
......@@ -62,7 +69,7 @@ gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint w, gint h)
{
Visual *xvisual;
GdkImage *image;
GdkImagePrivate *private;
GdkImagePrivateWin32 *private;
struct {
BITMAPINFOHEADER bmiHeader;
union {
......@@ -74,9 +81,11 @@ gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint w, gint h)
int bpl = (w-1)/8 + 1;
int bpl32 = ((w-1)/32 + 1)*4;
private = g_new(GdkImagePrivate, 1);
private = g_new (GdkImagePrivateWin32, 1);
image = (GdkImage *) private;
private->image_put = gdk_image_put_normal;
private->base.ref_count = 1;
private->base.klass = &image_class;
image->type = GDK_IMAGE_SHARED;
image->visual = visual;
image->width = w;
......@@ -140,7 +149,7 @@ gdk_image_new_with_depth (GdkImageType type,
gint depth)
{
GdkImage *image;
GdkImagePrivate *private;
GdkImagePrivateWin32 *private;
Visual *xvisual;
struct {
BITMAPINFOHEADER bmiHeader;
......@@ -162,10 +171,11 @@ gdk_image_new_with_depth (GdkImageType type,
(type == GDK_IMAGE_SHARED_PIXMAP ? "shared_pixmap" :
"???"))));
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private = g_new (GdkImagePrivateWin32, 1);
image = (GdkImage *) private;
private->image_put = NULL;
private->base.ref_count = 1;
private->base.klass = &image_class;
image->type = type;
image->visual = visual;
......@@ -175,8 +185,6 @@ gdk_image_new_with_depth (GdkImageType type,
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
private->image_put = gdk_image_put_normal;
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
......@@ -300,7 +308,7 @@ gdk_image_get (GdkWindow *window,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
GdkImagePrivateWin32 *private;
HDC hdc, memdc;
struct {
BITMAPINFOHEADER bmiHeader;
......@@ -323,10 +331,11 @@ gdk_image_get (GdkWindow *window,
GDK_NOTE (MISC, g_print ("gdk_image_get: %#x %dx%d@+%d+%d\n",
GDK_DRAWABLE_XID (window), width, height, x, y));
private = g_new (GdkImagePrivate, 1);
private = g_new (GdkImagePrivateWin32, 1);
image = (GdkImage*) private;
private->image_put = gdk_image_put_normal;
private->base.ref_count = 1;
private->base.klass = &image_class;
image->type = GDK_IMAGE_SHARED;
image->visual = gdk_window_get_visual (window);
......@@ -540,12 +549,9 @@ gdk_image_get_pixel (GdkImage *image,
gint y)
{
guint32 pixel;
GdkImagePrivate *private;
g_return_val_if_fail (image != NULL, 0);
private = (GdkImagePrivate *) image;
g_return_val_if_fail (x >= 0 && x < image->width
&& y >= 0 && y < image->height, 0);
......@@ -585,12 +591,8 @@ gdk_image_put_pixel (GdkImage *image,
gint y,
guint32 pixel)
{
GdkImagePrivate *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate *) image;
g_return_if_fail (x >= 0 && x < image->width && y >= 0 && y < image->height);
if (image->depth == 1)
......@@ -617,16 +619,16 @@ gdk_image_put_pixel (GdkImage *image,
}
}
void
gdk_image_destroy (GdkImage *image)
static void
gdk_win32_image_destroy (GdkImage *image)
{
GdkImagePrivate *private;
GdkImagePrivateWin32 *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate*) image;
private = (GdkImagePrivateWin32 *) image;
GDK_NOTE (MISC, g_print ("gdk_image_destroy: %#x%s\n",
GDK_NOTE (MISC, g_print ("gdk_win32_image_destroy: %#x%s\n",
private->ximage,
(image->type == GDK_IMAGE_SHARED_PIXMAP ?
" (shared pixmap)" : "")));
......@@ -641,7 +643,7 @@ gdk_image_destroy (GdkImage *image)
case GDK_IMAGE_SHARED:
if (!DeleteObject (private->ximage))
g_warning ("gdk_image_destroy: DeleteObject failed");
g_warning ("gdk_win32_image_destroy: DeleteObject failed");
break;
default:
......@@ -652,21 +654,21 @@ gdk_image_destroy (GdkImage *image)
}
static void
gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
gdk_image_put (GdkImage *image,
GdkDrawable *drawable,
GdkGC *gc,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkImagePrivate *image_private;
GdkImagePrivateWin32 *image_private;
GdkGCPrivate *gc_private;
HDC hdc;
GdkColormapPrivate *colormap_private;
GdkColormapPrivateWin32 *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
......@@ -674,14 +676,14 @@ gdk_image_put_normal (GdkDrawable *drawable,
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
image_private = (GdkImagePrivateWin32 *) image;
drawable_private = (GdkDrawablePrivate *) drawable;
gc_private = (GdkGCPrivate *) gc;
/* The image can in fact be "shared", so don't test */
hdc = gdk_gc_predraw (drawable_private, gc_private);
colormap_private = (GdkColormapPrivate *) drawable_private->colormap;
hdc = gdk_gc_predraw (drawable, gc_private);
colormap_private = (GdkColormapPrivateWin32 *) drawable_private->colormap;
if (colormap_private && colormap_private->xcolormap->rc_palette)
{
DIBSECTION ds;
......@@ -702,7 +704,7 @@ gdk_image_put_normal (GdkDrawable *drawable,
if (GetObject (image_private->ximage, sizeof (DIBSECTION),
&ds) != sizeof (DIBSECTION))
{
g_warning ("gdk_image_put_normal: GetObject failed");
g_warning ("gdk_image_put: GetObject failed");
}
#if 0
g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n",
......@@ -734,26 +736,27 @@ gdk_image_put_normal (GdkDrawable *drawable,
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
{
g_warning ("gdk_image_put_normal: CreateCompatibleDC failed");
gdk_gc_postdraw (drawable_private, gc_private);
g_warning ("gdk_image_put: CreateCompatibleDC failed");
gdk_gc_postdraw (drawable, gc_private);
return;
}
if ((oldbitmap = SelectObject (memdc, image_private->ximage)) == NULL)
{
g_warning ("gdk_image_put_normal: SelectObject #1 failed");
gdk_gc_postdraw (drawable_private, gc_private);
g_warning ("gdk_image_put: SelectObject #1 failed");
gdk_gc_postdraw (drawable, gc_private);
return;
}
if (!BitBlt (hdc, xdest, ydest, width, height,
memdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_image_put_normal: BitBlt failed");
g_warning ("gdk_image_put: BitBlt failed");
if (SelectObject (memdc, oldbitmap) == NULL)
g_warning ("gdk_image_put_normal: SelectObject #2 failed");
if (!DeleteDC (memdc))
g_warning ("gdk_image_put_normal: DeleteDC failed");
g_warning ("gdk_image_put: DeleteDC failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
......@@ -34,7 +34,7 @@
#include "gdk.h"
#include "gdkinput.h"
#include "gdkprivate.h"
#include "gdkx.h"
#include "gdkwin32.h"
#ifdef HAVE_WINTAB
#include <wintab.h>
......@@ -78,8 +78,8 @@ struct _GdkDevicePrivate {
#endif
};
#ifndef M_PI
#define M_PI 3.14159265358979323846
#ifndef G_PI
#define G_PI 3.14159265358979323846
#endif
/* If USE_SYSCONTEXT is on, we open the Wintab device (hmm, what if
......@@ -94,7 +94,7 @@ struct _GdkDevicePrivate {
#define DEBUG_WINTAB 1
#endif
#define TWOPI (2.*M_PI)
#define TWOPI (2.*G_PI)
#define PING() g_print("%s: %d\n",__FILE__,__LINE__)
......@@ -289,7 +289,6 @@ gdk_input_init (void)
guint32 deviceid_counter = 0;
#ifdef HAVE_WINTAB
GdkDevicePrivate *gdkdev;
GdkDrawablePrivate *window_private;
GdkWindowAttr wa;
WORD specversion;
LOGCONTEXT defcontext;
......@@ -341,7 +340,6 @@ gdk_input_init (void)
return;
}
gdk_window_ref (wintab_window);
window_private = (GdkDrawablePrivate *) wintab_window;
for (devix = 0; devix < ndevices; devix++)
{
......@@ -420,7 +418,7 @@ gdk_input_init (void)
print_lc(&lc)));
#endif
hctx = g_new (HCTX, 1);
if ((*hctx = WTOpen (window_private->xwindow, &lc, TRUE)) == NULL)
if ((*hctx = WTOpen (GDK_DRAWABLE_XID (wintab_window), &lc, TRUE)) == NULL)
{
g_warning ("gdk_input_init: WTOpen failed");
return;
......@@ -991,7 +989,6 @@ gdk_input_win32_other_event (GdkEvent *event,