我正在使用自訂圖什格Ubuntu 11.04 中使用 Magic Trackpad 進行多點觸控手勢設定。由於預設手勢(例如 3 指點擊並拖曳以移動視窗、4 指點擊以顯示破折號等)顯然是在 Unity 中硬編碼的,因此我無法為它們分配任何自訂 Touchégg 操作,並且有些預設手勢手勢(我不打算使用太多,如果有的話)偶爾會與我類似的自訂分配的手勢混合併被意外觸發。
有沒有一種實用的方法(無需調整 uTouch 來源)來停用某些預設手勢?如果沒有,指向定義預設手勢的程式碼部分(可能在 grail 中?)的指標以及調整方面的幫助也將受到讚賞。
答案1
更新至主人回答適用於 Ubuntu 12.10。
Unity原始碼明顯發生了變化,因此這裡介紹如何在Unity 6.8.0中實現相同的效果。下載Unity原始程式碼的步驟與之前相同(我將複製並貼上domster的程式碼片段):
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
此時,要編輯的文件只有/tmp/unity/unity-6.8.0/plugins/unityshell/src/unityshell.cpp
.
找到該方法UnityScreen::InitGesturesSupport()
(Unity 6.8.0 的第 3368 行)。
然後,註解所有以gesture_sub_launcher開頭的行,使其看起來像:
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();
*/
}
再次按照 domster 的指示重新建構 Unity:
cd /tmp/unity/unity-6.8.0
dpkg-buildpackage -us -uc -nc
cd ..
sudo dpkg -i *deb
又瞧!登出並重新登入。
答案2
unity
事實證明,修補該包以完全禁用其對多點觸控和手勢的處理並不難。以下是修補的逐步說明unity-4.24.0
。
在命令列中輸入:
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
此時,註解掉文件中的以下兩行
/tmp/unity/unity-4.24.0/plugins/unityshell/src/unityshell.cpp
:
GeisAdapter::Default()->Run();
gestureEngine = new GestureEngine(screen);
以及文件中的以下 4 行/tmp/unity/unity-4.24.0/plugins/unityshell/src/Launcher.cpp
:
GeisAdapter& adapter = *(GeisAdapter::Default());
adapter.drag_start.connect(sigc::mem_fun(this, &Launcher::OnDragStart));
adapter.drag_update.connect(sigc::mem_fun(this, &Launcher::OnDragUpdate));
adapter.drag_finish.connect(sigc::mem_fun(this, &Launcher::OnDragFinish));
原始碼位於 中C++
,因此註解行是透過//
在行首新增來完成的。例如,該行
GeisAdapter::Default()->Run();
變成
//GeisAdapter::Default()->Run(); .
回到命令列,輸入:
cd unity-4.24.0
dpkg-buildpackage -us -uc -nc
cd ..
sudo dpkg -i *deb
等等瞧!
現在,如果您登出並重新登錄,手勢應該可以正常工作。預設情況下,在我的系統上,三次點擊作為中鍵點擊,不需要 touchegg。但 touchegg 和 ginn 現在都可以很好地為您的應用程式定義自訂手勢。
答案3
要在 12.04 中的最新 Unity (5.18.0) 上執行此操作,您必須註解掉略有不同的程式碼行。
在plugins/unityshell/src/Launcher.cpp:
// GeisAdapter& adapter = GeisAdapter::Instance();
// adapter.drag_start.connect(sigc::mem_fun(this, &Launcher::OnDragStart));
// adapter.drag_update.connect(sigc::mem_fun(this, &Launcher::OnDragUpdate));
// adapter.drag_finish.connect(sigc::mem_fun(this, &Launcher::OnDragFinish));
在plugins/unityshell/src/unityshell.cpp:
// geis_adapter_.Run();
// gesture_engine_.reset(new GestureEngine(screen));
答案4
停用標準觸控手勢,如下所示:
sudo apt install dconf-editor
dconf-editor
在左側選單中點選
com > canonical > unity > gestures
並停用此處顯示的 3 個基本手勢。這適用於 16.04.3。