inputdevices: fixed deadlock
- using mouse's double-click and drag-threshold replace tpad's
- add global var 'xsSetting' to avoid gsettings signal cycle emit. But why?
Last active
January 18, 2016 14:44
-
-
Save jouyouyun/24b30b13deaba5eba797 to your computer and use it in GitHub Desktop.
ci_summit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/appearance/handle_gsetting.go b/appearance/handle_gsetting.go | |
index b783192..5eb37a6 100644 | |
--- a/appearance/handle_gsetting.go | |
+++ b/appearance/handle_gsetting.go | |
@@ -34,6 +34,7 @@ func (m *Manager) listenBgGsettings() { | |
if m.gnomeBgSetting == nil { | |
return | |
} | |
+ logger.Debug("[Wrap background] sync gnome bg:", uri, m.gnomeBgSetting.GetString(gsKeyBackground)) | |
if uri == m.gnomeBgSetting.GetString(gsKeyBackground) { | |
return | |
} | |
@@ -48,6 +49,7 @@ func (m *Manager) listenBgGsettings() { | |
gsLocker.Lock() | |
defer gsLocker.Unlock() | |
uri := m.gnomeBgSetting.GetString(gsKeyBackground) | |
+ logger.Debug("[Gnome background] sync wrap bg:", uri, m.wrapBgSetting.GetString(gsKeyBackground)) | |
if uri == m.wrapBgSetting.GetString(gsKeyBackground) { | |
return | |
} | |
diff --git a/inputdevices/handle_gsettings.go b/inputdevices/handle_gsettings.go | |
index 1168d95..922fc1a 100644 | |
--- a/inputdevices/handle_gsettings.go | |
+++ b/inputdevices/handle_gsettings.go | |
@@ -42,16 +42,6 @@ func (m *Mouse) handleGSettings() { | |
m.motionThreshold() | |
case mouseKeyDoubleClick: | |
m.doubleClick() | |
- | |
- // Sync tpad and mouse double clicck time | |
- gsLocker.Lock() | |
- var tpad = getTouchpad() | |
- if tpad.DoubleClick.Get() == m.DoubleClick.Get() { | |
- gsLocker.Unlock() | |
- return | |
- } | |
- tpad.DoubleClick.Set(m.DoubleClick.Get()) | |
- gsLocker.Unlock() | |
case mouseKeyDragThreshold: | |
m.dragThreshold() | |
} | |
@@ -78,19 +68,6 @@ func (tpad *Touchpad) handleGSettings() { | |
tpad.enableTwoFingerScroll() | |
case tpadKeyWhileTyping: | |
tpad.disableWhileTyping() | |
- case tpadKeyDoubleClick: | |
- tpad.doubleClick() | |
- | |
- gsLocker.Lock() | |
- var m = getMouse() | |
- if tpad.DoubleClick.Get() == m.DoubleClick.Get() { | |
- gsLocker.Unlock() | |
- return | |
- } | |
- m.DoubleClick.Set(tpad.DoubleClick.Get()) | |
- gsLocker.Unlock() | |
- case tpadKeyDragThreshold: | |
- tpad.dragThreshold() | |
case tpadKeyAcceleration: | |
tpad.motionAcceleration() | |
case tpadKeyThreshold: | |
diff --git a/inputdevices/touchpad.go b/inputdevices/touchpad.go | |
index 21ed9be..a34d6be 100644 | |
--- a/inputdevices/touchpad.go | |
+++ b/inputdevices/touchpad.go | |
@@ -2,13 +2,13 @@ package inputdevices | |
import ( | |
"fmt" | |
+ "gir/gio-2.0" | |
"io/ioutil" | |
"os" | |
"os/exec" | |
"pkg.deepin.io/dde/api/dxinput" | |
dxutils "pkg.deepin.io/dde/api/dxinput/utils" | |
"pkg.deepin.io/lib/dbus/property" | |
- "gir/gio-2.0" | |
dutils "pkg.deepin.io/lib/utils" | |
"strconv" | |
"strings" | |
@@ -28,8 +28,6 @@ const ( | |
tpadKeyThreshold = "motion-threshold" | |
tpadKeyTapClick = "tap-to-click" | |
tpadKeyScrollDelta = "delta-scroll" | |
- tpadKeyDoubleClick = "double-click" | |
- tpadKeyDragThreshold = "drag-threshold" | |
) | |
const ( | |
@@ -56,9 +54,10 @@ type Touchpad struct { | |
Exist bool | |
DeviceList dxutils.DeviceInfos | |
- dxTPads map[int32]*dxinput.Touchpad | |
- setting *gio.Settings | |
- synProcess *os.Process | |
+ dxTPads map[int32]*dxinput.Touchpad | |
+ setting *gio.Settings | |
+ mouseSetting *gio.Settings | |
+ synProcess *os.Process | |
} | |
var _tpad *Touchpad | |
@@ -114,12 +113,14 @@ func NewTouchpad() *Touchpad { | |
tpad.DeltaScroll = property.NewGSettingsIntProperty( | |
tpad, "DeltaScroll", | |
tpad.setting, tpadKeyScrollDelta) | |
+ | |
+ tpad.mouseSetting = gio.NewSettings(mouseSchema) | |
tpad.DoubleClick = property.NewGSettingsIntProperty( | |
tpad, "DoubleClick", | |
- tpad.setting, tpadKeyDoubleClick) | |
+ tpad.mouseSetting, mouseKeyDoubleClick) | |
tpad.DragThreshold = property.NewGSettingsIntProperty( | |
tpad, "DragThreshold", | |
- tpad.setting, tpadKeyDragThreshold) | |
+ tpad.mouseSetting, mouseKeyDragThreshold) | |
tpad.updateDeviceList() | |
tpad.dxTPads = make(map[int32]*dxinput.Touchpad) | |
diff --git a/inputdevices/utils.go b/inputdevices/utils.go | |
index e39b99c..985a7c9 100644 | |
--- a/inputdevices/utils.go | |
+++ b/inputdevices/utils.go | |
@@ -2,8 +2,9 @@ package inputdevices | |
import ( | |
"fmt" | |
- "os/exec" | |
"gir/gio-2.0" | |
+ "os/exec" | |
+ "sync" | |
) | |
const ( | |
@@ -13,11 +14,15 @@ const ( | |
xsPropDragThres = "dnd-drag-threshold" | |
) | |
-func xsSetInt32(prop string, value int32) { | |
- s := gio.NewSettings(xsettingsSchema) | |
- defer s.Unref() | |
+var ( | |
+ xsLocker sync.Mutex | |
+ xsSetting = gio.NewSettings(xsettingsSchema) | |
+) | |
- s.SetInt(prop, value) | |
+func xsSetInt32(prop string, value int32) { | |
+ xsLocker.Lock() | |
+ xsSetting.SetInt(prop, value) | |
+ xsLocker.Unlock() | |
} | |
func addItemToList(item string, list []string) ([]string, bool) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment