gdk/win32/gdkprivate-win32.h Drop global variable _gdk_root_window, just

2005-03-16  Tor Lillqvist  <tml@novell.com>

	* gdk/win32/gdkprivate-win32.h
	* gdk/win32/*.c: Drop global variable _gdk_root_window, just call
	GetDesktopWindow(). Rename the GdkWindow* _gdk_parent_root to
	_gdk_root.

	* gdk/win32/gdkwindow-win32.h (GdkWindowImplWin32): Add
	toplevel_window_type field.

	* gdk/win32/gdkwindow-win32.c: As there is only one root
	window in GDK on Win32, we can compare directly to _gdk_root
	instead of checking the window type.
	(gdk_window_reparent): When reparenting a child of the desktop
	clear out the window decorations. Correspondingly, when
	reparenting to the desktop, add decorations. As in the X11
	backend, save the window type of a toplevel window when
	reparenting, in case it is reparented back to toplevel.
This commit is contained in:
Tor Lillqvist 2005-03-16 02:21:14 +00:00 committed by Tor Lillqvist
parent df9768cf3a
commit 34bfd71279
14 changed files with 164 additions and 73 deletions

View File

@ -15,6 +15,23 @@
windows have a GDK window type GDK_WINDOW_FOREIGN, but are still windows have a GDK window type GDK_WINDOW_FOREIGN, but are still
de facto child windows. de facto child windows.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/*.c: Drop global variable _gdk_root_window, just call
GetDesktopWindow(). Rename the GdkWindow* _gdk_parent_root to
_gdk_root.
* gdk/win32/gdkwindow-win32.h (GdkWindowImplWin32): Add
toplevel_window_type field.
* gdk/win32/gdkwindow-win32.c: As there is only one root window in
GDK on Win32, we can compare directly to _gdk_root instead of
checking the window type.
(gdk_window_reparent): When reparenting a child of the desktop
clear out the window decorations. Correspondingly, when
reparenting to the desktop, add decorations. As in the X11
backend, save the window type of a toplevel window when
reparenting, in case it is reparented back to toplevel.
2005-03-15 Matthias Clasen <mclasen@redhat.com> 2005-03-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkradioaction.c (gtk_radio_action_get_group): Add an * gtk/gtkradioaction.c (gtk_radio_action_get_group): Add an

View File

@ -15,6 +15,23 @@
windows have a GDK window type GDK_WINDOW_FOREIGN, but are still windows have a GDK window type GDK_WINDOW_FOREIGN, but are still
de facto child windows. de facto child windows.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/*.c: Drop global variable _gdk_root_window, just call
GetDesktopWindow(). Rename the GdkWindow* _gdk_parent_root to
_gdk_root.
* gdk/win32/gdkwindow-win32.h (GdkWindowImplWin32): Add
toplevel_window_type field.
* gdk/win32/gdkwindow-win32.c: As there is only one root window in
GDK on Win32, we can compare directly to _gdk_root instead of
checking the window type.
(gdk_window_reparent): When reparenting a child of the desktop
clear out the window decorations. Correspondingly, when
reparenting to the desktop, add decorations. As in the X11
backend, save the window type of a toplevel window when
reparenting, in case it is reparented back to toplevel.
2005-03-15 Matthias Clasen <mclasen@redhat.com> 2005-03-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkradioaction.c (gtk_radio_action_get_group): Add an * gtk/gtkradioaction.c (gtk_radio_action_get_group): Add an

View File

@ -15,6 +15,23 @@
windows have a GDK window type GDK_WINDOW_FOREIGN, but are still windows have a GDK window type GDK_WINDOW_FOREIGN, but are still
de facto child windows. de facto child windows.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/*.c: Drop global variable _gdk_root_window, just call
GetDesktopWindow(). Rename the GdkWindow* _gdk_parent_root to
_gdk_root.
* gdk/win32/gdkwindow-win32.h (GdkWindowImplWin32): Add
toplevel_window_type field.
* gdk/win32/gdkwindow-win32.c: As there is only one root window in
GDK on Win32, we can compare directly to _gdk_root instead of
checking the window type.
(gdk_window_reparent): When reparenting a child of the desktop
clear out the window decorations. Correspondingly, when
reparenting to the desktop, add decorations. As in the X11
backend, save the window type of a toplevel window when
reparenting, in case it is reparented back to toplevel.
2005-03-15 Matthias Clasen <mclasen@redhat.com> 2005-03-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkradioaction.c (gtk_radio_action_get_group): Add an * gtk/gtkradioaction.c (gtk_radio_action_get_group): Add an

View File

@ -971,7 +971,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
private = GDK_DRAG_CONTEXT_PRIVATE_DATA (context); private = GDK_DRAG_CONTEXT_PRIVATE_DATA (context);
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES; context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE; context->is_source = FALSE;
context->source_window = _gdk_parent_root; context->source_window = _gdk_root;
g_object_ref (context->source_window); g_object_ref (context->source_window);
context->dest_window = event->any.window; context->dest_window = event->any.window;
g_object_ref (context->dest_window); g_object_ref (context->dest_window);

View File

@ -677,13 +677,13 @@ find_real_window_for_grabbed_mouse_event (GdkWindow* reported_window,
GetClientRect (hwnd, &rect); GetClientRect (hwnd, &rect);
ScreenToClient (hwnd, &pt); ScreenToClient (hwnd, &pt);
if (!PtInRect (&rect, pt)) if (!PtInRect (&rect, pt))
return _gdk_parent_root; return _gdk_root;
other_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd); other_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
} }
if (other_window == NULL) if (other_window == NULL)
return _gdk_parent_root; return _gdk_root;
return other_window; return other_window;
} }
@ -1678,7 +1678,7 @@ propagate (GdkWindow **window,
{ {
/* Owner doesn't want it, propagate to parent. */ /* Owner doesn't want it, propagate to parent. */
GdkWindow *parent = gdk_window_get_parent (*window); GdkWindow *parent = gdk_window_get_parent (*window);
if (parent == _gdk_parent_root || parent == NULL) if (parent == _gdk_root || parent == NULL)
{ {
/* No parent; check if grabbed */ /* No parent; check if grabbed */
if (grab_window != NULL) if (grab_window != NULL)
@ -1790,7 +1790,7 @@ handle_configure_event (MSG *msg,
point.x = client_rect.left; /* always 0 */ point.x = client_rect.left; /* always 0 */
point.y = client_rect.top; point.y = client_rect.top;
/* top level windows need screen coords */ /* top level windows need screen coords */
if (gdk_window_get_parent (window) == _gdk_parent_root) if (gdk_window_get_parent (window) == _gdk_root)
{ {
ClientToScreen (msg->hwnd, &point); ClientToScreen (msg->hwnd, &point);
point.x += _gdk_offset_x; point.x += _gdk_offset_x;
@ -2773,7 +2773,7 @@ gdk_event_translate (GdkDisplay *display,
if (current_window != NULL && if (current_window != NULL &&
(((GdkWindowObject *) current_window)->event_mask & GDK_LEAVE_NOTIFY_MASK)) (((GdkWindowObject *) current_window)->event_mask & GDK_LEAVE_NOTIFY_MASK))
{ {
synthesize_crossing_events (_gdk_parent_root, GDK_CROSSING_NORMAL, msg); synthesize_crossing_events (_gdk_root, GDK_CROSSING_NORMAL, msg);
} }
break; break;
@ -3055,7 +3055,7 @@ gdk_event_translate (GdkDisplay *display,
point.x = client_rect.left; /* always 0 */ point.x = client_rect.left; /* always 0 */
point.y = client_rect.top; point.y = client_rect.top;
/* top level windows need screen coords */ /* top level windows need screen coords */
if (gdk_window_get_parent (window) == _gdk_parent_root) if (gdk_window_get_parent (window) == _gdk_root)
{ {
ClientToScreen (msg->hwnd, &point); ClientToScreen (msg->hwnd, &point);
point.x += _gdk_offset_x; point.x += _gdk_offset_x;
@ -3319,7 +3319,7 @@ gdk_event_translate (GdkDisplay *display,
case WM_DESTROY: case WM_DESTROY:
if (window == current_window) if (window == current_window)
assign_object (&current_window, _gdk_parent_root); assign_object (&current_window, _gdk_root);
if (p_grab_window == window) if (p_grab_window == window)
gdk_pointer_ungrab (msg->time); gdk_pointer_ungrab (msg->time);
@ -3327,7 +3327,7 @@ gdk_event_translate (GdkDisplay *display,
if (k_grab_window == window) if (k_grab_window == window)
gdk_keyboard_ungrab (msg->time); gdk_keyboard_ungrab (msg->time);
if ((window != NULL) && (_gdk_root_window != msg->hwnd)) if ((window != NULL) && (msg->hwnd != GetDesktopWindow ()))
gdk_window_destroy_notify (window); gdk_window_destroy_notify (window);
if (window == NULL || GDK_WINDOW_DESTROYED (window)) if (window == NULL || GDK_WINDOW_DESTROYED (window))

View File

@ -31,14 +31,13 @@
GdkDisplay *_gdk_display = NULL; GdkDisplay *_gdk_display = NULL;
GdkScreen *_gdk_screen = NULL; GdkScreen *_gdk_screen = NULL;
GdkWindow *_gdk_parent_root = NULL; GdkWindow *_gdk_root = NULL;
gint _gdk_num_monitors; gint _gdk_num_monitors;
GdkRectangle *_gdk_monitors = NULL; GdkRectangle *_gdk_monitors = NULL;
gint _gdk_offset_x, _gdk_offset_y; gint _gdk_offset_x, _gdk_offset_y;
HWND _gdk_root_window = NULL;
HDC _gdk_display_hdc; HDC _gdk_display_hdc;
HINSTANCE _gdk_dll_hinstance; HINSTANCE _gdk_dll_hinstance;
HINSTANCE _gdk_app_hmodule; HINSTANCE _gdk_app_hmodule;

View File

@ -596,7 +596,7 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
if (gdkdev->info.mode == GDK_MODE_SCREEN) if (gdkdev->info.mode == GDK_MODE_SCREEN)
{ {
root_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl); root_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl);
x_scale = root_impl->width / device_width; x_scale = root_impl->width / device_width;
y_scale = root_impl->height / device_height; y_scale = root_impl->height / device_height;
@ -756,7 +756,7 @@ _gdk_input_other_event (GdkEvent *event,
#if USE_SYSCONTEXT #if USE_SYSCONTEXT
window = gdk_window_at_pointer (&x, &y); window = gdk_window_at_pointer (&x, &y);
if (window == NULL) if (window == NULL)
window = _gdk_parent_root; window = _gdk_root;
g_object_ref (window); g_object_ref (window);
display = gdk_drawable_get_display (window); display = gdk_drawable_get_display (window);
@ -794,7 +794,7 @@ _gdk_input_other_event (GdkEvent *event,
GDK_NOTE (EVENTS_OR_INPUT, g_print ("... ignored when moving/sizing\n")); GDK_NOTE (EVENTS_OR_INPUT, g_print ("... ignored when moving/sizing\n"));
return FALSE; return FALSE;
} }
if (window == _gdk_parent_root && x_grab_window == NULL) if (window == _gdk_root && x_grab_window == NULL)
{ {
GDK_NOTE (EVENTS_OR_INPUT, g_print ("... is root\n")); GDK_NOTE (EVENTS_OR_INPUT, g_print ("... is root\n"));
return FALSE; return FALSE;
@ -882,7 +882,7 @@ _gdk_input_other_event (GdkEvent *event,
{ {
GDK_NOTE (EVENTS_OR_INPUT, g_print ("... not selected\n")); GDK_NOTE (EVENTS_OR_INPUT, g_print ("... not selected\n"));
if (obj->parent == GDK_WINDOW_OBJECT (_gdk_parent_root)) if (obj->parent == GDK_WINDOW_OBJECT (_gdk_root))
return FALSE; return FALSE;
/* It is not good to propagate the extended events up to the parent /* It is not good to propagate the extended events up to the parent

View File

@ -97,7 +97,6 @@ _gdk_windowing_init (void)
_gdk_app_hmodule = GetModuleHandle (NULL); _gdk_app_hmodule = GetModuleHandle (NULL);
_gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL); _gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
_gdk_root_window = GetDesktopWindow ();
_gdk_input_locale = GetKeyboardLayout (0); _gdk_input_locale = GetKeyboardLayout (0);
_gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale); _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT), GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
@ -174,13 +173,13 @@ gdk_get_use_xshm (void)
gint gint
gdk_screen_get_width (GdkScreen *screen) gdk_screen_get_width (GdkScreen *screen)
{ {
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->width; return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl)->width;
} }
gint gint
gdk_screen_get_height (GdkScreen *screen) gdk_screen_get_height (GdkScreen *screen)
{ {
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->height; return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl)->height;
} }
gint gint
gdk_screen_get_width_mm (GdkScreen *screen) gdk_screen_get_width_mm (GdkScreen *screen)

View File

@ -158,7 +158,7 @@ gdk_pixmap_new (GdkDrawable *drawable,
g_return_val_if_fail ((width != 0) && (height != 0), NULL); g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (!drawable) if (!drawable)
drawable = _gdk_parent_root; drawable = _gdk_root;
if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable)) if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL; return NULL;
@ -190,7 +190,7 @@ gdk_pixmap_new (GdkDrawable *drawable,
if (GDK_IS_WINDOW (drawable)) if (GDK_IS_WINDOW (drawable))
hwnd = GDK_WINDOW_HWND (drawable); hwnd = GDK_WINDOW_HWND (drawable);
else else
hwnd = GDK_WINDOW_HWND (_gdk_parent_root); hwnd = GetDesktopWindow ();
if ((hdc = GetDC (hwnd)) == NULL) if ((hdc = GetDC (hwnd)) == NULL)
{ {
WIN32_GDI_FAILED ("GetDC"); WIN32_GDI_FAILED ("GetDC");
@ -360,9 +360,8 @@ gdk_bitmap_create_from_data (GdkDrawable *drawable,
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
if (!drawable) if (!drawable)
drawable = _gdk_parent_root; drawable = _gdk_root;
else if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL; return NULL;
pixmap = gdk_pixmap_new (drawable, width, height, 1); pixmap = gdk_pixmap_new (drawable, width, height, 1);

View File

@ -443,8 +443,7 @@ void _gdk_win32_gdi_failed (const gchar *where,
extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM); extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
extern HWND _gdk_root_window; extern GdkWindow *_gdk_root;
extern GdkWindow *_gdk_parent_root;
extern GdkDisplay *_gdk_display; extern GdkDisplay *_gdk_display;
extern GdkScreen *_gdk_screen; extern GdkScreen *_gdk_screen;

View File

@ -492,7 +492,7 @@ gdk_property_delete (GdkWindow *window,
if (property == _gdk_selection_property) if (property == _gdk_selection_property)
_gdk_selection_property_delete (window); _gdk_selection_property_delete (window);
else if (property == _wm_transient_for) else if (property == _wm_transient_for)
gdk_window_set_transient_for (window, _gdk_parent_root); gdk_window_set_transient_for (window, _gdk_root);
else else
{ {
prop_name = gdk_atom_name (property); prop_name = gdk_atom_name (property);

View File

@ -32,7 +32,7 @@ gdk_screen_get_display (GdkScreen *screen)
GdkWindow * GdkWindow *
gdk_screen_get_root_window (GdkScreen *screen) gdk_screen_get_root_window (GdkScreen *screen)
{ {
return _gdk_parent_root; return _gdk_root;
} }
GdkColormap * GdkColormap *

View File

@ -85,6 +85,10 @@ static void gdk_window_impl_win32_finalize (GObject *object);
static gpointer parent_class = NULL; 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 GType
_gdk_window_impl_win32_get_type (void) _gdk_window_impl_win32_get_type (void)
{ {
@ -124,7 +128,7 @@ gdk_window_impl_win32_init (GdkWindowImplWin32 *impl)
{ {
impl->width = 1; impl->width = 1;
impl->height = 1; impl->height = 1;
impl->toplevel_window_type = -1;
impl->hcursor = NULL; impl->hcursor = NULL;
impl->hicon_big = NULL; impl->hicon_big = NULL;
impl->hicon_small = NULL; impl->hicon_small = NULL;
@ -308,7 +312,7 @@ _gdk_root_window_size_init (void)
GdkRectangle rect; GdkRectangle rect;
int i; int i;
impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) _gdk_parent_root)->impl); impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) _gdk_root)->impl);
rect = _gdk_monitors[0]; rect = _gdk_monitors[0];
for (i = 1; i < _gdk_num_monitors; i++) for (i = 1; i < _gdk_num_monitors; i++)
gdk_rectangle_union (&rect, _gdk_monitors+i, &rect); gdk_rectangle_union (&rect, _gdk_monitors+i, &rect);
@ -323,13 +327,13 @@ _gdk_windowing_window_init (void)
GdkWindowObject *private; GdkWindowObject *private;
GdkDrawableImplWin32 *draw_impl; GdkDrawableImplWin32 *draw_impl;
g_assert (_gdk_parent_root == NULL); g_assert (_gdk_root == NULL);
_gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL); _gdk_root = g_object_new (GDK_TYPE_WINDOW, NULL);
private = (GdkWindowObject *)_gdk_parent_root; private = (GdkWindowObject *)_gdk_root;
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl); 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->wrapper = GDK_DRAWABLE (private);
draw_impl->colormap = gdk_colormap_get_system (); draw_impl->colormap = gdk_colormap_get_system ();
g_object_ref (draw_impl->colormap); g_object_ref (draw_impl->colormap);
@ -341,9 +345,9 @@ _gdk_windowing_window_init (void)
_gdk_window_init_position (GDK_WINDOW (private)); _gdk_window_init_position (GDK_WINDOW (private));
gdk_win32_handle_table_insert ((HANDLE *) &_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 * static const gchar *
@ -505,7 +509,7 @@ gdk_window_new_internal (GdkWindow *parent,
if (!parent) if (!parent)
{ {
screen = gdk_screen_get_default (); screen = gdk_screen_get_default ();
parent = gdk_screen_get_root_window (screen); parent = _gdk_root;
} }
else else
screen = gdk_drawable_get_screen (parent); screen = gdk_drawable_get_screen (parent);
@ -537,7 +541,7 @@ gdk_window_new_internal (GdkWindow *parent,
* of the root window, except for actual creation. * of the root window, except for actual creation.
*/ */
if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN) if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)
parent = _gdk_parent_root; parent = _gdk_root;
private->parent = (GdkWindowObject *)parent; private->parent = (GdkWindowObject *)parent;
@ -570,7 +574,7 @@ gdk_window_new_internal (GdkWindow *parent,
* attributes->window_type for input-only windows * attributes->window_type for input-only windows
* before * before
*/ */
if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT) if (parent == _gdk_root)
private->window_type = GDK_WINDOW_TEMP; private->window_type = GDK_WINDOW_TEMP;
else else
private->window_type = GDK_WINDOW_CHILD; private->window_type = GDK_WINDOW_CHILD;
@ -610,11 +614,11 @@ gdk_window_new_internal (GdkWindow *parent,
{ {
case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_DIALOG: case GDK_WINDOW_DIALOG:
if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT) if (parent != _gdk_root)
{ {
g_warning (G_STRLOC ": Toplevel windows must be created as children\n" g_warning (G_STRLOC ": Toplevel windows must be created as children\n"
"of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN"); "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");
hparent = _gdk_root_window; hparent = GetDesktopWindow ();
} }
/* Children of foreign windows aren't toplevel windows */ /* Children of foreign windows aren't toplevel windows */
if (GDK_WINDOW_TYPE (orig_parent) == GDK_WINDOW_FOREIGN) if (GDK_WINDOW_TYPE (orig_parent) == GDK_WINDOW_FOREIGN)
@ -639,7 +643,7 @@ gdk_window_new_internal (GdkWindow *parent,
case GDK_WINDOW_TEMP: case GDK_WINDOW_TEMP:
/* A temp window is not necessarily a top level window */ /* A temp window is not necessarily a top level window */
dwStyle = (_gdk_parent_root == parent ? WS_POPUP : WS_CHILDWINDOW); dwStyle = (_gdk_root == parent ? WS_POPUP : WS_CHILDWINDOW);
dwStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; dwStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
dwExStyle |= WS_EX_TOOLWINDOW; dwExStyle |= WS_EX_TOOLWINDOW;
offset_x = _gdk_offset_x; offset_x = _gdk_offset_x;
@ -786,7 +790,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display,
private->parent = gdk_win32_handle_table_lookup ((GdkNativeWindow) parent); private->parent = gdk_win32_handle_table_lookup ((GdkNativeWindow) parent);
if (!private->parent || GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_FOREIGN) 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); private->parent->children = g_list_prepend (private->parent->children, window);
@ -795,7 +799,7 @@ gdk_window_foreign_new_for_display (GdkDisplay *display,
point.x = rect.left; point.x = rect.left;
point.y = rect.right; point.y = rect.right;
ClientToScreen ((HWND) anid, &point); ClientToScreen ((HWND) anid, &point);
if (parent != _gdk_root_window) if (parent != GetDesktopWindow ())
ScreenToClient (parent, &point); ScreenToClient (parent, &point);
private->x = point.x; private->x = point.x;
private->y = point.y; private->y = point.y;
@ -862,19 +866,13 @@ _gdk_windowing_window_destroy (GdkWindow *window,
void void
_gdk_windowing_window_destroy_foreign (GdkWindow *window) _gdk_windowing_window_destroy_foreign (GdkWindow *window)
{ {
/* It's somebody else's window, but in our hierarchy, /* It's somebody else's window, but in our hierarchy, so reparent it
* so reparent it to the root window, and then call * to the desktop, and then try to destroy it.
* DestroyWindow() on it.
*/ */
gdk_window_hide (window); gdk_window_hide (window);
gdk_window_reparent (window, NULL, 0, 0); gdk_window_reparent (window, NULL, 0, 0);
/* Is this too drastic? Many (most?) applications PostMessage (GDK_WINDOW_HWND (window), WM_CLOSE, 0, 0);
* 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);
} }
/* This function is called when the window really gone. /* This function is called when the window really gone.
@ -1197,7 +1195,7 @@ gdk_window_move (GdkWindow *window,
* Foreign windows (another app's windows) might be children of our * Foreign windows (another app's windows) might be children of our
* windows! Especially in the case of gtkplug/socket. * windows! Especially in the case of gtkplug/socket.
*/ */
if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != _gdk_root_window) if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
_gdk_window_move_resize_child (window, x, y, impl->width, impl->height); _gdk_window_move_resize_child (window, x, y, impl->width, impl->height);
else else
{ {
@ -1245,7 +1243,7 @@ gdk_window_resize (GdkWindow *window,
if (private->state & GDK_WINDOW_STATE_FULLSCREEN) if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
return; return;
if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != _gdk_root_window) if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
_gdk_window_move_resize_child (window, private->x, private->y, width, height); _gdk_window_move_resize_child (window, private->x, private->y, width, height);
else else
{ {
@ -1297,7 +1295,7 @@ gdk_window_move_resize (GdkWindow *window,
GDK_WINDOW_HWND (window), GDK_WINDOW_HWND (window),
width, height, x, y)); width, height, x, y));
if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != _gdk_root_window) if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
_gdk_window_move_resize_child (window, x, y, width, height); _gdk_window_move_resize_child (window, x, y, width, height);
else else
{ {
@ -1332,11 +1330,13 @@ gdk_window_reparent (GdkWindow *window,
GdkWindowObject *parent_private; GdkWindowObject *parent_private;
GdkWindowObject *old_parent_private; GdkWindowObject *old_parent_private;
GdkWindowImplWin32 *impl; GdkWindowImplWin32 *impl;
gboolean was_toplevel;
LONG style;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent)); 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) || if (GDK_WINDOW_DESTROYED (window) ||
(new_parent && GDK_WINDOW_DESTROYED (new_parent))) (new_parent && GDK_WINDOW_DESTROYED (new_parent)))
@ -1345,34 +1345,76 @@ gdk_window_reparent (GdkWindow *window,
} }
if (!new_parent) if (!new_parent)
new_parent = _gdk_parent_root; new_parent = _gdk_root;
window_private = (GdkWindowObject*) window; window_private = (GdkWindowObject*) window;
old_parent_private = (GdkWindowObject *) window_private->parent; old_parent_private = (GdkWindowObject *) window_private->parent;
parent_private = (GdkWindowObject*) new_parent; parent_private = (GdkWindowObject*) new_parent;
impl = GDK_WINDOW_IMPL_WIN32 (window_private->impl); 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)));
style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
was_toplevel = GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) == GetDesktopWindow ();
if (was_toplevel && new_parent != _gdk_root)
{ {
GDK_NOTE (MISC, g_print ("gdk_window_reparent: %p: %p\n", /* Reparenting from top-level (child of desktop). Clear out
GDK_WINDOW_HWND (window), * decorations.
GDK_WINDOW_HWND (new_parent))); */
style &= ~(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
API_CALL (SetParent, (GDK_WINDOW_HWND (window), style |= WS_CHILD;
GDK_WINDOW_HWND (new_parent))); SetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE, style);
API_CALL (MoveWindow, (GDK_WINDOW_HWND (window),
x, y, impl->width, impl->height, TRUE));
} }
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 /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like
* the root window * the root window
*/ */
if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN) if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
new_parent = _gdk_parent_root; new_parent = _gdk_root;
window_private->parent = (GdkWindowObject *)new_parent; 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) if (old_parent_private)
old_parent_private->children = old_parent_private->children =
g_list_remove (old_parent_private->children, window); g_list_remove (old_parent_private->children, window);
@ -1920,7 +1962,7 @@ gdk_window_get_geometry (GdkWindow *window,
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
if (!window) if (!window)
window = _gdk_parent_root; window = _gdk_root;
if (!GDK_WINDOW_DESTROYED (window)) if (!GDK_WINDOW_DESTROYED (window))
{ {
@ -1928,7 +1970,7 @@ gdk_window_get_geometry (GdkWindow *window,
API_CALL (GetClientRect, (GDK_WINDOW_HWND (window), &rect)); API_CALL (GetClientRect, (GDK_WINDOW_HWND (window), &rect));
if (window != _gdk_parent_root) if (window != _gdk_root)
{ {
POINT pt; POINT pt;
GdkWindow *parent = gdk_window_get_parent (window); GdkWindow *parent = gdk_window_get_parent (window);
@ -1947,7 +1989,7 @@ gdk_window_get_geometry (GdkWindow *window,
rect.right = pt.x; rect.right = pt.x;
rect.bottom = pt.y; rect.bottom = pt.y;
if (parent == _gdk_parent_root) if (parent == _gdk_root)
{ {
rect.left += _gdk_offset_x; rect.left += _gdk_offset_x;
rect.top += _gdk_offset_y; rect.top += _gdk_offset_y;
@ -2103,7 +2145,7 @@ _gdk_windowing_window_get_pointer (GdkDisplay *display,
*x = point.x; *x = point.x;
*y = point.y; *y = point.y;
if (window == _gdk_parent_root) if (window == _gdk_root)
{ {
*x += _gdk_offset_x; *x += _gdk_offset_x;
*y += _gdk_offset_y; *y += _gdk_offset_y;
@ -2191,7 +2233,7 @@ _gdk_windowing_window_at_pointer (GdkDisplay *display,
if (hwnd == NULL) if (hwnd == NULL)
{ {
window = _gdk_parent_root; window = _gdk_root;
*win_x = pointc.x + _gdk_offset_x; *win_x = pointc.x + _gdk_offset_x;
*win_y = pointc.y + _gdk_offset_y; *win_y = pointc.y + _gdk_offset_y;
return window; return window;

View File

@ -75,6 +75,8 @@ struct _GdkWindowImplWin32
GdkWin32PositionInfo position_info; GdkWin32PositionInfo position_info;
gint8 toplevel_window_type;
HCURSOR hcursor; HCURSOR hcursor;
HICON hicon_big; HICON hicon_big;
HICON hicon_small; HICON hicon_small;