浏览代码

Fix SDL_Hints location

Ivan Savenko 2 年之前
父节点
当前提交
e23dfec6c5

+ 0 - 13
client/CMT.cpp

@@ -313,19 +313,6 @@ int main(int argc, char * argv[])
 		logGlobal->info("Initializing screen and sound handling: %d ms", pomtime.getDiff());
 	}
 
-#ifdef VCMI_MAC
-	// Ctrl+click should be treated as a right click on Mac OS X
-	SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1");
-#endif
-
-#ifdef SDL_HINT_MOUSE_TOUCH_EVENTS
-	if(settings["general"]["userRelativePointer"].Bool())
-	{
-		SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
-		SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
-	}
-#endif
-
 #ifndef VCMI_NO_THREADED_LOAD
 	//we can properly play intro only in the main thread, so we have to move loading to the separate thread
 	boost::thread loading(init);

+ 1 - 1
client/eventsSDL/InputHandler.cpp

@@ -29,7 +29,7 @@
 #include "../../lib/CConfigHandler.h"
 
 #include <SDL_events.h>
-
+#include <SDL_hints.h>
 
 InputHandler::InputHandler()
 	: mouseHandler(std::make_unique<InputSourceMouse>())

+ 9 - 0
client/eventsSDL/InputSourceKeyboard.cpp

@@ -18,6 +18,15 @@
 #include "../gui/ShortcutHandler.h"
 
 #include <SDL_events.h>
+#include <SDL_hints.h>
+
+InputSourceKeyboard::InputSourceKeyboard()
+{
+#ifdef VCMI_MAC
+	// Ctrl+click should be treated as a right click on Mac OS X
+	SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1");
+#endif
+}
 
 void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key)
 {

+ 2 - 0
client/eventsSDL/InputSourceKeyboard.h

@@ -15,6 +15,8 @@ struct SDL_KeyboardEvent;
 class InputSourceKeyboard
 {
 public:
+	InputSourceKeyboard();
+
 	void handleEventKeyDown(const SDL_KeyboardEvent & current);
 	void handleEventKeyUp(const SDL_KeyboardEvent & current);
 };

+ 6 - 0
client/eventsSDL/InputSourceTouch.cpp

@@ -21,11 +21,17 @@
 
 #include <SDL_events.h>
 #include <SDL_render.h>
+#include <SDL_hints.h>
 
 InputSourceTouch::InputSourceTouch()
 	: multifinger(false)
 	, isPointerRelativeMode(settings["general"]["userRelativePointer"].Bool())
 {
+	if(isPointerRelativeMode)
+	{
+		SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
+		SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
+	}
 }
 
 void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfinger)

+ 1 - 1
client/lobby/SelectionTab.cpp

@@ -277,7 +277,7 @@ void SelectionTab::clickLeft(tribool down, bool previousState)
 		}
 #ifdef VCMI_IOS
 		// focus input field if clicked inside it
-		else if(inputName && inputName->active && inputNameRect.isInside(GH.getCursorPosition()))
+		else if(inputName && inputName->isActive() && inputNameRect.isInside(GH.getCursorPosition()))
 			inputName->giveFocus();
 #endif
 	}