Ubuntu – How to disable arbitrary default multitouch gestures in Unity

gesturesmagic-trackpadmulti-touchtoucheggunity

I'm using a custom Touchégg multitouch gesture setup in Ubuntu 11.04 with a Magic Trackpad. Since the default gestures (such as 3-finger tap and drag to move windows, 4 finger tap to reveal the dash, etc.) are apparently hardcoded in Unity, I'm unable to assign any custom Touchégg actions to them, and some default gestures (that I don't intend to use much, if at all) occasionally mix up with my similar custom-assigned ones and get triggered by accident.

Is there a practical way (short of tweaking the uTouch source) to disable some of the default gestures? If not, pointers to parts of the code (perhaps in grail?) where the default gestures are defined, and help with tweaking would also be appreciated.

Best Answer

An update to domster answer for Ubuntu 12.10.

Unity source code has obviously changed, so here is how to achieve the same in Unity 6.8.0. The steps to download Unity source code are the same as before (I will copy & paste domster's snippet):

sudo apt-get build-dep unity
cd /tmp  #It can be done somewhere else, feel free to change the base location.
mkdir unity
cd unity
apt-get source unity

At this point, the file to be edited is only /tmp/unity/unity-6.8.0/plugins/unityshell/src/unityshell.cpp.

Find the method UnityScreen::InitGesturesSupport() (line 3368 for Unity 6.8.0).

Then, comment all the lines starting with gesture_sub_launcher to make it look like:

void UnityScreen::InitGesturesSupport()
{
  std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker);
  wt->GetWindowCompositor().SetGestureBroker(std::move(gesture_broker));
  /*
  gestures_sub_launcher_.reset(new nux::GesturesSubscription);
  gestures_sub_launcher_->SetGestureClasses(nux::DRAG_GESTURE);
  gestures_sub_launcher_->SetNumTouches(4);
  gestures_sub_launcher_->SetWindowId(GDK_ROOT_WINDOW());
  gestures_sub_launcher_->Activate();

  gestures_sub_dash_.reset(new nux::GesturesSubscription);
  gestures_sub_dash_->SetGestureClasses(nux::TAP_GESTURE);
  gestures_sub_dash_->SetNumTouches(4);
  gestures_sub_dash_->SetWindowId(GDK_ROOT_WINDOW());
  gestures_sub_dash_->Activate();

  gestures_sub_windows_.reset(new nux::GesturesSubscription);
  gestures_sub_windows_->SetGestureClasses(nux::TOUCH_GESTURE
                                         | nux::DRAG_GESTURE
                                         | nux::PINCH_GESTURE);
  gestures_sub_windows_->SetNumTouches(3);
  gestures_sub_windows_->SetWindowId(GDK_ROOT_WINDOW());
  gestures_sub_windows_->Activate();
  */
}

Re-build Unity following domster's instructions again:

cd /tmp/unity/unity-6.8.0
dpkg-buildpackage -us -uc -nc
cd ..
sudo dpkg -i *deb

Et voila again! Logout and log back in.

Related Question