diff --git a/termite.cc b/termite.cc index 07061b3..c31aef6 100644 --- a/termite.cc +++ b/termite.cc @@ -98,6 +98,7 @@ struct keybind_info { search_panel_info panel; select_info select; config_info config; + std::function fullscreen_toggle; }; struct draw_cb_info { @@ -108,6 +109,7 @@ struct draw_cb_info { static void launch_browser(char *browser, char *url); static void window_title_cb(VteTerminal *vte, gboolean *dynamic_title); +static gboolean window_state_cb(GtkWindow *window, GdkEventWindowState *event, keybind_info *info); static gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info); static gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *info); static gboolean position_overlay_cb(GtkBin *overlay, GtkWidget *widget, GdkRectangle *alloc); @@ -599,8 +601,20 @@ static void update_font_size(VteTerminal *vte, int update, GtkWindow *window) { } } +gboolean window_state_cb(GtkWindow *, GdkEventWindowState *event, keybind_info *info) { + if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) + info->fullscreen_toggle = gtk_window_unfullscreen; + else + info->fullscreen_toggle = gtk_window_fullscreen; + return FALSE; +} + gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info) { const guint modifiers = event->state & gtk_accelerator_get_default_mod_mask(); + + if (event->keyval == GDK_KEY_F11) + info->fullscreen_toggle(info->window); + if (info->select.mode != vi_mode::insert) { if (modifiers == GDK_CONTROL_MASK) { switch (gdk_keyval_to_lower(event->keyval)) { @@ -1358,7 +1372,8 @@ 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, -1, config_file} + nullptr, FALSE, FALSE, FALSE, FALSE, -1, config_file}, + gtk_window_fullscreen }; load_config(GTK_WINDOW(window), vte, &info.config, geometry ? nullptr : &geometry); @@ -1395,6 +1410,7 @@ int main(int argc, char **argv) { g_signal_connect(vte, "child-exited", G_CALLBACK(exit_with_status), nullptr); } g_signal_connect(window, "destroy", G_CALLBACK(exit_with_success), nullptr); + g_signal_connect(window, "window-state-event", G_CALLBACK(window_state_cb), &info); g_signal_connect(vte, "key-press-event", G_CALLBACK(key_press_cb), &info); g_signal_connect(info.panel.entry, "key-press-event", G_CALLBACK(entry_key_press_cb), &info); g_signal_connect(panel_overlay, "get-child-position", G_CALLBACK(position_overlay_cb), nullptr);