Vera-Firefly / Pojav-Glow-Worm

PojavLauncher with more practical functions,A modified Launcher from the PojavLauncher team
GNU General Public License v3.0
165 stars 22 forks source link

[BUG] Incorrect screen resolution on some devices #294

Open IncludedBerry11 opened 3 weeks ago

IncludedBerry11 commented 3 weeks ago

Describe the bug

Devices with a notch (i guess) isn't properly scaled, the mouse is offset(not where it seems) and the screen seems off aswell, it works perfectly with FoldCraft Launcher tho, my device model is vivo 1811

The log file and images/videos

no

Steps To Reproduce

no

Expected Behavior

I expect the resolution to fit the screen properly and not be offset as done in FoldCraft Launcher

Platform

- Device model: Vivo 1811
- CPU architecture: arm64
- Android version: 8.1
- PojavLauncher version: Pojav ZH latest fork of yours

Anything else?

even the controls seem to be offset

Vera-Firefly commented 3 weeks ago

That doesn't seem right. Have you ever tried full screen? Press F11 after entering the game

kasrarouhi commented 3 weeks ago

I don't know very much about this but try alternate surface rendering off

IncludedBerry11 commented 3 weeks ago

here are some more info, Screenshot_20240823_064410 latestlog.txt

IncludedBerry11 commented 3 weeks ago

Screenshot_20240823_064933

Vera-Firefly commented 3 weeks ago

Screenshot_2024-08-22-23-04-51-500_net kdt pojavlaunch firefly debug Did you open it?

IncludedBerry11 commented 3 weeks ago

i don't have that option, maybe its for android versions above 8.1?

IncludedBerry11 commented 3 weeks ago

it shows 1464x720 in fcl's debug menu but in pojav's debug menu, it shows 1520x720

WesleyVanNeck commented 3 weeks ago

i don't have that option, maybe its for android versions above 8.1?

You need indeed android 8.1 or higer

kasrarouhi commented 3 weeks ago

I recommend not use (ignore notch) option. For saving battery

IncludedBerry11 commented 3 weeks ago

can you check and find out what's the problem? it works fine with FCL

IncludedBerry11 commented 3 weeks ago

i have tried changing overrideWidth to 1464 and the problem still persists

IncludedBerry11 commented 3 weeks ago

it is the same on all pojav launchers

IncludedBerry11 commented 3 weeks ago

maybe its only the controls including mouse

IncludedBerry11 commented 3 weeks ago

Screenshot_2024-08-22-23-04-51-500_net kdt pojavlaunch firefly debug Did you open it?

can you convert this fcl code to your pojav's code? this must be the solution

FCL Code :

public static int getScreenHeight(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Point point = new Point();
    wm.getDefaultDisplay().getRealSize(point);
    return point.y;
}

public static int getScreenWidth(Activity context) {
    SharedPreferences sharedPreferences;
    sharedPreferences = context.getSharedPreferences("theme", MODE_PRIVATE);
    boolean fullscreen = sharedPreferences.getBoolean("fullscreen", false);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Point point = new Point();
    wm.getDefaultDisplay().getRealSize(point);
    if (fullscreen || SDK_INT < Build.VERSION_CODES.P) {
        return point.x;
    } else {
        try {
            Rect notchRect;
            if (SDK_INT >= Build.VERSION_CODES.S) {
                notchRect = Objects.requireNonNull(wm.getCurrentWindowMetrics().getWindowInsets().getDisplayCutout()).getBoundingRects().get(0);
            } else {
                notchRect = Objects.requireNonNull(context.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout()).getBoundingRects().get(0);
            }
            return point.x - Math.min(notchRect.width(), notchRect.height());
        } catch (Exception e) {
            return point.x;
        }
    }
}

Pojav's Code:

public static DisplayMetrics getDisplayMetrics(Activity activity) {
    DisplayMetrics displayMetrics = new DisplayMetrics();

    if(activity.isInMultiWindowMode() || activity.isInPictureInPictureMode()){
        //For devices with free form/split screen, we need window size, not screen size.
        displayMetrics = activity.getResources().getDisplayMetrics();
    }else{
        if (SDK_INT >= Build.VERSION_CODES.R) {
            activity.getDisplay().getRealMetrics(displayMetrics);
        } else { // Removed the clause for devices with unofficial notch support, since it also ruins all devices with virtual nav bars before P
            activity.getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
        }
        if(!PREF_IGNORE_NOTCH){
            //Remove notch width when it isn't ignored.
            if(activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
                displayMetrics.heightPixels -= PREF_NOTCH_SIZE;
            else
                displayMetrics.widthPixels -= PREF_NOTCH_SIZE;
        }
    }
    currentDisplayMetrics = displayMetrics;
    return displayMetrics;
}
IncludedBerry11 commented 3 weeks ago

It must be the notch or bounding box and maybe because of ignore notch(which is unaccessible for android 8.1 and below and enabled by default), i have forked and changed MovTery's PojavZenithHorizons's getDisplayMetrics code to minus 66 pixels from displayMetrics.getWidthPixels and it works perfectly fine. please make it so that the ignore notch option is available for all supported android versions if the problem persists on some other devices

IncludedBerry11 commented 3 weeks ago

i minus'd 66 pixels because it returns 1464 instead of 1530 which is the correct widthPixels which i have seen in FCL

IncludedBerry11 commented 2 weeks ago

nevermind, the bounding rects are implemented unofficially