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

Prevent change of Pioneer's mouse pointer when hiding HUD #4827

Merged
merged 1 commit into from
Mar 4, 2020

Conversation

cwyss
Copy link
Contributor

@cwyss cwyss commented Mar 1, 2020

Description

Remarks

As mentioned in #4812 (comment), the fix is to comment out three lines of code which change an imgui mouse setting:

#if 0 // Mouse cursors are set via the OS facilities.
	// See also below.
	if (!Pi::DrawGUI) {
		ImGui::GetIO().MouseDrawCursor = true;
	}
#endif

In fact, a few lines below an analogous change was already made in 5824d0a by @Web-eWorks:

#if 0 // Mouse cursors are set via the OS facilities.
	// We may want to revisit this at a later date.
	if(Pi::DoingMouseGrab() || !Pi::DrawGUI) {
		ImGui::GetIO().MouseDrawCursor = false;
	} else {
		ImGui::GetIO().MouseDrawCursor = true;
	}
#endif

Note that I have no real understanding of the imgui API at all. All I did when trying to find a fix for #4812 was to search for places in the code that are triggered when the HUD is off, i.e. places referencing Pi::DrawGUI. So I don't know if this is the proper way to do it. As @Web-eWorks commented in the code,

We may want to revisit this at a later date.

So there might be a better way to do it.

Nevertheless, I have checked that both #4762 and #4812 are fixed with this. I also tried to make sure that my uneducated fix does not introduce any new bugs. At least I did not experience any problems while test-playing this.

- When hiding HUD in flight-ui with double TAB (i.e. Pi::DrawGUI==false),
  prevent a change of Pioneer's custom mouse pointer to the system
  default pointer (fixes pioneerspacesim#4762)
- This also fixes a bug with Pioneer crashing occasionally after TAB-
  toggling the HUD off/on (pioneerspacesim#4812)
@Web-eWorks
Copy link
Member

@cwyss thank you for tracking this one down! I'm not even 50% sure of the interaction between Pioneer, ImGui and the system when it comes to cursors, so don't feel bad about not understanding ImGui very well.

Once we rip out newUI and oldUI completely, I'll revisit mouse cursor handling and see if I can remove all the hacks, but if this PR works as advertised I'll get it merged right away.

@Bodasey
Copy link

Bodasey commented Mar 3, 2020

I think it's also for #4783

@cwyss
Copy link
Contributor Author

cwyss commented Mar 3, 2020

I think it's also for #4783

No, just checked it: behaviour of #4783 remains the same.

@Web-eWorks
Copy link
Member

Tested and looks good. Will track down #4783 soon as well!

@Web-eWorks Web-eWorks merged commit 3b2116e into pioneerspacesim:master Mar 4, 2020
@cwyss cwyss deleted the mousefix branch March 9, 2020 19:19
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.

Pioneer occasionally crashing after toggling HUD off in flight-ui Mouse cursor changes when you hide HUD
3 participants