mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Restrict relative mouse mode to Wayland users (#15697)
This commit is contained in:
parent
282c81fe3a
commit
45c5ef8798
4 changed files with 25 additions and 2 deletions
|
@ -198,6 +198,9 @@ public:
|
||||||
or similar. */
|
or similar. */
|
||||||
virtual bool supportsTouchEvents() const { return false; }
|
virtual bool supportsTouchEvents() const { return false; }
|
||||||
|
|
||||||
|
//! Checks whether windowing uses the Wayland protocol.
|
||||||
|
virtual bool isUsingWayland() const { return false; }
|
||||||
|
|
||||||
//! Get the current color format of the window
|
//! Get the current color format of the window
|
||||||
/** \return Color format of the window. */
|
/** \return Color format of the window. */
|
||||||
virtual video::ECOLOR_FORMAT getColorFormat() const = 0;
|
virtual video::ECOLOR_FORMAT getColorFormat() const = 0;
|
||||||
|
|
|
@ -1248,6 +1248,15 @@ bool CIrrDeviceSDL::supportsTouchEvents() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Checks whether windowing uses the Wayland protocol.
|
||||||
|
bool CIrrDeviceSDL::isUsingWayland() const
|
||||||
|
{
|
||||||
|
if (!Window)
|
||||||
|
return false;
|
||||||
|
auto *name = SDL_GetCurrentVideoDriver();
|
||||||
|
return name && !strcmp(name, "wayland");
|
||||||
|
}
|
||||||
|
|
||||||
//! returns if window is active. if not, nothing need to be drawn
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
bool CIrrDeviceSDL::isWindowActive() const
|
bool CIrrDeviceSDL::isWindowActive() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,6 +96,9 @@ public:
|
||||||
//! Checks if the Irrlicht device supports touch events.
|
//! Checks if the Irrlicht device supports touch events.
|
||||||
bool supportsTouchEvents() const override;
|
bool supportsTouchEvents() const override;
|
||||||
|
|
||||||
|
//! Checks whether windowing uses the Wayland protocol.
|
||||||
|
bool isUsingWayland() const override;
|
||||||
|
|
||||||
//! Get the position of this window on screen
|
//! Get the position of this window on screen
|
||||||
core::position2di getWindowPosition() override;
|
core::position2di getWindowPosition() override;
|
||||||
|
|
||||||
|
|
|
@ -754,6 +754,7 @@ private:
|
||||||
f32 m_repeat_dig_time;
|
f32 m_repeat_dig_time;
|
||||||
f32 m_cache_cam_smoothing;
|
f32 m_cache_cam_smoothing;
|
||||||
|
|
||||||
|
bool m_enable_relative_mode = false;
|
||||||
bool m_invert_mouse;
|
bool m_invert_mouse;
|
||||||
bool m_enable_hotbar_mouse_wheel;
|
bool m_enable_hotbar_mouse_wheel;
|
||||||
bool m_invert_hotbar_mouse_wheel;
|
bool m_invert_hotbar_mouse_wheel;
|
||||||
|
@ -898,6 +899,11 @@ bool Game::startup(bool *kill,
|
||||||
|
|
||||||
m_first_loop_after_window_activation = true;
|
m_first_loop_after_window_activation = true;
|
||||||
|
|
||||||
|
// In principle we could always enable relative mouse mode, but it causes weird
|
||||||
|
// bugs on some setups (e.g. #14932), so we enable it only when it's required.
|
||||||
|
// That is: on Wayland, because it does not support mouse repositioning
|
||||||
|
m_enable_relative_mode = device->isUsingWayland();
|
||||||
|
|
||||||
g_client_translations->clear();
|
g_client_translations->clear();
|
||||||
|
|
||||||
// address can change if simple_singleplayer_mode
|
// address can change if simple_singleplayer_mode
|
||||||
|
@ -2349,8 +2355,10 @@ void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
|
||||||
Since Minetest has its own code to synthesize mouse events from touch events,
|
Since Minetest has its own code to synthesize mouse events from touch events,
|
||||||
this results in duplicated input. To avoid that, we don't enable relative
|
this results in duplicated input. To avoid that, we don't enable relative
|
||||||
mouse mode if we're in touchscreen mode. */
|
mouse mode if we're in touchscreen mode. */
|
||||||
if (cur_control)
|
if (cur_control) {
|
||||||
cur_control->setRelativeMode(!g_touchcontrols && !isMenuActive());
|
cur_control->setRelativeMode(m_enable_relative_mode &&
|
||||||
|
!g_touchcontrols && !isMenuActive());
|
||||||
|
}
|
||||||
|
|
||||||
if ((device->isWindowActive() && device->isWindowFocused()
|
if ((device->isWindowActive() && device->isWindowFocused()
|
||||||
&& !isMenuActive()) || input->isRandom()) {
|
&& !isMenuActive()) || input->isRandom()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue