Opened 3 years ago

Closed 3 years ago

#2493 closed bug (Fixed)

Add Torrent dialog does not display when screen does not have an active workspace.

Reported by: namtabmai Owned by:
Priority: minor Milestone: 1.3.8
Component: GTK UI Version: 1.3.7
Keywords: Cc:

Description

Setup.

  • Multi-monitor setup - 3 monitors
  • WM - i3
  • Firefox on 1st workspace of 1 screen
  • Deluge-gtk 1.3.7 on 6th workspace of 2 screen.
  • Firefox has been configured to use Deluge-gtk for magnet links.

Tests

  • With deluge-gtk being on the active, visible first workspace on the second monitor. Clicking on Add Torrent button the "Add Torrent" dialog appears.
  • With deluge-gtk being on the inactive, visible first workspace on the second monitor. Clicking on magnet links in the Firefox on the first screen works. Deluge becomes active and the "Add Torrent" dialog appears.
  • With deluge-gtk being on the inactive, visible second workspace on the second monitor. Clicking on magnet links in the Firefox on the first screen does not work, no "Add Torrent" dialog appears. The workspace icon flashes to show that deluge-gtk has activated but the workspace isn't automatically switched to and on manually switching to it there is no dialog present.

Trackback

  File "/usr/lib/python2.7/site-packages/twisted/protocols/policies.py", line 120, in dataReceived
    self.wrappedProtocol.dataReceived(data)
  File "/usr/lib/python2.7/site-packages/deluge/ui/client.py", line 179, in dataReceived
    d.callback(request[2])
  File "/usr/lib/python2.7/site-packages/twisted/internet/defer.py", line 382, in callback
    self._startRunCallbacks(result)
  File "/usr/lib/python2.7/site-packages/twisted/internet/defer.py", line 490, in _startRunCallbacks
    self._runCallbacks()
--- <exception caught here> ---
  File "/usr/lib/python2.7/site-packages/twisted/internet/defer.py", line 577, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python2.7/site-packages/deluge/ui/gtkui/addtorrentdialog.py", line 199, in _on_config_values
    self._show(focus)
  File "/usr/lib/python2.7/site-packages/deluge/ui/gtkui/addtorrentdialog.py", line 172, in _show
    if component.get("MainWindow").is_on_active_workspace():
  File "/usr/lib/python2.7/site-packages/deluge/ui/gtkui/mainwindow.py", line 315, in is_on_active_workspace
    return win.is_on_workspace(win.get_screen().get_active_workspace())
exceptions.TypeError: Wnck.Window.is_on_workspace() argument 1 must be wnck.Workspace, not None

Appears to be an assuming that a screen always has an active workspace, which in the case of multiple monitors might not always be true.

I changed check at the end of mainwindow.py to be

if win.get_screen().get_active_workspace() is not None:
    return win.is_on_workspace(win.get_screen().get_active_workspace())
else:
    return False

which fixes the issue.

Not entirely sure of the required behaviour here, perhaps deluge-gtk should be activating the workspace on that monitor, but WnckScreen? doesn't appear to have a set_active_workspace function or anything approaching that.

Change History (3)

comment:1 Changed 3 years ago by Cas

  • Milestone changed from Future to 1.3.8

Thanks for catching this, I missed in the docs that get_active_workspace might return None.

My second monitor broke so I don't currently have a multi-monitor setup to test this with, so some help in determining the best fix would be great. What would you expect to happen if it can't get the active_workspace? Based on the original ticket for this code, #2260, does returning False still satisfy those cases?

Also you could test this modified fix that gets rid of the for loop:

-        for win in self.screen.get_windows():
-            if win.get_xid() == self.window.window.xid:
-                return win.is_on_workspace(win.get_screen().get_active_workspace())
+        win = wnck.window_get(self.window.window.xid)
+        active_wksp = win.get_screen().get_active_workspace()
+        if active_wksp:
+            return win.is_on_workspace(active_wksp)
+        else:
+            return False

comment:2 Changed 3 years ago by namtabmai

I gave that change a try and works well in all cases I mentioned in the original report.

As for the cases mentioned in #2260 neither of the two cases happen, if I had to pick a preference it would be for the first

Unity automatically switches to workspace 2, and show the "Download" dialog. The Deluge window stays in workspace 2.

as I'd rather not have applications moving workspaces without my explicit intention.

What would you expect to happen if it can't get the active_workspace?

Personally I'm not a fan of applications taking focus, so I'd prefer that if deluge isn't on an active workspace I would expect it to open the dialog on the same workspace as deluge-gtk, but not try and switch workspaces. My WM will notify me that the application requires attention.

comment:3 Changed 3 years ago by Cas

  • Resolution set to Fixed
  • Status changed from new to closed

Thanks, the point of the function is to stop the Add Dialog pulling the main Deluge window to another workspace so it is working as expected.

Fixed in 1.3-stable: [4e77c46694]

Note: See TracTickets for help on using tickets.