Add method to determine window manager

This commit is contained in:
Philipp Hörist 2019-03-25 20:01:01 +01:00
parent f6e113c0b6
commit 4acf36c97b
2 changed files with 23 additions and 0 deletions

View File

@ -39,12 +39,14 @@ from distutils.version import LooseVersion as V
from collections import namedtuple
import nbxmpp
from gi.repository import Gdk
import gajim
from gajim.common import config as c_config
from gajim.common import configpaths
from gajim.common import ged as ged_module
from gajim.common.i18n import LANG
from gajim.common.const import Display
from gajim.common.contacts import LegacyContactsAPI
from gajim.common.events import Events
from gajim.common.types import NetworkEventsControllerT # pylint: disable=unused-import
@ -212,6 +214,18 @@ def is_installed(dependency):
def is_flatpak():
return gajim.IS_FLATPAK
def is_display(display):
# XWayland reports as Display X11, so try with env var
is_wayland = os.environ.get('XDG_SESSION_TYPE') == 'wayland'
if is_wayland and display == Display.WAYLAND:
return True
default = Gdk.Display.get_default()
if default is None:
log('gajim').warning('Could not determine window manager')
return False
return default.__class__.__name__ == display.value
def disable_dependency(dependency):
_dependencies[dependency] = False

View File

@ -199,6 +199,7 @@ class MUCUser(IntEnum):
AFFILIATION = 3
AFFILIATION_TEXT = 4
@unique
class Trust(IntEnum):
UNTRUSTED = 0
@ -206,6 +207,14 @@ class Trust(IntEnum):
BLIND = 2
VERIFIED = 3
class Display(Enum):
X11 = 'X11Display'
WAYLAND = 'GdkWaylandDisplay'
WIN32 = 'GdkWin32Display'
QUARTZ = 'GdkQuartzDisplay'
EME_MESSAGES = {
'urn:xmpp:otr:0':
_('This message was encrypted with OTR '