Browse Source

Add love.window.getPointer, returns a SDL_Window* as lightuserdata.

Sasha Szpakowski 1 year ago
parent
commit
6feedc8222

+ 1 - 1
src/modules/window/Window.h

@@ -217,7 +217,7 @@ public:
 	virtual double fromPixels(double x) const = 0;
 	virtual void fromPixels(double px, double py, double &wx, double &wy) const = 0;
 
-	virtual const void *getHandle() const = 0;
+	virtual void *getHandle() const = 0;
 
 	virtual bool showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow) = 0;
 	virtual int showMessageBox(const MessageBoxData &data) = 0;

+ 1 - 1
src/modules/window/sdl/Window.cpp

@@ -1405,7 +1405,7 @@ void Window::fromPixels(double px, double py, double &wx, double &wy) const
 	wy = py / scale;
 }
 
-const void *Window::getHandle() const
+void *Window::getHandle() const
 {
 	return window;
 }

+ 1 - 1
src/modules/window/sdl/Window.h

@@ -123,7 +123,7 @@ public:
 	double fromPixels(double x) const override;
 	void fromPixels(double px, double py, double &wx, double &wy) const override;
 
-	const void *getHandle() const override;
+	void *getHandle() const override;
 
 	bool showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow) override;
 	int showMessageBox(const MessageBoxData &data) override;

+ 7 - 0
src/modules/window/wrap_Window.cpp

@@ -647,6 +647,12 @@ int w_requestAttention(lua_State *L)
 	return 0;
 }
 
+int w_getPointer(lua_State *L)
+{
+	lua_pushlightuserdata(L, instance()->getHandle());
+	return 1;
+}
+
 static const luaL_Reg functions[] =
 {
 	{ "getDisplayCount", w_getDisplayCount },
@@ -688,6 +694,7 @@ static const luaL_Reg functions[] =
 	{ "isMinimized", w_isMinimized },
 	{ "showMessageBox", w_showMessageBox },
 	{ "requestAttention", w_requestAttention },
+	{ "getPointer", w_getPointer },
 	{ 0, 0 }
 };