replace uses of SDL_Window with RenWindow (#1319)
Since Renwindow contains our instance of SDL_Window we can use this to simplify future logic to create separate window instances
This commit is contained in:
parent
81776b1c19
commit
bebef68d97
|
@ -7,6 +7,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include "api.h"
|
||||
#include "../rencache.h"
|
||||
#include "../renwindow.h"
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
|
@ -36,8 +37,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
extern SDL_Window *window;
|
||||
|
||||
extern RenWindow window_renderer;
|
||||
|
||||
static const char* button_name(int button) {
|
||||
switch (button) {
|
||||
|
@ -76,7 +76,7 @@ static SDL_HitTestResult SDLCALL hit_test(SDL_Window *window, const SDL_Point *p
|
|||
const int controls_width = hit_info->controls_width;
|
||||
int w, h;
|
||||
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSize(window_renderer.window, &w, &h);
|
||||
|
||||
if (pt->y < hit_info->title_height &&
|
||||
#if RESIZE_FROM_TOP
|
||||
|
@ -326,7 +326,7 @@ top:
|
|||
return 3;
|
||||
|
||||
case SDL_FINGERDOWN:
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSize(window_renderer.window, &w, &h);
|
||||
|
||||
lua_pushstring(L, "touchpressed");
|
||||
lua_pushinteger(L, (lua_Integer)(e.tfinger.x * w));
|
||||
|
@ -335,7 +335,7 @@ top:
|
|||
return 4;
|
||||
|
||||
case SDL_FINGERUP:
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSize(window_renderer.window, &w, &h);
|
||||
|
||||
lua_pushstring(L, "touchreleased");
|
||||
lua_pushinteger(L, (lua_Integer)(e.tfinger.x * w));
|
||||
|
@ -351,7 +351,7 @@ top:
|
|||
e.tfinger.dx += event_plus.tfinger.dx;
|
||||
e.tfinger.dy += event_plus.tfinger.dy;
|
||||
}
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowSize(window_renderer.window, &w, &h);
|
||||
|
||||
lua_pushstring(L, "touchmoved");
|
||||
lua_pushinteger(L, (lua_Integer)(e.tfinger.x * w));
|
||||
|
@ -415,7 +415,7 @@ static int f_set_cursor(lua_State *L) {
|
|||
|
||||
static int f_set_window_title(lua_State *L) {
|
||||
const char *title = luaL_checkstring(L, 1);
|
||||
SDL_SetWindowTitle(window, title);
|
||||
SDL_SetWindowTitle(window_renderer.window, title);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -425,39 +425,39 @@ enum { WIN_NORMAL, WIN_MINIMIZED, WIN_MAXIMIZED, WIN_FULLSCREEN };
|
|||
|
||||
static int f_set_window_mode(lua_State *L) {
|
||||
int n = luaL_checkoption(L, 1, "normal", window_opts);
|
||||
SDL_SetWindowFullscreen(window,
|
||||
SDL_SetWindowFullscreen(window_renderer.window,
|
||||
n == WIN_FULLSCREEN ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
if (n == WIN_NORMAL) { SDL_RestoreWindow(window); }
|
||||
if (n == WIN_MAXIMIZED) { SDL_MaximizeWindow(window); }
|
||||
if (n == WIN_MINIMIZED) { SDL_MinimizeWindow(window); }
|
||||
if (n == WIN_NORMAL) { SDL_RestoreWindow(window_renderer.window); }
|
||||
if (n == WIN_MAXIMIZED) { SDL_MaximizeWindow(window_renderer.window); }
|
||||
if (n == WIN_MINIMIZED) { SDL_MinimizeWindow(window_renderer.window); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int f_set_window_bordered(lua_State *L) {
|
||||
int bordered = lua_toboolean(L, 1);
|
||||
SDL_SetWindowBordered(window, bordered);
|
||||
SDL_SetWindowBordered(window_renderer.window, bordered);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int f_set_window_hit_test(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
SDL_SetWindowHitTest(window, NULL, NULL);
|
||||
SDL_SetWindowHitTest(window_renderer.window, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
window_hit_info->title_height = luaL_checknumber(L, 1);
|
||||
window_hit_info->controls_width = luaL_checknumber(L, 2);
|
||||
window_hit_info->resize_border = luaL_checknumber(L, 3);
|
||||
SDL_SetWindowHitTest(window, hit_test, window_hit_info);
|
||||
SDL_SetWindowHitTest(window_renderer.window, hit_test, window_hit_info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int f_get_window_size(lua_State *L) {
|
||||
int x, y, w, h;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
SDL_GetWindowPosition(window, &x, &y);
|
||||
SDL_GetWindowSize(window_renderer.window, &w, &h);
|
||||
SDL_GetWindowPosition(window_renderer.window, &x, &y);
|
||||
lua_pushinteger(L, w);
|
||||
lua_pushinteger(L, h);
|
||||
lua_pushinteger(L, x);
|
||||
|
@ -471,22 +471,22 @@ static int f_set_window_size(lua_State *L) {
|
|||
double h = luaL_checknumber(L, 2);
|
||||
double x = luaL_checknumber(L, 3);
|
||||
double y = luaL_checknumber(L, 4);
|
||||
SDL_SetWindowSize(window, w, h);
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
SDL_SetWindowSize(window_renderer.window, w, h);
|
||||
SDL_SetWindowPosition(window_renderer.window, x, y);
|
||||
ren_resize_window();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int f_window_has_focus(lua_State *L) {
|
||||
unsigned flags = SDL_GetWindowFlags(window);
|
||||
unsigned flags = SDL_GetWindowFlags(window_renderer.window);
|
||||
lua_pushboolean(L, flags & SDL_WINDOW_INPUT_FOCUS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int f_get_window_mode(lua_State *L) {
|
||||
unsigned flags = SDL_GetWindowFlags(window);
|
||||
unsigned flags = SDL_GetWindowFlags(window_renderer.window);
|
||||
if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||
lua_pushstring(L, "fullscreen");
|
||||
} else if (flags & SDL_WINDOW_MINIMIZED) {
|
||||
|
@ -524,8 +524,8 @@ static int f_raise_window(lua_State *L) {
|
|||
to allow the window to be focused. Also on wayland the raise window event
|
||||
may not always be obeyed.
|
||||
*/
|
||||
SDL_SetWindowInputFocus(window);
|
||||
SDL_RaiseWindow(window);
|
||||
SDL_SetWindowInputFocus(window_renderer.window);
|
||||
SDL_RaiseWindow(window_renderer.window);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -901,7 +901,7 @@ static int f_fuzzy_match(lua_State *L) {
|
|||
|
||||
static int f_set_window_opacity(lua_State *L) {
|
||||
double n = luaL_checknumber(L, 1);
|
||||
int r = SDL_SetWindowOpacity(window, n);
|
||||
int r = SDL_SetWindowOpacity(window_renderer.window, n);
|
||||
lua_pushboolean(L, r > -1);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
SDL_Window *window;
|
||||
static SDL_Window *window;
|
||||
|
||||
static double get_scale(void) {
|
||||
#ifndef __APPLE__
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define MAX_LOADABLE_GLYPHSETS 1024
|
||||
#define SUBPIXEL_BITMAPS_CACHED 3
|
||||
|
||||
static RenWindow window_renderer = {0};
|
||||
RenWindow window_renderer = {0};
|
||||
static FT_Library library;
|
||||
|
||||
// draw_rect_surface is used as a 1x1 surface to simplify ren_draw_rect with blending
|
||||
|
|
Loading…
Reference in New Issue