Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt/macOS: enable HiDPI ( retina display ) support #12552

Merged
merged 3 commits into from
Feb 4, 2020

Conversation

CarterLi
Copy link
Contributor

@CarterLi CarterLi commented Jan 5, 2020

Tested on macOS 10.15.2

image
image

EDIT: now we can modify Info.plist automatically

emugl->resizeGL(emugl->size().width(), emugl->size().height());
// TODO: Won't showFullScreen do this for us?
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that resizing the main window will trigger resizeGL automatically. This code should be unnecessary on Windows too.

activateWindow();
}

void MainWindow::SetFullScreen(bool fullscreen) {
if (fullscreen) {
#if !PPSSPP_PLATFORM(MAC)
menuBar()->hide();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qt uses native menubar on macOS by default, which is hidden automatically on fullscreen.

g_dpi = (float)System_GetPropertyInt(SYSPROP_DISPLAY_DPI);
float g_logical_dpi = (float)System_GetPropertyInt(SYSPROP_DISPLAY_LOGICAL_DPI);
g_dpi_scale_x = g_logical_dpi / g_dpi;
g_dpi_scale_y = g_logical_dpi / g_dpi;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tries to get the native scale factor. This should work on Windows too ( untested )

Qt/QtMain.cpp Outdated Show resolved Hide resolved
@CarterLi CarterLi force-pushed the master branch 2 times, most recently from d2d6364 to d570049 Compare January 5, 2020 17:11
@LastChalice
Copy link

LastChalice commented Jan 18, 2020

Just out of curiosity, how did u manage to get ppsspp 1.9.3 working on your mac?
The latest version I have access to is 1.6.3.
In addition, how well does 1.9.3 function compared to on windows, since macos has outdated OpenGl and as far as I know, mac has no Vulkan either.
Edit: Or did u use moltenVK to translate from Vulkan to Metal?

@CarterLi
Copy link
Contributor Author

Just out of curiosity, how did u manage to get ppsspp 1.9.3 working on your mac?
The latest version I have access to is 1.6.3.

I built it from source

In addition, how well does 1.9.3 function compared to on windows, since macos has outdated OpenGl and as far as I know, mac has no Vulkan either.
Edit: Or did u use moltenVK to translate from Vulkan to Metal?

Just use OpenGL

@CarterLi
Copy link
Contributor Author

CarterLi commented Jan 21, 2020

I just dig HiDPI support for SDL2. For Vulkan, everything worked like a charm ( including dpi scale, surprisedly ). For OGL, images were displayed in the bottom-left quarter.

SDL2 supports HiDPI by specifying SDL_WINDOW_ALLOW_HIGHDPI flag when creating SDL window. After that we can get the correct drawable size using SDL_GL_GetDrawableSize. Just call it in the SDL event loop:

if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
	int w = event.window.data1, h = event.window.data2;
	if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
		SDL_GL_GetDrawableSize(window, &w, &h);
	}
	UpdateScreenScale(w, h);
}

But it breaks mouse event. Need more hacking...

@Florin9doi
Copy link
Contributor

Florin9doi commented Feb 2, 2020

Modify Info.plist manually ( don't know how to do it automatically ):

QMAKE_POST_LINK += plutil -replace NSPrincipalClass -string \"NSApplication\" $${TARGET}.app/Contents/Info.plist;
QMAKE_POST_LINK += plutil -replace NSHighResolutionCapable -bool YES $${TARGET}.app/Contents/Info.plist;

@LastChalice
Copy link

Is this build publicly available?
I'm a rookie to Github, so I'm not sure how this system works.

@CarterLi
Copy link
Contributor Author

CarterLi commented Feb 4, 2020

Modify Info.plist manually ( don't know how to do it automatically ):

QMAKE_POST_LINK += plutil -replace NSPrincipalClass -string \"NSApplication\" $${TARGET}.app/Contents/Info.plist;
QMAKE_POST_LINK += plutil -replace NSHighResolutionCapable -bool YES $${TARGET}.app/Contents/Info.plist;

But PPSSPP uses CMAKE_AUTOMOC, instead of qmake things

Added macbundle.sh to do it

@CarterLi
Copy link
Contributor Author

CarterLi commented Feb 4, 2020

Bundle @LastChalice : PPSSPPQt.zip

Install dependencies

$ brew install sdl2 qt

@hrydgard @unknownbrackets any chance to get reviewed?

@hrydgard
Copy link
Owner

hrydgard commented Feb 4, 2020

Sorry, this fell between the cracks somehow. It looks good!

(I got the impression this wasn't finished because of the mouse issue above, but I assume it's fixed now since you're asking for review).

@hrydgard hrydgard merged commit dcc2682 into hrydgard:master Feb 4, 2020
@CarterLi
Copy link
Contributor Author

CarterLi commented Feb 4, 2020

(I got the impression this wasn't finished because of the mouse issue above, but I assume it's fixed now since you're asking for review).

It related to the SDL version, which I didn't touch in this PR

@unknownbrackets unknownbrackets added this to the v1.10.0 milestone Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants