Hello fellows. I faced some problems with the version of SDL2 (2.0.20) that I installed through apt on Ubuntu 22.04.
So following the installation instructions I installed version 2.31.0 through github. But I did so without removing the previous version.
Now, sdl2-config --version on the terminal shows that it is 2.31.0 but I think my programs are still using version 2.0.20.
Is it not advisable to install newer versions of software without first uninstalling the previous ones? Do I simply uninstall both versions and redo?
Can anyone help me out here? Thank you.
update: I uninstalled both the versions, then installed just 2.31.0. But programs still face the same problem they faced with version 2.0.20, namely: some inputs (mouse button up and down, some keys on keyboard) are being followed by the SDL_keymapchanged code. Any clues?
I don’t know what will happen if you have two versions installed. They will probably be installed at different locations, apt-get in /usr/lib, /usr/include, etc. and your manual install in /usr/local/lib, /usr/local/include, etc. so my guess is that you can uninstall the 2.0.20 version using apt-get without interfering with the 2.31.0 version.
I used SDL_GetVersion and the program still says version 2.0.20 eventhough I have uninstalled it. Even sdl2-config --version return 2.31.0.
Also I am using #include </usr/local/include/SDL2/SDL.h> (eventhough just <SDL2/SDL.h> was working jut fine)
Further, I checked usr/include and there is no SDL2 folder there.
what do you think?
I DID NOT uninstall the normal runtime package. Is that it?
Removing the runtime package fixed it. Now, the program runs on 2.31.0!
Thank you!
I just have one doubt. If you have the time…
In 2.0.20, since my program wasn’t working right, I made a simple program which just returns the event.type after SDL_PollEvent, to check exactly the problem.
with each mousebutton down, I would get 512, 1025, 772
with each mousebutton up, I would get 772, 1026, 772
some keys on the keyboard also would be wrapped in 772 (the code for SDL_KEYMAPCHANGED).
Now, that is largely fixed. Just that the mousebutton down input is still preceded by 512 (code for SDL_WINDOWEVENT).
Is this normal behaviour?
I tested this on my computers (Debian/X11, SDL 2.0.5 and SDL 2.29.2) and I don’t seem to get any SDL_WINDOWEVENT_TAKE_FOCUS events unless I click on the window borders. If I click on the title bar I get two such events each time.
I don’t fully understand how this event is meant to be used so I don’t know which behaviour is correct. You’re being “offered focus” but you already have focus so what’s the harm? It seems to be a Linux-only thing. You can probably just ignore it. I think most programs probably don’t handle this event. If you want to react to receiving focus you would use SDL_WINDOWEVENT_FOCUS_GAINED instead.
If you really are interested to know more about this event...
I swtiched from wayland to X11… and it works fine. I am crying.
Thank you for helping me
some rambling, I want to vent TT -
I spent the entire day trying to get everything working after installing from source. SDL2_ttf was giving me problems. When it did work finally, I realized that the window event (which was preceding SDL_MOUSEBUTTONDOWN), was about 1 in 20 times following the SDL_MOUSEBUTTONDOWN event, REPLACING what was coming after it (sometimes even one after the other for 10 times straight).
So, a simple mouse click often did not work because it wouldn’t detect a SDL_MOUSEBUTTONUP. And I needed to check for either a mouse button up or mouse motion event after a mouse button down, so I couldn’t just assume what would come after the button down. Although I see it could have been fixed by recording the x and y coordinates on mousebuttondown, and then comparing with the coordinates of the mouse cursor after the faulty window event to figure out whether it was supposed to be a mouse click, or drag.
All this when I could have made this small change. But I did end up learning a few things. That is something.