Rename gdk_window_set_has_native to gdk_window_ensure_native

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.
This commit is contained in:
Alexander Larsson 2009-06-01 11:57:59 +02:00
parent d1f5050262
commit 287b821705
7 changed files with 76 additions and 93 deletions

View 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>

View 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>

View 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,22 +1360,20 @@ 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);
if (impl_window->window_type == GDK_WINDOW_OFFSCREEN)
return; /* native in offscreens not supported */
return FALSE; /* native in offscreens not supported */
if (impl_window == private)
/* Already has an impl, and its not offscreen . */
return TRUE;
/* Need to create a native window */
screen = gdk_drawable_get_screen (window);
visual = gdk_drawable_get_visual (window);
@ -1421,25 +1421,6 @@ gdk_window_set_has_native (GdkWindow *window, gboolean has_native)
if (gdk_window_is_viewable (window))
GDK_WINDOW_IMPL_GET_IFACE (private->impl)->show (window);
}
else
{
/* Remove native window */
if (!gdk_window_has_impl (private))
return; /* Not native, can't remove */
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 */
g_warning ("Tried to turn native window to client side window, this is not supported yet.");
/* TODO: remove native */
}
}
static void
window_remove_filters (GdkWindow *window)
@ -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));

View 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

View 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))

View File

@ -5366,7 +5366,7 @@ 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);

View 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);