gtk+ r19746 - in trunk: . gdk/quartz



Author: rhult
Date: Tue Mar 11 10:14:47 2008
New Revision: 19746
URL: http://svn.gnome.org/viewvc/gtk+?rev=19746&view=rev

Log:
2008-03-11  Richard Hult  <richard imendio com>

	* gdk/quartz/gdkwindow-quartz.c: Implement gdk_window_reparent.


Modified:
   trunk/ChangeLog
   trunk/gdk/quartz/gdkwindow-quartz.c

Modified: trunk/gdk/quartz/gdkwindow-quartz.c
==============================================================================
--- trunk/gdk/quartz/gdkwindow-quartz.c	(original)
+++ trunk/gdk/quartz/gdkwindow-quartz.c	Tue Mar 11 10:14:47 2008
@@ -1437,14 +1437,51 @@
 
 void
 gdk_window_reparent (GdkWindow *window,
-		     GdkWindow *new_parent,
-		     gint       x,
-		     gint       y)
-{
-  g_warning ("gdk_window_reparent: %p %p (%d, %d)", 
-	     window, new_parent, x, y);
+                     GdkWindow *new_parent,
+                     gint       x,
+                     gint       y)
+{
+  GdkWindowObject *private, *old_parent_private, *new_parent_private;
+  GdkWindowImplQuartz *impl, *old_parent_impl, *new_parent_impl;
+  NSView *view, *new_parent_view;
 
-  /* FIXME: Implement */
+  if (!new_parent || new_parent == _gdk_root)
+    {
+      /* Could be added, just needs implementing. */
+      g_warning ("Reparenting to root window is not supported yet in the Mac OS X backend");
+      return;
+    }
+
+  private = GDK_WINDOW_OBJECT (window);
+  impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
+  view = impl->view;
+
+  new_parent_private = GDK_WINDOW_OBJECT (new_parent);
+  new_parent_impl = GDK_WINDOW_IMPL_QUARTZ (new_parent_private->impl);
+  new_parent_view = new_parent_impl->view;
+
+  old_parent_private = GDK_WINDOW_OBJECT (private->parent);
+  old_parent_impl = GDK_WINDOW_IMPL_QUARTZ (old_parent_private->impl);
+
+  [view retain];
+
+  [view removeFromSuperview];
+  [new_parent_view addSubview:view];
+
+  [view release];
+
+  private->x = x;
+  private->y = y;
+  private->parent = (GdkWindowObject *)new_parent;
+
+  if (old_parent_private)
+    {
+      old_parent_private->children = g_list_remove (old_parent_private->children, window);
+      old_parent_impl->sorted_children = g_list_remove (old_parent_impl->sorted_children, window);
+    }
+
+  new_parent_private->children = g_list_prepend (new_parent_private->children, window);
+  new_parent_impl->sorted_children = g_list_prepend (new_parent_impl->sorted_children, window);
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]