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 23c08892a0
commit 2f5d00d1f3
3 changed files with 24 additions and 20 deletions

View File

@ -51,11 +51,13 @@ import nbxmpp
from nbxmpp.stringprepare import nameprep from nbxmpp.stringprepare import nameprep
import precis_i18n.codec # pylint: disable=unused-import import precis_i18n.codec # pylint: disable=unused-import
from gajim.common import app
from gajim.common import caps_cache from gajim.common import caps_cache
from gajim.common import configpaths from gajim.common import configpaths
from gajim.common.i18n import Q_ from gajim.common.i18n import Q_
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.i18n import ngettext from gajim.common.i18n import ngettext
from gajim.common.const import Display
log = logging.getLogger('gajim.c.helpers') log = logging.getLogger('gajim.c.helpers')
@ -1534,3 +1536,14 @@ class AdditionalDataDict(collections.UserDict):
del _dict[key] del _dict[key]
except KeyError: except KeyError:
return 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

@ -59,6 +59,7 @@ from gajim.common import helpers
from gajim.common import idle from gajim.common import idle
from gajim.common.exceptions import GajimGeneralException from gajim.common.exceptions import GajimGeneralException
from gajim.common import i18n from gajim.common import i18n
from gajim.common.helpers import save_roster_position
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.const import PEPEventType, AvatarSize, StyleAttr from gajim.common.const import PEPEventType, AvatarSize, StyleAttr
from gajim.common.dbus import location from gajim.common.dbus import location
@ -2407,11 +2408,7 @@ class RosterWindow:
if not app.config.get('quit_on_roster_x_button') and ( if not app.config.get('quit_on_roster_x_button') and (
(app.interface.systray_enabled and app.config.get('trayicon') != \ (app.interface.systray_enabled and app.config.get('trayicon') != \
'on_event') or app.config.get('allow_hide_roster')): 'on_event') or app.config.get('allow_hide_roster')):
if app.config.get('save-roster-position'): save_roster_position(self.window)
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)
if os.name == 'nt' or app.config.get('hide_on_roster_x_button'): if os.name == 'nt' or app.config.get('hide_on_roster_x_button'):
self.window.hide() self.window.hide()
else: else:
@ -2436,11 +2433,7 @@ class RosterWindow:
# in case show_roster_on_start is False and roster is never shown # in case show_roster_on_start is False and roster is never shown
# window.window is None # window.window is None
if self.window.get_window() is not None: if self.window.get_window() is not None:
if app.config.get('save-roster-position'): save_roster_position(self.window)
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)
width, height = self.window.get_size() width, height = self.window.get_size()
app.config.set('roster_width', width) app.config.set('roster_width', width)
app.config.set('roster_height', height) app.config.set('roster_height', height)

View File

@ -30,6 +30,8 @@ from gajim import gtkgui_helpers
from gajim.common import app from gajim.common import app
from gajim.common import helpers from gajim.common import helpers
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.helpers import save_roster_position
from gajim.gtk.single_message import SingleMessageWindow from gajim.gtk.single_message import SingleMessageWindow
@ -371,18 +373,14 @@ class StatusIcon:
# No pending events, so toggle visible/hidden for roster window # No pending events, so toggle visible/hidden for roster window
if win.get_property('visible'): if win.get_property('visible'):
if win.get_property('has-toplevel-focus') or os.name == 'nt': if win.get_property('has-toplevel-focus') or os.name == 'nt':
if app.config.get('save-roster-position'): save_roster_position(win)
x, y = win.get_position()
app.config.set('roster_x-position', x)
app.config.set('roster_y-position', y)
win.hide() # else we hide it from VD that was visible in win.hide() # else we hide it from VD that was visible in
else: else:
if not win.get_property('visible'): win.show_all()
win.show_all() if app.config.get('save-roster-position'):
if app.config.get('save-roster-position'): gtkgui_helpers.move_window(win,
gtkgui_helpers.move_window(win, app.config.get('roster_x-position'),
app.config.get('roster_x-position'), app.config.get('roster_y-position'))
app.config.get('roster_y-position'))
if not app.config.get('roster_window_skip_taskbar'): if not app.config.get('roster_window_skip_taskbar'):
win.set_property('skip-taskbar-hint', False) win.set_property('skip-taskbar-hint', False)
win.present_with_time(Gtk.get_current_event_time()) win.present_with_time(Gtk.get_current_event_time())