vte291: Fix geometry issues

Thank you
Author: egmont@gmail.com
master-1.22
Wolfgang Ulbrich 2015-11-15 23:54:19 +01:00
parent f3e72e52a4
commit 387af1fe86
2 changed files with 41 additions and 5 deletions

View File

@ -138,8 +138,12 @@ static void terminal_screen_cook_title (TerminalScreen *screen);
static void terminal_screen_cook_icon_title (TerminalScreen *screen);
static char* terminal_screen_check_match (TerminalScreen *screen,
#if VTE_CHECK_VERSION (0, 38, 0)
GdkEvent *event,
#else
int column,
int row,
#endif
int *flavor);
static guint signals[LAST_SIGNAL] = { 0 };
@ -1679,14 +1683,19 @@ terminal_screen_button_press (GtkWidget *widget,
TerminalScreen *screen = TERMINAL_SCREEN (widget);
gboolean (* button_press_event) (GtkWidget*, GdkEventButton*) =
GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event;
int char_width, char_height, row, col;
char *matched_string;
int matched_flavor = 0;
guint state;
#if !VTE_CHECK_VERSION (0, 38, 0)
int char_width, char_height, row, col;
GtkBorder *inner_border = NULL;
#endif
state = event->state & gtk_accelerator_get_default_mod_mask ();
#if VTE_CHECK_VERSION (0, 38, 0)
matched_string = terminal_screen_check_match (screen, event, &matched_flavor);
#else
terminal_screen_get_cell_size (screen, &char_width, &char_height);
gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
@ -1694,8 +1703,8 @@ terminal_screen_button_press (GtkWidget *widget,
col = (event->y - (inner_border ? inner_border->top : 0)) / char_height;
gtk_border_free (inner_border);
/* FIXMEchpe: add vte API to do this check by widget coords instead of grid coords */
matched_string = terminal_screen_check_match (screen, row, col, &matched_flavor);
#endif
if (matched_string != NULL &&
(event->button == 1 || event->button == 2) &&
@ -2334,8 +2343,12 @@ terminal_screen_skey_match_remove (TerminalScreen *screen)
static char*
terminal_screen_check_match (TerminalScreen *screen,
#if VTE_CHECK_VERSION (0, 38, 0)
GdkEvent *event,
#else
int column,
int row,
#endif
int *flavor)
{
TerminalScreenPrivate *priv = screen->priv;
@ -2343,7 +2356,11 @@ terminal_screen_check_match (TerminalScreen *screen,
int tag;
char *match;
#if VTE_CHECK_VERSION (0, 38, 0)
match = vte_terminal_match_check_event (VTE_TERMINAL (screen), event, &tag);
#else
match = vte_terminal_match_check (VTE_TERMINAL (screen), column, row, &tag);
#endif
for (tags = priv->match_tags; tags != NULL; tags = tags->next)
{
TagData *tag_data = (TagData*) tags->data;

View File

@ -1060,6 +1060,7 @@ update_edit_menu(TerminalWindow *window)
g_object_ref (window));
}
/* width and height are character-based in vte 0.38, pixel-based in previous versions */
static void
screen_resize_window_cb (TerminalScreen *screen,
guint width,
@ -1069,12 +1070,13 @@ screen_resize_window_cb (TerminalScreen *screen,
TerminalWindowPrivate *priv = window->priv;
VteTerminal *terminal = VTE_TERMINAL (screen);
GtkWidget *widget = GTK_WIDGET (screen);
#if !VTE_CHECK_VERSION (0, 38, 0)
guint grid_width, grid_height;
int char_width, char_height;
GtkBorder *inner_border = NULL;
GtkAllocation widget_allocation;
#endif
gtk_widget_get_allocation (widget, &widget_allocation);
/* Don't do anything if we're maximised or fullscreened */
// FIXME: realized && ... instead?
if (!gtk_widget_get_realized (widget) ||
@ -1083,6 +1085,11 @@ screen_resize_window_cb (TerminalScreen *screen,
/* NOTE: width and height already include the VteTerminal's padding! */
#if VTE_CHECK_VERSION (0, 38, 0)
vte_terminal_set_size (terminal, width, height);
#else
gtk_widget_get_allocation (widget, &widget_allocation);
/* Short-circuit */
if (((int) width) == widget_allocation.width &&
((int) height) == widget_allocation.height)
@ -1099,6 +1106,7 @@ screen_resize_window_cb (TerminalScreen *screen,
gtk_border_free (inner_border);
vte_terminal_set_size (terminal, grid_width, grid_height);
#endif
if (screen != priv->active_screen)
return;
@ -3128,18 +3136,29 @@ terminal_window_update_geometry (TerminalWindow *window)
char_height != priv->old_char_height ||
widget != (GtkWidget*) priv->old_geometry_widget)
{
GtkBorder *inner_border = NULL;
/* FIXME Since we're using xthickness/ythickness to compute
* padding we need to change the hints when the theme changes.
*/
#if VTE_CHECK_VERSION (0, 38, 0)
GtkBorder padding;
gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
gtk_widget_get_state_flags(widget),
&padding);
hints.base_width = padding.left + padding.right;
hints.base_height = padding.top + padding.bottom;
#else
GtkBorder *inner_border = NULL;
gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
hints.base_width = (inner_border ? (inner_border->left + inner_border->right) : 0);
hints.base_height = (inner_border ? (inner_border->top + inner_border->bottom) : 0);
gtk_border_free (inner_border);
#endif
#define MIN_WIDTH_CHARS 4
#define MIN_HEIGHT_CHARS 1