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

fix #3190 #3464

Closed
wants to merge 3 commits into from
Closed

fix #3190 #3464

wants to merge 3 commits into from

Conversation

octaeder
Copy link
Contributor

@octaeder octaeder commented Jan 1, 2024

This PR fixes #3190. Pdf-viewer window now can be restored to maximized window from embedded state.
Main reasons for the issue are: Resize and move after setting to maximized. Bad coordinates appear because they were retrieved and stored while in maximized state. But maximizing a window is solely achieved by setting appropriate attributes not by window coordinates.

pdf viewer window now can be restored to maximized window from embedded state
when maximized window is embedded and then txs closed
@sunderme
Copy link
Member

sunderme commented Jan 4, 2024

unfortunately I am busy and I don't have time to review this. May take a while.

@@ -4298,11 +4298,15 @@ PDFDocument *PDFDocument::findDocument(const QString &fileName)

void PDFDocument::saveGeometryToConfig()
{
globalConfig->windowLeft = x();
Copy link
Member

Choose a reason for hiding this comment

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

if the window position is only saved when not maximised, then the move(x,y) is possibly undefined or wrong.
This probably comes into play for multi-monitor set-ups ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I've seen with debug under Win10 lead me to the conclusion that retrieving window coordinates while in maximized (and similar) modes returns invalid values. Especially the coordinate of the upper left window corner has negative values. It seems that line 2860 was introduced to fix this. So I assume that maximized/fullscreen needs to be handled by flags not by coordinates.

Be aware that the code retrieves coordinates from different things: The window corner as mentioned before and the size of the pdf widget. This can introduce problems because we and Qt have no access to the geometry of the window decoration (how thick are the border lines of the window surrounding the widget, height of the window title, and so on, which are under control of the window manager). Typically we don't need to know these details when all changes to the coordinates (and flags) are retrieved. Because with these values we should be able to restore a correct window at any time. So the move should be no problem here. Can you reproduce some case?

But this is currently not the case. After my PR I observed following: Maximize and restore pdf window. Thus window coordinates are retrieved and stored. Now move or resize the window, then maximize it, then end txs. When starting txs again the maximized window mode is restored with my PR, but when the maximized flag is cleared, then the normal window has the last saved coordinates instead of the last ones used. I tried to improve this with following code where I need help:

connect(window(), SIGNAL(PDFDocument::windowStateChanged(Qt::WindowState)), this, SLOT(slotWindowStateChanged(Qt::WindowState)));

But I couldn't figure out how to find the window as the sender of the signal. If this would work then the current coordinates of the window could be retrieved by txs on maximizing the window (and the like). This should be sufficient for single monitor setups.

In multi monitor setups this may lead to cases where the window is placed on the wrong screens. And what about the case that one drags the maximized window to another screen such that it appears maximized (or normal) there?

@octaeder
Copy link
Contributor Author

Maybe someone else will find a good solution

@octaeder octaeder closed this Jan 20, 2024
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.

toggling between embedded and windowed pdf viewer
2 participants