diff --git a/gdk/win32/gdk-win32.def b/gdk/win32/gdk-win32.def index 564af22e41..a839be9547 100644 --- a/gdk/win32/gdk-win32.def +++ b/gdk/win32/gdk-win32.def @@ -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 diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c index 8f9c07c126..a8d1760d66 100644 --- a/gdk/win32/gdkcursor-win32.c +++ b/gdk/win32/gdkcursor-win32.c @@ -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; diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index 7c486767cd..0e40ab3756 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -741,7 +741,7 @@ gdk_dnd_init (void) } void -gdk_dnd_exit (void) +gdk_win32_dnd_exit (void) { #ifdef OLE2_DND OleUninitialize (); diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index fb87e27a83..c143219765 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -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 (); +} diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c index cc9c7016b0..bc9cf7bac7 100644 --- a/gdk/win32/gdkfont-win32.c +++ b/gdk/win32/gdkfont-win32.c @@ -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) { diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c index a577585951..c6c2f32010 100644 --- a/gdk/win32/gdkgc-win32.c +++ b/gdk/win32/gdkgc-win32.c @@ -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 diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c index 4f9f498a72..9f0dc1e1d3 100644 --- a/gdk/win32/gdkglobals-win32.c +++ b/gdk/win32/gdkglobals-win32.c @@ -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; diff --git a/gdk/win32/gdkimage-win32.c b/gdk/win32/gdkimage-win32.c index 0f2825e405..78dd91119c 100644 --- a/gdk/win32/gdkimage-win32.c +++ b/gdk/win32/gdkimage-win32.c @@ -29,17 +29,24 @@ #include "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */ #include "gdkimage.h" #include "gdkprivate.h" -#include "gdkx.h" +#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 void gdk_image_put_normal (GdkDrawable *drawable, - GdkGC *gc, - GdkImage *image, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); 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); } diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c index bd73d8b032..9c6a29c66e 100644 --- a/gdk/win32/gdkinput-win32.c +++ b/gdk/win32/gdkinput-win32.c @@ -34,7 +34,7 @@ #include "gdk.h" #include "gdkinput.h" #include "gdkprivate.h" -#include "gdkx.h" +#include "gdkwin32.h" #ifdef HAVE_WINTAB #include @@ -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, GdkWindow *current_window; GdkInputWindow *input_window; GdkWindow *window; - GdkWindowPrivate *window_private; GdkDevicePrivate *gdkdev; GdkEventMask masktest; POINT pt; @@ -1009,12 +1006,10 @@ gdk_input_win32_other_event (GdkEvent *event, #if USE_SYSCONTEXT window = gdk_window_at_pointer (&x, &y); if (window == NULL) - window = (GdkWindow *) gdk_root_parent; + window = gdk_parent_root; gdk_window_ref (window); - window_private = (GdkWindowPrivate *) window; - GDK_NOTE (EVENTS, g_print ("gdk_input_win32_other_event: window=%#x (%d,%d)\n", GDK_DRAWABLE_XID (window), x, y)); @@ -1039,7 +1034,7 @@ gdk_input_win32_other_event (GdkEvent *event, switch (xevent->message) { case WT_PACKET: - if (window_private == gdk_root_parent) + if (window == gdk_parent_root) { GDK_NOTE (EVENTS, g_print ("...is root\n")); return FALSE; @@ -1102,21 +1097,20 @@ gdk_input_win32_other_event (GdkEvent *event, * propagate if necessary. */ dijkstra: - if (!window_private->extension_events_selected - || !(window_private->extension_events & masktest)) + if (!GDK_WINDOW_WIN32DATA (window)->extension_events_selected + || !(GDK_WINDOW_WIN32DATA (window)->extension_events & masktest)) { GDK_NOTE (EVENTS, g_print ("...not selected\n")); - if (window_private->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) window)->parent == gdk_parent_root) return FALSE; pt.x = x; pt.y = y; ClientToScreen (GDK_DRAWABLE_XID (window), &pt); gdk_window_unref (window); - window = window_private->parent; + window = ((GdkWindowPrivate *) window)->parent; gdk_window_ref (window); - window_private = (GdkWindowPrivate *) window; ScreenToClient (GDK_DRAWABLE_XID (window), &pt); x = pt.x; y = pt.y; @@ -1263,9 +1257,7 @@ static gint gdk_input_win32_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev) { - GdkWindowPrivate *window_private = (GdkWindowPrivate *) window; - - window_private->extension_events_selected = TRUE; + GDK_WINDOW_WIN32DATA (window)->extension_events_selected = TRUE; return TRUE; } @@ -1273,9 +1265,7 @@ static gint gdk_input_win32_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev) { - GdkWindowPrivate *window_private = (GdkWindowPrivate *) window; - - window_private->extension_events_selected = FALSE; + GDK_WINDOW_WIN32DATA (window)->extension_events_selected = FALSE; return TRUE; } @@ -1483,23 +1473,19 @@ gdk_input_window_find (GdkWindow *window) static GdkInputWindow * gdk_input_window_find_within (GdkWindow *window) { - GList *tmp_list; - GdkWindowPrivate *window_private; - GdkWindowPrivate *tmp_private; + GList *list; + GdkWindow *tmpw; GdkInputWindow *candidate = NULL; - window_private = (GdkWindowPrivate *) window; - - for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next) + for (list = gdk_input_windows; list != NULL; list = list->next) { - (GdkWindowPrivate *) tmp_private = - (GdkWindowPrivate *) (((GdkInputWindow *)(tmp_list->data))->window); - if (tmp_private == window_private - || IsChild (window_private->xwindow, tmp_private->xwindow)) + tmpw = ((GdkInputWindow *) (tmp_list->data))->window; + if (tmpw == window + || IsChild (GDK_DRAWABLE_XID (window), GDK_DRAWABLE_XID (tmpw))) { if (candidate) return NULL; /* Multiple hits */ - candidate = (GdkInputWindow *)(tmp_list->data); + candidate = (GdkInputWindow *) (list->data); } } diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c index e8fa5af5d2..9d8abb8bfe 100644 --- a/gdk/win32/gdkmain-win32.c +++ b/gdk/win32/gdkmain-win32.c @@ -34,36 +34,28 @@ #include #include "gdk.h" -#include "gdkprivate.h" +#include "gdkprivate-win32.h" #include "gdkinputprivate.h" #include "gdkkeysyms.h" #include -static void gdkx_XConvertCase (KeySym symbol, - KeySym *lower, - KeySym *upper); -static void gdk_exit_func (void); +static gboolean gdk_synchronize = FALSE; +GdkArgDesc _gdk_windowing_args[] = { + { "sync", GDK_ARG_BOOL, &gdk_synchronize, (GdkArgFunc) NULL}, + { "no-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab, + (GdkArgFunc) NULL}, + { "ignore-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab, + (GdkArgFunc) NULL}, + { "event-func-from-window-proc", + GDK_ARG_BOOL, &gdk_event_func_from_window_proc, + (GdkArgFunc) NULL}, + { NULL } +}; /* Private variable declarations */ -static int gdk_initialized = 0; /* 1 if the library is initialized, - * 0 otherwise. - */ -#ifdef G_ENABLE_DEBUG -static const GDebugKey gdk_debug_keys[] = { - {"events", GDK_DEBUG_EVENTS}, - {"misc", GDK_DEBUG_MISC}, - {"dnd", GDK_DEBUG_DND}, - {"color-context", GDK_DEBUG_COLOR_CONTEXT}, - {"xim", GDK_DEBUG_XIM}, - {"selection", GDK_DEBUG_SELECTION} -}; - -static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey); - -#endif /* G_ENABLE_DEBUG */ int __stdcall DllMain(HINSTANCE hinstDLL, @@ -75,163 +67,21 @@ DllMain(HINSTANCE hinstDLL, return TRUE; } -/* - *-------------------------------------------------------------- - * gdk_init - * - * Initialize the library for use. - * - * Arguments: - * "argc" is the number of arguments. - * "argv" is an array of strings. - * - * Results: - * "argc" and "argv" are modified to reflect any arguments - * which were not handled. (Such arguments should either - * be handled by the application or dismissed). - * - * Side effects: - * The library is initialized. - * - *-------------------------------------------------------------- - */ - gboolean -gdk_init_check (int *argc, - char ***argv) +_gdk_windowing_init_check (int argc, + char **argv) { gint i, j, k; - if (gdk_initialized) - return TRUE; - - if (g_thread_supported ()) - gdk_threads_mutex = g_mutex_new (); - -#ifdef G_ENABLE_DEBUG - { - gchar *debug_string = getenv("GDK_DEBUG"); - if (debug_string != NULL) - gdk_debug_flags = g_parse_debug_string (debug_string, - (GDebugKey *) gdk_debug_keys, - gdk_ndebug_keys); - } -#endif /* G_ENABLE_DEBUG */ - if (getenv ("GDK_IGNORE_WINTAB") != NULL) gdk_input_ignore_wintab = TRUE; if (getenv ("GDK_EVENT_FUNC_FROM_WINDOW_PROC") != NULL) gdk_event_func_from_window_proc = TRUE; - if (argc && argv) - { - if (*argc > 0) - { - gchar *d; - - d = strrchr((*argv)[0], G_DIR_SEPARATOR); - if (d != NULL) - g_set_prgname (d + 1); - else - g_set_prgname ((*argv)[0]); - } - - for (i = 1; i < *argc;) - { -#ifdef G_ENABLE_DEBUG - if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) || - (strncmp ("--gdk-debug=", (*argv)[i], 12) == 0)) - { - gchar *equal_pos = strchr ((*argv)[i], '='); - - if (equal_pos != NULL) - { - gdk_debug_flags |= g_parse_debug_string (equal_pos+1, - (GDebugKey *) gdk_debug_keys, - gdk_ndebug_keys); - } - else if ((i + 1) < *argc && (*argv)[i + 1]) - { - gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1], - (GDebugKey *) gdk_debug_keys, - gdk_ndebug_keys); - (*argv)[i] = NULL; - i += 1; - } - (*argv)[i] = NULL; - } - else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) || - (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0)) - { - gchar *equal_pos = strchr ((*argv)[i], '='); + if (gdk_synchronize) + GdiSetBatchLimit (1); - if (equal_pos != NULL) - { - gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1, - (GDebugKey *) gdk_debug_keys, - gdk_ndebug_keys); - } - else if ((i + 1) < *argc && (*argv)[i + 1]) - { - gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1], - (GDebugKey *) gdk_debug_keys, - gdk_ndebug_keys); - (*argv)[i] = NULL; - i += 1; - } - (*argv)[i] = NULL; - } - else -#endif /* G_ENABLE_DEBUG */ - if (strcmp ("--sync", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - GdiSetBatchLimit (1); - } - else if (strcmp ("--name", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - g_set_prgname ((*argv)[i]); - (*argv)[i] = NULL; - } - } - else if (strcmp ("--gdk-no-wintab", (*argv)[i]) == 0 - || strcmp ("--gdk-ignore-wintab", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - gdk_input_ignore_wintab = TRUE; - } - else if (strcmp ("--gdk-event-func-from-window-proc", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - gdk_event_func_from_window_proc = TRUE; - } - i += 1; - } - - for (i = 1; i < *argc; i++) - { - for (k = i; k < *argc; k++) - if ((*argv)[k] != NULL) - break; - - if (k > i) - { - k -= i; - for (j = i + k; j < *argc; j++) - (*argv)[j-k] = (*argv)[j]; - *argc -= k; - } - } - } - else - { - g_set_prgname (""); - } - gdk_ProgInstance = GetModuleHandle (NULL); gdk_DC = CreateDC ("DISPLAY", NULL, NULL, NULL); gdk_root_window = GetDesktopWindow (); @@ -248,61 +98,11 @@ gdk_init_check (int *argc, gdk_win32_dropfiles_atom = gdk_atom_intern ("DROPFILES_DND", FALSE); gdk_ole2_dnd_atom = gdk_atom_intern ("OLE2_DND", FALSE); - gdk_progclass = g_basename (g_get_prgname ()); - gdk_progclass[0] = toupper (gdk_progclass[0]); - - g_atexit (gdk_exit_func); - - gdk_events_init (); - gdk_visual_init (); - gdk_window_init (); - gdk_image_init (); - gdk_input_init (); - gdk_selection_init (); - gdk_dnd_init (); - - gdk_initialized = 1; + gdk_win32_selection_init (); return TRUE; } -void -gdk_init (int *argc, char ***argv) -{ - if (!gdk_init_check (argc, argv)) - { - g_warning ("cannot initialize GDK"); - exit(1); - } -} - -/* - *-------------------------------------------------------------- - * gdk_exit - * - * Restores the library to an un-itialized state and exits - * the program using the "exit" system call. - * - * Arguments: - * "errorcode" is the error value to pass to "exit". - * - * Results: - * Allocated structures are freed and the program exits - * cleanly. - * - * Side effects: - * - *-------------------------------------------------------------- - */ - -void -gdk_exit (gint errorcode) -{ - /* de-initialisation is done by the gdk_exit_func(), - no need to do this here (Alex J.) */ - exit (errorcode); -} - void gdk_set_use_xshm (gint use_xshm) { @@ -333,11 +133,7 @@ gdk_get_use_xshm (void) gint gdk_screen_width (void) { - gint return_val; - - return_val = gdk_root_parent->drawable.width; - - return return_val; + return ((GdkWindowPrivate *) gdk_parent_root)->drawable.width; } /* @@ -358,11 +154,7 @@ gdk_screen_width (void) gint gdk_screen_height (void) { - gint return_val; - - return_val = gdk_root_parent->drawable.height; - - return return_val; + return ((GdkWindowPrivate *) gdk_parent_root)->drawable.height; } /* @@ -383,14 +175,7 @@ gdk_screen_height (void) gint gdk_screen_width_mm (void) { - HDC hdc; - gint return_val; - - hdc = GetDC (NULL); - return_val = GetDeviceCaps (hdc, HORZSIZE); - ReleaseDC (NULL, hdc); - - return return_val; + return GetDeviceCaps (gdk_DC, HORZSIZE); } /* @@ -411,14 +196,7 @@ gdk_screen_width_mm (void) gint gdk_screen_height_mm (void) { - HDC hdc; - gint return_val; - - hdc = GetDC (NULL); - return_val = GetDeviceCaps (hdc, VERTSIZE); - ReleaseDC (NULL, hdc); - - return return_val; + return GetDeviceCaps (gdk_DC, VERTSIZE); } void @@ -433,245 +211,25 @@ gdk_key_repeat_restore (void) /* XXX */ } - -/* - *-------------------------------------------------------------- - * gdk_flush - * - * Flushes the Xlib output buffer and then waits - * until all requests have been received and processed - * by the X server. The only real use for this function - * is in dealing with XShm. - * - * Arguments: - * - * Results: - * - * Side effects: - * - *-------------------------------------------------------------- - */ - -void -gdk_flush (void) -{ - GdiFlush (); -} - void gdk_beep (void) { Beep(1000, 50); } -/* - *-------------------------------------------------------------- - * gdk_exit_func - * - * This is the "atexit" function that makes sure the - * library gets a chance to cleanup. - * - * Arguments: - * - * Results: - * - * Side effects: - * The library is un-initialized and the program exits. - * - *-------------------------------------------------------------- - */ - -static void -gdk_exit_func (void) +void +gdk_windowing_exit (void) { - static gboolean in_gdk_exit_func = FALSE; - - GDK_NOTE (MISC, g_print ("gdk_exit_func\n")); - /* This is to avoid an infinite loop if a program segfaults in - an atexit() handler (and yes, it does happen, especially if a program - has trounced over memory too badly for even g_message to work) */ - if (in_gdk_exit_func == TRUE) - return; - in_gdk_exit_func = TRUE; - - if (gdk_initialized) - { - gdk_image_exit (); - gdk_input_exit (); - gdk_key_repeat_restore (); - gdk_dnd_exit (); - - CoUninitialize (); - - DeleteDC (gdk_DC); - gdk_DC = NULL; - gdk_initialized = 0; - } + gdk_win32_dnd_exit (); + CoUninitialize (); + DeleteDC (gdk_DC); + gdk_DC = NULL; } gchar * gdk_get_display(void) { - return "local:"; -} - -/************************************************************* - * gdk_error_trap_push: - * Push an error trap. X errors will be trapped until - * the corresponding gdk_error_pop(), which will return - * the error code, if any. - * arguments: - * - * results: - *************************************************************/ - -void -gdk_error_trap_push (void) -{ - /* ??? */ -} - -/************************************************************* - * gdk_error_trap_pop: - * Pop an error trap added with gdk_error_push() - * arguments: - * - * results: - * 0, if no error occured, otherwise the error code. - *************************************************************/ - -gint -gdk_error_trap_pop (void) -{ - /* ??? */ - return 0; -} - -static void -gdkx_XConvertCase (KeySym symbol, - KeySym *lower, - KeySym *upper) -{ - register KeySym sym = symbol; - - g_return_if_fail (lower != NULL); - g_return_if_fail (upper != NULL); - - *lower = sym; - *upper = sym; - - switch (sym >> 8) - { -#if defined (GDK_A) && defined (GDK_Ooblique) - case 0: /* Latin 1 */ - if ((sym >= GDK_A) && (sym <= GDK_Z)) - *lower += (GDK_a - GDK_A); - else if ((sym >= GDK_a) && (sym <= GDK_z)) - *upper -= (GDK_a - GDK_A); - else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis)) - *lower += (GDK_agrave - GDK_Agrave); - else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis)) - *upper -= (GDK_agrave - GDK_Agrave); - else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn)) - *lower += (GDK_oslash - GDK_Ooblique); - else if ((sym >= GDK_oslash) && (sym <= GDK_thorn)) - *upper -= (GDK_oslash - GDK_Ooblique); - break; -#endif /* LATIN1 */ - -#if defined (GDK_Aogonek) && defined (GDK_tcedilla) - case 1: /* Latin 2 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym == GDK_Aogonek) - *lower = GDK_aogonek; - else if (sym >= GDK_Lstroke && sym <= GDK_Sacute) - *lower += (GDK_lstroke - GDK_Lstroke); - else if (sym >= GDK_Scaron && sym <= GDK_Zacute) - *lower += (GDK_scaron - GDK_Scaron); - else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot) - *lower += (GDK_zcaron - GDK_Zcaron); - else if (sym == GDK_aogonek) - *upper = GDK_Aogonek; - else if (sym >= GDK_lstroke && sym <= GDK_sacute) - *upper -= (GDK_lstroke - GDK_Lstroke); - else if (sym >= GDK_scaron && sym <= GDK_zacute) - *upper -= (GDK_scaron - GDK_Scaron); - else if (sym >= GDK_zcaron && sym <= GDK_zabovedot) - *upper -= (GDK_zcaron - GDK_Zcaron); - else if (sym >= GDK_Racute && sym <= GDK_Tcedilla) - *lower += (GDK_racute - GDK_Racute); - else if (sym >= GDK_racute && sym <= GDK_tcedilla) - *upper -= (GDK_racute - GDK_Racute); - break; -#endif /* LATIN2 */ - -#if defined (GDK_Hstroke) && defined (GDK_Cabovedot) - case 2: /* Latin 3 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex) - *lower += (GDK_hstroke - GDK_Hstroke); - else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex) - *lower += (GDK_gbreve - GDK_Gbreve); - else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex) - *upper -= (GDK_hstroke - GDK_Hstroke); - else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex) - *upper -= (GDK_gbreve - GDK_Gbreve); - else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex) - *lower += (GDK_cabovedot - GDK_Cabovedot); - else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex) - *upper -= (GDK_cabovedot - GDK_Cabovedot); - break; -#endif /* LATIN3 */ - -#if defined (GDK_Rcedilla) && defined (GDK_Amacron) - case 3: /* Latin 4 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= GDK_Rcedilla && sym <= GDK_Tslash) - *lower += (GDK_rcedilla - GDK_Rcedilla); - else if (sym >= GDK_rcedilla && sym <= GDK_tslash) - *upper -= (GDK_rcedilla - GDK_Rcedilla); - else if (sym == GDK_ENG) - *lower = GDK_eng; - else if (sym == GDK_eng) - *upper = GDK_ENG; - else if (sym >= GDK_Amacron && sym <= GDK_Umacron) - *lower += (GDK_amacron - GDK_Amacron); - else if (sym >= GDK_amacron && sym <= GDK_umacron) - *upper -= (GDK_amacron - GDK_Amacron); - break; -#endif /* LATIN4 */ - -#if defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu) - case 6: /* Cyrillic */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE) - *lower -= (GDK_Serbian_DJE - GDK_Serbian_dje); - else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze) - *upper += (GDK_Serbian_DJE - GDK_Serbian_dje); - else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN) - *lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu); - else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign) - *upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu); - break; -#endif /* CYRILLIC */ - -#if defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma) - case 7: /* Greek */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent) - *lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent); - else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent && - sym != GDK_Greek_iotaaccentdieresis && - sym != GDK_Greek_upsilonaccentdieresis) - *upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent); - else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA) - *lower += (GDK_Greek_alpha - GDK_Greek_ALPHA); - else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega && - sym != GDK_Greek_finalsmallsigma) - *upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA); - break; -#endif /* GREEK */ - } + return "Win32"; } static struct gdk_key { @@ -2044,72 +1602,3 @@ gdk_keyval_from_name (const gchar *keyval_name) else return GDK_VoidSymbol; } - -guint -gdk_keyval_to_upper (guint keyval) -{ - if (keyval) - { - KeySym lower_val = 0; - KeySym upper_val = 0; - - gdkx_XConvertCase (keyval, &lower_val, &upper_val); - return upper_val; - } - return 0; -} - -guint -gdk_keyval_to_lower (guint keyval) -{ - if (keyval) - { - KeySym lower_val = 0; - KeySym upper_val = 0; - - gdkx_XConvertCase (keyval, &lower_val, &upper_val); - return lower_val; - } - return 0; -} - -gboolean -gdk_keyval_is_upper (guint keyval) -{ - if (keyval) - { - KeySym lower_val = 0; - KeySym upper_val = 0; - - gdkx_XConvertCase (keyval, &lower_val, &upper_val); - return upper_val == keyval; - } - return TRUE; -} - -gboolean -gdk_keyval_is_lower (guint keyval) -{ - if (keyval) - { - KeySym lower_val = 0; - KeySym upper_val = 0; - - gdkx_XConvertCase (keyval, &lower_val, &upper_val); - return lower_val == keyval; - } - return TRUE; -} - - -void -gdk_threads_enter () -{ - GDK_THREADS_ENTER (); -} - -void -gdk_threads_leave () -{ - GDK_THREADS_LEAVE (); -} diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c index a78fca9355..0438f81455 100644 --- a/gdk/win32/gdkpixmap-win32.c +++ b/gdk/win32/gdkpixmap-win32.c @@ -33,7 +33,7 @@ #include "gdkpixmap.h" #include "gdkprivate.h" -#include "gdkx.h" +#include "gdkwin32.h" typedef struct { @@ -49,6 +49,49 @@ typedef struct gulong pixels[1]; } _GdkPixmapInfo; +static void +gdk_win32_pixmap_destroy (GdkPixmap *pixmap) +{ + GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; + + GDK_NOTE (MISC, g_print ("gdk_win32_pixmap_destroy: %#x\n", + GDK_DRAWABLE_XID (pixmap))); + + if (!DeleteObject (GDK_DRAWABLE_XID (pixmap))) + g_warning ("gdk_win32_pixmap_destroy: DeleteObject failed"); + + gdk_xid_table_remove (GDK_DRAWABLE_XID (pixmap)); + + g_free (GDK_DRAWABLE_WIN32DATA (pixmap)); +} + +static GdkDrawable * +gdk_win32_pixmap_alloc (void) +{ + GdkDrawable *drawable; + GdkDrawablePrivate *private; + + static GdkDrawableClass klass; + static gboolean initialized = FALSE; + + if (!initialized) + { + initialized = TRUE; + + klass = _gdk_win32_drawable_class; + klass.destroy = gdk_win32_pixmap_destroy; + } + + drawable = gdk_drawable_alloc (); + private = (GdkDrawablePrivate *) drawable; + + private->klass = &klass; + private->klass_data = g_new (GdkDrawableWin32Data, 1); + private->window_type = GDK_DRAWABLE_PIXMAP; + + return drawable; +} + GdkPixmap* gdk_pixmap_new (GdkWindow *window, gint width, @@ -57,7 +100,6 @@ gdk_pixmap_new (GdkWindow *window, { GdkPixmap *pixmap; GdkDrawablePrivate *private; - GdkWindowPrivate *window_private; struct { BITMAPINFOHEADER bmiHeader; union { @@ -77,11 +119,10 @@ gdk_pixmap_new (GdkWindow *window, g_return_val_if_fail ((width != 0) && (height != 0), NULL); if (!window) - window = (GdkWindow*) gdk_root_parent; + window = gdk_parent_root; if (GDK_DRAWABLE_DESTROYED (window)) return NULL; - window_private = (GdkWindowPrivate*) window; if (depth == -1) depth = gdk_drawable_get_visual (window)->depth; @@ -89,10 +130,8 @@ gdk_pixmap_new (GdkWindow *window, GDK_NOTE (MISC, g_print ("gdk_pixmap_new: %dx%dx%d\n", width, height, depth)); - private = g_new0 (GdkDrawablePrivate, 1); - pixmap = (GdkPixmap*) private; - - private->window_type = GDK_DRAWABLE_PIXMAP; + pixmap = gdk_win32_pixmap_alloc (); + private = (GdkDrawablePrivate *) pixmap; visual = gdk_drawable_get_visual (window); @@ -139,7 +178,7 @@ gdk_pixmap_new (GdkWindow *window, } else { - private->colormap = window_private->drawable.colormap; + private->colormap = ((GdkWindowPrivate *) window)->drawable.colormap; if (private->colormap == NULL) private->colormap = gdk_colormap_get_system (); @@ -164,25 +203,23 @@ gdk_pixmap_new (GdkWindow *window, #endif } } - if ((private->xwindow = + if ((GDK_DRAWABLE_WIN32DATA (pixmap)->xid = CreateDIBSection (hdc, (BITMAPINFO *) &bmi, iUsage, (PVOID *) &bits, NULL, 0)) == NULL) { g_warning ("gdk_pixmap_new: CreateDIBSection failed: %d", GetLastError ()); ReleaseDC (GDK_DRAWABLE_XID (window), hdc); - g_free (private); + g_free (pixmap); return NULL; } ReleaseDC (GDK_DRAWABLE_XID (window), hdc); - GDK_NOTE (MISC, g_print ("... = %#x\n", private->xwindow)); + GDK_NOTE (MISC, g_print ("... = %#x\n", GDK_DRAWABLE_XID (pixmap))); private->width = width; private->height = height; - private->ref_count = 1; - private->destroyed = 0; - gdk_xid_table_insert (&private->xwindow, pixmap); + gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap); return pixmap; } @@ -196,13 +233,10 @@ gdk_pixmap_create_on_shared_image (GdkImage **image_return, gint depth) { GdkPixmap *pixmap; - GdkImagePrivate *image_private; GdkDrawablePrivate *private; - GdkWindowPrivate *window_private; g_return_val_if_fail (window != NULL, NULL); - window_private = (GdkWindowPrivate *) window; if (depth == 1) *image_return = gdk_image_bitmap_new (GDK_IMAGE_SHARED_PIXMAP, visual, width, height); @@ -214,24 +248,20 @@ gdk_pixmap_create_on_shared_image (GdkImage **image_return, g_return_val_if_fail (*image_return != NULL, NULL); - image_private = (GdkImagePrivate *) *image_return; + pixmap = gdk_win32_pixmap_alloc (); + private = (GdkDrawablePrivate *) pixmap; - private = g_new0 (GdkDrawablePrivate, 1); - pixmap = (GdkPixmap*) private; - - private->xwindow = image_private->ximage; - private->window_type = GDK_DRAWABLE_PIXMAP; - private->colormap = window_private->drawable.colormap; + GDK_DRAWABLE_WIN32DATA (pixmap)->xid = + ((GdkImagePrivateWin32 *) *image_return)->ximage; + private->colormap = ((GdkWindowPrivate *) window)->drawable.colormap; private->width = width; private->height = height; - private->ref_count = 1; - private->destroyed = 0; - gdk_xid_table_insert (&private->xwindow, pixmap); + gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap); GDK_NOTE (MISC, g_print ("gdk_pixmap_create_on_shared_image: %dx%dx%d = %#x\n", - width, height, depth, private->xwindow)); + width, height, depth, GDK_DRAWABLE_XID (pixmap))); return pixmap; } @@ -287,19 +317,16 @@ gdk_bitmap_create_from_data (GdkWindow *window, g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); if (!window) - window = (GdkWindow*) gdk_root_parent; + window = gdk_parent_root; if (GDK_DRAWABLE_DESTROYED (window)) return NULL; - private = g_new0 (GdkDrawablePrivate, 1); - pixmap = (GdkPixmap*) private; + pixmap = gdk_win32_pixmap_alloc (); + private = (GdkDrawablePrivate *) pixmap; - private->window_type = GDK_DRAWABLE_PIXMAP; private->width = width; private->height = height; - private->ref_count = 1; - private->destroyed = FALSE; bpl = ((width - 1) / 8 + 1); aligned_bpl = ((bpl - 1) / 2 + 1) * 2; @@ -307,15 +334,16 @@ gdk_bitmap_create_from_data (GdkWindow *window, for (i = 0; i < height; i++) for (j = 0; j < bpl; j++) bits[i*aligned_bpl + j] = mirror[(guchar) data[i*bpl + j]]; - private->xwindow = CreateBitmap (width, height, 1, 1, bits); + GDK_DRAWABLE_WIN32DATA (pixmap)->xid = + CreateBitmap (width, height, 1, 1, bits); GDK_NOTE (MISC, g_print ("gdk_bitmap_create_from_data: %dx%d = %#x\n", - width, height, private->xwindow)); + width, height, GDK_DRAWABLE_XID (pixmap))); g_free (bits); private->colormap = NULL; - gdk_xid_table_insert (&private->xwindow, pixmap); + gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap); return pixmap; } @@ -341,8 +369,8 @@ gdk_pixmap_create_from_data (GdkWindow *window, GdkGC *gc = gdk_gc_new (result); gdk_gc_set_foreground (gc, fg); gdk_gc_set_background (gc, bg); - gdk_draw_pixmap (result, gc, source, 0, 0, 0, 0, width, height); - gdk_pixmap_unref (source); + gdk_draw_drawable (result, gc, source, 0, 0, 0, 0, width, height); + gdk_drawable_unref (source); gdk_gc_unref (gc); GDK_NOTE (MISC, g_print ("gdk_pixmap_create_from_data: %dx%dx%d = %#x\n", @@ -616,12 +644,12 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window, g_warning ("Creating pixmap from xpm with NULL window and colormap"); if (window == NULL) - window = (GdkWindow *) gdk_root_parent; + window = gdk_parent_root; if (colormap == NULL) { - colormap = gdk_window_get_colormap (window); - visual = gdk_window_get_visual (window); + colormap = gdk_drawable_get_colormap (window); + visual = gdk_drawable_get_visual (window); } else visual = ((GdkColormapPrivate *)colormap)->visual; @@ -761,7 +789,7 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window, error: if (mask) - gdk_gc_destroy (gc); + gdk_gc_unref (gc); if (image != NULL) { @@ -774,8 +802,8 @@ _gdk_pixmap_create_from_xpm (GdkWindow *window, gc = gdk_gc_new (pixmap); gdk_gc_set_foreground (gc, transparent_color); gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); - gdk_gc_destroy (gc); - gdk_image_destroy (image); + gdk_gc_unref (gc); + gdk_image_unref (image); } else if (color_info) gdk_xpm_destroy_notify (color_info); @@ -859,7 +887,7 @@ gdk_pixmap_create_from_xpm (GdkWindow *window, const gchar *filename) { return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask, - transparent_color, filename); + transparent_color, filename); } struct mem_handle @@ -917,7 +945,6 @@ gdk_pixmap_foreign_new (guint32 anid) { GdkPixmap *pixmap; GdkDrawablePrivate *private; - GdkWindowPrivate *window_private; HBITMAP xpixmap; SIZE size; unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret; @@ -928,8 +955,6 @@ gdk_pixmap_foreign_new (guint32 anid) /* set the pixmap to the passed in value */ xpixmap = (HBITMAP) anid; - /* get the root window */ - window_private = gdk_root_parent; /* get information about the BITMAP to fill in the structure for the gdk window */ @@ -938,65 +963,15 @@ gdk_pixmap_foreign_new (guint32 anid) h_ret = size.cy; /* allocate a new gdk pixmap */ - private = g_new (GdkDrawablePrivate, 1); - pixmap = (GdkPixmap *)private; + pixmap = gdk_win32_pixmap_alloc (); + private = (GdkDrawablePrivate *) pixmap; - private->window_type = GDK_DRAWABLE_PIXMAP; - private->xwindow = xpixmap; + GDK_DRAWABLE_WIN32DATA (pixmap)->xid = xpixmap; private->colormap = NULL; private->width = w_ret; private->height = h_ret; - private->ref_count = 1; - private->destroyed = 0; - gdk_xid_table_insert(&private->xwindow, pixmap); + gdk_xid_table_insert(&GDK_DRAWABLE_XID (pixmap), pixmap); return pixmap; } - -GdkPixmap* -gdk_pixmap_ref (GdkPixmap *pixmap) -{ - GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; - g_return_val_if_fail (pixmap != NULL, NULL); - g_return_val_if_fail (GDK_IS_PIXMAP (private), NULL); - - private->ref_count += 1; - return pixmap; -} - -void -gdk_pixmap_unref (GdkPixmap *pixmap) -{ - GdkDrawablePrivate *private = (GdkDrawablePrivate *)pixmap; - g_return_if_fail (pixmap != NULL); - g_return_if_fail (GDK_IS_PIXMAP (private)); - g_return_if_fail (private->ref_count > 0); - - private->ref_count -= 1; - - GDK_NOTE (MISC, g_print ("gdk_pixmap_unref: %#x %d%s\n", - private->xwindow, private->ref_count, - (private->ref_count == 0 ? " freeing" : ""))); - - if (private->ref_count == 0) - { - if (!DeleteObject (private->xwindow)) - g_warning ("gdk_pixmap_unref: DeleteObject failed"); - gdk_xid_table_remove (private->xwindow); - g_dataset_destroy (private); - g_free (private); - } -} - -GdkBitmap * -gdk_bitmap_ref (GdkBitmap *bitmap) -{ - return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap); -} - -void -gdk_bitmap_unref (GdkBitmap *bitmap) -{ - gdk_pixmap_unref ((GdkPixmap *)bitmap); -} diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index f1c4fa3254..8cf53f7ca3 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -261,8 +261,8 @@ struct _GdkRegionPrivate HRGN xregion; }; -void gdk_selection_init (void); -void gdk_dnd_exit (void); +void gdk_win32_selection_init (void); +void gdk_win32_dnd_exit (void); GdkColormap* gdk_colormap_lookup (Colormap xcolormap); GdkVisual* gdk_visual_lookup (Visual *xvisual); @@ -309,6 +309,7 @@ char *gdk_color_to_string (const GdkColor *); extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM); +extern GdkDrawableClass _gdk_win32_drawable_class; extern HWND gdk_root_window; GDKVAR ATOM gdk_selection_property; GDKVAR gchar *gdk_progclass; diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c index 86ee087223..06a20e9608 100644 --- a/gdk/win32/gdkproperty-win32.c +++ b/gdk/win32/gdkproperty-win32.c @@ -31,7 +31,7 @@ #include "gdkproperty.h" #include "gdkselection.h" #include "gdkprivate.h" -#include "gdkx.h" +#include "gdkwin32.h" GdkAtom gdk_atom_intern (const gchar *atom_name, @@ -119,6 +119,12 @@ gdk_property_get (GdkWindow *window, gint *actual_length, guchar **data) { + g_return_val_if_fail (window != NULL, FALSE); + g_return_val_if_fail (!GDK_IS_WINDOW (window), FALSE); + + if (GDK_DRAWABLE_DESTROYED (window)) + return FALSE; + g_warning ("gdk_property_get: Not implemented"); return FALSE; @@ -138,10 +144,13 @@ gdk_property_change (GdkWindow *window, gchar *prop_name, *type_name; guchar *ptr; + g_return_if_fail (window != NULL); + g_return_if_fail (!GDK_IS_WINDOW (window)); + if (GDK_DRAWABLE_DESTROYED (window)) return; - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, (prop_name = gdk_atom_name (property), type_name = gdk_atom_name (type), g_print ("gdk_property_change: %#x %#x (%s) %#x (%s) %s %d*%d bytes %.10s\n", @@ -166,8 +175,8 @@ gdk_property_change (GdkWindow *window, if (*ptr++ == '\n') length++; #if 1 - GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n", - GDK_DRAWABLE_XID (window))); + GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n", + GDK_DRAWABLE_XID (window))); if (!OpenClipboard (GDK_DRAWABLE_XID (window))) { g_warning ("gdk_property_change: OpenClipboard failed"); @@ -176,7 +185,7 @@ gdk_property_change (GdkWindow *window, #endif hdata = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, length + 1); ptr = GlobalLock (hdata); - GDK_NOTE (SELECTION, g_print ("...hdata=%#x, ptr=%#x\n", hdata, ptr)); + GDK_NOTE (MISC, g_print ("...hdata=%#x, ptr=%#x\n", hdata, ptr)); for (i = 0; i < nelements; i++) { @@ -186,13 +195,13 @@ gdk_property_change (GdkWindow *window, } *ptr++ = '\0'; GlobalUnlock (hdata); - GDK_NOTE (SELECTION, g_print ("...SetClipboardData(CF_TEXT, %#x)\n", - hdata)); + GDK_NOTE (MISC, g_print ("...SetClipboardData(CF_TEXT, %#x)\n", + hdata)); if (!SetClipboardData(CF_TEXT, hdata)) g_warning ("gdk_property_change: SetClipboardData failed: %d", GetLastError ()); #if 1 - GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n")); + GDK_NOTE (MISC, g_print ("...CloseClipboard()\n")); if (!CloseClipboard ()) { g_warning ("gdk_property_change: CloseClipboard failed"); @@ -211,10 +220,10 @@ gdk_property_delete (GdkWindow *window, gchar *prop_name, *type_name; extern void gdk_selection_property_delete (GdkWindow *); - if (GDK_DRAWABLE_DESTROYED (window)) - return; + g_return_if_fail (window != NULL); + g_return_if_fail (!GDK_IS_WINDOW (window)); - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, (prop_name = gdk_atom_name (property), g_print ("gdk_property_delete: %#x %#x (%s)\n", (window ? GDK_DRAWABLE_XID (window) : 0), diff --git a/gdk/win32/gdkregion-win32.c b/gdk/win32/gdkregion-win32.c index 7a0acf5fa5..0cc4b4e265 100644 --- a/gdk/win32/gdkregion-win32.c +++ b/gdk/win32/gdkregion-win32.c @@ -27,7 +27,7 @@ #include "config.h" #include "gdk.h" -#include "gdkprivate.h" +#include "gdkprivate-win32.h" GdkRegion* @@ -274,9 +274,10 @@ gdk_region_union_with_rect (GdkRegion *region, return res; } -GdkRegion* -gdk_regions_intersect (GdkRegion *source1, - GdkRegion *source2) +static GdkRegion * +gdk_regions_op (GdkRegion *source1, + GdkRegion *source2, + guint op) { GdkRegionPrivate *private1; GdkRegionPrivate *private2; @@ -292,76 +293,34 @@ gdk_regions_intersect (GdkRegion *source1, res = gdk_region_new (); res_private = (GdkRegionPrivate *) res; - CombineRgn (res_private->xregion, private1->xregion, private2->xregion, - RGN_AND); + CombineRgn (res_private->xregion, private1->xregion, private2->xregion, op); return res; } -GdkRegion* -gdk_regions_union (GdkRegion *source1, - GdkRegion *source2) +GdkRegion* +gdk_regions_intersect (GdkRegion *source1, + GdkRegion *source2) { - GdkRegionPrivate *private1; - GdkRegionPrivate *private2; - GdkRegion *res; - GdkRegionPrivate *res_private; + return gdk_regions_op (source1, source2, RGN_AND); +} - g_return_val_if_fail (source1 != NULL, NULL); - g_return_val_if_fail (source2 != NULL, NULL); - - private1 = (GdkRegionPrivate *) source1; - private2 = (GdkRegionPrivate *) source2; - - res = gdk_region_new (); - res_private = (GdkRegionPrivate *) res; - - CombineRgn (res_private->xregion, private1->xregion, private2->xregion, - RGN_OR); - return res; +GdkRegion* +gdk_regions_union (GdkRegion *source1, + GdkRegion *source2) +{ + return gdk_regions_op (source1, source2, RGN_OR); } GdkRegion* gdk_regions_subtract (GdkRegion *source1, GdkRegion *source2) { - GdkRegionPrivate *private1; - GdkRegionPrivate *private2; - GdkRegion *res; - GdkRegionPrivate *res_private; - - g_return_val_if_fail (source1 != NULL, NULL); - g_return_val_if_fail (source2 != NULL, NULL); - - private1 = (GdkRegionPrivate *) source1; - private2 = (GdkRegionPrivate *) source2; - - res = gdk_region_new (); - res_private = (GdkRegionPrivate *) res; - - CombineRgn (res_private->xregion, private1->xregion, private2->xregion, - RGN_DIFF); - return res; + return gdk_regions_op (source1, source2, RGN_DIFF); } GdkRegion* gdk_regions_xor (GdkRegion *source1, GdkRegion *source2) { - GdkRegionPrivate *private1; - GdkRegionPrivate *private2; - GdkRegion *res; - GdkRegionPrivate *res_private; - - g_return_val_if_fail (source1 != NULL, NULL); - g_return_val_if_fail (source2 != NULL, NULL); - - private1 = (GdkRegionPrivate *) source1; - private2 = (GdkRegionPrivate *) source2; - - res = gdk_region_new (); - res_private = (GdkRegionPrivate *) res; - - CombineRgn (res_private->xregion, private1->xregion, private2->xregion, - RGN_XOR); - return res; + return gdk_regions_op (source1, source2, RGN_XOR); } diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c index 0338672893..7c58baaa3a 100644 --- a/gdk/win32/gdkselection-win32.c +++ b/gdk/win32/gdkselection-win32.c @@ -29,7 +29,7 @@ #include #include -#include "gdkx.h" +#include "gdkwin32.h" /* We emulate the GDK_SELECTION window properties by storing * it's data in a per-window hashtable. @@ -45,7 +45,7 @@ typedef struct { static GHashTable *sel_prop_table = NULL; void -gdk_selection_init (void) +gdk_win32_selection_init (void) { if (sel_prop_table == NULL) sel_prop_table = g_hash_table_new (g_int_hash, g_int_equal); @@ -83,7 +83,7 @@ gdk_selection_owner_set (GdkWindow *owner, gchar *sel_name; HWND xwindow; - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, (sel_name = gdk_atom_name (selection), g_print ("gdk_selection_owner_set: %#x %#x (%s)\n", (owner ? GDK_DRAWABLE_XID (owner) : 0), @@ -98,13 +98,13 @@ gdk_selection_owner_set (GdkWindow *owner, else xwindow = NULL; - GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n", xwindow)); + GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n", xwindow)); if (!OpenClipboard (xwindow)) { g_warning ("gdk_selection_owner_set: OpenClipboard failed"); return FALSE; } - GDK_NOTE (SELECTION, g_print ("...EmptyClipboard()\n")); + GDK_NOTE (MISC, g_print ("...EmptyClipboard()\n")); if (!EmptyClipboard ()) { g_warning ("gdk_selection_owner_set: EmptyClipboard failed"); @@ -116,7 +116,7 @@ gdk_selection_owner_set (GdkWindow *owner, if (xwindow != NULL) SetClipboardData (CF_TEXT, NULL); #endif - GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n")); + GDK_NOTE (MISC, g_print ("...CloseClipboard()\n")); if (!CloseClipboard ()) { g_warning ("gdk_selection_owner_set: CloseClipboard failed"); @@ -154,7 +154,7 @@ gdk_selection_owner_get (GdkAtom selection) #endif - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, (sel_name = gdk_atom_name (selection), g_print ("gdk_selection_owner_get: %#x (%s) = %#x\n", selection, sel_name, @@ -180,7 +180,7 @@ gdk_selection_convert (GdkWindow *requestor, if (GDK_DRAWABLE_DESTROYED (requestor)) return; - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, (sel_name = gdk_atom_name (selection), tgt_name = gdk_atom_name (target), g_print ("gdk_selection_convert: %#x %#x (%s) %#x (%s)\n", @@ -194,7 +194,7 @@ gdk_selection_convert (GdkWindow *requestor, * contents of the clipboard. Get the clipboard data, * and store it for later. */ - GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n", + GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n", GDK_DRAWABLE_XID (requestor))); if (!OpenClipboard (GDK_DRAWABLE_XID (requestor))) { @@ -202,15 +202,15 @@ gdk_selection_convert (GdkWindow *requestor, return; } - GDK_NOTE (SELECTION, g_print ("...GetClipboardData(CF_TEXT)\n")); + GDK_NOTE (MISC, g_print ("...GetClipboardData(CF_TEXT)\n")); if ((hdata = GetClipboardData (CF_TEXT)) != NULL) { if ((ptr = GlobalLock (hdata)) != NULL) { length = GlobalSize (hdata); - GDK_NOTE (SELECTION, g_print ("...got data: %d bytes: %.10s\n", - length, ptr)); + GDK_NOTE (MISC, g_print ("...got data: %d bytes: %.10s\n", + length, ptr)); slength = 0; p = ptr; @@ -240,7 +240,7 @@ gdk_selection_convert (GdkWindow *requestor, GlobalUnlock (hdata); } } - GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n")); + GDK_NOTE (MISC, g_print ("...CloseClipboard()\n")); CloseClipboard (); @@ -257,11 +257,13 @@ gdk_selection_convert (GdkWindow *requestor, */ GdkSelProp *prop; - prop = g_hash_table_lookup (sel_prop_table, &gdk_root_parent->drawable.xwindow); + prop = g_hash_table_lookup (sel_prop_table, + &GDK_DRAWABLE_XID (gdk_parent_root)); if (prop != NULL) { - g_hash_table_remove (sel_prop_table, &gdk_root_parent->drawable.xwindow); + g_hash_table_remove (sel_prop_table, + &GDK_DRAWABLE_XID (gdk_parent_root)); gdk_sel_prop_store (requestor, prop->type, prop->format, prop->data, prop->length); g_free (prop); @@ -288,8 +290,8 @@ gdk_selection_property_get (GdkWindow *requestor, if (GDK_DRAWABLE_DESTROYED (requestor)) return 0; - GDK_NOTE (SELECTION, g_print ("gdk_selection_property_get: %#x\n", - GDK_DRAWABLE_XID (requestor))); + GDK_NOTE (MISC, g_print ("gdk_selection_property_get: %#x\n", + GDK_DRAWABLE_XID (requestor))); prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (requestor)); @@ -333,7 +335,7 @@ gdk_selection_send_notify (guint32 requestor, { gchar *sel_name, *tgt_name, *prop_name; - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, (sel_name = gdk_atom_name (selection), tgt_name = gdk_atom_name (target), prop_name = gdk_atom_name (property), @@ -370,7 +372,7 @@ gdk_text_property_to_text_list (GdkAtom encoding, gint length, gchar ***list) { - GDK_NOTE (SELECTION, + GDK_NOTE (MISC, g_print ("gdk_text_property_to_text_list not implemented\n")); return 0; diff --git a/gdk/win32/gdkvisual-win32.c b/gdk/win32/gdkvisual-win32.c index 635c51551c..d2827e7240 100644 --- a/gdk/win32/gdkvisual-win32.c +++ b/gdk/win32/gdkvisual-win32.c @@ -27,7 +27,7 @@ #include "config.h" #include "gdkvisual.h" -#include "gdkprivate.h" +#include "gdkprivate-win32.h" static void gdk_visual_decompose_mask (gulong mask, gint *shift, diff --git a/gdk/win32/gdkwin32id.c b/gdk/win32/gdkwin32id.c index 4cba645459..a0a6a556fe 100644 --- a/gdk/win32/gdkwin32id.c +++ b/gdk/win32/gdkwin32id.c @@ -29,18 +29,18 @@ #include #include -#include "gdkprivate.h" +#include "gdkprivate-win32.h" -static guint gdk_xid_hash (XID *xid); -static gint gdk_xid_compare (XID *a, - XID *b); +static guint gdk_xid_hash (HANDLE *xid); +static gint gdk_xid_compare (HANDLE *a, + HANDLE *b); static GHashTable *xid_ht = NULL; void -gdk_xid_table_insert (XID *xid, +gdk_xid_table_insert (HANDLE *xid, gpointer data) { g_return_if_fail (xid != NULL); @@ -53,7 +53,7 @@ gdk_xid_table_insert (XID *xid, } void -gdk_xid_table_remove (XID xid) +gdk_xid_table_remove (HANDLE xid) { if (!xid_ht) xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash, @@ -63,7 +63,7 @@ gdk_xid_table_remove (XID xid) } gpointer -gdk_xid_table_lookup (XID xid) +gdk_xid_table_lookup (HANDLE xid) { gpointer data = NULL; @@ -75,14 +75,14 @@ gdk_xid_table_lookup (XID xid) static guint -gdk_xid_hash (XID *xid) +gdk_xid_hash (HANDLE *xid) { return (guint) *xid; } static gint -gdk_xid_compare (XID *a, - XID *b) +gdk_xid_compare (HANDLE *a, + HANDLE *b) { return (*a == *b); } diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 40c64f169d..1f466ae40b 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -33,9 +33,13 @@ #include "gdkevents.h" #include "gdkpixmap.h" #include "gdkwindow.h" -#include "gdkprivate.h" +#include "gdkprivate-win32.h" #include "gdkinputprivate.h" -#include "gdkx.h" +#include "gdkwin32.h" + +static gboolean gdk_window_gravity_works (void); +static void gdk_window_set_static_win_gravity (GdkWindow *window, + gboolean on); /* The Win API function AdjustWindowRect may return negative values * resulting in obscured title bars. This helper function is coreccting it. @@ -61,50 +65,66 @@ SafeAdjustWindowRectEx (RECT* lpRect, return TRUE; } -/* Forward declarations */ -static gboolean gdk_window_gravity_works (void); -static void gdk_window_set_static_win_gravity (GdkWindow *window, - gboolean on); - -/* - * The following fucntion by The Rasterman - * This function returns the X Window ID in which the x y location is in - * (x and y being relative to the root window), excluding any windows listed - * in the GList excludes (this is a list of X Window ID's - gpointer being - * the Window ID). - * - * This is primarily designed for internal gdk use - for DND for example - * when using a shaped icon window as the drag object - you exclude the - * X Window ID of the "icon" (perhaps more if excludes may be needed) and - * You can get back an X Window ID as to what X Window ID is infact under - * those X,Y co-ordinates. - */ -HWND -gdk_window_xid_at_coords (gint x, - gint y, - GList *excludes, - gboolean excl_child) +static void +gdk_win32_window_destroy (GdkDrawable *drawable) { - POINT pt; - gboolean warned = FALSE; - - pt.x = x; - pt.y = y; - /* This is probably not correct, just a quick hack */ - - if (!warned) + if (!GDK_DRAWABLE_DESTROYED (drawable)) { - g_warning ("gdk_window_xid_at_coords probably not implemented correctly"); - warned = TRUE; + if (GDK_DRAWABLE_TYPE (drawable) == GDK_WINDOW_FOREIGN) + gdk_xid_table_remove (GDK_DRAWABLE_XID (drawable)); + else + g_warning ("losing last reference to undestroyed window\n"); } - /* XXX */ - return WindowFromPoint (pt); + if (GDK_WINDOW_WIN32DATA (drawable)->bg_type == GDK_WIN32_BG_PIXMAP + && GDK_WINDOW_WIN32DATA (drawable)->bg_pixmap != NULL) + gdk_drawable_unref (GDK_WINDOW_WIN32DATA (drawable)->bg_pixmap); + + g_free (GDK_DRAWABLE_WIN32DATA (drawable)); +} + +static GdkWindow * +gdk_win32_window_alloc (void) +{ + GdkWindow *window; + GdkWindowPrivate *private; + + static GdkDrawableClass klass; + static gboolean initialized = FALSE; + + if (!initialized) + { + initialized = TRUE; + + klass = _gdk_win32_drawable_class; + klass.destroy = gdk_win32_window_destroy; + } + + window = _gdk_window_alloc (); + private = (GdkWindowPrivate *) window; + + private->drawable.klass = &klass; + private->drawable.klass_data = g_new (GdkDrawableWin32Data, 1); + + GDK_WINDOW_WIN32DATA (window)->event_mask = 0; + GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_NORMAL; + GDK_WINDOW_WIN32DATA (window)->xcursor = NULL; + GDK_WINDOW_WIN32DATA (window)->hint_flags = 0; + GDK_WINDOW_WIN32DATA (window)->extension_events = 0; + GDK_WINDOW_WIN32DATA (window)->extension_events_selected = FALSE; + + GDK_WINDOW_WIN32DATA (window)->input_locale = GetKeyboardLayout (0); + TranslateCharsetInfo ((DWORD FAR *) GetACP (), + &GDK_WINDOW_WIN32DATA (window)->charset_info, + TCI_SRCCODEPAGE); + + return window; } void gdk_window_init (void) { + GdkWindowPrivate *private; RECT r; guint width; guint height; @@ -113,18 +133,15 @@ gdk_window_init (void) width = r.right - r.left; height = r.bottom - r.top; - gdk_root_parent = g_new (GdkWindowPrivate, 1); - gdk_root_parent->drawable.xwindow = gdk_root_window; - gdk_root_parent->drawable.window_type = GDK_WINDOW_ROOT; - gdk_root_parent->drawable.drawable.user_data = NULL; - gdk_root_parent->drawable.width = width; - gdk_root_parent->drawable.height = height; - gdk_root_parent->drawable.ref_count = 1; - gdk_root_parent->drawable.colormap = NULL; - gdk_root_parent->parent = NULL; - gdk_root_parent->children = NULL; + gdk_parent_root = gdk_win32_window_alloc (); + private = (GdkWindowPrivate *) gdk_parent_root; + + GDK_DRAWABLE_WIN32DATA (gdk_parent_root)->xid = gdk_root_window; + private->drawable.window_type = GDK_WINDOW_ROOT; + private->drawable.width = width; + private->drawable.height = height; - gdk_xid_table_insert (&gdk_root_window, gdk_root_parent); + gdk_xid_table_insert (&gdk_root_window, gdk_parent_root); } /* RegisterGdkClass @@ -135,7 +152,7 @@ gdk_window_init (void) * get its own class */ ATOM -RegisterGdkClass(GdkWindowType wtype) +RegisterGdkClass (GdkDrawableType wtype) { static ATOM klassTOPLEVEL = 0; static ATOM klassDIALOG = 0; @@ -238,8 +255,7 @@ RegisterGdkClass(GdkWindowType wtype) } return klass; -} /* RegisterGdkClass */ - +} GdkWindow* gdk_window_new (GdkWindow *parent, @@ -255,7 +271,6 @@ gdk_window_new (GdkWindow *parent, ATOM klass = 0; DWORD dwStyle, dwExStyle; RECT rect; - UINT acp; int width, height; int x, y; char *title; @@ -267,38 +282,27 @@ gdk_window_new (GdkWindow *parent, g_return_val_if_fail (attributes != NULL, NULL); if (!parent) - parent = (GdkWindow*) gdk_root_parent; + parent = gdk_parent_root; parent_private = (GdkWindowPrivate*) parent; if (GDK_DRAWABLE_DESTROYED (parent)) return NULL; - xparent = parent_private->drawable.xwindow; + xparent = GDK_DRAWABLE_XID (parent); - private = g_new (GdkWindowPrivate, 1); - window = (GdkWindow*) private; + window = gdk_win32_window_alloc (); + private = (GdkWindowPrivate *)window; private->parent = parent; - private->drawable.destroyed = FALSE; - private->mapped = FALSE; - private->guffaw_gravity = FALSE; - private->resize_count = 0; - private->drawable.ref_count = 1; - private->x = (attributes_mask & GDK_WA_X) ? attributes->x : 0; private->y = (attributes_mask & GDK_WA_Y) ? attributes->y : 0; private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1); private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1); private->drawable.window_type = attributes->window_type; - private->extension_events = 0; - private->extension_events_selected = FALSE; - - private->filters = NULL; - private->children = NULL; - - window->user_data = NULL; + GDK_WINDOW_WIN32DATA (window)->extension_events = 0; + GDK_WINDOW_WIN32DATA (window)->extension_events_selected = FALSE; if (attributes_mask & GDK_WA_VISUAL) visual = attributes->visual; @@ -311,10 +315,7 @@ gdk_window_new (GdkWindow *parent, else title = g_get_prgname (); - private->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask; - private->bg_type = GDK_WIN32_BG_NORMAL; - private->hint_flags = 0; - private->xcursor = NULL; + GDK_WINDOW_WIN32DATA (window)->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask; if (parent_private && parent_private->guffaw_gravity) { @@ -333,8 +334,8 @@ gdk_window_new (GdkWindow *parent, { dwExStyle = WS_EX_TRANSPARENT; private->drawable.colormap = NULL; - private->bg_type = GDK_WIN32_BG_TRANSPARENT; - private->bg_pixmap = NULL; + GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_TRANSPARENT; + GDK_WINDOW_WIN32DATA (window)->bg_pixmap = NULL; } if (attributes_mask & GDK_WA_X) @@ -415,12 +416,6 @@ gdk_window_new (GdkWindow *parent, height = private->drawable.height; } - acp = GetACP (); - private->input_locale = GetKeyboardLayout (0); - TranslateCharsetInfo ((DWORD FAR *) acp, - &private->charset_info, - TCI_SRCCODEPAGE); - titlelen = strlen (title); wctitle = g_new (wchar_t, titlelen + 1); mbtitle = g_new (char, 3*titlelen + 1); @@ -429,7 +424,7 @@ gdk_window_new (GdkWindow *parent, WideCharToMultiByte (GetACP (), 0, wctitle, -1, mbtitle, 3*titlelen, NULL, NULL); - private->drawable.xwindow = + GDK_DRAWABLE_WIN32DATA (window)->xid = CreateWindowEx (dwExStyle, MAKEINTRESOURCE(klass), mbtitle, @@ -452,22 +447,23 @@ gdk_window_new (GdkWindow *parent, mbtitle, width, height, (x == CW_USEDEFAULT ? -9999 : x), y, xparent, - private->drawable.xwindow, - private->input_locale, - private->charset_info.ciACP)); + GDK_DRAWABLE_XID (window), + GDK_WINDOW_WIN32DATA (window)->input_locale, + GDK_WINDOW_WIN32DATA (window)->charset_info.ciACP)); g_free (mbtitle); g_free (wctitle); - if (private->drawable.xwindow == NULL) + if (GDK_DRAWABLE_XID (window) == NULL) { g_warning ("gdk_window_create: CreateWindowEx failed"); + g_free (GDK_DRAWABLE_WIN32DATA (window)); g_free (private); return NULL; } - gdk_window_ref (window); - gdk_xid_table_insert (&private->drawable.xwindow, window); + gdk_drawable_ref (window); + gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window); if (private->drawable.colormap) gdk_colormap_ref (private->drawable.colormap); @@ -489,8 +485,8 @@ gdk_window_foreign_new (guint32 anid) RECT rect; POINT point; - private = g_new (GdkWindowPrivate, 1); - window = (GdkWindow*) private; + window = gdk_win32_window_alloc (); + private = (GdkWindowPrivate *)window; parent = GetParent ((HWND) anid); private->parent = gdk_xid_table_lookup (parent); @@ -500,7 +496,7 @@ gdk_window_foreign_new (guint32 anid) if (parent_private) parent_private->children = g_list_prepend (parent_private->children, window); - private->drawable.xwindow = (HWND) anid; + GDK_DRAWABLE_WIN32DATA (window)->xid = (HWND) anid; GetClientRect ((HWND) anid, &rect); point.x = rect.left; point.y = rect.right; @@ -511,31 +507,21 @@ gdk_window_foreign_new (guint32 anid) private->y = point.y; private->drawable.width = rect.right - rect.left; private->drawable.height = rect.bottom - rect.top; - private->resize_count = 0; - private->drawable.ref_count = 1; private->drawable.window_type = GDK_WINDOW_FOREIGN; private->drawable.destroyed = FALSE; - private->mapped = IsWindowVisible (private->drawable.xwindow); - private->guffaw_gravity = FALSE; - private->extension_events = 0; - private->extension_events_selected = FALSE; + private->mapped = IsWindowVisible (GDK_DRAWABLE_XID (window)); private->drawable.colormap = NULL; - private->filters = NULL; - private->children = NULL; - - window->user_data = NULL; - - gdk_window_ref (window); - gdk_xid_table_insert (&private->drawable.xwindow, window); + gdk_drawable_ref (window); + gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window); return window; } /* Call this function when you want a window and all its children to - * disappear. When xdestroy is true, a request to destroy the XWindow - * is sent out. When it is false, it is assumed that the XWindow has + * disappear. When xdestroy is true, a request to destroy the window + * is sent out. When it is false, it is assumed that the window has * been or will be destroyed by destroying some ancestor of this * window. */ @@ -552,12 +538,12 @@ gdk_window_internal_destroy (GdkWindow *window, g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; + private = (GdkWindowPrivate *) window; GDK_NOTE (MISC, g_print ("gdk_window_internal_destroy %#x\n", - private->drawable.xwindow)); + GDK_DRAWABLE_XID (window))); - switch (private->drawable.window_type) + switch (GDK_DRAWABLE_TYPE (window)) { case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_CHILD: @@ -625,11 +611,11 @@ gdk_window_internal_destroy (GdkWindow *window, * OTOH, I don't think foreign windows are much * used, so the question is maybe academic. */ - PostMessage (private->drawable.xwindow, WM_QUIT, 0, 0); + PostMessage (GDK_DRAWABLE_XID (window), WM_QUIT, 0, 0); } } else if (xdestroy) - DestroyWindow (private->drawable.xwindow); + DestroyWindow (GDK_DRAWABLE_XID (window)); if (private->drawable.colormap) gdk_colormap_unref (private->drawable.colormap); @@ -644,7 +630,7 @@ gdk_window_internal_destroy (GdkWindow *window, break; case GDK_DRAWABLE_PIXMAP: - g_error ("called gdk_window_destroy on a pixmap (use gdk_pixmap_unref)"); + g_error ("called gdk_window_destroy on a pixmap (use gdk_drawable_unref)"); break; } } @@ -656,108 +642,63 @@ void gdk_window_destroy (GdkWindow *window) { gdk_window_internal_destroy (window, TRUE, TRUE); - gdk_window_unref (window); + gdk_drawable_unref (window); } -/* This function is called when the XWindow is really gone. */ +/* This function is called when the window really gone. */ void gdk_window_destroy_notify (GdkWindow *window) { g_return_if_fail (window != NULL); - GDK_NOTE (EVENTS, g_print ("gdk_window_destroy_notify: %#x %d\n", - GDK_DRAWABLE_XID (window), GDK_DRAWABLE_DESTROYED (window))); + GDK_NOTE (EVENTS, + g_print ("gdk_window_destroy_notify: %#x %s\n", + GDK_DRAWABLE_XID (window), + (GDK_DRAWABLE_DESTROYED (window) ? "yes" : "no"))); if (!GDK_DRAWABLE_DESTROYED (window)) { if (GDK_DRAWABLE_TYPE(window) != GDK_WINDOW_FOREIGN) - g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_DRAWABLE_XID (window)); + g_warning ("window %#x unexpectedly destroyed", + GDK_DRAWABLE_XID (window)); gdk_window_internal_destroy (window, FALSE, FALSE); } gdk_xid_table_remove (GDK_DRAWABLE_XID (window)); - gdk_window_unref (window); -} - -GdkWindow* -gdk_window_ref (GdkWindow *window) -{ - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - g_return_val_if_fail (window != NULL, NULL); - - private->drawable.ref_count += 1; - - GDK_NOTE (MISC, g_print ("gdk_window_ref %#x %d\n", - GDK_DRAWABLE_XID (window), - private->drawable.ref_count)); - - return window; -} - -void -gdk_window_unref (GdkWindow *window) -{ - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - g_return_if_fail (window != NULL); - - private->drawable.ref_count -= 1; - - GDK_NOTE (MISC, g_print ("gdk_window_unref %#x %d%s\n", - private->drawable.xwindow, - private->drawable.ref_count, - (private->drawable.ref_count == 0 ? " freeing" : ""))); - - if (private->drawable.ref_count == 0) - { - if (private->bg_type == GDK_WIN32_BG_PIXMAP - && private->bg_pixmap != NULL) - gdk_pixmap_unref (private->bg_pixmap); - - if (!private->drawable.destroyed) - { - if (private->drawable.window_type == GDK_WINDOW_FOREIGN) - gdk_xid_table_remove (private->drawable.xwindow); - else - g_warning ("losing last reference to undestroyed window"); - } - g_dataset_destroy (window); - g_free (window); - } + gdk_drawable_unref (window); } void gdk_window_show (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { GDK_NOTE (MISC, g_print ("gdk_window_show: %#x\n", - private->drawable.xwindow)); + GDK_DRAWABLE_XID (window))); - private->mapped = TRUE; - if (private->drawable.window_type == GDK_WINDOW_TEMP) + ((GdkWindowPrivate *) window)->mapped = TRUE; + if (GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_TEMP) { - ShowWindow (private->drawable.xwindow, SW_SHOWNOACTIVATE); - SetWindowPos (private->drawable.xwindow, HWND_TOPMOST, 0, 0, 0, 0, + ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNOACTIVATE); + SetWindowPos (GDK_DRAWABLE_XID (window), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); #if 0 - ShowWindow (private->drawable.xwindow, SW_HIDE); /* Don't put on toolbar */ + /* Don't put on toolbar */ + ShowWindow (GDK_DRAWABLE_XID (window), SW_HIDE); #endif } else { - ShowWindow (private->drawable.xwindow, SW_SHOWNORMAL); - ShowWindow (private->drawable.xwindow, SW_RESTORE); - SetForegroundWindow (private->drawable.xwindow); - BringWindowToTop (private->drawable.xwindow); + ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNORMAL); + ShowWindow (GDK_DRAWABLE_XID (window), SW_RESTORE); + SetForegroundWindow (GDK_DRAWABLE_XID (window)); + BringWindowToTop (GDK_DRAWABLE_XID (window)); #if 0 - ShowOwnedPopups (private->drawable.xwindow, TRUE); + ShowOwnedPopups (GDK_DRAWABLE_XID (window), TRUE); #endif } } @@ -766,25 +707,22 @@ gdk_window_show (GdkWindow *window) void gdk_window_hide (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { GDK_NOTE (MISC, g_print ("gdk_window_hide: %#x\n", - private->drawable.xwindow)); + GDK_DRAWABLE_XID (window))); - private->mapped = FALSE; - if (private->drawable.window_type == GDK_WINDOW_TOPLEVEL) - ShowOwnedPopups (private->drawable.xwindow, FALSE); + ((GdkWindowPrivate *) window)->mapped = FALSE; + if (GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_TOPLEVEL) + ShowOwnedPopups (GDK_DRAWABLE_XID (window), FALSE); #if 1 - ShowWindow (private->drawable.xwindow, SW_HIDE); + ShowWindow (GDK_DRAWABLE_XID (window), SW_HIDE); #elif 0 - ShowWindow (private->drawable.xwindow, SW_MINIMIZE); + ShowWindow (GDK_DRAWABLE_XID (window), SW_MINIMIZE); #else - CloseWindow (private->drawable.xwindow); + CloseWindow (GDK_DRAWABLE_XID (window)); #endif } } @@ -792,15 +730,12 @@ gdk_window_hide (GdkWindow *window) void gdk_window_withdraw (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { GDK_NOTE (MISC, g_print ("gdk_window_withdraw: %#x\n", - private->drawable.xwindow)); + GDK_DRAWABLE_XID (window))); gdk_window_hide (window); /* XXX */ } @@ -815,17 +750,17 @@ gdk_window_move (GdkWindow *window, g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { RECT rect; GDK_NOTE (MISC, g_print ("gdk_window_move: %#x +%d+%d\n", - private->drawable.xwindow, x, y)); + GDK_DRAWABLE_XID (window), x, y)); - GetClientRect (private->drawable.xwindow, &rect); + private = (GdkWindowPrivate *) window; + GetClientRect (GDK_DRAWABLE_XID (window), &rect); - if (private->drawable.window_type != GDK_WINDOW_CHILD) + if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD) { POINT ptTL, ptBR; DWORD dwStyle; @@ -833,18 +768,18 @@ gdk_window_move (GdkWindow *window, ptTL.x = 0; ptTL.y = 0; - ClientToScreen (private->drawable.xwindow, &ptTL); + ClientToScreen (GDK_DRAWABLE_XID (window), &ptTL); rect.left = x; rect.top = y; ptBR.x = rect.right; ptBR.y = rect.bottom; - ClientToScreen (private->drawable.xwindow, &ptBR); + ClientToScreen (GDK_DRAWABLE_XID (window), &ptBR); rect.right = x + ptBR.x - ptTL.x; rect.bottom = y + ptBR.y - ptTL.y; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); if (!SafeAdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle)) g_warning ("gdk_window_move: AdjustWindowRectEx failed"); @@ -857,10 +792,10 @@ gdk_window_move (GdkWindow *window, private->y = y; } GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n", - private->drawable.xwindow, + GDK_DRAWABLE_XID (window), rect.right - rect.left, rect.bottom - rect.top, x, y)); - if (!MoveWindow (private->drawable.xwindow, + if (!MoveWindow (GDK_DRAWABLE_XID (window), x, y, rect.right - rect.left, rect.bottom - rect.top, TRUE)) g_warning ("gdk_window_move: MoveWindow failed"); @@ -891,7 +826,7 @@ gdk_window_resize (GdkWindow *window, int x, y; GDK_NOTE (MISC, g_print ("gdk_window_resize: %#x %dx%d\n", - private->drawable.xwindow, width, height)); + GDK_DRAWABLE_XID (window), width, height)); if (private->drawable.window_type != GDK_WINDOW_CHILD) { @@ -902,14 +837,14 @@ gdk_window_resize (GdkWindow *window, pt.x = 0; pt.y = 0; - ClientToScreen (private->drawable.xwindow, &pt); + ClientToScreen (GDK_DRAWABLE_XID (window), &pt); rect.left = pt.x; rect.top = pt.y; rect.right = pt.x + width; rect.bottom = pt.y + height; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle)) g_warning ("gdk_window_resize: AdjustWindowRectEx failed"); @@ -928,9 +863,10 @@ gdk_window_resize (GdkWindow *window, private->resize_count += 1; - GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n", - private->drawable.xwindow, width, height, x, y)); - if (!MoveWindow (private->drawable.xwindow, + GDK_NOTE (MISC, + g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n", + GDK_DRAWABLE_XID (window), width, height, x, y)); + if (!MoveWindow (GDK_DRAWABLE_XID (window), x, y, width, height, TRUE)) g_warning ("gdk_window_resize: MoveWindow failed"); @@ -953,23 +889,23 @@ gdk_window_move_resize (GdkWindow *window, if ((gint16) height < 1) height = 1; - private = (GdkWindowPrivate*) window; - if (!private->drawable.destroyed) + if (!GDK_DRAWABLE_DESTROYED (window)) { RECT rect; DWORD dwStyle; DWORD dwExStyle; GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %#x %dx%d@+%d+%d\n", - private->drawable.xwindow, width, height, x, y)); + GDK_DRAWABLE_XID (window), width, height, x, y)); + private = (GdkWindowPrivate*) window; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle)) g_warning ("gdk_window_move_resize: AdjustWindowRectEx failed"); @@ -981,10 +917,10 @@ gdk_window_move_resize (GdkWindow *window, private->drawable.height = height; } GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n", - private->drawable.xwindow, + GDK_DRAWABLE_XID (window), rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top)); - if (!MoveWindow (private->drawable.xwindow, + if (!MoveWindow (GDK_DRAWABLE_XID (window), rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE)) @@ -1020,23 +956,26 @@ gdk_window_reparent (GdkWindow *window, g_return_if_fail (window != NULL); if (!new_parent) - new_parent = (GdkWindow*) gdk_root_parent; + new_parent = gdk_parent_root; window_private = (GdkWindowPrivate*) window; - old_parent_private = (GdkWindowPrivate*)window_private->parent; + old_parent_private = (GdkWindowPrivate *) window_private->parent; parent_private = (GdkWindowPrivate*) new_parent; - if (!window_private->drawable.destroyed && !parent_private->drawable.destroyed) + if (!GDK_DRAWABLE_DESTROYED (window) + && !GDK_DRAWABLE_DESTROYED (new_parent)) { GDK_NOTE (MISC, g_print ("gdk_window_reparent: %#x %#x\n", - window_private->drawable.xwindow, - parent_private->drawable.xwindow)); - if (!SetParent (window_private->drawable.xwindow, parent_private->drawable.xwindow)) + GDK_DRAWABLE_XID (window), + GDK_DRAWABLE_XID (new_parent))); + if (!SetParent (GDK_DRAWABLE_XID (window), + GDK_DRAWABLE_XID (new_parent))) g_warning ("gdk_window_reparent: SetParent failed"); - if (!MoveWindow (window_private->drawable.xwindow, + if (!MoveWindow (GDK_DRAWABLE_XID (window), x, y, - window_private->drawable.width, window_private->drawable.height, + window_private->drawable.width, + window_private->drawable.height, TRUE)) g_warning ("gdk_window_reparent: MoveWindow failed"); } @@ -1044,7 +983,8 @@ gdk_window_reparent (GdkWindow *window, window_private->parent = new_parent; if (old_parent_private) - old_parent_private->children = g_list_remove (old_parent_private->children, window); + old_parent_private->children = + g_list_remove (old_parent_private->children, window); if ((old_parent_private && (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) || @@ -1152,15 +1092,6 @@ gdk_window_lower (GdkWindow *window) } } -void -gdk_window_set_user_data (GdkWindow *window, - gpointer user_data) -{ - g_return_if_fail (window != NULL); - - window->user_data = user_data; -} - void gdk_window_set_hints (GdkWindow *window, gint x, @@ -1171,7 +1102,6 @@ gdk_window_set_hints (GdkWindow *window, gint max_height, gint flags) { - GdkWindowPrivate *private; WINDOWPLACEMENT size_hints; RECT rect; DWORD dwStyle; @@ -1184,20 +1114,18 @@ gdk_window_set_hints (GdkWindow *window, if (GDK_DRAWABLE_DESTROYED (window)) return; - private = (GdkWindowPrivate*) window; - GDK_NOTE (MISC, g_print ("gdk_window_set_hints: %#x %dx%d..%dx%d @+%d+%d\n", - private->drawable.xwindow, + GDK_DRAWABLE_XID (window), min_width, min_height, max_width, max_height, x, y)); - private->hint_flags = flags; + GDK_WINDOW_WIN32DATA (window)->hint_flags = flags; size_hints.length = sizeof (size_hints); if (flags) { if (flags & GDK_HINT_POS) - if (!GetWindowPlacement (private->drawable.xwindow, &size_hints)) + if (!GetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints)) g_warning ("gdk_window_set_hints: GetWindowPlacement failed"); else { @@ -1214,8 +1142,8 @@ gdk_window_set_hints (GdkWindow *window, rect.top = y; rect.right = rect.left + 200; /* dummy */ rect.bottom = rect.top + 200; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle); size_hints.flags = 0; size_hints.showCmd = SW_SHOWNA; @@ -1234,10 +1162,10 @@ gdk_window_set_hints (GdkWindow *window, size_hints.rcNormalPosition.top, size_hints.rcNormalPosition.right, size_hints.rcNormalPosition.bottom)); - if (!SetWindowPlacement (private->drawable.xwindow, &size_hints)) + if (!SetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints)) g_warning ("gdk_window_set_hints: SetWindowPlacement failed"); - private->hint_x = rect.left; - private->hint_y = rect.top; + GDK_WINDOW_WIN32DATA (window)->hint_x = rect.left; + GDK_WINDOW_WIN32DATA (window)->hint_y = rect.top; } if (flags & GDK_HINT_MIN_SIZE) @@ -1246,14 +1174,16 @@ gdk_window_set_hints (GdkWindow *window, rect.top = 0; rect.right = min_width; rect.bottom = min_height; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle); - private->hint_min_width = rect.right - rect.left; - private->hint_min_height = rect.bottom - rect.top; + GDK_WINDOW_WIN32DATA (window)->hint_min_width = + rect.right - rect.left; + GDK_WINDOW_WIN32DATA (window)->hint_min_height = + rect.bottom - rect.top; /* Also chek if he current size of the window is in bounds. */ - GetClientRect (private->drawable.xwindow, &rect); + GetClientRect (GDK_DRAWABLE_XID (window), &rect); if (rect.right < min_width && rect.bottom < min_height) gdk_window_resize (window, min_width, min_height); else if (rect.right < min_width) @@ -1261,19 +1191,22 @@ gdk_window_set_hints (GdkWindow *window, else if (rect.bottom < min_height) gdk_window_resize (window, rect.right, min_height); } + if (flags & GDK_HINT_MAX_SIZE) { rect.left = 0; rect.top = 0; rect.right = max_width; rect.bottom = max_height; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle); - private->hint_max_width = rect.right - rect.left; - private->hint_max_height = rect.bottom - rect.top; + GDK_WINDOW_WIN32DATA (window)->hint_max_width = + rect.right - rect.left; + GDK_WINDOW_WIN32DATA (window)->hint_max_height = + rect.bottom - rect.top; /* Again, check if the window is too large currently. */ - GetClientRect (private->drawable.xwindow, &rect); + GetClientRect (GDK_DRAWABLE_XID (window), &rect); if (rect.right > max_width && rect.bottom > max_height) gdk_window_resize (window, max_width, max_height); else if (rect.right > max_width) @@ -1289,7 +1222,6 @@ gdk_window_set_geometry_hints (GdkWindow *window, GdkGeometry *geometry, GdkWindowHints geom_mask) { - GdkWindowPrivate *private; WINDOWPLACEMENT size_hints; RECT rect; DWORD dwStyle; @@ -1302,11 +1234,9 @@ gdk_window_set_geometry_hints (GdkWindow *window, if (GDK_DRAWABLE_DESTROYED (window)) return; - private = (GdkWindowPrivate*) window; - size_hints.length = sizeof (size_hints); - private->hint_flags = geom_mask; + GDK_WINDOW_WIN32DATA (window)->hint_flags = geom_mask; if (geom_mask & GDK_HINT_POS) ; /* XXX */ @@ -1317,14 +1247,14 @@ gdk_window_set_geometry_hints (GdkWindow *window, rect.top = 0; rect.right = geometry->min_width; rect.bottom = geometry->min_height; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle); - private->hint_min_width = rect.right - rect.left; - private->hint_min_height = rect.bottom - rect.top; + GDK_WINDOW_WIN32DATA (window)->hint_min_width = rect.right - rect.left; + GDK_WINDOW_WIN32DATA (window)->hint_min_height = rect.bottom - rect.top; /* Also check if he current size of the window is in bounds */ - GetClientRect (private->drawable.xwindow, &rect); + GetClientRect (GDK_DRAWABLE_XID (window), &rect); if (rect.right < geometry->min_width && rect.bottom < geometry->min_height) gdk_window_resize (window, geometry->min_width, geometry->min_height); @@ -1340,14 +1270,14 @@ gdk_window_set_geometry_hints (GdkWindow *window, rect.top = 0; rect.right = geometry->max_width; rect.bottom = geometry->max_height; - dwStyle = GetWindowLong (private->drawable.xwindow, GWL_STYLE); - dwExStyle = GetWindowLong (private->drawable.xwindow, GWL_EXSTYLE); + dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); + dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE); AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle); - private->hint_max_width = rect.right - rect.left; - private->hint_max_height = rect.bottom - rect.top; + GDK_WINDOW_WIN32DATA (window)->hint_max_width = rect.right - rect.left; + GDK_WINDOW_WIN32DATA (window)->hint_max_height = rect.bottom - rect.top; /* Again, check if the window is too large currently. */ - GetClientRect (private->drawable.xwindow, &rect); + GetClientRect (GDK_DRAWABLE_XID (window), &rect); if (rect.right > geometry->max_width && rect.bottom > geometry->max_height) gdk_window_resize (window, geometry->max_width, geometry->max_height); @@ -1361,7 +1291,7 @@ gdk_window_set_geometry_hints (GdkWindow *window, if (geom_mask & GDK_HINT_BASE_SIZE && geometry->base_width > 0 && geometry->base_height > 0) - if (!GetWindowPlacement (private->drawable.xwindow, &size_hints)) + if (!GetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints)) g_warning ("gdk_window_set_hints: GetWindowPlacement failed"); else { @@ -1380,7 +1310,7 @@ gdk_window_set_geometry_hints (GdkWindow *window, size_hints.rcNormalPosition.top, size_hints.rcNormalPosition.right, size_hints.rcNormalPosition.bottom)); - if (!SetWindowPlacement (private->drawable.xwindow, &size_hints)) + if (!SetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints)) g_warning ("gdk_window_set_hints: SetWindowPlacement failed"); } @@ -1459,29 +1389,26 @@ void gdk_window_set_background (GdkWindow *window, GdkColor *color) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; if (!GDK_DRAWABLE_DESTROYED (window)) { GDK_NOTE (MISC, g_print ("gdk_window_set_background: %#x %s\n", - private->drawable.xwindow, + GDK_DRAWABLE_XID (window), gdk_color_to_string (color))); - if (private->bg_type == GDK_WIN32_BG_PIXMAP) + if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PIXMAP) { - if (private->bg_pixmap != NULL) + if (GDK_WINDOW_WIN32DATA (window)->bg_pixmap != NULL) { - gdk_pixmap_unref (private->bg_pixmap); - private->bg_pixmap = NULL; + gdk_drawable_unref (GDK_WINDOW_WIN32DATA (window)->bg_pixmap); + GDK_WINDOW_WIN32DATA (window)->bg_pixmap = NULL; } - private->bg_type = GDK_WIN32_BG_NORMAL; + GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_NORMAL; } - private->bg_type = GDK_WIN32_BG_PIXEL; - private->bg_pixel = *color; + GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_PIXEL; + GDK_WINDOW_WIN32DATA (window)->bg_pixel = *color; } } @@ -1490,27 +1417,24 @@ gdk_window_set_back_pixmap (GdkWindow *window, GdkPixmap *pixmap, gint parent_relative) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; - if (!GDK_DRAWABLE_DESTROYED (window)) { - if (private->bg_type == GDK_WIN32_BG_PIXMAP) + if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PIXMAP) { - if (private->bg_pixmap != NULL) + if (GDK_WINDOW_WIN32DATA (window)->bg_pixmap != NULL) { - gdk_pixmap_unref (private->bg_pixmap); - private->bg_pixmap = NULL; + gdk_drawable_unref (GDK_WINDOW_WIN32DATA (window)->bg_pixmap); + GDK_WINDOW_WIN32DATA (window)->bg_pixmap = NULL; } - private->bg_type = GDK_WIN32_BG_NORMAL; + GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_NORMAL; } if (parent_relative) { - private->bg_type = GDK_WIN32_BG_PARENT_RELATIVE; + GDK_WINDOW_WIN32DATA (window)->bg_type = + GDK_WIN32_BG_PARENT_RELATIVE; } else if (!pixmap) { @@ -1518,12 +1442,12 @@ gdk_window_set_back_pixmap (GdkWindow *window, } else { - /* We must cache the pixmap in the WindowPrivate and + /* We must cache the pixmap in the GdkWindowWin32Data and * paint it each time we get WM_ERASEBKGND */ - private->bg_type = GDK_WIN32_BG_PIXMAP; - private->bg_pixmap = pixmap; - gdk_pixmap_ref (pixmap); + GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_PIXMAP; + GDK_WINDOW_WIN32DATA (window)->bg_pixmap = pixmap; + gdk_drawable_ref (pixmap); } } } @@ -1532,14 +1456,12 @@ void gdk_window_set_cursor (GdkWindow *window, GdkCursor *cursor) { - GdkWindowPrivate *window_private; GdkCursorPrivate *cursor_private; HCURSOR xcursor; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - window_private = (GdkWindowPrivate*) window; cursor_private = (GdkCursorPrivate*) cursor; if (!GDK_DRAWABLE_DESTROYED (window)) @@ -1550,20 +1472,11 @@ gdk_window_set_cursor (GdkWindow *window, xcursor = cursor_private->xcursor; GDK_NOTE (MISC, g_print ("gdk_window_set_cursor: %#x %#x\n", - window_private->drawable.xwindow, xcursor)); - window_private->xcursor = xcursor; + GDK_DRAWABLE_XID (window), xcursor)); + GDK_WINDOW_WIN32DATA (window)->xcursor = xcursor; } } -void -gdk_window_get_user_data (GdkWindow *window, - gpointer *data) -{ - g_return_if_fail (window != NULL); - - *data = window->user_data; -} - void gdk_window_get_geometry (GdkWindow *window, gint *x, @@ -1575,7 +1488,7 @@ gdk_window_get_geometry (GdkWindow *window, g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); if (!window) - window = (GdkWindow*) gdk_root_parent; + window = gdk_parent_root; if (!GDK_DRAWABLE_DESTROYED (window)) { @@ -1597,24 +1510,6 @@ gdk_window_get_geometry (GdkWindow *window, } } -void -gdk_window_get_position (GdkWindow *window, - gint *x, - gint *y) -{ - GdkWindowPrivate *window_private; - - g_return_if_fail (window != NULL); - g_return_if_fail (GDK_IS_WINDOW (window)); - - window_private = (GdkWindowPrivate*) window; - - if (x) - *x = window_private->x; - if (y) - *y = window_private->y; -} - gint gdk_window_get_origin (GdkWindow *window, gint *x, @@ -1663,13 +1558,13 @@ gdk_window_get_root_origin (GdkWindow *window, gint *x, gint *y) { - GdkWindowPrivate *private; + GdkWindowPrivate *rover; POINT pt; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; + rover = (GdkWindowPrivate*) window; if (x) *x = 0; if (y) @@ -1677,14 +1572,14 @@ gdk_window_get_root_origin (GdkWindow *window, if (GDK_DRAWABLE_DESTROYED (window)) return; - while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) - private = (GdkWindowPrivate*) private->parent; - if (private->drawable.destroyed) + while (rover->parent && ((GdkWindowPrivate*) rover->parent)->parent) + rover = (GdkWindowPrivate *) rover->parent; + if (rover->drawable.destroyed) return; pt.x = 0; pt.y = 0; - ClientToScreen (private->drawable.xwindow, &pt); + ClientToScreen (GDK_DRAWABLE_XID (rover), &pt); if (x) *x = pt.x; if (y) @@ -1692,7 +1587,7 @@ gdk_window_get_root_origin (GdkWindow *window, GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %#x: (%#x) +%d+%d\n", GDK_DRAWABLE_XID (window), - private->drawable.xwindow, pt.x, pt.y)); + GDK_DRAWABLE_XID (rover), pt.x, pt.y)); } GdkWindow* @@ -1708,7 +1603,7 @@ gdk_window_get_pointer (GdkWindow *window, g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); if (!window) - window = (GdkWindow*) gdk_root_parent; + window = gdk_parent_root; return_val = NULL; GetCursorPos (&pointc); @@ -1772,7 +1667,7 @@ gdk_window_at_pointer (gint *win_x, if (hwnd == NULL) { - window = (GdkWindow *) gdk_root_parent; + window = gdk_parent_root; if (win_x) *win_x = pointc.x; if (win_y) @@ -1806,27 +1701,6 @@ gdk_window_at_pointer (gint *win_x, return window; } -GdkWindow* -gdk_window_get_parent (GdkWindow *window) -{ - g_return_val_if_fail (window != NULL, NULL); - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - - return ((GdkWindowPrivate*) window)->parent; -} - -GdkWindow* -gdk_window_get_toplevel (GdkWindow *window) -{ - g_return_val_if_fail (window != NULL, NULL); - g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - - while (GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_CHILD) - window = ((GdkWindowPrivate*) window)->parent; - - return window; -} - GList* gdk_window_get_children (GdkWindow *window) { @@ -1849,32 +1723,26 @@ gdk_window_get_children (GdkWindow *window) GdkEventMask gdk_window_get_events (GdkWindow *window) { - GdkWindowPrivate *private; - g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - private = (GdkWindowPrivate*) window; if (GDK_DRAWABLE_DESTROYED (window)) return 0; - return private->event_mask; + return GDK_WINDOW_WIN32DATA (window)->event_mask; } void gdk_window_set_events (GdkWindow *window, GdkEventMask event_mask) { - GdkWindowPrivate *private; - g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; if (GDK_DRAWABLE_DESTROYED (window)) return; - private->event_mask = event_mask; + GDK_WINDOW_WIN32DATA (window)->event_mask = event_mask; } void @@ -1899,19 +1767,17 @@ gdk_window_shape_combine_mask (GdkWindow *window, } else { - GdkDrawablePrivate *pixmap_private; HRGN hrgn; DWORD dwStyle; DWORD dwExStyle; RECT rect; /* Convert mask bitmap to region */ - pixmap_private = (GdkDrawablePrivate*) mask; - hrgn = BitmapToRegion (pixmap_private->xwindow); + hrgn = BitmapToRegion (GDK_DRAWABLE_XID (mask)); GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x %#x\n", GDK_DRAWABLE_XID (window), - pixmap_private->xwindow)); + GDK_DRAWABLE_XID (mask))); /* SetWindowRgn wants window (not client) coordinates */ dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE); @@ -1934,73 +1800,6 @@ gdk_window_shape_combine_mask (GdkWindow *window, } } -void -gdk_window_add_filter (GdkWindow *window, - GdkFilterFunc function, - gpointer data) -{ - GdkWindowPrivate *private; - GList *tmp_list; - GdkEventFilter *filter; - - g_return_if_fail (window != NULL); - g_return_if_fail (GDK_IS_WINDOW (window)); - - private = (GdkWindowPrivate*) window; - if (private && GDK_DRAWABLE_DESTROYED (window)) - return; - - tmp_list = private->filters; - - while (tmp_list) - { - filter = (GdkEventFilter *)tmp_list->data; - if ((filter->function == function) && (filter->data == data)) - return; - tmp_list = tmp_list->next; - } - - filter = g_new (GdkEventFilter, 1); - filter->function = function; - filter->data = data; - - private->filters = g_list_append (private->filters, filter); -} - -void -gdk_window_remove_filter (GdkWindow *window, - GdkFilterFunc function, - gpointer data) -{ - GdkWindowPrivate *private; - GList *tmp_list, *node; - GdkEventFilter *filter; - - g_return_if_fail (window != NULL); - g_return_if_fail (GDK_IS_WINDOW (window)); - - private = (GdkWindowPrivate*) window; - - tmp_list = private->filters; - - while (tmp_list) - { - filter = (GdkEventFilter *)tmp_list->data; - node = tmp_list; - tmp_list = tmp_list->next; - - if ((filter->function == function) && (filter->data == data)) - { - private->filters = g_list_remove_link (private->filters, node); - - g_list_free_1 (node); - g_free (filter); - - return; - } - } -} - void gdk_window_set_override_redirect (GdkWindow *window, gboolean override_redirect) @@ -2122,22 +1921,6 @@ gdk_window_set_functions (GdkWindow *window, SetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE, style); } -GList * -gdk_window_get_toplevels (void) -{ - GList *new_list = NULL; - GList *tmp_list; - - tmp_list = gdk_root_parent->children; - while (tmp_list) - { - new_list = g_list_prepend (new_list, tmp_list->data); - tmp_list = tmp_list->next; - } - - return new_list; -} - /* * propagate the shapes from all child windows of a GDK window to the parent * window. Shamelessly ripped from Enlightenment's code @@ -2240,59 +2023,6 @@ gdk_window_merge_child_shapes (GdkWindow *window) gdk_propagate_shapes (GDK_DRAWABLE_XID (window), TRUE); } -/************************************************************* - * gdk_window_is_visible: - * Check if the given window is mapped. - * arguments: - * window: - * results: - * is the window mapped - *************************************************************/ - -gboolean -gdk_window_is_visible (GdkWindow *window) -{ - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - - g_return_val_if_fail (window != NULL, FALSE); - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - - return private->mapped; -} - -/************************************************************* - * gdk_window_is_viewable: - * Check if the window and all ancestors of the window - * are mapped. (This is not necessarily "viewable" in - * the X sense, since we only check as far as we have - * GDK window parents, not to the root window) - * arguments: - * window: - * results: - * is the window viewable - *************************************************************/ - -gboolean -gdk_window_is_viewable (GdkWindow *window) -{ - GdkWindowPrivate *private = (GdkWindowPrivate *)window; - - g_return_val_if_fail (window != NULL, FALSE); - g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - - while (private && - (private != gdk_root_parent) && - (private->drawable.window_type != GDK_WINDOW_FOREIGN)) - { - if (!private->mapped) - return FALSE; - - private = (GdkWindowPrivate *)private->parent; - } - - return TRUE; -} - /* Support for windows that can be guffaw-scrolled * (See http://www.gtk.org/~otaylor/whitepapers/guffaw-scrolling.txt) */ diff --git a/gdk/win32/makefile.cygwin b/gdk/win32/makefile.cygwin index 3b71ee4bd9..f2399d7349 100644 --- a/gdk/win32/makefile.cygwin +++ b/gdk/win32/makefile.cygwin @@ -1,9 +1,5 @@ -## Makefile for building the GDK DLL with egcs on cygwin -## Use: make -f makefile.cygwin install - -# Change this to wherever you want to install the DLL. This directory -# should be in your PATH. -BIN = /bin +## Makefile for building the machine dependent part of GDK with gcc on cygwin +## Use: make -f makefile.cygwin # Location of the Wintab toolkit. Downloadable from http://www.pointing.com. # We use the wntab32x.lib archive library directly (copy it as libwntab32x.a). @@ -19,7 +15,6 @@ CC = gcc -mno-cygwin -mpentium -fnative-struct CP = cp LD = ld -INSTALL = install GLIB_VER=1.3 GTK_VER=1.3 @@ -29,10 +24,9 @@ CFLAGS = $(OPTIMIZE) -I . -I .. -I ../.. -I $(WTKIT)/include -I $(GLIB) -DG_ENAB all: \ ../../config.h \ - gdk-win32-$(GTK_VER).dll - -install : all - $(INSTALL) gdk-win32-$(GTK_VER).dll $(BIN) + libgdk-win32.a \ + gdk-win32res.o \ + libwntab32x.a gdk_win32_OBJECTS = \ gdkcolor-win32.o \ @@ -61,8 +55,9 @@ gdk_win32_OBJECTS = \ gdk-win32res.o : rc/gdk.rc windres --include-dir rc rc/gdk.rc gdk-win32res.o -gdk-win32-$(GTK_VER).dll : $(gdk_win32_OBJECTS) gdk-win32.def gdk-win32res.o libwntab32x.a - $(GLIB)/build-dll gdk-win32 $(GTK_VER) gdk-win32.def $(gdk_win32_OBJECTS) -L $(GLIB) -lglib-$(GLIB_VER) -L . -lwntab32x -lgdi32 -luser32 -limm32 -lshell32 -lole32 -luuid $(LDFLAGS) gdk-win32res.o +libgdk-win32.a : $(gdk_win32_OBJECTS) + -rm -f $@ + $(AR) rv $@ $(gdk_win32_OBJECTS) libwntab32x.a : $(WTKIT)/lib/i386/wntab32x.lib cp $(WTKIT)/lib/i386/wntab32x.lib libwntab32x.a