diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py index fd78676a0..4c25f97be 100644 --- a/deluge/ui/gtk3/addtorrentdialog.py +++ b/deluge/ui/gtk3/addtorrentdialog.py @@ -155,14 +155,17 @@ class AddTorrentDialog(component.Component): self.update_core_config(True, focus) def _show(self, focus=False): - if component.get('MainWindow').is_on_active_workspace(): - self.dialog.set_transient_for(component.get('MainWindow').window) + main_window = component.get('MainWindow') + if main_window.is_on_active_workspace(): + self.dialog.set_transient_for(main_window.window) else: self.dialog.set_transient_for(None) + self.dialog.set_position(Gtk.WindowPosition.CENTER) self.dialog.present() if focus: - self.dialog.window.focus() + timestamp = main_window.get_timestamp() + self.dialog.get_window().set_user_time(timestamp) def hide(self): self.dialog.hide() diff --git a/deluge/ui/gtk3/files_tab.py b/deluge/ui/gtk3/files_tab.py index dc5d914da..6c9b5c7fd 100644 --- a/deluge/ui/gtk3/files_tab.py +++ b/deluge/ui/gtk3/files_tab.py @@ -321,7 +321,7 @@ class FilesTab(Tab): path = self.get_file_path(select).split('/') filepath = os.path.join(status['download_location'], *path) log.debug('Open file: %s', filepath) - timestamp = Gtk.get_current_event_time() + timestamp = component.get('MainWindow').get_timestamp() open_file(filepath, timestamp=timestamp) def _on_show_file(self, status): @@ -334,7 +334,7 @@ class FilesTab(Tab): path = self.get_file_path(select).split('/') filepath = os.path.join(status['download_location'], *path) log.debug('Show file: %s', filepath) - timestamp = Gtk.get_current_event_time() + timestamp = component.get('MainWindow').get_timestamp() show_file(filepath, timestamp=timestamp) # The following 3 methods create the folder/file view in the treeview diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py index 51292e052..8200d9535 100644 --- a/deluge/ui/gtk3/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -13,7 +13,7 @@ import logging import os.path from hashlib import sha1 as sha -from gi.repository import Gtk +from gi.repository import GdkX11, Gtk from gi.repository.Gdk import DragAction, WindowState from twisted.internet import reactor from twisted.internet.error import ReactorNotRunning @@ -173,6 +173,7 @@ class MainWindow(component.Component): # Restore the proper x,y coords for the window prior to showing it component.resume(self.child_components) self.window.present() + self.window.get_window().set_user_time(self.get_timestamp()) self.load_window_state() if self.config['lock_tray'] and not self.visible(): @@ -190,6 +191,14 @@ class MainWindow(component.Component): else: restore() + def get_timestamp(self): + """Returns the timestamp for the windowing server.""" + timestamp = 0 + gdk_window = self.window.get_window() + if isinstance(gdk_window, GdkX11.X11Window): + timestamp = GdkX11.x11_get_server_time(gdk_window) + return timestamp + def active(self): """Returns True if the window is active, False if not.""" return self.window.is_active() @@ -351,8 +360,6 @@ class MainWindow(component.Component): if Wnck: self.screen.force_update() - from gi.repository import GdkX11 # NOQA - win = Wnck.Window.get(self.window.get_window().get_xid()) if win: active_wksp = win.get_screen().get_active_workspace() diff --git a/deluge/ui/gtk3/menubar.py b/deluge/ui/gtk3/menubar.py index e98181bbf..e09f394fc 100644 --- a/deluge/ui/gtk3/menubar.py +++ b/deluge/ui/gtk3/menubar.py @@ -313,7 +313,7 @@ class MenuBar(component.Component): log.debug('on_menuitem_open_folder') def _on_torrent_status(status): - timestamp = Gtk.get_current_event_time() + timestamp = component.get('MainWindow').get_timestamp() path = os.path.join( status['download_location'], status['files'][0]['path'].split('/')[0] )