/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1998-2002 Tor Lillqvist
+ * Copyright (C) 1998-2004 Tor Lillqvist
+ * Copyright (C) 2001-2004 Hans Breuer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include <config.h>
#include <stdlib.h>
+#define _WIN32_WINNT 0x0500
+#define WINVER _WIN32_WINNT
+
#include "gdk.h" /* gdk_rectangle_intersect */
#include "gdkevents.h"
#include "gdkpixmap.h"
#include "gdkprivate-win32.h"
#include "gdkinput-win32.h"
+#if defined(_MSC_VER) && (WINVER < 0x0500)
+#define GetAncestor(hwnd,what) _gdk_win32_get_ancestor_parent(hwnd)
+
+static HWND
+_gdk_win32_get_ancestor_parent (HWND hwnd)
+{
+#ifndef GA_PARENT
+# define GA_PARENT 1
+#endif
+ typedef HWND (WINAPI *PFN_GetAncestor) (HWND,UINT);
+ static PFN_GetAncestor p_GetAncestor = NULL;
+ static gboolean once = FALSE;
+
+ if (!once)
+ {
+ HMODULE user32;
+
+ user32 = GetModuleHandle ("user32.dll");
+ p_GetAncestor = (PFN_GetAncestor)GetProcAddress (user32, "GetAncestor");
+ once = TRUE;
+ }
+ if (p_GetAncestor)
+ return p_GetAncestor (hwnd, GA_PARENT);
+ else /* not completely right, but better than nothing ? */
+ return GetParent (hwnd);
+}
+
+#endif
+
+#if 0
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <stdio.h> /* sprintf */
+#include <stdio.h>
+#endif
static GdkColormap* gdk_window_impl_win32_get_colormap (GdkDrawable *drawable);
static void gdk_window_impl_win32_set_colormap (GdkDrawable *drawable,
static gpointer parent_class = NULL;
+#define WINDOW_IS_TOPLEVEL(window) \
+ (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN)
+
GType
_gdk_window_impl_win32_get_type (void)
{
{
impl->width = 1;
impl->height = 1;
-
+ impl->toplevel_window_type = -1;
impl->hcursor = NULL;
- impl->hicon = NULL;
+ impl->hicon_big = NULL;
+ impl->hicon_small = NULL;
impl->hint_flags = 0;
impl->extension_events_selected = FALSE;
}
GDI_CALL (DestroyCursor, (window_impl->hcursor));
window_impl->hcursor = NULL;
}
- if (window_impl->hicon != NULL)
+ if (window_impl->hicon_big != NULL)
+ {
+ GDI_CALL (DestroyIcon, (window_impl->hicon_big));
+ window_impl->hicon_big = NULL;
+ }
+ if (window_impl->hicon_small != NULL)
{
- GDI_CALL (DestroyIcon, (window_impl->hicon));
- window_impl->hicon = NULL;
+ GDI_CALL (DestroyIcon, (window_impl->hicon_small));
+ window_impl->hicon_small = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
drawable_impl->colormap == NULL)
{
- drawable_impl->colormap = gdk_colormap_get_system ();
+ drawable_impl->colormap =
+ gdk_screen_get_system_colormap (gdk_drawable_get_screen (drawable));
g_object_ref (drawable_impl->colormap);
}
{
GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (drawable);
GdkRectangle result_rect;
+ HDC hdc;
result_rect.x = 0;
result_rect.y = 0;
gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
+ /* take this win32 specific part into account (smaller when obscured) */
+ hdc = GetDC (GDK_DRAWABLE_IMPL_WIN32_HANDLE (impl));
+ if (hdc)
+ {
+ RECT r;
+ if (SIMPLEREGION == GetClipBox (hdc, &r))
+ {
+ GdkRectangle gr;
+
+ gr.x = r.left + impl->position_info.x_offset;
+ gr.y = r.top + impl->position_info.y_offset;
+ gr.width = r.right - r.left;
+ gr.height = r.bottom - r.top;
+
+ gdk_rectangle_intersect (&result_rect, &gr, &result_rect);
+ }
+ ReleaseDC (GDK_DRAWABLE_IMPL_WIN32_HANDLE (drawable), hdc);
+ }
+
return gdk_region_rectangle (&result_rect);
}
+void
+_gdk_root_window_size_init (void)
+{
+ GdkWindowImplWin32 *impl;
+ GdkRectangle rect;
+ int i;
+
+ impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) _gdk_root)->impl);
+ rect = _gdk_monitors[0];
+ for (i = 1; i < _gdk_num_monitors; i++)
+ gdk_rectangle_union (&rect, _gdk_monitors+i, &rect);
+
+ impl->width = rect.width;
+ impl->height = rect.height;
+}
+
void
_gdk_windowing_window_init (void)
{
GdkWindowObject *private;
- GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
- GdkRectangle rect;
- gint i;
- g_assert (_gdk_parent_root == NULL);
+ g_assert (_gdk_root == NULL);
- _gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL);
- private = (GdkWindowObject *)_gdk_parent_root;
- impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+ _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
+ private = (GdkWindowObject *)_gdk_root;
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
- draw_impl->handle = _gdk_root_window;
+ draw_impl->handle = GetDesktopWindow ();
draw_impl->wrapper = GDK_DRAWABLE (private);
draw_impl->colormap = gdk_colormap_get_system ();
g_object_ref (draw_impl->colormap);
private->window_type = GDK_WINDOW_ROOT;
private->depth = gdk_visual_get_system ()->depth;
- rect = _gdk_monitors[0];
- for (i = 1; i < _gdk_num_monitors; i++)
- gdk_rectangle_union (&rect, _gdk_monitors+i, &rect);
-
- impl->width = rect.width;
- impl->height = rect.height;
-
+ _gdk_root_window_size_init ();
+
_gdk_window_init_position (GDK_WINDOW (private));
- gdk_win32_handle_table_insert (&_gdk_root_window, _gdk_parent_root);
+ gdk_win32_handle_table_insert ((HANDLE *) &draw_impl->handle, _gdk_root);
- GDK_NOTE (MISC, g_print ("_gdk_parent_root=%p\n", GDK_WINDOW_HWND (_gdk_parent_root)));
+ GDK_NOTE (MISC, g_print ("_gdk_root=%p\n", GDK_WINDOW_HWND (_gdk_root)));
}
static const gchar *
return klass;
}
-GdkWindow*
-gdk_window_new (GdkWindow *parent,
- GdkWindowAttr *attributes,
- gint attributes_mask)
+static GdkWindow*
+gdk_window_new_internal (GdkWindow *parent,
+ GdkWindowAttr *attributes,
+ gint attributes_mask,
+ gboolean from_set_skip_taskbar_hint)
{
+ HWND hwndNew;
HANDLE hparent;
ATOM klass = 0;
DWORD dwStyle = 0, dwExStyle;
RECT rect;
GdkWindow *window;
+ GdkWindow *orig_parent;
GdkWindowObject *private;
GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
if (!parent)
{
screen = gdk_screen_get_default ();
- parent = gdk_screen_get_root_window (screen);
+ parent = _gdk_root;
}
else
screen = gdk_drawable_get_screen (parent);
g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
+ orig_parent = parent;
+
GDK_NOTE (MISC,
g_print ("gdk_window_new: %s\n",
(attributes->window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :
* of the root window, except for actual creation.
*/
if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
- parent = _gdk_parent_root;
+ parent = _gdk_root;
private->parent = (GdkWindowObject *)parent;
+ private->accept_focus = TRUE;
+ private->focus_on_map = TRUE;
+
if (attributes_mask & GDK_WA_X)
private->x = attributes->x;
else
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;
+ if (attributes->wclass == GDK_INPUT_ONLY)
+ {
+ /* Backwards compatiblity - we've always ignored
+ * attributes->window_type for input-only windows
+ * before
+ */
+ if (parent == _gdk_root)
+ private->window_type = GDK_WINDOW_TEMP;
+ else
+ private->window_type = GDK_WINDOW_CHILD;
+ }
+ else
+ private->window_type = attributes->window_type;
if (attributes->wclass == GDK_INPUT_OUTPUT)
{
dwExStyle = WS_EX_TRANSPARENT;
private->depth = 0;
private->input_only = TRUE;
- draw_impl->colormap = gdk_colormap_get_system ();
+ draw_impl->colormap = gdk_screen_get_system_colormap (screen);
g_object_ref (draw_impl->colormap);
- GDK_NOTE (MISC, g_print ("...GDK_INPUT_ONLY, system colormap"));
+ GDK_NOTE (MISC, g_print ("... GDK_INPUT_ONLY, system colormap"));
}
switch (private->window_type)
{
case GDK_WINDOW_TOPLEVEL:
- dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
- hparent = _gdk_root_window;
- offset_x = _gdk_offset_x;
- offset_y = _gdk_offset_y;
+ case GDK_WINDOW_DIALOG:
+ if (parent != _gdk_root)
+ {
+ g_warning (G_STRLOC ": Toplevel windows must be created as children\n"
+ "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
+ hparent = GetDesktopWindow ();
+ }
+ /* Children of foreign windows aren't toplevel windows */
+ if (GDK_WINDOW_TYPE (orig_parent) == GDK_WINDOW_FOREIGN)
+ {
+ dwStyle = WS_CHILDWINDOW | WS_CLIPCHILDREN;
+ }
+ else
+ {
+ if (private->window_type == GDK_WINDOW_TOPLEVEL)
+ dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
+ else
+ dwStyle = WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME | WS_CLIPCHILDREN;
+
+ offset_x = _gdk_offset_x;
+ offset_y = _gdk_offset_y;
+ }
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
- hparent = _gdk_root_window;
- offset_x = _gdk_offset_x;
- offset_y = _gdk_offset_y;
- break;
-
case GDK_WINDOW_TEMP:
- dwStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
- /* a temp window is not necessarily a top level window */
- dwStyle |= (_gdk_parent_root == parent ? WS_POPUP : WS_CHILDWINDOW);
+ /* A temp window is not necessarily a top level window */
+ dwStyle = (_gdk_root == parent ? WS_POPUP : WS_CHILDWINDOW);
+ dwStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
dwExStyle |= WS_EX_TOOLWINDOW;
offset_x = _gdk_offset_x;
offset_y = _gdk_offset_y;
window_height = impl->position_info.height;
}
- if (impl->position_info.big)
- private->guffaw_gravity = TRUE;
-
if (attributes_mask & GDK_WA_TITLE)
title = attributes->title;
else
title = get_default_title ();
if (!title || !*title)
- title = "GDK client window";
+ title = "";
private->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
- if (private->parent && private->parent->guffaw_gravity)
- {
- /* XXX ??? */
- }
-
if (private->parent)
private->parent->children = g_list_prepend (private->parent->children, window);
mbtitle = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
-#ifdef WITHOUT_WM_CREATE
- draw_impl->handle =
- CreateWindowEx (dwExStyle,
- MAKEINTRESOURCE(klass),
- mbtitle,
- dwStyle,
- ((attributes_mask & GDK_WA_X) ?
- impl->position_info.x - offset_x : CW_USEDEFAULT),
- impl->position_info.y - offset_y,
- window_width, window_height,
- hparent,
- NULL,
- _gdk_app_hmodule,
- NULL);
-#else
- {
- HWND hwndNew =
- CreateWindowEx (dwExStyle,
- MAKEINTRESOURCE(klass),
- mbtitle,
- dwStyle,
- ((attributes_mask & GDK_WA_X) ?
- impl->position_info.x - offset_x: CW_USEDEFAULT),
- impl->position_info.y - offset_y,
- window_width, window_height,
- hparent,
- NULL,
- _gdk_app_hmodule,
- window);
+ hwndNew = CreateWindowEx (dwExStyle,
+ MAKEINTRESOURCE(klass),
+ mbtitle,
+ dwStyle,
+ ((attributes_mask & GDK_WA_X) ?
+ impl->position_info.x - offset_x : CW_USEDEFAULT),
+ impl->position_info.y - offset_y,
+ window_width, window_height,
+ hparent,
+ NULL,
+ _gdk_app_hmodule,
+ window);
if (GDK_WINDOW_HWND (window) != hwndNew)
{
g_warning("gdk_window_new: gdk_event_translate::WM_CREATE (%p, %p) HWND mismatch.",
# endif
}
- }
+
g_object_ref (window);
gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
-#endif
- GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@+%d+%d %p = %p\n",
+ GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
mbtitle,
window_width, window_height,
((attributes_mask & GDK_WA_X) ?
return NULL;
}
-#ifdef WITHOUT_WM_CREATE
- g_object_ref (window);
- gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
-#endif
+ if (!from_set_skip_taskbar_hint && private->window_type == GDK_WINDOW_TEMP)
+ gdk_window_set_skip_taskbar_hint (window, TRUE);
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
(attributes->cursor) :
return window;
}
+GdkWindow*
+gdk_window_new (GdkWindow *parent,
+ GdkWindowAttr *attributes,
+ gint attributes_mask)
+{
+ return gdk_window_new_internal (parent, attributes, attributes_mask, FALSE);
+}
+
GdkWindow *
gdk_window_foreign_new_for_display (GdkDisplay *display,
GdkNativeWindow 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;
+ private->parent = (GdkWindowObject *)_gdk_root;
private->parent->children = g_list_prepend (private->parent->children, window);
point.x = rect.left;
point.y = rect.right;
ClientToScreen ((HWND) anid, &point);
- if (parent != _gdk_root_window)
+ if (parent != GetDesktopWindow ())
ScreenToClient (parent, &point);
private->x = point.x;
private->y = point.y;
g_object_ref (window);
gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);
+ GDK_NOTE (MISC, g_print ("gdk_window_foreign_new_for_display: %p: %s@%+d%+d\n",
+ (HWND) anid,
+ _gdk_win32_drawable_description (window),
+ private->x, private->y));
+
return window;
}
if (private->extension_events != 0)
_gdk_input_window_destroy (window);
- if (private->window_type == GDK_WINDOW_FOREIGN)
- {
- if (!foreign_destroy && (private->parent != 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);
-
- /* 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);
- }
- }
- else if (!recursing && !foreign_destroy)
+
+ if (!recursing && !foreign_destroy)
{
+ _gdk_win32_drawable_finish (private->impl);
+
private->destroyed = TRUE;
DestroyWindow (GDK_WINDOW_HWND (window));
}
+ gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window));
+}
+
+void
+_gdk_windowing_window_destroy_foreign (GdkWindow *window)
+{
+ /* It's somebody else's window, but in our hierarchy, so reparent it
+ * to the desktop, and then try to destroy it.
+ */
+ gdk_window_hide (window);
+ gdk_window_reparent (window, NULL, 0, 0);
+
+ PostMessage (GDK_WINDOW_HWND (window), WM_CLOSE, 0, 0);
}
/* This function is called when the window really gone.
{
GdkWindowObject *private;
HWND old_active_window;
-
+ gboolean focus_on_map = TRUE;
+
private = (GdkWindowObject *) window;
if (private->destroyed)
/* Other cases */
if (!GDK_WINDOW_IS_MAPPED (window))
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_WITHDRAWN,
- 0);
+ {
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_WITHDRAWN,
+ 0);
+ focus_on_map = private->focus_on_map;
+ }
+
+ /* Use SetWindowPos to show transparent windows so automatic redraws
+ * in other windows can be suppressed.
+ */
+ if (GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE) & WS_EX_TRANSPARENT)
+ {
+ UINT flags = SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOMOVE | SWP_NOSIZE;
+ if (!raise)
+ flags |= SWP_NOZORDER;
+ if (!raise || GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map)
+ flags |= SWP_NOACTIVATE;
+
+ SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOP, 0, 0, 0, 0, flags);
+ return;
+ }
old_active_window = GetActiveWindow ();
if (private->state & GDK_WINDOW_STATE_ABOVE)
exstyle |= WS_EX_TOPMOST;
- if (!SetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE, exstyle))
- WIN32_API_FAILED ("SetWindowLong");
+ API_CALL (SetWindowLong, (GDK_WINDOW_HWND (window), GWL_EXSTYLE, exstyle));
}
if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
ShowWindow (GDK_WINDOW_HWND (window), SW_MAXIMIZE);
else if (private->state & GDK_WINDOW_STATE_ICONIFIED)
ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
- else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
+ else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP || !focus_on_map)
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNOACTIVATE);
else
ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNORMAL);
if (raise)
- if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
- SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
- else
- BringWindowToTop (GDK_WINDOW_HWND (window));
+ {
+ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
+ SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOPMOST,
+ 0, 0, 0, 0,
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+ else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL ||
+ GDK_WINDOW_TYPE (window) == GDK_WINDOW_DIALOG)
+ SetForegroundWindow (GDK_WINDOW_HWND (window));
+ else
+ BringWindowToTop (GDK_WINDOW_HWND (window));
+ }
else if (old_active_window != GDK_WINDOW_HWND (window))
SetActiveWindow (old_active_window);
}
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);
+ SetWindowPos (GDK_WINDOW_HWND (window), HWND_BOTTOM,
+ 0, 0, 0, 0,
+ SWP_HIDEWINDOW | SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE);
}
else
{
if (GDK_WINDOW_DESTROYED (window))
return;
- GDK_NOTE (MISC, g_print ("gdk_window_move: %p: +%d+%d\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_move: %p: %+d%+d\n",
GDK_WINDOW_HWND (window), x, y));
impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
return;
- if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
+ /* Don't check GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD.
+ * Foreign windows (another app's windows) might be children of our
+ * windows! Especially in the case of gtkplug/socket.
+ */
+ if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
_gdk_window_move_resize_child (window, x, y, impl->width, impl->height);
else
{
adjust_for_gravity_hints (impl, &outer_rect, &x, &y);
+ GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,0,0,"
+ "NOACTIVATE|NOSIZE|NOZORDER)\n",
+ GDK_WINDOW_HWND (window),
+ x - _gdk_offset_x, y - _gdk_offset_y));
+
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
x - _gdk_offset_x, y - _gdk_offset_y, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
return;
- if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
+ if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
_gdk_window_move_resize_child (window, private->x, private->y, width, height);
else
{
RECT outer_rect;
get_outer_rect (window, width, height, &outer_rect);
+ GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,0,0,%ld,%ld,"
+ "NOACTIVATE|NOMOVE|NOZORDER)\n",
+ GDK_WINDOW_HWND (window),
+ outer_rect.right - outer_rect.left,
+ outer_rect.bottom - outer_rect.top));
+
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
0, 0,
outer_rect.right - outer_rect.left,
if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
return;
- GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %p: %dx%d@+%d+%d\n",
+ 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)
+ if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
_gdk_window_move_resize_child (window, x, y, width, height);
else
{
adjust_for_gravity_hints (impl, &outer_rect, &x, &y);
+ GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%ld,%ld,"
+ "NOACTIVATE|NOZORDER)\n",
+ GDK_WINDOW_HWND (window),
+ x - _gdk_offset_x, y - _gdk_offset_y,
+ outer_rect.right - outer_rect.left,
+ outer_rect.bottom - outer_rect.top));
+
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
x - _gdk_offset_x, y - _gdk_offset_y,
outer_rect.right - outer_rect.left,
GdkWindowObject *parent_private;
GdkWindowObject *old_parent_private;
GdkWindowImplWin32 *impl;
+ gboolean was_toplevel;
+ LONG style;
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);
+ g_return_if_fail (window != _gdk_root);
+
+ if (GDK_WINDOW_DESTROYED (window) ||
+ (new_parent && GDK_WINDOW_DESTROYED (new_parent)))
+ {
+ return;
+ }
if (!new_parent)
- new_parent = _gdk_parent_root;
+ new_parent = _gdk_root;
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_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
- {
- GDK_NOTE (MISC, g_print ("gdk_window_reparent: %p: %p\n",
- GDK_WINDOW_HWND (window),
- GDK_WINDOW_HWND (new_parent)));
+ GDK_NOTE (MISC, g_print ("gdk_window_reparent: %p: %p\n",
+ GDK_WINDOW_HWND (window),
+ GDK_WINDOW_HWND (new_parent)));
- API_CALL (SetParent, (GDK_WINDOW_HWND (window),
- GDK_WINDOW_HWND (new_parent)));
+ style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
- API_CALL (MoveWindow, (GDK_WINDOW_HWND (window),
- x, y, impl->width, impl->height, TRUE));
+ was_toplevel = GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) == GetDesktopWindow ();
+ if (was_toplevel && new_parent != _gdk_root)
+ {
+ /* Reparenting from top-level (child of desktop). Clear out
+ * decorations.
+ */
+ style &= ~(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
+ style |= WS_CHILD;
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
+ }
+ else if (new_parent == _gdk_root)
+ {
+ /* Reparenting to top-level. Add decorations. */
+ style &= ~(WS_CHILD);
+ style |= WS_OVERLAPPEDWINDOW;
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
}
+ API_CALL (SetParent, (GDK_WINDOW_HWND (window),
+ GDK_WINDOW_HWND (new_parent)));
+
+ API_CALL (MoveWindow, (GDK_WINDOW_HWND (window),
+ x, y, impl->width, impl->height, TRUE));
+
/* 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;
+ new_parent = _gdk_root;
window_private->parent = (GdkWindowObject *)new_parent;
+ /* Switch the window type as appropriate */
+
+ switch (GDK_WINDOW_TYPE (new_parent))
+ {
+ case GDK_WINDOW_ROOT:
+ if (impl->toplevel_window_type != -1)
+ GDK_WINDOW_TYPE (window) = impl->toplevel_window_type;
+ else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
+ GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
+ break;
+
+ case GDK_WINDOW_TOPLEVEL:
+ case GDK_WINDOW_CHILD:
+ case GDK_WINDOW_DIALOG:
+ case GDK_WINDOW_TEMP:
+ if (WINDOW_IS_TOPLEVEL (window))
+ {
+ /* Save the original window type so we can restore it if the
+ * window is reparented back to be a toplevel.
+ */
+ impl->toplevel_window_type = GDK_WINDOW_TYPE (window);
+ GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
+ }
+ }
+
if (old_parent_private)
old_parent_private->children =
g_list_remove (old_parent_private->children, window);
-#if 0
- if ((old_parent_private &&
- (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||
- (!old_parent_private && parent_private->guffaw_gravity))
- gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
-#endif
-
parent_private->children = g_list_prepend (parent_private->children, window);
_gdk_window_init_position (GDK_WINDOW (window_private));
}
if (height == 0)
height = impl->height - y;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area: %p: "
- "%dx%d@+%d+%d\n",
+ "%dx%d@%+d%+d\n",
GDK_WINDOW_HWND (window),
width, height, x, y));
hdc = GetDC (GDK_WINDOW_HWND (window));
RECT rect;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area_e: %p: "
- "%dx%d@+%d+%d\n",
+ "%dx%d@%+d%+d\n",
GDK_WINDOW_HWND (window),
width, height, x, y));
if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (MISC, g_print ("gdk_window_lower: %p\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_lower: %p\n"
+ "... SetWindowPos(%p,HWND_BOTTOM,0,0,0,0,"
+ "NOACTIVATE|NOMOVE|NOSIZE)\n",
+ GDK_WINDOW_HWND (window),
GDK_WINDOW_HWND (window)));
- API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_BOTTOM, 0, 0, 0, 0,
+ API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_BOTTOM,
+ 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE));
}
}
impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
- GDK_NOTE (MISC, g_print ("gdk_window_set_hints: %p: %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));
}
}
+void
+gdk_window_set_urgency_hint (GdkWindow *window,
+ gboolean urgent)
+{
+ FLASHWINFO flashwinfo;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+ g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ flashwinfo.cbSize = sizeof (flashwinfo);
+ flashwinfo.hwnd = GDK_WINDOW_HWND (window);
+ if (urgent)
+ flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
+ else
+ flashwinfo.dwFlags = FLASHW_STOP;
+ flashwinfo.uCount = 0;
+ flashwinfo.dwTimeout = 0;
+
+ FlashWindowEx (&flashwinfo);
+}
+
void
gdk_window_set_geometry_hints (GdkWindow *window,
GdkGeometry *geometry,
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",
+ GDK_NOTE (MISC, g_print ("... setting: rcNormal: (%ld,%ld)--(%ld,%ld)\n",
size_hints.rcNormalPosition.left,
size_hints.rcNormalPosition.top,
size_hints.rcNormalPosition.right,
gdk_window_set_title (GdkWindow *window,
const gchar *title)
{
- char *mbtitle;
-
- g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (title != NULL);
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
/* 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: %p: %s\n",
GDK_WINDOW_HWND (window), title));
- if (!GDK_WINDOW_DESTROYED (window))
+ if (G_WIN32_HAVE_WIDECHAR_API ())
{
- /* As the title is in UTF-8 we must translate it
- * to the system codepage.
- */
- mbtitle = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
- API_CALL (SetWindowText, (GDK_WINDOW_HWND (window), mbtitle));
- g_free (mbtitle);
+ wchar_t *wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
+ API_CALL (SetWindowTextW, (GDK_WINDOW_HWND (window), wtitle));
+ g_free (wtitle);
+ }
+ else
+ {
+ char *cptitle = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
+ API_CALL (SetWindowTextA, (GDK_WINDOW_HWND (window), cptitle));
+ g_free (cptitle);
}
}
if (((GdkWindowObject *) window)->window_type == GDK_WINDOW_CHILD)
{
- GDK_NOTE (MISC, g_print ("...a child window!\n"));
+ GDK_NOTE (MISC, g_print ("... a child window!\n"));
return;
}
}
void
-gdk_window_set_background (GdkWindow *window,
- GdkColor *color)
+gdk_window_set_background (GdkWindow *window,
+ const GdkColor *color)
{
GdkWindowObject *private = (GdkWindowObject *)window;
g_return_if_fail (pixmap == NULL || !parent_relative);
g_return_if_fail (pixmap == NULL || gdk_drawable_get_depth (window) == gdk_drawable_get_depth (pixmap));
+ if (pixmap && !gdk_drawable_get_colormap (pixmap))
+ {
+ g_warning ("gdk_window_set_back_pixmap(): pixmap must have a colormap");
+ return;
+ }
+
if (private->bg_pixmap &&
private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
private->bg_pixmap != GDK_NO_BG)
*/
if ((impl->hcursor = CopyCursor (hcursor)) == NULL)
WIN32_API_FAILED ("CopyCursor");
- GDK_NOTE (MISC, g_print ("...CopyCursor (%p) = %p\n",
+ GDK_NOTE (MISC, g_print ("... CopyCursor (%p) = %p\n",
hcursor, impl->hcursor));
}
- /* If the pointer is over our window, set new cursor if given */
- if (gdk_window_get_pointer(window, NULL, NULL, NULL) == window)
- if (impl->hcursor != NULL)
- SetCursor (impl->hcursor);
+ if (impl->hcursor != NULL)
+ {
+ /* If the pointer is over our window, set new cursor */
+ GdkWindow *curr_window = gdk_window_get_pointer (window, NULL, NULL, NULL);
+ if (curr_window == window)
+ SetCursor (impl->hcursor);
+ else
+ {
+ /* Climb up the tree and find whether our window is the
+ * first ancestor that has cursor defined, and if so, set
+ * new cursor.
+ */
+ GdkWindowObject *curr_window_obj = GDK_WINDOW_OBJECT (curr_window);
+ while (curr_window_obj &&
+ !GDK_WINDOW_IMPL_WIN32 (curr_window_obj->impl)->hcursor)
+ {
+ curr_window_obj = curr_window_obj->parent;
+ if (curr_window_obj == GDK_WINDOW_OBJECT (window))
+ {
+ SetCursor (impl->hcursor);
+ break;
+ }
+ }
+ }
+ }
/* 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
SetCursor (hcursor);
}
- GDK_NOTE (MISC, g_print ("...DestroyCursor (%p)\n",
- hprevcursor));
+ GDK_NOTE (MISC, g_print ("... DestroyCursor (%p)\n", hprevcursor));
API_CALL (DestroyCursor, (hprevcursor));
}
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!window)
- window = _gdk_parent_root;
+ window = _gdk_root;
if (!GDK_WINDOW_DESTROYED (window))
{
API_CALL (GetClientRect, (GDK_WINDOW_HWND (window), &rect));
- if (window != _gdk_parent_root)
+ if (window != _gdk_root)
{
POINT pt;
GdkWindow *parent = gdk_window_get_parent (window);
rect.right = pt.x;
rect.bottom = pt.y;
- if (parent == _gdk_parent_root)
+ if (parent == _gdk_root)
{
rect.left += _gdk_offset_x;
rect.top += _gdk_offset_y;
if (depth)
*depth = gdk_drawable_get_visual (window)->depth;
- GDK_NOTE (MISC, g_print ("gdk_window_get_geometry: %p: %ldx%ldx%d@+%ld+%ld\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_get_geometry: %p: %ldx%ldx%d@%+ld%+ld\n",
GDK_WINDOW_HWND (window),
rect.right - rect.left, rect.bottom - rect.top,
gdk_drawable_get_visual (window)->depth,
if (y)
*y = ty + _gdk_offset_y;
- GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %p: +%d+%d\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %p: %+d%+d\n",
GDK_WINDOW_HWND (window),
tx, ty));
return return_val;
if (y)
*y = rect.y;
- GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %p: +%d+%d\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %p: %+d%+d\n",
GDK_WINDOW_HWND (window), rect.x, rect.y));
}
private = (GdkWindowObject*) private->parent;
hwnd = GDK_WINDOW_HWND (window);
-
- /* find the frame window */
- while (HWND_DESKTOP != GetParent (hwnd))
- {
- hwnd = GetParent (hwnd);
- g_return_if_fail (NULL != hwnd);
- }
-
API_CALL (GetWindowRect, (hwnd, &r));
rect->x = r.left + _gdk_offset_x;
rect->width = r.right - r.left;
rect->height = r.bottom - r.top;
- GDK_NOTE (MISC, g_print ("gdk_window_get_frame_extents: %p: %ldx%ld@+%ld+%ld\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_get_frame_extents: %p: %ldx%ld@%+ld%+ld\n",
GDK_WINDOW_HWND (window),
r.right - r.left, r.bottom - r.top,
r.left, r.top));
*x = point.x;
*y = point.y;
- if (window == _gdk_parent_root)
+ if (window == _gdk_root)
{
*x += _gdk_offset_x;
*y += _gdk_offset_y;
_gdk_windowing_window_get_pointer (display, root_window, x, y, mask);
}
+void
+gdk_display_warp_pointer (GdkDisplay *display,
+ GdkScreen *screen,
+ gint x,
+ gint y)
+{
+ SetCursorPos (x, y);
+}
+
GdkWindow*
_gdk_windowing_window_at_pointer (GdkDisplay *display,
gint *win_x,
if (hwnd == NULL)
{
- window = _gdk_parent_root;
+ window = _gdk_root;
*win_x = pointc.x + _gdk_offset_x;
*win_y = pointc.y + _gdk_offset_y;
return window;
*win_y = point.y - rect.top;
}
- GDK_NOTE (MISC, g_print ("_gdk_windowing_window_at_pointer: +%d+%d %p%s\n",
+ GDK_NOTE (MISC, g_print ("_gdk_windowing_window_at_pointer: %+d%+d %p%s\n",
*win_x, *win_y,
hwnd,
(window == NULL ? " NULL" : "")));
g_warning ("gdk_window_set_override_redirect not implemented");
}
-void
-gdk_window_set_icon_list (GdkWindow *window,
- GList *pixbufs)
+void
+gdk_window_set_accept_focus (GdkWindow *window,
+ gboolean accept_focus)
{
+ 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;
+
+ accept_focus = accept_focus != FALSE;
- /* 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 ?
- */
+ if (private->accept_focus != accept_focus)
+ private->accept_focus = accept_focus;
+}
+
+void
+gdk_window_set_focus_on_map (GdkWindow *window,
+ gboolean focus_on_map)
+{
+ GdkWindowObject *private;
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ private = (GdkWindowObject *)window;
+
+ focus_on_map = focus_on_map != FALSE;
+
+ if (private->focus_on_map != focus_on_map)
+ private->focus_on_map = focus_on_map;
}
void
-gdk_window_set_icon (GdkWindow *window,
- GdkWindow *icon_window,
- GdkPixmap *pixmap,
- GdkBitmap *mask)
+gdk_window_set_icon_list (GdkWindow *window,
+ GList *pixbufs)
{
- ICONINFO ii;
- HICON hIcon;
- gint w = 0, h = 0;
+ GdkPixbuf *pixbuf, *big_pixbuf, *small_pixbuf;
+ gint big_diff, small_diff;
+ gint big_w, big_h, small_w, small_h;
+ gint w, h;
+ gint dw, dh, diff;
+ HICON small_hicon, big_hicon;
GdkWindowImplWin32 *impl;
+ gint i, big_i, small_i;
- g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
- if (pixmap)
- {
- static int num = 0;
- HBITMAP hbmmask = NULL;
-
- gdk_drawable_get_size (GDK_DRAWABLE(pixmap), &w, &h);
+ /* ideal sizes for small and large icons */
+ big_w = GetSystemMetrics (SM_CXICON);
+ big_h = GetSystemMetrics (SM_CYICON);
+ small_w = GetSystemMetrics (SM_CXSMICON);
+ small_h = GetSystemMetrics (SM_CYSMICON);
+
+ /* find closest sized icons in the list */
+ big_pixbuf = NULL;
+ small_pixbuf = NULL;
+ big_diff = 0;
+ small_diff = 0;
+ i = 0;
+ while (pixbufs)
+ {
+ pixbuf = (GdkPixbuf*) pixbufs->data;
+ w = gdk_pixbuf_get_width (pixbuf);
+ h = gdk_pixbuf_get_height (pixbuf);
+
+ dw = ABS (w - big_w);
+ dh = ABS (h - big_h);
+ diff = dw*dw + dh*dh;
+ if (big_pixbuf == NULL || diff < big_diff)
+ {
+ big_pixbuf = pixbuf;
+ big_diff = diff;
+ big_i = i;
+ }
- /* we need the inverted mask for the XOR op */
- {
- HDC hdc1 = CreateCompatibleDC (NULL);
- HBITMAP hbmold1;
-
- hbmmask = CreateCompatibleBitmap (hdc1, w, h);
- hbmold1 = SelectObject (hdc1, hbmmask);
- if (mask)
- {
- HDC hdc2 = CreateCompatibleDC (NULL);
- HBITMAP hbmold2 = SelectObject (hdc2, GDK_PIXMAP_HBITMAP (mask));
- GDI_CALL (BitBlt, (hdc1, 0,0,w,h, hdc2, 0,0, NOTSRCCOPY));
- GDI_CALL (SelectObject, (hdc2, hbmold2));
- GDI_CALL (DeleteDC, (hdc2));
- }
- else
- {
- RECT rect;
- GetClipBox (hdc1, &rect);
- GDI_CALL (FillRect, (hdc1, &rect, GetStockObject (WHITE_BRUSH)));
- }
- GDI_CALL (SelectObject, (hdc1, hbmold1));
- GDI_CALL (DeleteDC, (hdc1));
- }
-
- ii.fIcon = TRUE;
- ii.xHotspot = ii.yHotspot = 0; /* ignored for icons */
- ii.hbmMask = hbmmask;
- ii.hbmColor = GDK_PIXMAP_HBITMAP (pixmap);
- hIcon = CreateIconIndirect (&ii);
- if (!hIcon)
- WIN32_API_FAILED ("CreateIconIndirect");
- GDI_CALL (DeleteObject, (hbmmask));
-#if 0 /* to debug pixmap and mask setting */
- {
- GdkPixbuf* pixbuf = NULL;
- char name[256];
-
- pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL, 0, 0, 0, 0, w, h);
- if (pixbuf)
- {
- num = (num + 1) % 999; /* restrict maximim number */
- sprintf (name, "c:\\temp\\ico%03dpixm.png", num);
- gdk_pixbuf_save (pixbuf, name, "png", NULL, NULL);
- gdk_pixbuf_unref (pixbuf);
- }
- pixbuf = !mask ? NULL : gdk_pixbuf_get_from_drawable (NULL, mask, NULL, 0, 0, 0, 0, w, h);
- if (pixbuf)
- {
- sprintf (name, "c:\\temp\\ico%03dmask.png", num);
- gdk_pixbuf_save (pixbuf, name, "png", NULL, NULL);
- gdk_pixbuf_unref (pixbuf);
- }
- }
-#endif
+ dw = ABS(w - small_w);
+ dh = ABS(h - small_h);
+ diff = dw*dw + dh*dh;
+ if (small_pixbuf == NULL || diff < small_diff)
+ {
+ small_pixbuf = pixbuf;
+ small_diff = diff;
+ small_i = i;
+ }
- hIcon = (HICON)SendMessage (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG, (LPARAM)hIcon);
- if (impl->hicon)
- GDI_CALL (DestroyIcon, (impl->hicon));
- impl->hicon = hIcon;
- }
- else
- {
- /* reseting to default icon */
- if (impl->hicon)
- {
- hIcon = (HICON)SendMessage (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG, 0);
- GDI_CALL (DestroyIcon, (impl->hicon));
- impl->hicon = NULL;
- }
+ pixbufs = g_list_next (pixbufs);
+ i++;
}
- GDK_NOTE (MISC, g_print ("gdk_window_set_icon: %p: %p %dx%d\n", GDK_WINDOW_HWND (window), impl->hicon, w, h));
+ /* Create the icons */
+ big_hicon = _gdk_win32_pixbuf_to_hicon (big_pixbuf);
+ small_hicon = _gdk_win32_pixbuf_to_hicon (small_pixbuf);
+
+ /* Set the icons */
+ SendMessage (GDK_WINDOW_HWND (window), WM_SETICON, ICON_BIG,
+ (LPARAM)big_hicon);
+ SendMessage (GDK_WINDOW_HWND (window), WM_SETICON, ICON_SMALL,
+ (LPARAM)small_hicon);
+
+ /* Store the icons, destroying any previous icons */
+ if (impl->hicon_big)
+ GDI_CALL (DestroyIcon, (impl->hicon_big));
+ impl->hicon_big = big_hicon;
+ if (impl->hicon_small)
+ GDI_CALL (DestroyIcon, (impl->hicon_small));
+ impl->hicon_small = small_hicon;
+}
+
+void
+gdk_window_set_icon (GdkWindow *window,
+ GdkWindow *icon_window,
+ GdkPixmap *pixmap,
+ GdkBitmap *mask)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ /* do nothing, use gdk_window_set_icon_list instead */
}
void
API_CALL (SetWindowText, (GDK_WINDOW_HWND (window), name));
}
+GdkWindow *
+gdk_window_get_group (GdkWindow *window)
+{
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return NULL;
+
+ g_warning ("gdk_window_get_group not yet implemented");
+
+ return NULL;
+}
+
void
gdk_window_set_group (GdkWindow *window,
GdkWindow *leader)
style &= ~settable_bits, style |= bits;
SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
- SetWindowPos (GDK_WINDOW_HWND (window), NULL, 0, 0, 0, 0,
+ SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
}
style &= ~settable_bits, style |= bits;
SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
- SetWindowPos (GDK_WINDOW_HWND (window), NULL, 0, 0, 0, 0,
+ SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
}
gdk_window_set_static_gravities (GdkWindow *window,
gboolean use_static)
{
- GdkWindowObject *private = (GdkWindowObject *)window;
-
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
- if (!use_static == !private->guffaw_gravity)
- return TRUE;
+ return !use_static;
+}
+
+void
+gdk_window_begin_resize_drag (GdkWindow *window,
+ GdkWindowEdge edge,
+ gint button,
+ gint root_x,
+ gint root_y,
+ guint32 timestamp)
+{
+ WPARAM winedge;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ /* Tell Windows to start interactively resizing the window by pretending that
+ * the left pointer button was clicked in the suitable edge or corner. This
+ * will only work if the button is down when this function is called, and
+ * will only work with button 1 (left), since Windows only allows window
+ * dragging using the left mouse button */
+ if (button != 1)
+ return;
- if (use_static)
- return FALSE;
+ /* Must break the automatic grab that occured when the button was pressed,
+ * otherwise it won't work */
+ gdk_display_pointer_ungrab (gdk_display_get_default (), 0);
+
+ switch (edge)
+ {
+ case GDK_WINDOW_EDGE_NORTH_WEST:
+ winedge = HTTOPLEFT;
+ break;
+
+ case GDK_WINDOW_EDGE_NORTH:
+ winedge = HTTOP;
+ break;
+
+ case GDK_WINDOW_EDGE_NORTH_EAST:
+ winedge = HTTOPRIGHT;
+ break;
+
+ case GDK_WINDOW_EDGE_WEST:
+ winedge = HTLEFT;
+ break;
+
+ case GDK_WINDOW_EDGE_EAST:
+ winedge = HTRIGHT;
+ break;
+
+ case GDK_WINDOW_EDGE_SOUTH_WEST:
+ winedge = HTBOTTOMLEFT;
+ break;
+
+ case GDK_WINDOW_EDGE_SOUTH:
+ winedge = HTBOTTOM;
+ break;
+
+ case GDK_WINDOW_EDGE_SOUTH_EAST:
+ default:
+ winedge = HTBOTTOMRIGHT;
+ break;
+ }
+
+ DefWindowProc (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, winedge,
+ MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
+}
+
+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));
- private->guffaw_gravity = use_static;
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ /* Tell Windows to start interactively moving the window by pretending that
+ * the left pointer button was clicked in the titlebar. This will only work
+ * if the button is down when this function is called, and will only work
+ * with button 1 (left), since Windows only allows window dragging using the
+ * left mouse button */
+ if (button != 1)
+ return;
- return TRUE;
+ /* Must break the automatic grab that occured when the button was pressed,
+ * otherwise it won't work */
+ gdk_display_pointer_ungrab (gdk_display_get_default (), 0);
+
+ DefWindowProc (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, HTCAPTION,
+ MAKELPARAM (root_x - _gdk_offset_x, root_y - _gdk_offset_y));
}
+
/*
* Setting window states
*/
SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
(fi->style & ~WS_OVERLAPPEDWINDOW) | WS_POPUP);
- if (!SetWindowPos (GDK_WINDOW_HWND (window), HWND_TOP /*not MOST, taskswitch!*/,
- 0, 0, width, height,
- SWP_NOCOPYBITS | SWP_SHOWWINDOW))
- WIN32_API_FAILED ("SetWindowPos");
+
+ API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP,
+ 0, 0, width, height,
+ SWP_NOCOPYBITS | SWP_SHOWWINDOW));
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
}
impl->hint_flags = fi->hint_flags;
SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, fi->style);
- if (!SetWindowPos (GDK_WINDOW_HWND (window), HWND_NOTOPMOST,
- fi->r.left, fi->r.top, fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
- SWP_NOCOPYBITS | SWP_SHOWWINDOW))
- WIN32_API_FAILED ("SetWindowPos");
-
+ API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_NOTOPMOST,
+ fi->r.left, fi->r.top,
+ fi->r.right - fi->r.left, fi->r.bottom - fi->r.top,
+ SWP_NOCOPYBITS | SWP_SHOWWINDOW));
+
g_object_set_data (G_OBJECT (window), "fullscreen-info", NULL);
g_free (fi);
if (GDK_WINDOW_IS_MAPPED (window))
{
- if (!SetWindowPos(GDK_WINDOW_HWND (window), setting ? HWND_TOPMOST : HWND_NOTOPMOST,
- 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE))
- WIN32_API_FAILED ("SetWindowPos");
+ API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
+ setting ? HWND_TOPMOST : HWND_NOTOPMOST,
+ 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
}
else
gdk_synthesize_window_state (window,
if (GDK_WINDOW_IS_MAPPED (window))
{
- if (!SetWindowPos(GDK_WINDOW_HWND (window), setting ? HWND_BOTTOM : HWND_NOTOPMOST,
- 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE))
- WIN32_API_FAILED ("SetWindowPos");
+ API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
+ setting ? HWND_BOTTOM : HWND_NOTOPMOST,
+ 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE));
}
else
gdk_synthesize_window_state (window,
if (GDK_WINDOW_IS_MAPPED (window))
API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window),
modal ? HWND_TOPMOST : HWND_NOTOPMOST,
- 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE));
+ 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE));
}
void
gdk_window_set_skip_taskbar_hint (GdkWindow *window,
gboolean skips_taskbar)
{
- LONG extended_style;
+ static GdkWindow *owner = NULL;
+ GdkWindowAttr wa;
g_return_if_fail (GDK_IS_WINDOW (window));
GDK_WINDOW_HWND (window),
skips_taskbar ? "TRUE" : "FALSE"));
- extended_style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);
-
if (skips_taskbar)
- extended_style |= WS_EX_TOOLWINDOW;
- else
- extended_style &= ~WS_EX_TOOLWINDOW;
+ {
+ if (owner == NULL)
+ {
+ wa.window_type = GDK_WINDOW_TEMP;
+ wa.wclass = GDK_INPUT_OUTPUT;
+ wa.width = wa.height = 1;
+ wa.event_mask = 0;
+ owner = gdk_window_new_internal (NULL, &wa, 0, TRUE);
+ }
+
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_HWNDPARENT,
+ (long) GDK_WINDOW_HWND (owner));
- SetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE, extended_style);
+#if 0 /* Should we also turn off the minimize and maximize buttons? */
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE,
+ GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE) & ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU));
+ SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+ 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE |
+ SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+#endif
+ }
+ else
+ {
+ SetWindowLong (GDK_WINDOW_HWND (window), GWL_HWNDPARENT, 0);
+ }
}
void
case GDK_WINDOW_TYPE_HINT_UTILITY:
break;
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
+ gdk_window_set_decorations (window,
+ GDK_DECOR_ALL |
+ GDK_DECOR_RESIZEH |
+ GDK_DECOR_MENU |
+ GDK_DECOR_MINIMIZE |
+ GDK_DECOR_MAXIMIZE);
break;
case GDK_WINDOW_TYPE_HINT_DOCK:
break;
/* 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)
+GdkWindow *
+gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
{
- g_return_if_fail (GDK_IS_WINDOW (window));
-
- if (GDK_WINDOW_DESTROYED (window))
- return;
+ g_return_val_if_fail (display == gdk_display_get_default(), NULL);
- /* XXX: isn't all this default on win32 ... */
+ return gdk_window_lookup (anid);
}
void
-gdk_window_begin_move_drag (GdkWindow *window,
- gint button,
- gint root_x,
- gint root_y,
- guint32 timestamp)
+gdk_window_enable_synchronized_configure (GdkWindow *window)
{
- g_return_if_fail (GDK_IS_WINDOW (window));
-
- if (GDK_WINDOW_DESTROYED (window))
- return;
-
- /* XXX: isn't all this default on win32 ... */
}
-GdkWindow *
-gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid)
+void
+gdk_window_configure_finished (GdkWindow *window)
{
- g_return_val_if_fail (display == gdk_display_get_default(), NULL);
-
- return gdk_window_lookup (anid);
}