Functions to get and set OS Window size

This commit is contained in:
Kovid Goyal
2021-07-25 12:58:58 +05:30
parent 2e01c1f37e
commit 3d9b52fbc2
4 changed files with 67 additions and 1 deletions

View File

@@ -481,6 +481,16 @@ make_os_window_context_current(OSWindow *w) {
}
}
void
get_os_window_size(OSWindow *os_window, int *w, int *h, int *fw, int *fh) {
if (w && h) glfwGetWindowSize(os_window->handle, w, h);
if (fw && fh) glfwGetFramebufferSize(os_window->handle, fw, fh);
}
void
set_os_window_size(OSWindow *os_window, int x, int y) {
glfwSetWindowSize(os_window->handle, x, y);
}
static inline void
get_window_content_scale(GLFWwindow *w, float *xscale, float *yscale, double *xdpi, double *ydpi) {
@@ -508,6 +518,11 @@ get_window_dpi(GLFWwindow *w, double *x, double *y) {
get_window_content_scale(w, &xscale, &yscale, x, y);
}
void
get_os_window_content_scale(OSWindow *os_window, double *xdpi, double *ydpi, float *xscale, float *yscale) {
get_window_content_scale(os_window->handle, xscale, yscale, xdpi, ydpi);
}
static void
set_os_window_dpi(OSWindow *w) {
get_window_dpi(w->handle, &w->logical_dpi_x, &w->logical_dpi_y);
@@ -1253,7 +1268,6 @@ cocoa_window_id(PyObject UNUSED *self, PyObject *os_wid) {
return NULL;
#endif
}
static PyObject*
get_primary_selection(PYNOARG) {
if (glfwGetPrimarySelectionString) {