Fix warnings, update RGFW, fix msvc errors (make sure windows macro _WIN32 is correct)
This commit is contained in:
parent
46c1d60e05
commit
389b92c7dd
301
src/external/RGFW.h
vendored
301
src/external/RGFW.h
vendored
|
|
@ -38,6 +38,7 @@
|
||||||
#define RGFW_OPENGL_ES2 - (optional) use OpenGL ES (version 2)
|
#define RGFW_OPENGL_ES2 - (optional) use OpenGL ES (version 2)
|
||||||
#define RGFW_OPENGL_ES3 - (optional) use OpenGL ES (version 3)
|
#define RGFW_OPENGL_ES3 - (optional) use OpenGL ES (version 3)
|
||||||
#define RGFW_DIRECTX - (optional) use directX for the rendering backend (rather than opengl) (windows only, defaults to opengl for unix)
|
#define RGFW_DIRECTX - (optional) use directX for the rendering backend (rather than opengl) (windows only, defaults to opengl for unix)
|
||||||
|
#define RGFW_WEBGPU - (optional) use webGPU for rendering (Web ONLY)
|
||||||
#define RGFW_NO_API - (optional) don't use any rendering API (no opengl, no vulkan, no directX)
|
#define RGFW_NO_API - (optional) don't use any rendering API (no opengl, no vulkan, no directX)
|
||||||
|
|
||||||
#define RGFW_LINK_EGL (optional) (windows only) if EGL is being used, if EGL functions should be defined dymanically (using GetProcAddress)
|
#define RGFW_LINK_EGL (optional) (windows only) if EGL is being used, if EGL functions should be defined dymanically (using GetProcAddress)
|
||||||
|
|
@ -84,6 +85,9 @@
|
||||||
Rob Rohan -> X11 bugs and missing features, MacOS/Cocoa fixing memory issues/bugs
|
Rob Rohan -> X11 bugs and missing features, MacOS/Cocoa fixing memory issues/bugs
|
||||||
AICDG (@THISISAGOODNAME) -> vulkan support (example)
|
AICDG (@THISISAGOODNAME) -> vulkan support (example)
|
||||||
@Easymode -> support, testing/debugging, bug fixes and reviews
|
@Easymode -> support, testing/debugging, bug fixes and reviews
|
||||||
|
Joshua Rowe (omnisci3nce) - bug fix, review (macOS)
|
||||||
|
@lesleyrs -> bug fix, review (OpenGL)
|
||||||
|
Nick Porcino (meshula) - testing, organization, review (MacOS, examples)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if _MSC_VER
|
#if _MSC_VER
|
||||||
|
|
@ -192,7 +196,7 @@
|
||||||
typedef u32 b32;
|
typedef u32 b32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RGFW_TRUE 1
|
#define RGFW_TRUE (!(0))
|
||||||
#define RGFW_FALSE 0
|
#define RGFW_FALSE 0
|
||||||
|
|
||||||
/* thse OS macros looks better & are standardized */
|
/* thse OS macros looks better & are standardized */
|
||||||
|
|
@ -201,7 +205,7 @@
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#define RGFW_WEBASM
|
#define RGFW_WEBASM
|
||||||
|
|
||||||
#ifndef RGFW_NO_API
|
#if !defined(RGFW_NO_API) && !defined(RGFW_WEBGPU)
|
||||||
#define RGFW_OPENGL
|
#define RGFW_OPENGL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -211,6 +215,10 @@
|
||||||
|
|
||||||
#include <emscripten/html5.h>
|
#include <emscripten/html5.h>
|
||||||
#include <emscripten/key_codes.h>
|
#include <emscripten/key_codes.h>
|
||||||
|
|
||||||
|
#ifdef RGFW_WEBGPU
|
||||||
|
#include <emscripten/html5_webgpu.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RGFW_X11) && defined(__APPLE__)
|
#if defined(RGFW_X11) && defined(__APPLE__)
|
||||||
|
|
@ -276,11 +284,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RGFW_EGL
|
#ifdef RGFW_EGL
|
||||||
#if defined(__APPLE__)
|
|
||||||
#warning EGL is not supported for Cocoa, switching back to the native opengl api
|
|
||||||
#undef RGFW_EGL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#elif defined(RGFW_OSMESA)
|
#elif defined(RGFW_OSMESA)
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
|
|
@ -578,7 +581,13 @@ typedef struct RGFW_window_src {
|
||||||
void* image;
|
void* image;
|
||||||
#endif
|
#endif
|
||||||
#elif defined(RGFW_WEBASM)
|
#elif defined(RGFW_WEBASM)
|
||||||
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx;
|
#ifdef RGFW_WEBGPU
|
||||||
|
WGPUInstance ctx;
|
||||||
|
WGPUDevice device;
|
||||||
|
WGPUQueue queue;
|
||||||
|
#else
|
||||||
|
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
} RGFW_window_src;
|
} RGFW_window_src;
|
||||||
|
|
||||||
|
|
@ -611,10 +620,17 @@ typedef struct RGFW_window {
|
||||||
/** * @defgroup Window_management
|
/** * @defgroup Window_management
|
||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* the class name for X11 and WinAPI. apps with the same class will be grouped by the WM
|
||||||
|
* by default the class name will == the root window's name
|
||||||
|
*/
|
||||||
|
RGFWDEF void RGFW_setClassName(char* name);
|
||||||
|
|
||||||
/*! this has to be set before createWindow is called, else the fulscreen size is used */
|
/*! this has to be set before createWindow is called, else the fulscreen size is used */
|
||||||
RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resized (by RGFW) */
|
RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resized (by RGFW) */
|
||||||
|
|
||||||
RGFW_window* RGFW_createWindow(
|
RGFWDEF RGFW_window* RGFW_createWindow(
|
||||||
const char* name, /* name of the window */
|
const char* name, /* name of the window */
|
||||||
RGFW_rect rect, /* rect of window */
|
RGFW_rect rect, /* rect of window */
|
||||||
u16 args /* extra arguments (NULL / (u16)0 means no args used)*/
|
u16 args /* extra arguments (NULL / (u16)0 means no args used)*/
|
||||||
|
|
@ -635,7 +651,7 @@ RGFWDEF RGFW_area RGFW_getScreenSize(void);
|
||||||
although you still need some way to tell RGFW to process events eg. `RGFW_window_checkEvents`
|
although you still need some way to tell RGFW to process events eg. `RGFW_window_checkEvents`
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RGFW_Event* RGFW_window_checkEvent(RGFW_window* win); /*!< check current event (returns a pointer to win->event or NULL if there is no event)*/
|
RGFWDEF RGFW_Event* RGFW_window_checkEvent(RGFW_window* win); /*!< check current event (returns a pointer to win->event or NULL if there is no event)*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
for RGFW_window_eventWait and RGFW_window_checkEvents
|
for RGFW_window_eventWait and RGFW_window_checkEvents
|
||||||
|
|
@ -706,7 +722,7 @@ RGFWDEF void RGFW_window_setName(RGFW_window* win,
|
||||||
char* name
|
char* name
|
||||||
);
|
);
|
||||||
|
|
||||||
void RGFW_window_setIcon(RGFW_window* win, /*!< source window */
|
RGFWDEF void RGFW_window_setIcon(RGFW_window* win, /*!< source window */
|
||||||
u8* icon /*!< icon bitmap */,
|
u8* icon /*!< icon bitmap */,
|
||||||
RGFW_area a /*!< width and height of the bitmap*/,
|
RGFW_area a /*!< width and height of the bitmap*/,
|
||||||
i32 channels /*!< how many channels the bitmap has (rgb : 3, rgba : 4) */
|
i32 channels /*!< how many channels the bitmap has (rgb : 3, rgba : 4) */
|
||||||
|
|
@ -1178,9 +1194,9 @@ int main() {
|
||||||
static : ar rcs RGFW.a RGFW.o
|
static : ar rcs RGFW.a RGFW.o
|
||||||
shared :
|
shared :
|
||||||
windows:
|
windows:
|
||||||
gcc -shared RGFW.o -lopengl32 -lshell32 -lgdi32 -o RGFW.dll
|
gcc -shared RGFW.o -lwinmm -lopengl32 -lshell32 -lgdi32 -o RGFW.dll
|
||||||
linux:
|
linux:
|
||||||
gcc -shared RGFW.o -lX11 -lXcursor -lGL -o RGFW.so
|
gcc -shared RGFW.o -lX11 -lXcursor -lGL -lXrandr -o RGFW.so
|
||||||
macos:
|
macos:
|
||||||
gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
|
gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
|
||||||
*/
|
*/
|
||||||
|
|
@ -1404,7 +1420,7 @@ char RGFW_keyCodeToChar(u32 keycode, b8 shift) {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '`', '0', '1', '2', '3', '4', '5', '6', '7', '8',
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '`', '0', '1', '2', '3', '4', '5', '6', '7', '8',
|
||||||
'9', '-', '=', 0, '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
'9', '-', '=', 0, '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', ',', '/', '[', ']', ';', '\n', '\'', '\\',
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', ',', '/', '[', ']', ';', '\n', '\'', '\\',
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', '*', '-', '1', '2', '3', '3', '5', '6', '7', '8', '9', '0', '\n'
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', '*', '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\n'
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char mapCaps[] = {
|
static const char mapCaps[] = {
|
||||||
|
|
@ -1609,9 +1625,6 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) {
|
||||||
if (args & RGFW_FULLSCREEN)
|
if (args & RGFW_FULLSCREEN)
|
||||||
rect = RGFW_RECT(0, 0, screenR.w, screenR.h);
|
rect = RGFW_RECT(0, 0, screenR.w, screenR.h);
|
||||||
|
|
||||||
if (args & RGFW_CENTER)
|
|
||||||
rect = RGFW_RECT((screenR.w - rect.w) / 2, (screenR.h - rect.h) / 2, rect.w, rect.h);
|
|
||||||
|
|
||||||
/* set and init the new window's data */
|
/* set and init the new window's data */
|
||||||
win->r = rect;
|
win->r = rect;
|
||||||
win->event.inFocus = 1;
|
win->event.inFocus = 1;
|
||||||
|
|
@ -1627,7 +1640,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) {
|
||||||
void RGFW_window_scaleToMonitor(RGFW_window* win) {
|
void RGFW_window_scaleToMonitor(RGFW_window* win) {
|
||||||
RGFW_monitor monitor = RGFW_window_getMonitor(win);
|
RGFW_monitor monitor = RGFW_window_getMonitor(win);
|
||||||
|
|
||||||
RGFW_window_resize(win, RGFW_AREA(((u32) monitor.scaleX) * win->r.w, ((u32) monitor.scaleX) * win->r.h));
|
RGFW_window_resize(win, RGFW_AREA((u32)(monitor.scaleX * (float)win->r.w), (u32)(monitor.scaleX * (float)win->r.h)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1637,6 +1650,16 @@ RGFW_window* RGFW_root = NULL;
|
||||||
#define RGFW_HOLD_MOUSE (1L<<2) /*!< hold the moues still */
|
#define RGFW_HOLD_MOUSE (1L<<2) /*!< hold the moues still */
|
||||||
#define RGFW_MOUSE_LEFT (1L<<3) /* if mouse left the window */
|
#define RGFW_MOUSE_LEFT (1L<<3) /* if mouse left the window */
|
||||||
|
|
||||||
|
#ifdef RGFW_MACOS
|
||||||
|
RGFWDEF void RGFW_window_cocoaSetLayer(RGFW_window* win, void* layer);
|
||||||
|
RGFWDEF void* RGFW_cocoaGetLayer(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char* RGFW_className = NULL;
|
||||||
|
void RGFW_setClassName(char* name) {
|
||||||
|
RGFW_className = name;
|
||||||
|
}
|
||||||
|
|
||||||
void RGFW_clipboardFree(char* str) { RGFW_FREE(str); }
|
void RGFW_clipboardFree(char* str) { RGFW_FREE(str); }
|
||||||
|
|
||||||
RGFW_keyState RGFW_mouseButtons[5] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} };
|
RGFW_keyState RGFW_mouseButtons[5] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} };
|
||||||
|
|
@ -1960,7 +1983,7 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
|
||||||
|
|
||||||
size_t index = (sizeof(attribs) / sizeof(attribs[0])) - 13;
|
size_t index = (sizeof(attribs) / sizeof(attribs[0])) - 13;
|
||||||
|
|
||||||
#define RGFW_GL_ADD_ATTRIB(attrib, attVal) \
|
#define RGFW_GL_ADD_ATTRIB(attrib, attVal) \
|
||||||
if (attVal) { \
|
if (attVal) { \
|
||||||
attribs[index] = attrib;\
|
attribs[index] = attrib;\
|
||||||
attribs[index + 1] = attVal;\
|
attribs[index + 1] = attVal;\
|
||||||
|
|
@ -2073,6 +2096,8 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
|
||||||
|
|
||||||
#ifdef RGFW_WINDOWS
|
#ifdef RGFW_WINDOWS
|
||||||
win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType) win->src.hdc);
|
win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType) win->src.hdc);
|
||||||
|
#elif defined(RGFW_MACOS)
|
||||||
|
win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType)0);
|
||||||
#else
|
#else
|
||||||
win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType) win->src.display);
|
win->src.EGL_display = eglGetDisplay((EGLNativeDisplayType) win->src.display);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2104,8 +2129,15 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
eglChooseConfig(win->src.EGL_display, egl_config, &config, 1, &numConfigs);
|
eglChooseConfig(win->src.EGL_display, egl_config, &config, 1, &numConfigs);
|
||||||
|
|
||||||
|
#if defined(RGFW_MACOS)
|
||||||
|
void* layer = RGFW_cocoaGetLayer();
|
||||||
|
|
||||||
win->src.EGL_surface = eglCreateWindowSurface(win->src.EGL_display, config, (EGLNativeWindowType) win->src.window, NULL);
|
RGFW_window_cocoaSetLayer(win, layer);
|
||||||
|
|
||||||
|
win->src.EGL_surface = eglCreateWindowSurface(win->src.EGL_display, config, (EGLNativeWindowType) layer, NULL);
|
||||||
|
#else
|
||||||
|
win->src.EGL_surface = eglCreateWindowSurface(win->src.EGL_display, config, (EGLNativeWindowType) win->src.window, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
EGLint attribs[] = {
|
EGLint attribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION,
|
EGL_CONTEXT_CLIENT_VERSION,
|
||||||
|
|
@ -2322,7 +2354,7 @@ Start of Linux / Unix defines
|
||||||
|
|
||||||
u8 RGFW_mouseIconSrc[] = { XC_arrow, XC_left_ptr, XC_xterm, XC_crosshair, XC_hand2, XC_sb_h_double_arrow, XC_sb_v_double_arrow, XC_bottom_left_corner, XC_bottom_right_corner, XC_fleur, XC_X_cursor};
|
u8 RGFW_mouseIconSrc[] = { XC_arrow, XC_left_ptr, XC_xterm, XC_crosshair, XC_hand2, XC_sb_h_double_arrow, XC_sb_v_double_arrow, XC_bottom_left_corner, XC_bottom_right_corner, XC_fleur, XC_X_cursor};
|
||||||
/*atoms needed for drag and drop*/
|
/*atoms needed for drag and drop*/
|
||||||
Atom XdndAware, XdndTypeList, XdndSelection, XdndEnter, XdndPosition, XdndStatus, XdndLeave, XdndDrop, XdndFinished, XdndActionCopy, XdndActionMove, XdndActionLink, XdndActionAsk, XdndActionPrivate;
|
Atom XdndAware, XdndTypeList, XdndSelection, XdndEnter, XdndPosition, XdndStatus, XdndLeave, XdndDrop, XdndFinished, XdndActionCopy, XtextPlain, XtextUriList;
|
||||||
|
|
||||||
Atom wm_delete_window = 0;
|
Atom wm_delete_window = 0;
|
||||||
|
|
||||||
|
|
@ -2504,7 +2536,8 @@ Start of Linux / Unix defines
|
||||||
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
|
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
|
||||||
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLES, &samples);
|
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLES, &samples);
|
||||||
|
|
||||||
if ((best_fbc < 0 || samp_buf) && (samples == RGFW_SAMPLES || best_fbc == -1)) {
|
if ((!(args & RGFW_TRANSPARENT_WINDOW) || vi->depth == 32) &&
|
||||||
|
(best_fbc < 0 || samp_buf) && (samples == RGFW_SAMPLES || best_fbc == -1)) {
|
||||||
best_fbc = i;
|
best_fbc = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2520,11 +2553,6 @@ Start of Linux / Unix defines
|
||||||
XVisualInfo* vi = glXGetVisualFromFBConfig((Display*) win->src.display, bestFbc);
|
XVisualInfo* vi = glXGetVisualFromFBConfig((Display*) win->src.display, bestFbc);
|
||||||
|
|
||||||
XFree(fbc);
|
XFree(fbc);
|
||||||
|
|
||||||
if (args & RGFW_TRANSPARENT_WINDOW) {
|
|
||||||
XMatchVisualInfo((Display*) win->src.display, DefaultScreen((Display*) win->src.display), 32, TrueColor, vi); /*!< for RGBA backgrounds*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
XVisualInfo viNorm;
|
XVisualInfo viNorm;
|
||||||
|
|
||||||
|
|
@ -2563,9 +2591,13 @@ Start of Linux / Unix defines
|
||||||
// In your .desktop app, if you set the property
|
// In your .desktop app, if you set the property
|
||||||
// StartupWMClass=RGFW that will assoicate the launcher icon
|
// StartupWMClass=RGFW that will assoicate the launcher icon
|
||||||
// with your application - robrohan
|
// with your application - robrohan
|
||||||
|
|
||||||
|
if (RGFW_className == NULL)
|
||||||
|
RGFW_className = (char*)name;
|
||||||
|
|
||||||
XClassHint *hint = XAllocClassHint();
|
XClassHint *hint = XAllocClassHint();
|
||||||
assert(hint != NULL);
|
assert(hint != NULL);
|
||||||
hint->res_class = (char*)"RGFW";
|
hint->res_class = (char*)RGFW_className;
|
||||||
hint->res_name = (char*)name; // just use the window name as the app name
|
hint->res_name = (char*)name; // just use the window name as the app name
|
||||||
XSetClassHint((Display*) win->src.display, win->src.window, hint);
|
XSetClassHint((Display*) win->src.display, win->src.window, hint);
|
||||||
XFree(hint);
|
XFree(hint);
|
||||||
|
|
@ -2609,6 +2641,11 @@ Start of Linux / Unix defines
|
||||||
RGFW_window_scaleToMonitor(win);
|
RGFW_window_scaleToMonitor(win);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (args & RGFW_CENTER) {
|
||||||
|
RGFW_area screenR = RGFW_getScreenSize();
|
||||||
|
RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
|
||||||
|
}
|
||||||
|
|
||||||
if (args & RGFW_NO_RESIZE) { /* make it so the user can't resize the window*/
|
if (args & RGFW_NO_RESIZE) { /* make it so the user can't resize the window*/
|
||||||
XSizeHints* sh = XAllocSizeHints();
|
XSizeHints* sh = XAllocSizeHints();
|
||||||
sh->flags = (1L << 4) | (1L << 5);
|
sh->flags = (1L << 4) | (1L << 5);
|
||||||
|
|
@ -2646,7 +2683,6 @@ Start of Linux / Unix defines
|
||||||
if (args & RGFW_ALLOW_DND) { /* init drag and drop atoms and turn on drag and drop for this window */
|
if (args & RGFW_ALLOW_DND) { /* init drag and drop atoms and turn on drag and drop for this window */
|
||||||
win->_winArgs |= RGFW_ALLOW_DND;
|
win->_winArgs |= RGFW_ALLOW_DND;
|
||||||
|
|
||||||
XdndAware = XInternAtom((Display*) win->src.display, "XdndAware", False);
|
|
||||||
XdndTypeList = XInternAtom((Display*) win->src.display, "XdndTypeList", False);
|
XdndTypeList = XInternAtom((Display*) win->src.display, "XdndTypeList", False);
|
||||||
XdndSelection = XInternAtom((Display*) win->src.display, "XdndSelection", False);
|
XdndSelection = XInternAtom((Display*) win->src.display, "XdndSelection", False);
|
||||||
|
|
||||||
|
|
@ -2660,15 +2696,16 @@ Start of Linux / Unix defines
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
XdndActionCopy = XInternAtom((Display*) win->src.display, "XdndActionCopy", False);
|
XdndActionCopy = XInternAtom((Display*) win->src.display, "XdndActionCopy", False);
|
||||||
XdndActionMove = XInternAtom((Display*) win->src.display, "XdndActionMove", False);
|
|
||||||
XdndActionLink = XInternAtom((Display*) win->src.display, "XdndActionLink", False);
|
XtextUriList = XInternAtom((Display*) win->src.display, "text/uri-list", False);
|
||||||
XdndActionAsk = XInternAtom((Display*) win->src.display, "XdndActionAsk", False);
|
XtextPlain = XInternAtom((Display*) win->src.display, "text/plain", False);
|
||||||
XdndActionPrivate = XInternAtom((Display*) win->src.display, "XdndActionPrivate", False);
|
|
||||||
const Atom version = 5;
|
XdndAware = XInternAtom((Display*) win->src.display, "XdndAware", False);
|
||||||
|
const u8 version = 5;
|
||||||
|
|
||||||
XChangeProperty((Display*) win->src.display, (Window) win->src.window,
|
XChangeProperty((Display*) win->src.display, (Window) win->src.window,
|
||||||
XdndAware, 4, 32,
|
XdndAware, 4, 32,
|
||||||
PropModeReplace, (u8*) &version, 1); /*!< turns on drag and drop */
|
PropModeReplace, &version, 1); /*!< turns on drag and drop */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RGFW_EGL
|
#ifdef RGFW_EGL
|
||||||
|
|
@ -2716,17 +2753,16 @@ Start of Linux / Unix defines
|
||||||
return RGFWMouse;
|
return RGFWMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct XDND {
|
|
||||||
long source, version;
|
|
||||||
i32 format;
|
|
||||||
} XDND; /*!< data structure for xdnd events */
|
|
||||||
XDND xdnd;
|
|
||||||
|
|
||||||
int xAxis = 0, yAxis = 0;
|
int xAxis = 0, yAxis = 0;
|
||||||
|
|
||||||
RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
|
RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
|
||||||
assert(win != NULL);
|
assert(win != NULL);
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
long source, version;
|
||||||
|
i32 format;
|
||||||
|
} xdnd;
|
||||||
|
|
||||||
if (win->event.type == 0)
|
if (win->event.type == 0)
|
||||||
RGFW_resetKey();
|
RGFW_resetKey();
|
||||||
|
|
||||||
|
|
@ -2893,13 +2929,16 @@ Start of Linux / Unix defines
|
||||||
|
|
||||||
win->event.droppedFilesCount = 0;
|
win->event.droppedFilesCount = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
much of this event (drag and drop code) is source from glfw
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((win->_winArgs & RGFW_ALLOW_DND) == 0)
|
if ((win->_winArgs & RGFW_ALLOW_DND) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
XEvent reply = { ClientMessage };
|
||||||
|
reply.xclient.window = xdnd.source;
|
||||||
|
reply.xclient.format = 32;
|
||||||
|
reply.xclient.data.l[0] = (long) win->src.window;
|
||||||
|
reply.xclient.data.l[1] = 0;
|
||||||
|
reply.xclient.data.l[2] = None;
|
||||||
|
|
||||||
if (E.xclient.message_type == XdndEnter) {
|
if (E.xclient.message_type == XdndEnter) {
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
Atom* formats;
|
Atom* formats;
|
||||||
|
|
@ -2944,28 +2983,11 @@ Start of Linux / Unix defines
|
||||||
formats = real_formats;
|
formats = real_formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 i;
|
unsigned long i;
|
||||||
for (i = 0; i < (u32)count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
char* name = XGetAtomName((Display*) win->src.display, formats[i]);
|
if (formats[i] == XtextUriList || formats[i] == XtextPlain) {
|
||||||
|
xdnd.format = formats[i];
|
||||||
char* links[2] = { (char*) (const char*) "text/uri-list", (char*) (const char*) "text/plain" };
|
break;
|
||||||
for (; 1; name++) {
|
|
||||||
u32 j;
|
|
||||||
for (j = 0; j < 2; j++) {
|
|
||||||
if (*links[j] != *name) {
|
|
||||||
links[j] = (char*) (const char*) "\1";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*links[j] == '\0' && *name == '\0')
|
|
||||||
xdnd.format = formats[i];
|
|
||||||
|
|
||||||
if (*links[j] != '\0' && *links[j] != '\1')
|
|
||||||
links[j]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*name == '\0')
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2994,13 +3016,8 @@ Start of Linux / Unix defines
|
||||||
win->event.point.x = xpos;
|
win->event.point.x = xpos;
|
||||||
win->event.point.y = ypos;
|
win->event.point.y = ypos;
|
||||||
|
|
||||||
XEvent reply = { ClientMessage };
|
|
||||||
reply.xclient.window = xdnd.source;
|
reply.xclient.window = xdnd.source;
|
||||||
reply.xclient.message_type = XdndStatus;
|
reply.xclient.message_type = XdndStatus;
|
||||||
reply.xclient.format = 32;
|
|
||||||
reply.xclient.data.l[0] = (long) win->src.window;
|
|
||||||
reply.xclient.data.l[2] = 0;
|
|
||||||
reply.xclient.data.l[3] = 0;
|
|
||||||
|
|
||||||
if (xdnd.format) {
|
if (xdnd.format) {
|
||||||
reply.xclient.data.l[1] = 1;
|
reply.xclient.data.l[1] = 1;
|
||||||
|
|
@ -3035,12 +3052,6 @@ Start of Linux / Unix defines
|
||||||
time);
|
time);
|
||||||
} else if (xdnd.version >= 2) {
|
} else if (xdnd.version >= 2) {
|
||||||
XEvent reply = { ClientMessage };
|
XEvent reply = { ClientMessage };
|
||||||
reply.xclient.window = xdnd.source;
|
|
||||||
reply.xclient.message_type = XdndFinished;
|
|
||||||
reply.xclient.format = 32;
|
|
||||||
reply.xclient.data.l[0] = (long) win->src.window;
|
|
||||||
reply.xclient.data.l[1] = 0;
|
|
||||||
reply.xclient.data.l[2] = None;
|
|
||||||
|
|
||||||
XSendEvent((Display*) win->src.display, xdnd.source,
|
XSendEvent((Display*) win->src.display, xdnd.source,
|
||||||
False, NoEventMask, &reply);
|
False, NoEventMask, &reply);
|
||||||
|
|
@ -3125,11 +3136,7 @@ Start of Linux / Unix defines
|
||||||
XFree(data);
|
XFree(data);
|
||||||
|
|
||||||
if (xdnd.version >= 2) {
|
if (xdnd.version >= 2) {
|
||||||
XEvent reply = { ClientMessage };
|
|
||||||
reply.xclient.window = xdnd.source;
|
|
||||||
reply.xclient.message_type = XdndFinished;
|
reply.xclient.message_type = XdndFinished;
|
||||||
reply.xclient.format = 32;
|
|
||||||
reply.xclient.data.l[0] = (long) win->src.window;
|
|
||||||
reply.xclient.data.l[1] = result;
|
reply.xclient.data.l[1] = result;
|
||||||
reply.xclient.data.l[2] = XdndActionCopy;
|
reply.xclient.data.l[2] = XdndActionCopy;
|
||||||
|
|
||||||
|
|
@ -3480,7 +3487,7 @@ Start of Linux / Unix defines
|
||||||
*size = sizeN;
|
*size = sizeN;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
almost all of this function is sourced from GLFW
|
almost all of this function is sourced from GLFW
|
||||||
|
|
@ -3520,9 +3527,6 @@ Start of Linux / Unix defines
|
||||||
XEvent reply = { SelectionNotify };
|
XEvent reply = { SelectionNotify };
|
||||||
reply.xselection.property = 0;
|
reply.xselection.property = 0;
|
||||||
|
|
||||||
const Atom formats[] = { UTF8_STRING, XA_STRING };
|
|
||||||
const i32 formatCount = sizeof(formats) / sizeof(formats[0]);
|
|
||||||
|
|
||||||
if (request->target == TARGETS) {
|
if (request->target == TARGETS) {
|
||||||
const Atom targets[] = { TARGETS,
|
const Atom targets[] = { TARGETS,
|
||||||
MULTIPLE,
|
MULTIPLE,
|
||||||
|
|
@ -3552,15 +3556,7 @@ Start of Linux / Unix defines
|
||||||
|
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
for (i = 0; i < (u32)count; i += 2) {
|
for (i = 0; i < (u32)count; i += 2) {
|
||||||
i32 j;
|
if (targets[i] == UTF8_STRING || targets[i] == XA_STRING) {
|
||||||
|
|
||||||
for (j = 0; j < formatCount; j++) {
|
|
||||||
if (targets[i] == formats[j])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j < formatCount)
|
|
||||||
{
|
|
||||||
XChangeProperty((Display*) RGFW_root->src.display,
|
XChangeProperty((Display*) RGFW_root->src.display,
|
||||||
request->requestor,
|
request->requestor,
|
||||||
targets[i + 1],
|
targets[i + 1],
|
||||||
|
|
@ -3728,31 +3724,53 @@ Start of Linux / Unix defines
|
||||||
|
|
||||||
Display* display = XOpenDisplay(NULL);
|
Display* display = XOpenDisplay(NULL);
|
||||||
|
|
||||||
monitor.rect = RGFW_RECT(0, 0, DisplayWidth(display, screen), DisplayHeight(display, screen));
|
RGFW_area size = RGFW_getScreenSize();
|
||||||
monitor.physW = (monitor.rect.w * 25.4f / 96.f);
|
|
||||||
monitor.physH = (monitor.rect.h * 25.4f / 96.f);
|
|
||||||
|
|
||||||
strncpy(monitor.name, DisplayString(display), 128);
|
monitor.rect = RGFW_RECT(0, 0, size.w, size.h);
|
||||||
|
monitor.physW = DisplayWidthMM(display, screen);
|
||||||
|
monitor.physH = DisplayHeightMM(display, screen);
|
||||||
|
|
||||||
XGetSystemContentScale(display, &monitor.scaleX, &monitor.scaleY);
|
XGetSystemContentScale(display, &monitor.scaleX, &monitor.scaleY);
|
||||||
|
|
||||||
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(display, RootWindow(display, screen));
|
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(display, RootWindow(display, screen));
|
||||||
|
|
||||||
XRRCrtcInfo* ci = NULL;
|
XRRCrtcInfo* ci = NULL;
|
||||||
int crtc = 0;
|
int crtc = screen;
|
||||||
|
|
||||||
if (sr->ncrtc > crtc) {
|
if (sr->ncrtc > crtc) {
|
||||||
ci = XRRGetCrtcInfo(display, sr, sr->crtcs[crtc]);
|
ci = XRRGetCrtcInfo(display, sr, sr->crtcs[crtc]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ci == NULL) {
|
if (ci == NULL) {
|
||||||
|
float dpi_width = round((double)monitor.rect.w/(((double)monitor.physW)/25.4));
|
||||||
|
float dpi_height = round((double)monitor.rect.h/(((double)monitor.physH)/25.4));
|
||||||
|
|
||||||
|
monitor.scaleX = (float) (dpi_width) / (float) 96;
|
||||||
|
monitor.scaleY = (float) (dpi_height) / (float) 96;
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XRROutputInfo* info = XRRGetOutputInfo (display, sr, sr->outputs[screen]);
|
||||||
|
monitor.physW = info->mm_width;
|
||||||
|
monitor.physH = info->mm_height;
|
||||||
|
|
||||||
monitor.rect.x = ci->x;
|
monitor.rect.x = ci->x;
|
||||||
monitor.rect.y = ci->y;
|
monitor.rect.y = ci->y;
|
||||||
|
monitor.rect.w = ci->width;
|
||||||
|
monitor.rect.h = ci->height;
|
||||||
|
|
||||||
|
float dpi_width = round((double)monitor.rect.w/(((double)monitor.physW)/25.4));
|
||||||
|
float dpi_height = round((double)monitor.rect.h/(((double)monitor.physH)/25.4));
|
||||||
|
|
||||||
|
monitor.scaleX = (float) (dpi_width) / (float) 96;
|
||||||
|
monitor.scaleY = (float) (dpi_height) / (float) 96;
|
||||||
|
|
||||||
|
if (monitor.scaleX > 1 && monitor.scaleX < 1.1)
|
||||||
|
monitor.scaleX = 1;
|
||||||
|
|
||||||
|
if (monitor.scaleY > 1 && monitor.scaleY < 1.1)
|
||||||
|
monitor.scaleY = 1;
|
||||||
|
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
|
|
@ -4150,9 +4168,6 @@ RGFW_Event RGFW_eventPipe_pop(RGFW_window* win) {
|
||||||
|
|
||||||
if (win->src.eventLen >= 0)
|
if (win->src.eventLen >= 0)
|
||||||
ev = win->src.events[win->src.eventLen];
|
ev = win->src.events[win->src.eventLen];
|
||||||
else {
|
|
||||||
printf("H2\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ev;
|
return ev;
|
||||||
}
|
}
|
||||||
|
|
@ -4675,6 +4690,10 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
|
||||||
decoration_manager, win->src.xdg_toplevel);
|
decoration_manager, win->src.xdg_toplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args & RGFW_CENTER) {
|
||||||
|
RGFW_area screenR = RGFW_getScreenSize();
|
||||||
|
RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
|
||||||
|
}
|
||||||
|
|
||||||
if (args & RGFW_OPENGL_SOFTWARE)
|
if (args & RGFW_OPENGL_SOFTWARE)
|
||||||
setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);
|
setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);
|
||||||
|
|
@ -5000,8 +5019,6 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
|
||||||
#define OEMRESOURCE
|
#define OEMRESOURCE
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
__declspec(dllimport) int __stdcall WideCharToMultiByte( UINT CodePage, DWORD dwFlags, const WCHAR* lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
|
||||||
|
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
@ -5009,6 +5026,10 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <shellscalingapi.h>
|
#include <shellscalingapi.h>
|
||||||
|
|
||||||
|
#include <winuser.h>
|
||||||
|
|
||||||
|
__declspec(dllimport) int __stdcall WideCharToMultiByte( UINT CodePage, DWORD dwFlags, const WCHAR* lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
||||||
|
|
||||||
#ifndef RGFW_NO_XINPUT
|
#ifndef RGFW_NO_XINPUT
|
||||||
typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
|
typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
|
||||||
PFN_XInputGetState XInputGetStateSRC = NULL;
|
PFN_XInputGetState XInputGetStateSRC = NULL;
|
||||||
|
|
@ -5226,13 +5247,14 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGFW_releaseCursor(RGFW_window* win) {
|
void RGFW_releaseCursor(RGFW_window* win) {
|
||||||
|
RGFW_UNUSED(win);
|
||||||
ClipCursor(NULL);
|
ClipCursor(NULL);
|
||||||
const RAWINPUTDEVICE id = { 0x01, 0x02, RIDEV_REMOVE, NULL };
|
const RAWINPUTDEVICE id = { 0x01, 0x02, RIDEV_REMOVE, NULL };
|
||||||
RegisterRawInputDevices(&id, 1, sizeof(id));
|
RegisterRawInputDevices(&id, 1, sizeof(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGFW_captureCursor(RGFW_window* win, RGFW_rect rect) {
|
void RGFW_captureCursor(RGFW_window* win, RGFW_rect rect) {
|
||||||
RGFW_UNUSED(win)
|
RGFW_UNUSED(win); RGFW_UNUSED(rect);
|
||||||
|
|
||||||
RECT clipRect;
|
RECT clipRect;
|
||||||
GetClientRect(win->src.window, &clipRect);
|
GetClientRect(win->src.window, &clipRect);
|
||||||
|
|
@ -5254,6 +5276,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
if (RGFW_Shcore_dll == NULL) {
|
if (RGFW_Shcore_dll == NULL) {
|
||||||
RGFW_Shcore_dll = LoadLibraryA("shcore.dll");
|
RGFW_Shcore_dll = LoadLibraryA("shcore.dll");
|
||||||
GetDpiForMonitorSRC = (PFN_GetDpiForMonitor)(void*)GetProcAddress(RGFW_Shcore_dll, "GetDpiForMonitor");
|
GetDpiForMonitorSRC = (PFN_GetDpiForMonitor)(void*)GetProcAddress(RGFW_Shcore_dll, "GetDpiForMonitor");
|
||||||
|
SetProcessDPIAware();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -5288,7 +5311,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
WNDCLASSA Class = { };
|
WNDCLASSA Class = { };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Class.lpszClassName = name;
|
if (RGFW_className == NULL)
|
||||||
|
RGFW_className = (char*)name;
|
||||||
|
|
||||||
|
Class.lpszClassName = RGFW_className;
|
||||||
Class.hInstance = inh;
|
Class.hInstance = inh;
|
||||||
Class.hCursor = LoadCursor(NULL, IDC_ARROW);
|
Class.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
Class.lpfnWndProc = WndProc;
|
Class.lpfnWndProc = WndProc;
|
||||||
|
|
@ -5502,6 +5528,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
RGFW_window_scaleToMonitor(win);
|
RGFW_window_scaleToMonitor(win);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (args & RGFW_CENTER) {
|
||||||
|
RGFW_area screenR = RGFW_getScreenSize();
|
||||||
|
RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RGFW_EGL
|
#ifdef RGFW_EGL
|
||||||
if ((args & RGFW_NO_INIT_API) == 0)
|
if ((args & RGFW_NO_INIT_API) == 0)
|
||||||
RGFW_createOpenGLContext(win);
|
RGFW_createOpenGLContext(win);
|
||||||
|
|
@ -6102,7 +6133,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
|
|
||||||
if (GetDpiForMonitor != NULL) {
|
if (GetDpiForMonitor != NULL) {
|
||||||
u32 x, y;
|
u32 x, y;
|
||||||
GetDpiForMonitor(src, MDT_ANGULAR_DPI, &x, &y);
|
GetDpiForMonitor(src, MDT_EFFECTIVE_DPI, &x, &y);
|
||||||
|
|
||||||
monitor.scaleX = (float) (x) / (float) USER_DEFAULT_SCREEN_DPI;
|
monitor.scaleX = (float) (x) / (float) USER_DEFAULT_SCREEN_DPI;
|
||||||
monitor.scaleY = (float) (y) / (float) USER_DEFAULT_SCREEN_DPI;
|
monitor.scaleY = (float) (y) / (float) USER_DEFAULT_SCREEN_DPI;
|
||||||
}
|
}
|
||||||
|
|
@ -7104,7 +7136,6 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
id fileURL = objc_msgSend_arr(fileURLs, sel_registerName("objectAtIndex:"), i);
|
id fileURL = objc_msgSend_arr(fileURLs, sel_registerName("objectAtIndex:"), i);
|
||||||
const char *filePath = ((const char* (*)(id, SEL))objc_msgSend)(fileURL, sel_registerName("UTF8String"));
|
const char *filePath = ((const char* (*)(id, SEL))objc_msgSend)(fileURL, sel_registerName("UTF8String"));
|
||||||
// printf("File: %s\n", filePath);
|
|
||||||
strncpy(win->event.droppedFiles[i], filePath, RGFW_MAX_PATH);
|
strncpy(win->event.droppedFiles[i], filePath, RGFW_MAX_PATH);
|
||||||
win->event.droppedFiles[i][RGFW_MAX_PATH - 1] = '\0';
|
win->event.droppedFiles[i][RGFW_MAX_PATH - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
@ -7208,6 +7239,16 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RGFW_window_cocoaSetLayer(RGFW_window* win, void* layer) {
|
||||||
|
objc_msgSend_void_id(win->src.view, sel_registerName("setLayer"), layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* RGFW_cocoaGetLayer(void) {
|
||||||
|
return objc_msgSend_class(objc_getClass("CAMetalLayer"), sel_registerName("layer"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NSPasteboardType const NSPasteboardTypeURL = "public.url";
|
NSPasteboardType const NSPasteboardTypeURL = "public.url";
|
||||||
NSPasteboardType const NSPasteboardTypeFileURL = "public.file-url";
|
NSPasteboardType const NSPasteboardTypeFileURL = "public.file-url";
|
||||||
|
|
||||||
|
|
@ -7263,6 +7304,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
NSString* str = NSString_stringWithUTF8String(name);
|
NSString* str = NSString_stringWithUTF8String(name);
|
||||||
objc_msgSend_void_id(win->src.window, sel_registerName("setTitle:"), str);
|
objc_msgSend_void_id(win->src.window, sel_registerName("setTitle:"), str);
|
||||||
|
|
||||||
|
#ifdef RGFW_EGL
|
||||||
|
if ((args & RGFW_NO_INIT_API) == 0)
|
||||||
|
RGFW_createOpenGLContext(win);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RGFW_OPENGL
|
#ifdef RGFW_OPENGL
|
||||||
if ((args & RGFW_NO_INIT_API) == 0) {
|
if ((args & RGFW_NO_INIT_API) == 0) {
|
||||||
void* attrs = RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE);
|
void* attrs = RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE);
|
||||||
|
|
@ -7329,6 +7375,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
RGFW_window_scaleToMonitor(win);
|
RGFW_window_scaleToMonitor(win);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (args & RGFW_CENTER) {
|
||||||
|
RGFW_area screenR = RGFW_getScreenSize();
|
||||||
|
RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2));
|
||||||
|
}
|
||||||
|
|
||||||
if (args & RGFW_HIDE_MOUSE)
|
if (args & RGFW_HIDE_MOUSE)
|
||||||
RGFW_window_showMouse(win, 0);
|
RGFW_window_showMouse(win, 0);
|
||||||
|
|
||||||
|
|
@ -7935,6 +7986,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGFW_releaseCursor(RGFW_window* win) {
|
void RGFW_releaseCursor(RGFW_window* win) {
|
||||||
|
RGFW_UNUSED(win);
|
||||||
CGAssociateMouseAndMouseCursorPosition(1);
|
CGAssociateMouseAndMouseCursorPosition(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7994,13 +8046,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
monitor.rect = RGFW_RECT((int) bounds.origin.x, (int) bounds.origin.y, (int) bounds.size.width, (int) bounds.size.height);
|
monitor.rect = RGFW_RECT((int) bounds.origin.x, (int) bounds.origin.y, (int) bounds.size.width, (int) bounds.size.height);
|
||||||
|
|
||||||
CGSize screenSizeMM = CGDisplayScreenSize(display);
|
CGSize screenSizeMM = CGDisplayScreenSize(display);
|
||||||
monitor.physW = screenSizeMM.width / 25.4;
|
monitor.physW = screenSizeMM.width;
|
||||||
monitor.physH = screenSizeMM.height / 25.4;
|
monitor.physH = screenSizeMM.height;
|
||||||
|
|
||||||
monitor.scaleX = (monitor.rect.w / (screenSizeMM.width)) / 2.6;
|
monitor.scaleX = ((monitor.rect.w / (screenSizeMM.width / 25.4)) / 96) + 0.25;
|
||||||
monitor.scaleY = (monitor.rect.h / (screenSizeMM.height)) / 2.6;
|
monitor.scaleY = ((monitor.rect.h / (screenSizeMM.height / 25.4)) / 96) + 0.25;
|
||||||
|
|
||||||
snprintf(monitor.name, 128, "%i %i %i", CGDisplayModelNumber(display), CGDisplayVendorNumber(display), CGDisplaySerialNumber(display));
|
|
||||||
|
|
||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
|
|
@ -8090,6 +8140,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
#if defined(RGFW_OPENGL)
|
#if defined(RGFW_OPENGL)
|
||||||
|
|
||||||
NSOpenGLContext_setValues(win->src.ctx, &swapInterval, 222);
|
NSOpenGLContext_setValues(win->src.ctx, &swapInterval, 222);
|
||||||
|
#else
|
||||||
|
RGFW_UNUSED(swapInterval);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -8506,6 +8558,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
|
||||||
|
|
||||||
RGFW_window* win = RGFW_window_basic_init(rect, args);
|
RGFW_window* win = RGFW_window_basic_init(rect, args);
|
||||||
|
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
EmscriptenWebGLContextAttributes attrs;
|
EmscriptenWebGLContextAttributes attrs;
|
||||||
attrs.alpha = EM_TRUE;
|
attrs.alpha = EM_TRUE;
|
||||||
attrs.depth = EM_TRUE;
|
attrs.depth = EM_TRUE;
|
||||||
|
|
@ -8534,6 +8587,11 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
|
||||||
#ifdef LEGACY_GL_EMULATION
|
#ifdef LEGACY_GL_EMULATION
|
||||||
EM_ASM("Module.useWebGL = true; GLImmediate.init();");
|
EM_ASM("Module.useWebGL = true; GLImmediate.init();");
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
win->src.ctx = wgpuCreateInstance(NULL);
|
||||||
|
win->src.device = emscripten_webgpu_get_device();
|
||||||
|
win->src.queue = wgpuDeviceGetQueue(win->src.device);
|
||||||
|
#endif
|
||||||
|
|
||||||
emscripten_set_canvas_element_size("#canvas", rect.w, rect.h);
|
emscripten_set_canvas_element_size("#canvas", rect.w, rect.h);
|
||||||
emscripten_set_window_title(name);
|
emscripten_set_window_title(name);
|
||||||
|
|
@ -8829,16 +8887,20 @@ void RGFW_window_swapBuffers(RGFW_window* win) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
emscripten_webgl_commit_frame();
|
emscripten_webgl_commit_frame();
|
||||||
|
#endif
|
||||||
emscripten_sleep(0);
|
emscripten_sleep(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
|
void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
if (win == NULL)
|
if (win == NULL)
|
||||||
emscripten_webgl_make_context_current(0);
|
emscripten_webgl_make_context_current(0);
|
||||||
else
|
else
|
||||||
emscripten_webgl_make_context_current(win->src.ctx);
|
emscripten_webgl_make_context_current(win->src.ctx);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef RGFW_EGL
|
#ifndef RGFW_EGL
|
||||||
|
|
@ -8846,7 +8908,9 @@ void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) { RGFW_UNUSED(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void RGFW_window_close(RGFW_window* win) {
|
void RGFW_window_close(RGFW_window* win) {
|
||||||
emscripten_webgl_destroy_context(win->src.ctx);
|
#ifndef RGFW_WEBGPU
|
||||||
|
emscripten_webgl_destroy_context(win->src.ctx);
|
||||||
|
#endif
|
||||||
|
|
||||||
free(win);
|
free(win);
|
||||||
}
|
}
|
||||||
|
|
@ -8875,11 +8939,12 @@ u64 RGFW_getTime(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGFW_releaseCursor(RGFW_window* win) {
|
void RGFW_releaseCursor(RGFW_window* win) {
|
||||||
|
RGFW_UNUSED(win);
|
||||||
emscripten_exit_pointerlock();
|
emscripten_exit_pointerlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) {
|
void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) {
|
||||||
RGFW_UNUSED(win)
|
RGFW_UNUSED(win); RGFW_UNUSED(r);
|
||||||
|
|
||||||
emscripten_request_pointerlock("#canvas", 1);
|
emscripten_request_pointerlock("#canvas", 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,16 @@ void CloseWindow(void);
|
||||||
|
|
||||||
#define RGFW_IMPLEMENTATION
|
#define RGFW_IMPLEMENTATION
|
||||||
|
|
||||||
#if defined(__WIN32) || defined(__WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define Rectangle rectangle_win32
|
#define Rectangle rectangle_win32
|
||||||
#define CloseWindow CloseWindow_win32
|
#define CloseWindow CloseWindow_win32
|
||||||
#define ShowCursor __imp_ShowCursor
|
#define ShowCursor __imp_ShowCursor
|
||||||
#define _APISETSTRING_
|
#define _APISETSTRING_
|
||||||
|
|
||||||
|
#undef MAX_PATH
|
||||||
|
|
||||||
|
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
@ -76,15 +80,16 @@ void CloseWindow(void);
|
||||||
#define Size NSSIZE
|
#define Size NSSIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
|
|
||||||
|
|
||||||
#include "../external/RGFW.h"
|
#include "../external/RGFW.h"
|
||||||
|
|
||||||
#if defined(__WIN32) || defined(__WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#undef DrawText
|
#undef DrawText
|
||||||
#undef ShowCursor
|
#undef ShowCursor
|
||||||
#undef CloseWindow
|
#undef CloseWindow
|
||||||
#undef Rectangle
|
#undef Rectangle
|
||||||
|
|
||||||
|
#undef MAX_PATH
|
||||||
|
#define MAX_PATH 1025
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@
|
||||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void *hModule, void *lpFilename, unsigned long nSize);
|
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void *hModule, void *lpFilename, unsigned long nSize);
|
||||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(void *hModule, void *lpFilename, unsigned long nSize);
|
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(void *hModule, void *lpFilename, unsigned long nSize);
|
||||||
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, void *widestr, int cchwide, void *str, int cbmb, void *defchar, int *used_default);
|
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, void *widestr, int cchwide, void *str, int cbmb, void *defchar, int *used_default);
|
||||||
unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
__declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||||
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user