Skip to content

Commit

Permalink
Add love.window.getPointer, returns a SDL_Window* as lightuserdata.
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Jan 9, 2024
1 parent ecd9b00 commit 6feedc8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modules/window/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class Window : public Module
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;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/window/sdl/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/window/sdl/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Window final : public love::window::Window
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;
Expand Down
7 changes: 7 additions & 0 deletions src/modules/window/wrap_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -688,6 +694,7 @@ static const luaL_Reg functions[] =
{ "isMinimized", w_isMinimized },
{ "showMessageBox", w_showMessageBox },
{ "requestAttention", w_requestAttention },
{ "getPointer", w_getPointer },
{ 0, 0 }
};

Expand Down

0 comments on commit 6feedc8

Please sign in to comment.