s25edit backports from s25client#37
Conversation
Flamefire
left a comment
There was a problem hiding this comment.
Thanks for the PR, that definitely improves it!
Some notes inline, a common theme is that any pair of x/y or width/height values should use either Point/PointF or Extent which avoids C&P errors and makes processing easier (single assignment instead of 2, operator support for combining with other Points)
Note: In some places fixed-size variants are used. That is historical and not necessary in almost all cases, so no need to introduce new uses of them unless there is a specific reason for the size requirement.
Thanks again!
| moveMap(offset); | ||
|
|
||
| // this whole "warping-thing" is to prevent cursor-moving WITHIN the window while user moves over the map | ||
| SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); |
There was a problem hiding this comment.
Why the change? Isn't handling this "issue" here better where it is caused than where mouse moves should be handled?
IIRC SDL offers a relative mouse mode. As we only support SDL here that might be the best solution if we change this
There was a problem hiding this comment.
This is matching current s25client VideoSDL2.cpp which doesn't use SDL_EventState.
There was a problem hiding this comment.
That is not a good reason to me.
There was a problem hiding this comment.
Well they're clearly not needed.
There was a problem hiding this comment.
Re: removing SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE)
This change is part of what fixes mouse panning on Linux in this PR. The old SDL_EventState/SDL_IGNORE/SDL_ENABLE dance is a global filter that temporarily drops all motion events — on > Linux (X11/Wayland) the warp-generated event can arrive asynchronously after SDL_ENABLE is called, creating a feedback loop where each motion event warps the mouse, which generates > another event, which warps again, etc. That matches the symptom of panning that stutters and becomes unusable.
The replacement filters by position identity: a motion event with the same coordinates as the previous one is a warp echo and gets skipped. It's strictly more targeted, and it converges > immediately instead of looping.
I know "s25client does it" isn't a strong argument on its own — I mention it more as validation that this approach is well-tested in production, not as the reason for the change. The actual reason is that it fixes a real bug with a more precise filter, replacing a global side-effect that interacts poorly with asynchronous event delivery on Linux.
There was a problem hiding this comment.
So this is the exact source of frustration causing mouse scrolling to sputter and fail after just a few frames in every PR I work on.
67f2175 to
604b117
Compare
|
Maybe I should split this into smaller PRs. I was working on import heightmap as I posted about on Discord, not sure I will submit as PR. And these were some quality of life improvements that felt important. |
|
What's the holdup here? All review comments are resolved. |
life ;-) oh and there is a conflict |
|
Ah ok no worries then. I'm just impatient lol. |
|
In every branch I work on I'm frustrated by the lack of the Fix mouse panning commit that's in this PR. |
|
fc01c45 to
74d768d
Compare
|
I went all in on rebase. Squashed some commits with feedback into original commit, removed the commit that was reverted and extracted. |
| #include "callbacks.h" | ||
| #include "globals.h" | ||
|
|
||
| namespace { |
There was a problem hiding this comment.
Why am I using anonymous namespaces like this?
Please advice, my review overlords.
There was a problem hiding this comment.
Ok it's just file local helper function that is not available from other object files.
So it's fine. Not needed but whatever.
I'd assumed that not being added to .h would've made it inaccessible but I guess this is explicit and goes further.
AI adds these on it's own initiative and then makes a mess and chokes on it when there's multiple namespace scopes in same file.
|
Also renamed commit "Wrap mouse for large screens" ->"Wrap brush for large screens", as it refers to the icons drawn on vertices not the cursor itself. |
| Xeven += (map->width); | ||
| else if(Xeven > map->width - 1) | ||
| Xeven -= (map->width - 1); | ||
| Xeven = ((Xeven % map->width) + map->width) % map->width; |
There was a problem hiding this comment.
Can you add a function for that please? Something like int positiveIntegerModulo(int,int) or see if your AI can come up with a better name. I'm worried about repeating the same value 3 times per line which at least makes review hard as there might be a C&P mistake somewhere
420fbe3 to
9694bea
Compare
Allow window resizingsplit to Allow window resizing #46