Drop child surfaces

Drop gdk_surface_child_new and the child surface type,
since we no longer use them. Deprecate surface apis
that only make sense with child surfaces.
This commit is contained in:
Matthias Clasen 2019-03-22 14:24:39 -04:00
parent 52c3507ae1
commit 989792cbc0
13 changed files with 15 additions and 261 deletions

View File

@ -214,7 +214,6 @@ gdk_surface_move
gdk_surface_resize
gdk_surface_move_resize
gdk_surface_move_to_rect
gdk_surface_has_native
gdk_surface_raise
gdk_surface_lower
gdk_surface_restack
@ -269,10 +268,6 @@ gdk_surface_get_root_coords
gdk_surface_get_device_position
GdkModifierType
GdkModifierIntent
gdk_surface_get_parent
gdk_surface_get_toplevel
gdk_surface_get_children
gdk_surface_peek_children
gdk_surface_set_icon_name
gdk_surface_set_transient_for
gdk_surface_set_startup_id

View File

@ -46,8 +46,7 @@
/* Forward declarations */
static void gdk_surface_impl_broadway_finalize (GObject *object);
#define SURFACE_IS_TOPLEVEL(surface) \
(GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD)
#define SURFACE_IS_TOPLEVEL(surface) TRUE
struct _GdkBroadwaySurface {
GdkSurface parent;

View File

@ -1258,9 +1258,9 @@ gdk_device_grab (GdkDevice *device,
g_return_val_if_fail (GDK_IS_SURFACE (surface), GDK_GRAB_FAILED);
g_return_val_if_fail (gdk_surface_get_display (surface) == gdk_device_get_display (device), GDK_GRAB_FAILED);
native = gdk_surface_get_toplevel (surface);
native = surface;
if (native == NULL || GDK_SURFACE_DESTROYED (native))
if (GDK_SURFACE_DESTROYED (native))
return GDK_GRAB_NOT_VIEWABLE;
res = GDK_DEVICE_GET_CLASS (device)->grab (device,

View File

@ -141,7 +141,6 @@ typedef union _GdkEvent GdkEvent;
* @GDK_LEAVE_NOTIFY: the pointer has left the surface.
* @GDK_FOCUS_CHANGE: the keyboard focus has entered or left the surface.
* @GDK_CONFIGURE: the size, position or stacking order of the surface has changed.
* Note that GTK+ discards these events for %GDK_SURFACE_CHILD surfaces.
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
* surface (e.g. a touchscreen or graphics tablet).
* @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing

View File

@ -220,7 +220,7 @@ gdk_surface_init (GdkSurface *surface)
{
/* 0-initialization is good for all other fields. */
surface->surface_type = GDK_SURFACE_CHILD;
surface->surface_type = GDK_SURFACE_TOPLEVEL;
surface->state = GDK_SURFACE_STATE_WITHDRAWN;
surface->fullscreen_mode = GDK_FULLSCREEN_ON_CURRENT_MONITOR;
@ -708,16 +708,7 @@ gdk_surface_new (GdkDisplay *display,
surface->alpha = 255;
if (attributes->wclass == GDK_INPUT_ONLY)
{
/* Backwards compatiblity - we've always ignored
* attributes->surface_type for input-only surfaces
* before
*/
if (parent == NULL)
surface->surface_type = GDK_SURFACE_TEMP;
else
surface->surface_type = GDK_SURFACE_CHILD;
}
surface->surface_type = GDK_SURFACE_TEMP;
else
surface->surface_type = attributes->surface_type;
@ -729,8 +720,6 @@ gdk_surface_new (GdkDisplay *display,
if (parent != NULL)
g_warning (G_STRLOC "Toplevel surfaces must be created without a parent");
break;
case GDK_SURFACE_CHILD:
break;
default:
g_warning (G_STRLOC "cannot make surfaces of type %d", surface->surface_type);
return NULL;
@ -900,33 +889,6 @@ gdk_surface_new_temp (GdkDisplay *display)
return gdk_surface_new (display, NULL, &attr);
}
/**
* gdk_surface_new_child: (constructor)
* @parent: the parent surface
* @position: placement of the surface inside @parent
*
* Creates a new client-side child surface.
*
* Returns: (transfer full): the new #GdkSurface
**/
GdkSurface *
gdk_surface_new_child (GdkSurface *parent,
const GdkRectangle *position)
{
GdkSurfaceAttr attr;
g_return_val_if_fail (GDK_IS_SURFACE (parent), 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_CHILD;
return gdk_surface_new (gdk_surface_get_display (parent), parent, &attr);
}
static void
update_pointer_info_foreach (GdkDisplay *display,
GdkDevice *device,
@ -994,7 +956,6 @@ _gdk_surface_destroy_hierarchy (GdkSurface *surface,
break;
case GDK_SURFACE_TOPLEVEL:
case GDK_SURFACE_CHILD:
case GDK_SURFACE_TEMP:
if (surface->parent)
{
@ -1158,22 +1119,6 @@ gdk_surface_is_destroyed (GdkSurface *surface)
return GDK_SURFACE_DESTROYED (surface);
}
/**
* gdk_surface_has_native:
* @surface: a #GdkSurface
*
* Checks whether the surface has a native surface or not.
*
* Returns: %TRUE if the @surface has a native surface, %FALSE otherwise.
*/
gboolean
gdk_surface_has_native (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
return surface->parent == NULL || surface->parent->impl != surface->impl;
}
/**
* gdk_surface_get_position:
* @surface: a #GdkSurface
@ -1202,101 +1147,6 @@ gdk_surface_get_position (GdkSurface *surface,
*y = surface->y;
}
/**
* gdk_surface_get_parent:
* @surface: a #GdkSurface
*
* Obtains the parent of @surface, as known to GDK. Does not query the
* X server; thus this returns the parent as passed to gdk_surface_new(),
* not the actual parent. This should never matter unless youre using
* Xlib calls mixed with GDK calls on the X11 platform. It may also
* matter for toplevel windows, because the window manager may choose
* to reparent them.
*
* Returns: (transfer none): parent of @surface
**/
GdkSurface*
gdk_surface_get_parent (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
return surface->parent;
}
/**
* gdk_surface_get_toplevel:
* @surface: a #GdkSurface
*
* Gets the toplevel surface thats an ancestor of @surface.
*
* Any surface type but %GDK_SURFACE_CHILD is considered a
* toplevel surface, as is a %GDK_SURFACE_CHILD surface that
* has a root surface as parent.
*
* Returns: (transfer none): the toplevel surface containing @surface
**/
GdkSurface *
gdk_surface_get_toplevel (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
while (surface->surface_type == GDK_SURFACE_CHILD)
{
if (gdk_surface_is_toplevel (surface))
break;
surface = surface->parent;
}
return surface;
}
/**
* gdk_surface_get_children:
* @surface: a #GdkSurface
*
* Gets the list of children of @surface known to GDK.
* This function only returns children created via GDK,
* so for example its useless when used with the root window;
* it only returns surfaces an application created itself.
*
* The returned list must be freed, but the elements in the
* list need not be.
*
* Returns: (transfer container) (element-type GdkSurface):
* list of child surfaces inside @surface
**/
GList*
gdk_surface_get_children (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
if (GDK_SURFACE_DESTROYED (surface))
return NULL;
return g_list_copy (surface->children);
}
/**
* gdk_surface_peek_children:
* @surface: a #GdkSurface
*
* Like gdk_surface_get_children(), but does not copy the list of
* children, so the list does not need to be freed.
*
* Returns: (transfer none) (element-type GdkSurface):
* a reference to the list of child surfaces in @surface
**/
GList *
gdk_surface_peek_children (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
if (GDK_SURFACE_DESTROYED (surface))
return NULL;
return surface->children;
}
/**
* gdk_surface_is_visible:
* @surface: a #GdkSurface
@ -1627,11 +1477,7 @@ gdk_surface_remove_update_surface (GdkSurface *surface)
static gboolean
gdk_surface_is_toplevel_frozen (GdkSurface *surface)
{
GdkSurface *toplevel;
toplevel = gdk_surface_get_toplevel (surface);
return toplevel->update_and_descendants_freeze_count > 0;
return surface->update_and_descendants_freeze_count > 0;
}
static void
@ -1943,7 +1789,6 @@ void
gdk_surface_freeze_toplevel_updates (GdkSurface *surface)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (surface->surface_type != GDK_SURFACE_CHILD);
surface->update_and_descendants_freeze_count++;
_gdk_frame_clock_freeze (gdk_surface_get_frame_clock (surface));
@ -1953,7 +1798,6 @@ void
gdk_surface_thaw_toplevel_updates (GdkSurface *surface)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (surface->surface_type != GDK_SURFACE_CHILD);
g_return_if_fail (surface->update_and_descendants_freeze_count > 0);
surface->update_and_descendants_freeze_count--;
@ -3811,8 +3655,7 @@ gdk_surface_print (GdkSurface *surface,
#endif
}
if (surface->surface_type != GDK_SURFACE_CHILD)
g_print (" %s", surface_types[surface->surface_type]);
g_print (" %s", surface_types[surface->surface_type]);
if (surface->input_only)
g_print (" input-only");
@ -4950,13 +4793,9 @@ gdk_surface_set_frame_clock (GdkSurface *surface,
GdkFrameClock*
gdk_surface_get_frame_clock (GdkSurface *surface)
{
GdkSurface *toplevel;
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
toplevel = gdk_surface_get_toplevel (surface);
return toplevel->frame_clock;
return surface->frame_clock;
}
/**
@ -5194,7 +5033,6 @@ gdk_surface_set_state (GdkSurface *surface,
case GDK_SURFACE_TEMP: /* ? */
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
break;
case GDK_SURFACE_CHILD:
default:
break;
}

View File

@ -42,7 +42,6 @@ typedef struct _GdkGeometry GdkGeometry;
/**
* GdkSurfaceType:
* @GDK_SURFACE_TOPLEVEL: toplevel window (used to implement #GtkWindow)
* @GDK_SURFACE_CHILD: child surface (used to implement e.g. #GtkEntry)
* @GDK_SURFACE_TEMP: override redirect temporary surface (used to implement #GtkMenu)
*
* Describes the kind of surface.
@ -50,7 +49,6 @@ typedef struct _GdkGeometry GdkGeometry;
typedef enum
{
GDK_SURFACE_TOPLEVEL,
GDK_SURFACE_CHILD,
GDK_SURFACE_TEMP
} GdkSurfaceType;
@ -444,9 +442,6 @@ GdkSurface * gdk_surface_new_popup_full (GdkDisplay *display,
GdkSurface *parent);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_surface_new_temp (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_surface_new_child (GdkSurface *parent,
const GdkRectangle *position);
GDK_AVAILABLE_IN_ALL
void gdk_surface_destroy (GdkSurface *surface);
@ -544,8 +539,6 @@ GdkSurfaceState gdk_surface_get_state (GdkSurface *surface);
/* GdkSurface */
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_has_native (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_type_hint (GdkSurface *surface,
GdkSurfaceTypeHint hint);
@ -639,16 +632,6 @@ GdkSurface * gdk_surface_get_device_position (GdkSurface *surface,
double *x,
double *y,
GdkModifierType *mask);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_surface_get_parent (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_surface_get_toplevel (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GList * gdk_surface_get_children (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GList * gdk_surface_peek_children (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_icon_list (GdkSurface *surface,
GList *surfaces);

View File

@ -39,7 +39,7 @@
#define GRIP_HEIGHT 15
#define GDK_LION_RESIZE 5
#define SURFACE_IS_TOPLEVEL(window) (GDK_SURFACE_TYPE (window) != GDK_SURFACE_CHILD)
#define SURFACE_IS_TOPLEVEL(window) TRUE
/* This is the window corresponding to the key window */
static GdkSurface *current_keyboard_window;

View File

@ -62,7 +62,7 @@ static FullscreenSavedGeometry *get_fullscreen_geometry (GdkSurface *window);
static void update_toplevel_order (void);
static void clear_toplevel_order (void);
#define SURFACE_IS_TOPLEVEL(window) (GDK_SURFACE_TYPE (window) != GDK_SURFACE_CHILD)
#define SURFACE_IS_TOPLEVEL(window) TRUE
/*
* GdkQuartzSurface
@ -827,29 +827,6 @@ _gdk_quartz_display_create_surface_impl (GdkDisplay *display,
}
break;
case GDK_SURFACE_CHILD:
{
GdkSurfaceImplQuartz *parent_impl = GDK_SURFACE_IMPL_QUARTZ (window->parent->impl);
if (!window->input_only)
{
NSRect frame_rect = NSMakeRect (window->x + window->parent->abs_x,
window->y + window->parent->abs_y,
window->width,
window->height);
impl->view = [[GdkQuartzView alloc] initWithFrame:frame_rect];
[impl->view setGdkSurface:window];
/* GdkSurfaces should be hidden by default */
[impl->view setHidden:YES];
[parent_impl->view addSubview:impl->view];
[impl->view release];
}
}
break;
default:
g_assert_not_reached ();
}

View File

@ -49,8 +49,7 @@ enum {
static guint signals[LAST_SIGNAL];
#define SURFACE_IS_TOPLEVEL(surface) \
(GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD)
#define SURFACE_IS_TOPLEVEL(surface) TRUE
#define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
@ -585,7 +584,6 @@ _gdk_wayland_display_create_surface_impl (GdkDisplay *display,
gdk_surface_set_title (surface, get_default_title ());
break;
case GDK_SURFACE_CHILD:
default:
break;
}

View File

@ -498,7 +498,6 @@ RegisterGdkClass (GdkSurfaceType wtype, GdkSurfaceTypeHint wtype_hint)
}
break;
case GDK_SURFACE_CHILD:
default:
g_assert_not_reached ();
break;
@ -611,7 +610,6 @@ _gdk_win32_display_create_surface_impl (GdkDisplay *display,
break;
case GDK_SURFACE_CHILD:
default:
g_assert_not_reached ();
}
@ -1187,10 +1185,6 @@ gdk_win32_surface_move (GdkSurface *window,
if (window->state & GDK_SURFACE_STATE_FULLSCREEN)
return;
/* Don't check GDK_SURFACE_TYPE (window) == GDK_SURFACE_CHILD.
* Foreign windows (another app's windows) might be children of our
* windows! Especially in the case of gtkplug/socket.
*/
if (GetAncestor (GDK_SURFACE_HWND (window), GA_PARENT) != GetDesktopWindow ())
{
_gdk_surface_move_resize_child (window, x, y, window->width, window->height);

View File

@ -931,13 +931,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
xevent->xconfigure.border_width,
xevent->xconfigure.above,
xevent->xconfigure.override_redirect,
!surface
? " (discarding)"
: surface->surface_type == GDK_SURFACE_CHILD
? " (discarding child)"
: xevent->xconfigure.event != xevent->xconfigure.window
? " (discarding substructure)"
: ""));
!surface ? " (discarding)" : ""));
if (_gdk_x11_display_is_root_window (display, xevent->xconfigure.window))
{
_gdk_x11_screen_size_changed (x11_screen, xevent);
@ -953,8 +947,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
#endif
if (!surface ||
xevent->xconfigure.event != xevent->xconfigure.window ||
GDK_SURFACE_TYPE (surface) == GDK_SURFACE_CHILD)
xevent->xconfigure.event != xevent->xconfigure.window)
return_val = FALSE;
else
{

View File

@ -870,7 +870,6 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display,
}
break;
case GDK_SURFACE_CHILD:
default:
g_assert_not_reached ();
break;
@ -969,7 +968,6 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display,
setup_toplevel_window (surface, x11_screen);
break;
case GDK_SURFACE_CHILD:
default:
break;
}
@ -1319,7 +1317,6 @@ gdk_surface_x11_hide (GdkSurface *surface)
gdk_surface_x11_withdraw (surface);
return;
case GDK_SURFACE_CHILD:
default:
break;
}
@ -1525,7 +1522,6 @@ gdk_x11_surface_move_to_current_desktop (GdkSurface *surface)
GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD);
toplevel = _gdk_x11_surface_get_toplevel (surface);
@ -1881,8 +1877,6 @@ gdk_x11_surface_set_skip_taskbar_hint (GdkSurface *surface,
{
GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD);
if (GDK_SURFACE_DESTROYED (surface) ||
!SURFACE_IS_TOPLEVEL (surface))
return;
@ -1910,8 +1904,6 @@ gdk_x11_surface_set_skip_pager_hint (GdkSurface *surface,
{
GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD);
if (GDK_SURFACE_DESTROYED (surface) ||
!SURFACE_IS_TOPLEVEL (surface))
return;
@ -1939,8 +1931,6 @@ gdk_x11_surface_set_urgency_hint (GdkSurface *surface,
{
GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD);
if (GDK_SURFACE_DESTROYED (surface) ||
!SURFACE_IS_TOPLEVEL (surface))
return;
@ -3416,7 +3406,6 @@ gdk_x11_surface_set_group (GdkSurface *surface,
GdkToplevelX11 *toplevel;
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (GDK_SURFACE_TYPE (surface) != GDK_SURFACE_CHILD);
g_return_if_fail (leader == NULL || GDK_IS_SURFACE (leader));
if (GDK_SURFACE_DESTROYED (surface) ||

View File

@ -600,23 +600,12 @@ _gtk_gesture_cancel_all (GtkGesture *gesture)
static gboolean
gesture_within_surface (GtkGesture *gesture,
GdkSurface *parent)
GdkSurface *surface)
{
GdkSurface *surface;
GtkWidget *widget;
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
surface = gtk_widget_get_surface (widget);
while (surface)
{
if (surface == parent)
return TRUE;
surface = gdk_surface_get_parent (surface);
}
return FALSE;
return surface == gtk_widget_get_surface (widget);
}
static gboolean