Enable frame throttling when triple buffering is disabled

This commit is contained in:
lynxnb 2022-10-18 19:26:18 +02:00
parent d962059ce2
commit 5cf14e45e1

View File

@ -7,10 +7,10 @@ package emu.skyline
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.preference.CheckBoxPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import emu.skyline.databinding.SettingsActivityBinding import emu.skyline.databinding.SettingsActivityBinding
@ -37,7 +37,7 @@ class SettingsActivity : AppCompatActivity() {
var layoutDone = false // Tracks if the layout is complete to avoid retrieving invalid attributes var layoutDone = false // Tracks if the layout is complete to avoid retrieving invalid attributes
binding.coordinatorLayout.viewTreeObserver.addOnTouchModeChangeListener { isTouchMode -> binding.coordinatorLayout.viewTreeObserver.addOnTouchModeChangeListener { isTouchMode ->
val layoutUpdate = { -> val layoutUpdate = {
val params = binding.settings.layoutParams as CoordinatorLayout.LayoutParams val params = binding.settings.layoutParams as CoordinatorLayout.LayoutParams
if (!isTouchMode) { if (!isTouchMode) {
binding.titlebar.appBarLayout.setExpanded(true) binding.titlebar.appBarLayout.setExpanded(true)
@ -83,6 +83,14 @@ class SettingsActivity : AppCompatActivity() {
*/ */
override fun onCreatePreferences(savedInstanceState : Bundle?, rootKey : String?) { override fun onCreatePreferences(savedInstanceState : Bundle?, rootKey : String?) {
setPreferencesFromResource(R.xml.preferences, rootKey) setPreferencesFromResource(R.xml.preferences, rootKey)
// Uncheck `disable_frame_throttling` if `force_triple_buffering` gets disabled
val disableFrameThrottlingPref = findPreference<CheckBoxPreference>("disable_frame_throttling")!!
findPreference<CheckBoxPreference>("force_triple_buffering")?.setOnPreferenceChangeListener { _, newValue ->
if (newValue == false)
disableFrameThrottlingPref.isChecked = false
true
}
} }
override fun onDisplayPreferenceDialog(preference : Preference) { override fun onDisplayPreferenceDialog(preference : Preference) {