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

Map scrolls to top left if mouse hasn't moved since wesnoth started #2149

Open
jostephd opened this issue Oct 30, 2017 · 19 comments
Open

Map scrolls to top left if mouse hasn't moved since wesnoth started #2149

jostephd opened this issue Oct 30, 2017 · 19 comments
Labels
Bug Issues involving unexpected behavior. Input Issues that involve the handling of user input and input devices. UI User interface issues, including both back-end and front-end issues.

Comments

@jostephd
Copy link
Member

jostephd commented Oct 30, 2017

To reproduce:

  1. Start HttT
  2. Jump to scenario 14 using :change_level
  3. "Load game" and load the most recent savegame (HttT-Pluging_into_the_Darkness-Auto-Save1)

In 1.12.6, the map scrolls to Konrad. In 1.13.10+dev, it doesn't, the player starts with the viewport at the top of the map.

edit Partly fixed; see #2149 (comment) for the current status.

@Vultraz Vultraz added the UI User interface issues, including both back-end and front-end issues. label Oct 30, 2017
@Vultraz
Copy link
Member

Vultraz commented Oct 30, 2017

Assigning this to @gfgtdf since he made the save-viewport-in-savefiles change. There must be something with the gamestate when the autosave is made that puts the camera in the top left..

gfgtdf added a commit that referenced this issue Oct 31, 2017
to investigate #2149
@gfgtdf gfgtdf closed this as completed in 02ebe52 Oct 31, 2017
@gfgtdf
Copy link
Contributor

gfgtdf commented Oct 31, 2017

turned out it was unrelated to autosaves, scroll_to_tile just by default refused to scroll to that position i it is fogged. Please test now.

@jostephd
Copy link
Member Author

jostephd commented Nov 1, 2017

Thanks for the quick turnaround.

The viewport opens on Konrad, but after I press "Esc" to close the objectives dialog, it scrolls to the top. This also happened in HttT S1 and in AToTB S1, both when starting the campaigns anew and when loading the Auto-Save1 file.

This is not 100% reproducible. It seems that once this issue stopped happening in a particular wesnoth instance, it would not reproduce until wesnoth was closed and re-opened.

To clarify, in HttT S1, it scrolled to the top twice: once before the objectives were displayed, to show the player the signpost on (1,1), and once after the objectives were accepted, which is the anomaly.

@jostephd
Copy link
Member Author

This is not 100% reproducible.

The rule seems to be: the issue still reproduces if the mouse has not moved since wesnoth was launched.

For example, launch wesnoth and start AToTB using the keyboard. After the objectives are displayed the viewport scrolls to (1,1). This happens again after exiting to the title menu and re-starting the campaign, but does not happen if the mouse is moved before (re-)starting the campaign.

GregoryLundberg pushed a commit that referenced this issue Nov 30, 2017
to investigate #2149
@jostephd
Copy link
Member Author

jostephd commented Dec 1, 2017

@GregoryLundberg Thanks for the additional fix but I can still reproduce the behaviour from my last comment as of 238a994.

@GregoryLundberg
Copy link
Contributor

Paging @gfgtdf

I don't know how I got on the commit. Probably related to the test-master branch last night as we tried to figure out what was up with master and if we needed to do anything to fix things.

@CelticMinstrel CelticMinstrel added the Bug Issues involving unexpected behavior. label Dec 2, 2017
@jostephd
Copy link
Member Author

jostephd commented Dec 5, 2017

Sorry for the false positive ping, I was confused by github's interface. Perhaps someone could "Reopen" this issue?

@CelticMinstrel CelticMinstrel reopened this Dec 5, 2017
@CelticMinstrel
Copy link
Member

Sure, I'll assume you have a reason for wanting it reopened.

@GregoryLundberg
Copy link
Contributor

Confirming @jostephd report. This still is an issue.

  1. Move mouse to your desk drawer. Leave it there!

  2. Wesnoth MUST NOT lose focus. Perform the following from memory:

a) Start Wesnoth from the command line.
b) Press C to start a campaign.
c) Press Enter to select AToTB
d) Press Enter to accept Horseman
e) Press Esc to bypass story.
f ) Press Esc to bypass dialog
g) Press Esc to close objectives

The map will scroll to the top-left corner.

@GregoryLundberg GregoryLundberg changed the title When loading HttT Pluging into the Darkness, map doesn't scroll to leader Map doesn't scroll to leader Dec 5, 2017
@CelticMinstrel
Copy link
Member

Move mouse to your desk drawer. Leave it there!

This is the best instruction. XD

@gfgtdf
Copy link
Contributor

gfgtdf commented Dec 23, 2017

i tried to reproduce but i couldn't but i also hve to say tht the esc key on this keyboard is borken so i had to user enter a few times to skip.

also this one doesn't seem to be related to reloading so ithis doesn't seem to be related to my commit.

@jostephd
Copy link
Member Author

@gfgtdf Thanks. I confirm I can reproduce the issue without the Esc key, using only Space and Enter to skip.

@jostephd
Copy link
Member Author

The rule seems to be: the issue still reproduces if the mouse has not moved since wesnoth was launched.

controller_base::play_slice() calls SDL_GetMouseState(), which sets mousex and mousey to 0, which causes scrolling to the top left.

int mousex, mousey;
uint8_t mouse_flags = SDL_GetMouseState(&mousex, &mousey);
// TODO enable after an axis choosing mechanism is implemented
#if 0
std::pair<double, double> values = joystick_manager_.get_mouse_axis_pair();
mousex += values.first * 10;
mousey += values.second * 10;
SDL_WarpMouse(mousex, mousey);
#endif
scrolling_ = handle_scroll(mousex, mousey, mouse_flags, joystickx, joysticky);

I tried adding a call to SDL_PumpEvents but that didn't help.

@Wedge009
Copy link
Member

Wedge009 commented Oct 9, 2019

Step 2 should be :choose_level, I think. And Step 3 should be Plunging but isn't terribly important to this issue.

1.14.9 works for me although you do state it's 'partly fixed'. What's not yet fixed? Testing 1.14.9+dev for Gregory's report on 2017-12-05 is also fine for me too - I don't get the top-left scrolling and yes I don't touch the mouse from start to finish. (At a guess maybe the mouse co-ordinates wasn't initialised until there's mouse movement and so went to 0,0, but that doesn't seem to be the case now.)

@jostephd
Copy link
Member Author

jostephd commented Oct 9, 2019

What's not yet fixed?

I can reproduce the problem using @GregoryLundberg's instructions in current master.

(At a guess maybe the mouse co-ordinates wasn't initialised until there's mouse movement and so went to 0,0, but that doesn't seem to be the case now.)

That's exactly what happens. mousex and mousey default to 0 before the mouse has moved.

@Wedge009
Copy link
Member

Strange. When was the last time you or Gregory tested? Checking master (1.15.1+dev @ 495f60d) I could not replicate the issue there either. I even switched off my (wireless) mouse to be doubly sure there were no mouse inputs.

Nonetheless, there seem to be a number of cases where mouse co-ordinates are not updated until there's mouse movement, including #1335, #1533, and #1795.

@jostephd
Copy link
Member Author

I tested it just before I posted my last comment.

Those other issues are unrelated to this one. In this issue, the problem is that SDL returns 0 for the mouse position before the mouse moved. Those other three are about the scrolling event not checking what's under the mouse after the scroll.

@jostephd jostephd changed the title Map doesn't scroll to leader Map scrolls to top left if mouse hasn't moved since wesnoth started Oct 10, 2019
@Wedge009
Copy link
Member

My point is that the mouse co-ordinates are not updated till the mouse is moved.

@jostephd
Copy link
Member Author

That's a good description of all four bugs, but they're still not the same. This bug occurs because we call SDL_GetMouseState and it returns 0,0. The other three issues you links are just missing code in our own GUI toolkit code.

@Wedge009 Wedge009 added the Input Issues that involve the handling of user input and input devices. label Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues involving unexpected behavior. Input Issues that involve the handling of user input and input devices. UI User interface issues, including both back-end and front-end issues.
Projects
None yet
Development

No branches or pull requests

6 participants