From 7982fac85ca089ff88702e389ca6cf83b9489321 Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Tue, 6 Aug 2013 22:27:37 -0400 Subject: [PATCH] Add option for enabling size hints for the window Cleaned up per discussion on #112 --- config | 3 +++ termite.cc | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config b/config index cfca532..7f2071d 100644 --- a/config +++ b/config @@ -32,6 +32,9 @@ cursor_shape = block # (default if unset: all graphic non-punctuation/space characters) #word_chars = -A-Za-z0-9,./?%&#:_=+@~ +# set size hints for the window +#size_hints = false + [colors] foreground = #dcdccc foreground_bold = #ffffff diff --git a/termite.cc b/termite.cc index fdbea48..ff34478 100644 --- a/termite.cc +++ b/termite.cc @@ -88,7 +88,7 @@ struct hint_info { struct config_info { hint_info hints; char *browser; - gboolean dynamic_title, urgent_on_bell, clickable_url, opacity_set, pseudo_transparency; + gboolean dynamic_title, urgent_on_bell, clickable_url, opacity_set, pseudo_transparency, size_hints; int tag; char *config_file; }; @@ -151,6 +151,21 @@ static void set_opacity(GtkWidget *window, VteTerminal *vte, double opacity, gbo } } +static void set_size_hints(GtkWindow *window, int char_width, int char_height) +{ + static const GdkWindowHints wh = (GdkWindowHints)(GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE); + GdkGeometry hints; + + hints.base_width = char_width; + hints.base_height = char_height; + hints.min_width = char_width; + hints.min_height = char_height; + hints.width_inc = char_width; + hints.height_inc = char_height; + + gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &hints, wh); +} + static void launch_in_directory(VteTerminal *vte) { const char *uri = vte_terminal_get_current_directory_uri(vte); if (!uri) { @@ -1175,6 +1190,7 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info, info->urgent_on_bell = cfg_bool("urgent_on_bell", TRUE); info->clickable_url = cfg_bool("clickable_url", TRUE); info->pseudo_transparency = cfg_bool("pseudo_transparency", FALSE); + info->size_hints = cfg_bool("size_hints", FALSE); if (info->clickable_url) { info->tag = @@ -1245,6 +1261,11 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info, } } + if (info->size_hints) { + set_size_hints(GTK_WINDOW(window), (int)vte_terminal_get_char_width(vte), + (int)vte_terminal_get_char_height(vte)); + } + load_theme(window, vte, config, info->hints); }/*}}}*/ @@ -1344,7 +1365,7 @@ int main(int argc, char **argv) { nullptr}, {vi_mode::insert, 0, 0, 0, 0}, {{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, 0, 0}, - nullptr, FALSE, FALSE, FALSE, FALSE, FALSE, -1, config_file} + nullptr, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, config_file} }; load_config(GTK_WINDOW(window), vte, &info.config, geometry ? nullptr : &geometry);