Include the build directory.

2000-07-25  Tor Lillqvist  <tml@iki.fi>

	* Makefile.am: Include the build directory.

	* configure.in: Generate build/Makefile and build/win32/Makefile.

	* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.

	* gdk/gdk.def
	* gtk/gtk.def: Updates.

	* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
	PANGOWIN32_LIBS and gdk_pixbuf.

	* gdk/win32: Compiles, but no doubt doesn't work at all.

	* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.

	* gdk/win32/gdkinput.c: New file, temporarily.

	* gdk/win32/gdkinput-win32.h: New file

	* gdk/win32/gdkinputprivate.h: Remove.

	* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
	made externally visible.
This commit is contained in:
Tor Lillqvist 2000-07-25 17:31:05 +00:00 committed by Tor Lillqvist
parent 37e809867e
commit 5ac61d3eee
37 changed files with 2641 additions and 2914 deletions

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,3 +1,30 @@
2000-07-25 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Include the build directory.
* configure.in: Generate build/Makefile and build/win32/Makefile.
* config.h.win32: Add USE_GMODULE and USE_MMX for gdk-pixbuf.
* gdk/gdk.def
* gtk/gtk.def: Updates.
* gdk/makefile.mingw.in: Define GDK_COMPILATION. Link with
PANGOWIN32_LIBS and gdk_pixbuf.
* gdk/win32: Compiles, but no doubt doesn't work at all.
* gdk/win32/makefile.mingw.in: Define GDK_COMPILATION.
* gdk/win32/gdkinput.c: New file, temporarily.
* gdk/win32/gdkinput-win32.h: New file
* gdk/win32/gdkinputprivate.h: Remove.
* gtk/gtkrc.[ch] (gtk_win32_get_installation_directory): Renamed and
made externally visible.
2000-07-24 Elliot Lee <sopwith@redhat.com>
* gdk/gdkprivate.h: Remove gdk_*_lookup() defines, since they are defined by the
individual backends already.
@ -33,12 +60,13 @@
* gdk/win32/gdkcolor-win32.c
* gdk/win32/gdkcursor-win32.c
* gdk/win32/gdkdrawable-win32.c
* gdk/win32/gdkgc-win32.c
* gdk/win32/gdkimage-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Update data structures. Cosmetics:
don't use fields and variables called xcursor, xid, etc (leftovers
from the X11 backend).
Rename fields and variables called xcursor, xid, etc (these names
were leftovers from the X11 backend) to hcursor, hwnd, hbitmap etc.
Sat Jul 22 17:41:26 2000 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,7 @@
## Makefile.am for GTK+
SRC_SUBDIRS = gdk-pixbuf gdk modules gtk demos
SUBDIRS = po $(SRC_SUBDIRS) docs
SUBDIRS = po $(SRC_SUBDIRS) docs build
bin_SCRIPTS = gtk-config-2.0

View File

@ -190,3 +190,8 @@
* (available in the Platform SDK)
*/
/* #define HAVE_DIMM_H 1 */
#define USE_GMODULE 1
#define USE_MMX 1
/* #undef HAVE_SIGSETJMP */

View File

@ -993,6 +993,8 @@ docs/gtk-config.1
Makefile
gtk-config-2.0
po/Makefile.in
build/Makefile
build/win32/Makefile
demos/Makefile
docs/Makefile
docs/reference/Makefile

View File

@ -46,6 +46,11 @@ EXPORTS
gdk_cursor_new_from_pixmap
gdk_cursor_ref
gdk_cursor_unref
gdk_device_set_axis_use
gdk_device_set_key
gdk_device_set_mode
gdk_device_set_source
gdk_devices_list
gdk_dnd_init
gdk_drag_abort
gdk_drag_begin
@ -70,13 +75,13 @@ EXPORTS
gdk_draw_polygon
gdk_draw_rectangle
gdk_draw_rgb_32_image
gdk_draw_rgb_32_image_dithalign
gdk_draw_rgb_image
gdk_draw_rgb_image_dithalign
gdk_draw_segments
gdk_draw_string
gdk_draw_text
gdk_draw_text_wc
gdk_drawable_alloc
gdk_drawable_get_colormap
gdk_drawable_get_size
gdk_drawable_get_type
@ -124,7 +129,6 @@ EXPORTS
gdk_fontset_load
gdk_free_compound_text
gdk_free_text_list
gdk_gc_alloc
gdk_gc_copy
gdk_gc_get_values
gdk_gc_new
@ -163,7 +167,6 @@ EXPORTS
gdk_im_end
gdk_im_ready
gdk_im_set_best_style
gdk_image_bitmap_new
gdk_image_get
gdk_image_get_pixel
gdk_image_new
@ -177,15 +180,9 @@ EXPORTS
gdk_input_add_full
gdk_input_exit
gdk_input_init
gdk_input_list_devices
gdk_input_motion_events
gdk_input_remove
gdk_input_set_axes
gdk_input_set_extension_events
gdk_input_set_key
gdk_input_set_mode
gdk_input_set_source
gdk_input_window_get_pointer
gdk_key_repeat_disable
gdk_key_repeat_restore
gdk_keyboard_grab
@ -205,7 +202,6 @@ EXPORTS
gdk_pixmap_create_from_data
gdk_pixmap_create_from_xpm
gdk_pixmap_create_from_xpm_d
gdk_pixmap_create_on_shared_image
gdk_pixmap_foreign_new
gdk_pixmap_new
gdk_pointer_grab
@ -236,10 +232,11 @@ EXPORTS
gdk_region_xor
gdk_rgb_cmap_free
gdk_rgb_cmap_new
gdk_rgb_colormap_ditherable
gdk_rgb_ditherable
gdk_rgb_gc_set_background
gdk_rgb_gc_set_foreground
gdk_rgb_get_cmap
gdk_rgb_get_colormap
gdk_rgb_get_visual
gdk_rgb_init
gdk_rgb_set_install
@ -285,6 +282,7 @@ EXPORTS
gdk_visual_ref
gdk_visual_unref
gdk_wcstombs
gdk_win32_handle_table_lookup
gdk_win32_hdc_get
gdk_win32_hdc_release
gdk_window_add_filter
@ -345,5 +343,3 @@ EXPORTS
gdk_window_shape_combine_mask
gdk_window_show
gdk_window_withdraw
gdk_xid_table_insert
gdk_xid_table_lookup

View File

@ -15,7 +15,7 @@ OPTIMIZE = -g
INCLUDES = -I . -I .. -I ../gdk-pixbuf
DEPCFLAGS = $(GLIB_CFLAGS) $(PANGO_CFLAGS)
DEFINES = -DG_ENABLE_DEBUG -DHAVE_CONFIG_H -DGDK_VERSION=\"$(GTK_VER)\"
DEFINES = -DG_ENABLE_DEBUG -DHAVE_CONFIG_H -DGDK_VERSION=\"$(GTK_VER)\" -DGDK_COMPILATION
all: \
../config.h \
@ -58,7 +58,7 @@ win32/gdk-win32res.o : FRC
cd win32 && $(MAKE) -f makefile.mingw gdk-win32res.o
gdk-win32-$(GTK_VER).dll : $(gdk_OBJECTS) gdk.def win32/libgdk-win32.a win32/gdk-win32res.o win32/libwntab32x.a
$(GLIB)/build-dll gdk-win32 $(GTK_VER) gdk.def $(gdk_OBJECTS) win32/gdk-win32.a win32/wntab32x.a $(GLIB_LIBS) -lgdi32 -luser32 -limm32 -lshell32 -lole32 -luuid $(LDFLAGS) win32/gdk-win32res.o
$(GLIB)/build-dll gdk-win32 $(GTK_VER) gdk.def $(gdk_OBJECTS) win32/libgdk-win32.a win32/libwntab32x.a -L ../gdk-pixbuf -lgdk_pixbuf-$(GTK_VER) $(GLIB_LIBS) $(PANGOWIN32_LIBS) -lgdi32 -luser32 -limm32 -lshell32 -lole32 -luuid $(LDFLAGS) win32/gdk-win32res.o
win32/libwntab32x.a : FRC
cd win32 && $(MAKE) -f makefile.mingw libwntab32x.a

View File

@ -34,8 +34,6 @@
#include "gdkcolor.h"
#include "gdkprivate-win32.h"
#define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
static void free_colormap (Colormap colormap);
static gint gdk_colormap_match_color (GdkColormap *cmap,

View File

@ -1113,7 +1113,7 @@ gdk_drag_find_window (GdkDragContext *context,
POINT pt;
GDK_NOTE (DND, g_print ("gdk_drag_find_window: %#x +%d+%d\n",
(drag_window ? GDK_DRAWABLE_XID (drag_window) : 0),
(drag_window ? GDK_WINDOW_HWND (drag_window) : 0),
x_root, y_root));
pt.x = x_root;
@ -1123,7 +1123,7 @@ gdk_drag_find_window (GdkDragContext *context,
*dest_window = NULL;
else
{
*dest_window = gdk_window_lookup (recipient);
*dest_window = gdk_win32_handle_table_lookup (recipient);
if (*dest_window)
gdk_drawable_ref (*dest_window);
*protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
@ -1225,7 +1225,7 @@ gdk_window_register_dnd (GdkWindow *window)
g_return_if_fail (window != NULL);
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n",
GDK_DRAWABLE_XID (window)));
GDK_WINDOW_HWND (window)));
/* We always claim to accept dropped files, but in fact we might not,
* of course. This function is called in such a way that it cannot know
@ -1244,7 +1244,7 @@ gdk_window_register_dnd (GdkWindow *window)
OTHER_API_FAILED ("CoLockObjectExternal");
else
{
hres = RegisterDragDrop (GDK_DRAWABLE_XID (window), &ctx->idt);
hres = RegisterDragDrop (GDK_WINDOW_HWND (window), &ctx->idt);
if (hres == DRAGDROP_E_ALREADYREGISTERED)
{
g_print ("DRAGDROP_E_ALREADYREGISTERED\n");

View File

@ -229,7 +229,7 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
(filled ? "fill " : ""),
width, height, x, y));
hdc = gdk_gc_predraw (drawable, gc_private, mask);
hdc = gdk_win32_hdc_get (drawable, gc, mask);
#if 0
{
@ -307,7 +307,7 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
SelectObject (hdc, oldbrush);
}
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -336,7 +336,7 @@ gdk_win32_draw_arc (GdkDrawable *drawable,
if (width <= 2 || height <= 2 || angle2 == 0)
return;
hdc = gdk_gc_predraw (drawable, gc_private, mask);
hdc = gdk_win32_hdc_get (drawable, gc, mask);
if (angle2 >= 360*64)
{
@ -380,7 +380,7 @@ gdk_win32_draw_arc (GdkDrawable *drawable,
nXStartArc, nYStartArc, nXEndArc, nYEndArc))
WIN32_GDI_FAILED ("Arc");
}
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -405,7 +405,7 @@ gdk_win32_draw_polygon (GdkDrawable *drawable,
if (npoints < 2)
return;
hdc = gdk_gc_predraw (drawable, gc_private, mask);
hdc = gdk_win32_hdc_get (drawable, gc, mask);
pts = g_new (POINT, npoints+1);
for (i = 0; i < npoints; i++)
@ -467,7 +467,7 @@ gdk_win32_draw_polygon (GdkDrawable *drawable,
}
}
g_free (pts);
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
typedef struct
@ -525,7 +525,7 @@ gdk_win32_draw_text (GdkDrawable *drawable,
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable, gc_private, mask);
arg.hdc = gdk_win32_hdc_get (drawable, gc, mask);
GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n",
GDK_DRAWABLE_HANDLE (drawable),
@ -550,7 +550,7 @@ gdk_win32_draw_text (GdkDrawable *drawable,
}
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -575,7 +575,7 @@ gdk_win32_draw_text_wc (GdkDrawable *drawable,
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable, gc_private, mask);
arg.hdc = gdk_win32_hdc_get (drawable, gc, mask);
GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n",
GDK_DRAWABLE_HANDLE (drawable),
@ -596,7 +596,7 @@ gdk_win32_draw_text_wc (GdkDrawable *drawable,
if (sizeof (wchar_t) != sizeof (GdkWChar))
g_free (wcstr);
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -626,13 +626,13 @@ gdk_win32_draw_drawable (GdkDrawable *drawable,
GDK_PIXMAP_HBITMAP (src),
width, height, xsrc, ysrc));
hdc = gdk_gc_predraw (drawable, gc_private, 0);
hdc = gdk_win32_hdc_get (drawable, gc, 0);
gdk_drawable_get_size (src, &src_width, &src_height);
src_rgn = CreateRectRgn (0, 0, src_width + 1, src_height + 1);
draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1);
if (!GDK_IS_PIXMAP (drawable))
if (GDK_IS_WINDOW (drawable))
{
/* If we are drawing on a window, calculate the region that is
* outside the source pixmap, and invalidate that, causing it to
@ -738,7 +738,7 @@ gdk_win32_draw_drawable (GdkDrawable *drawable,
WIN32_GDI_FAILED ("BitBlt");
ReleaseDC (GDK_WINDOW_HWND (src), srcdc);
}
gdk_gc_postdraw (drawable, gc_private, 0);
gdk_win32_hdc_release (drawable, gc, 0);
}
static void
@ -751,21 +751,19 @@ gdk_win32_draw_points (GdkDrawable *drawable,
COLORREF fg;
GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc);
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
GdkColormapPrivateWin32 *colormap_private =
(GdkColormapPrivateWin32 *) impl->colormap;
int i;
hdc = gdk_gc_predraw (drawable, gc_private, 0);
hdc = gdk_win32_hdc_get (drawable, gc, 0);
fg = gdk_colormap_color (colormap_private, gc_private->foreground);
fg = gdk_colormap_color (impl->colormap, gc_private->foreground);
GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x %dx%.06x\n",
GDK_DRAWABLE_XID (drawable), npoints, fg));
GDK_DRAWABLE_HANDLE (drawable), npoints, fg));
for (i = 0; i < npoints; i++)
SetPixel (hdc, points[i].x, points[i].y, fg);
gdk_gc_postdraw (drawable, gc_private, 0);
gdk_win32_hdc_release (drawable, gc, 0);
}
static void
@ -784,7 +782,7 @@ gdk_win32_draw_segments (GdkDrawable *drawable,
GDK_NOTE (MISC, g_print ("gdk_win32_draw_segments: %#x nsegs: %d\n",
GDK_DRAWABLE_HANDLE (drawable), nsegs));
hdc = gdk_gc_predraw (drawable, gc_private, mask);
hdc = gdk_win32_hdc_get (drawable, gc, mask);
if (gc_private->fill_style == GDK_OPAQUE_STIPPLED)
{
@ -832,7 +830,7 @@ gdk_win32_draw_segments (GdkDrawable *drawable,
WIN32_GDI_FAILED ("LineTo"), ok = FALSE;
}
}
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -851,7 +849,7 @@ gdk_win32_draw_lines (GdkDrawable *drawable,
if (npoints < 2)
return;
hdc = gdk_gc_predraw (drawable, gc_private, mask);
hdc = gdk_win32_hdc_get (drawable, gc, mask);
pts = g_new (POINT, npoints);
@ -873,7 +871,7 @@ gdk_win32_draw_lines (GdkDrawable *drawable,
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
WIN32_GDI_FAILED ("LineTo");
}
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -889,11 +887,11 @@ gdk_win32_draw_glyphs (GdkDrawable *drawable,
const GdkGCValuesMask mask = GDK_GC_FOREGROUND;
HDC hdc;
hdc = gdk_gc_predraw (drawable, gc_private, mask);
hdc = gdk_win32_hdc_get (drawable, gc, mask);
pango_win32_render (hdc, font, glyphs, x, y);
gdk_gc_postdraw (drawable, gc_private, mask);
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
@ -922,7 +920,7 @@ gdk_win32_draw_image (GdkDrawable *drawable,
gboolean ok = TRUE;
int i;
hdc = gdk_gc_predraw (drawable, gc_private, 0);
hdc = gdk_win32_hdc_get (drawable, gc, 0);
if (colormap_private && colormap_private->xcolormap->rc_palette)
{
@ -978,7 +976,7 @@ gdk_win32_draw_image (GdkDrawable *drawable,
if (memdc != NULL && !DeleteDC (memdc))
WIN32_GDI_FAILED ("DeleteDC");
}
gdk_gc_postdraw (drawable, gc_private, 0);
gdk_win32_hdc_release (drawable, gc, 0);
}
static gint

View File

@ -38,16 +38,7 @@
#include <stdio.h>
#include "gdk.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
#include "gdkpixmap-win32.h"
#include "gdkkeysyms.h"
#include "gdkinputprivate.h"
#include <objbase.h>
#include <imm.h>
@ -58,9 +49,14 @@
#include "surrogate-dimm.h"
#endif
#ifdef HAVE_WINTAB
#include <wintab.h>
#endif
#include "gdk.h"
#include "gdkinternals.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
#include "gdkpixmap-win32.h"
#include "gdkinput-win32.h"
#include "gdkkeysyms.h"
#define PING() printf("%s: %d\n",__FILE__,__LINE__),fflush(stdout)
@ -330,7 +326,7 @@ gdk_events_init (void)
if (track_mouse_event != NULL)
GDK_NOTE (EVENTS, g_print ("Using TrackMouseEvent to detect leave events\n"));
#endif
if (IS_WIN_NT (windows_version) && (windows_version & 0xFF) == 5)
if (IS_WIN_NT () && (windows_version & 0xFF) == 5)
{
/* On Win2k (Beta 3, at least) WM_IME_CHAR doesn't seem to work
* correctly for non-Unicode applications. Handle
@ -488,7 +484,7 @@ gdk_pointer_grab (GdkWindow *window,
cursor_private = (GdkCursorPrivate*) cursor;
if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to))
if (!confine_to || GDK_WINDOW_DESTROYED (confine_to))
hwnd_confined_to = NULL;
else
hwnd_confined_to = GDK_WINDOW_HWND (confine_to);
@ -498,35 +494,32 @@ gdk_pointer_grab (GdkWindow *window,
else
hcursor = cursor_private->hcursor;
if (gdk_input_vtable.grab_pointer)
return_val = gdk_input_vtable.grab_pointer (window,
owner_events,
event_mask,
confine_to,
time);
else
return_val = GDK_GRAB_SUCCESS;
return_val = _gdk_input_grab_pointer (window,
owner_events,
event_mask,
confine_to,
time);
if (return_val == GDK_GRAB_SUCCESS)
{
if (!GDK_DRAWABLE_DESTROYED (window))
{
GDK_NOTE (EVENTS, g_print ("gdk_pointer_grab: %#x %s %#x %s\n",
GDK_WINDOW_HWND (window),
(owner_events ? "TRUE" : "FALSE"),
hcursor,
event_mask_string (event_mask)));
p_grab_mask = event_mask;
p_grab_owner_events = (owner_events != 0);
p_grab_automatic = FALSE;
if (!GDK_WINDOW_DESTROYED (window))
{
GDK_NOTE (EVENTS, g_print ("gdk_pointer_grab: %#x %s %#x %s\n",
GDK_WINDOW_HWND (window),
(owner_events ? "TRUE" : "FALSE"),
hcursor,
event_mask_string (event_mask)));
p_grab_mask = event_mask;
p_grab_owner_events = (owner_events != 0);
p_grab_automatic = FALSE;
#if 1 /* Menus don't work if we use mouse capture. Pity, because many other
* things work better with mouse capture.
*/
SetCapture (GDK_WINDOW_HWND (window));
SetCapture (GDK_WINDOW_HWND (window));
#endif
return_val = GDK_GRAB_SUCCESS;
}
return_val = GDK_GRAB_SUCCESS;
}
else
return_val = GDK_GRAB_ALREADY_GRABBED;
}
@ -558,13 +551,14 @@ gdk_pointer_grab (GdkWindow *window,
void
gdk_pointer_ungrab (guint32 time)
{
if (gdk_input_vtable.ungrab_pointer)
gdk_input_vtable.ungrab_pointer (time);
GDK_NOTE (EVENTS, g_print ("gdk_pointer_ungrab\n"));
_gdk_input_ungrab_pointer (time);
#if 1
if (GetCapture () != NULL)
ReleaseCapture ();
#endif
GDK_NOTE (EVENTS, g_print ("gdk_pointer_ungrab\n"));
p_grab_window = NULL;
}
@ -623,7 +617,7 @@ gdk_keyboard_grab (GdkWindow *window,
GDK_NOTE (EVENTS, g_print ("gdk_keyboard_grab %#x\n",
GDK_WINDOW_HWND (window)));
if (!GDK_DRAWABLE_DESTROYED (window))
if (!GDK_WINDOW_DESTROYED (window))
{
k_grab_owner_events = owner_events != 0;
return_val = GDK_GRAB_SUCCESS;
@ -1151,10 +1145,8 @@ synthesize_crossing_events (GdkWindow *window,
GDK_NOTE (EVENTS, print_event (event));
if (GDK_WINDOW_OBJECT (window)->extension_events != 0
&& gdk_input_vtable.enter_event)
gdk_input_vtable.enter_event (&event->crossing, window);
if (GDK_WINDOW_OBJECT (window)->extension_events != 0)
_gdk_input_enter_event (&event->crossing, window);
}
if (current_window)
@ -1366,13 +1358,25 @@ gdk_event_translate (GdkEvent *event,
MINMAXINFO *mmi;
HWND hwnd;
HCURSOR hcursor;
GdkWindow *window, *orig_window, *newwindow;
/* Invariant:
* window_impl == GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)
*/
GdkWindow *window;
GdkWindowImplWin32 *window_impl;
#define ASSIGN_WINDOW(rhs) \
(window = rhs, \
window_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl))
GdkWindow *orig_window, *new_window;
GdkColormapPrivateWin32 *colormap_private;
GdkEventMask mask;
GdkPixmap *pixmap;
GdkPixmapImplWin32 *pixmap_impl;
int button;
int i, j, n, k;
gchar buf[256];
gchar *msgname;
gboolean return_val;
@ -1383,7 +1387,7 @@ gdk_event_translate (GdkEvent *event,
if (ret_val_flagp)
*ret_val_flagp = FALSE;
window = gdk_window_lookup (msg->hwnd);
ASSIGN_WINDOW (gdk_win32_handle_table_lookup (msg->hwnd));
orig_window = window;
event->any.window = window;
@ -1419,7 +1423,7 @@ gdk_event_translate (GdkEvent *event,
return FALSE;
}
if (!GDK_DRAWABLE_DESTROYED (window))
if (!GDK_WINDOW_DESTROYED (window))
{
/* Check for filters for this window */
GdkFilterReturn result;
@ -1446,7 +1450,7 @@ gdk_event_translate (GdkEvent *event,
event->selection.property = gdk_selection_property;
event->selection.time = msg->time;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
/* Will pass through switch below without match */
}
@ -1463,7 +1467,7 @@ gdk_event_translate (GdkEvent *event,
event->selection.requestor = (guint32) msg->hwnd;
event->selection.time = msg->time;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
/* Again, will pass through switch below without match */
}
@ -1477,7 +1481,7 @@ gdk_event_translate (GdkEvent *event,
event->selection.selection = msg->wParam;
event->selection.time = msg->time;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
/* Once again, we will pass through switch below without match */
}
@ -1527,9 +1531,9 @@ gdk_event_translate (GdkEvent *event,
GDK_NOTE (EVENTS,
g_print ("WM_INPUTLANGCHANGE: %#x charset %d locale %x\n",
msg->hwnd, msg->wParam, msg->lParam));
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->input_locale = (HKL) msg->lParam;
window_impl->input_locale = (HKL) msg->lParam;
TranslateCharsetInfo ((DWORD FAR *) msg->wParam,
&GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->charset_info,
&window_impl->charset_info,
TCI_SRCCHARSET);
break;
@ -1788,6 +1792,7 @@ gdk_event_translate (GdkEvent *event,
k_grab_window, k_grab_owner_events, GDK_ALL_EVENTS_MASK,
doesnt_want_key))
break;
ASSIGN_WINDOW (window);
is_altgr_key = FALSE;
event->key.type = ((msg->message == WM_KEYDOWN
@ -1805,7 +1810,7 @@ gdk_event_translate (GdkEvent *event,
event->key.state |= GDK_MOD1_MASK;
event->key.string = NULL;
event->key.length = 0;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
case WM_IME_COMPOSITION:
@ -1844,33 +1849,36 @@ gdk_event_translate (GdkEvent *event,
k_grab_window, k_grab_owner_events, GDK_ALL_EVENTS_MASK,
doesnt_want_char))
break;
ASSIGN_WINDOW (window);
event->key.window = window;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
if (return_val && (event->key.window == k_grab_window
|| (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_KEY_RELEASE_MASK)))
|| (window_impl->event_mask & GDK_KEY_RELEASE_MASK)))
{
if (window == k_grab_window
|| (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_KEY_PRESS_MASK))
|| (window_impl->event_mask & GDK_KEY_PRESS_MASK))
{
/* Append a GDK_KEY_PRESS event to the pushback list
* (from which it will be fetched before the release
* event).
*/
GdkEvent *event2 = gdk_event_new ();
build_keypress_event (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl), event2, msg);
build_keypress_event (window_impl, event2, msg);
event2->key.window = window;
gdk_drawable_ref (window);
gdk_event_queue_append (event2);
GDK_NOTE (EVENTS, print_event (event2));
}
/* Return the key release event. */
build_keyrelease_event (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl), event, msg);
build_keyrelease_event (window_impl, event, msg);
}
else if (return_val
&& (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_KEY_PRESS_MASK))
&& (window_impl->event_mask & GDK_KEY_PRESS_MASK))
{
/* Return just the key press event. */
build_keypress_event (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl), event, msg);
build_keypress_event (window_impl, event, msg);
}
else
return_val = FALSE;
@ -1914,19 +1922,21 @@ gdk_event_translate (GdkEvent *event,
p_grab_window, p_grab_owner_events, p_grab_mask,
doesnt_want_button_press))
break;
ASSIGN_WINDOW (window);
event->button.window = window;
/* Emulate X11's automatic active grab */
if (!p_grab_window)
{
/* No explicit active grab, let's start one automatically */
gint owner_events =
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask
gint owner_events = window_impl->event_mask
& (GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
GDK_NOTE (EVENTS, g_print ("...automatic grab started\n"));
gdk_pointer_grab (window,
owner_events,
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask,
window_impl->event_mask,
NULL, NULL, 0);
p_grab_automatic = TRUE;
}
@ -1945,7 +1955,7 @@ gdk_event_translate (GdkEvent *event,
gdk_event_button_generate (event);
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
case WM_LBUTTONUP:
@ -1979,6 +1989,8 @@ gdk_event_translate (GdkEvent *event,
p_grab_window, p_grab_owner_events, p_grab_mask,
doesnt_want_button_release))
goto maybe_ungrab;
ASSIGN_WINDOW (window);
event->button.window = window;
event->button.time = msg->time;
if (window != orig_window)
@ -1992,7 +2004,7 @@ gdk_event_translate (GdkEvent *event,
event->button.button = button;
event->button.device = gdk_core_pointer;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
maybe_ungrab:
if (p_grab_window != NULL
@ -2037,6 +2049,8 @@ gdk_event_translate (GdkEvent *event,
p_grab_window, p_grab_owner_events, p_grab_mask,
doesnt_want_button_motion))
break;
ASSIGN_WINDOW (window);
event->motion.window = window;
event->motion.time = msg->time;
if (window != orig_window)
@ -2050,7 +2064,7 @@ gdk_event_translate (GdkEvent *event,
event->motion.is_hint = FALSE;
event->motion.device = gdk_core_pointer;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
case WM_NCMOUSEMOVE:
@ -2110,12 +2124,12 @@ gdk_event_translate (GdkEvent *event,
if ((hwnd = WindowFromPoint (pt)) == NULL)
break;
msg->hwnd = hwnd;
if ((newwindow = gdk_window_lookup (msg->hwnd)) == NULL)
if ((new_window = gdk_win32_handle_table_lookup (msg->hwnd)) == NULL)
break;
if (newwindow != window)
if (new_window != window)
{
gdk_drawable_unref (window);
window = newwindow;
ASSIGN_WINDOW (new_window);
gdk_drawable_ref (window);
}
ScreenToClient (msg->hwnd, &pt);
@ -2123,6 +2137,8 @@ gdk_event_translate (GdkEvent *event,
p_grab_window, p_grab_owner_events, p_grab_mask,
doesnt_want_scroll))
break;
ASSIGN_WINDOW (window);
event->button.window = window;
event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
GDK_SCROLL_UP : GDK_SCROLL_DOWN;
@ -2134,7 +2150,7 @@ gdk_event_translate (GdkEvent *event,
event->scroll.y_root = (gint16) LOWORD (msg->lParam);
event->scroll.state = build_pointer_event_state (msg);
event->scroll.device = gdk_core_pointer;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
@ -2142,7 +2158,7 @@ gdk_event_translate (GdkEvent *event,
case WM_MOUSELEAVE:
GDK_NOTE (EVENTS, g_print ("WM_MOUSELEAVE: %#x\n", msg->hwnd));
if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_LEAVE_NOTIFY_MASK))
if (!(window_impl->event_mask & GDK_LEAVE_NOTIFY_MASK))
break;
event->crossing.type = GDK_LEAVE_NOTIFY;
@ -2172,7 +2188,7 @@ gdk_event_translate (GdkEvent *event,
current_window = NULL;
}
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
#endif
@ -2183,20 +2199,20 @@ gdk_event_translate (GdkEvent *event,
"SET" : "KILL"),
msg->hwnd));
if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_FOCUS_CHANGE_MASK))
if (!(window_impl->event_mask & GDK_FOCUS_CHANGE_MASK))
break;
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = (msg->message == WM_SETFOCUS);
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
case WM_ERASEBKGND:
GDK_NOTE (EVENTS, g_print ("WM_ERASEBKGND: %#x dc %#x\n",
msg->hwnd, msg->wParam));
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_WINDOW_DESTROYED (window))
break;
colormap_private = (GdkColormapPrivateWin32 *) GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap;
@ -2218,27 +2234,27 @@ gdk_event_translate (GdkEvent *event,
*ret_val_flagp = TRUE;
*ret_valp = 1;
if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_TRANSPARENT)
if (GDK_WINDOW_OBJECT (window)->input_only)
break;
if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE)
if (GDK_WINDOW_OBJECT (window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
{
/* If this window should have the same background as the
* parent, fetch the parent. (And if the same goes for
* the parent, fetch the grandparent, etc.)
*/
while (window && GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE)
while (window && GDK_WINDOW_OBJECT (window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
{
gdk_drawable_unref (window);
window = GDK_WINDOW (GDK_WINDOW_OBJECT (window)->parent);
ASSIGN_WINDOW (GDK_WINDOW (GDK_WINDOW_OBJECT (window)->parent));
gdk_drawable_ref (window);
}
}
if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PIXEL)
if (GDK_WINDOW_OBJECT (window)->bg_pixmap == NULL)
{
bg = gdk_colormap_color (colormap_private,
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_pixel);
bg = gdk_colormap_color (GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap,
GDK_WINDOW_OBJECT (window)->bg_color.pixel);
GetClipBox (hdc, &rect);
GDK_NOTE (EVENTS,
@ -2255,9 +2271,10 @@ gdk_event_translate (GdkEvent *event,
WIN32_GDI_FAILED ("FillRect");
DeleteObject (hbr);
}
else if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PIXMAP)
else if (GDK_WINDOW_OBJECT (window)->bg_pixmap != NULL &&
GDK_WINDOW_OBJECT (window)->bg_pixmap != GDK_NO_BG)
{
pixmap = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_pixmap;
pixmap = GDK_WINDOW_OBJECT (window)->bg_pixmap;
pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (pixmap);
GetClipBox (hdc, &rect);
@ -2348,7 +2365,7 @@ gdk_event_translate (GdkEvent *event,
EndPaint (msg->hwnd, &paintstruct);
if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_EXPOSURE_MASK))
if (!(window_impl->event_mask & GDK_EXPOSURE_MASK))
break;
if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left)
@ -2363,7 +2380,7 @@ gdk_event_translate (GdkEvent *event,
event->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
event->expose.count = 0;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
if (return_val)
{
GList *list = gdk_queued_events;
@ -2389,8 +2406,8 @@ gdk_event_translate (GdkEvent *event,
if (p_grab_window != NULL && p_grab_cursor != NULL)
hcursor = p_grab_cursor;
else if (!GDK_DRAWABLE_DESTROYED (window))
hcursor = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hcursor;
else if (!GDK_WINDOW_DESTROYED (window))
hcursor = window_impl->hcursor;
else
hcursor = NULL;
@ -2408,7 +2425,7 @@ gdk_event_translate (GdkEvent *event,
msg->hwnd,
msg->wParam));
if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_STRUCTURE_MASK))
if (!(window_impl->event_mask & GDK_STRUCTURE_MASK))
break;
event->any.type = (msg->wParam ? GDK_MAP : GDK_UNMAP);
@ -2422,7 +2439,7 @@ gdk_event_translate (GdkEvent *event,
&& k_grab_window == window)
gdk_keyboard_ungrab (msg->time);
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
case WM_SIZE:
@ -2436,7 +2453,7 @@ gdk_event_translate (GdkEvent *event,
(msg->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))),
LOWORD (msg->lParam), HIWORD (msg->lParam)));
if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_STRUCTURE_MASK))
if (!(window_impl->event_mask & GDK_STRUCTURE_MASK))
break;
if (msg->wParam == SIZE_MINIMIZED)
@ -2450,12 +2467,12 @@ gdk_event_translate (GdkEvent *event,
if (k_grab_window == window)
gdk_keyboard_ungrab (msg->time);
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
}
else if ((msg->wParam == SIZE_RESTORED
|| msg->wParam == SIZE_MAXIMIZED)
#if 1
&& GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD
&& GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD
#endif
)
{
@ -2473,17 +2490,16 @@ gdk_event_translate (GdkEvent *event,
event->configure.height = HIWORD (msg->lParam);
GDK_WINDOW_OBJECT (window)->x = event->configure.x;
GDK_WINDOW_OBJECT (window)->y = event->configure.y;
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->width = event->configure.width;
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->height = event->configure.height;
window_impl->width = event->configure.width;
window_impl->height = event->configure.height;
if (GDK_WINDOW_OBJECT (window)->resize_count > 1)
GDK_WINDOW_OBJECT (window)->resize_count -= 1;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
if (return_val
&& GDK_WINDOW_OBJECT (window)->extension_events != 0
&& gdk_input_vtable.configure_event)
gdk_input_vtable.configure_event (&event->configure, window);
&& GDK_WINDOW_OBJECT (window)->extension_events != 0)
_gdk_input_configure_event (&event->configure, window);
}
break;
@ -2491,18 +2507,18 @@ gdk_event_translate (GdkEvent *event,
GDK_NOTE (EVENTS, g_print ("WM_GETMINMAXINFO: %#x\n", msg->hwnd));
mmi = (MINMAXINFO*) msg->lParam;
if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_flags & GDK_HINT_MIN_SIZE)
if (window_impl->hint_flags & GDK_HINT_MIN_SIZE)
{
mmi->ptMinTrackSize.x = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_min_width;
mmi->ptMinTrackSize.y = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_min_height;
mmi->ptMinTrackSize.x = window_impl->hint_min_width;
mmi->ptMinTrackSize.y = window_impl->hint_min_height;
}
if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_flags & GDK_HINT_MAX_SIZE)
if (window_impl->hint_flags & GDK_HINT_MAX_SIZE)
{
mmi->ptMaxTrackSize.x = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_width;
mmi->ptMaxTrackSize.y = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_height;
mmi->ptMaxTrackSize.x = window_impl->hint_max_width;
mmi->ptMaxTrackSize.y = window_impl->hint_max_height;
mmi->ptMaxSize.x = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_width;
mmi->ptMaxSize.y = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_height;
mmi->ptMaxSize.x = window_impl->hint_max_width;
mmi->ptMaxSize.y = window_impl->hint_max_height;
}
break;
@ -2511,10 +2527,10 @@ gdk_event_translate (GdkEvent *event,
msg->hwnd,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_STRUCTURE_MASK))
if (!(window_impl->event_mask & GDK_STRUCTURE_MASK))
break;
if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD
&& !IsIconic(msg->hwnd)
&& IsWindowVisible(msg->hwnd))
{
@ -2527,10 +2543,10 @@ gdk_event_translate (GdkEvent *event,
event->configure.height = rect.bottom;
GDK_WINDOW_OBJECT (window)->x = event->configure.x;
GDK_WINDOW_OBJECT (window)->y = event->configure.y;
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->width = event->configure.width;
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->height = event->configure.height;
window_impl->width = event->configure.width;
window_impl->height = event->configure.height;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
}
break;
@ -2540,7 +2556,7 @@ gdk_event_translate (GdkEvent *event,
event->any.type = GDK_DELETE;
event->any.window = window;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
break;
#if 0
@ -2582,7 +2598,7 @@ gdk_event_translate (GdkEvent *event,
event->selection.property = gdk_selection_property;
event->selection.requestor = (guint32) msg->hwnd;
event->selection.time = msg->time;
return_val = !GDK_DRAWABLE_DESTROYED (window);
return_val = !GDK_WINDOW_DESTROYED (window);
#else
/* Test code, to see if SetClipboardData works when called from
* the window procedure.
@ -2619,7 +2635,7 @@ gdk_event_translate (GdkEvent *event,
if (k_grab_window == window)
gdk_keyboard_ungrab (msg->time);
return_val = window != NULL && !GDK_DRAWABLE_DESTROYED (window);
return_val = window != NULL && !GDK_WINDOW_DESTROYED (window);
if (window != NULL)
gdk_window_destroy_notify (window);
@ -2651,7 +2667,7 @@ gdk_event_translate (GdkEvent *event,
/* Fall through */
wintab:
event->any.window = window;
return_val = gdk_input_vtable.other_event(event, msg);
return_val = _gdk_input_other_event(event, msg, window);
break;
#endif

View File

@ -34,6 +34,9 @@
#include "gdkregion-generic.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
#include "gdkpixmap-win32.h"
static void gdk_win32_gc_destroy (GdkGC *gc);
static void gdk_win32_gc_get_values (GdkGC *gc,
@ -257,7 +260,7 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
gdk_drawable_ref (win32_gc->tile);
win32_gc->values_mask |= GDK_GC_TILE;
GDK_NOTE (MISC, (g_print ("%stile=%#x", s,
GDK_DRAWABLE_XID (win32_gc->tile)),
GDK_PIXMAP_HBITMAP (win32_gc->tile)),
s = ","));
}
else
@ -307,7 +310,7 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
gdk_drawable_ref (win32_gc->stipple);
win32_gc->values_mask |= GDK_GC_STIPPLE;
GDK_NOTE (MISC, (g_print ("%sstipple=%#x", s,
GDK_DRAWABLE_XID (win32_gc->stipple)),
GDK_PIXMAP_HBITMAP (win32_gc->stipple)),
s = ","));
}
else
@ -331,7 +334,7 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
if (values->clip_mask != NULL)
{
win32_gc->hcliprgn =
BitmapToRegion ((HBITMAP) GDK_DRAWABLE_XID (values->clip_mask));
BitmapToRegion ((HBITMAP) GDK_PIXMAP_HBITMAP (values->clip_mask));
win32_gc->values_mask |= GDK_GC_CLIP_MASK;
OffsetRgn (win32_gc->hcliprgn,
win32_gc->parent_instance.clip_x_origin,
@ -636,7 +639,7 @@ gdk_win32_gc_set_dashes (GdkGC *gc,
* More workarounds for Win9x descibed at:
* http://www.codeguru.com/gdi/dashed.shtml
*/
if (!IS_WIN_NT (windows_version) && win32_gc->pen_width > 1)
if (!IS_WIN_NT () && win32_gc->pen_width > 1)
{
GDK_NOTE (MISC, g_print ("gdk_win32_gc_set_dashes: not fully supported\n"));
win32_gc->pen_style |= PS_SOLID;
@ -755,8 +758,8 @@ void
gdk_gc_copy (GdkGC *dst_gc,
GdkGC *src_gc)
{
GdkGCWin32 *dst_data;
GdkGCWin32 *src_data;
GdkGCWin32 *dst_win32_gc;
GdkGCWin32 *src_win32_gc;
DWORD nbytes;
LPRGNDATA rgn;
@ -790,39 +793,45 @@ gdk_gc_copy (GdkGC *dst_gc,
static guint bitmask[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
COLORREF
gdk_colormap_color (GdkColormapPrivateWin32 *colormap_private,
gulong pixel)
gdk_colormap_color (GdkColormap *colormap,
gulong pixel)
{
GdkVisual *visual;
const GdkVisual *visual;
GdkColormapPrivateWin32 *colormap_private;
guchar r, g, b;
if (colormap_private == NULL || colormap_private->xcolormap->rc_palette)
if (colormap == NULL)
return PALETTEINDEX (pixel);
else
{
visual = colormap_private->base.visual;
r = (pixel & visual->red_mask) >> visual->red_shift;
r = (r * 255) / bitmask[visual->red_prec];
g = (pixel & visual->green_mask) >> visual->green_shift;
g = (g * 255) / bitmask[visual->green_prec];
b = (pixel & visual->blue_mask) >> visual->blue_shift;
b = (b * 255) / bitmask[visual->blue_prec];
return RGB (r, g, b);
}
colormap_private = GDK_COLORMAP_PRIVATE_DATA (colormap);
if (colormap_private->xcolormap->rc_palette)
return PALETTEINDEX (pixel);
visual = colormap->visual;
r = (pixel & visual->red_mask) >> visual->red_shift;
r = (r * 255) / bitmask[visual->red_prec];
g = (pixel & visual->green_mask) >> visual->green_shift;
g = (g * 255) / bitmask[visual->green_prec];
b = (pixel & visual->blue_mask) >> visual->blue_shift;
b = (b * 255) / bitmask[visual->blue_prec];
return RGB (r, g, b);
}
static void
predraw_set_foreground (GdkGCWin32 *gc_win32,
GdkColormapPrivateWin32 *colormap_private,
gboolean *ok)
predraw_set_foreground (GdkGC *gc,
GdkColormap *colormap,
gboolean *ok)
{
GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
GdkColormapPrivateWin32 *colormap_private;
COLORREF fg;
LOGBRUSH logbrush;
HPEN hpen;
HBRUSH hbr;
if (colormap_private == NULL)
if (colormap == NULL)
{
/* A 1 bit deep bitmap */
struct
@ -853,25 +862,29 @@ predraw_set_foreground (GdkGCWin32 *gc_win32,
RealizePalette (win32_gc->hdc);
fg = PALETTEINDEX (win32_gc->foreground);
}
else if (colormap_private->xcolormap->rc_palette)
else
{
int k;
if (SelectPalette (win32_gc->hdc, colormap_private->xcolormap->palette,
FALSE) == NULL)
WIN32_GDI_FAILED ("SelectPalette"), *ok = FALSE;
if (TRUE || colormap_private->xcolormap->stale)
colormap_private = GDK_COLORMAP_PRIVATE_DATA (colormap);
if (colormap_private->xcolormap->rc_palette)
{
if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR)
WIN32_GDI_FAILED ("RealizePalette"), *ok = FALSE;
colormap_private->xcolormap->stale = FALSE;
}
int k;
if (SelectPalette (win32_gc->hdc, colormap_private->xcolormap->palette,
FALSE) == NULL)
WIN32_GDI_FAILED ("SelectPalette"), *ok = FALSE;
if (TRUE || colormap_private->xcolormap->stale)
{
if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR)
WIN32_GDI_FAILED ("RealizePalette"), *ok = FALSE;
colormap_private->xcolormap->stale = FALSE;
}
#if 0
g_print ("Selected palette %#x for gc %#x, realized %d colors\n",
colormap_private->xcolormap->palette, win32_gc->hdc, k);
g_print ("Selected palette %#x for gc %#x, realized %d colors\n",
colormap_private->xcolormap->palette, win32_gc->hdc, k);
#endif
}
}
fg = gdk_colormap_color (colormap_private, win32_gc->foreground);
fg = gdk_colormap_color (colormap, win32_gc->foreground);
if (SetTextColor (win32_gc->hdc, fg) == CLR_INVALID)
WIN32_GDI_FAILED ("SetTextColor"), *ok = FALSE;
@ -892,11 +905,11 @@ predraw_set_foreground (GdkGCWin32 *gc_win32,
switch (win32_gc->fill_style)
{
case GDK_OPAQUE_STIPPLED:
if (*ok && (hbr = CreatePatternBrush (GDK_DRAWABLE_XID (win32_gc->stipple))) == NULL)
if (*ok && (hbr = CreatePatternBrush (GDK_PIXMAP_HBITMAP (win32_gc->stipple))) == NULL)
WIN32_GDI_FAILED ("CreatePatternBrush"), *ok = FALSE;
if (*ok && !SetBrushOrgEx(win32_gc->hdc, gc_private->ts_x_origin,
gc_private->ts_y_origin, NULL))
if (*ok && !SetBrushOrgEx(win32_gc->hdc, gc->ts_x_origin,
gc->ts_y_origin, NULL))
WIN32_GDI_FAILED ("SetBrushOrgEx"), *ok = FALSE;
break;
@ -911,21 +924,23 @@ predraw_set_foreground (GdkGCWin32 *gc_win32,
}
void
predraw_set_background (GdkGCWin32 *win32_gc,
GdkColormapPrivateWin32 *colormap_private,
gboolean *ok)
predraw_set_background (GdkGC *gc,
GdkColormap *colormap,
gboolean *ok)
{
COLORREF bg = gdk_colormap_color (colormap_private, win32_gc->background);
GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
COLORREF bg = gdk_colormap_color (colormap, win32_gc->background);
if (SetBkColor (win32_gc->hdc, bg) == CLR_INVALID)
WIN32_GDI_FAILED ("SetBkColor"), *ok = FALSE;
}
HDC
gdk_gc_predraw (GdkDrawable *drawable,
GdkGCWin32 *win32_gc,
GdkGCValuesMask usage)
gdk_win32_hdc_get (GdkDrawable *drawable,
GdkGC *gc,
GdkGCValuesMask usage)
{
GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
GdkColormapPrivateWin32 *colormap_private =
(GdkColormapPrivateWin32 *) GDK_DRAWABLE_IMPL_WIN32 (drawable)->colormap;
gboolean ok = TRUE;
@ -933,9 +948,9 @@ gdk_gc_predraw (GdkDrawable *drawable,
g_assert (win32_gc->hdc == NULL);
win32_gc->hwnd = GDK_DRAWABLE_XID (drawable);
win32_gc->hwnd = GDK_DRAWABLE_HANDLE (drawable);
if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (drawable))
{
if ((win32_gc->hdc = CreateCompatibleDC (NULL)) == NULL)
WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE;
@ -956,12 +971,12 @@ gdk_gc_predraw (GdkDrawable *drawable,
}
if (ok && (usage & GDK_GC_FOREGROUND))
predraw_set_foreground (gc_private, colormap_private, &ok);
predraw_set_foreground (gc, GDK_DRAWABLE_IMPL_WIN32 (drawable)->colormap, &ok);
if (ok
&& (usage & GDK_GC_BACKGROUND)
&& (win32_gc->values_mask & GDK_GC_BACKGROUND))
predraw_set_background (win32_gc, colormap_private, &ok);
predraw_set_background (gc, GDK_DRAWABLE_IMPL_WIN32 (drawable)->colormap, &ok);
if (ok && (usage & GDK_GC_FONT))
{
@ -1002,13 +1017,13 @@ gdk_gc_predraw (GdkDrawable *drawable,
{
rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++;
rect->left = CLAMP (boxes[i].x1 + gc_private->clip_x_origin,
rect->left = CLAMP (boxes[i].x1 + gc->clip_x_origin,
G_MINSHORT, G_MAXSHORT);
rect->right = CLAMP (boxes[i].x2 + gc_private->clip_x_origin,
rect->right = CLAMP (boxes[i].x2 + gc->clip_x_origin,
G_MINSHORT, G_MAXSHORT);
rect->top = CLAMP (boxes[i].y1 + gc_private->clip_y_origin,
rect->top = CLAMP (boxes[i].y1 + gc->clip_y_origin,
G_MINSHORT, G_MAXSHORT);
rect->bottom = CLAMP (boxes[i].y2 + gc_private->clip_y_origin,
rect->bottom = CLAMP (boxes[i].y2 + gc->clip_y_origin,
G_MINSHORT, G_MAXSHORT);
GDK_NOTE (MISC, g_print ("clip rgn box %d: %dx%d@+%d+%d\n",
@ -1051,7 +1066,7 @@ gdk_gc_predraw (GdkDrawable *drawable,
HRGN hrgn;
RECT rect;
g_print ("gdk_gc_predraw: %d: %#x\n", win32_gc, win32_gc->hdc);
g_print ("gdk_win32_hdc_get: %d: %#x\n", win32_gc, win32_gc->hdc);
obj = GetCurrentObject (win32_gc->hdc, OBJ_BRUSH);
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
g_print ("brush: style: %s color: %.06x hatch: %#x\n",
@ -1110,13 +1125,11 @@ gdk_gc_predraw (GdkDrawable *drawable,
}
void
gdk_gc_postdraw (GdkDrawable *drawable,
GdkGCWin32 *win32_gc,
GdkGCValuesMask usage)
gdk_win32_hdc_release (GdkDrawable *drawable,
GdkGC *gc,
GdkGCValuesMask usage)
{
GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable;
GdkColormapPrivateWin32 *colormap_private =
(GdkColormapPrivateWin32 *) drawable_private->colormap;
GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
HGDIOBJ hpen = NULL;
HGDIOBJ hbr = NULL;
@ -1141,7 +1154,7 @@ gdk_gc_postdraw (GdkDrawable *drawable,
WIN32_GDI_FAILED ("UnrealizeObject");
}
#endif
if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (drawable))
{
if (!DeleteDC (win32_gc->hdc))
WIN32_GDI_FAILED ("DeleteDC");
@ -1162,22 +1175,6 @@ gdk_gc_postdraw (GdkDrawable *drawable,
win32_gc->hdc = NULL;
}
HDC
gdk_win32_hdc_get (GdkDrawable *drawable,
GdkGC *gc,
GdkGCValuesMask usage)
{
return gdk_gc_predraw (drawable, GDK_GC_WIN32 (gc), usage);
}
void
gdk_win32_hdc_release (GdkDrawable *drawable,
GdkGC *gc,
GdkGCValuesMask usage)
{
gdk_gc_postdraw (drawable, GDK_GC_WIN32 (gc), usage);
}
/* This function originally from Jean-Edouard Lachand-Robert, and
* available at www.codeguru.com. Simplified for our needs, now
* handles just one-bit deep bitmaps (in Window parlance, ie those

View File

@ -33,6 +33,8 @@
#include "gdkregion-generic.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
typedef struct _GdkWindowQueueItem GdkWindowQueueItem;
typedef struct _GdkWindowParentPos GdkWindowParentPos;
@ -67,10 +69,10 @@ struct _GdkWindowParentPos
GdkRectangle clip_rect;
};
static void gdk_window_compute_position (GdkWindow *window,
static void gdk_window_compute_position (GdkWindowImplWin32 *window,
GdkWindowParentPos *parent_pos,
GdkWin32PositionInfo *info);
static void gdk_window_compute_parent_pos (GdkWindow *window,
static void gdk_window_compute_parent_pos (GdkWindowImplWin32 *window,
GdkWindowParentPos *parent_pos);
static void gdk_window_premove (GdkWindow *window,
GdkWindowParentPos *parent_pos);
@ -92,25 +94,122 @@ _gdk_windowing_window_get_offsets (GdkWindow *window,
gint *x_offset,
gint *y_offset)
{
GdkWindowWin32Data *data = GDK_WINDOW_WIN32DATA (window);
GdkWindowImplWin32 *impl =
GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
*x_offset = data->position_info.x_offset;
*y_offset = data->position_info.y_offset;
*x_offset = impl->position_info.x_offset;
*y_offset = impl->position_info.y_offset;
}
void
_gdk_window_init_position (GdkWindow *window)
{
GdkWindowWin32Data *data;
GdkWindowParentPos parent_pos;
GdkWindowImplWin32 *impl;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
data = GDK_WINDOW_WIN32DATA (window);
impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
gdk_window_compute_parent_pos (window, &parent_pos);
gdk_window_compute_position (window, &parent_pos, &data->position_info);
gdk_window_compute_parent_pos (impl, &parent_pos);
gdk_window_compute_position (impl, &parent_pos, &impl->position_info);
}
/**
* gdk_window_scroll:
* @window: a #GdkWindow
* @dx: Amount to scroll in the X direction
* @dy: Amount to scroll in the Y direction
*
* Scroll the contents of its window, both pixels and children, by
* the given amount. Portions of the window that the scroll operation
* brings in from offscreen areas are invalidated. The invalidated
* region may be bigger than what would strictly be necessary.
* (For X11, a minimum area will be invalidated if the window has
* no subwindows, or if the edges of the window's parent do not extend
* beyond the edges of the window. In other cases, a multi-step process
* is used to scroll the window which may produce temporary visual
* artifacts and unnecessary invalidations.)
**/
void
gdk_window_scroll (GdkWindow *window,
gint dx,
gint dy)
{
gboolean can_guffaw_scroll = FALSE;
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
g_return_if_fail (GDK_IS_WINDOW (window));
obj = GDK_WINDOW_OBJECT (window);
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
if (GDK_WINDOW_DESTROYED (window))
return;
/* We can guffaw scroll if we are a child window, and the parent
* does not extend beyond our edges.
*/
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
{
GdkWindowImplWin32 *parent_impl = GDK_WINDOW_IMPL_WIN32 (obj->parent->impl);
can_guffaw_scroll = (obj->x <= 0 &&
obj->y <= 0 &&
obj->x + impl->width >= parent_impl->width &&
obj->y + impl->height >= parent_impl->height);
}
if (!obj->children || !can_guffaw_scroll)
{
/* Use ScrollWindowEx, then move any children later
*/
GList *tmp_list;
GdkRegion *invalidate_region;
GdkRectangle dest_rect;
invalidate_region = gdk_region_rectangle (&impl->position_info.clip_rect);
dest_rect = impl->position_info.clip_rect;
dest_rect.x += dx;
dest_rect.y += dy;
gdk_rectangle_intersect (&dest_rect, &impl->position_info.clip_rect, &dest_rect);
if (dest_rect.width > 0 && dest_rect.height > 0)
{
GdkRegion *tmp_region;
tmp_region = gdk_region_rectangle (&dest_rect);
gdk_region_subtract (invalidate_region, tmp_region);
gdk_region_destroy (tmp_region);
gdk_window_queue_translation (window, dx, dy);
if (ScrollWindowEx (GDK_WINDOW_HWND (window), dx, dy,
NULL, NULL, NULL, NULL, 0) == ERROR)
WIN32_API_FAILED ("ScrollWindowEx");
}
gdk_window_invalidate_region (window, invalidate_region, TRUE);
gdk_region_destroy (invalidate_region);
tmp_list = obj->children;
while (tmp_list)
{
GdkWindow * child = GDK_WINDOW (tmp_list->data);
gdk_window_move (child, obj->x + dx, obj->y + dy);
tmp_list = tmp_list->next;
}
}
else
{
/* Guffaw scroll
*/
g_warning ("gdk_window_scroll(): guffaw scrolling not yet implemented");
}
}
void
@ -120,10 +219,10 @@ _gdk_window_move_resize_child (GdkWindow *window,
gint width,
gint height)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
GdkWin32PositionInfo new_info;
GdkWindowParentPos parent_pos;
GdkWindowWin32Data *data;
RECT rect;
GList *tmp_list;
gint d_xoffset, d_yoffset;
@ -134,35 +233,36 @@ _gdk_window_move_resize_child (GdkWindow *window,
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
data = GDK_WINDOW_WIN32DATA (window);
obj = GDK_WINDOW_OBJECT (window);
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
dx = x - private->x;
dy = y - private->y;
dx = x - obj->x;
dy = y - obj->y;
is_move = dx != 0 || dy != 0;
is_resize = private->drawable.width != width || private->drawable.height != height;
is_resize = impl->width != width || impl->height != height;
if (!is_move && !is_resize)
return;
private->x = x;
private->y = y;
private->drawable.width = width;
private->drawable.height = height;
obj->x = x;
obj->y = y;
impl->width = width;
impl->height = height;
gdk_window_compute_parent_pos (window, &parent_pos);
gdk_window_compute_position (window, &parent_pos, &new_info);
gdk_window_compute_parent_pos (impl, &parent_pos);
gdk_window_compute_position (impl, &parent_pos, &new_info);
gdk_window_clip_changed (window, &data->position_info.clip_rect, &new_info.clip_rect);
gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
parent_pos.x += private->x;
parent_pos.y += private->y;
parent_pos.x += obj->x;
parent_pos.y += obj->y;
parent_pos.win32_x += new_info.x;
parent_pos.win32_y += new_info.y;
parent_pos.clip_rect = new_info.clip_rect;
d_xoffset = new_info.x_offset - data->position_info.x_offset;
d_yoffset = new_info.y_offset - data->position_info.y_offset;
d_xoffset = new_info.x_offset - impl->position_info.x_offset;
d_yoffset = new_info.y_offset - impl->position_info.y_offset;
if (d_xoffset != 0 || d_yoffset != 0)
{
@ -175,41 +275,41 @@ _gdk_window_move_resize_child (GdkWindow *window,
if (d_xoffset < 0)
{
new_x0 = data->position_info.x + d_xoffset;
new_x1 = data->position_info.x + data->position_info.width;
new_x0 = impl->position_info.x + d_xoffset;
new_x1 = impl->position_info.x + impl->position_info.width;
}
else
{
new_x0 = data->position_info.x;
new_x1 = data->position_info.x + new_info.width + d_xoffset;
new_x0 = impl->position_info.x;
new_x1 = impl->position_info.x + new_info.width + d_xoffset;
}
if (d_yoffset < 0)
{
new_y0 = data->position_info.y + d_yoffset;
new_y1 = data->position_info.y + data->position_info.height;
new_y0 = impl->position_info.y + d_yoffset;
new_y1 = impl->position_info.y + impl->position_info.height;
}
else
{
new_y0 = data->position_info.y;
new_y1 = data->position_info.y + new_info.height + d_yoffset;
new_y0 = impl->position_info.y;
new_y1 = impl->position_info.y + new_info.height + d_yoffset;
}
if (!MoveWindow (GDK_DRAWABLE_XID (window),
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0,
FALSE))
WIN32_API_FAILED ("MoveWindow");
tmp_list = private->children;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_premove (tmp_list->data, &parent_pos);
tmp_list = tmp_list->next;
}
GetClientRect (GDK_DRAWABLE_XID (window), &rect);
GetClientRect (GDK_WINDOW_HWND (window), &rect);
if (!MoveWindow (GDK_DRAWABLE_XID (window),
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_x0 + dx, new_y0 + dy,
rect.right - rect.left, rect.bottom - rect.top,
FALSE))
@ -218,20 +318,20 @@ _gdk_window_move_resize_child (GdkWindow *window,
if (d_xoffset > 0 || d_yoffset > 0)
gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
if (!MoveWindow (GDK_DRAWABLE_XID (window),
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_info.x, new_info.y, new_info.width, new_info.height,
FALSE))
WIN32_API_FAILED ("MoveWindow");
if (data->position_info.no_bg)
if (impl->position_info.no_bg)
gdk_window_tmp_reset_bg (window);
if (!data->position_info.mapped && new_info.mapped && private->mapped)
ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNA);
if (!impl->position_info.mapped && new_info.mapped && obj->mapped)
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);
data->position_info = new_info;
impl->position_info = new_info;
tmp_list = private->children;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_postmove (tmp_list->data, &parent_pos);
@ -243,10 +343,10 @@ _gdk_window_move_resize_child (GdkWindow *window,
if (is_move && is_resize)
gdk_window_set_static_gravities (window, FALSE);
if (data->position_info.mapped && !new_info.mapped)
ShowWindow (GDK_DRAWABLE_XID (window), SW_HIDE);
if (impl->position_info.mapped && !new_info.mapped)
ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
tmp_list = private->children;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_premove (tmp_list->data, &parent_pos);
@ -255,94 +355,98 @@ _gdk_window_move_resize_child (GdkWindow *window,
if (is_resize)
{
if (!MoveWindow (GDK_DRAWABLE_XID (window),
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_info.x, new_info.y, new_info.width, new_info.height,
FALSE))
WIN32_API_FAILED ("MoveWindow");
}
else
{
GetClientRect (GDK_DRAWABLE_XID (window), &rect);
if (!MoveWindow (GDK_DRAWABLE_XID (window),
GetClientRect (GDK_WINDOW_HWND (window), &rect);
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_info.x, new_info.y,
rect.right - rect.left, rect.bottom - rect.top,
FALSE))
WIN32_API_FAILED ("MoveWindow");
}
tmp_list = private->children;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_postmove (tmp_list->data, &parent_pos);
tmp_list = tmp_list->next;
}
if (data->position_info.no_bg)
if (impl->position_info.no_bg)
gdk_window_tmp_reset_bg (window);
if (!data->position_info.mapped && new_info.mapped && private->mapped)
ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNA);
if (!impl->position_info.mapped && new_info.mapped && obj->mapped)
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);
data->position_info = new_info;
impl->position_info = new_info;
}
}
static void
gdk_window_compute_position (GdkWindow *window,
gdk_window_compute_position (GdkWindowImplWin32 *window,
GdkWindowParentPos *parent_pos,
GdkWin32PositionInfo *info)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
GdkWindowObject *wrapper;
int parent_x_offset;
int parent_y_offset;
g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (window));
wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_WIN32 (window)->wrapper);
info->big = FALSE;
if (private->drawable.width <= 32768)
if (window->width <= 32768)
{
info->width = private->drawable.width;
info->x = parent_pos->x + private->x - parent_pos->win32_x;
info->width = window->width;
info->x = parent_pos->x + wrapper->x - parent_pos->win32_x;
}
else
{
info->big = TRUE;
info->width = 32768;
if (parent_pos->x + private->x < -16384)
if (parent_pos->x + wrapper->x < -16384)
{
if (parent_pos->x + private->x + private->drawable.width < 16384)
info->x = parent_pos->x + private->x + private->drawable.width - 32768 - parent_pos->win32_x;
if (parent_pos->x + wrapper->x + window->width < 16384)
info->x = parent_pos->x + wrapper->x + window->width - 32768 - parent_pos->win32_x;
else
info->x = -16384 - parent_pos->win32_y;
}
else
info->x = parent_pos->x + private->x - parent_pos->win32_x;
info->x = parent_pos->x + wrapper->x - parent_pos->win32_x;
}
if (private->drawable.height <= 32768)
if (window->height <= 32768)
{
info->height = private->drawable.height;
info->y = parent_pos->y + private->y - parent_pos->win32_y;
info->height = window->height;
info->y = parent_pos->y + wrapper->y - parent_pos->win32_y;
}
else
{
info->big = TRUE;
info->height = 32768;
if (parent_pos->y + private->y < -16384)
if (parent_pos->y + wrapper->y < -16384)
{
if (parent_pos->y + private->y + private->drawable.height < 16384)
info->y = parent_pos->y + private->y + private->drawable.height - 32768 - parent_pos->win32_y;
if (parent_pos->y + wrapper->y + window->height < 16384)
info->y = parent_pos->y + wrapper->y + window->height - 32768 - parent_pos->win32_y;
else
info->y = -16384 - parent_pos->win32_y;
}
else
info->y = parent_pos->y + private->y - parent_pos->win32_y;
info->y = parent_pos->y + wrapper->y - parent_pos->win32_y;
}
parent_x_offset = parent_pos->win32_x - parent_pos->x;
parent_y_offset = parent_pos->win32_y - parent_pos->y;
info->x_offset = parent_x_offset + info->x - private->x;
info->y_offset = parent_y_offset + info->y - private->y;
info->x_offset = parent_x_offset + info->x - wrapper->x;
info->y_offset = parent_y_offset + info->y - wrapper->y;
/* We don't considering the clipping of toplevel windows and their immediate children
* by their parents, and simply always map those windows.
@ -353,24 +457,24 @@ gdk_window_compute_position (GdkWindow *window,
else if (info->x + parent_x_offset < parent_pos->clip_rect.x + parent_pos->clip_rect.width - 65536 ||
info->x + info->width + parent_x_offset > parent_pos->clip_rect.x + 65536 ||
info->y + parent_y_offset < parent_pos->clip_rect.y + parent_pos->clip_rect.height - 65536 ||
info->y + info->width + parent_y_offset > parent_pos->clip_rect.y + 65536)
info->y + info->height + parent_y_offset > parent_pos->clip_rect.y + 65536)
info->mapped = FALSE;
else
info->mapped = TRUE;
info->no_bg = FALSE;
if (GDK_DRAWABLE_TYPE (private) == GDK_WINDOW_CHILD)
if (GDK_WINDOW_TYPE (wrapper) == GDK_WINDOW_CHILD)
{
info->clip_rect.x = private->x;
info->clip_rect.y = private->y;
info->clip_rect.width = private->drawable.width;
info->clip_rect.height = private->drawable.height;
info->clip_rect.x = wrapper->x;
info->clip_rect.y = wrapper->y;
info->clip_rect.width = window->width;
info->clip_rect.height = window->height;
gdk_rectangle_intersect (&info->clip_rect, &parent_pos->clip_rect, &info->clip_rect);
info->clip_rect.x -= private->x;
info->clip_rect.y -= private->y;
info->clip_rect.x -= wrapper->x;
info->clip_rect.y -= wrapper->y;
}
else
{
@ -382,16 +486,20 @@ gdk_window_compute_position (GdkWindow *window,
}
static void
gdk_window_compute_parent_pos (GdkWindow *window,
gdk_window_compute_parent_pos (GdkWindowImplWin32 *window,
GdkWindowParentPos *parent_pos)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
GdkWindowWin32Data *data;
GdkWindowObject *wrapper;
GdkWindowObject *parent;
GdkRectangle tmp_clip;
int clip_xoffset = 0;
int clip_yoffset = 0;
g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (window));
wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_WIN32 (window)->wrapper);
parent_pos->x = 0;
parent_pos->y = 0;
parent_pos->win32_x = 0;
@ -413,27 +521,27 @@ gdk_window_compute_parent_pos (GdkWindow *window,
parent_pos->clip_rect.width = G_MAXINT;
parent_pos->clip_rect.height = G_MAXINT;
private = (GdkWindowPrivate *)private->parent;
while (private && private->drawable.window_type == GDK_WINDOW_CHILD)
parent = (GdkWindowObject *)wrapper->parent;
while (parent && parent->window_type == GDK_WINDOW_CHILD)
{
data = (GdkWindowWin32Data *)private->drawable.klass_data;
GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (parent->impl);
tmp_clip.x = - clip_xoffset;
tmp_clip.y = - clip_yoffset;
tmp_clip.width = private->drawable.width;
tmp_clip.height = private->drawable.height;
tmp_clip.width = impl->width;
tmp_clip.height = impl->height;
gdk_rectangle_intersect (&parent_pos->clip_rect, &tmp_clip, &parent_pos->clip_rect);
parent_pos->x += private->x;
parent_pos->y += private->y;
parent_pos->win32_x += data->position_info.x;
parent_pos->win32_y += data->position_info.y;
parent_pos->x += parent->x;
parent_pos->y += parent->y;
parent_pos->win32_x += impl->position_info.x;
parent_pos->win32_y += impl->position_info.y;
clip_xoffset += private->x;
clip_yoffset += private->y;
clip_xoffset += parent->x;
clip_yoffset += parent->y;
private = (GdkWindowPrivate *)private->parent;
parent = (GdkWindowObject *)parent->parent;
}
}
@ -441,28 +549,31 @@ static void
gdk_window_premove (GdkWindow *window,
GdkWindowParentPos *parent_pos)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
GdkWindowWin32Data *data = GDK_WINDOW_WIN32DATA (window);
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
GdkWin32PositionInfo new_info;
GList *tmp_list;
gint d_xoffset, d_yoffset;
GdkWindowParentPos this_pos;
gdk_window_compute_position (window, parent_pos, &new_info);
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
gdk_window_compute_position (impl, parent_pos, &new_info);
gdk_window_clip_changed (window, &data->position_info.clip_rect, &new_info.clip_rect);
gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
this_pos.x = parent_pos->x + private->x;
this_pos.y = parent_pos->y + private->y;
this_pos.x = parent_pos->x + obj->x;
this_pos.y = parent_pos->y + obj->y;
this_pos.win32_x = parent_pos->win32_x + new_info.x;
this_pos.win32_y = parent_pos->win32_y + new_info.y;
this_pos.clip_rect = new_info.clip_rect;
if (data->position_info.mapped && !new_info.mapped)
ShowWindow (GDK_DRAWABLE_XID (window), SW_HIDE);
if (impl->position_info.mapped && !new_info.mapped)
ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
d_xoffset = new_info.x_offset - data->position_info.x_offset;
d_yoffset = new_info.y_offset - data->position_info.y_offset;
d_xoffset = new_info.x_offset - impl->position_info.x_offset;
d_yoffset = new_info.y_offset - impl->position_info.y_offset;
if (d_xoffset != 0 || d_yoffset != 0)
{
@ -473,33 +584,33 @@ gdk_window_premove (GdkWindow *window,
if (d_xoffset < 0)
{
new_x0 = data->position_info.x + d_xoffset;
new_x1 = data->position_info.x + data->position_info.width;
new_x0 = impl->position_info.x + d_xoffset;
new_x1 = impl->position_info.x + impl->position_info.width;
}
else
{
new_x0 = data->position_info.x;
new_x1 = data->position_info.x + new_info.width + d_xoffset;
new_x0 = impl->position_info.x;
new_x1 = impl->position_info.x + new_info.width + d_xoffset;
}
if (d_yoffset < 0)
{
new_y0 = data->position_info.y + d_yoffset;
new_y1 = data->position_info.y + data->position_info.height;
new_y0 = impl->position_info.y + d_yoffset;
new_y1 = impl->position_info.y + impl->position_info.height;
}
else
{
new_y0 = data->position_info.y;
new_y1 = data->position_info.y + new_info.height + d_yoffset;
new_y0 = impl->position_info.y;
new_y1 = impl->position_info.y + new_info.height + d_yoffset;
}
if (!MoveWindow (GDK_DRAWABLE_XID (window),
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_x0, new_y0, new_x1 - new_x0, new_y1 - new_y0,
FALSE))
WIN32_API_FAILED ("MoveWindow");
}
tmp_list = private->children;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_premove (tmp_list->data, &this_pos);
@ -511,44 +622,47 @@ static void
gdk_window_postmove (GdkWindow *window,
GdkWindowParentPos *parent_pos)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
GdkWindowWin32Data *data = (GdkWindowWin32Data *)private->drawable.klass_data;
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
GdkWin32PositionInfo new_info;
GList *tmp_list;
gint d_xoffset, d_yoffset;
GdkWindowParentPos this_pos;
gdk_window_compute_position (window, parent_pos, &new_info);
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
gdk_window_compute_position (impl, parent_pos, &new_info);
this_pos.x = parent_pos->x + private->x;
this_pos.y = parent_pos->y + private->y;
this_pos.x = parent_pos->x + obj->x;
this_pos.y = parent_pos->y + obj->y;
this_pos.win32_x = parent_pos->win32_x + new_info.x;
this_pos.win32_y = parent_pos->win32_y + new_info.y;
this_pos.clip_rect = new_info.clip_rect;
d_xoffset = new_info.x_offset - data->position_info.x_offset;
d_yoffset = new_info.y_offset - data->position_info.y_offset;
d_xoffset = new_info.x_offset - impl->position_info.x_offset;
d_yoffset = new_info.y_offset - impl->position_info.y_offset;
if (d_xoffset != 0 || d_yoffset != 0)
{
if (d_xoffset > 0 || d_yoffset > 0)
gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
if (!MoveWindow (GDK_DRAWABLE_XID (window),
if (!MoveWindow (GDK_WINDOW_HWND (window),
new_info.x, new_info.y, new_info.width, new_info.height,
FALSE))
WIN32_API_FAILED ("MoveWindow");
}
if (!data->position_info.mapped && new_info.mapped && private->mapped)
ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNA);
if (!impl->position_info.mapped && new_info.mapped && obj->mapped)
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);
if (data->position_info.no_bg)
if (impl->position_info.no_bg)
gdk_window_tmp_reset_bg (window);
data->position_info = new_info;
impl->position_info = new_info;
tmp_list = private->children;
tmp_list = obj->children;
while (tmp_list)
{
gdk_window_postmove (tmp_list->data, &this_pos);
@ -569,7 +683,7 @@ gdk_window_queue_translation (GdkWindow *window,
item->u.translate.dy = dy;
GDK_NOTE (EVENTS, g_print ("gdk_window_queue_translation %#x %d %d,%d\n",
GDK_DRAWABLE_XID (window),
GDK_WINDOW_HWND (window),
item->serial,
dx, dy));
@ -589,7 +703,7 @@ _gdk_windowing_window_queue_antiexpose (GdkWindow *window,
item->u.antiexpose.area = area;
GDK_NOTE (EVENTS, g_print ("_gdk_windowing_window_queue_antiexpose %#x %d %dx%d@+%d+%d\n",
GDK_DRAWABLE_XID (window),
GDK_WINDOW_HWND (window),
item->serial,
area->extents.x2 - area->extents.x1,
area->extents.y2 - area->extents.y1,
@ -606,14 +720,15 @@ _gdk_window_process_expose (GdkWindow *window,
gulong serial,
GdkRectangle *area)
{
GdkWindowWin32Data *data = GDK_WINDOW_WIN32DATA (window);
GdkWindowImplWin32 *impl;
GdkRegion *invalidate_region = gdk_region_rectangle (area);
GdkRegion *clip_region;
GSList *tmp_list = translate_queue;
impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
GDK_NOTE (EVENTS, g_print ("_gdk_window_process_expose %#x %d %dx%d@+%d+%d\n",
GDK_DRAWABLE_XID (window), serial,
GDK_WINDOW_HWND (window), serial,
area->width, area->height, area->x, area->y));
while (tmp_list)
@ -646,7 +761,7 @@ _gdk_window_process_expose (GdkWindow *window,
}
}
clip_region = gdk_region_rectangle (&data->position_info.clip_rect);
clip_region = gdk_region_rectangle (&impl->position_info.clip_rect);
gdk_region_intersect (invalidate_region, clip_region);
if (!gdk_region_empty (invalidate_region))
@ -659,33 +774,64 @@ _gdk_window_process_expose (GdkWindow *window,
static void
gdk_window_tmp_unset_bg (GdkWindow *window)
{
/* ??? */
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
impl->position_info.no_bg = TRUE;
if (obj->bg_pixmap != GDK_NO_BG)
/* ??? */;
}
static void
gdk_window_tmp_reset_bg (GdkWindow *window)
{
/* ??? */
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
obj = (GdkWindowObject *) window;
impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
impl->position_info.no_bg = FALSE;
if (obj->bg_pixmap == GDK_NO_BG)
return;
if (obj->bg_pixmap)
{
HBITMAP hbitmap;
/* ??? */
}
else
{
/* ??? */
}
}
static void
gdk_window_clip_changed (GdkWindow *window, GdkRectangle *old_clip, GdkRectangle *new_clip)
gdk_window_clip_changed (GdkWindow *window,
GdkRectangle *old_clip,
GdkRectangle *new_clip)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)window;
GdkWindowImplWin32 *impl;
GdkWindowObject *obj;
GdkRegion *old_clip_region;
GdkRegion *new_clip_region;
if (private->input_only)
if (((GdkWindowObject *)window)->input_only)
return;
old_clip_region = gdk_region_rectangle (old_clip);
new_clip_region = gdk_region_rectangle (new_clip);
/* Trim invalid region of window to new clip rectangle
*/
if (private->update_area)
gdk_region_intersect (private->update_area, new_clip_region);
if (obj->update_area)
gdk_region_intersect (obj->update_area, new_clip_region);
/* Invalidate newly exposed portion of window
*/

View File

@ -41,3 +41,4 @@ GdkAtom gdk_ole2_dnd_atom;
ATOM gdk_selection_property;
gint gdk_null_window_warnings = TRUE;
DWORD windows_version = 0;
gint gdk_input_ignore_wintab = FALSE;

View File

@ -27,8 +27,12 @@
#include "config.h"
#include "gdkimage.h"
#include "gdkpixmap.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
#include "gdkpixmap-win32.h"
static GList *image_list = NULL;
static gpointer parent_class = NULL;
@ -129,10 +133,8 @@ gdk_image_new_bitmap (GdkVisual *visual,
int bpl = (w-1)/8 + 1;
int bpl32 = ((w-1)/32 + 1)*4;
private = g_new (GdkImagePrivateWin32, 1);
image = (GdkImage *) private;
private->base.ref_count = 1;
private->base.klass = &image_class;
image = g_object_new (gdk_image_get_type (), NULL);
private = PRIVATE_DATA (image);
image->type = GDK_IMAGE_SHARED;
image->visual = visual;
@ -165,8 +167,8 @@ gdk_image_new_bitmap (GdkVisual *visual,
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
private->ximage = CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi,
DIB_RGB_COLORS, &bits, NULL, 0);
private->hbitmap = CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi,
DIB_RGB_COLORS, &bits, NULL, 0);
if (bpl != bpl32)
{
/* Win32 expects scanlines in DIBs to be 32 bit aligned */
@ -190,12 +192,11 @@ _gdk_windowing_image_init (void)
/* Nothing needed AFAIK */
}
static GdkImage*
gdk_image_new_with_depth (GdkImageType type,
GdkVisual *visual,
gint width,
gint height,
gint depth)
GdkImage*
gdk_image_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
GdkImage *image;
GdkImagePrivateWin32 *private;
@ -214,23 +215,20 @@ gdk_image_new_with_depth (GdkImageType type,
if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL)
type = GDK_IMAGE_SHARED;
GDK_NOTE (MISC, g_print ("gdk_image_new_with_depth: %dx%dx%d %s\n",
width, height, depth,
GDK_NOTE (MISC, g_print ("gdk_image_new: %dx%d %s\n",
width, height,
(type == GDK_IMAGE_SHARED ? "shared" :
(type == GDK_IMAGE_SHARED_PIXMAP ? "shared_pixmap" :
"???"))));
private = g_new (GdkImagePrivateWin32, 1);
image = (GdkImage *) private;
private->base.ref_count = 1;
private->base.klass = &image_class;
image = g_object_new (gdk_image_get_type (), NULL);
private = PRIVATE_DATA (image);
image->type = type;
image->visual = visual;
image->width = width;
image->height = height;
image->depth = depth;
image->depth = visual->depth;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
@ -238,15 +236,13 @@ gdk_image_new_with_depth (GdkImageType type,
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
if (depth == 15)
if (image->depth == 15)
bmi.bmiHeader.biBitCount = 16;
else
bmi.bmiHeader.biBitCount = depth;
#if 1
if (depth == 16)
bmi.bmiHeader.biBitCount = image->depth;
if (image->depth == 16)
bmi.bmiHeader.biCompression = BI_BITFIELDS;
else
#endif
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
@ -262,7 +258,8 @@ gdk_image_new_with_depth (GdkImageType type,
}
else
{
if (depth == 1)
iUsage = DIB_RGB_COLORS;
if (image->depth == 1)
{
bmi.u.bmiColors[0].rgbBlue =
bmi.u.bmiColors[0].rgbGreen =
@ -275,29 +272,25 @@ gdk_image_new_with_depth (GdkImageType type,
bmi.u.bmiColors[1].rgbReserved = 0x00;
}
#if 1
else if (depth == 16)
else if (image->depth == 16)
{
bmi.u.bmiMasks[0] = visual->red_mask;
bmi.u.bmiMasks[1] = visual->green_mask;
bmi.u.bmiMasks[2] = visual->blue_mask;
}
#endif
iUsage = DIB_RGB_COLORS;
}
private->ximage =
CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0);
private->hbitmap = CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi,
iUsage, &image->mem, NULL, 0);
if (private->ximage == NULL)
if (private->hbitmap == NULL)
{
WIN32_GDI_FAILED ("CreateDIBSection");
g_free (image);
return NULL;
}
switch (depth)
switch (image->depth)
{
case 1:
case 8:
@ -314,40 +307,21 @@ gdk_image_new_with_depth (GdkImageType type,
image->bpp = 4;
break;
default:
g_warning ("gdk_image_new_with_depth: depth = %d", depth);
g_warning ("gdk_image_new: depth = %d", image->depth);
g_assert_not_reached ();
}
image->byte_order = GDK_LSB_FIRST;
if (depth == 1)
if (image->depth == 1)
image->bpl = ((width-1)/32 + 1)*4;
else
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
GDK_NOTE (MISC, g_print ("... = %#x mem = %#x, bpl = %d\n",
private->ximage, image->mem, image->bpl));
private->hbitmap, image->mem, image->bpl));
return image;
}
GdkImage*
gdk_image_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
return gdk_image_new_with_depth (type, visual, width, height,
visual->depth);
}
GdkImage*
gdk_image_bitmap_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
return gdk_image_new_with_depth (type, visual, width, height, 1);
}
GdkImage*
gdk_image_get (GdkWindow *window,
gint x,
@ -373,11 +347,11 @@ gdk_image_get (GdkWindow *window,
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_WINDOW_DESTROYED (window))
return NULL;
GDK_NOTE (MISC, g_print ("gdk_image_get: %#x %dx%d@+%d+%d\n",
GDK_DRAWABLE_XID (window), width, height, x, y));
GDK_DRAWABLE_HANDLE (window), width, height, x, y));
image = g_object_new (gdk_image_get_type (), NULL);
private = PRIVATE_DATA (image);
@ -390,7 +364,7 @@ gdk_image_get (GdkWindow *window,
/* This function is called both to blit from a window and from
* a pixmap.
*/
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (window))
{
if ((hdc = CreateCompatibleDC (NULL)) == NULL)
{
@ -398,14 +372,14 @@ gdk_image_get (GdkWindow *window,
g_free (image);
return NULL;
}
if ((oldbitmap1 = SelectObject (hdc, GDK_DRAWABLE_XID (window))) == NULL)
if ((oldbitmap1 = SelectObject (hdc, GDK_PIXMAP_HBITMAP (window))) == NULL)
{
WIN32_GDI_FAILED ("SelectObject");
DeleteDC (hdc);
g_free (image);
return NULL;
}
GetObject (GDK_DRAWABLE_XID (window), sizeof (BITMAP), &bm);
GetObject (GDK_PIXMAP_HBITMAP (window), sizeof (BITMAP), &bm);
GDK_NOTE (MISC,
g_print ("gdk_image_get: bmWidth = %d, bmHeight = %d, bmWidthBytes = %d, bmBitsPixel = %d\n",
bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, bm.bmBitsPixel));
@ -421,7 +395,7 @@ gdk_image_get (GdkWindow *window,
}
else
{
if ((hdc = GetDC (GDK_DRAWABLE_XID (window))) == NULL)
if ((hdc = GetDC (GDK_WINDOW_HWND (window))) == NULL)
{
WIN32_GDI_FAILED ("GetDC");
g_free (image);
@ -441,14 +415,14 @@ gdk_image_get (GdkWindow *window,
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
{
WIN32_GDI_FAILED ("CreateCompatibleDC");
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (window))
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
}
g_free (image);
return NULL;
@ -484,38 +458,37 @@ gdk_image_get (GdkWindow *window,
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
if ((private->ximage =
CreateDIBSection (hdc, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0)) == NULL)
if ((private->hbitmap = CreateDIBSection (hdc, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0)) == NULL)
{
WIN32_GDI_FAILED ("CreateDIBSection");
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (window))
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
}
g_free (image);
return NULL;
}
if ((oldbitmap2 = SelectObject (memdc, private->ximage)) == NULL)
if ((oldbitmap2 = SelectObject (memdc, private->hbitmap)) == NULL)
{
WIN32_GDI_FAILED ("SelectObject");
DeleteObject (private->ximage);
DeleteObject (private->hbitmap);
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (window))
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
}
g_free (image);
return NULL;
@ -525,16 +498,16 @@ gdk_image_get (GdkWindow *window,
{
WIN32_GDI_FAILED ("BitBlt");
SelectObject (memdc, oldbitmap2);
DeleteObject (private->ximage);
DeleteObject (private->hbitmap);
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (window))
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
}
g_free (image);
return NULL;
@ -546,14 +519,14 @@ gdk_image_get (GdkWindow *window,
if (!DeleteDC (memdc))
WIN32_GDI_FAILED ("DeleteDC");
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
if (GDK_IS_PIXMAP (window))
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
}
switch (image->depth)
@ -583,7 +556,7 @@ gdk_image_get (GdkWindow *window,
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
GDK_NOTE (MISC, g_print ("... = %#x mem = %#x, bpl = %d\n",
private->ximage, image->mem, image->bpl));
private->hbitmap, image->mem, image->bpl));
return image;
}
@ -595,10 +568,10 @@ gdk_image_get_pixel (GdkImage *image,
{
guint32 pixel;
g_return_val_if_fail (image != NULL, 0);
g_return_val_if_fail (GDK_IS_IMAGE (image), 0);
g_return_val_if_fail (x >= 0 && x < image->width
&& y >= 0 && y < image->height, 0);
if (!(x >= 0 && x < image->width && y >= 0 && y < image->height))
return 0;
if (image->depth == 1)
pixel = (((char *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
@ -638,7 +611,8 @@ gdk_image_put_pixel (GdkImage *image,
{
g_return_if_fail (image != NULL);
g_return_if_fail (x >= 0 && x < image->width && y >= 0 && y < image->height);
if (!(x >= 0 && x < image->width && y >= 0 && y < image->height))
return;
if (image->depth == 1)
if (pixel & 1)
@ -669,7 +643,7 @@ gdk_win32_image_destroy (GdkImage *image)
{
GdkImagePrivateWin32 *private;
g_return_if_fail (image != NULL);
g_return_if_fail (GDK_IS_IMAGE (image));
private = PRIVATE_DATA (image);
@ -680,7 +654,7 @@ gdk_win32_image_destroy (GdkImage *image)
return;
GDK_NOTE (MISC, g_print ("gdk_win32_image_destroy: %#x%s\n",
private->ximage,
private->hbitmap,
(image->type == GDK_IMAGE_SHARED_PIXMAP ?
" (shared pixmap)" : "")));
@ -693,7 +667,7 @@ gdk_win32_image_destroy (GdkImage *image)
*/
case GDK_IMAGE_SHARED:
if (!DeleteObject (private->ximage))
if (!DeleteObject (private->hbitmap))
WIN32_GDI_FAILED ("DeleteObject");
break;
@ -702,5 +676,6 @@ gdk_win32_image_destroy (GdkImage *image)
}
g_free (private);
image->windowing_data = NULL;
}

File diff suppressed because it is too large Load Diff

177
gdk/win32/gdkinput-win32.h Normal file
View File

@ -0,0 +1,177 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_INPUT_WIN32_H__
#define __GDK_INPUT_WIN32_H__
#ifdef HAVE_WINTAB
#include <wintab.h>
#endif
typedef struct _GdkAxisInfo GdkAxisInfo;
typedef struct _GdkDevicePrivate GdkDevicePrivate;
typedef struct _GdkInputWindow GdkInputWindow;
/* information about a device axis */
struct _GdkAxisInfo
{
/* reported x resolution */
gint xresolution;
/* reported x minimum/maximum values */
gint xmin_value, xmax_value;
/* calibrated resolution (for aspect ration) - only relative values
between axes used */
gint resolution;
/* calibrated minimum/maximum values */
gint min_value, max_value;
};
#define GDK_INPUT_NUM_EVENTC 6
struct _GdkDevicePrivate
{
GdkDevice info;
/* information about the axes */
GdkAxisInfo *axes;
/* minimum key code for device */
gint min_keycode;
int buttonpress_type, buttonrelease_type, keypress_type,
keyrelease_type, motionnotify_type, proximityin_type,
proximityout_type, changenotify_type;
/* true if we need to select a different set of events, but
can't because this is the core pointer */
gint needs_update;
/* Mask of buttons (used for button grabs) */
gint button_state;
/* true if we've claimed the device as active. (used only for XINPUT_GXI) */
gint claimed;
gint *last_axis_data;
gint last_buttons;
#ifdef HAVE_WINTAB
/* WINTAB stuff: */
HCTX hctx;
/* Cursor number */
UINT cursor;
/* The cursor's CSR_PKTDATA */
WTPKT pktdata;
/* CSR_NPBTNMARKS */
UINT npbtnmarks[2];
/* Azimuth and altitude axis */
AXIS orientation_axes[2];
#endif
};
struct _GdkInputWindow
{
/* gdk window */
GdkWindow *window;
/* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
GdkExtensionMode mode;
/* position relative to root window */
gint root_x;
gint root_y;
/* rectangles relative to window of windows obscuring this one */
GdkRectangle *obscuring;
gint num_obscuring;
/* Is there a pointer grab for this window ? */
gint grabbed;
};
/* Global data */
#define GDK_IS_CORE(d) (((GdkDevice *)(d)) == gdk_core_pointer)
extern GList *gdk_input_devices;
extern GList *gdk_input_windows;
extern gint gdk_input_ignore_core;
extern GdkDevice gdk_input_core_info;
/* Function declarations */
void gdk_input_window_destroy (GdkWindow *window);
GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
gint n_events);
/* The following functions are provided by each implementation
* (just wintab for now)
*/
gint _gdk_input_window_none_event(GdkEvent *event,
MSG *msg);
void _gdk_input_configure_event (GdkEventConfigure *event,
GdkWindow *window);
void _gdk_input_enter_event (GdkEventCrossing *event,
GdkWindow *window);
gint _gdk_input_other_event (GdkEvent *event,
MSG *msg,
GdkWindow *window);
/* These should be in gdkinternals.h */
GdkInputWindow *gdk_input_window_find (GdkWindow *window);
gint _gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint _gdk_input_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint _gdk_input_grab_pointer (GdkWindow *window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
guint32 time);
void _gdk_input_ungrab_pointer (guint32 time);
gboolean _gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
#define GDK_MAX_DEVICE_CLASSES 13
gint gdk_input_common_init (gint include_core);
gint gdk_input_common_other_event (GdkEvent *event,
MSG *msg,
GdkInputWindow *input_window,
GdkWindow *window);
#endif /* __GDK_INPUT_WIN32_H__ */

368
gdk/win32/gdkinput.c Normal file
View File

@ -0,0 +1,368 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/* This file should really be one level up, in the backend-independent
* GDK, and the x11/gdkinput.c could also be removed.
*
* That stuff in x11/gdkinput.c which really *is* X11-dependent should
* be in x11/gdkinput-x11.c.
*/
#include "config.h"
#include "gdkinput.h"
#include "gdkprivate.h"
/* When ther necessary stuff is in
* gdkinput.h, gdkinternals.h and
* gdkprivate.h, these includes shouldn't be here.
*/
#include <windows.h>
#include <wintab.h>
#include "gdkinput-win32.h"
static GdkDeviceAxis gdk_input_core_axes[] = {
{ GDK_AXIS_X, 0, 0 },
{ GDK_AXIS_Y, 0, 0 }
};
GdkDevice gdk_input_core_info =
{
"Core Pointer",
GDK_SOURCE_MOUSE,
GDK_MODE_SCREEN,
TRUE,
2,
gdk_input_core_axes,
0,
NULL
};
/* Global variables */
GDKVAR GdkDevice *gdk_core_pointer = (GdkDevice *)&gdk_input_core_info;
gint gdk_input_ignore_core;
GList *gdk_input_devices;
GList *gdk_input_windows;
GList *
gdk_devices_list (void)
{
return gdk_input_devices;
}
void
gdk_device_set_source (GdkDevice *device,
GdkInputSource source)
{
g_return_if_fail (device != NULL);
device->source = source;
}
void
gdk_device_set_key (GdkDevice *device,
guint index,
guint keyval,
GdkModifierType modifiers)
{
g_return_if_fail (device != NULL);
g_return_if_fail (index < device->num_keys);
device->keys[index].keyval = keyval;
device->keys[index].modifiers = modifiers;
}
void
gdk_device_set_axis_use (GdkDevice *device,
guint index,
GdkAxisUse use)
{
g_return_if_fail (device != NULL);
g_return_if_fail (index < device->num_axes);
device->axes[index].use = use;
switch (use)
{
case GDK_AXIS_X:
case GDK_AXIS_Y:
device->axes[index].min = 0.;
device->axes[index].max = 0.;
break;
case GDK_AXIS_XTILT:
case GDK_AXIS_YTILT:
device->axes[index].min = -1.;
device->axes[index].max = 1;
break;
default:
device->axes[index].min = 0.;
device->axes[index].max = 1;
break;
}
}
GdkTimeCoord **
_gdk_device_allocate_history (GdkDevice *device,
gint n_events)
{
GdkTimeCoord **result = g_new (GdkTimeCoord *, n_events);
gint i;
for (i=0; i<n_events; i++)
result[i] = g_malloc (sizeof (GdkTimeCoord) -
sizeof (double) * (GDK_MAX_TIMECOORD_AXES - device->num_axes));
return result;
}
void
gdk_device_free_history (GdkTimeCoord **events,
gint n_events)
{
gint i;
for (i=0; i<n_events; i++)
g_free (events[i]);
g_free (events);
}
GdkInputWindow *
gdk_input_window_find(GdkWindow *window)
{
GList *tmp_list;
for (tmp_list=gdk_input_windows; tmp_list; tmp_list=tmp_list->next)
if (((GdkInputWindow *)(tmp_list->data))->window == window)
return (GdkInputWindow *)(tmp_list->data);
return NULL; /* Not found */
}
/* FIXME: this routine currently needs to be called between creation
and the corresponding configure event (because it doesn't get the
root_relative_geometry). This should work with
gtk_window_set_extension_events, but will likely fail in other
cases */
void
gdk_input_set_extension_events (GdkWindow *window, gint mask,
GdkExtensionMode mode)
{
GdkWindowObject *window_private;
GList *tmp_list;
GdkInputWindow *iw;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
window_private = (GdkWindowObject*) window;
if (GDK_WINDOW_DESTROYED (window))
return;
if (mode == GDK_EXTENSION_EVENTS_NONE)
mask = 0;
if (mask != 0)
{
iw = g_new(GdkInputWindow,1);
iw->window = window;
iw->mode = mode;
iw->obscuring = NULL;
iw->num_obscuring = 0;
iw->grabbed = FALSE;
gdk_input_windows = g_list_append(gdk_input_windows,iw);
window_private->extension_events = mask;
/* Add enter window events to the event mask */
if (g_list_length (gdk_input_devices) > 1)
gdk_window_set_events (window,
gdk_window_get_events (window) |
GDK_ENTER_NOTIFY_MASK);
}
else
{
iw = gdk_input_window_find (window);
if (iw)
{
gdk_input_windows = g_list_remove(gdk_input_windows,iw);
g_free(iw);
}
window_private->extension_events = 0;
}
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevicePrivate *gdkdev = tmp_list->data;
if (!GDK_IS_CORE (gdkdev))
{
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
_gdk_input_enable_window (window,gdkdev);
else
_gdk_input_disable_window (window,gdkdev);
}
}
}
void
gdk_input_window_destroy (GdkWindow *window)
{
GdkInputWindow *input_window;
input_window = gdk_input_window_find (window);
g_return_if_fail (input_window != NULL);
gdk_input_windows = g_list_remove (gdk_input_windows,input_window);
g_free(input_window);
}
void
gdk_input_exit (void)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (!GDK_IS_CORE (gdkdev))
{
gdk_device_set_mode (&gdkdev->info, GDK_MODE_DISABLED);
g_free(gdkdev->info.name);
g_free(gdkdev->axes);
g_free(gdkdev->info.axes);
g_free(gdkdev->info.keys);
g_free(gdkdev);
}
}
g_list_free(gdk_input_devices);
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
g_free(tmp_list->data);
g_list_free(gdk_input_windows);
}
/**
* gdk_device_get_axis:
* @axis: a #GdkDevice
* @axes: pointer to an array of axes
* @use: the use to look for
* @value: location to store the found value.
*
* Interprets an array of double as axis values for a given device,
* and locates the value in the array for a given axis use.
*
* Return value: %TRUE if the given axis use was found, otherwies %FALSE
**/
gboolean
gdk_device_get_axis (GdkDevice *device, gdouble *axes, GdkAxisUse use, gdouble *value)
{
gint i;
g_return_val_if_fail (device != NULL, FALSE);
if (axes == NULL)
return FALSE;
for (i=0; i<device->num_axes; i++)
if (device->axes[i].use == use)
{
if (value)
*value = axes[i];
return TRUE;
}
return FALSE;
}
gboolean
gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
GdkInputMode old_mode;
GdkInputWindow *input_window;
if (GDK_IS_CORE (device))
return FALSE;
gdkdev = (GdkDevicePrivate *)device;
if (device->mode == mode)
return TRUE;
old_mode = device->mode;
device->mode = mode;
if (mode == GDK_MODE_WINDOW)
{
device->has_cursor = FALSE;
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
_gdk_input_enable_window (input_window->window, gdkdev);
else
if (old_mode != GDK_MODE_DISABLED)
_gdk_input_disable_window (input_window->window, gdkdev);
}
}
else if (mode == GDK_MODE_SCREEN)
{
device->has_cursor = TRUE;
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
_gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
gdkdev);
}
else /* mode == GDK_MODE_DISABLED */
{
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (old_mode != GDK_MODE_WINDOW ||
input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
_gdk_input_disable_window (input_window->window, gdkdev);
}
}
return TRUE;
}

View File

@ -1,119 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_INPUTPRIVATE_H__
#define __GDK_INPUTPRIVATE_H__
typedef struct _GdkAxisInfo GdkAxisInfo;
typedef struct _GdkInputVTable GdkInputVTable;
typedef struct _GdkDevicePrivate GdkDevicePrivate;
typedef struct _GdkInputWindow GdkInputWindow;
struct _GdkInputVTable {
gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
void (*set_key) (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
GdkTimeCoord* (*motion_events) (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
void (*get_pointer) (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
gint (*grab_pointer) (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
void (*ungrab_pointer) (guint32 time);
void (*configure_event) (GdkEventConfigure *event, GdkWindow *window);
void (*enter_event) (GdkEventCrossing *event, GdkWindow *window);
gint (*other_event) (GdkEvent *event, MSG *xevent);
gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
};
/* information about a device axis */
struct _GdkAxisInfo
{
/* reported x resolution */
gint xresolution;
/* reported x minimum/maximum values */
gint xmin_value, xmax_value;
/* calibrated resolution (for aspect ration) - only relative values
between axes used */
gint resolution;
/* calibrated minimum/maximum values */
gint min_value, max_value;
};
struct _GdkInputWindow
{
/* gdk window */
GdkWindow *window;
/* Extension mode (GDK_EXTENSION_EVENTS_ALL/CURSOR) */
GdkExtensionMode mode;
/* position relative to root window */
gint16 root_x;
gint16 root_y;
/* rectangles relative to window of windows obscuring this one */
GdkRectangle *obscuring;
gint num_obscuring;
/* Is there a pointer grab for this window ? */
gint grabbed;
};
/* Global data */
extern GdkInputVTable gdk_input_vtable;
extern gint gdk_input_ignore_core;
extern gint gdk_input_ignore_wintab;
/* Function declarations */
void gdk_input_window_destroy (GdkWindow *window);
void gdk_input_init (void);
void gdk_input_exit (void);
#endif /* __GDK_INPUTPRIVATE_H__ */

View File

@ -34,10 +34,11 @@
#include <io.h>
#include "gdk.h"
#include "gdkkeysyms.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkinputprivate.h"
#include "gdkkeysyms.h"
#include "gdkwindow-win32.h"
#include "gdkinput-win32.h"
#include <objbase.h>
@ -71,9 +72,10 @@ _gdk_windowing_init_check (int argc,
{
gint i, j, k;
#ifdef HAVE_WINTAB
if (getenv ("GDK_IGNORE_WINTAB") != NULL)
gdk_input_ignore_wintab = TRUE;
#endif
if (getenv ("GDK_EVENT_FUNC_FROM_WINDOW_PROC") != NULL)
gdk_event_func_from_window_proc = TRUE;
@ -127,7 +129,7 @@ gdk_win32_gdi_failed (const gchar *where,
/* On Win9x GDI calls are implemented in 16-bit code and thus
* don't set the 32-bit error code, sigh.
*/
if (IS_WIN_NT (windows_version))
if (IS_WIN_NT ())
gdk_win32_api_failed (where, line, api);
else
gdk_other_api_failed (where, line, api);
@ -163,7 +165,7 @@ gdk_get_use_xshm (void)
gint
gdk_screen_width (void)
{
return ((GdkWindowPrivate *) gdk_parent_root)->drawable.width;
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (gdk_parent_root)->impl)->width;
}
/*
@ -184,7 +186,7 @@ gdk_screen_width (void)
gint
gdk_screen_height (void)
{
return ((GdkWindowPrivate *) gdk_parent_root)->drawable.height;
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (gdk_parent_root)->impl)->height;
}
/*

View File

@ -34,62 +34,100 @@
#include "gdkpixmap.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
#include "gdkpixmap-win32.h"
typedef struct
static void gdk_pixmap_impl_win32_get_size (GdkDrawable *drawable,
gint *width,
gint *height);
static void gdk_pixmap_impl_win32_init (GdkPixmapImplWin32 *pixmap);
static void gdk_pixmap_impl_win32_class_init (GdkPixmapImplWin32Class *klass);
static void gdk_pixmap_impl_win32_finalize (GObject *object);
static gpointer parent_class = NULL;
GType
gdk_pixmap_impl_win32_get_type (void)
{
gchar *color_string;
GdkColor color;
gint transparent;
} _GdkPixmapColor;
static GType object_type = 0;
typedef struct
{
guint ncolors;
GdkColormap *colormap;
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)))
WIN32_GDI_FAILED ("DeleteObject");
gdk_xid_table_remove (GDK_DRAWABLE_XID (pixmap));
g_free (GDK_DRAWABLE_WIN32DATA (pixmap));
if (!object_type)
{
static const GTypeInfo object_info =
{
sizeof (GdkPixmapImplWin32Class),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_pixmap_impl_win32_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkPixmapImplWin32),
0, /* n_preallocs */
(GInstanceInitFunc) gdk_pixmap_impl_win32_init,
};
object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_WIN32,
"GdkPixmapImplWin32",
&object_info);
}
return object_type;
}
static GdkDrawable *
gdk_win32_pixmap_alloc (void)
GType
_gdk_pixmap_impl_get_type (void)
{
GdkDrawable *drawable;
GdkDrawablePrivate *private;
return gdk_pixmap_impl_win32_get_type ();
}
static void
gdk_pixmap_impl_win32_init (GdkPixmapImplWin32 *impl)
{
impl->width = 1;
impl->height = 1;
}
static void
gdk_pixmap_impl_win32_class_init (GdkPixmapImplWin32Class *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
static GdkDrawableClass klass;
static gboolean initialized = FALSE;
parent_class = g_type_class_peek_parent (klass);
if (!initialized)
{
initialized = TRUE;
klass = _gdk_win32_drawable_class;
klass.destroy = gdk_win32_pixmap_destroy;
}
object_class->finalize = gdk_pixmap_impl_win32_finalize;
drawable = gdk_drawable_alloc ();
private = (GdkDrawablePrivate *) drawable;
drawable_class->get_size = gdk_pixmap_impl_win32_get_size;
}
private->klass = &klass;
private->klass_data = g_new (GdkDrawableWin32Data, 1);
private->window_type = GDK_DRAWABLE_PIXMAP;
static void
gdk_pixmap_impl_win32_finalize (GObject *object)
{
GdkPixmapImplWin32 *impl = GDK_PIXMAP_IMPL_WIN32 (object);
GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_WIN32 (impl)->wrapper);
return drawable;
GDK_NOTE (MISC, g_print ("gdk_pixmap_impl_win32_finalize: %#x\n",
GDK_PIXMAP_HBITMAP (object)));
if (!DeleteObject (GDK_PIXMAP_HBITMAP (object)))
WIN32_GDI_FAILED ("DeleteObject");
gdk_win32_handle_table_remove (GDK_PIXMAP_HBITMAP (object));
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gdk_pixmap_impl_win32_get_size (GdkDrawable *drawable,
gint *width,
gint *height)
{
if (width)
*width = GDK_PIXMAP_IMPL_WIN32 (drawable)->width;
if (height)
*height = GDK_PIXMAP_IMPL_WIN32 (drawable)->height;
}
GdkPixmap*
@ -99,7 +137,10 @@ gdk_pixmap_new (GdkWindow *window,
gint depth)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
GdkDrawableImplWin32 *draw_impl;
GdkPixmapImplWin32 *pix_impl;
GdkVisual *visual;
struct {
BITMAPINFOHEADER bmiHeader;
union {
@ -110,7 +151,7 @@ gdk_pixmap_new (GdkWindow *window,
} bmi;
UINT iUsage;
HDC hdc;
GdkVisual *visual;
guchar *bits;
gint i;
@ -134,24 +175,31 @@ gdk_pixmap_new (GdkWindow *window,
if (!window)
window = gdk_parent_root;
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_WINDOW_DESTROYED (window))
return NULL;
visual = gdk_drawable_get_visual (window);
if (depth == -1)
depth = gdk_drawable_get_visual (window)->depth;
depth = visual->depth;
GDK_NOTE (MISC, g_print ("gdk_pixmap_new: %dx%dx%d\n",
width, height, depth));
pixmap = gdk_win32_pixmap_alloc ();
private = (GdkDrawablePrivate *) pixmap;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
pix_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
draw_impl->wrapper = GDK_DRAWABLE (pixmap);
pix_impl->is_foreign = FALSE;
pix_impl->width = width;
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
visual = gdk_drawable_get_visual (window);
if ((hdc = GetDC (GDK_DRAWABLE_XID (window))) == NULL)
if ((hdc = GetDC (GDK_WINDOW_HWND (window))) == NULL)
{
WIN32_GDI_FAILED ("GetDC");
g_free (private);
g_object_unref ((GObject *) pixmap);
return NULL;
}
@ -163,11 +211,9 @@ gdk_pixmap_new (GdkWindow *window,
bmi.bmiHeader.biBitCount = 16;
else
bmi.bmiHeader.biBitCount = depth;
#if 1
if (depth == 16)
bmi.bmiHeader.biCompression = BI_BITFIELDS;
else
#endif
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
@ -187,13 +233,13 @@ gdk_pixmap_new (GdkWindow *window,
bmi.u.bmiColors[1].rgbGreen =
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
private->colormap = NULL;
draw_impl->colormap = NULL;
}
else
{
private->colormap = ((GdkWindowPrivate *) window)->drawable.colormap;
if (private->colormap == NULL)
private->colormap = gdk_colormap_get_system ();
draw_impl->colormap = GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap;
if (draw_impl->colormap == NULL)
draw_impl->colormap = gdk_colormap_get_system ();
if (depth == 8)
{
@ -206,75 +252,28 @@ gdk_pixmap_new (GdkWindow *window,
if (depth != visual->depth)
g_warning ("gdk_pixmap_new: depth %d doesn't match display depth %d",
depth, visual->depth);
#if 1
if (depth == 16)
{
bmi.u.bmiMasks[0] = visual->red_mask;
bmi.u.bmiMasks[1] = visual->green_mask;
bmi.u.bmiMasks[2] = visual->blue_mask;
}
#endif
}
}
if ((GDK_DRAWABLE_WIN32DATA (pixmap)->xid =
CreateDIBSection (hdc, (BITMAPINFO *) &bmi,
iUsage, (PVOID *) &bits, NULL, 0)) == NULL)
if ((draw_impl->handle = CreateDIBSection (hdc, (BITMAPINFO *) &bmi,
iUsage, (PVOID *) &bits,
NULL, 0)) == NULL)
{
WIN32_GDI_FAILED ("CreateDIBSection");
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
g_free (pixmap);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
g_object_unref ((GObject *) pixmap);
return NULL;
}
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
GDK_NOTE (MISC, g_print ("... = %#x\n", GDK_DRAWABLE_XID (pixmap)));
GDK_NOTE (MISC, g_print ("... = %#x\n", GDK_PIXMAP_HBITMAP (pixmap)));
private->width = width;
private->height = height;
gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
return pixmap;
}
GdkPixmap *
gdk_pixmap_create_on_shared_image (GdkImage **image_return,
GdkWindow *window,
GdkVisual *visual,
gint width,
gint height,
gint depth)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
g_return_val_if_fail (window != NULL, NULL);
if (depth == 1)
*image_return = gdk_image_bitmap_new (GDK_IMAGE_SHARED_PIXMAP, visual, width, height);
else
{
g_return_val_if_fail (depth == visual->depth, NULL);
*image_return = gdk_image_new (GDK_IMAGE_SHARED_PIXMAP, visual, width, height);
}
g_return_val_if_fail (*image_return != NULL, NULL);
pixmap = gdk_win32_pixmap_alloc ();
private = (GdkDrawablePrivate *) pixmap;
GDK_DRAWABLE_WIN32DATA (pixmap)->xid =
((GdkImagePrivateWin32 *) *image_return)->ximage;
private->colormap = ((GdkWindowPrivate *) window)->drawable.colormap;
private->width = width;
private->height = height;
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, GDK_DRAWABLE_XID (pixmap)));
gdk_win32_handle_table_insert (GDK_PIXMAP_HBITMAP (pixmap), pixmap);
return pixmap;
}
@ -321,7 +320,8 @@ gdk_bitmap_create_from_data (GdkWindow *window,
gint height)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
GdkDrawableImplWin32 *draw_impl;
GdkPixmapImplWin32 *pix_impl;
gint i, j, bpl, aligned_bpl;
guchar *bits;
@ -332,14 +332,18 @@ gdk_bitmap_create_from_data (GdkWindow *window,
if (!window)
window = gdk_parent_root;
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_WINDOW_DESTROYED (window))
return NULL;
pixmap = gdk_win32_pixmap_alloc ();
private = (GdkDrawablePrivate *) pixmap;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
pix_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
draw_impl->wrapper = GDK_DRAWABLE (pixmap);
private->width = width;
private->height = height;
pix_impl->is_foreign = FALSE;
pix_impl->width = width;
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = 1;
bpl = ((width - 1) / 8 + 1);
aligned_bpl = ((bpl - 1) / 2 + 1) * 2;
@ -348,16 +352,15 @@ gdk_bitmap_create_from_data (GdkWindow *window,
for (j = 0; j < bpl; j++)
bits[i*aligned_bpl + j] = mirror[(guchar) data[i*bpl + j]];
GDK_DRAWABLE_WIN32DATA (pixmap)->xid =
CreateBitmap (width, height, 1, 1, bits);
draw_impl->handle = CreateBitmap (width, height, 1, 1, bits);
GDK_NOTE (MISC, g_print ("gdk_bitmap_create_from_data: %dx%d = %#x\n",
width, height, GDK_DRAWABLE_XID (pixmap)));
width, height, GDK_PIXMAP_HBITMAP (pixmap)));
g_free (bits);
private->colormap = NULL;
gdk_xid_table_insert (&GDK_DRAWABLE_XID (pixmap), pixmap);
draw_impl->colormap = NULL;
gdk_win32_handle_table_insert (GDK_PIXMAP_HBITMAP (pixmap), pixmap);
return pixmap;
}
@ -389,605 +392,45 @@ gdk_pixmap_create_from_data (GdkWindow *window,
GDK_NOTE (MISC, g_print ("gdk_pixmap_create_from_data: %dx%dx%d = %#x\n",
width, height, depth,
GDK_DRAWABLE_XID (result)));
GDK_PIXMAP_HBITMAP (result)));
return result;
}
static gint
gdk_pixmap_seek_string (FILE *infile,
const gchar *str,
gint skip_comments)
{
char instr[1024];
while (1)
{
if (fscanf (infile, "%1023s", instr) != 1)
return FALSE;
if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
{
do
{
if (fscanf (infile, "%1023s", instr) != 1)
return FALSE;
}
while (strcmp (instr, "*/") != 0);
}
else if (strcmp (instr, str) == 0)
return TRUE;
}
}
static gint
gdk_pixmap_seek_char (FILE *infile,
gchar c)
{
gint b, oldb;
while ((b = getc(infile)) != EOF)
{
if (c != b && b == '/')
{
b = getc (infile);
if (b == EOF)
return FALSE;
else if (b == '*') /* we have a comment */
{
b = -1;
do
{
oldb = b;
b = getc (infile);
if (b == EOF)
return FALSE;
}
while (!(oldb == '*' && b == '/'));
}
}
else if (c == b)
return TRUE;
}
return FALSE;
}
static gint
gdk_pixmap_read_string (FILE *infile,
gchar **buffer,
guint *buffer_size)
{
gint c;
guint cnt = 0, bufsiz, ret = FALSE;
gchar *buf;
buf = *buffer;
bufsiz = *buffer_size;
if (buf == NULL)
{
bufsiz = 10 * sizeof (gchar);
buf = g_new(gchar, bufsiz);
}
do
c = getc (infile);
while (c != EOF && c != '"');
if (c != '"')
goto out;
while ((c = getc(infile)) != EOF)
{
if (cnt == bufsiz)
{
guint new_size = bufsiz * 2;
if (new_size > bufsiz)
bufsiz = new_size;
else
goto out;
buf = (gchar *) g_realloc (buf, bufsiz);
buf[bufsiz-1] = '\0';
}
if (c != '"')
buf[cnt++] = c;
else
{
buf[cnt] = 0;
ret = TRUE;
break;
}
}
out:
buf[bufsiz-1] = '\0'; /* ensure null termination for errors */
*buffer = buf;
*buffer_size = bufsiz;
return ret;
}
static gchar*
gdk_pixmap_skip_whitespaces (gchar *buffer)
{
gint32 index = 0;
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
index++;
return &buffer[index];
}
static gchar*
gdk_pixmap_skip_string (gchar *buffer)
{
gint32 index = 0;
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
index++;
return &buffer[index];
}
#define MAX_COLOR_LEN 120
static gchar*
gdk_pixmap_extract_color (gchar *buffer)
{
gint counter, numnames;
gchar *ptr = NULL, ch, temp[128];
gchar color[MAX_COLOR_LEN], *retcol;
gint space;
counter = 0;
while (ptr == NULL)
{
if (buffer[counter] == 'c')
{
ch = buffer[counter + 1];
if (ch == 0x20 || ch == 0x09)
ptr = &buffer[counter + 1];
}
else if (buffer[counter] == 0)
return NULL;
counter++;
}
ptr = gdk_pixmap_skip_whitespaces (ptr);
if (ptr[0] == 0)
return NULL;
else if (ptr[0] == '#')
{
counter = 1;
while (ptr[counter] != 0 &&
((ptr[counter] >= '0' && ptr[counter] <= '9') ||
(ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
(ptr[counter] >= 'A' && ptr[counter] <= 'F')))
counter++;
retcol = g_new (gchar, counter+1);
strncpy (retcol, ptr, counter);
retcol[counter] = 0;
return retcol;
}
color[0] = 0;
numnames = 0;
space = MAX_COLOR_LEN - 1;
while (space > 0)
{
sscanf (ptr, "%127s", temp);
if (((gint)ptr[0] == 0) ||
(strcmp ("s", temp) == 0) || (strcmp ("m", temp) == 0) ||
(strcmp ("g", temp) == 0) || (strcmp ("g4", temp) == 0))
{
break;
}
else
{
if (numnames > 0)
{
space -= 1;
strcat (color, " ");
}
strncat (color, temp, space);
space -= MIN (space, strlen (temp));
ptr = gdk_pixmap_skip_string (ptr);
ptr = gdk_pixmap_skip_whitespaces (ptr);
numnames++;
}
}
retcol = g_strdup (color);
return retcol;
}
enum buffer_op
{
op_header,
op_cmap,
op_body
};
static void
gdk_xpm_destroy_notify (gpointer data)
{
_GdkPixmapInfo *info = (_GdkPixmapInfo *)data;
GdkColor color;
int i;
for (i=0; i<info->ncolors; i++)
{
color.pixel = info->pixels[i];
gdk_colormap_free_colors (info->colormap, &color, 1);
}
gdk_colormap_unref (info->colormap);
g_free (info);
}
static GdkPixmap *
_gdk_pixmap_create_from_xpm (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar * (*get_buf) (enum buffer_op op,
gpointer handle),
gpointer handle)
{
GdkPixmap *pixmap = NULL;
GdkImage *image = NULL;
GdkVisual *visual;
GdkGC *gc = NULL;
GdkColor tmp_color;
gint width, height, num_cols, cpp, n, ns, cnt, xcnt, ycnt, wbytes;
gchar *buffer, pixel_str[32];
gchar *name_buf;
_GdkPixmapColor *color = NULL, *fallbackcolor = NULL;
_GdkPixmapColor *colors = NULL;
gulong index;
GHashTable *color_hash = NULL;
_GdkPixmapInfo *color_info = NULL;
if ((window == NULL) && (colormap == NULL))
g_warning ("Creating pixmap from xpm with NULL window and colormap");
if (window == NULL)
window = gdk_parent_root;
if (colormap == NULL)
{
colormap = gdk_drawable_get_colormap (window);
visual = gdk_drawable_get_visual (window);
}
else
visual = ((GdkColormapPrivate *)colormap)->visual;
buffer = (*get_buf) (op_header, handle);
if (buffer == NULL)
return NULL;
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
if (cpp >= 32)
{
g_warning ("Pixmap has more than 31 characters per color");
return NULL;
}
color_hash = g_hash_table_new (g_str_hash, g_str_equal);
if (transparent_color == NULL)
{
gdk_color_white (colormap, &tmp_color);
transparent_color = &tmp_color;
}
/* For pseudo-color and grayscale visuals, we have to remember
* the colors we allocated, so we can free them later.
*/
if ((visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
(visual->type == GDK_VISUAL_GRAYSCALE))
{
color_info = g_malloc (sizeof (_GdkPixmapInfo) +
sizeof(gulong) * (num_cols - 1));
color_info->ncolors = num_cols;
color_info->colormap = colormap;
gdk_colormap_ref (colormap);
}
name_buf = g_new (gchar, num_cols * (cpp+1));
colors = g_new (_GdkPixmapColor, num_cols);
for (cnt = 0; cnt < num_cols; cnt++)
{
gchar *color_name;
buffer = (*get_buf) (op_cmap, handle);
if (buffer == NULL)
goto error;
color = &colors[cnt];
color->color_string = &name_buf [cnt * (cpp + 1)];
strncpy (color->color_string, buffer, cpp);
color->color_string[cpp] = 0;
buffer += strlen (color->color_string);
color->transparent = FALSE;
color_name = gdk_pixmap_extract_color (buffer);
if (color_name == NULL ||
gdk_color_parse (color_name, &color->color) == FALSE)
{
color->color = *transparent_color;
color->transparent = TRUE;
}
g_free (color_name);
/* FIXME: The remaining slowness appears to happen in this
function. */
gdk_color_alloc (colormap, &color->color);
if (color_info)
color_info->pixels[cnt] = color->color.pixel;
g_hash_table_insert (color_hash, color->color_string, color);
if (cnt == 0)
fallbackcolor = color;
}
index = 0;
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
if (mask)
{
/* The pixmap mask is just a bits pattern.
* Color 0 is used for background and 1 for foreground.
* We don't care about the colormap, we just need 0 and 1.
*/
GdkColor mask_pattern;
*mask = gdk_pixmap_new (window, width, height, 1);
gc = gdk_gc_new (*mask);
mask_pattern.pixel = 0;
gdk_gc_set_foreground (gc, &mask_pattern);
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
mask_pattern.pixel = 1;
gdk_gc_set_foreground (gc, &mask_pattern);
}
wbytes = width * cpp;
for (ycnt = 0; ycnt < height; ycnt++)
{
buffer = (*get_buf) (op_body, handle);
/* FIXME: this slows things down a little - it could be
* integrated into the strncpy below, perhaps. OTOH, strlen
* is fast.
*/
if ((buffer == NULL) || strlen (buffer) < wbytes)
continue;
for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++)
{
strncpy (pixel_str, &buffer[n], cpp);
pixel_str[cpp] = 0;
ns = 0;
color = g_hash_table_lookup (color_hash, pixel_str);
if (!color) /* screwed up XPM file */
color = fallbackcolor;
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
if (mask && color->transparent)
{
if (cnt < xcnt)
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
cnt = xcnt + 1;
}
}
if (mask && (cnt < xcnt))
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
}
error:
if (mask)
gdk_gc_unref (gc);
if (image != NULL)
{
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
if (color_info)
gdk_drawable_set_data (pixmap, "gdk-xpm", color_info,
gdk_xpm_destroy_notify);
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_unref (gc);
gdk_image_unref (image);
}
else if (color_info)
gdk_xpm_destroy_notify (color_info);
if (color_hash != NULL)
g_hash_table_destroy (color_hash);
if (colors != NULL)
g_free (colors);
if (name_buf != NULL)
g_free (name_buf);
return pixmap;
}
struct file_handle
{
FILE *infile;
gchar *buffer;
guint buffer_size;
};
static gchar *
file_buffer (enum buffer_op op, gpointer handle)
{
struct file_handle *h = handle;
switch (op)
{
case op_header:
if (gdk_pixmap_seek_string (h->infile, "XPM", FALSE) != TRUE)
break;
if (gdk_pixmap_seek_char (h->infile,'{') != TRUE)
break;
/* Fall through to the next gdk_pixmap_seek_char. */
case op_cmap:
gdk_pixmap_seek_char (h->infile, '"');
fseek (h->infile, -1, SEEK_CUR);
/* Fall through to the gdk_pixmap_read_string. */
case op_body:
gdk_pixmap_read_string (h->infile, &h->buffer, &h->buffer_size);
return h->buffer;
}
return 0;
}
GdkPixmap*
gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename)
{
struct file_handle h;
GdkPixmap *pixmap = NULL;
memset (&h, 0, sizeof (h));
h.infile = fopen (filename, "rb");
if (h.infile != NULL)
{
pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
transparent_color,
file_buffer, &h);
fclose (h.infile);
g_free (h.buffer);
}
return pixmap;
}
GdkPixmap*
gdk_pixmap_create_from_xpm (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename)
{
return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
transparent_color, filename);
}
struct mem_handle
{
gchar **data;
int offset;
};
static gchar *
mem_buffer (enum buffer_op op, gpointer handle)
{
struct mem_handle *h = handle;
switch (op)
{
case op_header:
case op_cmap:
case op_body:
if (h->data[h->offset])
return h->data[h->offset ++];
}
return 0;
}
GdkPixmap*
gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data)
{
struct mem_handle h;
GdkPixmap *pixmap = NULL;
memset (&h, 0, sizeof (h));
h.data = data;
pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
transparent_color,
mem_buffer, &h);
return pixmap;
}
GdkPixmap*
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data)
{
return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
transparent_color, data);
}
GdkPixmap*
gdk_pixmap_foreign_new (guint32 anid)
gdk_pixmap_foreign_new (GdkNativeWindow anid)
{
GdkPixmap *pixmap;
GdkDrawablePrivate *private;
HBITMAP xpixmap;
GdkDrawableImplWin32 *draw_impl;
GdkPixmapImplWin32 *pix_impl;
HBITMAP hbitmap;
SIZE size;
unsigned int x_ret, y_ret, w_ret, h_ret, bw_ret, depth_ret;
/* check to make sure we were passed something at
least a little sane */
g_return_val_if_fail((anid != 0), NULL);
/* check to make sure we were passed a HBITMAP */
g_return_val_if_fail(GetObjectType ((HGDIOBJ) anid) == OBJ_BITMAP, NULL);
/* set the pixmap to the passed in value */
xpixmap = (HBITMAP) anid;
hbitmap = (HBITMAP) anid;
/* get information about the BITMAP to fill in the structure for
/* get information about the bitmap to fill in the structure for
the gdk window */
GetBitmapDimensionEx (xpixmap, &size);
GetBitmapDimensionEx (hbitmap, &size);
w_ret = size.cx;
h_ret = size.cy;
/* allocate a new gdk pixmap */
pixmap = gdk_win32_pixmap_alloc ();
private = (GdkDrawablePrivate *) pixmap;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
pix_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
draw_impl->wrapper = GDK_DRAWABLE (pixmap);
draw_impl->handle = hbitmap;
draw_impl->colormap = NULL;
pix_impl->width = w_ret;
pix_impl->height = h_ret;
GDK_DRAWABLE_WIN32DATA (pixmap)->xid = xpixmap;
private->colormap = NULL;
private->width = w_ret;
private->height = h_ret;
gdk_xid_table_insert(&GDK_DRAWABLE_XID (pixmap), pixmap);
gdk_win32_handle_table_insert (GDK_PIXMAP_HBITMAP (pixmap), pixmap);
return pixmap;
}

View File

@ -30,21 +30,15 @@
#include <gdk/gdkprivate.h>
#include "gdkwin32.h"
void gdk_xid_table_insert (HANDLE *hnd,
gpointer data);
void gdk_xid_table_remove (HANDLE xid);
void gdk_win32_handle_table_insert (HANDLE handle,
gpointer data);
void gdk_win32_handle_table_remove (HANDLE handle);
GdkGC * _gdk_win32_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
COLORREF gdk_colormap_color (GdkColormapPrivateWin32 *colormap_private,
gulong pixel);
HDC gdk_gc_predraw (GdkDrawable *drawable,
GdkGCWin32 *gcwin32,
GdkGCValuesMask usage);
void gdk_gc_postdraw (GdkDrawable *drawable,
GdkGCWin32 *gcwin32,
GdkGCValuesMask usage);
COLORREF gdk_colormap_color (GdkColormap *colormap,
gulong pixel);
HRGN BitmapToRegion (HBITMAP hBmp);
gchar *gdk_font_full_name_get (GdkFont *font);
@ -95,7 +89,6 @@ void gdk_win32_api_failed (const gchar *where,
extern LRESULT CALLBACK gdk_window_procedure (HWND, UINT, WPARAM, LPARAM);
extern GdkDrawableClass _gdk_win32_drawable_class;
extern HWND gdk_root_window;
extern gboolean gdk_event_func_from_window_proc;
@ -111,6 +104,8 @@ extern GdkAtom gdk_win32_dropfiles_atom;
extern GdkAtom gdk_ole2_dnd_atom;
extern DWORD windows_version;
#define IS_WIN_NT(dwVersion) (dwVersion < 0x80000000)
#define IS_WIN_NT() (windows_version < 0x80000000)
extern gint gdk_input_ignore_wintab;
#endif /* __GDK_PRIVATE_WIN32_H__ */

View File

@ -32,6 +32,8 @@
#include "gdkselection.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
#include "gdkdrawable-win32.h"
#include "gdkwindow-win32.h"
GdkAtom
gdk_atom_intern (const gchar *atom_name,
@ -122,7 +124,7 @@ gdk_property_get (GdkWindow *window,
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_WINDOW_DESTROYED (window))
return FALSE;
g_warning ("gdk_property_get: Not implemented");
@ -147,14 +149,14 @@ gdk_property_change (GdkWindow *window,
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_DRAWABLE_DESTROYED (window))
if (GDK_WINDOW_DESTROYED (window))
return;
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",
GDK_DRAWABLE_XID (window), property, prop_name,
GDK_WINDOW_HWND (window), property, prop_name,
type, type_name,
(mode == GDK_PROP_MODE_REPLACE ? "REPLACE" :
(mode == GDK_PROP_MODE_PREPEND ? "PREPEND" :
@ -175,8 +177,8 @@ gdk_property_change (GdkWindow *window,
length++;
#if 1
GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n",
GDK_DRAWABLE_XID (window)));
if (!OpenClipboard (GDK_DRAWABLE_XID (window)))
GDK_WINDOW_HWND (window)));
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
{
WIN32_API_FAILED ("OpenClipboard");
return;
@ -221,7 +223,7 @@ gdk_property_delete (GdkWindow *window,
GDK_NOTE (MISC,
(prop_name = gdk_atom_name (property),
g_print ("gdk_property_delete: %#x %#x (%s)\n",
(window ? GDK_DRAWABLE_XID (window) : 0),
(window ? GDK_WINDOW_HWND (window) : 0),
property, prop_name),
g_free (prop_name)));

View File

@ -33,6 +33,7 @@
#include "gdkinternals.h"
#include "gdkprivate.h"
#include "gdkprivate-win32.h"
#include "gdkwindow-win32.h"
/* We emulate the GDK_SELECTION window properties by storing
* it's data in a per-window hashtable.
@ -63,18 +64,18 @@ gdk_sel_prop_store (GdkWindow *owner,
{
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (owner));
prop = g_hash_table_lookup (sel_prop_table, &GDK_WINDOW_HWND (owner));
if (prop != NULL)
{
g_free (prop->data);
g_hash_table_remove (sel_prop_table, &GDK_DRAWABLE_XID (owner));
g_hash_table_remove (sel_prop_table, &GDK_WINDOW_HWND (owner));
}
prop = g_new (GdkSelProp, 1);
prop->data = data;
prop->length = length;
prop->format = format;
prop->type = type;
g_hash_table_insert (sel_prop_table, &GDK_DRAWABLE_XID (owner), prop);
g_hash_table_insert (sel_prop_table, &GDK_WINDOW_HWND (owner), prop);
}
gboolean
@ -89,7 +90,7 @@ gdk_selection_owner_set (GdkWindow *owner,
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),
(owner ? GDK_WINDOW_HWND (owner) : 0),
selection, sel_name),
g_free (sel_name)));
@ -97,7 +98,7 @@ gdk_selection_owner_set (GdkWindow *owner,
return FALSE;
if (owner != NULL)
xwindow = GDK_DRAWABLE_XID (owner);
xwindow = GDK_WINDOW_HWND (owner);
else
xwindow = NULL;
@ -153,7 +154,7 @@ gdk_selection_owner_get (GdkAtom selection)
if (selection != gdk_clipboard_atom)
window = NULL;
else
window = gdk_window_lookup (GetClipboardOwner ());
window = gdk_win32_handle_table_lookup (GetClipboardOwner ());
#endif
@ -161,7 +162,7 @@ gdk_selection_owner_get (GdkAtom selection)
(sel_name = gdk_atom_name (selection),
g_print ("gdk_selection_owner_get: %#x (%s) = %#x\n",
selection, sel_name,
(window ? GDK_DRAWABLE_XID (window) : 0)),
(window ? GDK_WINDOW_HWND (window) : 0)),
g_free (sel_name)));
return window;
@ -180,14 +181,14 @@ gdk_selection_convert (GdkWindow *requestor,
gchar *sel_name, *tgt_name;
g_return_if_fail (requestor != NULL);
if (GDK_DRAWABLE_DESTROYED (requestor))
if (GDK_WINDOW_DESTROYED (requestor))
return;
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",
GDK_DRAWABLE_XID (requestor), selection, sel_name, target, tgt_name),
GDK_WINDOW_HWND (requestor), selection, sel_name, target, tgt_name),
g_free (sel_name),
g_free (tgt_name)));
@ -198,8 +199,8 @@ gdk_selection_convert (GdkWindow *requestor,
* and store it for later.
*/
GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n",
GDK_DRAWABLE_XID (requestor)));
if (!OpenClipboard (GDK_DRAWABLE_XID (requestor)))
GDK_WINDOW_HWND (requestor)));
if (!OpenClipboard (GDK_WINDOW_HWND (requestor)))
{
WIN32_API_FAILED ("OpenClipboard");
return;
@ -250,7 +251,7 @@ gdk_selection_convert (GdkWindow *requestor,
/* Send ourselves an ersatz selection notify message so that we actually
* fetch the data.
*/
SendMessage (GDK_DRAWABLE_XID (requestor), gdk_selection_notify_msg, selection, target);
SendMessage (GDK_WINDOW_HWND (requestor), gdk_selection_notify_msg, selection, target);
}
else if (selection == gdk_win32_dropfiles_atom)
{
@ -261,16 +262,16 @@ gdk_selection_convert (GdkWindow *requestor,
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table,
&GDK_DRAWABLE_XID (gdk_parent_root));
&GDK_WINDOW_HWND (gdk_parent_root));
if (prop != NULL)
{
g_hash_table_remove (sel_prop_table,
&GDK_DRAWABLE_XID (gdk_parent_root));
&GDK_WINDOW_HWND (gdk_parent_root));
gdk_sel_prop_store (requestor, prop->type, prop->format,
prop->data, prop->length);
g_free (prop);
SendMessage (GDK_DRAWABLE_XID (requestor), gdk_selection_notify_msg, selection, target);
SendMessage (GDK_WINDOW_HWND (requestor), gdk_selection_notify_msg, selection, target);
}
}
else
@ -290,13 +291,13 @@ gdk_selection_property_get (GdkWindow *requestor,
g_return_val_if_fail (requestor != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
if (GDK_DRAWABLE_DESTROYED (requestor))
if (GDK_WINDOW_DESTROYED (requestor))
return 0;
GDK_NOTE (MISC, g_print ("gdk_selection_property_get: %#x\n",
GDK_DRAWABLE_XID (requestor)));
GDK_WINDOW_HWND (requestor)));
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (requestor));
prop = g_hash_table_lookup (sel_prop_table, &GDK_WINDOW_HWND (requestor));
if (prop == NULL)
{
@ -319,11 +320,11 @@ gdk_selection_property_delete (GdkWindow *window)
{
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (window));
prop = g_hash_table_lookup (sel_prop_table, &GDK_WINDOW_HWND (window));
if (prop != NULL)
{
g_free (prop->data);
g_hash_table_remove (sel_prop_table, &GDK_DRAWABLE_XID (window));
g_hash_table_remove (sel_prop_table, &GDK_WINDOW_HWND (window));
}
else
g_warning ("huh?");

View File

@ -188,7 +188,6 @@ typedef struct {
unsigned long base_pixel;
} XStandardColormap;
typedef struct _GdkGCWin32Data GdkGCWin32Data;
typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
@ -295,10 +294,11 @@ GType gdk_gc_win32_get_type (void);
#define GDK_ROOT_WINDOW() ((guint32) HWND_DESKTOP)
#define GDK_ROOT_PARENT() ((GdkWindow *) gdk_parent_root)
#define GDK_DISPLAY() NULL
#define GDK_WINDOW_HWND(win) (HWND) (GDK_DRAWABLE_IMPL_WIN32(((GdkWindowObject *)win)->impl)->handle)
#define GDK_PIXMAP_HBITMAP(win) (HBITMAP) (GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)win)->impl)->handle)
#define GDK_DRAWABLE_HANDLE(win) (GDK_IS_WINDOW (win) ? ((HGDIOBJ) GDK_WINDOW_HWND (win)) : ((HGDIOBJ) GDK_PIXMAP_HBITMAP (win)))
#define GDK_WINDOW_HWND(win) (GDK_DRAWABLE_IMPL_WIN32(((GdkWindowObject *)win)->impl)->handle)
#define GDK_PIXMAP_HBITMAP(pixmap) (GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)pixmap)->impl)->handle)
#define GDK_DRAWABLE_HANDLE(win) (GDK_IS_WINDOW (win) ? (GDK_WINDOW_HWND (win)) : (GDK_PIXMAP_HBITMAP (win)))
#define GDK_IMAGE_HBM(image) (((GdkImagePrivateWin32 *) GDK_IMAGE (image)->windowing_data)->hbm)
#define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateWin32 *) cmap->windowing_data)
#define GDK_COLORMAP_WIN32COLORMAP(cmap) (((GdkColormapPrivateWin32 *)GDK_COLORMAP (cmap)->windowing_data)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate *) vis)->xvisual)
@ -310,7 +310,7 @@ GdkPixmap *gdk_pixmap_foreign_new (guint32 anid);
GdkWindow *gdk_window_foreign_new (guint32 anid);
/* Return the Gdk* for a particular HANDLE */
gpointer gdk_xid_table_lookup (HANDLE handle);
gpointer gdk_win32_handle_table_lookup (HANDLE handle);
/* Return a device context to draw in a drawable, given a GDK GC,
* and a mask indicating which GC values might be used (for efficiency,

View File

@ -24,65 +24,56 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <stdio.h>
#include <gdk/gdk.h>
#include "gdkprivate-win32.h"
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 (HANDLE *xid,
gpointer data)
{
g_return_if_fail (xid != NULL);
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_insert (xid_ht, xid, data);
}
void
gdk_xid_table_remove (HANDLE xid)
{
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_remove (xid_ht, &xid);
}
gpointer
gdk_xid_table_lookup (HANDLE xid)
{
gpointer data = NULL;
if (xid_ht)
data = g_hash_table_lookup (xid_ht, &xid);
return data;
}
static GHashTable *handle_ht = NULL;
static guint
gdk_xid_hash (HANDLE *xid)
gdk_handle_hash (HANDLE *handle)
{
return (guint) *xid;
return (guint) *handle;
}
static gint
gdk_xid_compare (HANDLE *a,
gdk_handle_compare (HANDLE *a,
HANDLE *b)
{
return (*a == *b);
}
/* Note that the handle is passed by value to this function! */
void
gdk_win32_handle_table_insert (HANDLE handle,
gpointer data)
{
g_return_if_fail (handle != NULL);
if (!handle_ht)
handle_ht = g_hash_table_new ((GHashFunc) gdk_handle_hash,
(GCompareFunc) gdk_handle_compare);
g_hash_table_insert (handle_ht, &handle, data);
}
void
gdk_win32_handle_table_remove (HANDLE handle)
{
if (!handle_ht)
handle_ht = g_hash_table_new ((GHashFunc) gdk_handle_hash,
(GCompareFunc) gdk_handle_compare);
g_hash_table_remove (handle_ht, &handle);
}
gpointer
gdk_win32_handle_table_lookup (HANDLE handle)
{
gpointer data = NULL;
if (handle_ht)
data = g_hash_table_lookup (handle_ht, &handle);
return data;
}

File diff suppressed because it is too large Load Diff

View File

@ -77,18 +77,6 @@ struct _GdkWindowImplWin32
/* We must keep the event mask here to filter them ourselves */
gint event_mask;
/* Values for bg_type */
#define GDK_WIN32_BG_NORMAL 0
#define GDK_WIN32_BG_PIXEL 1
#define GDK_WIN32_BG_PIXMAP 2
#define GDK_WIN32_BG_PARENT_RELATIVE 3
#define GDK_WIN32_BG_TRANSPARENT 4
/* We draw the background ourselves at WM_ERASEBKGND */
guchar bg_type;
gulong bg_pixel;
GdkPixmap *bg_pixmap;
HCURSOR hcursor;
/* Window size hints */

View File

@ -17,7 +17,7 @@ OPTIMIZE = -g
INCLUDES = -I ../.. -I .. -I $(WTKIT)/include
DEPCFLAGS = $(GLIB_CFLAGS) $(PANGO_CFLAGS)
DEFINES = -DG_ENABLE_DEBUG -DHAVE_CONFIG_H -DGDK_VERSION=\"$(GTK_VER)\"
DEFINES = -DG_ENABLE_DEBUG -DHAVE_CONFIG_H -DGDK_VERSION=\"$(GTK_VER)\" -DGDK_COMPILATION
all: \
../../config.h \
@ -39,6 +39,7 @@ gdk_win32_OBJECTS = \
gdkglobals-win32.o \
gdkim-win32.o \
gdkimage-win32.o \
gdkinput.o \
gdkinput-win32.o \
gdkmain-win32.o \
gdkpixmap-win32.o \

View File

@ -218,8 +218,8 @@ EXPORTS
gtk_calendar_freeze
gtk_calendar_get_date
gtk_calendar_get_type
gtk_calendar_new
gtk_calendar_mark_day
gtk_calendar_new
gtk_calendar_select_day
gtk_calendar_select_month
gtk_calendar_thaw
@ -298,7 +298,6 @@ EXPORTS
gtk_clist_set_selection_mode
gtk_clist_set_shadow_type
gtk_clist_set_shift
gtk_ctree_set_show_stub
gtk_clist_set_sort_column
gtk_clist_set_sort_type
gtk_clist_set_text
@ -418,6 +417,7 @@ EXPORTS
gtk_ctree_set_indent
gtk_ctree_set_line_style
gtk_ctree_set_node_info
gtk_ctree_set_show_stub
gtk_ctree_set_spacing
gtk_ctree_sort_node
gtk_ctree_sort_recursive
@ -447,8 +447,8 @@ EXPORTS
gtk_drag_highlight
gtk_drag_set_default_icon
gtk_drag_set_icon_default
gtk_drag_set_icon_widget
gtk_drag_set_icon_pixmap
gtk_drag_set_icon_widget
gtk_drag_source_handle_event
gtk_drag_source_set
gtk_drag_source_set_icon
@ -695,8 +695,8 @@ EXPORTS
gtk_marshal_NONE__POINTER
gtk_marshal_NONE__POINTER_INT
gtk_marshal_NONE__POINTER_INT_INT
gtk_marshal_NONE__POINTER_INT_POINTER
gtk_marshal_NONE__POINTER_INT_INT_POINTER_INT_INT
gtk_marshal_NONE__POINTER_INT_POINTER
gtk_marshal_NONE__POINTER_POINTER
gtk_marshal_NONE__POINTER_POINTER_INT_INT
gtk_marshal_NONE__POINTER_POINTER_POINTER
@ -854,13 +854,13 @@ EXPORTS
gtk_paint_focus
gtk_paint_handle
gtk_paint_hline
gtk_paint_oval
gtk_paint_option
gtk_paint_oval
gtk_paint_polygon
gtk_paint_ramp
gtk_paint_slider
gtk_paint_shadow
gtk_paint_shadow_gap
gtk_paint_slider
gtk_paint_string
gtk_paint_tab
gtk_paint_vline
@ -967,8 +967,8 @@ EXPORTS
gtk_rc_find_pixmap_in_path
gtk_rc_get_default_files
gtk_rc_get_module_dir
gtk_rc_get_theme_dir
gtk_rc_get_style
gtk_rc_get_theme_dir
gtk_rc_init
gtk_rc_load_image
gtk_rc_parse
@ -1053,9 +1053,9 @@ EXPORTS
gtk_signal_name
gtk_signal_new
gtk_signal_newv
gtk_signal_set_funcs
gtk_signal_query
gtk_signal_remove_emission_hook
gtk_signal_set_funcs
gtk_socket_get_type
gtk_socket_new
gtk_socket_steal
@ -1320,6 +1320,7 @@ EXPORTS
gtk_widget_unparent
gtk_widget_unrealize
gtk_widget_unref
gtk_win32_get_installation_directory
gtk_window_activate_default
gtk_window_activate_focus
gtk_window_add_accel_group

View File

@ -255,35 +255,35 @@ static GtkImageLoader image_loader = NULL;
#ifdef G_OS_WIN32
gchar *
get_gtk_sysconf_directory (void)
gtk_win32_get_installation_directory (void)
{
static gboolean been_here = FALSE;
static gchar gtk_sysconf_dir[200];
static gchar gtk_installation_dir[200];
gchar win_dir[100];
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes = sizeof (gtk_sysconf_dir);
DWORD nbytes = sizeof (gtk_installation_dir);
if (been_here)
return gtk_sysconf_dir;
return gtk_installation_dir;
been_here = TRUE;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\GNU\\GTk+", 0,
KEY_QUERY_VALUE, &reg_key) != ERROR_SUCCESS
|| RegQueryValueEx (reg_key, "InstallationDirectory", 0,
&type, gtk_sysconf_dir, &nbytes) != ERROR_SUCCESS
&type, gtk_installation_dir, &nbytes) != ERROR_SUCCESS
|| type != REG_SZ)
{
/* Uh oh. Use the old hard-coded %WinDir%\GTk+ value */
GetWindowsDirectory (win_dir, sizeof (win_dir));
sprintf (gtk_sysconf_dir, "%s\\gtk+", win_dir);
sprintf (gtk_installation_dir, "%s\\gtk+", win_dir);
}
if (reg_key != NULL)
RegCloseKey (reg_key);
return gtk_sysconf_dir;
return gtk_installation_dir;
}
static gchar *
@ -291,7 +291,7 @@ get_themes_directory (void)
{
static gchar themes_dir[200];
sprintf (themes_dir, "%s\\themes", get_gtk_sysconf_directory ());
sprintf (themes_dir, "%s\\themes", gtk_win32_get_installation_directory ());
return themes_dir;
}
@ -398,7 +398,7 @@ gtk_rc_add_initial_default_files (void)
#ifndef G_OS_WIN32
str = g_strdup (GTK_SYSCONFDIR G_DIR_SEPARATOR_S "gtk-2.0" G_DIR_SEPARATOR_S "gtkrc");
#else
str = g_strdup_printf ("%s\\gtkrc", get_gtk_sysconf_directory ());
str = g_strdup_printf ("%s\\gtkrc", gtk_win32_get_installation_directory ());
#endif
gtk_rc_add_default_file (str);

View File

@ -186,6 +186,11 @@ guint gtk_rc_parse_state (GScanner *scanner,
guint gtk_rc_parse_priority (GScanner *scanner,
GtkPathPriorityType *priority);
#ifdef G_OS_WIN32
gchar *gtk_win32_get_installation_directory (void);
#endif
#ifdef __cplusplus