* Copyright (C) 1998-1999 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser 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.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser 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
+ * Modified by the GTK+ Team and others 1997-2000. 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/.
*/
-#include "config.h"
-
#include <stdlib.h>
-#include <stdio.h>
#include "gdkevents.h"
#include "gdkpixmap.h"
#include "gdkwindow.h"
#include "gdkinternals.h"
-#include "gdkprivate.h"
#include "gdkprivate-win32.h"
-#include "gdkinputprivate.h"
-#include "gdkwin32.h"
+#include "gdkinput-win32.h"
static gboolean gdk_window_gravity_works (void);
static void gdk_window_set_static_win_gravity (GdkWindow *window,
gboolean on);
-/* The Win API function AdjustWindowRect may return negative values
- * resulting in obscured title bars. This helper function is coreccting it.
- */
-BOOL
-SafeAdjustWindowRectEx (RECT* lpRect,
- DWORD dwStyle,
- BOOL bMenu,
- DWORD dwExStyle)
+static GdkColormap* gdk_window_impl_win32_get_colormap (GdkDrawable *drawable);
+static void gdk_window_impl_win32_set_colormap (GdkDrawable *drawable,
+ GdkColormap *cmap);
+static void gdk_window_impl_win32_get_size (GdkDrawable *drawable,
+ gint *width,
+ gint *height);
+static GdkRegion* gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable);
+static void gdk_window_impl_win32_init (GdkWindowImplWin32 *window);
+static void gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass);
+static void gdk_window_impl_win32_finalize (GObject *object);
+
+static gpointer parent_class = NULL;
+
+GType
+gdk_window_impl_win32_get_type (void)
{
- if (!AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle))
- {
- WIN32_API_FAILED ("AdjustWindowRectEx");
- return FALSE;
- }
- if (lpRect->left < 0)
- {
- lpRect->right -= lpRect->left;
- lpRect->left = 0;
- }
- if (lpRect->top < 0)
+ static GType object_type = 0;
+
+ if (!object_type)
{
- lpRect->bottom -= lpRect->top;
- lpRect->top = 0;
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkWindowImplWin32Class),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gdk_window_impl_win32_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkWindowImplWin32),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gdk_window_impl_win32_init,
+ };
+
+ object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_WIN32,
+ "GdkWindowImplWin32",
+ &object_info, 0);
}
- return TRUE;
+
+ return object_type;
+}
+
+GType
+_gdk_window_impl_get_type (void)
+{
+ return gdk_window_impl_win32_get_type ();
}
-GdkDrawableClass _gdk_windowing_window_class;
+static void
+gdk_window_impl_win32_init (GdkWindowImplWin32 *impl)
+{
+ impl->width = 1;
+ impl->height = 1;
+
+ impl->event_mask = 0;
+ impl->hcursor = NULL;
+ impl->hint_flags = 0;
+ impl->extension_events_selected = FALSE;
+ impl->input_locale = GetKeyboardLayout (0);
+ TranslateCharsetInfo ((DWORD FAR *) GetACP (), &impl->charset_info,
+ TCI_SRCCODEPAGE);
+}
static void
-gdk_win32_window_destroy (GdkDrawable *drawable)
+gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass)
{
- if (!GDK_DRAWABLE_DESTROYED (drawable))
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = gdk_window_impl_win32_finalize;
+
+ drawable_class->set_colormap = gdk_window_impl_win32_set_colormap;
+ drawable_class->get_colormap = gdk_window_impl_win32_get_colormap;
+ drawable_class->get_size = gdk_window_impl_win32_get_size;
+
+ /* Visible and clip regions are the same */
+ drawable_class->get_clip_region = gdk_window_impl_win32_get_visible_region;
+ drawable_class->get_visible_region = gdk_window_impl_win32_get_visible_region;
+}
+
+static void
+gdk_window_impl_win32_finalize (GObject *object)
+{
+ GdkWindowObject *wrapper;
+ GdkDrawableImplWin32 *draw_impl;
+ GdkWindowImplWin32 *window_impl;
+
+ g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (object));
+
+ draw_impl = GDK_DRAWABLE_IMPL_WIN32 (object);
+ window_impl = GDK_WINDOW_IMPL_WIN32 (object);
+
+ wrapper = (GdkWindowObject*) draw_impl->wrapper;
+
+ if (!GDK_WINDOW_DESTROYED (wrapper))
{
- if (GDK_DRAWABLE_TYPE (drawable) == GDK_WINDOW_FOREIGN)
- gdk_xid_table_remove (GDK_DRAWABLE_XID (drawable));
- else
- g_warning ("losing last reference to undestroyed window\n");
+ gdk_win32_handle_table_remove (draw_impl->handle);
}
- if (GDK_WINDOW_WIN32DATA (drawable)->bg_type == GDK_WIN32_BG_PIXMAP
- && GDK_WINDOW_WIN32DATA (drawable)->bg_pixmap != NULL)
- gdk_drawable_unref (GDK_WINDOW_WIN32DATA (drawable)->bg_pixmap);
+ if (window_impl->hcursor != NULL)
+ {
+ if (!DestroyCursor (window_impl->hcursor))
+ WIN32_GDI_FAILED("DestroyCursor");
+ window_impl->hcursor = NULL;
+ }
- g_free (GDK_DRAWABLE_WIN32DATA (drawable));
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static GdkWindow *
-gdk_win32_window_alloc (void)
+static GdkColormap*
+gdk_window_impl_win32_get_colormap (GdkDrawable *drawable)
{
- GdkWindow *window;
- GdkWindowPrivate *private;
+ GdkDrawableImplWin32 *drawable_impl;
+ GdkWindowImplWin32 *window_impl;
- static gboolean initialized = FALSE;
+ g_return_val_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable), NULL);
+
+ drawable_impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+ window_impl = GDK_WINDOW_IMPL_WIN32 (drawable);
- if (!initialized)
+ if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
+ drawable_impl->colormap == NULL)
{
- initialized = TRUE;
-
- _gdk_windowing_window_class = _gdk_win32_drawable_class;
- _gdk_win32_drawable_class.destroy = gdk_win32_window_destroy;
+ drawable_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (drawable_impl->colormap);
}
+
+ return drawable_impl->colormap;
+}
- window = _gdk_window_alloc ();
- private = (GdkWindowPrivate *) window;
+static void
+gdk_window_impl_win32_set_colormap (GdkDrawable *drawable,
+ GdkColormap *cmap)
+{
+ GdkWindowImplWin32 *impl;
+ GdkDrawableImplWin32 *draw_impl;
+
+ g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable));
+ g_return_if_fail (gdk_colormap_get_visual (cmap) != gdk_drawable_get_visual (drawable));
- private->drawable.klass = &_gdk_windowing_window_class;
- private->drawable.klass_data = g_new (GdkWindowWin32Data, 1);
+ impl = GDK_WINDOW_IMPL_WIN32 (drawable);
+ draw_impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- GDK_WINDOW_WIN32DATA (window)->event_mask = 0;
- GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_NORMAL;
- GDK_WINDOW_WIN32DATA (window)->xcursor = NULL;
- GDK_WINDOW_WIN32DATA (window)->hint_flags = 0;
- GDK_WINDOW_WIN32DATA (window)->extension_events_selected = FALSE;
+ GDK_DRAWABLE_GET_CLASS (draw_impl)->set_colormap (drawable, cmap);
- GDK_WINDOW_WIN32DATA (window)->input_locale = GetKeyboardLayout (0);
- TranslateCharsetInfo ((DWORD FAR *) GetACP (),
- &GDK_WINDOW_WIN32DATA (window)->charset_info,
- TCI_SRCCODEPAGE);
+ /* XXX */
+ g_print("gdk_window_impl_win32_set_colormap: XXX\n");
+}
- return window;
+static void
+gdk_window_impl_win32_get_size (GdkDrawable *drawable,
+ gint *width,
+ gint *height)
+{
+ g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable));
+
+ if (width)
+ *width = GDK_WINDOW_IMPL_WIN32 (drawable)->width;
+ if (height)
+ *height = GDK_WINDOW_IMPL_WIN32 (drawable)->height;
+}
+
+static GdkRegion*
+gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable)
+{
+ GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (drawable);
+ GdkRectangle result_rect;
+
+ result_rect.x = 0;
+ result_rect.y = 0;
+ result_rect.width = impl->width;
+ result_rect.height = impl->height;
+
+ gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
+
+ return gdk_region_rectangle (&result_rect);
}
void
-gdk_window_init (void)
+_gdk_windowing_window_init (void)
{
- GdkWindowPrivate *private;
- RECT r;
+ GdkWindowObject *private;
+ GdkWindowImplWin32 *impl;
+ GdkDrawableImplWin32 *draw_impl;
+ RECT rect;
guint width;
guint height;
- SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
- width = r.right - r.left;
- height = r.bottom - r.top;
-
- gdk_parent_root = gdk_win32_window_alloc ();
- private = (GdkWindowPrivate *) gdk_parent_root;
+ g_assert (gdk_parent_root == NULL);
+
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
+
+ gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL);
+ private = (GdkWindowObject *)gdk_parent_root;
+ impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+ draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
+
+ draw_impl->handle = gdk_root_window;
+ draw_impl->wrapper = GDK_DRAWABLE (private);
- GDK_DRAWABLE_WIN32DATA (gdk_parent_root)->xid = gdk_root_window;
- private->drawable.window_type = GDK_WINDOW_ROOT;
- private->drawable.width = width;
- private->drawable.height = height;
+ private->window_type = GDK_WINDOW_ROOT;
+ private->depth = gdk_visual_get_system ()->depth;
+ impl->width = width;
+ impl->height = height;
- gdk_xid_table_insert (&gdk_root_window, gdk_parent_root);
+ gdk_win32_handle_table_insert (&gdk_root_window, gdk_parent_root);
+}
+
+/* The Win API function AdjustWindowRect may return negative values
+ * resulting in obscured title bars. This helper function is coreccting it.
+ */
+BOOL
+SafeAdjustWindowRectEx (RECT* lpRect,
+ DWORD dwStyle,
+ BOOL bMenu,
+ DWORD dwExStyle)
+{
+ if (!AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle))
+ {
+ WIN32_API_FAILED ("AdjustWindowRectEx");
+ return FALSE;
+ }
+ if (lpRect->left < 0)
+ {
+ lpRect->right -= lpRect->left;
+ lpRect->left = 0;
+ }
+ if (lpRect->top < 0)
+ {
+ lpRect->bottom -= lpRect->top;
+ lpRect->top = 0;
+ }
+ return TRUE;
}
/* RegisterGdkClass
* get its own class
*/
ATOM
-RegisterGdkClass (GdkDrawableType wtype)
+RegisterGdkClass (GdkWindowType wtype)
{
static ATOM klassTOPLEVEL = 0;
static ATOM klassDIALOG = 0;
wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
* on WM_SIZE and WM_MOVE. Flicker, Performance!
*/
- wcl.lpfnWndProc = gdk_WindowProc;
+ wcl.lpfnWndProc = gdk_window_procedure;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = gdk_ProgInstance;
+ wcl.hInstance = gdk_app_hmodule;
wcl.hIcon = 0;
/* initialize once! */
if (0 == hAppIcon)
{
gchar sLoc [_MAX_PATH+1];
- HINSTANCE hInst = GetModuleHandle(NULL);
- if (0 != GetModuleFileName(hInst, sLoc, _MAX_PATH))
+ if (0 != GetModuleFileName (gdk_app_hmodule, sLoc, _MAX_PATH))
{
- hAppIcon = ExtractIcon(hInst, sLoc, 0);
+ hAppIcon = ExtractIcon (gdk_app_hmodule, sLoc, 0);
if (0 == hAppIcon)
{
char *gdklibname = g_strdup_printf ("gdk-%s.dll", GDK_VERSION);
- hAppIcon = ExtractIcon(hInst, gdklibname, 0);
+ hAppIcon = ExtractIcon (gdk_app_hmodule, gdklibname, 0);
g_free (gdklibname);
}
#define ONCE_PER_CLASS() \
wcl.hIcon = CopyIcon (hAppIcon); \
wcl.hIconSm = CopyIcon (hAppIcon); \
- wcl.hbrBackground = CreateSolidBrush( RGB(0,0,0)); \
+ wcl.hbrBackground = CreateSolidBrush (RGB (0,0,0)); \
wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
switch (wtype)
{
- case GDK_WINDOW_TOPLEVEL:
- if (0 == klassTOPLEVEL)
+ case GDK_WINDOW_TOPLEVEL:
+ if (0 == klassTOPLEVEL)
{
wcl.lpszClassName = "gdkWindowToplevel";
-
+
ONCE_PER_CLASS();
- klassTOPLEVEL = RegisterClassEx(&wcl);
+ klassTOPLEVEL = RegisterClassEx (&wcl);
}
- klass = klassTOPLEVEL;
- break;
+ klass = klassTOPLEVEL;
+ break;
+
case GDK_WINDOW_CHILD:
if (0 == klassCHILD)
- {
- wcl.lpszClassName = "gdkWindowChild";
-
- wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */
- ONCE_PER_CLASS();
- klassCHILD = RegisterClassEx(&wcl);
- }
+ {
+ wcl.lpszClassName = "gdkWindowChild";
+
+ wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */
+ ONCE_PER_CLASS();
+ klassCHILD = RegisterClassEx (&wcl);
+ }
klass = klassCHILD;
break;
- case GDK_WINDOW_DIALOG:
- if (0 == klassDIALOG)
+
+ case GDK_WINDOW_DIALOG:
+ if (0 == klassDIALOG)
{
wcl.lpszClassName = "gdkWindowDialog";
wcl.style |= CS_SAVEBITS;
ONCE_PER_CLASS();
- klassDIALOG = RegisterClassEx(&wcl);
+ klassDIALOG = RegisterClassEx (&wcl);
}
- klass = klassDIALOG;
- break;
- case GDK_WINDOW_TEMP:
- if (0 == klassTEMP)
+ klass = klassDIALOG;
+ break;
+
+ case GDK_WINDOW_TEMP:
+ if (0 == klassTEMP)
{
wcl.lpszClassName = "gdkWindowTemp";
wcl.style |= CS_SAVEBITS;
ONCE_PER_CLASS();
- klassTEMP = RegisterClassEx(&wcl);
+ klassTEMP = RegisterClassEx (&wcl);
}
- klass = klassTEMP;
- break;
- case GDK_WINDOW_ROOT:
- g_error ("cannot make windows of type GDK_WINDOW_ROOT");
- break;
- case GDK_DRAWABLE_PIXMAP:
- g_error ("cannot make windows of type GDK_DRAWABLE_PIXMAP (use gdk_pixmap_new)");
- break;
+ klass = klassTEMP;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
}
if (klass == 0)
gint attributes_mask)
{
GdkWindow *window;
- GdkWindowPrivate *private;
- GdkWindowPrivate *parent_private;
+ GdkWindowObject *private;
+ GdkWindowObject *parent_private;
+ GdkWindowImplWin32 *impl;
+ GdkDrawableImplWin32 *draw_impl;
+
GdkVisual *visual;
- HANDLE xparent;
- Visual *xvisual;
+
+ HANDLE hparent;
ATOM klass = 0;
DWORD dwStyle, dwExStyle;
RECT rect;
+ Visual *xvisual;
+
int width, height;
int x, y;
char *title;
- gint titlelen;
- wchar_t *wctitle;
- gint wlen;
char *mbtitle;
g_return_val_if_fail (attributes != NULL, NULL);
if (!parent)
parent = gdk_parent_root;
- parent_private = (GdkWindowPrivate*) parent;
- if (GDK_DRAWABLE_DESTROYED (parent))
+ g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
+
+ GDK_NOTE (MISC,
+ g_print ("gdk_window_new: %s\n",
+ (attributes->window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :
+ (attributes->window_type == GDK_WINDOW_CHILD ? "CHILD" :
+ (attributes->window_type == GDK_WINDOW_DIALOG ? "DIALOG" :
+ (attributes->window_type == GDK_WINDOW_TEMP ? "TEMP" :
+ "???"))))));
+
+ parent_private = (GdkWindowObject*) parent;
+ if (GDK_WINDOW_DESTROYED (parent))
return NULL;
+
+ hparent = GDK_WINDOW_HWND (parent);
- xparent = GDK_DRAWABLE_XID (parent);
-
- window = gdk_win32_window_alloc ();
- private = (GdkWindowPrivate *)window;
+ window = g_object_new (GDK_TYPE_WINDOW, NULL);
+ private = (GdkWindowObject *)window;
+ impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+ draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
+ draw_impl->wrapper = GDK_DRAWABLE (window);
- private->parent = parent;
+ private->parent = (GdkWindowObject *)parent;
- private->x = (attributes_mask & GDK_WA_X) ? attributes->x : 0;
- private->y = (attributes_mask & GDK_WA_Y) ? attributes->y : 0;
+ if (attributes_mask & GDK_WA_X)
+ x = attributes->x;
+ else
+ x = CW_USEDEFAULT;
+
+ if (attributes_mask & GDK_WA_Y)
+ y = attributes->y;
+ else if (attributes_mask & GDK_WA_X)
+ y = 100; /* ??? We must put it somewhere... */
+ else
+ y = 0; /* x is CW_USEDEFAULT, y doesn't matter then */
+
+ private->x = x;
+ private->y = y;
+ impl->width = (attributes->width > 1) ? (attributes->width) : (1);
+ impl->height = (attributes->height > 1) ? (attributes->height) : (1);
+ impl->extension_events_selected = FALSE;
+ private->window_type = attributes->window_type;
- private->drawable.width = (attributes->width > 1) ? (attributes->width) : (1);
- private->drawable.height = (attributes->height > 1) ? (attributes->height) : (1);
- private->drawable.window_type = attributes->window_type;
- GDK_WINDOW_WIN32DATA (window)->extension_events_selected = FALSE;
+ _gdk_window_init_position (GDK_WINDOW (private));
+ if (impl->position_info.big)
+ private->guffaw_gravity = TRUE;
if (attributes_mask & GDK_WA_VISUAL)
visual = attributes->visual;
title = attributes->title;
else
title = g_get_prgname ();
- if (!title)
+ if (!title || !*title)
title = "GDK client window";
- GDK_WINDOW_WIN32DATA (window)->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
+ impl->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
if (parent_private && parent_private->guffaw_gravity)
{
if (attributes->wclass == GDK_INPUT_OUTPUT)
{
dwExStyle = 0;
+
+ private->input_only = FALSE;
+ private->depth = visual->depth;
+
if (attributes_mask & GDK_WA_COLORMAP)
- private->drawable.colormap = attributes->colormap;
+ {
+ draw_impl->colormap = attributes->colormap;
+ gdk_colormap_ref (attributes->colormap);
+ }
else
- private->drawable.colormap = gdk_colormap_get_system ();
+ {
+ if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
+ {
+ draw_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (draw_impl->colormap);
+ GDK_NOTE (MISC, g_print ("...using system colormap %p\n",
+ draw_impl->colormap));
+ }
+ else
+ {
+ draw_impl->colormap = gdk_colormap_new (visual, FALSE);
+ GDK_NOTE (MISC, g_print ("...using new colormap %p\n",
+ draw_impl->colormap));
+ }
+ }
}
else
{
dwExStyle = WS_EX_TRANSPARENT;
- private->drawable.colormap = NULL;
- GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_TRANSPARENT;
- GDK_WINDOW_WIN32DATA (window)->bg_pixmap = NULL;
+ private->depth = 0;
+ private->input_only = TRUE;
+ draw_impl->colormap = NULL;
+ GDK_NOTE (MISC, g_print ("...GDK_INPUT_ONLY, NULL colormap\n"));
}
- if (attributes_mask & GDK_WA_X)
- x = attributes->x;
- else
- x = CW_USEDEFAULT;
-
- if (attributes_mask & GDK_WA_Y)
- y = attributes->y;
- else if (attributes_mask & GDK_WA_X)
- y = 100; /* ??? We must put it somewhere... */
- else
- y = 500; /* x is CW_USEDEFAULT, y doesn't matter then */
-
if (parent_private)
parent_private->children = g_list_prepend (parent_private->children, window);
- switch (private->drawable.window_type)
+ switch (private->window_type)
{
case GDK_WINDOW_TOPLEVEL:
dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
- xparent = gdk_root_window;
+ hparent = gdk_root_window;
break;
+
case GDK_WINDOW_CHILD:
dwStyle = WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
break;
+
case GDK_WINDOW_DIALOG:
dwStyle = WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME | WS_CLIPCHILDREN;
#if 0
dwExStyle |= WS_EX_TOPMOST; /* //HB: want this? */
#endif
- xparent = gdk_root_window;
+ hparent = gdk_root_window;
break;
+
case GDK_WINDOW_TEMP:
dwStyle = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
dwExStyle |= WS_EX_TOOLWINDOW;
break;
+
case GDK_WINDOW_ROOT:
g_error ("cannot make windows of type GDK_WINDOW_ROOT");
break;
- case GDK_DRAWABLE_PIXMAP:
- g_error ("cannot make windows of type GDK_DRAWABLE_PIXMAP (use gdk_pixmap_new)");
- break;
}
- klass = RegisterGdkClass (private->drawable.window_type);
+ klass = RegisterGdkClass (private->window_type);
- if (private->drawable.window_type != GDK_WINDOW_CHILD)
+ if (private->window_type != GDK_WINDOW_CHILD)
{
if (x == CW_USEDEFAULT)
{
rect.top = y;
}
- rect.right = rect.left + private->drawable.width;
- rect.bottom = rect.top + private->drawable.height;
+ rect.right = rect.left + impl->width;
+ rect.bottom = rect.top + impl->height;
SafeAdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
}
else
{
- width = private->drawable.width;
- height = private->drawable.height;
+ width = impl->width;
+ height = impl->height;
}
- titlelen = strlen (title);
- wctitle = g_new (wchar_t, titlelen + 1);
- mbtitle = g_new (char, 3*titlelen + 1);
- wlen = gdk_nmbstowchar_ts (wctitle, title, titlelen, titlelen);
- wctitle[wlen] = 0;
- WideCharToMultiByte (GetACP (), 0, wctitle, -1,
- mbtitle, 3*titlelen, NULL, NULL);
+ mbtitle = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
- GDK_DRAWABLE_WIN32DATA (window)->xid =
+#ifdef WITHOUT_WM_CREATE
+ draw_impl->handle = CreateWindowEx (dwExStyle,
+ MAKEINTRESOURCE(klass),
+ mbtitle,
+ dwStyle,
+ x, y,
+ width, height,
+ hparent,
+ NULL,
+ gdk_app_hmodule,
+ NULL);
+#else
+ {
+ HWND hwndNew =
CreateWindowEx (dwExStyle,
MAKEINTRESOURCE(klass),
mbtitle,
dwStyle,
x, y,
width, height,
- xparent,
+ hparent,
NULL,
- gdk_ProgInstance,
- NULL);
+ gdk_app_hmodule,
+ window);
+ if (GDK_WINDOW_HWND (window) != hwndNew)
+ {
+ g_warning("gdk_window_new: gdk_event_translate::WM_CREATE (%#x, %#x) HWND mismatch.",
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) hwndNew);
+
+ /* HB: IHMO due to a race condition the handle was increased by
+ * one, which causes much trouble. Because I can't find the
+ * real bug, try to workaround it ...
+ * To reproduce: compile with MSVC 5, DEBUG=1
+ */
+# if 0
+ gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
+ GDK_WINDOW_HWND (window) = hwndNew;
+ gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
+# else
+ /* the old behaviour, but with warning */
+ GDK_WINDOW_HWND (window) = hwndNew;
+# endif
+
+ }
+ }
+ gdk_drawable_ref (window);
+ gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
+#endif
GDK_NOTE (MISC,
- g_print ("gdk_window_new: %s %s %dx%d@+%d+%d %#x = %#x\n"
- "...locale %#x codepage %d\n",
- (private->drawable.window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :
- (private->drawable.window_type == GDK_WINDOW_CHILD ? "CHILD" :
- (private->drawable.window_type == GDK_WINDOW_DIALOG ? "DIALOG" :
- (private->drawable.window_type == GDK_WINDOW_TEMP ? "TEMP" :
- "???")))),
+ g_print ("... \"%s\" %dx%d@+%d+%d %#x = %#x\n"
+ "... locale %#x codepage %d\n",
mbtitle,
width, height, (x == CW_USEDEFAULT ? -9999 : x), y,
- xparent,
- GDK_DRAWABLE_XID (window),
- GDK_WINDOW_WIN32DATA (window)->input_locale,
- GDK_WINDOW_WIN32DATA (window)->charset_info.ciACP));
+ (guint) hparent,
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) impl->input_locale,
+ (guint) impl->charset_info.ciACP));
g_free (mbtitle);
- g_free (wctitle);
- if (GDK_DRAWABLE_XID (window) == NULL)
+ if (draw_impl->handle == NULL)
{
WIN32_API_FAILED ("CreateWindowEx");
- g_free (GDK_DRAWABLE_WIN32DATA (window));
- g_free (private);
+ g_object_unref ((GObject *) window);
return NULL;
}
+#ifdef WITHOUT_WM_CREATE
gdk_drawable_ref (window);
- gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window);
-
- if (private->drawable.colormap)
- gdk_colormap_ref (private->drawable.colormap);
+ gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
+#endif
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
(attributes->cursor) :
}
GdkWindow *
-gdk_window_foreign_new (guint32 anid)
+gdk_window_foreign_new (GdkNativeWindow anid)
{
GdkWindow *window;
- GdkWindowPrivate *private;
- GdkWindowPrivate *parent_private;
+ GdkWindowObject *private;
+ GdkWindowObject *parent_private;
+ GdkWindowImplWin32 *impl;
+ GdkDrawableImplWin32 *draw_impl;
+
HANDLE parent;
RECT rect;
POINT point;
- window = gdk_win32_window_alloc ();
- private = (GdkWindowPrivate *)window;
-
- parent = GetParent ((HWND) anid);
- private->parent = gdk_xid_table_lookup (parent);
-
- parent_private = (GdkWindowPrivate *)private->parent;
+ window = g_object_new (GDK_TYPE_WINDOW, NULL);
+ private = (GdkWindowObject *)window;
+ impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+ draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
+ draw_impl->wrapper = GDK_DRAWABLE (window);
+ parent = GetParent ((HWND)anid);
+
+ private->parent = gdk_win32_handle_table_lookup ((GdkNativeWindow) parent);
+
+ parent_private = (GdkWindowObject *)private->parent;
if (parent_private)
parent_private->children = g_list_prepend (parent_private->children, window);
- GDK_DRAWABLE_WIN32DATA (window)->xid = (HWND) anid;
+ draw_impl->handle = (HWND) anid;
GetClientRect ((HWND) anid, &rect);
point.x = rect.left;
point.y = rect.right;
ClientToScreen ((HWND) anid, &point);
- if (parent != GetDesktopWindow ())
+ if (parent != gdk_root_window)
ScreenToClient (parent, &point);
private->x = point.x;
private->y = point.y;
- private->drawable.width = rect.right - rect.left;
- private->drawable.height = rect.bottom - rect.top;
- private->drawable.window_type = GDK_WINDOW_FOREIGN;
- private->drawable.destroyed = FALSE;
- private->mapped = IsWindowVisible (GDK_DRAWABLE_XID (window));
-
- private->drawable.colormap = NULL;
+ impl->width = rect.right - rect.left;
+ impl->height = rect.bottom - rect.top;
+ private->window_type = GDK_WINDOW_FOREIGN;
+ private->destroyed = FALSE;
+ private->mapped = IsWindowVisible ((HWND) anid);
+ private->depth = gdk_visual_get_system ()->depth;
gdk_drawable_ref (window);
- gdk_xid_table_insert (&GDK_DRAWABLE_XID (window), window);
+ gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
return window;
}
-/* Call this function when you want a window and all its children to
- * disappear. When xdestroy is true, a request to destroy the window
- * is sent out. When it is false, it is assumed that the window has
- * been or will be destroyed by destroying some ancestor of this
- * window.
- */
-static void
-gdk_window_internal_destroy (GdkWindow *window,
- gboolean xdestroy,
- gboolean our_destroy)
+void
+_gdk_windowing_window_destroy (GdkWindow *window,
+ gboolean recursing,
+ gboolean foreign_destroy)
{
- GdkWindowPrivate *private;
- GdkWindowPrivate *temp_private;
- GdkWindow *temp_window;
- GList *children;
- GList *tmp;
+ GdkWindowObject *private = (GdkWindowObject *)window;
- g_return_if_fail (window != NULL);
-
- private = (GdkWindowPrivate *) window;
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ GDK_NOTE (MISC, g_print ("_gdk_windowing_window_destroy %#x\n",
+ (guint) GDK_WINDOW_HWND (window)));
- GDK_NOTE (MISC, g_print ("gdk_window_internal_destroy %#x\n",
- GDK_DRAWABLE_XID (window)));
+ if (private->extension_events != 0)
+ gdk_input_window_destroy (window);
- switch (GDK_DRAWABLE_TYPE (window))
+ if (private->window_type == GDK_WINDOW_FOREIGN)
{
- case GDK_WINDOW_TOPLEVEL:
- case GDK_WINDOW_CHILD:
- case GDK_WINDOW_DIALOG:
- case GDK_WINDOW_TEMP:
- case GDK_WINDOW_FOREIGN:
- if (!private->drawable.destroyed)
+ if (!foreign_destroy && (private->parent != NULL))
{
- if (private->parent)
- {
- GdkWindowPrivate *parent_private = (GdkWindowPrivate *)private->parent;
- if (parent_private->children)
- parent_private->children = g_list_remove (parent_private->children, window);
- }
-
- if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_FOREIGN)
- {
- children = tmp = private->children;
- private->children = NULL;
-
- while (tmp)
- {
- temp_window = tmp->data;
- tmp = tmp->next;
-
- temp_private = (GdkWindowPrivate*) temp_window;
- if (temp_private)
- gdk_window_internal_destroy (temp_window, FALSE,
- our_destroy);
- }
-
- g_list_free (children);
- }
-
- if (private->extension_events != 0)
- gdk_input_window_destroy (window);
-
- if (private->filters)
- {
- tmp = private->filters;
-
- while (tmp)
- {
- g_free (tmp->data);
- tmp = tmp->next;
- }
-
- g_list_free (private->filters);
- private->filters = NULL;
- }
+ /* It's somebody else's window, but in our hierarchy,
+ * so reparent it to the root window, and then call
+ * DestroyWindow() on it.
+ */
+ gdk_window_hide (window);
+ gdk_window_reparent (window, NULL, 0, 0);
- if (private->drawable.window_type == GDK_WINDOW_FOREIGN)
- {
- if (our_destroy && (private->parent != NULL))
- {
- /* It's somebody elses window, but in our hierarchy,
- * so reparent it to the root window, and then send
- * it a delete event, as if we were a WM
- */
- gdk_window_hide (window);
- gdk_window_reparent (window, NULL, 0, 0);
-
- /* Is this too drastic? Many (most?) applications
- * quit if any window receives WM_QUIT I think.
- * OTOH, I don't think foreign windows are much
- * used, so the question is maybe academic.
- */
- PostMessage (GDK_DRAWABLE_XID (window), WM_QUIT, 0, 0);
- }
- }
- else
- {
- private->drawable.destroyed = TRUE;
- if (xdestroy)
- {
- /* Calls gdk_WindowProc */
- DestroyWindow (GDK_DRAWABLE_XID (window));
- }
- }
-
- if (private->drawable.colormap)
- gdk_colormap_unref (private->drawable.colormap);
-
- private->mapped = FALSE;
+ /* Is this too drastic? Many (most?) applications
+ * quit if any window receives WM_QUIT I think.
+ * OTOH, I don't think foreign windows are much
+ * used, so the question is maybe academic.
+ */
+ PostMessage (GDK_WINDOW_HWND (window), WM_QUIT, 0, 0);
}
- break;
-
- case GDK_WINDOW_ROOT:
- g_error ("attempted to destroy root window");
- break;
-
- case GDK_DRAWABLE_PIXMAP:
- g_error ("called gdk_window_destroy on a pixmap (use gdk_drawable_unref)");
- break;
}
+ else if (!recursing && !foreign_destroy)
+ DestroyWindow (GDK_WINDOW_HWND (window));
}
-/* Like internal_destroy, but also destroys the reference created by
- gdk_window_new. */
-
-void
-gdk_window_destroy (GdkWindow *window)
-{
- gdk_window_internal_destroy (window, TRUE, TRUE);
- gdk_drawable_unref (window);
-}
-
-/* This function is called when the window really gone. */
-
+/* This function is called when the window really gone.
+ */
void
gdk_window_destroy_notify (GdkWindow *window)
{
g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
GDK_NOTE (EVENTS,
g_print ("gdk_window_destroy_notify: %#x %s\n",
- GDK_DRAWABLE_XID (window),
- (GDK_DRAWABLE_DESTROYED (window) ? "yes" : "no")));
+ (guint) GDK_WINDOW_HWND (window),
+ (GDK_WINDOW_DESTROYED (window) ? "(destroyed)" : "")));
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
- if (GDK_DRAWABLE_TYPE(window) != GDK_WINDOW_FOREIGN)
+ if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
g_warning ("window %#x unexpectedly destroyed",
- GDK_DRAWABLE_XID (window));
+ (guint) GDK_WINDOW_HWND (window));
- gdk_window_internal_destroy (window, FALSE, FALSE);
+ _gdk_window_destroy (window, TRUE);
}
- gdk_xid_table_remove (GDK_DRAWABLE_XID (window));
+ gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
gdk_drawable_unref (window);
}
void
gdk_window_show (GdkWindow *window)
{
- g_return_if_fail (window != NULL);
-
- if (!GDK_DRAWABLE_DESTROYED (window))
+ GdkWindowObject *private;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ private = (GdkWindowObject*) window;
+ if (!private->destroyed)
{
GDK_NOTE (MISC, g_print ("gdk_window_show: %#x\n",
- GDK_DRAWABLE_XID (window)));
+ (guint) GDK_WINDOW_HWND (window)));
- ((GdkWindowPrivate *) window)->mapped = TRUE;
- if (GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_TEMP)
+ private->mapped = TRUE;
+ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
{
- ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNOACTIVATE);
- SetWindowPos (GDK_DRAWABLE_XID (window), HWND_TOPMOST, 0, 0, 0, 0,
+ ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNOACTIVATE);
+ SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
#if 0
/* Don't put on toolbar */
- ShowWindow (GDK_DRAWABLE_XID (window), SW_HIDE);
+ ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
#endif
}
else
{
- ShowWindow (GDK_DRAWABLE_XID (window), SW_SHOWNORMAL);
- ShowWindow (GDK_DRAWABLE_XID (window), SW_RESTORE);
- SetForegroundWindow (GDK_DRAWABLE_XID (window));
- BringWindowToTop (GDK_DRAWABLE_XID (window));
+ if (GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
+ {
+ SetWindowPos(GDK_WINDOW_HWND (window), HWND_TOP, 0, 0, 0, 0,
+ SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE);
+ }
+ else
+ {
+ GdkWindow *parent = private->parent;
+
+ ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
+ ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
+ if (parent == gdk_parent_root)
+ SetForegroundWindow (GDK_WINDOW_HWND (window));
+ BringWindowToTop (GDK_WINDOW_HWND (window));
#if 0
- ShowOwnedPopups (GDK_DRAWABLE_XID (window), TRUE);
+ ShowOwnedPopups (GDK_WINDOW_HWND (window), TRUE);
#endif
+ }
}
}
}
void
gdk_window_hide (GdkWindow *window)
{
+ GdkWindowObject *private;
+
g_return_if_fail (window != NULL);
- if (!GDK_DRAWABLE_DESTROYED (window))
+ private = (GdkWindowObject*) window;
+ if (!private->destroyed)
{
GDK_NOTE (MISC, g_print ("gdk_window_hide: %#x\n",
- GDK_DRAWABLE_XID (window)));
-
- ((GdkWindowPrivate *) window)->mapped = FALSE;
- if (GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_TOPLEVEL)
- ShowOwnedPopups (GDK_DRAWABLE_XID (window), FALSE);
-#if 1
- ShowWindow (GDK_DRAWABLE_XID (window), SW_HIDE);
-#elif 0
- ShowWindow (GDK_DRAWABLE_XID (window), SW_MINIMIZE);
-#else
- CloseWindow (GDK_DRAWABLE_XID (window));
-#endif
+ (guint) GDK_WINDOW_HWND (window)));
+
+ private->mapped = FALSE;
+ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
+ ShowOwnedPopups (GDK_WINDOW_HWND (window), FALSE);
+
+ if (GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
+ {
+ SetWindowPos(GDK_WINDOW_HWND (window), HWND_BOTTOM, 0, 0, 0, 0,
+ SWP_HIDEWINDOW | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
+ }
+ else
+ {
+ ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
+ }
}
}
void
gdk_window_withdraw (GdkWindow *window)
{
+ GdkWindowObject *private;
+
g_return_if_fail (window != NULL);
-
- if (!GDK_DRAWABLE_DESTROYED (window))
+
+ private = (GdkWindowObject*) window;
+ if (!private->destroyed)
{
GDK_NOTE (MISC, g_print ("gdk_window_withdraw: %#x\n",
- GDK_DRAWABLE_XID (window)));
+ (guint) GDK_WINDOW_HWND (window)));
- gdk_window_hide (window); /* XXX */
+ gdk_window_hide (window); /* ??? */
}
}
gint x,
gint y)
{
- GdkWindowPrivate *private;
+ GdkWindowObject *private = (GdkWindowObject *)window;
+ GdkWindowImplWin32 *impl;
g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
- if (!GDK_DRAWABLE_DESTROYED (window))
- {
- RECT rect;
-
- GDK_NOTE (MISC, g_print ("gdk_window_move: %#x +%d+%d\n",
- GDK_DRAWABLE_XID (window), x, y));
-
- private = (GdkWindowPrivate *) window;
- GetClientRect (GDK_DRAWABLE_XID (window), &rect);
-
- if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD)
- {
- POINT ptTL, ptBR;
- DWORD dwStyle;
- DWORD dwExStyle;
-
- ptTL.x = 0;
- ptTL.y = 0;
- ClientToScreen (GDK_DRAWABLE_XID (window), &ptTL);
- rect.left = x;
- rect.top = y;
-
- ptBR.x = rect.right;
- ptBR.y = rect.bottom;
- ClientToScreen (GDK_DRAWABLE_XID (window), &ptBR);
- rect.right = x + ptBR.x - ptTL.x;
- rect.bottom = y + ptBR.y - ptTL.y;
-
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
- SafeAdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
-
- x = rect.left;
- y = rect.top;
- }
- else
- {
- private->x = x;
- private->y = y;
- }
- GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n",
- GDK_DRAWABLE_XID (window),
- rect.right - rect.left, rect.bottom - rect.top,
- x, y));
- if (!MoveWindow (GDK_DRAWABLE_XID (window),
- x, y, rect.right - rect.left, rect.bottom - rect.top,
- TRUE))
- WIN32_API_FAILED ("MoveWindow");
- }
+ impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+
+ gdk_window_move_resize (window, x, y, impl->width, impl->height);
}
void
gint width,
gint height)
{
- GdkWindowPrivate *private;
+ GdkWindowObject *private = (GdkWindowObject*) window;
+ GdkWindowImplWin32 *impl;
+ int x, y;
g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
- if ((gint16) width < 1)
+ if (width < 1)
width = 1;
- if ((gint16) height < 1)
+ if (height < 1)
height = 1;
- private = (GdkWindowPrivate*) window;
-
- if (!private->drawable.destroyed &&
- ((private->resize_count > 0) ||
- (private->drawable.width != (guint16) width) ||
- (private->drawable.height != (guint16) height)))
+ impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+
+ if (!private->destroyed)
{
- int x, y;
-
GDK_NOTE (MISC, g_print ("gdk_window_resize: %#x %dx%d\n",
- GDK_DRAWABLE_XID (window), width, height));
+ (guint) GDK_WINDOW_HWND (window),
+ width, height));
- if (private->drawable.window_type != GDK_WINDOW_CHILD)
+ if (GDK_WINDOW_TYPE (private) != GDK_WINDOW_CHILD)
{
POINT pt;
RECT rect;
pt.x = 0;
pt.y = 0;
- ClientToScreen (GDK_DRAWABLE_XID (window), &pt);
+ ClientToScreen (GDK_WINDOW_HWND (window), &pt);
rect.left = pt.x;
rect.top = pt.y;
rect.right = pt.x + width;
rect.bottom = pt.y + height;
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle))
WIN32_API_FAILED ("AdjustWindowRectEx");
{
x = private->x;
y = private->y;
- private->drawable.width = width;
- private->drawable.height = height;
+ impl->width = width;
+ impl->height = height;
}
private->resize_count += 1;
- GDK_NOTE (MISC,
- g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n",
- GDK_DRAWABLE_XID (window), width, height, x, y));
- if (!MoveWindow (GDK_DRAWABLE_XID (window),
- x, y, width, height,
- TRUE))
+ GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n",
+ (guint) GDK_WINDOW_HWND (window),
+ width, height, x, y));
+ if (!MoveWindow (GDK_WINDOW_HWND (window), x, y, width, height, TRUE))
WIN32_API_FAILED ("MoveWindow");
}
}
gint width,
gint height)
{
- GdkWindowPrivate *private;
+ GdkWindowObject *private = (GdkWindowObject*) window;
+ GdkWindowImplWin32 *impl;
g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
- if ((gint16) width < 1)
+ if (width < 1)
width = 1;
- if ((gint16) height < 1)
+ if (height < 1)
height = 1;
+
+ impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!private->destroyed)
{
RECT rect;
DWORD dwStyle;
DWORD dwExStyle;
GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %#x %dx%d@+%d+%d\n",
- GDK_DRAWABLE_XID (window), width, height, x, y));
+ (guint) GDK_WINDOW_HWND (window),
+ width, height, x, y));
- private = (GdkWindowPrivate*) window;
- rect.left = x;
- rect.top = y;
- rect.right = x + width;
- rect.bottom = y + height;
-
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
- if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle))
- WIN32_API_FAILED ("AdjustWindowRectEx");
-
- if (private->drawable.window_type == GDK_WINDOW_CHILD)
+ if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
+ _gdk_window_move_resize_child (window, x, y, width, height);
+ else
{
- private->x = x;
- private->y = y;
- private->drawable.width = width;
- private->drawable.height = height;
- }
- GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n",
- GDK_DRAWABLE_XID (window),
- rect.right - rect.left, rect.bottom - rect.top,
- rect.left, rect.top));
- if (!MoveWindow (GDK_DRAWABLE_XID (window),
- rect.left, rect.top,
- rect.right - rect.left, rect.bottom - rect.top,
- TRUE))
- WIN32_API_FAILED ("MoveWindow");
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + width;
+ rect.bottom = y + height;
- if (private->guffaw_gravity)
- {
- GList *tmp_list = private->children;
- while (tmp_list)
- {
- GdkWindowPrivate *child_private = tmp_list->data;
-
- child_private->x -= x - private->x;
- child_private->y -= y - private->y;
-
- tmp_list = tmp_list->next;
- }
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
+ if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle))
+ WIN32_API_FAILED ("AdjustWindowRectEx");
+
+ GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%ldx%ld@+%ld+%ld)\n",
+ (guint) GDK_WINDOW_HWND (window),
+ rect.right - rect.left, rect.bottom - rect.top,
+ rect.left, rect.top));
+ if (!MoveWindow (GDK_WINDOW_HWND (window),
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ TRUE))
+ WIN32_API_FAILED ("MoveWindow");
}
-
}
}
gint x,
gint y)
{
- GdkWindowPrivate *window_private;
- GdkWindowPrivate *parent_private;
- GdkWindowPrivate *old_parent_private;
+ GdkWindowObject *window_private;
+ GdkWindowObject *parent_private;
+ GdkWindowObject *old_parent_private;
+ GdkWindowImplWin32 *impl;
g_return_if_fail (window != NULL);
if (!new_parent)
new_parent = gdk_parent_root;
- window_private = (GdkWindowPrivate*) window;
- old_parent_private = (GdkWindowPrivate *) window_private->parent;
- parent_private = (GdkWindowPrivate*) new_parent;
+ window_private = (GdkWindowObject*) window;
+ old_parent_private = (GdkWindowObject *) window_private->parent;
+ parent_private = (GdkWindowObject*) new_parent;
+ impl = GDK_WINDOW_IMPL_WIN32 (window_private->impl);
- if (!GDK_DRAWABLE_DESTROYED (window)
- && !GDK_DRAWABLE_DESTROYED (new_parent))
+ if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
{
GDK_NOTE (MISC, g_print ("gdk_window_reparent: %#x %#x\n",
- GDK_DRAWABLE_XID (window),
- GDK_DRAWABLE_XID (new_parent)));
- if (!SetParent (GDK_DRAWABLE_XID (window),
- GDK_DRAWABLE_XID (new_parent)))
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) GDK_WINDOW_HWND (new_parent)));
+ if (!SetParent (GDK_WINDOW_HWND (window),
+ GDK_WINDOW_HWND (new_parent)))
WIN32_API_FAILED ("SetParent");
- if (!MoveWindow (GDK_DRAWABLE_XID (window),
- x, y,
- window_private->drawable.width,
- window_private->drawable.height,
- TRUE))
+ if (!MoveWindow (GDK_WINDOW_HWND (window),
+ x, y, impl->width, impl->height, TRUE))
WIN32_API_FAILED ("MoveWindow");
}
- window_private->parent = new_parent;
+ window_private->parent = (GdkWindowObject *)new_parent;
if (old_parent_private)
old_parent_private->children =
gint width,
gint height)
{
+ GdkWindowImplWin32 *impl;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- if (!GDK_DRAWABLE_DESTROYED (window))
+ impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
+
+ if (!GDK_WINDOW_DESTROYED (window))
{
HDC hdc;
if (width == 0)
- width = ((GdkDrawablePrivate *) window)->width - x;
+ width = impl->width - x;
if (height == 0)
- height = ((GdkDrawablePrivate *) window)->height - y;
+ height = impl->height - y;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area: "
"%#x %dx%d@+%d+%d\n",
- GDK_DRAWABLE_XID (window), width, height, x, y));
- hdc = GetDC (GDK_DRAWABLE_XID (window));
+ (guint) GDK_WINDOW_HWND (window),
+ width, height, x, y));
+ hdc = GetDC (GDK_WINDOW_HWND (window));
IntersectClipRect (hdc, x, y, x + width + 1, y + height + 1);
- SendMessage (GDK_DRAWABLE_XID (window), WM_ERASEBKGND, (WPARAM) hdc, 0);
- ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
+ SendMessage (GDK_WINDOW_HWND (window), WM_ERASEBKGND, (WPARAM) hdc, 0);
+ ReleaseDC (GDK_WINDOW_HWND (window), hdc);
}
}
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
RECT rect;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area_e: "
"%#x %dx%d@+%d+%d\n",
- GDK_DRAWABLE_XID (window), width, height, x, y));
+ (guint) GDK_WINDOW_HWND (window),
+ width, height, x, y));
rect.left = x;
rect.right = x + width + 1;
rect.top = y;
rect.bottom = y + height + 1;
- if (!InvalidateRect (GDK_DRAWABLE_XID (window), &rect, TRUE))
+ if (!InvalidateRect (GDK_WINDOW_HWND (window), &rect, TRUE))
WIN32_GDI_FAILED ("InvalidateRect");
- UpdateWindow (GDK_DRAWABLE_XID (window));
+ UpdateWindow (GDK_WINDOW_HWND (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))
{
GDK_NOTE (MISC, g_print ("gdk_window_raise: %#x\n",
- GDK_DRAWABLE_XID (window)));
+ (guint) GDK_WINDOW_HWND (window)));
- if (!BringWindowToTop (GDK_DRAWABLE_XID (window)))
+ if (!BringWindowToTop (GDK_WINDOW_HWND (window)))
WIN32_API_FAILED ("BringWindowToTop");
}
}
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
GDK_NOTE (MISC, g_print ("gdk_window_lower: %#x\n",
- GDK_DRAWABLE_XID (window)));
+ (guint) GDK_WINDOW_HWND (window)));
- if (!SetWindowPos (GDK_DRAWABLE_XID (window), HWND_BOTTOM, 0, 0, 0, 0,
+ if (!SetWindowPos (GDK_WINDOW_HWND (window), HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
WIN32_API_FAILED ("SetWindowPos");
}
gint max_height,
gint flags)
{
+ GdkWindowImplWin32 *impl;
WINDOWPLACEMENT size_hints;
RECT rect;
DWORD dwStyle;
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;
+ impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
+
GDK_NOTE (MISC, g_print ("gdk_window_set_hints: %#x %dx%d..%dx%d @+%d+%d\n",
- GDK_DRAWABLE_XID (window),
+ (guint) GDK_WINDOW_HWND (window),
min_width, min_height, max_width, max_height,
x, y));
- GDK_WINDOW_WIN32DATA (window)->hint_flags = flags;
+ impl->hint_flags = flags;
size_hints.length = sizeof (size_hints);
if (flags)
{
if (flags & GDK_HINT_POS)
- if (!GetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints))
- WIN32_API_FAILED ("GetWindowPlacement");
- else
- {
- GDK_NOTE (MISC, g_print ("...rcNormalPosition:"
- " (%d,%d)--(%d,%d)\n",
- size_hints.rcNormalPosition.left,
- size_hints.rcNormalPosition.top,
- size_hints.rcNormalPosition.right,
- size_hints.rcNormalPosition.bottom));
- /* What are the corresponding window coordinates for client
- * area coordinates x, y
- */
- rect.left = x;
- rect.top = y;
- rect.right = rect.left + 200; /* dummy */
- rect.bottom = rect.top + 200;
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
- AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- size_hints.flags = 0;
- size_hints.showCmd = SW_SHOWNA;
-
- /* Set the normal position hint to that location, with unchanged
- * width and height.
- */
- diff = size_hints.rcNormalPosition.left - rect.left;
- size_hints.rcNormalPosition.left = rect.left;
- size_hints.rcNormalPosition.right -= diff;
- diff = size_hints.rcNormalPosition.top - rect.top;
- size_hints.rcNormalPosition.top = rect.top;
- size_hints.rcNormalPosition.bottom -= diff;
- GDK_NOTE (MISC, g_print ("...setting: (%d,%d)--(%d,%d)\n",
- size_hints.rcNormalPosition.left,
- size_hints.rcNormalPosition.top,
- size_hints.rcNormalPosition.right,
- size_hints.rcNormalPosition.bottom));
- if (!SetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints))
- WIN32_API_FAILED ("SetWindowPlacement");
- GDK_WINDOW_WIN32DATA (window)->hint_x = rect.left;
- GDK_WINDOW_WIN32DATA (window)->hint_y = rect.top;
- }
+ {
+ if (!GetWindowPlacement (GDK_WINDOW_HWND (window), &size_hints))
+ WIN32_API_FAILED ("GetWindowPlacement");
+ else
+ {
+ GDK_NOTE (MISC, g_print ("...rcNormalPosition:"
+ " (%ld,%ld)--(%ld,%ld)\n",
+ size_hints.rcNormalPosition.left,
+ size_hints.rcNormalPosition.top,
+ size_hints.rcNormalPosition.right,
+ size_hints.rcNormalPosition.bottom));
+ /* What are the corresponding window coordinates for client
+ * area coordinates x, y
+ */
+ rect.left = x;
+ rect.top = y;
+ rect.right = rect.left + 200; /* dummy */
+ rect.bottom = rect.top + 200;
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
+ AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
+ size_hints.flags = 0;
+ size_hints.showCmd = SW_SHOWNA;
+
+ /* Set the normal position hint to that location, with unchanged
+ * width and height.
+ */
+ diff = size_hints.rcNormalPosition.left - rect.left;
+ size_hints.rcNormalPosition.left = rect.left;
+ size_hints.rcNormalPosition.right -= diff;
+ diff = size_hints.rcNormalPosition.top - rect.top;
+ size_hints.rcNormalPosition.top = rect.top;
+ size_hints.rcNormalPosition.bottom -= diff;
+ GDK_NOTE (MISC, g_print ("...setting: (%ld,%ld)--(%ld,%ld)\n",
+ size_hints.rcNormalPosition.left,
+ size_hints.rcNormalPosition.top,
+ size_hints.rcNormalPosition.right,
+ size_hints.rcNormalPosition.bottom));
+ if (!SetWindowPlacement (GDK_WINDOW_HWND (window), &size_hints))
+ WIN32_API_FAILED ("SetWindowPlacement");
+ impl->hint_x = rect.left;
+ impl->hint_y = rect.top;
+ }
+ }
if (flags & GDK_HINT_MIN_SIZE)
{
rect.top = 0;
rect.right = min_width;
rect.bottom = min_height;
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- GDK_WINDOW_WIN32DATA (window)->hint_min_width =
- rect.right - rect.left;
- GDK_WINDOW_WIN32DATA (window)->hint_min_height =
- rect.bottom - rect.top;
+ impl->hint_min_width = rect.right - rect.left;
+ impl->hint_min_height = rect.bottom - rect.top;
/* Also chek if he current size of the window is in bounds. */
- GetClientRect (GDK_DRAWABLE_XID (window), &rect);
+ GetClientRect (GDK_WINDOW_HWND (window), &rect);
if (rect.right < min_width && rect.bottom < min_height)
gdk_window_resize (window, min_width, min_height);
else if (rect.right < min_width)
rect.top = 0;
rect.right = max_width;
rect.bottom = max_height;
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- GDK_WINDOW_WIN32DATA (window)->hint_max_width =
- rect.right - rect.left;
- GDK_WINDOW_WIN32DATA (window)->hint_max_height =
- rect.bottom - rect.top;
+ impl->hint_max_width = rect.right - rect.left;
+ impl->hint_max_height = rect.bottom - rect.top;
/* Again, check if the window is too large currently. */
- GetClientRect (GDK_DRAWABLE_XID (window), &rect);
+ GetClientRect (GDK_WINDOW_HWND (window), &rect);
if (rect.right > max_width && rect.bottom > max_height)
gdk_window_resize (window, max_width, max_height);
else if (rect.right > max_width)
GdkGeometry *geometry,
GdkWindowHints geom_mask)
{
+ GdkWindowImplWin32 *impl;
WINDOWPLACEMENT size_hints;
RECT rect;
DWORD dwStyle;
DWORD dwExStyle;
- int diff;
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;
+ impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
size_hints.length = sizeof (size_hints);
- GDK_WINDOW_WIN32DATA (window)->hint_flags = geom_mask;
+ impl->hint_flags = geom_mask;
if (geom_mask & GDK_HINT_POS)
; /* XXX */
rect.top = 0;
rect.right = geometry->min_width;
rect.bottom = geometry->min_height;
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- GDK_WINDOW_WIN32DATA (window)->hint_min_width = rect.right - rect.left;
- GDK_WINDOW_WIN32DATA (window)->hint_min_height = rect.bottom - rect.top;
+ impl->hint_min_width = rect.right - rect.left;
+ impl->hint_min_height = rect.bottom - rect.top;
/* Also check if he current size of the window is in bounds */
- GetClientRect (GDK_DRAWABLE_XID (window), &rect);
+ GetClientRect (GDK_WINDOW_HWND (window), &rect);
if (rect.right < geometry->min_width
&& rect.bottom < geometry->min_height)
gdk_window_resize (window, geometry->min_width, geometry->min_height);
rect.top = 0;
rect.right = geometry->max_width;
rect.bottom = geometry->max_height;
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
- AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- GDK_WINDOW_WIN32DATA (window)->hint_max_width = rect.right - rect.left;
- GDK_WINDOW_WIN32DATA (window)->hint_max_height = rect.bottom - rect.top;
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
+ /* HB: dont' know why AdjustWindowRectEx is called here, ... */
+ SafeAdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
+ impl->hint_max_width = rect.right - rect.left;
+ impl->hint_max_height = rect.bottom - rect.top;
+ /* ... but negative sizes are always wrong */
+ if (impl->hint_max_width < 0) impl->hint_max_width = G_MAXSHORT;
+ if (impl->hint_max_height < 0) impl->hint_max_height = G_MAXSHORT;
/* Again, check if the window is too large currently. */
- GetClientRect (GDK_DRAWABLE_XID (window), &rect);
+ GetClientRect (GDK_WINDOW_HWND (window), &rect);
if (rect.right > geometry->max_width
&& rect.bottom > geometry->max_height)
gdk_window_resize (window, geometry->max_width, geometry->max_height);
if (geom_mask & GDK_HINT_BASE_SIZE
&& geometry->base_width > 0
&& geometry->base_height > 0)
- if (!GetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints))
- WIN32_API_FAILED ("GetWindowPlacement");
- else
- {
- GDK_NOTE (MISC, g_print ("gdk_window_set_geometry_hints:"
- " rcNormalPosition: (%d,%d)--(%d,%d)\n",
- size_hints.rcNormalPosition.left,
- size_hints.rcNormalPosition.top,
- size_hints.rcNormalPosition.right,
- size_hints.rcNormalPosition.bottom));
- size_hints.rcNormalPosition.right =
- size_hints.rcNormalPosition.left + geometry->base_width;
- size_hints.rcNormalPosition.bottom =
- size_hints.rcNormalPosition.top + geometry->base_height;
- GDK_NOTE (MISC, g_print ("...setting: rcNormal: (%d,%d)--(%d,%d)\n",
- size_hints.rcNormalPosition.left,
- size_hints.rcNormalPosition.top,
- size_hints.rcNormalPosition.right,
- size_hints.rcNormalPosition.bottom));
- if (!SetWindowPlacement (GDK_DRAWABLE_XID (window), &size_hints))
- WIN32_API_FAILED ("SetWindowPlacement");
- }
+ {
+ if (!GetWindowPlacement (GDK_WINDOW_HWND (window), &size_hints))
+ WIN32_API_FAILED ("GetWindowPlacement");
+ else
+ {
+ GDK_NOTE (MISC, g_print ("gdk_window_set_geometry_hints:"
+ " rcNormalPosition: (%ld,%ld)--(%ld,%ld)\n",
+ size_hints.rcNormalPosition.left,
+ size_hints.rcNormalPosition.top,
+ size_hints.rcNormalPosition.right,
+ size_hints.rcNormalPosition.bottom));
+ size_hints.rcNormalPosition.right =
+ size_hints.rcNormalPosition.left + geometry->base_width;
+ size_hints.rcNormalPosition.bottom =
+ size_hints.rcNormalPosition.top + geometry->base_height;
+ GDK_NOTE (MISC, g_print ("...setting: rcNormal: (%ld,%ld)--(%ld,%ld)\n",
+ size_hints.rcNormalPosition.left,
+ size_hints.rcNormalPosition.top,
+ size_hints.rcNormalPosition.right,
+ size_hints.rcNormalPosition.bottom));
+ if (!SetWindowPlacement (GDK_WINDOW_HWND (window), &size_hints))
+ WIN32_API_FAILED ("SetWindowPlacement");
+ }
+ }
if (geom_mask & GDK_HINT_RESIZE_INC)
{
gdk_window_set_title (GdkWindow *window,
const gchar *title)
{
- gint titlelen;
- wchar_t *wcstr;
- gint wlen;
- char *mbstr;
+ char *mbtitle;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (title != NULL);
- g_return_if_fail (strlen (title) > 0);
+
+ /* Empty window titles not allowed, so set it to just a period. */
+ if (!title[0])
+ title = ".";
GDK_NOTE (MISC, g_print ("gdk_window_set_title: %#x %s\n",
- GDK_DRAWABLE_XID (window), title));
- if (!GDK_DRAWABLE_DESTROYED (window))
+ (guint) GDK_WINDOW_HWND (window), title));
+
+ if (!GDK_WINDOW_DESTROYED (window))
{
/* As the title is in UTF-8 we must translate it
* to the system codepage.
*/
- titlelen = strlen (title);
- wcstr = g_new (wchar_t, titlelen + 1);
- mbstr = g_new (char, 3*titlelen + 1);
- wlen = gdk_nmbstowchar_ts (wcstr, title, titlelen, titlelen);
- wcstr[wlen] = 0;
- WideCharToMultiByte (GetACP (), 0, wcstr, -1,
- mbstr, 3*titlelen, NULL, NULL);
-
- if (!SetWindowText (GDK_DRAWABLE_XID (window), mbstr))
+ mbtitle = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
+ if (!SetWindowText (GDK_WINDOW_HWND (window), mbtitle))
WIN32_API_FAILED ("SetWindowText");
- g_free (mbstr);
- g_free (wcstr);
+ g_free (mbtitle);
}
}
g_return_if_fail (GDK_IS_WINDOW (window));
GDK_NOTE (MISC, g_print ("gdk_window_set_role: %#x %s\n",
- GDK_DRAWABLE_XID (window), (role ? role : "NULL")));
+ (guint) GDK_WINDOW_HWND (window),
+ (role ? role : "NULL")));
/* XXX */
}
g_return_if_fail (GDK_IS_WINDOW (window));
GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %#x %#x\n",
- GDK_DRAWABLE_XID (window),
- GDK_DRAWABLE_XID (parent)));
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) GDK_WINDOW_HWND (parent)));
/* XXX */
}
gdk_window_set_background (GdkWindow *window,
GdkColor *color)
{
+ GdkWindowObject *private = (GdkWindowObject *)window;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- if (!GDK_DRAWABLE_DESTROYED (window))
- {
- GDK_NOTE (MISC, g_print ("gdk_window_set_background: %#x %s\n",
- GDK_DRAWABLE_XID (window),
- gdk_win32_color_to_string (color)));
+ GDK_NOTE (MISC, g_print ("gdk_window_set_background: %#x %s\n",
+ (guint) GDK_WINDOW_HWND (window),
+ gdk_win32_color_to_string (color)));
- if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PIXMAP)
- {
- if (GDK_WINDOW_WIN32DATA (window)->bg_pixmap != NULL)
- {
- gdk_drawable_unref (GDK_WINDOW_WIN32DATA (window)->bg_pixmap);
- GDK_WINDOW_WIN32DATA (window)->bg_pixmap = NULL;
- }
- GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_NORMAL;
- }
- GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_PIXEL;
- GDK_WINDOW_WIN32DATA (window)->bg_pixel = color->pixel;
+ private->bg_color = *color;
+
+ if (private->bg_pixmap &&
+ private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
+ private->bg_pixmap != GDK_NO_BG)
+ {
+ gdk_drawable_unref (private->bg_pixmap);
+ private->bg_pixmap = NULL;
}
}
GdkPixmap *pixmap,
gint parent_relative)
{
+ GdkWindowObject *private = (GdkWindowObject *)window;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (pixmap == NULL || !parent_relative);
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (private->bg_pixmap &&
+ private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
+ private->bg_pixmap != GDK_NO_BG)
+ gdk_drawable_unref (private->bg_pixmap);
+
+ if (parent_relative)
{
- if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PIXMAP)
- {
- if (GDK_WINDOW_WIN32DATA (window)->bg_pixmap != NULL)
- {
- gdk_drawable_unref (GDK_WINDOW_WIN32DATA (window)->bg_pixmap);
- GDK_WINDOW_WIN32DATA (window)->bg_pixmap = NULL;
- }
- GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_NORMAL;
- }
- if (parent_relative)
- {
- GDK_WINDOW_WIN32DATA (window)->bg_type =
- GDK_WIN32_BG_PARENT_RELATIVE;
- }
- else if (!pixmap)
+ private->bg_pixmap = GDK_PARENT_RELATIVE_BG;
+ }
+ else
+ {
+ if (pixmap)
{
-
+ gdk_drawable_ref (pixmap);
+ private->bg_pixmap = pixmap;
}
else
{
- /* We must cache the pixmap in the GdkWindowWin32Data and
- * paint it each time we get WM_ERASEBKGND
- */
- GDK_WINDOW_WIN32DATA (window)->bg_type = GDK_WIN32_BG_PIXMAP;
- GDK_WINDOW_WIN32DATA (window)->bg_pixmap = pixmap;
- gdk_drawable_ref (pixmap);
+ private->bg_pixmap = GDK_NO_BG;
}
}
}
gdk_window_set_cursor (GdkWindow *window,
GdkCursor *cursor)
{
+ GdkWindowImplWin32 *impl;
GdkCursorPrivate *cursor_private;
- HCURSOR xcursor;
+ HCURSOR hcursor;
POINT pt;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
+ impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
cursor_private = (GdkCursorPrivate*) cursor;
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
if (!cursor)
- xcursor = LoadCursor (NULL, IDC_ARROW);
+ hcursor = NULL;
else
- xcursor = cursor_private->xcursor;
+ hcursor = cursor_private->hcursor;
GDK_NOTE (MISC, g_print ("gdk_window_set_cursor: %#x %#x\n",
- GDK_DRAWABLE_XID (window), xcursor));
- GDK_WINDOW_WIN32DATA (window)->xcursor = xcursor;
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) hcursor));
+ if (impl->hcursor != NULL)
+ {
+ GDK_NOTE (MISC, g_print ("...DestroyCursor (%#x)\n",
+ (guint) impl->hcursor));
+
+ DestroyCursor (impl->hcursor);
+ impl->hcursor = NULL;
+ }
+ if (hcursor != NULL)
+ {
+ /* We must copy the cursor as it is OK to destroy the GdkCursor
+ * while still in use for some window. See for instance
+ * gimp_change_win_cursor() which calls
+ * gdk_window_set_cursor (win, cursor), and immediately
+ * afterwards gdk_cursor_destroy (cursor).
+ */
+ impl->hcursor = CopyCursor (hcursor);
+ GDK_NOTE (MISC, g_print ("...CopyCursor (%#x) = %#x\n",
+ (guint) hcursor, (guint) impl->hcursor));
- GetCursorPos (&pt);
- if (ChildWindowFromPoint (GDK_DRAWABLE_XID (window), pt) == GDK_DRAWABLE_XID (window))
- SetCursor (xcursor);
+ GetCursorPos (&pt);
+ if (ChildWindowFromPoint (GDK_WINDOW_HWND (window), pt) == GDK_WINDOW_HWND (window))
+ SetCursor (impl->hcursor);
+ }
}
}
if (!window)
window = gdk_parent_root;
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
RECT rect;
- if (!GetClientRect (GDK_DRAWABLE_XID (window), &rect))
+ if (!GetClientRect (GDK_WINDOW_HWND (window), &rect))
WIN32_API_FAILED ("GetClientRect");
if (x)
g_return_val_if_fail (window != NULL, 0);
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
POINT pt;
pt.x = 0;
pt.y = 0;
- ClientToScreen (GDK_DRAWABLE_XID (window), &pt);
+ ClientToScreen (GDK_WINDOW_HWND (window), &pt);
tx = pt.x;
ty = pt.y;
return_val = 1;
*y = ty;
GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %#x: +%d+%d\n",
- GDK_DRAWABLE_XID (window), tx, ty));
+ (guint) GDK_WINDOW_HWND (window),
+ tx, ty));
return return_val;
}
gint *x,
gint *y)
{
- GdkWindowPrivate *rover;
+ GdkWindowObject *rover;
POINT pt;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- rover = (GdkWindowPrivate*) window;
+ rover = (GdkWindowObject*) window;
if (x)
*x = 0;
if (y)
*y = 0;
- if (GDK_DRAWABLE_DESTROYED (window))
+
+ if (GDK_WINDOW_DESTROYED (window))
return;
- while (rover->parent && ((GdkWindowPrivate*) rover->parent)->parent)
- rover = (GdkWindowPrivate *) rover->parent;
- if (rover->drawable.destroyed)
+ while (rover->parent && ((GdkWindowObject*) rover->parent)->parent)
+ rover = (GdkWindowObject *) rover->parent;
+ if (rover->destroyed)
return;
pt.x = 0;
pt.y = 0;
- ClientToScreen (GDK_DRAWABLE_XID (rover), &pt);
+ ClientToScreen (GDK_WINDOW_HWND (rover), &pt);
if (x)
*x = pt.x;
if (y)
*y = pt.y;
- GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %#x: (%#x) +%d+%d\n",
- GDK_DRAWABLE_XID (window),
- GDK_DRAWABLE_XID (rover), pt.x, pt.y));
+ GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %#x: (%#x) +%ld+%ld\n",
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) GDK_WINDOW_HWND (rover),
+ pt.x, pt.y));
}
GdkWindow*
return_val = NULL;
GetCursorPos (&pointc);
point = pointc;
- ScreenToClient (GDK_DRAWABLE_XID (window), &point);
+ ScreenToClient (GDK_WINDOW_HWND (window), &point);
if (x)
*x = point.x;
ScreenToClient (hwndc, &point);
} while (hwndc != hwnd && (hwnd = hwndc, 1)); /* Ouch! */
- return_val = gdk_window_lookup (hwnd);
+ return_val = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
if (mask)
{
ScreenToClient (hwndc, &point);
} while (hwndc != hwnd && (hwnd = hwndc, 1));
- window = gdk_window_lookup (hwnd);
+ window = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
if (window && (win_x || win_y))
{
*win_y = point.y - rect.top;
}
- GDK_NOTE (MISC, g_print ("gdk_window_at_pointer: +%d+%d %#x%s\n",
- point.x, point.y, hwnd,
+ GDK_NOTE (MISC, g_print ("gdk_window_at_pointer: +%ld+%ld %#x%s\n",
+ point.x, point.y,
+ (guint) hwnd,
(window == NULL ? " NULL" : "")));
return window;
}
-GList*
-gdk_window_get_children (GdkWindow *window)
-{
- GdkWindowPrivate *private;
- GList *children;
-
- g_return_val_if_fail (window != NULL, NULL);
- g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
-
- if (GDK_DRAWABLE_DESTROYED (window))
- return NULL;
-
- /* XXX ??? */
- g_warning ("gdk_window_get_children not implemented");
- children = NULL;
-
- return children;
-}
-
GdkEventMask
gdk_window_get_events (GdkWindow *window)
{
g_return_val_if_fail (window != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
- if (GDK_DRAWABLE_DESTROYED (window))
+ if (GDK_WINDOW_DESTROYED (window))
return 0;
- return GDK_WINDOW_WIN32DATA (window)->event_mask;
+ return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask;
}
void
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_WINDOW_WIN32DATA (window)->event_mask = event_mask;
-}
-
-void
-gdk_window_add_colormap_windows (GdkWindow *window)
-{
- g_warning ("gdk_window_add_colormap_windows not implemented");
+ GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask = event_mask;
}
void
if (!mask)
{
GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x none\n",
- GDK_DRAWABLE_XID (window)));
- SetWindowRgn (GDK_DRAWABLE_XID (window), NULL, TRUE);
+ (guint) GDK_WINDOW_HWND (window)));
+ SetWindowRgn (GDK_WINDOW_HWND (window), NULL, TRUE);
}
else
{
RECT rect;
/* Convert mask bitmap to region */
- hrgn = BitmapToRegion (GDK_DRAWABLE_XID (mask));
+ hrgn = BitmapToRegion (GDK_WINDOW_HWND (mask));
GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x %#x\n",
- GDK_DRAWABLE_XID (window),
- GDK_DRAWABLE_XID (mask)));
+ (guint) GDK_WINDOW_HWND (window),
+ (guint) GDK_WINDOW_HWND (mask)));
/* SetWindowRgn wants window (not client) coordinates */
- dwStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
- GetClientRect (GDK_DRAWABLE_XID (window), &rect);
+ dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
+ GetClientRect (GDK_WINDOW_HWND (window), &rect);
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
OffsetRgn (hrgn, -rect.left, -rect.top);
OffsetRgn (hrgn, x, y);
/* If this is a top-level window, add the title bar to the region */
- if (GDK_DRAWABLE_TYPE (window) == GDK_WINDOW_TOPLEVEL)
+ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
{
CombineRgn (hrgn, hrgn,
CreateRectRgn (0, 0, rect.right - rect.left, -rect.top),
RGN_OR);
}
- SetWindowRgn (GDK_DRAWABLE_XID (window), hrgn, TRUE);
+ SetWindowRgn (GDK_WINDOW_HWND (window), hrgn, TRUE);
}
}
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;
/* Nothing to do, really. As we share window classes between windows
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;
- if (!SetWindowText (GDK_DRAWABLE_XID (window), name))
+ if (!SetWindowText (GDK_WINDOW_HWND (window), name))
WIN32_API_FAILED ("SetWindowText");
}
g_return_if_fail (leader != NULL);
g_return_if_fail (GDK_IS_WINDOW (leader));
- if (GDK_DRAWABLE_DESTROYED (window) || GDK_DRAWABLE_DESTROYED (leader))
+ if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
return;
g_warning ("gdk_window_set_group not implemented");
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- style = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- exstyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
+ style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
style &= (WS_OVERLAPPED|WS_POPUP|WS_CHILD|WS_MINIMIZE|WS_VISIBLE|WS_DISABLED
|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_MAXIMIZE);
if (decorations & GDK_DECOR_MAXIMIZE)
style |= (WS_MAXIMIZEBOX);
- SetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE, style);
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
}
void
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- style = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE);
- exstyle = GetWindowLong (GDK_DRAWABLE_XID (window), GWL_EXSTYLE);
+ style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
+ exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
style &= (WS_OVERLAPPED|WS_POPUP|WS_CHILD|WS_MINIMIZE|WS_VISIBLE|WS_DISABLED
|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_MAXIMIZE|WS_CAPTION|WS_BORDER
if (functions & GDK_FUNC_MAXIMIZE)
style |= (WS_MAXIMIZEBOX);
- SetWindowLong (GDK_DRAWABLE_XID (window), GWL_STYLE, style);
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
}
/*
{
RECT emptyRect;
HRGN region, childRegion;
- RECT rect;
HWND *list = NULL;
gint i, num;
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_propagate_shapes (GDK_DRAWABLE_XID (window), FALSE);
+ gdk_propagate_shapes (GDK_WINDOW_HWND (window), FALSE);
}
void
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_propagate_shapes (GDK_DRAWABLE_XID (window), TRUE);
+ gdk_propagate_shapes (GDK_WINDOW_HWND (window), TRUE);
}
/* Support for windows that can be guffaw-scrolled
gdk_window_set_static_gravities (GdkWindow *window,
gboolean use_static)
{
- GdkWindowPrivate *private = (GdkWindowPrivate *)window;
+ GdkWindowObject *private = (GdkWindowObject *)window;
GList *tmp_list;
g_return_val_if_fail (window != NULL, FALSE);
private->guffaw_gravity = use_static;
- if (!GDK_DRAWABLE_DESTROYED (window))
+ if (!GDK_WINDOW_DESTROYED (window))
{
gdk_window_set_static_bit_gravity (window, use_static);