summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-03-23 08:36:25 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-03-26 19:18:40 -0400
commit29955b824648bbe60fbcf8cc00a60211015c569c (patch)
treeee17ed4d1cda9c94270aa5799dd4e7cd212b5068
parentdf68d38f7d14a6b934e11bee0c0ff58b65a3e884 (diff)
downloadgtk+-29955b824648bbe60fbcf8cc00a60211015c569c.tar.gz
surface: minor cleanup
Make gdk_surface_new fully private, and reduce the use of GdkSurfaceAttr.
-rw-r--r--gdk/gdkinternals.h3
-rw-r--r--gdk/gdksurface.c141
2 files changed, 35 insertions, 109 deletions
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index c6ed927826..0dbb61664d 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -278,9 +278,6 @@ cairo_region_t *gdk_cairo_region_from_clip (cairo_t *cr);
* Interfaces used by windowing code *
*************************************/
-GdkSurface* gdk_surface_new (GdkDisplay *display,
- GdkSurface *parent,
- GdkSurfaceAttr *attributes);
void _gdk_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy);
void _gdk_surface_clear_update_area (GdkSurface *surface);
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 845fab1735..9b41f89a8b 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -656,86 +656,48 @@ _gdk_surface_update_size (GdkSurface *surface)
recompute_visible_regions (surface, FALSE);
}
-GdkSurface*
-gdk_surface_new (GdkDisplay *display,
- GdkSurface *parent,
- GdkSurfaceAttr *attributes)
+static GdkSurface *
+gdk_surface_new (GdkDisplay *display,
+ gboolean input_only,
+ GdkSurfaceType surface_type,
+ int x,
+ int y,
+ int width,
+ int height)
{
GdkSurface *surface;
- gboolean native;
-
- g_return_val_if_fail (attributes != NULL, NULL);
-
- if (parent != NULL && GDK_SURFACE_DESTROYED (parent))
- {
- g_warning ("gdk_surface_new(): parent is destroyed");
- return NULL;
- }
+ GdkFrameClock *frame_clock;
+ GdkSurfaceAttr attributes;
surface = _gdk_display_create_surface (display);
- surface->parent = parent;
+ surface->parent = NULL;
surface->accept_focus = TRUE;
surface->focus_on_map = TRUE;
-
- surface->x = attributes->x;
- surface->y = attributes->y;
- surface->width = (attributes->width > 1) ? (attributes->width) : (1);
- surface->height = (attributes->height > 1) ? (attributes->height) : (1);
surface->alpha = 255;
- if (attributes->wclass == GDK_INPUT_ONLY)
- surface->surface_type = GDK_SURFACE_TEMP;
- else
- surface->surface_type = attributes->surface_type;
-
- /* Sanity checks */
- switch (surface->surface_type)
- {
- case GDK_SURFACE_TOPLEVEL:
- case GDK_SURFACE_TEMP:
- if (parent != NULL)
- g_warning (G_STRLOC "Toplevel surfaces must be created without a parent");
- break;
- default:
- g_warning (G_STRLOC "cannot make surfaces of type %d", surface->surface_type);
- return NULL;
- }
-
- if (attributes->wclass == GDK_INPUT_OUTPUT)
- {
- surface->input_only = FALSE;
- }
- else
- {
- surface->input_only = TRUE;
- }
-
- native = FALSE;
+ surface->x = x;
+ surface->y = y;
+ surface->width = width;
+ surface->height = height;
+ surface->input_only = input_only;
+ surface->surface_type = surface_type;
- if (surface->parent != NULL)
- surface->parent->children = g_list_concat (&surface->children_list_node, surface->parent->children);
- else
- {
- GdkFrameClock *frame_clock = g_object_new (GDK_TYPE_FRAME_CLOCK_IDLE, NULL);
- gdk_surface_set_frame_clock (surface, frame_clock);
- g_object_unref (frame_clock);
+ g_warn_if_fail (!surface->input_only || surface->surface_type == GDK_SURFACE_TEMP);
- native = TRUE; /* Always use native surfaces for toplevels */
- }
+ frame_clock = g_object_new (GDK_TYPE_FRAME_CLOCK_IDLE, NULL);
+ gdk_surface_set_frame_clock (surface, frame_clock);
+ g_object_unref (frame_clock);
- if (native)
- {
- /* Create the impl */
- gdk_display_create_surface_impl (display, surface, parent, attributes);
- surface->impl_surface = surface;
- }
- else
- {
- surface->impl_surface = g_object_ref (surface->parent->impl_surface);
- surface->impl = g_object_ref (surface->impl_surface->impl);
- }
+ attributes.wclass = input_only ? GDK_INPUT_ONLY : GDK_INPUT_OUTPUT;
+ attributes.surface_type = surface_type;
+ attributes.x = x;
+ attributes.y = y;
+ attributes.width = width;
+ attributes.height = height;
+ gdk_display_create_surface_impl (display, surface, NULL, &attributes);
+ surface->impl_surface = surface;
recompute_visible_regions (surface, FALSE);
@@ -760,18 +722,9 @@ gdk_surface_new_toplevel (GdkDisplay *display,
gint width,
gint height)
{
- GdkSurfaceAttr attr;
-
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- attr.wclass = GDK_INPUT_OUTPUT;
- attr.x = 0;
- attr.y = 0;
- attr.width = width;
- attr.height = height;
- attr.surface_type = GDK_SURFACE_TOPLEVEL;
-
- return gdk_surface_new (display, NULL, &attr);
+ return gdk_surface_new (display, FALSE, GDK_SURFACE_TOPLEVEL, 0, 0, width, height);
}
/**
@@ -788,19 +741,12 @@ GdkSurface *
gdk_surface_new_popup (GdkDisplay *display,
const GdkRectangle *position)
{
- GdkSurfaceAttr attr;
-
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (position != NULL, NULL);
- attr.wclass = GDK_INPUT_OUTPUT;
- attr.x = position->x;
- attr.y = position->y;
- attr.width = position->width;
- attr.height = position->height;
- attr.surface_type = GDK_SURFACE_TEMP;
-
- return gdk_surface_new (display, NULL, &attr);
+ return gdk_surface_new (display, FALSE, GDK_SURFACE_TEMP,
+ position->x, position->y,
+ position->width, position->height);
}
GdkSurface *
@@ -808,19 +754,11 @@ gdk_surface_new_popup_full (GdkDisplay *display,
GdkSurface *parent)
{
GdkSurface *surface;
- GdkSurfaceAttr attr;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GDK_IS_SURFACE (parent), NULL);
- attr.wclass = GDK_INPUT_OUTPUT;
- attr.x = 0;
- attr.y = 0;
- attr.width = 100;
- attr.height = 100;
- attr.surface_type = GDK_SURFACE_TEMP;
-
- surface = gdk_surface_new (display, NULL, &attr);
+ surface = gdk_surface_new (display, FALSE, GDK_SURFACE_TEMP, 0, 0, 100, 100);
gdk_surface_set_transient_for (surface, parent);
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_MENU);
@@ -841,18 +779,9 @@ gdk_surface_new_popup_full (GdkDisplay *display,
GdkSurface *
gdk_surface_new_temp (GdkDisplay *display)
{
- GdkSurfaceAttr attr;
-
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- attr.wclass = GDK_INPUT_ONLY;
- attr.x = -100;
- attr.y = -100;
- attr.width = 10;
- attr.height = 10;
- attr.surface_type = GDK_SURFACE_TEMP;
-
- return gdk_surface_new (display, NULL, &attr);
+ return gdk_surface_new (display, TRUE, GDK_SURFACE_TEMP, -100, -100, 10, 10);
}
static void