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

Store window sizes in prefs at JabRef frame quit #10143

Merged
merged 3 commits into from
Aug 8, 2023

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Aug 5, 2023

Follow up fix for #4939

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2023

Your code currently does not meet JabRef's code guidelines. The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.

More information on code quality in JabRef is available at https://devdocs.jabref.org/getting-into-the-code/development-strategy.html.

Comment on lines 504 to 513
private void saveWindowState(Stage mainStage) {
GuiPreferences preferences = prefs.getGuiPreferences();
preferences.setPositionX(mainStage.getX());
preferences.setPositionY(mainStage.getY());
preferences.setSizeX(mainStage.getWidth());
preferences.setSizeY(mainStage.getHeight());
preferences.setWindowMaximised(mainStage.isMaximized());
preferences.setWindowFullScreen(mainStage.isFullScreen());
debugLogWindowState(mainStage);
}
Copy link
Member

Choose a reason for hiding this comment

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

Hm, this is not part of the frame, but of the stage. I was hoping I could untangle all that GUI-CLI-opendatabase stuff on jabcon. Right now this is just a code duplication of JabRefGUI#saveWindowState. But maybe you can make this method in JabRefFrame public and remove the one in JabRefGui?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. The key problem is that cmd + Q (like alt + f4 ) does not trigger the onCloseRequest listener of the stage

Copy link
Member

Choose a reason for hiding this comment

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

Yes, i did a little bit of reading on this one. I believe the main problem is that the whole startup and shutdown process has to be rewritten.
JabRefGui and MainApplication should probably be merged, the creation of ExecutorService be moved to JabRefGui so it can be cleanly be shutdown, so we can solve the problem with the runaway process when all windows are closed (see also Platform.setImplicitExit(true); ), the different openDatabase methods be unified ...

Copy link
Member Author

Choose a reason for hiding this comment

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

We had this before, but then the decision was made to avoid init of javafx directly and thus we have this Gui and CLI etc.

Copy link
Contributor

@credmond credmond Aug 12, 2023

Choose a reason for hiding this comment

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

@Siedlerchr / @calixtus

CMD+Q does and would trigger onCloseRequest, except you're binding that key combination (via "ctrl+Q" in KeyBinding) yourself and calling quit() in CloseAction's execute(); that's why the stage isn't being closed and calling the listener; it isn't getting the chance.

Alt-F4 also already calls onCloseRequest with no issue, at least on Linux; and that is the operating system.

Also, shouldn't "private void saveWindowState(Stage mainStage)" be removed from JabRefGUI? It's not used and its existence only adds to an already-confusing situation ;) ...

Finally, Mac-OS specific comments like this:

// General info dialog. The MacAdapter calls this method when "Quit" is selected from the application menu, Cmd-Q
// is pressed, or "Quit" is selected from the Dock. The function returns a boolean indicating if quitting is ok or
// not.

...seem all wrong to me. There is no MacAdapter (it's mentioned three times in the codebase), and there is no specific/special behaviour that I've observed that's Mac-specific here. It all makes sense (based on what I said above) and seems consistent between operating systems. Either something has changed fundamentally to make this commentary untrue/inaccurate, or else the original author has possibly misinterpreted things.

Copy link
Member

Choose a reason for hiding this comment

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

We had this before, but then the decision was made to avoid init of javafx directly and thus we have this Gui and CLI etc.

MainApplication is part of the GUI component. The Launcher class is the super class deciding on opening GUI or cli.

About MacOS stuff: parts of the codebase and parts of the architecture of jabref are 20 years old. It was necessary at one point, as it has fixed a bug once. Would probably have to be tested if this is still necessary.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2023

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

@Siedlerchr Siedlerchr merged commit 395584f into main Aug 8, 2023
@Siedlerchr Siedlerchr deleted the fixSavingWindowPosAgain branch August 8, 2023 19:07
@koppor koppor mentioned this pull request Jan 15, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants