mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 09:00:34 +00:00
API: Add gdk_window_get_background_pattern()
This is the suggested way for GTK3 to store a Window's background so it makes sense to use the same function today already.
This commit is contained in:
parent
77b703c2fc
commit
9f1cb0798b
@ -734,6 +734,7 @@ gdk_window_set_hints
|
||||
gdk_window_set_title
|
||||
gdk_window_set_background
|
||||
gdk_window_set_back_pixmap
|
||||
gdk_window_get_background_pattern
|
||||
GDK_PARENT_RELATIVE
|
||||
gdk_window_set_cursor
|
||||
gdk_window_get_cursor
|
||||
|
@ -676,6 +676,7 @@ gdk_window_move_resize
|
||||
gdk_window_scroll
|
||||
gdk_window_move_region
|
||||
gdk_window_get_accept_focus
|
||||
gdk_window_get_background_pattern
|
||||
gdk_window_get_composited
|
||||
gdk_window_get_cursor
|
||||
gdk_window_get_deskrelative_origin
|
||||
|
@ -274,6 +274,8 @@ struct _GdkWindowObject
|
||||
|
||||
cairo_surface_t *cairo_surface;
|
||||
guint outstanding_surfaces; /* only set on impl window */
|
||||
|
||||
cairo_pattern_t *background;
|
||||
};
|
||||
|
||||
#define GDK_WINDOW_TYPE(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->window_type)
|
||||
|
@ -2043,6 +2043,12 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
|
||||
private->bg_pixmap = NULL;
|
||||
}
|
||||
|
||||
if (private->background)
|
||||
{
|
||||
cairo_pattern_destroy (private->background);
|
||||
private->background = NULL;
|
||||
}
|
||||
|
||||
if (private->window_type == GDK_WINDOW_FOREIGN)
|
||||
g_assert (private->children == NULL);
|
||||
else
|
||||
@ -7864,6 +7870,12 @@ gdk_window_set_background (GdkWindow *window,
|
||||
|
||||
private->bg_pixmap = NULL;
|
||||
|
||||
if (private->background)
|
||||
{
|
||||
cairo_pattern_destroy (private->background);
|
||||
private->background = NULL;
|
||||
}
|
||||
|
||||
if (!GDK_WINDOW_DESTROYED (window) &&
|
||||
gdk_window_has_impl (private) &&
|
||||
!private->input_only)
|
||||
@ -7924,6 +7936,12 @@ gdk_window_set_back_pixmap (GdkWindow *window,
|
||||
private->bg_pixmap != GDK_NO_BG)
|
||||
g_object_unref (private->bg_pixmap);
|
||||
|
||||
if (private->background)
|
||||
{
|
||||
cairo_pattern_destroy (private->background);
|
||||
private->background = NULL;
|
||||
}
|
||||
|
||||
if (parent_relative)
|
||||
private->bg_pixmap = GDK_PARENT_RELATIVE_BG;
|
||||
else if (pixmap)
|
||||
@ -7940,6 +7958,56 @@ gdk_window_set_back_pixmap (GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_window_get_background_pattern:
|
||||
* @window: a window
|
||||
*
|
||||
* Gets the pattern used to clear the background on @window. If @window
|
||||
* does not have its own background and reuses the parent's, %NULL is
|
||||
* returned and you'll have to query it yourself.
|
||||
*
|
||||
* Returns: The pattern to use for the background or %NULL to use the
|
||||
* parent's background.
|
||||
*
|
||||
* Since: 2.22
|
||||
**/
|
||||
cairo_pattern_t *
|
||||
gdk_window_get_background_pattern (GdkWindow *window)
|
||||
{
|
||||
GdkWindowObject *private = (GdkWindowObject *) window;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
|
||||
|
||||
if (private->background == NULL)
|
||||
{
|
||||
if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG)
|
||||
private->background = NULL;
|
||||
else if (private->bg_pixmap != GDK_NO_BG &&
|
||||
private->bg_pixmap != NULL)
|
||||
{
|
||||
static cairo_user_data_key_t key;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = _gdk_drawable_ref_cairo_surface (private->bg_pixmap);
|
||||
private->background = cairo_pattern_create_for_surface (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
cairo_pattern_set_extend (private->background, CAIRO_EXTEND_REPEAT);
|
||||
cairo_pattern_set_user_data (private->background,
|
||||
&key,
|
||||
g_object_ref (private->bg_pixmap),
|
||||
g_object_unref);
|
||||
}
|
||||
else
|
||||
private->background =
|
||||
cairo_pattern_create_rgb (private->bg_color.red / 65535.,
|
||||
private->bg_color.green / 65535.,
|
||||
private->bg_color.blue / 65535.);
|
||||
}
|
||||
|
||||
return private->background;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_window_get_cursor:
|
||||
* @window: a #GdkWindow
|
||||
|
@ -531,6 +531,8 @@ void gdk_window_set_background (GdkWindow *window,
|
||||
void gdk_window_set_back_pixmap (GdkWindow *window,
|
||||
GdkPixmap *pixmap,
|
||||
gboolean parent_relative);
|
||||
cairo_pattern_t *gdk_window_get_background_pattern (GdkWindow *window);
|
||||
|
||||
void gdk_window_set_cursor (GdkWindow *window,
|
||||
GdkCursor *cursor);
|
||||
GdkCursor *gdk_window_get_cursor (GdkWindow *window);
|
||||
|
Loading…
Reference in New Issue
Block a user