diff --git a/guake/guake_app.py b/guake/guake_app.py index 5161240b..5b9480c5 100644 --- a/guake/guake_app.py +++ b/guake/guake_app.py @@ -68,6 +68,7 @@ from guake.settings import Settings from guake.simplegladeapp import SimpleGladeApp from guake.simplegladeapp import bindtextdomain from guake.terminal import GuakeTerminalBox +from guake.utils import get_server_time libutempter = None try: @@ -610,7 +611,7 @@ class Guake(SimpleGladeApp): value = self.settings.general.get_boolean('window-losefocus') visible = window.get_property('visible') if visible: - self.losefocus_time = GdkX11.x11_get_server_time(self.window.get_window()) + self.losefocus_time = get_server_time(self.window) if value: self.hide() @@ -862,16 +863,9 @@ class Guake(SimpleGladeApp): if not self.is_fullscreen: self.settings.general.triggerOnChangedValue(self.settings.general, 'window-height') - try: - # does it work in other gtk backends - # help(self.window.get_window()) - time = GdkX11.x11_get_server_time(self.window.get_window()) - except (TypeError, AttributeError): - # Issue: https://github.com/Guake/guake/issues/1071 - # Wayland does not seem to like `x11_get_server_time`. - # Quick and dirty fix like https://launchpadlibrarian.net/309178299/wayland_fix.diff - time = 0 - # TODO PORT this + time = get_server_time(self.window) + + # TODO PORT this # When minized, the window manager seems to refuse to resume # log.debug("self.window: %s. Dir=%s", type(self.window), dir(self.window)) # is_iconified = self.is_iconified() @@ -1984,10 +1978,7 @@ class Guake(SimpleGladeApp): search_query = quote_plus(search_query) if search_query: search_url = "https://www.google.com/#q={!s}&safe=off".format(search_query, ) - Gtk.show_uri( - self.window.get_screen(), search_url, - GdkX11.x11_get_server_time(self.window.get_window()) - ) + Gtk.show_uri(self.window.get_screen(), search_url, get_server_time(self.window)) return True def getCurrentTerminalLinkUnderCursor(self): diff --git a/guake/terminal.py b/guake/terminal.py index 1fd9eca8..ba766927 100644 --- a/guake/terminal.py +++ b/guake/terminal.py @@ -144,7 +144,7 @@ class Terminal(Vte.Terminal): elif TERMINAL_MATCH_TAGS[tag] == 'email': value = 'mailto:%s' % value - Gtk.show_uri(self.get_screen(), value, GdkX11.x11_get_server_time(self.get_window())) + Gtk.show_uri(self.get_screen(), value, get_server_time(self)) elif event.button == 3 and matched_string: self.matched_value = matched_string[0] diff --git a/guake/utils.py b/guake/utils.py new file mode 100644 index 00000000..50b68132 --- /dev/null +++ b/guake/utils.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8; -*- +""" +Copyright (C) 2007-2012 Lincoln de Sousa +Copyright (C) 2007 Gabriel Falcão + +This program 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 2 of the +License, or (at your option) any later version. + +This program 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, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301 USA +""" + +import gi +gi.require_version('Gtk', '3.0') + +from gi.repository import GdkX11 + + +def get_server_time(widget): + try: + return GdkX11.x11_get_server_time(widget.get_window()) + except (TypeError, AttributeError): + # Issue: https://github.com/Guake/guake/issues/1071 + # Wayland does not seem to like `x11_get_server_time`. + # Quick and dirty fix like https://launchpadlibrarian.net/309178299/wayland_fix.diff + return 0