Hello community, here is the log from the commit of package terminus for openSUSE:Factory checked in at 2019-10-14 12:41:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terminus (Old) and /work/SRC/openSUSE:Factory/.terminus.new.2352 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terminus" Mon Oct 14 12:41:42 2019 rev:5 rq:737928 version:1.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/terminus/terminus.changes 2019-05-10 09:19:19.376421423 +0200 +++ /work/SRC/openSUSE:Factory/.terminus.new.2352/terminus.changes 2019-10-14 12:41:54.826635653 +0200 @@ -1,0 +2,11 @@ +Sat Oct 12 20:17:46 UTC 2019 - Alexei Podvalsky <[email protected]> + +- Update to 1.7.0: + * Fixed the right-click menu under Wayland + * Fixed several compiling warnings + * Removed deprecated calls + * Now the Wayland version (under gnome shell) works like the + X11 one (is shown over all windows, and in all workspaces) + * Now the "guake" terminal is show always in the primary monitor + +------------------------------------------------------------------- Old: ---- terminus-1.5.0.tar.gz New: ---- terminus-1.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terminus.spec ++++++ --- /var/tmp/diff_new_pack.Vi0rTg/_old 2019-10-14 12:41:58.050627222 +0200 +++ /var/tmp/diff_new_pack.Vi0rTg/_new 2019-10-14 12:41:58.058627201 +0200 @@ -17,7 +17,7 @@ Name: terminus -Version: 1.5.0 +Version: 1.7.0 Release: 0 Summary: An X terminal written in Vala License: GPL-3.0-or-later ++++++ terminus-1.5.0.tar.gz -> terminus-1.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/CMakeLists.txt new/terminus-1.7.0/CMakeLists.txt --- old/terminus-1.5.0/CMakeLists.txt 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/CMakeLists.txt 2019-10-11 00:15:05.000000000 +0200 @@ -8,7 +8,6 @@ enable_testing () option(ICON_UPDATE "Update the icon cache after installing" ON) option(BUILD_VALADOC "Build API documentation if Valadoc is available" OFF) -option(GTK_3_20 "GTK_3_20" OFF) if( NOT CMAKE_BUILD_TYPE ) set(CMAKE_BUILD_TYPE Release) @@ -37,9 +36,11 @@ set(MODULES_TO_CHECK ${MODULES_TO_CHECK} gtk+-3.0) set(MODULES_TO_CHECK ${MODULES_TO_CHECK} gee-0.8) set(MODULES_TO_CHECK ${MODULES_TO_CHECK} gio-2.0) +set(MODULES_TO_CHECK ${MODULES_TO_CHECK} gio-unix-2.0) set(MODULES_TO_CHECK ${MODULES_TO_CHECK} glib-2.0) set(MODULES_TO_CHECK ${MODULES_TO_CHECK} gobject-2.0) set(MODULES_TO_CHECK ${MODULES_TO_CHECK} keybinder-3.0) +set(MODULES_TO_CHECK ${MODULES_TO_CHECK} pango) set(MODULES_TO_CHECK ${MODULES_TO_CHECK} vte-2.91) pkg_check_modules(DEPS REQUIRED ${MODULES_TO_CHECK}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/HISTORY.md new/terminus-1.7.0/HISTORY.md --- old/terminus-1.5.0/HISTORY.md 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/HISTORY.md 2019-10-11 00:15:05.000000000 +0200 @@ -1,5 +1,12 @@ # History of versions # +* Version 1.7.0 (2019-10-11) + * Fixed the right-click menu under Wayland + * Fixed several compiling warnings + * Removed deprecated calls +* Version 1.6.0 (2019-09-23) + * Now the Wayland version (under gnome shell) works like the X11 one (is shown over all windows, and in all workspaces) + * Now the "guake" terminal is show always in the primary monitor * Version 1.5.0 (2019-05-06) * Now PASTE works with clipboard managers * Version 1.4.1 (2019-03-26) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/PKGBUILD new/terminus-1.7.0/PKGBUILD --- old/terminus-1.5.0/PKGBUILD 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/PKGBUILD 2019-10-11 00:15:05.000000000 +0200 @@ -1,5 +1,5 @@ pkgname=terminus -pkgver=1.5.0 +pkgver=1.7.0 pkgrel=1 pkgdesc="A new terminal for XWindows " diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/README.md new/terminus-1.7.0/README.md --- old/terminus-1.5.0/README.md 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/README.md 2019-10-11 00:15:05.000000000 +0200 @@ -38,16 +38,6 @@ in a folder with parts of a previously failed cmake run can result in build errors (don't ask why). -If your system has an old Gtk version (like Ubuntu yakkety yak, which has Gtk 3.20), -you would need to define GTK_3_20 to use some old functions, not available in versions -older than Gtk 3.22. You can do it this way: - - mkdir install - cd install - cmake .. -DGTK_3_20=on - make - sudo make install - ## Using it ## By default, using Shift+F12 will show the Quake-like terminal, but you can change diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/data/interface/properties.ui new/terminus-1.7.0/data/interface/properties.ui --- old/terminus-1.5.0/data/interface/properties.ui 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/data/interface/properties.ui 2019-10-11 00:15:05.000000000 +0200 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.22.1 --> <interface> <requires lib="gtk+" version="3.20"/> <object class="GtkListStore" id="color_schemes"> @@ -48,6 +48,9 @@ <object class="GtkWindow"> <property name="can_focus">False</property> <child> + <placeholder/> + </child> + <child> <object class="GtkNotebook" id="properties_notebook"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -84,7 +87,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="top_attach">5</property> <property name="width">2</property> </packing> </child> @@ -125,6 +128,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="halign">start</property> <property name="draw_indicator">True</property> </object> <packing> @@ -147,25 +151,12 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="rewrap_on_resize"> - <property name="label" translatable="yes">Rewrap on resize</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - <property name="width">2</property> - </packing> - </child> - <child> <object class="GtkCheckButton" id="allow_bold"> <property name="label" translatable="yes">Allow bold text</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> + <property name="halign">start</property> <property name="draw_indicator">True</property> </object> <packing> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/debian/changelog new/terminus-1.7.0/debian/changelog --- old/terminus-1.5.0/debian/changelog 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/debian/changelog 2019-10-11 00:15:05.000000000 +0200 @@ -1,3 +1,18 @@ +terminus (1.7.0-Debian1) sid; urgency=low + + * Fixed the right-click menu under Wayland + * Fixed several compiling warnings + * Removed deprecated calls + + -- Sergio Costas Rodriguez <[email protected]> Fry, 11 Oct 2019 23:55:00 +0200 + +terminus (1.6.0-Debian1) sid; urgency=low + + * Now the Wayland version (under gnome shell) works like the X11 one (is shown over all windows, and in all workspaces) + * Now the "guake" terminal is show always in the primary monitor + + -- Sergio Costas Rodriguez <[email protected]> Mon, 23 Sep 2019 23:55:00 +0200 + terminus (1.5.0-Debian1) sid; urgency=low * Now PASTE works with clipboard managers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/debian/control new/terminus-1.7.0/debian/control --- old/terminus-1.5.0/debian/control 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/debian/control 2019-10-11 00:15:05.000000000 +0200 @@ -8,7 +8,7 @@ Package: terminus Architecture: any -Version: 1.5.0 +Version: 1.7.0 Depends: libgee-0.8-2, libkeybinder-3.0-0, libvte-2.91-0, libpcre3, libglib2.0-bin Description: A new terminal for X11 and Wayland both for classic, in-window terminal, and Guake-like (hot-key drop-down mode) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/meson.build new/terminus-1.7.0/meson.build --- old/terminus-1.5.0/meson.build 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/meson.build 2019-10-11 00:15:05.000000000 +0200 @@ -1,7 +1,5 @@ project('terminus',['c','vala']) -GTK_3_20 = (get_option('GTK_3_20') != '') - add_global_arguments('-DGETTEXT_PACKAGE="terminus"',language: 'c') find_program ('glib-compile-resources') @@ -11,9 +9,11 @@ gtk_3_0_dep = dependency('gtk+-3.0') gee_0_8_dep = dependency('gee-0.8') gio_2_0_dep = dependency('gio-2.0') +gio_unix_2_0_dep = dependency('gio-unix-2.0') glib_2_0_dep = dependency('glib-2.0') gobject_2_0_dep = dependency('gobject-2.0') keybinder_3_0_dep = dependency('keybinder-3.0') +pango_dep = dependency('pango') vte_2_91_dep = dependency('vte-2.91') subdir('po') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/meson_options.txt new/terminus-1.7.0/meson_options.txt --- old/terminus-1.5.0/meson_options.txt 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/meson_options.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -option('GTK_3_20',type : 'string', value: '') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/rpmbuild/SPECS/terminus.spec new/terminus-1.7.0/rpmbuild/SPECS/terminus.spec --- old/terminus-1.5.0/rpmbuild/SPECS/terminus.spec 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/rpmbuild/SPECS/terminus.spec 2019-10-11 00:15:05.000000000 +0200 @@ -1,5 +1,5 @@ Name: terminus -Version: 1.5.0 +Version: 1.7.0 Release: 1 License: Unknown/not set Summary: A new terminal for XWindows and Wayland diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/CMakeLists.txt new/terminus-1.7.0/src/CMakeLists.txt --- old/terminus-1.5.0/src/CMakeLists.txt 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/CMakeLists.txt 2019-10-11 00:15:05.000000000 +0200 @@ -7,13 +7,13 @@ set (RELEASE_NAME "terminus") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "1.5.0") +set (VERSION "1.7.0") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.base ${CMAKE_BINARY_DIR}/src/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "1.5.0") +set (VERSION "1.7.0") add_definitions (${DEPS_CFLAGS}) link_libraries ( ${DEPS_LIBRARIES} ) link_directories ( ${DEPS_LIBRARY_DIRS} ) @@ -27,9 +27,11 @@ set (VALA_PACKAGES ${VALA_PACKAGES} gtk+-3.0) set (VALA_PACKAGES ${VALA_PACKAGES} gee-0.8) set (VALA_PACKAGES ${VALA_PACKAGES} gio-2.0) +set (VALA_PACKAGES ${VALA_PACKAGES} gio-unix-2.0) set (VALA_PACKAGES ${VALA_PACKAGES} glib-2.0) set (VALA_PACKAGES ${VALA_PACKAGES} gobject-2.0) set (VALA_PACKAGES ${VALA_PACKAGES} keybinder-3.0) +set (VALA_PACKAGES ${VALA_PACKAGES} pango) set (VALA_PACKAGES ${VALA_PACKAGES} vte-2.91) set (APP_SOURCES ${APP_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Config.vala) @@ -46,11 +48,6 @@ set (CUSTOM_VAPIS_LIST ${CUSTOM_VAPIS_LIST} ${CMAKE_SOURCE_DIR}/src/checkwayland.vapi) -if (GTK_3_20) - set (COMPILE_OPTIONS ${COMPILE_OPTIONS} -D GTK_3_20) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGTK_3_20 " ) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTK_3_20 " ) -endif () set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --vapidir=${CMAKE_SOURCE_DIR}/src/vapidir ) if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug") OR (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/bindkeys.vala new/terminus-1.7.0/src/bindkeys.vala --- old/terminus-1.5.0/src/bindkeys.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/bindkeys.vala 2019-10-11 00:15:05.000000000 +0200 @@ -33,7 +33,11 @@ public signal void show_guake(); public Bindkey(bool use_bindkey) { - this.use_bindkey = use_bindkey; + if (check_wayland() != 0) { + this.use_bindkey = false; + } else { + this.use_bindkey = use_bindkey; + } if (this.use_bindkey) { Keybinder.init(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/checkwayland.c new/terminus-1.7.0/src/checkwayland.c --- old/terminus-1.5.0/src/checkwayland.c 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/checkwayland.c 2019-10-11 00:15:05.000000000 +0200 @@ -14,7 +14,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #include "gdk/gdk.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/container.vala new/terminus-1.7.0/src/container.vala --- old/terminus-1.5.0/src/container.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/container.vala 2019-10-11 00:15:05.000000000 +0200 @@ -27,7 +27,7 @@ * one. */ - public enum MoveFocus {UP, DOWN, LEFT, RIGHT} + public enum MoveFocus { UP, DOWN, LEFT, RIGHT } class Container : Gtk.Bin { public Terminus.Container ? container1; @@ -44,7 +44,7 @@ public signal void ended(Terminus.Container who); public Container(Terminus.Base main_container, Terminus.Terminal ? terminal, Terminus.Container ? top_container, Terminus.Container ? upper_container) { - this.main_container = main_container; + this.main_container = main_container; this.upper_container = upper_container; if (top_container == null) { this.top_container = this; @@ -129,14 +129,14 @@ this.terminal = null; } - public void move_focus(MoveFocus direction, Terminus.Container ? sender, bool searching_up) { + public void move_terminal_focus(MoveFocus direction, Terminus.Container ? sender, bool searching_up) { if (sender == null) { sender = this.container1; } if (this.terminal != null) { if (searching_up) { if (this.upper_container != null) { - this.upper_container.move_focus(direction, this, true); + this.upper_container.move_terminal_focus(direction, this, true); } } else { this.terminal.do_grab_focus(); @@ -149,53 +149,54 @@ if (searching_up) { if (this.splited_horizontal) { if ((direction == Terminus.MoveFocus.UP) && (sender == this.container2)) { - this.container1.move_focus(direction, this, false); + this.container1.move_terminal_focus(direction, this, false); } else if ((direction == Terminus.MoveFocus.DOWN) && (sender == this.container1)) { - this.container2.move_focus(direction, this, false); + this.container2.move_terminal_focus(direction, this, false); } else { if (this.upper_container != null) { - this.upper_container.move_focus(direction, this, true); + this.upper_container.move_terminal_focus(direction, this, true); } } } else { if (this.upper_container != null) { - this.upper_container.move_focus(direction, this, true); + this.upper_container.move_terminal_focus(direction, this, true); } } } else { if (direction == Terminus.MoveFocus.UP) { - this.container2.move_focus(direction, this, false); + this.container2.move_terminal_focus(direction, this, false); } else { - this.container1.move_focus(direction, this, false); + this.container1.move_terminal_focus(direction, this, false); } } - break; + break; + case Terminus.MoveFocus.LEFT: case Terminus.MoveFocus.RIGHT: if (searching_up) { if (!this.splited_horizontal) { if ((direction == Terminus.MoveFocus.LEFT) && (sender == this.container2)) { - this.container1.move_focus(direction, this, false); + this.container1.move_terminal_focus(direction, this, false); } else if ((direction == Terminus.MoveFocus.RIGHT) && (sender == this.container1)) { - this.container2.move_focus(direction, this, false); + this.container2.move_terminal_focus(direction, this, false); } else { if (this.upper_container != null) { - this.upper_container.move_focus(direction, this, true); + this.upper_container.move_terminal_focus(direction, this, true); } } } else { if (this.upper_container != null) { - this.upper_container.move_focus(direction, this, true); + this.upper_container.move_terminal_focus(direction, this, true); } } } else { if (direction == Terminus.MoveFocus.LEFT) { - this.container2.move_focus(direction, this, false); + this.container2.move_terminal_focus(direction, this, false); } else { - this.container1.move_focus(direction, this, false); + this.container1.move_terminal_focus(direction, this, false); } } - break; + break; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/meson.build new/terminus-1.7.0/src/meson.build --- old/terminus-1.5.0/src/meson.build 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/meson.build 2019-10-11 00:15:05.000000000 +0200 @@ -4,7 +4,7 @@ cfg_terminus.set('GETTEXT_PACKAGE', 'terminus') cfg_terminus.set('RELEASE_NAME', 'terminus') cfg_terminus.set('PREFIX', get_option('prefix')) -cfg_terminus.set('VERSION', '1.5.0') +cfg_terminus.set('VERSION', '1.7.0') cfg_terminus.set('TESTSRCDIR', meson.source_root()) cfgfile_2 = configure_file( @@ -16,9 +16,11 @@ terminus_deps += [gtk_3_0_dep] terminus_deps += [gee_0_8_dep] terminus_deps += [gio_2_0_dep] +terminus_deps += [gio_unix_2_0_dep] terminus_deps += [glib_2_0_dep] terminus_deps += [gobject_2_0_dep] terminus_deps += [keybinder_3_0_dep] +terminus_deps += [pango_dep] terminus_deps += [vte_2_91_dep] terminus_sources = [cfgfile_2] terminus_sources += ['PanedPercentage.vala'] @@ -37,17 +39,11 @@ terminus_vala_args = ['--pkg','posix'] terminus_vala_args += ['--vapidir='+join_paths(meson.source_root(),'src/vapidir')] terminus_vala_args += ['--gresources='+join_paths(meson.source_root(),'data/extras.gresource.xml')] -terminus_c_args = [] -if GTK_3_20 - terminus_vala_args += ['-D', 'GTK_3_20'] - terminus_c_args += ['-DGTK_3_20'] -endif terminus_link_args = ['-rdynamic'] executable('terminus',terminus_sources, dependencies: terminus_deps, vala_args: terminus_vala_args, - c_args: terminus_c_args, link_args: terminus_link_args, install: true) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/params.vala new/terminus-1.7.0/src/params.vala --- old/terminus-1.5.0/src/params.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/params.vala 2019-10-11 00:15:05.000000000 +0200 @@ -14,8 +14,11 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +//using GIO +//using GIO-unix namespace Terminus { class Parameters : Object { @@ -24,6 +27,7 @@ public bool check_guake; public string[] command; public string ? working_directory; + public string ? UUID; public Parameters(string [] argv) { int param_counter = 0; @@ -33,6 +37,7 @@ this.check_guake = false; this.working_directory = null; this.command = {}; + this.UUID = null; var add_commands = false; @@ -47,11 +52,27 @@ this.show_usage(0); break; } + if (argv[param_counter] == "--uuid") { + var stdinInput = new GLib.DataInputStream(new GLib.UnixInputStream(0, false)); + this.UUID = stdinInput.read_line(); + stdinInput.close(); + continue; + } if (argv[param_counter] == "--guake") { this.launch_guake = true; continue; } if (argv[param_counter] == "--check_guake") { + if (check_wayland() != 0) { + Posix.exit(0); + } + this.check_guake = true; + continue; + } + if (argv[param_counter] == "--check_guake_wayland") { + if (check_wayland() == 0) { + Posix.exit(0); + } this.check_guake = true; continue; } @@ -118,7 +139,8 @@ -e, --command=STRING launches a new Terminus window and execute the argument inside the terminal --working-directory=DIRNAME sets the terminal directory to DIRNAME --guake launch Terminus in background - --check_guake launch Terminus in background and return if there is already another Terminus process + --check_guake launch Terminus in background and return if there is already another Terminus process, or in Wayland + --check_guake_wayland launch Terminus in background and return if there is already another Terminus process, or in X11 --nobindkey don't try to bind the Quake-mode key (useful for gnome shell) """)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/settings.vala new/terminus-1.7.0/src/settings.vala --- old/terminus-1.5.0/src/settings.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/settings.vala 2019-10-11 00:15:05.000000000 +0200 @@ -198,7 +198,7 @@ this.palette_scheme.get_active_iter(out iter); GLib.Value selectedCell; this.palette_schemes.get_value(iter, 1, out selectedCell); - selected = selectedCell.get_int(); + selected = selectedCell.get_int(); var scheme = Terminus.main_root.palettes[selected]; if (scheme.custom) { return; @@ -221,7 +221,7 @@ this.color_scheme.get_active_iter(out iter); GLib.Value selectedCell; this.color_schemes.get_value(iter, 1, out selectedCell); - selected = selectedCell.get_int(); + selected = selectedCell.get_int(); var scheme = Terminus.main_root.palettes[selected]; if (scheme.custom) { return; @@ -250,7 +250,6 @@ Terminus.settings.bind("scroll-on-keystroke", main_window.get_object("scroll_on_keystroke") as Gtk.CheckButton, "active", GLib.SettingsBindFlags.DEFAULT); Terminus.settings.bind("enable-guake-mode", this.enable_guake_mode, "active", GLib.SettingsBindFlags.DEFAULT); Terminus.settings.bind("terminal-bell", main_window.get_object("terminal_bell") as Gtk.CheckButton, "active", GLib.SettingsBindFlags.DEFAULT); - Terminus.settings.bind("rewrap-on-resize", main_window.get_object("rewrap_on_resize") as Gtk.CheckButton, "active", GLib.SettingsBindFlags.DEFAULT); Terminus.settings.bind("allow-bold", main_window.get_object("allow_bold") as Gtk.CheckButton, "active", GLib.SettingsBindFlags.DEFAULT); Terminus.settings.bind("shell-command", main_window.get_object("command_shell") as Gtk.Entry, "text", GLib.SettingsBindFlags.DEFAULT); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/terminal.vala new/terminus-1.7.0/src/terminal.vala --- old/terminus-1.5.0/src/terminal.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/terminal.vala 2019-10-11 00:15:05.000000000 +0200 @@ -14,7 +14,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ using Vte; using Gtk; @@ -33,12 +34,16 @@ private Gtk.Label title; private Gtk.EventBox titlebox; private Gtk.EventBox closeButton; - private Gtk.Menu menu; - private Gtk.MenuItem item_copy; + private Gtk.Popover menuPopover; + private Gtk.Button item_copy; + private Gtk.Box menu_container; private Terminus.Container top_container; private Terminus.Container container; private Terminus.Base main_container; private Gtk.Scrollbar right_scroll; + private double title_r; + private double title_g; + private double title_b; private Gdk.EventKey new_tab_key; private Gdk.EventKey new_window_key; @@ -58,10 +63,88 @@ private void add_separator() { - var separator = new Gtk.SeparatorMenuItem(); + var separator = new Gtk.Separator(Gtk.Orientation.HORIZONTAL); separator.margin_top = 5; separator.margin_bottom = 5; - this.menu.add(separator); + this.menu_container.pack_start(separator, false, true, 0); + } + + private Gtk.Button new_menu_element(string text, string? icon = null) { + Gtk.Button item; + if (icon == null) { + item = new Gtk.Button.with_label(_(text)); + } else { + item = new Gtk.Button(); + var tmpbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 2); + var tmplabel = new Gtk.Label(_(text)); + var tmpicon = new Gtk.Image.from_resource(icon); + tmpbox.pack_start(tmpicon, false, true); + tmpbox.pack_start(tmplabel, false, true); + item.add(tmpbox); + } + item.relief = Gtk.ReliefStyle.NONE; + this.menu_container.pack_start(item, false, true, 0); + return item; + } + + private void create_menu() { + + this.menu_container = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); + this.item_copy = this.new_menu_element("Copy"); + this.item_copy.clicked.connect(() => { + this.do_copy(); + this.menuPopover.hide(); + }); + + var item = this.new_menu_element("Paste"); + item.clicked.connect(() => { + this.do_paste(); + this.menuPopover.hide(); + }); + + this.add_separator(); + + item = this.new_menu_element("Split horizontally", "/com/rastersoft/terminus/pixmaps/horizontal.svg"); + item.clicked.connect(() => { + this.split_horizontal(this); + this.menuPopover.hide(); + }); + item = this.new_menu_element("Split vertically", "/com/rastersoft/terminus/pixmaps/vertical.svg"); + item.clicked.connect(() => { + this.split_vertical(this); + this.menuPopover.hide(); + }); + + item = this.new_menu_element("New tab"); + item.clicked.connect(() => { + this.main_container.new_terminal_tab(); + this.menuPopover.hide(); + }); + + item = this.new_menu_element("New window"); + item.clicked.connect(() => { + this.main_container.new_terminal_window(); + this.menuPopover.hide(); + }); + + this.add_separator(); + + item = this.new_menu_element("Preferences"); + item.clicked.connect(() => { + this.menuPopover.hide(); + Terminus.main_root.window_properties.show_all(); + Terminus.main_root.window_properties.present(); + }); + + this.add_separator(); + + item = this.new_menu_element("Close"); + item.clicked.connect(() => { + this.menuPopover.hide(); + Posix.kill(this.pid, 9); + }); + this.menuPopover = new Gtk.Popover(this.title); + this.menuPopover.add(menu_container); } public void do_grab_focus() { @@ -101,6 +184,11 @@ this.title = new Gtk.Label(""); this.titlebox = new Gtk.EventBox(); + this.titlebox.draw.connect((cr) => { + cr.set_source_rgb(this.title_r, this.title_g, this.title_b); + cr.paint(); + return false; + }); // a titlebox to have access to the background color this.titlebox.add(this.title); @@ -126,8 +214,6 @@ this.vte_terminal = new Vte.Terminal(); - // by default, UTF-8 - this.vte_terminal.set_encoding(null); this.vte_terminal.window_title_changed.connect_after(() => { this.update_title(); @@ -176,76 +262,7 @@ this.ended(this); }); - this.menu = new Gtk.Menu(); - this.item_copy = new Gtk.MenuItem.with_label(_("Copy")); - this.item_copy.activate.connect(() => { - this.do_copy(); - }); - this.menu.add(this.item_copy); - - var item = new Gtk.MenuItem.with_label(_("Paste")); - item.activate.connect(() => { - this.do_paste(); - }); - this.menu.add(item); - - this.add_separator(); - - item = new Gtk.MenuItem(); - var tmpbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 2); - var tmplabel = new Gtk.Label(_("Split horizontally")); - var tmpicon = new Gtk.Image.from_resource("/com/rastersoft/terminus/pixmaps/horizontal.svg"); - tmpbox.pack_start(tmpicon, false, true); - tmpbox.pack_start(tmplabel, false, true); - item.add(tmpbox); - item.activate.connect(() => { - this.split_horizontal(this); - }); - this.menu.add(item); - - item = new Gtk.MenuItem(); - tmpbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 2); - tmplabel = new Gtk.Label(_("Split vertically")); - tmpicon = new Gtk.Image.from_resource("/com/rastersoft/terminus/pixmaps/vertical.svg"); - tmpbox.pack_start(tmpicon, false, true); - tmpbox.pack_start(tmplabel, false, true); - item.add(tmpbox); - item.activate.connect(() => { - this.split_vertical(this); - }); - this.menu.add(item); - - item = new Gtk.MenuItem.with_label(_("New tab")); - item.activate.connect(() => { - this.main_container.new_terminal_tab(); - }); - this.menu.add(item); - - item = new Gtk.MenuItem.with_label(_("New window")); - item.activate.connect(() => { - this.main_container.new_terminal_window(); - }); - this.menu.add(item); - - this.add_separator(); - - item = new Gtk.MenuItem.with_label(_("Preferences")); - item.activate.connect(() => { - Terminus.main_root.window_properties.show_all(); - Terminus.main_root.window_properties.present(); - }); - this.menu.add(item); - - this.add_separator(); - - item = new Gtk.MenuItem.with_label(_("Close")); - item.activate.connect(() => { - Posix.kill(this.pid, 9); - }); - this.menu.add(item); - this.menu.show_all(); - - this.show_all(); + this.create_menu(); this.vte_terminal.button_press_event.connect(this.button_event); this.vte_terminal.events = Gdk.EventMask.BUTTON_PRESS_MASK; @@ -288,6 +305,8 @@ settings_changed("terminal-bell"); settings_changed("allow-bold"); settings_changed("rewrap-on-resize"); + + this.show_all(); } public bool update_title_cb() { @@ -327,32 +346,32 @@ case "copy": this.copy.keyval = keyval; - this.copy.state = state; + this.copy.state = state; break; case "paste": this.paste.keyval = keyval; - this.paste.state = state; + this.paste.state = state; break; case "terminal-left": this.terminal_left.keyval = keyval; - this.terminal_left.state = state; + this.terminal_left.state = state; break; case "terminal-right": this.terminal_right.keyval = keyval; - this.terminal_right.state = state; + this.terminal_right.state = state; break; case "terminal-up": this.terminal_up.keyval = keyval; - this.terminal_up.state = state; + this.terminal_up.state = state; break; case "terminal-down": this.terminal_down.keyval = keyval; - this.terminal_down.state = state; + this.terminal_down.state = state; break; default: @@ -401,9 +420,9 @@ this.vte_terminal.audible_bell = Terminus.settings.get_boolean(key); break; - case "rewrap-on-resize": + /*case "rewrap-on-resize": this.vte_terminal.rewrap_on_resize = Terminus.settings.get_boolean(key); - break; + break;*/ case "allow-bold": this.vte_terminal.allow_bold = Terminus.settings.get_boolean(key); @@ -518,22 +537,22 @@ } if ((eventkey.keyval == this.terminal_up.keyval) && (eventkey.state == this.terminal_up.state)) { - this.container.move_focus(Terminus.MoveFocus.UP, null, true); + this.container.move_terminal_focus(Terminus.MoveFocus.UP, null, true); return true; } if ((eventkey.keyval == this.terminal_down.keyval) && (eventkey.state == this.terminal_down.state)) { - this.container.move_focus(Terminus.MoveFocus.DOWN, null, true); + this.container.move_terminal_focus(Terminus.MoveFocus.DOWN, null, true); return true; } if ((eventkey.keyval == this.terminal_left.keyval) && (eventkey.state == this.terminal_left.state)) { - this.container.move_focus(Terminus.MoveFocus.LEFT, null, true); + this.container.move_terminal_focus(Terminus.MoveFocus.LEFT, null, true); return true; } if ((eventkey.keyval == this.terminal_right.keyval) && (eventkey.state == this.terminal_right.state)) { - this.container.move_focus(Terminus.MoveFocus.RIGHT, null, true); + this.container.move_terminal_focus(Terminus.MoveFocus.RIGHT, null, true); return true; } @@ -553,37 +572,30 @@ } this.top_container.set_tab_title(s_title); - var bgcolor = Gdk.RGBA(); string fg; string bg; if (this.vte_terminal.has_focus) { - bgcolor.red = 1.0; - bgcolor.green = 0.0; - bgcolor.blue = 0.0; - bgcolor.alpha = 1.0; + this.title_r = 1.0; + this.title_g = 0.0; + this.title_b = 0.0; fg = "#FFFFFF"; bg = "#FF0000"; } else { - bgcolor.red = 0.6666666; - bgcolor.green = 0.6666666; - bgcolor.blue = 0.6666666; - bgcolor.alpha = 1.0; + this.title_r = 0.6666666; + this.title_g = 0.6666666; + this.title_b = 0.6666666; fg = "#000000"; bg = "#AAAAAA"; } this.title.use_markup = true; this.title.label = "<span foreground=\"%s\" background=\"%s\" size=\"small\">%s %ldx%ld</span>".printf(fg, bg, s_title, this.vte_terminal.get_column_count(), this.vte_terminal.get_row_count()); - this.titlebox.override_background_color(Gtk.StateFlags.NORMAL, bgcolor); + this.titlebox.queue_draw(); } public bool button_event(Gdk.EventButton event) { if (event.button == 3) { this.item_copy.sensitive = this.vte_terminal.get_has_selection(); -#if GTK_3_20 - this.menu.popup(null, null, null, 3, Gtk.get_current_event_time()); -#else - this.menu.popup_at_pointer(event); -#endif + this.menuPopover.show_all(); return true; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/terminus.vala new/terminus-1.7.0/src/terminus.vala --- old/terminus-1.5.0/src/terminus.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/terminus.vala 2019-10-11 00:15:05.000000000 +0200 @@ -14,12 +14,13 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ using Gtk; using Gee; -//project version = 1.5.0 +//project version = 1.7.0 namespace Terminus { TerminusRoot main_root; @@ -206,7 +207,7 @@ private Terminus.Window ? guake_window; private bool ready; private int extcall; - private bool guake_has_focus; + private string ? guake_title; private bool tmp_launch_terminal; private bool tmp_launch_guake; @@ -221,7 +222,7 @@ main_root = this; this.guake_terminal = null; this.guake_window = null; - this.guake_has_focus = false; + this.guake_title = null; bool binded_key = Terminus.bindkey.set_bindkey(Terminus.keybind_settings.get_string("guake-mode")); @@ -229,6 +230,7 @@ this.launch_guake = parameters.launch_guake; this.check_guake = parameters.check_guake; + this.guake_title = parameters.UUID; this.tmp_launch_terminal = true; this.tmp_launch_guake = false; @@ -278,6 +280,10 @@ show_hide_global(this.extcall); } }, () => { + // if we are checking to launch guake, and there is already a process, return an error + if (this.check_guake) { + Posix.exit(1); + } // if there is another Terminus process, ask it to open a new window and exit RemoteControlInterface server = Bus.get_proxy_sync(BusType.SESSION, "com.rastersoft.terminus", "/com/rastersoft/terminus"); if (this.tmp_launch_terminal) { @@ -336,16 +342,6 @@ Terminus.bindkey.show_guake.connect(this.show_hide); } - public bool focus_in(Gdk.EventFocus event) { - this.guake_has_focus = true; - return false; - } - - public bool focus_out(Gdk.EventFocus event) { - this.guake_has_focus = false; - return false; - } - public int create_window(bool guake_mode) { Terminus.Window window; @@ -353,11 +349,9 @@ if (this.guake_terminal == null) { this.guake_terminal = new Terminus.Base(); } - window = new Terminus.Window(true, tid_counter, this.guake_terminal); + window = new Terminus.Window(true, tid_counter, this.guake_terminal, this.guake_title); this.guake_window = window; Terminus.bindkey.show_guake.connect(this.show_hide); - this.guake_window.focus_in_event.connect(this.focus_in); - this.guake_window.focus_out_event.connect(this.focus_out); } else { window = new Terminus.Window(false, tid_counter); } @@ -421,12 +415,7 @@ // mode 2 if (this.guake_window.visible) { - if ((check_wayland() != 0) && (!this.guake_has_focus)) { - this.guake_window.hide(); - this.guake_window.show(); - } else { - this.guake_window.hide(); - } + this.guake_window.hide(); } else { this.guake_window.present(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/src/window.vala new/terminus-1.7.0/src/window.vala --- old/terminus-1.5.0/src/window.vala 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/src/window.vala 2019-10-11 00:15:05.000000000 +0200 @@ -48,23 +48,14 @@ private Terminus.Base terminal; private int initialized; - private int get_monitor_width() { -#if GTK_3_20 - return this.get_screen().get_width(); -#else - return this.get_display().get_monitor_at_window(this.get_window().get_effective_toplevel()).get_geometry().width; -#endif - } - - private int get_monitor_height() { -#if GTK_3_20 - return this.get_screen().get_height(); -#else - return this.get_display().get_monitor_at_window(this.get_window().get_effective_toplevel()).get_geometry().height; -#endif + private Gdk.Rectangle get_monitor_workarea() { + var display = Gdk.Display.get_default(); + var monitor = display.get_primary_monitor(); + var workarea = monitor.get_workarea(); + return workarea; } - public Window(bool guake_mode, int id, Terminus.Base ? terminal = null) { + public Window(bool guake_mode, int id, Terminus.Base ? terminal = null, string ? window_title = null) { this.terminal_id = id; this.is_guake = guake_mode; this.initialized = 0; @@ -95,15 +86,17 @@ }); if (guake_mode) { + if (window_title != null) { + this.title = window_title; + } this.set_properties(); this.current_size = Terminus.settings.get_int("guake-height"); - if (this.current_size < 0) { - this.current_size = this.get_monitor_height() * 3 / 7; + if ((this.current_size <= 0) && (check_wayland() == 0)) { + this.current_size = this.get_monitor_workarea().height * 3 / 7; Terminus.settings.set_int("guake-height", this.current_size); } - - this.map.connect(this.mapped); + this.map.connect_after(this.mapped); this.realize.connect_after(() => { this.set_size(); }); @@ -120,7 +113,6 @@ this.add(this.paned); this.paned.add1(this.terminal); this.fixed = new Terminus.Fixed(); - //this.fixed.set_size_request(1,1); this.paned.add2(fixed); this.mouseY = -1; @@ -140,7 +132,13 @@ int newval = y - this.mouseY; this.current_size += newval; this.mouseY = y; - this.resize(this.get_monitor_width(), this.current_size); + if (check_wayland() == 0) { + this.resize(this.get_monitor_workarea().width, this.current_size); + } else { + int width, height; + this.get_size(out width, out height); + this.resize(width, this.current_size); + } this.paned.set_position(this.current_size); return true; }); @@ -184,17 +182,27 @@ } private void set_properties() { - this.stick(); - this.set_keep_above(true); - this.set_skip_taskbar_hint(true); - this.set_skip_pager_hint(true); + if (check_wayland() == 0) { + this.stick(); + this.set_keep_above(true); + this.set_skip_taskbar_hint(true); + this.set_skip_pager_hint(true); + } this.set_decorated(false); } private void set_size() { - this.move(0, 0); - this.paned.set_position(this.current_size); - this.resize(this.get_monitor_width(), this.current_size); + if (check_wayland() == 0) { + var workarea = this.get_monitor_workarea(); + this.move(workarea.x, workarea.y); + this.paned.set_position(this.current_size); + this.resize(workarea.width, this.current_size); + } else { + int width, height; + this.get_size(out width, out height); + this.resize(width, this.current_size); + this.paned.set_position(this.current_size); + } } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/terminus.avprj new/terminus-1.7.0/terminus.avprj --- old/terminus-1.5.0/terminus.avprj 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/terminus.avprj 2019-10-11 00:15:05.000000000 +0200 @@ -6,14 +6,12 @@ custom: terminus_gnome_shell/extension.js share/gnome-shell/extensions/[email protected] custom: terminus_gnome_shell/metadata.json share/gnome-shell/extensions/[email protected] -*define: GTK_3_20 - *gresource: extras_gresource_xml data/extras.gresource.xml *vapidir: src/vapidir vala_binary: src/terminus -*version: 1.5.0 +*version: 1.7.0 use_gresource: extras_gresource_xml vala_vapi: checkwayland.vapi *vala_package: posix @@ -21,9 +19,11 @@ vala_check_package: gtk+-3.0 *vala_check_package: gee-0.8 *vala_check_package: gio-2.0 +*vala_check_package: gio-unix-2.0 *vala_check_package: glib-2.0 *vala_check_package: gobject-2.0 *vala_check_package: keybinder-3.0 +*vala_check_package: pango *vala_check_package: vte-2.91 *vala_source: PanedPercentage.vala *vala_source: base.vala diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terminus-1.5.0/terminus_gnome_shell/extension.js new/terminus-1.7.0/terminus_gnome_shell/extension.js --- old/terminus-1.5.0/terminus_gnome_shell/extension.js 2019-05-06 21:30:31.000000000 +0200 +++ new/terminus-1.7.0/terminus_gnome_shell/extension.js 2019-10-11 00:15:05.000000000 +0200 @@ -1,77 +1,262 @@ +/* + * Copyright 2016-2019 (C) Raster Software Vigo (Sergio Costas) + * + * This file is part of Terminus + * + * Terminus is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Terminus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ -const Main = imports.ui.main; +const GLib = imports.gi.GLib; const Shell = imports.gi.Shell; const Meta = imports.gi.Meta; const Gio = imports.gi.Gio; -const Lang = imports.lang; -const ExtensionUtils = imports.misc.extensionUtils; +const Main = imports.ui.main; +const Mainloop = imports.mainloop; const MyIface = '<node>\ -<interface name="com.rastersoft.terminus">\ - <method name="SwapGuake" />\ - <method name="DisableKeybind" />\ - <method name="DoPing" >\ - <arg name="n" direction="in" type="i"/>\ - <arg name="response" direction="out" type="i"/>\ - </method>\ -</interface>\ + <interface name="com.rastersoft.terminus">\ + <method name="SwapGuake" />\ + <method name="DisableKeybind" />\ + <method name="DoPing" >\ + <arg name="n" direction="in" type="i"/>\ + <arg name="response" direction="out" type="i"/>\ + </method>\ + </interface>\ </node>'; const MyProxy = Gio.DBusProxy.makeProxyWrapper(MyIface); const GioSSS = Gio.SettingsSchemaSource; -const TerminusClass = new Lang.Class({ - Name: 'Terminus.Launcher', +let terminusObject; + +class TerminusClass { + + constructor() { + this._settings = new Gio.Settings({ schema: 'org.rastersoft.terminus.keybindings' }); + this._settings2 = new Gio.Settings({ schema: 'org.rastersoft.terminus' }); + this._settingsChanged(null, "guake-mode"); // copy the guake-mode key to guake-mode-gnome-shell key + this.terminusInstance = null; + this._shown_error = false; + this._launch_process(); + } + + _launch_process() { + let argv = []; + argv.push("terminus"); + argv.push("--check_guake_wayland"); + this._currentProcess = new LaunchSubprocess(0, "TERMINUS", "--uuid"); + this._currentProcess.spawnv(argv); + this._currentProcess.subprocess.wait_async(null, () => { + this._reloadTime = 100; + if (this._currentProcess.subprocess.get_if_exited()) { + let retVal = this._currentProcess.subprocess.get_exit_status(); + if (retVal == 1) { + Main.notify("Can't launch Terminus", "There is already an instance of Terminus running. You must kill all of them to allow Terminus guake mode to work."); + this._shown_error = true; + this._reloadTime = 1000; + } else { + this._shown_error = false; + } + } else { + this._shown_error = false; + } + this._desktopWindow = null; + this._currentProcess = null; + if (this._launchDesktopId) { + GLib.source_remove(this._launchDesktopId); + } + this._launchProcessId = Mainloop.timeout_add(this._reloadTime, () => { + this._launchProcessId = 0; + this._launch_process(); + }); + }); + } - _init: function() { + enable() { + this._settingsChangedConnect = this._settings.connect('changed', (st, name) => { + this._settingsChanged(name); + }); + let mode = Shell.ActionMode ? Shell.ActionMode.NORMAL : Shell.KeyBindingMode.ALL; + let flags = Meta.KeyBindingFlags.NONE; + Main.wm.addKeybinding( + "guake-mode-gnome-shell", + this._settings, + flags, + mode, + () => { + if (this.terminusInstance === null) { + this.terminusInstance = new MyProxy(Gio.DBus.session, 'com.rastersoft.terminus', '/com/rastersoft/terminus'); + } + this.terminusInstance.DisableKeybindRemote((result, error) => { + this.terminusInstance.SwapGuakeSync(); + }); + } + ); + this._idMap = global.window_manager.connect_after('map', (obj, windowActor) => { + if (!this._currentProcess) { + return false; + } + let window = windowActor.get_meta_window(); + let belongs; + try { + belongs = this._currentProcess.query_window_belongs_to(window); + } catch (err) { + belongs = false; + } + if (belongs) { + // This is the Guake Terminal window, so ensure that it is kept above and shown in all workspaces + window.make_above(); + window.stick(); + let ws = global.workspace_manager.get_workspace_by_index(0); + let area = ws.get_work_area_for_monitor(0); + let height = this._settings2.get_int('guake-height'); + if (height <= 0) { + height = int(area.height() * 3 / 7); + this._settings2.set_int('guake-height'); + } + if (height >= area.height) { + height = int(area.height() * 5 / 7); + this._settings2.set_int('guake-height'); + } + window.move_resize_frame(false, area.x, area.y, area.width, this._settings2.get_int('guake-height')); + } + }); + } - this._settings = new Gio.Settings({schema: 'org.rastersoft.terminus.keybindings'}); - this._settingsChanged(null,"guake-mode"); // copy the guake-mode key to guake-mode-gnome-shell key - this._settingsChangedConnect = this._settings.connect('changed',Lang.bind(this,this._settingsChanged)); - - let mode = Shell.ActionMode ? Shell.ActionMode.NORMAL : Shell.KeyBindingMode.ALL; - let flags = Meta.KeyBindingFlags.NONE; - this.instance = null; - Main.wm.addKeybinding("guake-mode-gnome-shell", - this._settings, - flags, - mode, - Lang.bind(this, this.launch_function) - ); - }, - - destroy: function() { - Main.wm.removeKeybinding("guake-mode"); - }, - - launch_function: function() { - if (this.instance === null) { - this.instance = new MyProxy(Gio.DBus.session, 'com.rastersoft.terminus','/com/rastersoft/terminus'); - } - this.instance.DisableKeybindRemote(Lang.bind(this, function (result, error) { - this.instance.SwapGuakeSync(); - })); - }, + disable() { + if (this._settingsChangedConnect) { + this._settings.disconnect(this._settingsChangedConnect); + } + if (this._idMap) { + global.window_manager.disconnect(this._idMap); + } + Main.wm.removeKeybinding("guake-mode-gnome-shell"); + } - _settingsChanged: function(st,name) { - if (name == "guake-mode") { + _settingsChanged(name) { + if (name == "guake-mode") { var new_key = this._settings.get_string("guake-mode"); - this._settings.set_strv("guake-mode-gnome-shell",new Array(new_key)); + this._settings.set_strv("guake-mode-gnome-shell", new Array(new_key)); } } -}); +} function init() { - + // delegate everything to the main program when running under X11 + if (Meta.is_wayland_compositor()) + terminusObject = new TerminusClass(); } -let terminusObject; - function enable() { - terminusObject = new TerminusClass(); + if (Meta.is_wayland_compositor()) + terminusObject.enable(); } function disable() { + if (Meta.is_wayland_compositor()) { + terminusObject.disable(); + } +} + +/** + * This class encapsulates the code to launch a subprocess that can detect whether a window belongs to it + * It only accepts to do it under Wayland, because under X11 there is no need to do these tricks + * + * It is compatible with https://gitlab.gnome.org/GNOME/mutter/merge_requests/754 to simplify the code + * + * @param {int} flags Flags for the SubprocessLauncher class + * @param {string} process_id An string id for the debug output + * @param {string} cmd_parameter A command line parameter to pass when running. It will be passed only under Wayland, + * so, if this parameter isn't passed, the app can assume that it is running under X11. + */ +var LaunchSubprocess = class { + + constructor(flags, process_id, cmd_parameter) { + this._process_id = process_id; + this._cmd_parameter = cmd_parameter; + this._UUID = null; + this._flags = flags | Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE; + if (Meta.is_wayland_compositor()) { + this._flags |= Gio.SubprocessFlags.STDIN_PIPE; + } + this._launcher = new Gio.SubprocessLauncher({ flags: this._flags }); + this.subprocess = null; + this.process_running = false; + } + spawnv(argv) { + let UUID_string = null; + if (Meta.is_wayland_compositor()) { + /* + * Generate a random UUID to allow the extension to identify the window. It must be random + * to avoid other programs to cheat and pose themselves as the true process. This also means that + * launching the program from the command line won't give "superpowers" to it, + * but will work like any other program. Of course, under X11 it doesn't matter, but it does + * under Wayland. + */ + this._UUID = GLib.uuid_string_random(); + UUID_string = this._UUID + '\n'; + argv.push(this._cmd_parameter); + } + this.subprocess = this._launcher.spawnv(argv); + if (this.subprocess) { + /* + * Send the UUID to the application using STDIN as a "secure channel". Sending it as a parameter + * would be insecure, because another program could read it and create a window before our process, + * and cheat the extension. This is done only in Wayland, because under X11 there is no need for it. + * + * It also reads STDOUT and STDERR and sends it to the journal using global.log(). This allows to + * have any error from the desktop app in the same journal than other extensions. Every line from + * the desktop program is prepended with the "process_id" parameter sent in the constructor. + */ + this.subprocess.communicate_utf8_async(UUID_string, null, (object, res) => { + try { + let [d, stdout, stderr] = object.communicate_utf8_finish(res); + if (stdout.length != 0) { + global.log(`${this._process_id}: ${stdout}`); + } + } catch (e) { + global.log(`${this._process_id}_Error: ${e}`); + } + }); + this.subprocess.wait_async(null, () => { + this.process_running = false; + }); + this.process_running = true; + } + return this.subprocess; + } + + set_cwd(cwd) { + this._launcher.set_cwd(cwd); + } + + /** + * Queries whether the passed window belongs to the launched subprocess or not. + * @param {MetaWindow} window The window to check. + */ + query_window_belongs_to(window) { + if (!Meta.is_wayland_compositor()) { + throw new Error("Not in wayland"); + } + if (this._UUID == null) { + throw new Error("No process running"); + } + if (!this.process_running) { + throw new Error("No process running"); + } + return (window.get_title() == this._UUID); + } }
