diff --git a/src/pty.cc b/src/pty.cc index b0f56af..822edc0 100644 --- a/src/pty.cc +++ b/src/pty.cc @@ -249,6 +249,21 @@ Pty::child_setup() const noexcept close(fd); } + if (keep_fd > 0) { + int i; + /* Close most descriptors. */ + for (i = 0; i < sysconf(_SC_OPEN_MAX); i++) { + if (i != keep_fd && + i != fd && + i != STDOUT_FILENO && + i != STDIN_FILENO && + i != STDERR_FILENO) { + close(i); + } + } + } + + /* Now set the TERM environment variable */ /* FIXME: Setting environment here seems to have no effect, the merged envp2 will override on exec. * By the way, we'd need to set the one from there, if any. */ @@ -347,6 +362,24 @@ pty_child_setup_cb(void* data) pty->child_setup(); } +static int +_vte_pty_keep_fd(char **env_add) +{ + int i; + const gchar *needle = "VTE_PTY_KEEP_FD="; + + if (env_add == NULL) + return -1; + + for (i = 0; env_add[i] != NULL; i++) { + gchar *s = strstr(env_add[i], needle); + if (s != NULL) + return atoi(&s[strlen(needle)]); + } + + return -1; +} + /* * Pty::spawn: * @directory: the name of a directory the command should start in, or %nullptr @@ -428,6 +461,10 @@ Pty::spawn(char const* directory, /* add the given environment to the childs */ envp2 = __vte_pty_merge_environ (envv, directory, inherit_envv); + keep_fd = _vte_pty_keep_fd(envp2); + if (keep_fd > 0) + spawn_flags |= G_SPAWN_LEAVE_DESCRIPTORS_OPEN; + _VTE_DEBUG_IF (VTE_DEBUG_MISC) { g_printerr ("Spawning command:\n"); for (i = 0; argv[i] != NULL; i++) { diff --git a/src/pty.hh b/src/pty.hh index f03d279..fb42f33 100644 --- a/src/pty.hh +++ b/src/pty.hh @@ -37,6 +37,8 @@ private: VtePtyFlags m_flags{VTE_PTY_DEFAULT}; + int keep_fd{0}; + public: constexpr Pty(int fd = -1, VtePtyFlags flags = VTE_PTY_DEFAULT) noexcept diff --git a/src/vte.cc b/src/vte.cc index cba606e..56b336a 100644 --- a/src/vte.cc +++ b/src/vte.cc @@ -9455,6 +9455,13 @@ Terminal::widget_scroll(GdkEventScroll *event) read_modifiers(base_event); +#if GTK_CHECK_VERSION (2, 90, 8) + /* Do not intercept Alt+scroll, let the GtkNotebook handle it to switch tabs. + Requires a fixed GTK+, see https://bugzilla.gnome.org/show_bug.cgi?id=145244 */ + if (event->state & GDK_MOD1_MASK) + return; +#endif + switch (event->direction) { case GDK_SCROLL_UP: m_mouse_smooth_scroll_delta -= 1.; diff --git a/src/vtegtk.cc b/src/vtegtk.cc index 8edb9d9..8f2dd2d 100644 --- a/src/vtegtk.cc +++ b/src/vtegtk.cc @@ -74,6 +74,7 @@ struct _VteTerminalClassPrivate { GtkStyleProvider *style_provider; + GtkStyleProvider *style_provider_padding; }; #ifdef VTE_DEBUG @@ -399,6 +400,9 @@ vte_terminal_init(VteTerminal *terminal) context = gtk_widget_get_style_context(&terminal->widget); gtk_style_context_add_provider (context, VTE_TERMINAL_GET_CLASS (terminal)->priv->style_provider, + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); + gtk_style_context_add_provider (context, + VTE_TERMINAL_GET_CLASS (terminal)->priv->style_provider_padding, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); /* Initialize private data. NOTE: place is zeroed */ @@ -1813,6 +1817,7 @@ vte_terminal_class_init(VteTerminalClass *klass) klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, VTE_TYPE_TERMINAL, VteTerminalClassPrivate); klass->priv->style_provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ()); + klass->priv->style_provider_padding = GTK_STYLE_PROVIDER (gtk_css_provider_new ()); gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (klass->priv->style_provider), "VteTerminal, " VTE_TERMINAL_CSS_NAME " {\n" "padding: 1px 1px 1px 1px;\n" @@ -1821,6 +1826,11 @@ vte_terminal_class_init(VteTerminalClass *klass) "}\n", -1, NULL); + gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (klass->priv->style_provider_padding), + "VteTerminal, " VTE_TERMINAL_CSS_NAME " {\n" + "padding: 1px 1px 1px 1px;\n" + "}\n", + -1, NULL); #ifdef WITH_A11Y /* a11y */ gtk_widget_class_set_accessible_type(widget_class, VTE_TYPE_TERMINAL_ACCESSIBLE);