API: wayland: Add gdk_wayland_window_new_subsurface()

... and use it instead of gdk_window_new().
This commit is contained in:
Benjamin Otte 2016-11-06 21:36:43 +01:00
parent 87f07bac6b
commit b30afff511
4 changed files with 54 additions and 19 deletions

View File

@ -1174,6 +1174,7 @@ gdk_wayland_device_get_wl_seat
gdk_wayland_display_get_wl_compositor
gdk_wayland_display_get_wl_display
gdk_wayland_display_get_xdg_shell
gdk_wayland_window_new_subsurface
gdk_wayland_window_get_wl_surface
gdk_wayland_window_set_use_custom_surface
GdkWaylandWindowExported

View File

@ -45,6 +45,10 @@ typedef struct _GdkWaylandWindowClass GdkWaylandWindowClass;
GDK_AVAILABLE_IN_ALL
GType gdk_wayland_window_get_type (void);
GDK_AVAILABLE_IN_3_90
GdkWindow * gdk_wayland_window_new_subsurface (GdkDisplay *display,
int event_mask,
const GdkRectangle *position);
GDK_AVAILABLE_IN_ALL
struct wl_surface *gdk_wayland_window_get_wl_surface (GdkWindow *window);

View File

@ -3672,6 +3672,41 @@ _gdk_wayland_window_set_grab_seat (GdkWindow *window,
impl->grab_input_seat = seat;
}
/**
* gdk_wayland_window_new_subsurface: (constructor)
* @display: the display to create the window on
* @event_mask: event mask (see gdk_window_set_events())
* @position: position relative to the transient window
*
* Creates a new subsurface window.
*
* Returns: (transfer full): the new #GdkWindow
*
* Since: 3.90
**/
GdkWindow *
gdk_wayland_window_new_subsurface (GdkDisplay *display,
int event_mask,
const GdkRectangle *position)
{
GdkWindowAttr attr;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (position != NULL, 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_SUBSURFACE;
return gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
&attr,
GDK_WA_X | GDK_WA_Y);
}
/**
* gdk_wayland_window_get_wl_surface:
* @window: (type GdkWaylandWindow): a #GdkWindow

View File

@ -6370,21 +6370,10 @@ popover_realize (GtkWidget *widget,
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
{
GdkWindowAttr attributes;
gint attributes_mask;
attributes.window_type = GDK_WINDOW_SUBSURFACE;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.x = rect.x;
attributes.y = rect.y;
attributes.width = rect.width;
attributes.height = rect.height;
attributes.event_mask = gtk_widget_get_events (popover->widget) |
GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
popover->window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
&attributes, attributes_mask);
popover->window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (GTK_WIDGET (window)),
gtk_widget_get_events (popover->widget)
| GDK_EXPOSURE_MASK,
&rect);
gdk_window_set_transient_for (popover->window,
_gtk_widget_get_window (GTK_WIDGET (window)));
}
@ -6973,12 +6962,18 @@ gtk_window_realize (GtkWidget *widget)
#ifdef GDK_WINDOWING_WAYLAND
if (priv->use_subsurface &&
GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
attributes.window_type = GDK_WINDOW_SUBSURFACE;
{
gdk_window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (widget),
attributes.event_mask,
&allocation);
}
else
#endif
attributes.window_type = GDK_WINDOW_TEMP;
gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
&attributes, 0);
{
attributes.window_type = GDK_WINDOW_TEMP;
gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)),
&attributes, 0);
}
break;
default:
g_warning (G_STRLOC": Unknown window type %d!", priv->type);