-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[2.3] Prevent preferences dialog from going out of screen #4613
Conversation
if (windowDecorationWidth <= 0) { | ||
windowDecorationWidth = 2; | ||
} | ||
if (windowDecorationHeight <= 0) { | ||
windowDecorationHeight = 30; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not make sense to me. Would you mind giving some explanation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently debugging a similiar issue with DlgDevTools¹ and I ended up here, too:
Those magic numbers are used as default window decoration dimensions in QRect DlgPreferences::getDefaultGeometry() in case they cannot be retireved from the OS. !?
¹when I open it the initial window it's like 10.000 pixels wide
newX = std::max(0, std::min(newX, availableWidth - newWidth)); | ||
newY = std::max(0, std::min(newY, availableHeight - newHeight)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://en.cppreference.com/w/cpp/algorithm/clamp
newX = std::max(0, std::min(newX, availableWidth - newWidth)); | |
newY = std::max(0, std::min(newY, availableHeight - newHeight)); | |
newX = std::clamp(availableWidth - newWidth, 0, newX); | |
newY = std::clamp(availableHeight - newHeight, 0, newY); |
int availableWidth = screenSpace.width() - windowDecorationWidth; | ||
int availableHeight = screenSpace.height() - windowDecorationHeight; | ||
newWidth = std::min(newWidth, availableWidth); | ||
newHeight = std::min(newHeight, availableHeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not make sense to me either.
@@ -371,12 +373,29 @@ void DlgPreferences::onShow() { | |||
screenSpace = QSize(800, 600); | |||
} | |||
else { | |||
screenSpace = pScreen->size(); | |||
screenSpace = pScreen->availableSize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
availableSize
returns QSize(width, height)
Did you consider pScreen->availableGeometry()
here? It returns QRect(int x, int y, int width, int height)
newY = std::max(0, std::min(newY, screenSpace.height() - m_geometry[3].toInt())); | ||
|
||
// Make sure the entire window is visible on screen and is not occluded by taskbar | ||
// Note: Window geometry excludes window decoration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Note: Window geometry excludes window decoration | |
// The window's frameGeometry() includes window decoration, geometry() does not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind updating the comments in resizeEvent() and moveEvent()?
if (windowDecorationWidth <= 0) { | ||
windowDecorationWidth = 2; | ||
} | ||
if (windowDecorationHeight <= 0) { | ||
windowDecorationHeight = 30; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently debugging a similiar issue with DlgDevTools¹ and I ended up here, too:
Those magic numbers are used as default window decoration dimensions in QRect DlgPreferences::getDefaultGeometry() in case they cannot be retireved from the OS. !?
¹when I open it the initial window it's like 10.000 pixels wide
Looking fine on a 15" retina MacBook Pro when opening preferences from mixxx in windowed mode. No obvious regression I was able to spot. |
This PR is marked as stale because it has been open 90 days with no activity. |
Works nicely. Pref window is moved back into the screen if it has moved out. @Swiftb0y Any comments? |
LGTM once the pre-commit issues have been resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ronso0 merge?
yup, thank you! |
Thank you all for reviewing and testing this! ❤️ |
This fixes https://bugs.launchpad.net/mixxx/+bug/1938653.
Could someone check if this causes a regression on macOS?