Skip to content

Commit

Permalink
vte291: Fix geometry issues
Browse files Browse the repository at this point in the history
Thank you
Author: egmont@gmail.com
  • Loading branch information
Wolfgang Ulbrich committed Nov 15, 2015
1 parent f3e72e5 commit 387af1f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
21 changes: 19 additions & 2 deletions src/terminal-screen.c
Expand Up @@ -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 };
Expand Down Expand Up @@ -1679,23 +1683,28 @@ 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);
row = (event->x - (inner_border ? inner_border->left : 0)) / char_width;
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) &&
Expand Down Expand Up @@ -2334,16 +2343,24 @@ 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;
GSList *tags;
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;
Expand Down
25 changes: 22 additions & 3 deletions src/terminal-window.c
Expand Up @@ -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,
Expand All @@ -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) ||
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 387af1f

Please sign in to comment.