[gtk/wip/baedert/single-node-window: 485/485] /o\
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/single-node-window: 485/485] /o\
- Date: Thu, 7 May 2020 19:10:28 +0000 (UTC)
commit f56a710a55a3bb1992bc1f92160a3de48da18d60
Author: Timm Bäder <mail baedert org>
Date: Sat May 2 18:50:53 2020 +0200
/o\
gtk/gtkwindow.c | 88 ++++++++++++++++++---------------------------------------
1 file changed, 27 insertions(+), 61 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 86bf03c990..070760b8cb 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2157,7 +2157,7 @@ gtk_window_native_get_surface_transform (GtkNative *native,
get_shadow_width (GTK_WINDOW (native), &shadow);
*x = shadow.left;
- *y = shadow.right;
+ *y = shadow.top;
}
static void
@@ -4492,16 +4492,6 @@ max_borders (GtkBorder *one,
one->left = MAX (one->left, two->left);
}
-static void
-subtract_borders (GtkBorder *one,
- GtkBorder *two)
-{
- one->top -= two->top;
- one->right -= two->right;
- one->bottom -= two->bottom;
- one->left -= two->left;
-}
-
static void
get_shadow_width (GtkWindow *window,
GtkBorder *shadow_width)
@@ -4549,37 +4539,21 @@ get_shadow_width (GtkWindow *window,
static void
update_csd_shape (GtkWindow *window)
{
- GtkWidget *widget = (GtkWidget *)window;
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
cairo_rectangle_int_t rect;
- GtkBorder border, tmp;
GtkBorder window_border;
- GtkStyleContext *context;
if (!priv->client_decorated)
return;
- context = _gtk_widget_get_style_context (widget);
-
- /*gtk_style_context_save_to_node (context, priv->decoration_node);*/
- gtk_style_context_get_margin (context, &border);
- gtk_style_context_get_border (context, &tmp);
- sum_borders (&border, &tmp);
- gtk_style_context_get_padding (context, &tmp);
- sum_borders (&border, &tmp);
- /*gtk_style_context_restore (context);*/
get_shadow_width (window, &window_border);
/* update the input shape, which makes it so that clicks
- * outside the border windows go through.
- */
-
- subtract_borders (&window_border, &border);
-
+ * outside the border windows go through. */
rect.x = window_border.left;
rect.y = window_border.top;
- rect.width = gtk_widget_get_allocated_width (widget) - window_border.left - window_border.right;
- rect.height = gtk_widget_get_allocated_height (widget) - window_border.top - window_border.bottom;
+ rect.width = gdk_surface_get_width (priv->surface) - window_border.left - window_border.right;
+ rect.height = gdk_surface_get_height (priv->surface) - window_border.top - window_border.bottom;
if (rect.width > 0 && rect.height > 0)
{
@@ -4627,8 +4601,6 @@ subtract_decoration_corners_from_region (cairo_region_t *region,
priv->maximized)
return;
- /*gtk_style_context_save_to_node (context, priv->decoration_node);*/
-
corner_rect (&rect, _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS));
rect.x = extents->x;
rect.y = extents->y;
@@ -4648,14 +4620,11 @@ subtract_decoration_corners_from_region (cairo_region_t *region,
rect.x = extents->x + extents->width - rect.width;
rect.y = extents->y + extents->height - rect.height;
cairo_region_subtract_rectangle (region, &rect);
-
- /*gtk_style_context_restore (context);*/
}
static void
-update_opaque_region (GtkWindow *window,
- const GtkBorder *border,
- const GtkAllocation *allocation)
+update_opaque_region (GtkWindow *window,
+ const GtkBorder *border)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *widget = GTK_WIDGET (window);
@@ -4664,7 +4633,7 @@ update_opaque_region (GtkWindow *window,
gboolean is_opaque = FALSE;
if (!_gtk_widget_get_realized (widget))
- return;
+ return;
context = gtk_widget_get_style_context (widget);
@@ -4679,8 +4648,8 @@ update_opaque_region (GtkWindow *window,
rect.x = border->left;
rect.y = border->top;
- rect.width = allocation->width - border->left - border->right;
- rect.height = allocation->height - border->top - border->bottom;
+ rect.width = gdk_surface_get_width (priv->surface) - border->left - border->right;
+ rect.height = gdk_surface_get_height (priv->surface) - border->top - border->bottom;
opaque_region = cairo_region_create_rectangle (&rect);
@@ -4710,7 +4679,7 @@ update_realized_window_properties (GtkWindow *window,
window_border->top,
window_border->bottom);
- update_opaque_region (window, window_border, child_allocation);
+ update_opaque_region (window, window_border);
update_csd_shape (window);
}
@@ -4740,6 +4709,7 @@ gtk_window_realize (GtkWidget *widget)
allocation.y = shadow.top;
allocation.width = request.width - shadow.left - shadow.right;
allocation.height = request.height - shadow.top - shadow.bottom;
+
gtk_widget_size_allocate (widget, &allocation, -1);
gtk_widget_queue_resize (widget);
@@ -5640,13 +5610,11 @@ gtk_window_css_changed (GtkWidget *widget,
if (!_gtk_widget_get_alloc_needed (widget) &&
(change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_BACKGROUND_COLOR)))
{
- GtkAllocation allocation;
- GtkBorder window_border;
+ GtkBorder shadow;
- gtk_widget_get_allocation (widget, &allocation);
- get_shadow_width (window, &window_border);
+ get_shadow_width (window, &shadow);
- update_opaque_region (window, &window_border, &allocation);
+ update_opaque_region (window, &shadow);
}
}
@@ -5940,7 +5908,6 @@ gtk_window_do_popup (GtkWindow *window,
/* This function doesn't constrain to geometry hints */
static void
gtk_window_compute_configure_request_size (GtkWindow *window,
- GdkGeometry *geometry,
guint flags,
gint *width,
gint *height)
@@ -6035,7 +6002,7 @@ gtk_window_compute_configure_request (GtkWindow *window,
gtk_window_compute_hints (window, &new_geometry, &new_flags);
gtk_window_compute_configure_request_size (window,
- &new_geometry, new_flags,
+ new_flags,
&w, &h);
gtk_window_update_fixed_size (window, &new_geometry, w, h);
gtk_window_constrain_size (window,
@@ -6057,14 +6024,10 @@ gtk_window_compute_configure_request (GtkWindow *window,
y = 0;
}
- GtkBorder shadow = {0, };
-
- /*get_shadow_width (window, &shadow);*/
-
request->x = x;
request->y = y;
- request->width = w + shadow.left + shadow.right;
- request->height = h + shadow.top + shadow.bottom;
+ request->width = w;
+ request->height = h;
if (geometry)
*geometry = new_geometry;
@@ -6242,10 +6205,10 @@ gtk_window_move_resize (GtkWindow *window)
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
&min, NULL, NULL, NULL);
- allocation.width = MAX (min, current_width);
+ allocation.width = MAX (min, current_width - shadow.left - shadow.right);
gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, allocation.width,
&min, NULL, NULL, NULL);
- allocation.height = MAX (min, current_height);
+ allocation.height = MAX (min, current_height - shadow.top - shadow.bottom);
gtk_widget_size_allocate (widget, &allocation, -1);
@@ -6480,6 +6443,7 @@ gtk_window_update_fixed_size (GtkWindow *window,
if (info->default_width > -1)
{
gint w = MAX (MAX (default_width_csd, new_width), new_geometry->min_width);
+ g_critical ("TODO: Probably need to add the shadow size here as well");
new_geometry->min_width = w;
new_geometry->max_width = w;
}
@@ -6500,12 +6464,13 @@ gtk_window_update_fixed_size (GtkWindow *window,
*/
static void
gtk_window_compute_hints (GtkWindow *window,
- GdkGeometry *new_geometry,
- guint *new_flags)
+ GdkGeometry *new_geometry,
+ guint *new_flags)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *widget;
GtkRequisition requisition;
+ GtkBorder shadow;
widget = GTK_WIDGET (window);
@@ -6529,10 +6494,11 @@ gtk_window_compute_hints (GtkWindow *window,
new_geometry->base_width = 0;
new_geometry->base_height = 0;
+ get_shadow_width (window, &shadow);
*new_flags |= GDK_HINT_MIN_SIZE;
- new_geometry->min_width = requisition.width;
- new_geometry->min_height = requisition.height;
-
+ new_geometry->min_width = requisition.width + shadow.left + shadow.right;
+ new_geometry->min_height = requisition.height + shadow.top + shadow.bottom;
+
if (!priv->resizable)
{
*new_flags |= GDK_HINT_MAX_SIZE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]