Beispiel #1
0
func NewMouse(l *log.Logger) *Mouse {
	m := &Mouse{}

	m.settings = gio.NewSettings("com.deepin.dde.mouse")
	m.LeftHanded = property.NewGSettingsBoolProperty(
		m, "LeftHanded",
		m.settings, mouseKeyLeftHanded)
	m.DisableTpad = property.NewGSettingsBoolProperty(
		m, "DisableTpad",
		m.settings, mouseKeyDisableTouchpad)
	m.NaturalScroll = property.NewGSettingsBoolProperty(
		m, "NaturalScroll",
		m.settings, mouseKeyNaturalScroll)
	m.MiddleButtonEmulation = property.NewGSettingsBoolProperty(
		m, "MiddleButtonEmulation",
		m.settings, mouseKeyMiddleButton)

	m.MotionAcceleration = property.NewGSettingsFloatProperty(
		m, "MotionAcceleration",
		m.settings, mouseKeyAcceleration)
	m.MotionThreshold = property.NewGSettingsFloatProperty(
		m, "MotionThreshold",
		m.settings, mouseKeyThreshold)

	m.DoubleClick = property.NewGSettingsIntProperty(
		m, "DoubleClick",
		m.settings, mouseKeyDoubleClick)
	m.DragThreshold = property.NewGSettingsIntProperty(
		m, "DragThreshold",
		m.settings, mouseKeyDragThreshold)

	mouseList, _, _ := wrapper.GetDevicesList()
	m.setPropDeviceList(mouseList)
	if len(mouseList) > 0 {
		m.setPropExist(true)
	} else {
		m.setPropExist(false)
	}

	m.logger = l
	var err error
	m.xsettings, err = sessionmanager.NewXSettings(
		"com.deepin.SessionManager",
		"/com/deepin/XSettings",
	)
	if err != nil {
		m.warningInfo("Create XSettings Failed: %v", err)
		m.xsettings = nil
	}

	_mouse = m
	m.init()
	m.handleGSettings()

	return m
}
Beispiel #2
0
func NewTouchpad(l *log.Logger) *Touchpad {
	tpad := &Touchpad{}

	tpad.settings = gio.NewSettings("com.deepin.dde.touchpad")
	tpad.TPadEnable = property.NewGSettingsBoolProperty(
		tpad, "TPadEnable",
		tpad.settings, tpadKeyEnabled)
	tpad.LeftHanded = property.NewGSettingsBoolProperty(
		tpad, "LeftHanded",
		tpad.settings, tpadKeyLeftHanded)
	tpad.DisableIfTyping = property.NewGSettingsBoolProperty(
		tpad, "DisableIfTyping",
		tpad.settings, tpadKeyWhileTyping)
	tpad.NaturalScroll = property.NewGSettingsBoolProperty(
		tpad, "NaturalScroll",
		tpad.settings, tpadKeyNaturalScroll)
	tpad.EdgeScroll = property.NewGSettingsBoolProperty(
		tpad, "EdgeScroll",
		tpad.settings, tpadKeyEdgeScroll)
	tpad.VertScroll = property.NewGSettingsBoolProperty(
		tpad, "VertScroll",
		tpad.settings, tpadKeyVertScroll)
	tpad.HorizScroll = property.NewGSettingsBoolProperty(
		tpad, "HorizScroll",
		tpad.settings, tpadKeyHorizScroll)
	tpad.TapClick = property.NewGSettingsBoolProperty(
		tpad, "TapClick",
		tpad.settings, tpadKeyTapClick)

	tpad.MotionAcceleration = property.NewGSettingsFloatProperty(
		tpad, "MotionAcceleration",
		tpad.settings, tpadKeyAcceleration)
	tpad.MotionThreshold = property.NewGSettingsFloatProperty(
		tpad, "MotionThreshold",
		tpad.settings, tpadKeyThreshold)

	tpad.DeltaScroll = property.NewGSettingsIntProperty(
		tpad, "DeltaScroll",
		tpad.settings, tpadKeyScrollDelta)
	tpad.DoubleClick = property.NewGSettingsIntProperty(
		tpad, "DoubleClick",
		tpad.settings, tpadKeyDoubleClick)
	tpad.DragThreshold = property.NewGSettingsIntProperty(
		tpad, "DragThreshold",
		tpad.settings, tpadKeyDragThreshold)

	_, tpadList, _ := wrapper.GetDevicesList()
	tpad.setPropDeviceList(tpadList)

	if len(tpad.DeviceList) > 0 {
		tpad.setPropExist(true)
	} else {
		tpad.setPropExist(false)
	}

	tpad.logger = l
	var err error
	tpad.xsettings, err = sessionmanager.NewXSettings(
		"com.deepin.SessionManager",
		"/com/deepin/XSettings",
	)
	if err != nil {
		tpad.warningInfo("Create XSettings Failed: %v", err)
		tpad.xsettings = nil
	}

	_tpad = tpad
	tpad.init()
	tpad.handleGSettings()

	return tpad
}