gdk/toplevelsize: Rename 'margin' to 'shadow' and 'shadow_width'

This makes it more consistent with everywhere else.
This commit is contained in:
Jonas Ådahl 2020-12-02 17:08:43 +01:00
parent b738054344
commit 6ee7535af0
9 changed files with 98 additions and 86 deletions

View File

@ -1588,12 +1588,12 @@ gdk_broadway_toplevel_present (GdkToplevel *toplevel,
else
gdk_broadway_surface_unmaximize (surface);
if (size.margin.is_valid)
if (size.shadow.is_valid)
{
impl->shadow_left = size.margin.left;
impl->shadow_right = size.margin.right;
impl->shadow_top = size.margin.top;
impl->shadow_bottom = size.margin.bottom;
impl->shadow_left = size.shadow.left;
impl->shadow_right = size.shadow.right;
impl->shadow_top = size.shadow.top;
impl->shadow_bottom = size.shadow.bottom;
}
show_surface (surface);

View File

@ -118,18 +118,30 @@ gdk_toplevel_size_set_min_size (GdkToplevelSize *size,
size->min_height = min_height;
}
/**
* gdk_toplevel_size_set_shadow_width:
* @size: a #GdkToplevelSize
* @left: width of the left part of the shadow
* @right: width of the right part of the shadow
* @top: height of the top part of the shadow
* @bottom: height of the bottom part of the shadow
*
* The shadow width corresponds to the part of the computed surface size
* that would consist of the shadow margin surrounding the window, would
* there be any.
*/
void
gdk_toplevel_size_set_margin (GdkToplevelSize *size,
gdk_toplevel_size_set_shadow_width (GdkToplevelSize *size,
int left,
int right,
int top,
int bottom)
{
size->margin.is_valid = TRUE;
size->margin.left = left;
size->margin.right = right;
size->margin.top = top;
size->margin.bottom = bottom;
size->shadow.is_valid = TRUE;
size->shadow.left = left;
size->shadow.right = right;
size->shadow.top = top;
size->shadow.bottom = bottom;
}
void
@ -145,10 +157,10 @@ gdk_toplevel_size_validate (GdkToplevelSize *size)
geometry_width = size->width;
geometry_height = size->height;
if (size->margin.is_valid)
if (size->shadow.is_valid)
{
geometry_width -= size->margin.left + size->margin.right;
geometry_height -= size->margin.top + size->margin.bottom;
geometry_width -= size->shadow.left + size->shadow.right;
geometry_height -= size->shadow.top + size->shadow.bottom;
}
if (geometry_width > size->bounds_width ||
geometry_height > size->bounds_height)

View File

@ -55,7 +55,7 @@ void gdk_toplevel_size_set_min_size (GdkToplevelSize *
int min_height);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_size_set_margin (GdkToplevelSize *size,
void gdk_toplevel_size_set_shadow_width (GdkToplevelSize *size,
int left,
int right,
int top,

View File

@ -37,7 +37,7 @@ struct _GdkToplevelSize
int right;
int top;
int bottom;
} margin;
} shadow;
};
void gdk_toplevel_size_init (GdkToplevelSize *size,

View File

@ -155,13 +155,13 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
if (style_mask != [nswindow styleMask])
[nswindow setStyleMask:style_mask];
if (size.margin.is_valid)
if (size.shadow.is_valid)
{
_gdk_macos_surface_set_shadow_width (surface,
size.margin.left,
size.margin.right,
size.margin.top,
size.margin.bottom);
size.shadow.left,
size.shadow.right,
size.shadow.top,
size.shadow.bottom);
}
_gdk_macos_surface_set_geometry_hints (GDK_MACOS_SURFACE (self), &geometry, mask);

View File

@ -122,11 +122,11 @@ struct _GdkWaylandSurface
gint64 pending_frame_counter;
guint32 scale;
int margin_left;
int margin_right;
int margin_top;
int margin_bottom;
gboolean margin_dirty;
int shadow_left;
int shadow_right;
int shadow_top;
int shadow_bottom;
gboolean shadow_dirty;
struct wl_output *initial_fullscreen_output;
@ -294,7 +294,7 @@ static void gdk_wayland_surface_configure (GdkSurface *surface);
static void maybe_set_gtk_surface_dbus_properties (GdkWaylandSurface *impl);
static void maybe_set_gtk_surface_modal (GdkSurface *surface);
static void gdk_wayland_surface_sync_margin (GdkSurface *surface);
static void gdk_wayland_surface_sync_shadow (GdkSurface *surface);
static void gdk_wayland_surface_sync_input_region (GdkSurface *surface);
static void gdk_wayland_surface_sync_opaque_region (GdkSurface *surface);
@ -366,8 +366,8 @@ _gdk_wayland_surface_save_size (GdkSurface *surface)
if (surface->width <= 1 || surface->height <= 1)
return;
impl->saved_width = surface->width - impl->margin_left - impl->margin_right;
impl->saved_height = surface->height - impl->margin_top - impl->margin_bottom;
impl->saved_width = surface->width - impl->shadow_left - impl->shadow_right;
impl->saved_height = surface->height - impl->shadow_top - impl->shadow_bottom;
}
static void
@ -890,7 +890,7 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
void
gdk_wayland_surface_sync (GdkSurface *surface)
{
gdk_wayland_surface_sync_margin (surface);
gdk_wayland_surface_sync_shadow (surface);
gdk_wayland_surface_sync_opaque_region (surface);
gdk_wayland_surface_sync_input_region (surface);
}
@ -1148,10 +1148,10 @@ gdk_wayland_surface_get_window_geometry (GdkSurface *surface,
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
*geometry = (GdkRectangle) {
.x = impl->margin_left,
.y = impl->margin_top,
.width = surface->width - (impl->margin_left + impl->margin_right),
.height = surface->height - (impl->margin_top + impl->margin_bottom)
.x = impl->shadow_left,
.y = impl->shadow_top,
.width = surface->width - (impl->shadow_left + impl->shadow_right),
.height = surface->height - (impl->shadow_top + impl->shadow_bottom)
};
}
@ -1160,7 +1160,7 @@ static void gdk_wayland_surface_set_geometry_hints (GdkWaylandSurface *impl,
GdkSurfaceHints geom_mask);
static void
gdk_wayland_surface_sync_margin (GdkSurface *surface)
gdk_wayland_surface_sync_shadow (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandDisplay *display_wayland =
@ -1372,12 +1372,12 @@ configure_toplevel_geometry (GdkSurface *surface)
}
gdk_wayland_surface_set_geometry_hints (impl, &geometry, mask);
if (size.margin.is_valid)
if (size.shadow.is_valid)
{
impl->margin_left = size.margin.left;
impl->margin_right = size.margin.right;
impl->margin_top = size.margin.top;
impl->margin_bottom = size.margin.bottom;
impl->shadow_left = size.shadow.left;
impl->shadow_right = size.shadow.right;
impl->shadow_top = size.shadow.top;
impl->shadow_bottom = size.shadow.bottom;
}
if (impl->next_layout.configured_width > 0 &&
@ -1386,9 +1386,9 @@ configure_toplevel_geometry (GdkSurface *surface)
int width, height;
width = impl->next_layout.configured_width +
impl->margin_left + impl->margin_right;
impl->shadow_left + impl->shadow_right;
height = impl->next_layout.configured_height +
impl->margin_top + impl->margin_bottom;
impl->shadow_top + impl->shadow_bottom;
if (impl->next_layout.toplevel.should_constrain)
{
@ -1577,8 +1577,8 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
width = impl->pending.popup.width;
height = impl->pending.popup.height;
x += parent_impl->margin_left;
y += parent_impl->margin_top;
x += parent_impl->shadow_left;
y += parent_impl->shadow_top;
update_popup_layout_state (surface,
x, y,
@ -2262,9 +2262,9 @@ calculate_popup_rect (GdkSurface *surface,
int x = 0, y = 0;
width = (impl->popup.unconstrained_width -
(impl->margin_left + impl->margin_right));
(impl->shadow_left + impl->shadow_right));
height = (impl->popup.unconstrained_height -
(impl->margin_top + impl->margin_bottom));
(impl->shadow_top + impl->shadow_bottom));
anchor_rect = *gdk_popup_layout_get_anchor_rect (layout);
gdk_popup_layout_get_offset (layout, &dx, &dy);
@ -2465,15 +2465,15 @@ create_dynamic_positioner (GdkSurface *surface,
GdkAnchorHints anchor_hints;
geometry = (GdkRectangle) {
.x = impl->margin_left,
.y = impl->margin_top,
.width = width - (impl->margin_left + impl->margin_right),
.height = height - (impl->margin_top + impl->margin_bottom),
.x = impl->shadow_left,
.y = impl->shadow_top,
.width = width - (impl->shadow_left + impl->shadow_right),
.height = height - (impl->shadow_top + impl->shadow_bottom),
};
anchor_rect = gdk_popup_layout_get_anchor_rect (layout);
real_anchor_rect_x = anchor_rect->x - parent_impl->margin_left;
real_anchor_rect_y = anchor_rect->y - parent_impl->margin_top;
real_anchor_rect_x = anchor_rect->x - parent_impl->shadow_left;
real_anchor_rect_y = anchor_rect->y - parent_impl->shadow_top;
anchor_rect_width = MAX (anchor_rect->width, 1);
anchor_rect_height = MAX (anchor_rect->height, 1);
@ -2535,10 +2535,10 @@ create_dynamic_positioner (GdkSurface *surface,
int parent_width;
int parent_height;
parent_width = parent->width - (parent_impl->margin_left +
parent_impl->margin_right);
parent_height = parent->height - (parent_impl->margin_top +
parent_impl->margin_bottom);
parent_width = parent->width - (parent_impl->shadow_left +
parent_impl->shadow_right);
parent_height = parent->height - (parent_impl->shadow_top +
parent_impl->shadow_bottom);
xdg_positioner_set_parent_size (positioner,
parent_width,
@ -3558,9 +3558,9 @@ gdk_wayland_surface_set_geometry_hints (GdkWaylandSurface *impl,
if (geom_mask & GDK_HINT_MIN_SIZE)
{
min_width = MAX (0, (geometry->min_width -
(impl->margin_left + impl->margin_right)));
(impl->shadow_left + impl->shadow_right)));
min_height = MAX (0, (geometry->min_height -
(impl->margin_top + impl->margin_bottom)));
(impl->shadow_top + impl->shadow_bottom)));
}
else
{
@ -3571,9 +3571,9 @@ gdk_wayland_surface_set_geometry_hints (GdkWaylandSurface *impl,
if (geom_mask & GDK_HINT_MAX_SIZE)
{
max_width = MAX (0, (geometry->max_width -
(impl->margin_left + impl->margin_right)));
(impl->shadow_left + impl->shadow_right)));
max_height = MAX (0, (geometry->max_height -
(impl->margin_top + impl->margin_bottom)));
(impl->shadow_top + impl->shadow_bottom)));
}
else
{

View File

@ -4995,13 +4995,13 @@ gdk_win32_toplevel_present (GdkToplevel *toplevel,
show_surface (surface);
if (size.margin.is_valid)
if (size.shadow.is_valid)
{
gdk_win32_surface_set_shadow_width (surface,
size.margin.left,
size.margin.right,
size.margin.top,
size.margin.bottom);
size.shadow.left,
size.shadow.right,
size.shadow.top,
size.shadow.bottom);
}
return TRUE;

View File

@ -268,13 +268,13 @@ gdk_x11_surface_compute_size (GdkSurface *surface)
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
gdk_toplevel_notify_compute_size (GDK_TOPLEVEL (surface), &size);
if (size.margin.is_valid)
if (size.shadow.is_valid)
{
update_shadow_size (surface,
size.margin.left,
size.margin.right,
size.margin.top,
size.margin.bottom);
size.shadow.left,
size.shadow.right,
size.shadow.top,
size.shadow.bottom);
}
surface->width = impl->next_layout.configured_width;
@ -4999,13 +4999,13 @@ gdk_x11_toplevel_present (GdkToplevel *toplevel,
gdk_surface_constrain_size (&geometry, mask, width, height, &width, &height);
gdk_x11_surface_toplevel_resize (surface, width, height);
if (size.margin.is_valid)
if (size.shadow.is_valid)
{
update_shadow_size (surface,
size.margin.left,
size.margin.right,
size.margin.top,
size.margin.bottom);
size.shadow.left,
size.shadow.right,
size.shadow.top,
size.shadow.bottom);
}
impl->pending_configure_events++;

View File

@ -4323,7 +4323,7 @@ toplevel_compute_size (GdkToplevel *toplevel,
if (priv->use_client_shadow)
{
get_shadow_width (window, &shadow);
gdk_toplevel_size_set_margin (size,
gdk_toplevel_size_set_shadow_width (size,
shadow.left, shadow.right,
shadow.top, shadow.bottom);
}