/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1998-1999 Tor Lillqvist
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include <stdlib.h>
+#include "gdk.h" /* gdk_rectangle_intersect */
#include "gdkevents.h"
#include "gdkpixmap.h"
#include "gdkwindow.h"
-#include "gdkinternals.h"
#include "gdkprivate-win32.h"
+#include "gdkinput-win32.h"
static gboolean gdk_window_gravity_works (void);
static void gdk_window_set_static_win_gravity (GdkWindow *window,
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)
+_gdk_window_impl_win32_get_type (void)
{
static GType object_type = 0;
object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_WIN32,
"GdkWindowImplWin32",
- &object_info);
+ &object_info, 0);
}
return object_type;
GType
_gdk_window_impl_get_type (void)
{
- return gdk_window_impl_win32_get_type ();
+ return _gdk_window_impl_win32_get_type ();
}
static void
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
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
if (window_impl->hcursor != NULL)
{
- DestroyCursor (window_impl->hcursor);
+ if (GetCursor () == window_impl->hcursor)
+ SetCursor (NULL);
+ if (!DestroyCursor (window_impl->hcursor))
+ WIN32_GDI_FAILED("DestroyCursor");
window_impl->hcursor = NULL;
}
gdk_window_impl_win32_get_colormap (GdkDrawable *drawable)
{
GdkDrawableImplWin32 *drawable_impl;
- GdkWindowImplWin32 *window_impl;
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 (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
drawable_impl->colormap == NULL)
{
drawable_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (drawable_impl->colormap);
}
return drawable_impl->colormap;
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));
impl = GDK_WINDOW_IMPL_WIN32 (drawable);
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- GDK_DRAWABLE_GET_CLASS (draw_impl)->set_colormap (drawable, cmap);
+ /* chain up */
+ GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);
- /* XXX */
-
+ if (cmap)
+ {
+ /* XXX */
+ g_print("gdk_window_impl_win32_set_colormap: XXX\n");
+ }
}
static void
*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_windowing_window_init (void)
{
guint width;
guint height;
- g_assert (gdk_parent_root == NULL);
+ 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;
+ _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);
+ draw_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (draw_impl->colormap);
private->window_type = GDK_WINDOW_ROOT;
private->depth = gdk_visual_get_system ()->depth;
impl->width = width;
impl->height = height;
- gdk_win32_handle_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
+static BOOL
SafeAdjustWindowRectEx (RECT* lpRect,
DWORD dwStyle,
BOOL bMenu,
* is ever needed (e.g Dialog specific), every such window should
* get its own class
*/
-ATOM
+static ATOM
RegisterGdkClass (GdkWindowType wtype)
{
static ATOM klassTOPLEVEL = 0;
static WNDCLASSEX wcl;
ATOM klass = 0;
- wcl.cbSize = sizeof(WNDCLASSEX);
+ wcl.cbSize = sizeof (WNDCLASSEX);
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_window_procedure;
+ wcl.lpfnWndProc = _gdk_win32_window_procedure;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = gdk_app_hmodule;
hAppIcon = ExtractIcon (gdk_app_hmodule, sLoc, 0);
if (0 == hAppIcon)
{
- char *gdklibname = g_strdup_printf ("gdk-%s.dll", GDK_VERSION);
-
- hAppIcon = ExtractIcon (gdk_app_hmodule, gdklibname, 0);
- g_free (gdklibname);
+ if (0 != GetModuleFileName (gdk_dll_hinstance, sLoc, _MAX_PATH))
+ hAppIcon = ExtractIcon (gdk_dll_hinstance, sLoc, 0);
}
-
- if (0 == hAppIcon)
- hAppIcon = LoadIcon (NULL, IDI_APPLICATION);
}
+ if (0 == hAppIcon)
+ hAppIcon = LoadIcon (NULL, IDI_APPLICATION);
}
wcl.lpszMenuName = NULL;
wcl.hIconSm = 0;
/* initialize once per class */
+ /*
+ * HB: Setting the background brush leads to flicker, because we
+ * don't get asked how to clear the background. This is not what
+ * we want, at least not for input_only windows ...
+ */
#define ONCE_PER_CLASS() \
wcl.hIcon = CopyIcon (hAppIcon); \
wcl.hIconSm = CopyIcon (hAppIcon); \
- wcl.hbrBackground = CreateSolidBrush (RGB (0,0,0)); \
+ wcl.hbrBackground = NULL; \
wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
switch (wtype)
- {
- case GDK_WINDOW_TOPLEVEL:
- if (0 == klassTOPLEVEL)
- {
- wcl.lpszClassName = "gdkWindowToplevel";
-
- ONCE_PER_CLASS();
- klassTOPLEVEL = RegisterClassEx (&wcl);
- }
- klass = klassTOPLEVEL;
- break;
-
+ {
+ case GDK_WINDOW_TOPLEVEL:
+ if (0 == klassTOPLEVEL)
+ {
+ wcl.lpszClassName = "gdkWindowToplevel";
+
+ ONCE_PER_CLASS();
+ klassTOPLEVEL = RegisterClassEx (&wcl);
+ }
+ klass = klassTOPLEVEL;
+ break;
+
case GDK_WINDOW_CHILD:
if (0 == klassCHILD)
{
}
klass = klassCHILD;
break;
-
- case GDK_WINDOW_DIALOG:
- if (0 == klassDIALOG)
- {
- wcl.lpszClassName = "gdkWindowDialog";
- wcl.style |= CS_SAVEBITS;
- ONCE_PER_CLASS();
- klassDIALOG = RegisterClassEx (&wcl);
- }
- klass = klassDIALOG;
- break;
-
- case GDK_WINDOW_TEMP:
- if (0 == klassTEMP)
- {
- wcl.lpszClassName = "gdkWindowTemp";
- wcl.style |= CS_SAVEBITS;
- ONCE_PER_CLASS();
- klassTEMP = RegisterClassEx (&wcl);
- }
- klass = klassTEMP;
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-
+
+ case GDK_WINDOW_DIALOG:
+ if (0 == klassDIALOG)
+ {
+ wcl.lpszClassName = "gdkWindowDialog";
+ wcl.style |= CS_SAVEBITS;
+ ONCE_PER_CLASS();
+ klassDIALOG = RegisterClassEx (&wcl);
+ }
+ klass = klassDIALOG;
+ break;
+
+ case GDK_WINDOW_TEMP:
+ if (0 == klassTEMP)
+ {
+ wcl.lpszClassName = "gdkWindowTemp";
+ wcl.style |= CS_SAVEBITS;
+ ONCE_PER_CLASS();
+ klassTEMP = RegisterClassEx (&wcl);
+ }
+ klass = klassTEMP;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
if (klass == 0)
{
WIN32_API_FAILED ("RegisterClassEx");
GdkWindowAttr *attributes,
gint attributes_mask)
{
+ HANDLE hparent;
+ ATOM klass = 0;
+ DWORD dwStyle, dwExStyle;
+ RECT rect;
GdkWindow *window;
GdkWindowObject *private;
- GdkWindowObject *parent_private;
GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
-
GdkVisual *visual;
-
- 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 = _gdk_parent_root;
g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
- parent_private = (GdkWindowObject*) parent;
+ 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" :
+ "???"))))));
+
if (GDK_WINDOW_DESTROYED (parent))
return NULL;
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
draw_impl->wrapper = GDK_DRAWABLE (window);
+ /* Windows with a foreign parent are treated as if they are children
+ * of the root window, except for actual creation.
+ */
+ if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
+ parent = _gdk_parent_root;
+
private->parent = (GdkWindowObject *)parent;
if (attributes_mask & GDK_WA_X)
visual = attributes->visual;
else
visual = gdk_visual_get_system ();
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
if (attributes_mask & GDK_WA_TITLE)
title = attributes->title;
else
title = g_get_prgname ();
- if (!title)
+ if (!title || !*title)
title = "GDK client window";
- impl->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
+ private->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
- if (parent_private && parent_private->guffaw_gravity)
+ if (private->parent && private->parent->guffaw_gravity)
{
/* XXX ??? */
}
}
else
{
- if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
- {
- draw_impl->colormap =
- gdk_colormap_get_system ();
- gdk_colormap_ref (draw_impl->colormap);
- }
- else
- {
- draw_impl->colormap =
- gdk_colormap_new (visual, FALSE);
- }
+ draw_impl->colormap = gdk_colormap_get_system ();
}
}
else
dwExStyle = WS_EX_TRANSPARENT;
private->depth = 0;
private->input_only = TRUE;
- draw_impl->colormap = NULL;
+ draw_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (draw_impl->colormap);
+ GDK_NOTE (MISC, g_print ("...GDK_INPUT_ONLY, system colormap\n"));
}
- if (parent_private)
- parent_private->children = g_list_prepend (parent_private->children, window);
+ if (private->parent)
+ private->parent->children = g_list_prepend (private->parent->children, window);
switch (private->window_type)
{
break;
case GDK_WINDOW_TEMP:
- dwStyle = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ dwStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ /* a temp window is not necessarily a top level window */
+ dwStyle |= (_gdk_parent_root == parent ? WS_POPUP : WS_CHILDWINDOW);
dwExStyle |= WS_EX_TOOLWINDOW;
break;
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);
#ifdef WITHOUT_WM_CREATE
draw_impl->handle = CreateWindowEx (dwExStyle,
MAKEINTRESOURCE(klass),
mbtitle,
dwStyle,
- x, y,
- width, height,
+ impl->position_info.x, impl->position_info.y,
+ impl->position_info.width, impl->position_info.height,
hparent,
NULL,
gdk_app_hmodule,
MAKEINTRESOURCE(klass),
mbtitle,
dwStyle,
- x, y,
- width, height,
+ impl->position_info.x, impl->position_info.y,
+ impl->position_info.width, impl->position_info.height,
hparent,
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.",
- GDK_WINDOW_HWND (window), hwndNew);
+ g_warning("gdk_window_new: gdk_event_translate::WM_CREATE (%p, %p) HWND mismatch.",
+ GDK_WINDOW_HWND (window),
+ hwndNew);
/* HB: IHMO due to a race condition the handle was increased by
* one, which causes much trouble. Because I can't find the
#endif
GDK_NOTE (MISC,
- g_print ("gdk_window_new: %s %s %dx%d@+%d+%d %#x = %#x\n"
- "...locale %#x codepage %d\n",
- (private->window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :
- (private->window_type == GDK_WINDOW_CHILD ? "CHILD" :
- (private->window_type == GDK_WINDOW_DIALOG ? "DIALOG" :
- (private->window_type == GDK_WINDOW_TEMP ? "TEMP" :
- "???")))),
+ g_print ("... \"%s\" %dx%d@+%d+%d %p = %p\n",
mbtitle,
width, height, (x == CW_USEDEFAULT ? -9999 : x), y,
hparent,
- GDK_WINDOW_HWND (window),
- impl->input_locale,
- impl->charset_info.ciACP));
+ GDK_WINDOW_HWND (window)));
g_free (mbtitle);
- g_free (wctitle);
if (draw_impl->handle == NULL)
{
{
GdkWindow *window;
GdkWindowObject *private;
- GdkWindowObject *parent_private;
GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
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);
+ if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN)
+ private->parent = (GdkWindowObject *)_gdk_parent_root;
- parent_private = (GdkWindowObject *)private->parent;
-
- if (parent_private)
- parent_private->children = g_list_prepend (parent_private->children, window);
+ private->parent->children = g_list_prepend (private->parent->children, window);
draw_impl->handle = (HWND) anid;
GetClientRect ((HWND) anid, &rect);
impl->height = rect.bottom - rect.top;
private->window_type = GDK_WINDOW_FOREIGN;
private->destroyed = FALSE;
- private->mapped = IsWindowVisible ((HWND) anid);
+ private->event_mask = GDK_ALL_EVENTS_MASK; /* XXX */
+ if (IsWindowVisible ((HWND) anid))
+ private->state &= (~GDK_WINDOW_STATE_WITHDRAWN);
+ else
+ private->state |= GDK_WINDOW_STATE_WITHDRAWN;
private->depth = gdk_visual_get_system ()->depth;
gdk_drawable_ref (window);
return window;
}
+GdkWindow*
+gdk_window_lookup (GdkNativeWindow hwnd)
+{
+ return (GdkWindow*) gdk_win32_handle_table_lookup (hwnd);
+}
+
void
_gdk_windowing_window_destroy (GdkWindow *window,
gboolean recursing,
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("_gdk_windowing_window_destroy %#x\n",
+ GDK_NOTE (MISC, g_print ("_gdk_windowing_window_destroy %p\n",
GDK_WINDOW_HWND (window)));
if (private->extension_events != 0)
}
}
else if (!recursing && !foreign_destroy)
- DestroyWindow (GDK_WINDOW_HWND (window));
+ {
+ private->destroyed = TRUE;
+ DestroyWindow (GDK_WINDOW_HWND (window));
+ }
}
/* This function is called when the window really gone.
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",
+ g_print ("gdk_window_destroy_notify: %p %s\n",
GDK_WINDOW_HWND (window),
(GDK_WINDOW_DESTROYED (window) ? "(destroyed)" : "")));
if (!GDK_WINDOW_DESTROYED (window))
{
if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
- g_warning ("window %#x unexpectedly destroyed",
+ g_warning ("window %p unexpectedly destroyed",
GDK_WINDOW_HWND (window));
_gdk_window_destroy (window, TRUE);
gdk_drawable_unref (window);
}
-void
-gdk_window_show (GdkWindow *window)
+static void
+show_window_internal (GdkWindow *window,
+ gboolean raise)
{
GdkWindowObject *private;
- g_return_if_fail (GDK_IS_WINDOW (window));
-
- private = (GdkWindowObject*) window;
+ private = GDK_WINDOW_OBJECT (window);
+
if (!private->destroyed)
{
- GDK_NOTE (MISC, g_print ("gdk_window_show: %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_show: %p\n",
GDK_WINDOW_HWND (window)));
- private->mapped = TRUE;
+ private->state &= (~GDK_WINDOW_STATE_WITHDRAWN);
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
{
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNOACTIVATE);
}
else
{
- ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
- ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
- SetForegroundWindow (GDK_WINDOW_HWND (window));
- BringWindowToTop (GDK_WINDOW_HWND (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 = GDK_WINDOW (private->parent);
+
+ /* Todo: GDK_WINDOW_STATE_STICKY */
+ if (private->state & GDK_WINDOW_STATE_ICONIFIED)
+ ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMINIMIZED);
+ else if (private->state & GDK_WINDOW_STATE_MAXIMIZED)
+ ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
+ else
+ {
+ ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
+ ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
+ }
+ if (parent == _gdk_parent_root)
+ SetForegroundWindow (GDK_WINDOW_HWND (window));
+ if (raise)
+ BringWindowToTop (GDK_WINDOW_HWND (window));
#if 0
- ShowOwnedPopups (GDK_WINDOW_HWND (window), TRUE);
+ ShowOwnedPopups (GDK_WINDOW_HWND (window), TRUE);
#endif
+ }
}
}
}
+void
+gdk_window_show_unraised (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ show_window_internal (window, FALSE);
+}
+
+void
+gdk_window_show (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ show_window_internal (window, TRUE);
+}
+
void
gdk_window_hide (GdkWindow *window)
{
private = (GdkWindowObject*) window;
if (!private->destroyed)
{
- GDK_NOTE (MISC, g_print ("gdk_window_hide: %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_hide: %p\n",
GDK_WINDOW_HWND (window)));
- private->mapped = FALSE;
+ private->state |= GDK_WINDOW_STATE_WITHDRAWN;
+
+ _gdk_window_clear_update_area (window);
+
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
ShowOwnedPopups (GDK_WINDOW_HWND (window), FALSE);
- ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
+ 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);
+ }
}
}
private = (GdkWindowObject*) window;
if (!private->destroyed)
{
- GDK_NOTE (MISC, g_print ("gdk_window_withdraw: %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_withdraw: %p\n",
GDK_WINDOW_HWND (window)));
gdk_window_hide (window); /* ??? */
impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
- gdk_window_move_resize (window, x, y, impl->width, impl->height);
+ if (!GDK_WINDOW_DESTROYED (window))
+ {
+ if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
+ _gdk_window_move_resize_child (window, x, y,
+ impl->width, impl->height);
+ else
+ {
+ if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ x, y, impl->width, impl->height,
+ SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER))
+ WIN32_API_FAILED ("SetWindowPos");
+ }
+ }
}
void
impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
- if (!private->destroyed)
+ if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (MISC, g_print ("gdk_window_resize: %#x %dx%d\n",
- GDK_WINDOW_HWND (window), width, height));
-
- if (GDK_WINDOW_TYPE (private) != GDK_WINDOW_CHILD)
+ if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
+ _gdk_window_move_resize_child (window, private->x, private->y,
+ width, height);
+ else
{
POINT pt;
RECT rect;
y = rect.top;
width = rect.right - rect.left;
height = rect.bottom - rect.top;
+ if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ x, y, width, height,
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER))
+ WIN32_API_FAILED ("SetWindowPos");
}
- else
- {
- x = private->x;
- y = private->y;
- impl->width = width;
- impl->height = height;
- }
-
private->resize_count += 1;
-
- GDK_NOTE (MISC,
- g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n",
- GDK_WINDOW_HWND (window), width, height, x, y));
- if (!MoveWindow (GDK_WINDOW_HWND (window), x, y, width, height, TRUE))
- WIN32_API_FAILED ("MoveWindow");
}
}
DWORD dwStyle;
DWORD dwExStyle;
- GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %#x %dx%d@+%d+%d\n",
- GDK_WINDOW_HWND (window), width, height, x, y));
+ GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %p %dx%d@+%d+%d\n",
+ GDK_WINDOW_HWND (window),
+ width, height, x, y));
if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
_gdk_window_move_resize_child (window, x, y, width, height);
if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle))
WIN32_API_FAILED ("AdjustWindowRectEx");
- GDK_NOTE (MISC, g_print ("...MoveWindow(%#x,%dx%d@+%d+%d)\n",
+ GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%ldx%ld@+%ld+%ld)\n",
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");
+ if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ SWP_NOACTIVATE | SWP_NOZORDER))
+ WIN32_API_FAILED ("SetWindowPos");
}
}
}
GdkWindowImplWin32 *impl;
g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent));
+ g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT);
if (!new_parent)
- new_parent = gdk_parent_root;
+ new_parent = _gdk_parent_root;
window_private = (GdkWindowObject*) window;
old_parent_private = (GdkWindowObject *) window_private->parent;
if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
{
- GDK_NOTE (MISC, g_print ("gdk_window_reparent: %#x %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_reparent: %p %p\n",
GDK_WINDOW_HWND (window),
GDK_WINDOW_HWND (new_parent)));
if (!SetParent (GDK_WINDOW_HWND (window),
x, y, impl->width, impl->height, TRUE))
WIN32_API_FAILED ("MoveWindow");
}
+
+ /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like
+ * the root window
+ */
+ if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
+ new_parent = _gdk_parent_root;
window_private->parent = (GdkWindowObject *)new_parent;
gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
parent_private->children = g_list_prepend (parent_private->children, window);
+ _gdk_window_init_position (GDK_WINDOW (window_private));
}
void
if (height == 0)
height = impl->height - y;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area: "
- "%#x %dx%d@+%d+%d\n",
- GDK_WINDOW_HWND (window), width, height, x, y));
+ "%p %dx%d@+%d+%d\n",
+ 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_WINDOW_HWND (window), WM_ERASEBKGND, (WPARAM) hdc, 0);
- ReleaseDC (GDK_WINDOW_HWND (window), hdc);
+ if (!ReleaseDC (GDK_WINDOW_HWND (window), hdc))
+ WIN32_GDI_FAILED ("ReleaseDC");
}
}
RECT rect;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area_e: "
- "%#x %dx%d@+%d+%d\n",
- GDK_WINDOW_HWND (window), width, height, x, y));
+ "%p %dx%d@+%d+%d\n",
+ GDK_WINDOW_HWND (window),
+ width, height, x, y));
rect.left = x;
rect.right = x + width + 1;
if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (MISC, g_print ("gdk_window_raise: %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_raise: %p\n",
GDK_WINDOW_HWND (window)));
if (!BringWindowToTop (GDK_WINDOW_HWND (window)))
if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (MISC, g_print ("gdk_window_lower: %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_lower: %p\n",
GDK_WINDOW_HWND (window)));
if (!SetWindowPos (GDK_WINDOW_HWND (window), HWND_BOTTOM, 0, 0, 0, 0,
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_NOTE (MISC, g_print ("gdk_window_set_hints: %p %dx%d..%dx%d @+%d+%d\n",
GDK_WINDOW_HWND (window),
min_width, min_height, max_width, max_height,
x, y));
if (flags)
{
- if (flags & GDK_HINT_POS)
- if (!GetWindowPlacement (GDK_WINDOW_HWND (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_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: (%d,%d)--(%d,%d)\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;
- }
+ GdkGeometry geom;
+ gint geom_mask = 0;
- if (flags & GDK_HINT_MIN_SIZE)
+ geom.min_width = min_width;
+ geom.min_height = min_height;
+ geom.max_width = max_width;
+ geom.max_height = max_height;
+
+ if (flags & GDK_HINT_POS)
{
- rect.left = 0;
- rect.top = 0;
- rect.right = min_width;
- rect.bottom = min_height;
- dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
- AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- 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_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)
- gdk_window_resize (window, min_width, rect.bottom);
- else if (rect.bottom < min_height)
- gdk_window_resize (window, rect.right, min_height);
+ 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)
+ geom_mask |= GDK_HINT_MIN_SIZE;
+
if (flags & GDK_HINT_MAX_SIZE)
- {
- rect.left = 0;
- rect.top = 0;
- rect.right = max_width;
- rect.bottom = max_height;
- dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
- dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
- AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- 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_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)
- gdk_window_resize (window, max_width, rect.bottom);
- else if (rect.bottom > max_height)
- gdk_window_resize (window, rect.right, max_height);
- }
+ geom_mask |= GDK_HINT_MAX_SIZE;
+
+ gdk_window_set_geometry_hints (window, &geom, geom_mask);
}
}
RECT rect;
DWORD dwStyle;
DWORD dwExStyle;
- int diff;
+ gint new_width = 0, new_height = 0;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
impl->hint_flags = geom_mask;
if (geom_mask & GDK_HINT_POS)
- ; /* XXX */
+ ; /* even the X11 mplementation doesn't care */
if (geom_mask & GDK_HINT_MIN_SIZE)
{
/* Also check if he current size of the window is in bounds */
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);
+ {
+ new_width = geometry->min_width; new_height = geometry->min_height;
+ }
else if (rect.right < geometry->min_width)
- gdk_window_resize (window, geometry->min_width, rect.bottom);
+ {
+ new_width = geometry->min_width; new_height = rect.bottom;
+ }
else if (rect.bottom < geometry->min_height)
- gdk_window_resize (window, rect.right, geometry->min_height);
+ {
+ new_width = rect.right; new_height = geometry->min_height;
+ }
}
if (geom_mask & GDK_HINT_MAX_SIZE)
rect.bottom = geometry->max_height;
dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
dwExStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
- AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
+ /* 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_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);
+ {
+ new_width = geometry->max_width; new_height = geometry->max_height;
+ }
else if (rect.right > geometry->max_width)
- gdk_window_resize (window, geometry->max_width, rect.bottom);
+ {
+ new_width = geometry->max_width; new_height = rect.bottom;
+ }
else if (rect.bottom > geometry->max_height)
- gdk_window_resize (window, rect.right, geometry->max_height);
+ {
+ new_width = rect.right; new_height = geometry->max_height;
+ }
}
+
+ /* finally apply new size constraints */
+ if (new_width != 0 && new_height != 0)
+ gdk_window_resize (window, new_width, new_height);
/* I don't know what to do when called with zero base_width and height. */
if (geom_mask & GDK_HINT_BASE_SIZE
&& geometry->base_width > 0
&& geometry->base_height > 0)
- if (!GetWindowPlacement (GDK_WINDOW_HWND (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_WINDOW_HWND (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));
if (!title[0])
title = ".";
- GDK_NOTE (MISC, g_print ("gdk_window_set_title: %#x %s\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_set_title: %p %s\n",
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_WINDOW_HWND (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 (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_role: %#x %s\n",
- GDK_WINDOW_HWND (window), (role ? role : "NULL")));
+ GDK_NOTE (MISC, g_print ("gdk_window_set_role: %p %s\n",
+ GDK_WINDOW_HWND (window),
+ (role ? role : "NULL")));
/* XXX */
}
gdk_window_set_transient_for (GdkWindow *window,
GdkWindow *parent)
{
+ HWND window_id, parent_id;
+ LONG style;
+
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %#x %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %p %p\n",
GDK_WINDOW_HWND (window),
GDK_WINDOW_HWND (parent)));
- /* XXX */
+
+ if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent))
+ return;
+
+ window_id = GDK_WINDOW_HWND (window);
+ parent_id = GDK_WINDOW_HWND (parent);
+
+ if ((style = GetWindowLong (window_id, GWL_STYLE)) == 0)
+ WIN32_API_FAILED ("GetWindowLong");
+
+ style |= WS_POPUP;
+#if 0 /* not sure if we want to do this */
+ style &= ~(WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
+#endif
+
+ if (!SetWindowLong (window_id, GWL_STYLE, style))
+ WIN32_API_FAILED ("SetWindowLong");
+#if 0 /* not sure if we want to do this, clipping to parent size! */
+ if (!SetParent (window_id, parent_id))
+ WIN32_API_FAILED ("SetParent");
+#else /* make the modal window topmost instead */
+ if (!SetWindowPos (window_id, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE))
+ WIN32_API_FAILED ("SetWindowPos");
+#endif
+
+ if (!RedrawWindow (window_id, NULL, NULL,
+ RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW))
+ WIN32_API_FAILED ("RedrawWindow");
}
void
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_background: %#x %s\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_set_background: %p %s\n",
GDK_WINDOW_HWND (window),
gdk_win32_color_to_string (color)));
if (parent_relative)
{
private->bg_pixmap = GDK_PARENT_RELATIVE_BG;
+ GDK_NOTE (MISC, g_print (G_STRLOC ": setting background pixmap to parent_relative\n"));
}
else
{
GdkWindowImplWin32 *impl;
GdkCursorPrivate *cursor_private;
HCURSOR hcursor;
- POINT pt;
+ HCURSOR hprevcursor;
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_WINDOW_DESTROYED (window))
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (!cursor)
+ hcursor = NULL;
+ else
+ hcursor = cursor_private->hcursor;
+
+ GDK_NOTE (MISC, g_print ("gdk_window_set_cursor: %p %p\n",
+ GDK_WINDOW_HWND (window),
+ hcursor));
+
+ /* First get the old cursor, if any (we wait to free the old one
+ * since it may be the current cursor set in the Win32 API right
+ * now).
+ */
+ hprevcursor = impl->hcursor;
+
+ if (hcursor == NULL)
+ impl->hcursor = NULL;
+ else
{
- if (!cursor)
- hcursor = NULL;
- else
- hcursor = cursor_private->hcursor;
+ /* 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).
+ */
+ if ((impl->hcursor = CopyCursor (hcursor)) == NULL)
+ WIN32_API_FAILED ("CopyCursor");
+ GDK_NOTE (MISC, g_print ("...CopyCursor (%p) = %p\n",
+ hcursor, impl->hcursor));
+ }
- GDK_NOTE (MISC, g_print ("gdk_window_set_cursor: %#x %#x\n",
- GDK_WINDOW_HWND (window), hcursor));
- if (impl->hcursor != NULL)
- {
- GDK_NOTE (MISC, g_print ("...DestroyCursor (%#x)\n", 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",
- hcursor, impl->hcursor));
+ /* Set new cursor in all cases if we're over our window */
+ if (gdk_window_get_pointer(window, NULL, NULL, NULL) == window)
+ SetCursor (impl->hcursor);
- GetCursorPos (&pt);
- if (ChildWindowFromPoint (GDK_WINDOW_HWND (window), pt) == GDK_WINDOW_HWND (window))
- SetCursor (impl->hcursor);
- }
+ /* Destroy the previous cursor: Need to make sure it's no longer in
+ * use before we destroy it, in case we're not over our window but
+ * the cursor is still set to our old one.
+ */
+ if (hprevcursor != NULL)
+ {
+ if (GetCursor() == hprevcursor)
+ SetCursor (NULL);
+
+ GDK_NOTE (MISC, g_print ("...DestroyCursor (%p)\n",
+ hprevcursor));
+
+ if (!DestroyCursor (hprevcursor))
+ WIN32_API_FAILED ("DestroyCursor");
}
}
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!window)
- window = gdk_parent_root;
+ window = _gdk_parent_root;
if (!GDK_WINDOW_DESTROYED (window))
{
if (y)
*y = ty;
- GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %#x: +%d+%d\n",
- GDK_WINDOW_HWND (window), tx, ty));
+ GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %p: +%d+%d\n",
+ GDK_WINDOW_HWND (window),
+ tx, ty));
return return_val;
}
gint *x,
gint *y)
{
- GdkWindowObject *rover;
- POINT pt;
+ GdkRectangle rect;
- g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- rover = (GdkWindowObject*) window;
+ gdk_window_get_frame_extents (window, &rect);
+
if (x)
- *x = 0;
+ *x = rect.x;
+
if (y)
- *y = 0;
+ *y = rect.y;
+}
+void
+gdk_window_get_frame_extents (GdkWindow *window,
+ GdkRectangle *rect)
+{
+ GdkWindowObject *private;
+ HWND hwnd;
+ RECT r;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (rect != NULL);
+
+ private = GDK_WINDOW_OBJECT (window);
+
+ rect->x = 0;
+ rect->y = 0;
+ rect->width = 1;
+ rect->height = 1;
+
if (GDK_WINDOW_DESTROYED (window))
return;
-
- while (rover->parent && ((GdkWindowObject*) rover->parent)->parent)
- rover = (GdkWindowObject *) rover->parent;
- if (rover->destroyed)
- return;
- pt.x = 0;
- pt.y = 0;
- ClientToScreen (GDK_WINDOW_HWND (rover), &pt);
- if (x)
- *x = pt.x;
- if (y)
- *y = pt.y;
+ while (private->parent && ((GdkWindowObject*) private->parent)->parent)
+ private = (GdkWindowObject*) private->parent;
- GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %#x: (%#x) +%d+%d\n",
- GDK_WINDOW_HWND (window),
- GDK_WINDOW_HWND (rover), pt.x, pt.y));
+ hwnd = GDK_WINDOW_HWND (window);
+
+ /* find the frame window */
+ while (HWND_DESKTOP != GetParent (hwnd))
+ {
+ hwnd = GetParent (hwnd);
+ g_return_if_fail (NULL != hwnd);
+ }
+
+ if (!GetWindowRect (hwnd, &r))
+ WIN32_API_FAILED ("GetWindowRect");
+
+ rect->x = r.left;
+ rect->y = r.right;
+ rect->width = r.right - r.left;
+ rect->height = r.bottom - r.top;
}
GdkWindow*
-gdk_window_get_pointer (GdkWindow *window,
- gint *x,
- gint *y,
- GdkModifierType *mask)
+_gdk_windowing_window_get_pointer (GdkWindow *window,
+ gint *x,
+ gint *y,
+ GdkModifierType *mask)
{
GdkWindow *return_val;
- POINT pointc, point;
+ POINT screen_point, point;
HWND hwnd, hwndc;
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
if (!window)
- window = gdk_parent_root;
+ window = _gdk_parent_root;
return_val = NULL;
- GetCursorPos (&pointc);
- point = pointc;
+ GetCursorPos (&screen_point);
+ point = screen_point;
ScreenToClient (GDK_WINDOW_HWND (window), &point);
if (x)
*y = point.y;
hwnd = WindowFromPoint (point);
- point = pointc;
- ScreenToClient (hwnd, &point);
-
- do {
- hwndc = ChildWindowFromPoint (hwnd, point);
- ClientToScreen (hwnd, &point);
- ScreenToClient (hwndc, &point);
- } while (hwndc != hwnd && (hwnd = hwndc, 1)); /* Ouch! */
-
- return_val = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
-
+ if (hwnd != NULL)
+ {
+ gboolean done = FALSE;
+
+ while (!done)
+ {
+ point = screen_point;
+ ScreenToClient (hwnd, &point);
+ hwndc = ChildWindowFromPoint (hwnd, point);
+ if (hwndc == NULL)
+ done = TRUE;
+ else if (hwndc == hwnd)
+ done = TRUE;
+ else
+ hwnd = hwndc;
+ }
+
+ return_val = gdk_window_lookup ((GdkNativeWindow) hwnd);
+ }
+ else
+ return_val = NULL;
+
if (mask)
{
BYTE kbd[256];
}
GdkWindow*
-gdk_window_at_pointer (gint *win_x,
- gint *win_y)
+_gdk_windowing_window_at_pointer (GdkScreen *screen,
+ gint *win_x,
+ gint *win_y)
{
GdkWindow *window;
POINT point, pointc;
if (hwnd == NULL)
{
- window = gdk_parent_root;
+ window = _gdk_parent_root;
if (win_x)
*win_x = pointc.x;
if (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 %p%s\n",
+ point.x, point.y,
+ hwnd,
(window == NULL ? " NULL" : "")));
return window;
if (GDK_WINDOW_DESTROYED (window))
return 0;
- return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask;
+ return GDK_WINDOW_OBJECT (window)->event_mask;
}
void
if (GDK_WINDOW_DESTROYED (window))
return;
- GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask = event_mask;
+ /* gdk_window_new() always sets the GDK_STRUCTURE_MASK, so better
+ * set it here, too. Not that I know or remember why it is
+ * necessary, will have to test some day.
+ */
+ GDK_WINDOW_OBJECT (window)->event_mask = GDK_STRUCTURE_MASK | event_mask;
}
void
if (!mask)
{
- GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x none\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %p none\n",
GDK_WINDOW_HWND (window)));
SetWindowRgn (GDK_WINDOW_HWND (window), NULL, TRUE);
}
RECT rect;
/* Convert mask bitmap to region */
- hrgn = BitmapToRegion (GDK_WINDOW_HWND (mask));
+ hrgn = _gdk_win32_bitmap_to_region (mask);
- GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x %#x\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %p %p\n",
GDK_WINDOW_HWND (window),
GDK_WINDOW_HWND (mask)));
/* If this is a top-level window, add the title bar to the region */
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
{
- CombineRgn (hrgn, hrgn,
- CreateRectRgn (0, 0, rect.right - rect.left, -rect.top),
- RGN_OR);
+ HRGN tmp = CreateRectRgn (0, 0, rect.right - rect.left, -rect.top);
+ CombineRgn (hrgn, hrgn, tmp, RGN_OR);
+ DeleteObject (tmp);
}
SetWindowRgn (GDK_WINDOW_HWND (window), hrgn, TRUE);
g_warning ("gdk_window_set_override_redirect not implemented");
}
+void
+gdk_window_set_icon_list (GdkWindow *window,
+ GList *pixbufs)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ /* We could convert it to a hIcon and DrawIcon () it when getting
+ * a WM_PAINT with IsIconic, but is it worth it ? Same probably
+ * goes for gdk_window_set_icon (). Patches accepted :-) --hb
+ * Or do we only need to deliver the Icon on WM_GETICON ?
+ */
+}
+
void
gdk_window_set_icon (GdkWindow *window,
GdkWindow *icon_window,
{
RECT emptyRect;
HRGN region, childRegion;
- RECT rect;
HWND *list = NULL;
gint i, num;
{
g_return_if_fail (window != NULL);
- GDK_NOTE (MISC,
- g_print ("gdk_window_set_static_win_gravity: Not implemented\n"));
+ GDK_NOTE (MISC, g_print ("gdk_window_set_static_win_gravity: Not implemented\n"));
}
/*************************************************************
return TRUE;
}
+
+/*
+ * Setting window states
+ */
+void
+gdk_window_iconify (GdkWindow *window)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ {
+ ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
+ }
+ else
+ {
+ /* Flip our client side flag, the real work happens on map. */
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_ICONIFIED);
+ }
+}
+
+void
+gdk_window_deiconify (GdkWindow *window)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ {
+ gdk_window_show (window);
+ }
+ else
+ {
+ /* Flip our client side flag, the real work happens on map. */
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_ICONIFIED,
+ 0);
+ }
+}
+
+void
+gdk_window_stick (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ {
+ /* "stick" means stick to all desktops _and_ do not scroll with the
+ * viewport. i.e. glue to the monitor glass in all cases.
+ */
+ g_warning ("gdk_window_stick (%p) ???", GDK_WINDOW_HWND (window));
+ }
+ else
+ {
+ /* Flip our client side flag, the real work happens on map. */
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_STICKY);
+ }
+}
+
+void
+gdk_window_unstick (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ {
+ g_warning ("gdk_window_unstick (%p) ???", GDK_WINDOW_HWND (window));
+ }
+ else
+ {
+ /* Flip our client side flag, the real work happens on map. */
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_STICKY,
+ 0);
+ }
+}
+
+void
+gdk_window_maximize (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ ShowWindow (GDK_WINDOW_HWND (window), SW_MAXIMIZE);
+ else
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_MAXIMIZED);
+}
+
+void
+gdk_window_unmaximize (GdkWindow *window)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
+ else
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_MAXIMIZED,
+ 0);
+}
+
+void
+gdk_window_focus (GdkWindow *window,
+ guint32 timestamp)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ GDK_NOTE (MISC, g_print ("gdk_window_focus: %p\n", GDK_WINDOW_HWND (window)));
+
+ ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
+ SetFocus (GDK_WINDOW_HWND (window));
+}
+
+void
+gdk_window_set_modal_hint (GdkWindow *window,
+ gboolean modal)
+{
+ GdkWindowObject *private;
+
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ private = (GdkWindowObject*) window;
+
+ private->modal_hint = modal;
+
+ if (GDK_WINDOW_IS_MAPPED (window))
+ if (!SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST,
+ 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
+ WIN32_API_FAILED ("SetWindowPos");
+}
+
+void
+gdk_window_set_type_hint (GdkWindow *window,
+ GdkWindowTypeHint hint)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ switch (hint)
+ {
+ case GDK_WINDOW_TYPE_HINT_DIALOG:
+ break;
+ case GDK_WINDOW_TYPE_HINT_MENU:
+ break;
+ case GDK_WINDOW_TYPE_HINT_TOOLBAR:
+ break;
+ default:
+ g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
+ /* Fall thru */
+ case GDK_WINDOW_TYPE_HINT_NORMAL:
+ break;
+ }
+ /*
+ * XXX ???
+ */
+ GDK_NOTE (MISC, g_print ("gdk_window_set_type_hint (%p)\n",
+ GDK_WINDOW_HWND (window)));
+}
+
+void
+gdk_window_shape_combine_region (GdkWindow *window,
+ GdkRegion *shape_region,
+ gint offset_x,
+ gint offset_y)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ /* XXX: even on X implemented conditional ... */
+}
+
+void
+gdk_window_begin_resize_drag (GdkWindow *window,
+ GdkWindowEdge edge,
+ gint button,
+ gint root_x,
+ gint root_y,
+ guint32 timestamp)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ /* XXX: isn't all this default on win32 ... */
+}
+
+void
+gdk_window_begin_move_drag (GdkWindow *window,
+ gint button,
+ gint root_x,
+ gint root_y,
+ guint32 timestamp)
+{
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ /* XXX: isn't all this default on win32 ... */
+}