[gnome-terminal] window: Fix CSD size calculations with long titles
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] window: Fix CSD size calculations with long titles
- Date: Sun, 4 Sep 2016 12:32:10 +0000 (UTC)
commit cae04637f696e30f9054482411eb0fabd6064a84
Author: Sjoerd Simons <sjoerd luon net>
Date: Sun Sep 4 14:30:05 2016 +0200
window: Fix CSD size calculations with long titles
To get the size of the window use the actual allocation rather then the
preferred size as the latter takes into account the natural size of the
title bar as well as the content which throws of calculation when the
natural size of the title bar is wider then the content.
Also use the actual allocation of the content specifically for the
calculation of the CSD size such that both are in sync, but keep using
the preferred size otherwise as those values get used for resizing
calculations.
https://bugzilla.gnome.org/show_bug.cgi?id=769898
src/terminal-window.c | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 4207fb1..a290d9f 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3613,11 +3613,11 @@ terminal_window_update_geometry (TerminalWindow *window)
GtkWidget *widget;
GdkGeometry hints;
GtkBorder padding;
- GtkRequisition toplevel_request, vbox_request, widget_request;
+ GtkRequisition vbox_request, widget_request;
int grid_width, grid_height;
int char_width, char_height;
int chrome_width, chrome_height;
- int csd_width, csd_height;
+ int csd_width = 0, csd_height = 0;
if (priv->active_screen == NULL)
return;
@@ -3648,20 +3648,35 @@ terminal_window_update_geometry (TerminalWindow *window)
_terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "content area requests %dx%d px\n",
vbox_request.width, vbox_request.height);
- gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &toplevel_request);
- _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "window requests %dx%d px\n",
- toplevel_request.width, toplevel_request.height);
chrome_width = vbox_request.width - (char_width * grid_width);
chrome_height = vbox_request.height - (char_height * grid_height);
_terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "chrome: %dx%d px\n",
chrome_width, chrome_height);
- csd_width = toplevel_request.width - vbox_request.width;
- csd_height = toplevel_request.height - vbox_request.height;
- _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "CSDs: %dx%d px%s\n",
- csd_width, csd_height,
- priv->realized ? "" : " (just a guess)");
+ if (priv->realized)
+ {
+ /* Only when having been realize the CSD can be calculated. Do this by
+ * using the actual allocation rather then the preferred size as the
+ * the preferred size takes the natural size of e.g. the title bar into
+ * account which can be far wider then the contents size when using a
+ * very long title */
+ GtkAllocation toplevel_allocation, vbox_allocation;
+
+ gtk_widget_get_allocation (GTK_WIDGET (priv->main_vbox), &vbox_allocation);
+ _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,
+ "terminal widget allocation %dx%d px\n",
+ vbox_allocation.width, vbox_allocation.height);
+
+ gtk_widget_get_allocation (GTK_WIDGET (window), &toplevel_allocation);
+ _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "window allocation %dx%d px\n",
+ toplevel_allocation.width, toplevel_allocation.height);
+
+ csd_width = toplevel_allocation.width - vbox_allocation.width;
+ csd_height = toplevel_allocation.height - vbox_allocation.height;
+ _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "CSDs: %dx%d px\n",
+ csd_width, csd_height);
+ }
gtk_widget_get_preferred_size (widget, NULL, &widget_request);
_terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, "terminal widget requests %dx%d px\n",
@@ -3670,8 +3685,8 @@ terminal_window_update_geometry (TerminalWindow *window)
if (!priv->realized)
{
/* Don't actually set the geometry hints until we have been realized,
- * because we don't know precisely how large the client-side decorations
- * are going to be. We also avoid setting priv->old_csd_width or
+ * because we don't know how large the client-side decorations are going
+ * to be. We also avoid setting priv->old_csd_width or
* priv->old_csd_height, so that next time through this function we'll
* definitely recalculate the hints.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]