]> Pileus Git - ~andy/gtk/commitdiff
Rename gdk_window_set_has_native to gdk_window_ensure_native
authorAlexander Larsson <alexl@redhat.com>
Mon, 1 Jun 2009 09:57:59 +0000 (11:57 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 1 Jun 2009 09:57:59 +0000 (11:57 +0200)
This also removes the (unimplemented) possibility to change a window to
non-native. This seems generally not very useful, and there are some problems
with it, for instance if two "users" need a window to be native and then
one of the "users" doesn't need it anymore it can't change it back, because
it is unaware of the other reason the window is native.

docs/reference/gdk/tmpl/events.sgml
docs/reference/gdk/tmpl/windows.sgml
gdk/gdkwindow.c
gdk/x11/gdkdrawable-x11.c
gdk/x11/gdkmain-x11.c
gdk/x11/gdkwindow-x11.c
tests/testwindows.c

index b4dff1b5ef7d76ac91f782eb8d003389bb160f5b..2c39b5ef66e256fdd8e483dca242c56e716500af 100644 (file)
@@ -94,6 +94,7 @@ for the possible window states
   was added in 2.8.
 @GDK_DAMAGE: the content of the window has been changed. This event type
   was added in 2.14.
+@GDK_EVENT_LAST: 
 
 <!-- ##### ENUM GdkEventMask ##### -->
 <para>
index 195aabb6a4a9bad02422bf6efa49a8176e4f5f69..2ecae48d1ff93a627ab2945258af200b14abfc1c 100644 (file)
@@ -200,6 +200,7 @@ Describes the kind of window.
 @GDK_WINDOW_DIALOG: useless/deprecated compatibility type
 @GDK_WINDOW_TEMP: override redirect temporary window (used to implement #GtkMenu)
 @GDK_WINDOW_FOREIGN: foreign window (see gdk_window_foreign_new())
+@GDK_WINDOW_OFFSCREEN: 
 
 <!-- ##### ENUM GdkWindowClass ##### -->
 <para>
index b20cf6950295748fb90866df9b640d2f1d88b072..1c4d625ab3b1a971c2c86d3e0cdfb823a02e1d7f 100644 (file)
@@ -1220,7 +1220,7 @@ gdk_window_reparent (GdkWindow *window,
   /* Reparenting to toplevel. Ensure we have a native window so this can work */
   if (new_parent_private->window_type == GDK_WINDOW_ROOT ||
       new_parent_private->window_type == GDK_WINDOW_FOREIGN)
-    gdk_window_set_has_native (window, TRUE);
+    gdk_window_ensure_native (window);
 
   do_reparent_to_impl = FALSE;
   if (gdk_window_has_impl (private))
@@ -1330,20 +1330,22 @@ gdk_window_reparent (GdkWindow *window,
 }
 
 /**
- * gdk_window_set_has_native:
+ * gdk_window_ensure_native:
  * @window: a #GdkWindow
- * @has_native: whethe the window should have a native window
  *
- * Tries to create or remove a window-system native window for this
- * GdkWindow. This may fail in some situations. For instance:
+ * Tries to ensure that there is a window-system native window for this
+ * GdkWindow. This may fail in some situations, returning %FALSE.
  *
- * Toplevel and foreign windows must have a native window.
  * Offscreen window and children of them can never have native windows.
+ *
  * Some backends may not support native child windows.
- * 
+ *
+ * Returns: %TRUE if the window has a native window, %FALSE otherwise
+ *
+ * Since: 2.18
  **/
-void
-gdk_window_set_has_native (GdkWindow *window, gboolean has_native)
+gboolean
+gdk_window_ensure_native (GdkWindow *window)
 {
   GdkWindowObject *private;
   GdkWindowObject *impl_window;
@@ -1358,87 +1360,66 @@ gdk_window_set_has_native (GdkWindow *window, gboolean has_native)
 
   if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT ||
       GDK_WINDOW_DESTROYED (window))
-    return;
+    return FALSE;
 
   private = (GdkWindowObject *) window;
-  
-  if (has_native)
-    {
-      /* Create native window */
 
-      if (gdk_window_has_impl (private))
-       /* Already has an impl, either native (ok) or
-          offscreen (not supported). Bail. */
-       return; 
+  impl_window = gdk_window_get_impl_window (private);
 
-      impl_window = gdk_window_get_impl_window (private);
-      if (impl_window->window_type == GDK_WINDOW_OFFSCREEN)
-       return; /* native in offscreens not supported */
+  if (impl_window->window_type == GDK_WINDOW_OFFSCREEN)
+    return FALSE; /* native in offscreens not supported */
 
-      screen = gdk_drawable_get_screen (window);
-      visual = gdk_drawable_get_visual (window);
+  if (impl_window == private)
+    /* Already has an impl, and its not offscreen . */
+    return TRUE;
 
-      attributes.colormap = gdk_drawable_get_colormap (window);
-      
-      old_impl = private->impl;
-      _gdk_window_impl_new (window, (GdkWindow *)private->parent, screen, visual,
-                           get_native_event_mask (private), &attributes, GDK_WA_COLORMAP);
-      new_impl = private->impl;
+  /* Need to create a native window */
 
-      private->impl = old_impl;
-      change_impl (private, private, new_impl);
-      
-      /* Native window creation will put the native window topmost in the
-       * native parent, which may be wrong wrt other native windows in the
-       * non-native hierarchy, so restack */
-      above = find_native_sibling_above (private->parent, private);
-      if (above)
-       {
-         listhead.data = window;
-         listhead.prev = NULL;
-         listhead.next = NULL;
-         GDK_WINDOW_IMPL_GET_IFACE (private->impl)->restack_under ((GdkWindow *)above,
-                                                                   &listhead);
-       }
-
-      recompute_visible_regions (private, FALSE, FALSE);
+  screen = gdk_drawable_get_screen (window);
+  visual = gdk_drawable_get_visual (window);
 
-      /* The shape may not have been set, as the clip region doesn't actually
-        change, so do it here manually */
-      GDK_WINDOW_IMPL_GET_IFACE (private->impl)->shape_combine_region ((GdkWindow *)private, private->clip_region, 0, 0);
+  attributes.colormap = gdk_drawable_get_colormap (window);
 
-      reparent_to_impl (private);
+  old_impl = private->impl;
+  _gdk_window_impl_new (window, (GdkWindow *)private->parent, screen, visual,
+                       get_native_event_mask (private), &attributes, GDK_WA_COLORMAP);
+  new_impl = private->impl;
 
-      if (!private->input_only)
-       {
-         GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_background (window, &private->bg_color);
-         if (private->bg_pixmap != NULL)
-           GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_back_pixmap (window, private->bg_pixmap);
-       }
-      
-      GDK_WINDOW_IMPL_GET_IFACE (private->impl)->input_shape_combine_region ((GdkWindow *)private, private->input_shape, 0, 0);
+  private->impl = old_impl;
+  change_impl (private, private, new_impl);
 
-      if (gdk_window_is_viewable (window))
-       GDK_WINDOW_IMPL_GET_IFACE (private->impl)->show (window);
-    }
-  else
+  /* Native window creation will put the native window topmost in the
+   * native parent, which may be wrong wrt other native windows in the
+   * non-native hierarchy, so restack */
+  above = find_native_sibling_above (private->parent, private);
+  if (above)
     {
-      /* Remove native window */
+      listhead.data = window;
+      listhead.prev = NULL;
+      listhead.next = NULL;
+      GDK_WINDOW_IMPL_GET_IFACE (private->impl)->restack_under ((GdkWindow *)above,
+                                                               &listhead);
+    }
 
-      if (!gdk_window_has_impl (private))
-       return;  /* Not native, can't remove */
+  recompute_visible_regions (private, FALSE, FALSE);
 
-      if (private->window_type == GDK_WINDOW_OFFSCREEN)
-       return; /* Not native, can't remove */
-      
-      if (private->parent == NULL ||
-         GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT)
-       return; /* toplevel, must be native */
+  /* The shape may not have been set, as the clip region doesn't actually
+     change, so do it here manually */
+  GDK_WINDOW_IMPL_GET_IFACE (private->impl)->shape_combine_region ((GdkWindow *)private, private->clip_region, 0, 0);
 
-      g_warning ("Tried to turn native window to client side window, this is not supported yet.");
+  reparent_to_impl (private);
 
-      /* TODO: remove native */
+  if (!private->input_only)
+    {
+      GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_background (window, &private->bg_color);
+      if (private->bg_pixmap != NULL)
+       GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_back_pixmap (window, private->bg_pixmap);
     }
+
+  GDK_WINDOW_IMPL_GET_IFACE (private->impl)->input_shape_combine_region ((GdkWindow *)private, private->input_shape, 0, 0);
+
+  if (gdk_window_is_viewable (window))
+    GDK_WINDOW_IMPL_GET_IFACE (private->impl)->show (window);
 }
 
 static void
@@ -1891,7 +1872,7 @@ gdk_window_add_filter (GdkWindow     *window,
   /* Filters are for the native events on the native window, so
      ensure there is a native window. */
   if (window)
-    gdk_window_set_has_native (window, TRUE);
+    gdk_window_ensure_native (window);
   
   if (private)
     tmp_list = private->filters;
@@ -4348,7 +4329,7 @@ gdk_window_real_set_colormap (GdkDrawable *drawable,
   /* different colormap than parent, requires native window */
   if (!private->input_only &&
       cmap != gdk_drawable_get_colormap ((GdkDrawable *)(private->parent)))
-    gdk_window_set_has_native ((GdkWindow *)drawable, TRUE);
+    gdk_window_ensure_native ((GdkWindow *)drawable);
   
   gdk_drawable_set_colormap (private->impl, cmap);
 }
@@ -7560,7 +7541,7 @@ gdk_window_set_composited (GdkWindow *window,
     return;
 
   if (composited)
-    gdk_window_set_has_native (window, TRUE);
+    gdk_window_ensure_native (window);
 
   display = gdk_drawable_get_display (GDK_DRAWABLE (window));
 
index 90d5c9e8a15bd22caa56a0c19ead2c2c54d5775a..2b9b1d2c4e7a74280d19e4c8422e0415ec8b7333 100644 (file)
@@ -915,7 +915,7 @@ gdk_x11_drawable_get_xid (GdkDrawable *drawable)
       /* Try to ensure the window has a native window */
       if (!_gdk_window_has_impl (window))
        {
-         gdk_window_set_has_native (window, TRUE);
+         gdk_window_ensure_native (window);
 
          /* We sync here to ensure the window is created in the Xserver when
           * this function returns. This is required because the returned XID
index 08c7cffb4fc7505cbab92b0824ecca000755a92b..1e7d04b6f7de0b7043ce06108a7f778bf38301d8 100644 (file)
@@ -206,7 +206,7 @@ gdk_pointer_grab (GdkWindow *         window,
 
   /* We need a native window for confine to to work, ensure we have one */
   if (confine_to)
-    gdk_window_set_has_native (confine_to, TRUE);
+    gdk_window_ensure_native (confine_to, TRUE);
   
   /* TODO: What do we do for offscreens and  their children? We need to proxy the grab somehow */
   if (!GDK_IS_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (native)->impl))
index 4d38fcbc47cc4a9f20a77103d963f5db2235cac6..afe65f3cf6c99b09914bc263a4563cd00d7b20ac 100644 (file)
@@ -5366,8 +5366,8 @@ gdk_window_enable_synchronized_configure (GdkWindow *window)
     {
       /* This basically means you want to do fancy X specific stuff, so
         ensure we have a native window */
-      gdk_window_set_has_native (window, TRUE);
-  
+      gdk_window_ensure_native (window, TRUE);
+
       impl->use_synchronized_configure = TRUE;
       ensure_sync_counter (window);
     }
index 37bd74049a73dc85f0ee9fc371f821b457f966df..c6543c65966622fb263f012602513e74e54440aa 100644 (file)
@@ -368,7 +368,7 @@ parse_window (GdkWindow *parent, char **lines)
       color.blue = b;
       window = create_window (parent, x, y, w, h, &color);
       if (native)
-       gdk_window_set_has_native (window, TRUE);
+       gdk_window_ensure_native (window);
       
       for (i = 0; i < n_children; i++)
        lines = parse_window (window, lines);
@@ -692,7 +692,7 @@ native_window_clicked (GtkWidget *button,
     {
       window = l->data;
       
-      gdk_window_set_has_native (window, TRUE);
+      gdk_window_ensure_native (window, TRUE);
     }
   
   g_list_free (selected);