Dual Monitor: Fix Mouse Getting Stuck On Second Monitor In Gnome Shell With Ubuntu Dock Or Dash To Dock

I was experiencing a really annoying bug in Gnome Shell that I finally managed to "fix", and I thought I'd share it with you in case you're experiencing the same issue.

On my dual monitor setup, if I made any application fullscreen on the primary monitor (left-hand side screen - monitor "1" in the image above), the mouse cursor would get stuck on the secondary monitor (right-hand side screen) and I could only move it back to the primary monitor if I moved between monitors through the top part of the screen. 

The bug (which I reported already) continues to happen after exiting full-screen.

This occurs after making any window full-screen, be it an application, video, web video like YouTube, and so on, and it was driving me crazy so I investigated the issue and I finally found out what's causing this and how to avoid it. It looks like this bug is triggered by the following:
  • Multi-monitor setups (obviously)
  • Ubuntu Dock / Dash to Dock with the auto-hide option enabled
  • Ubuntu Dock / Dash to Dock set to show on all displays
  • Ubuntu Dock / Dash to Dock position set to left (this is the default setting)
  • No window covering the Ubuntu Dock / Dash to Dock on the second monitor (so dock is visible on the second monitor)

Ubuntu Dock Settings

I should also add that it probably works moving the mouse cursor between monitors though the top part of the screen because the Activities hot-corner interferes with the dock reveal on mouse hover feature.

I tested to see if this also occurs with Gnome Shell Dash to Dock extension, from which the Ubuntu Dock extension was forked, and it does, so the bug is caused by some upstream issue.

Gnome Shell with Ubuntu Dock or Dash to Dock extension: Fix mouse cursor stuck on second monitor in dual monitors setups

Until this is fixed, the solution is to change some of the Ubuntu Dock / Dash to Dock settings and the bug stops occurring.

For example, disabling the Ubuntu Dock auto-hide feature fixes this.

Setting the dock to only be displayed on the primary (left monitor in my case) monitor also fixes this. That's because this way there's no dock in the "middle" of the monitors, and so the mouse cursor doesn't have to go past the Ubuntu Dock when moving between monitors.

Setting the Ubuntu Dock position to bottom fixes the issue as well.

These settings can be found in Settings > Dock for the Ubuntu Dock, and in the Dash to Dock extension settings if that's what you're using.