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

Readd a method to center window (lost during DisplayServer refactoring) #5232

Closed
ztc0611 opened this issue Aug 23, 2022 · 7 comments · Fixed by godotengine/godot#81012
Closed
Milestone

Comments

@ztc0611
Copy link

ztc0611 commented Aug 23, 2022

Describe the project you are working on

Works for every project type.

Describe the problem or limitation you are having in your project

In Godot 3.x, there was OS.center_window(). Godot 4.0 does not have any equivalent function as far as I can find, but obviously still has the ability to center the window as when the project is run initially it is centered.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

This restores the functionality already found in Godot 3.x.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Running this function will place the window in the center of the screen.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be, but the function already existed in Godot 3.x.

Is there a reason why this should be core and not an add-on in the asset library?

Functionality existed in Godot 3.x.

@Calinou Calinou added this to the 4.0 milestone Aug 23, 2022
@Calinou Calinou changed the title Add DisplayServer.window_center() Readd a method to center window (lost during DisplayServer refactoring) Aug 23, 2022
@Calinou
Copy link
Member

Calinou commented Aug 23, 2022

The removal of this function is probably not intentional, so feel free to open a pull request to readd it 🙂

@ztc0611
Copy link
Author

ztc0611 commented Sep 6, 2022

@Calinou any tips as to where the code that runs when the project opens is, so I can look at that for help? That window always opens centered on the screen so I presume something is up there.

I'm a bit of a noob at this complex C++ stuff so bear with me. Edit: Got it, basic version is working.

However, should I add a get() for this, to check if the window is already centered? I'd imagine in some hyper specific scenario it might be useful, but I'm not sure. Every other window function has a setter and getter though.

To clarify...

DisplayServer.window_center(WINDOW=0)
or
DisplayServer.set_window_center(WINDOW=0) and DisplayServer.get_window_center(WINDOW=0)

@YuriSizov
Copy link
Contributor

@ztc0611 Probably should be DisplayServer.window_set_centered and DisplayServer.window_is_centered.

@ztc0611
Copy link
Author

ztc0611 commented Sep 6, 2022

Alright I have DisplayServer.window_set_centered and DisplayServer.window_is_centered implemented on macOS. I should be able to do Windows too, but I will require some assistance with Linux, as I don't have a Linux computer to 100% confirm the code works. Once I finish Windows and my attempt at Linux, should I open the PR and note in the body that a Linux tester is required, or is there a different procedure for this?

@YuriSizov
Copy link
Contributor

Yes, go ahead and open a PR and we can ping Linux folk, of which we have plenty, to offer a hand.

@ztc0611
Copy link
Author

ztc0611 commented Apr 27, 2023

Even if my own attempt at resolving this is not used, I would really appreciate the return of this function. 🙁

@YuriSizov
Copy link
Contributor

@ztc0611 Hey, doesn't look like there is anything wrong with your PR. It just needs to be reviewed again to finish things off. Sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants