API: gdk: Add gdk_window_new_child() and gdk_window_new_input()

This is an attempt to get rid of gdk_window_new() for more specific use
cases. These 2 are for client-side windows - regular ones and input-only
ones resepectively.

So far all those functions just call into gdk_window_new().
This commit is contained in:
Benjamin Otte 2016-10-17 20:11:23 +02:00
parent 6b01940194
commit d22e5e69d9
3 changed files with 72 additions and 0 deletions

View File

@ -334,6 +334,8 @@ GdkWindowTypeHint
GdkWindowAttr
GdkWindowAttributesType
gdk_window_new
gdk_window_new_child
gdk_window_new_input
gdk_window_destroy
gdk_window_get_window_type
gdk_window_get_display

View File

@ -1484,6 +1484,66 @@ gdk_window_new (GdkWindow *parent,
return window;
}
/**
* gdk_window_new_child: (constructor)
* @parent: the parent window
* @event_mask: event mask (see gdk_window_set_events())
* @position: placement of the window inside @parent
*
* Creates a new client-side child window.
*
* Returns: (transfer full): the new #GdkWindow
**/
GdkWindow *
gdk_window_new_child (GdkWindow *parent,
gint event_mask,
const GdkRectangle *position)
{
GdkWindowAttr attr;
g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
attr.event_mask = event_mask;
attr.wclass = GDK_INPUT_OUTPUT;
attr.x = position->x;
attr.y = position->y;
attr.width = position->width;
attr.height = position->height;
attr.window_type = GDK_WINDOW_CHILD;
return gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
}
/**
* gdk_window_new_input: (constructor)
* @parent: the parent window
* @event_mask: event mask (see gdk_window_set_events())
* @position: placement of the window inside @parent
*
* Creates a new client-side input-only window.
*
* Returns: (transfer full): the new #GdkWindow
**/
GdkWindow *
gdk_window_new_input (GdkWindow *parent,
gint event_mask,
const GdkRectangle *position)
{
GdkWindowAttr attr;
g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
attr.event_mask = event_mask;
attr.wclass = GDK_INPUT_ONLY;
attr.x = position->x;
attr.y = position->y;
attr.width = position->width;
attr.height = position->height;
attr.window_type = GDK_WINDOW_CHILD;
return gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
}
static gboolean
is_parent_of (GdkWindow *parent,
GdkWindow *child)

View File

@ -498,6 +498,16 @@ GDK_AVAILABLE_IN_ALL
GdkWindow* gdk_window_new (GdkWindow *parent,
GdkWindowAttr *attributes,
gint attributes_mask);
GDK_AVAILABLE_IN_3_90
GdkWindow * gdk_window_new_child (GdkWindow *parent,
gint event_mask,
const GdkRectangle *position);
GDK_AVAILABLE_IN_3_90
GdkWindow * gdk_window_new_input (GdkWindow *parent,
gint event_mask,
const GdkRectangle *position);
GDK_AVAILABLE_IN_ALL
void gdk_window_destroy (GdkWindow *window);
GDK_AVAILABLE_IN_ALL