Refactor saving roster position

- Dont save roster position on Wayland
This commit is contained in:
Philipp Hörist 2019-03-25 22:01:11 +01:00
parent b6e7f5c6d2
commit a9efde136b
3 changed files with 23 additions and 20 deletions

View File

@ -51,12 +51,14 @@ import nbxmpp
from nbxmpp.stringprepare import nameprep
import precis_i18n.codec # pylint: disable=unused-import
from gajim.common import app
from gajim.common import caps_cache
from gajim.common import configpaths
from gajim.common.i18n import Q_
from gajim.common.i18n import _
from gajim.common.i18n import ngettext
from gajim.common.const import ShowConstant
from gajim.common.const import Display
log = logging.getLogger('gajim.c.helpers')
@ -1508,3 +1510,14 @@ class AdditionalDataDict(collections.UserDict):
del _dict[key]
except KeyError:
return
def save_roster_position(window):
if not app.config.get('save-roster-position'):
return
if app.is_display(Display.WAYLAND):
return
x_pos, y_pos = window.get_position()
log.debug('Save roster position: %s %s', x_pos, y_pos)
app.config.set('roster_x-position', x_pos)
app.config.set('roster_y-position', y_pos)

View File

@ -28,6 +28,7 @@ from gajim import dialogs
from gajim.common import app
from gajim.common import helpers
from gajim.common.i18n import _
from gajim.common.helpers import save_roster_position
from gajim.gtk.util import get_builder
from gajim.gtk.util import get_icon_name
@ -375,13 +376,9 @@ class StatusIcon:
# No pending events, so toggle visible/hidden for roster window
if win.get_property('visible'):
if win.get_property('has-toplevel-focus') or os.name == 'nt':
if app.config.get('save-roster-position'):
x, y = win.get_position()
app.config.set('roster_x-position', x)
app.config.set('roster_y-position', y)
save_roster_position(win)
win.hide() # else we hide it from VD that was visible in
else:
if not win.get_property('visible'):
win.show_all()
if app.config.get('save-roster-position'):
move_window(win,

View File

@ -56,6 +56,7 @@ from gajim.common import helpers
from gajim.common import idle
from gajim.common.exceptions import GajimGeneralException
from gajim.common import i18n
from gajim.common.helpers import save_roster_position
from gajim.common.i18n import _
from gajim.common.const import PEPEventType, AvatarSize, StyleAttr
from gajim.common.dbus import location
@ -2365,11 +2366,7 @@ class RosterWindow:
if not app.config.get('quit_on_roster_x_button') and (
(app.interface.systray_enabled and app.config.get('trayicon') != \
'on_event') or app.config.get('allow_hide_roster')):
if app.config.get('save-roster-position'):
x, y = self.window.get_position()
log.debug('Save roster position (get_position): %s %s', x, y)
app.config.set('roster_x-position', x)
app.config.set('roster_y-position', y)
save_roster_position(self.window)
if os.name == 'nt' or app.config.get('hide_on_roster_x_button'):
self.window.hide()
else:
@ -2394,11 +2391,7 @@ class RosterWindow:
# in case show_roster_on_start is False and roster is never shown
# window.window is None
if self.window.get_window() is not None:
if app.config.get('save-roster-position'):
x, y = self.window.get_window().get_root_origin()
log.debug('Save roster position (get_root_origin): %s %s', x, y)
app.config.set('roster_x-position', x)
app.config.set('roster_y-position', y)
save_roster_position(self.window)
width, height = self.window.get_size()
app.config.set('roster_width', width)
app.config.set('roster_height', height)