Skip to content

Commit

Permalink
修复触屏点击。修复旋转屏幕方向。
Browse files Browse the repository at this point in the history
1. TouchpadView:
- 把自己的Matrix删掉,改为官方的XForm(为啥非得用数组呢,直接用现成的类不好吗)
- 源代码中有错误。updateXform中新建Viewport(就是原来的Transformation),只有一个安卓/x单位的scale,但是拉伸全屏时横向缩放和纵向缩放是不同的。
- 另外切换拉伸全屏时,TouchpadView里的矩阵也不会更新。所以还是像以前一样在onTouchEvent里时刻监测全屏变化了。

2. 修复旋转屏幕后画面位置错误问题
- 需要手动刷新视图。GLRenderer.viewportNeedsUpdate 用于标识本次绘制是否需要更新视图范围。在onDrawFrame里用了一次就被置为false。反射设置为true就行了
  • Loading branch information
ewt45 committed Apr 5, 2024
1 parent f946003 commit fe42527
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.winlator.MainActivity;
import com.winlator.core.Callback;
import com.winlator.core.OnExtractFileListener;
import com.winlator.core.TarCompressorUtils;
import com.winlator.xenvironment.ImageFs;

import java.io.DataInputStream;
Expand Down Expand Up @@ -251,13 +252,9 @@ private void downloadFromGithub() {

}

/**
* @deprecated TarZstdUtils.extract 这个函数没了,现在也不需要手动选了
*/
@Deprecated
private void extractFromUri(Uri uri, Runnable callback) {
Executors.newSingleThreadExecutor().execute(() -> {
boolean extractResult = false; //TarZstdUtils.extract(requireActivity(),uri,rootDir);
boolean extractResult = TarCompressorUtils.extract(TarCompressorUtils.Type.ZSTD, requireActivity(),uri,rootDir);
// try {
// extractResult = (Boolean) QH.reflectInvokeMethod(
// TarZstdUtils.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import com.winlator.XServerDisplayActivity;
import com.winlator.contentdialog.ContentDialog;
import com.winlator.core.EnvVars;
import com.winlator.renderer.GLRenderer;
import com.winlator.widget.TouchpadView;

import java.lang.reflect.Field;

public class XserverNavMenuControl {
private static final String TAG = "XserverNavMenuControl";
private static final String PREF_KEY_XSA_ORIENT_LAND = "activity_orientation_landsc";
Expand Down Expand Up @@ -94,13 +97,23 @@ public static boolean getIsOrieLandFromPref(Context a) {
}

@SuppressLint("SourceLockedOrientationActivity")
public static void setIsOrieLandFromPref(Context a, boolean isLandSc, boolean updatePref) {
public static void setIsOrieLandFromPref(XServerDisplayActivity a, boolean isLandSc, boolean updatePref) {
if (updatePref)
QH.getPreference(a).edit().putBoolean(PREF_KEY_XSA_ORIENT_LAND, isLandSc).apply();//更新存储设置
if (a instanceof Activity)
((Activity) a).setRequestedOrientation(isLandSc
? SCREEN_ORIENTATION_SENSOR_LANDSCAPE
: SCREEN_ORIENTATION_SENSOR_PORTRAIT);
((Activity) a).setRequestedOrientation(isLandSc
? SCREEN_ORIENTATION_SENSOR_LANDSCAPE
: SCREEN_ORIENTATION_SENSOR_PORTRAIT);
//手动刷新viewport (延迟切换拉伸全屏两次吧,不知道为啥直接反射 设置GLRenderer.viewportNeedsUpdate 没反应)(啊忘了是private要设置accessible了。。)
try {
Field field = GLRenderer.class.getDeclaredField("viewportNeedsUpdate");
field.setAccessible(true);
field.setBoolean(a.getXServer().getRenderer(), true);
field.setAccessible(false);
} catch (Exception e) {
e.printStackTrace();
}
// a.getXServer().getRenderer().xServerView.postDelayed(()-> a.getXServer().getRenderer().toggleFullscreen(),500);
// a.getXServer().getRenderer().xServerView.postDelayed(()-> a.getXServer().getRenderer().toggleFullscreen(),800);
}

public static boolean getIsGameStyleCursorFromPref(Context a) {
Expand Down Expand Up @@ -144,7 +157,7 @@ public static void addInputControlsItems(XServerDisplayActivity a, ContentDialog
checkGameStyleCursor.setChecked(getIsGameStyleCursorFromPref(a));
checkGameStyleCursor.setOnCheckedChangeListener((buttonView, isChecked) -> setIsGameStyleCursor(a, isChecked, true));
LinearLayout linearStyle = QH.wrapHelpBtnWithLinear(a, checkGameStyleCursor, QH.string.游戏样式光标选项说明);
linearRoot.addView(linearStyle);
// linearRoot.addView(linearStyle);

try {
boolean testHasFeature = TouchpadView.isRelativeOnStart;
Expand Down
Loading

0 comments on commit fe42527

Please sign in to comment.