Rename scale to integer_scale

We will presumably have a fractional_scale soon
This commit is contained in:
Kovid Goyal
2024-03-21 12:03:23 +05:30
parent 2b6edbccbc
commit eb42ad3a2b
5 changed files with 24 additions and 24 deletions

View File

@@ -282,7 +282,7 @@ render_edges(_GLFWwindow *window) {
static bool static bool
create_shm_buffers(_GLFWwindow* window) { create_shm_buffers(_GLFWwindow* window) {
const unsigned scale = window->wl.scale >= 1 ? window->wl.scale : 1; const unsigned scale = window->wl.integer_scale >= 1 ? window->wl.integer_scale : 1;
const size_t vertical_width = decs.metrics.width, vertical_height = window->wl.height + decs.metrics.top; const size_t vertical_width = decs.metrics.width, vertical_height = window->wl.height + decs.metrics.top;
const size_t horizontal_height = decs.metrics.width, horizontal_width = window->wl.width + 2 * decs.metrics.width; const size_t horizontal_height = decs.metrics.width, horizontal_width = window->wl.width + 2 * decs.metrics.width;
@@ -371,7 +371,7 @@ ensure_csd_resources(_GLFWwindow *window) {
const bool size_changed = ( const bool size_changed = (
decs.for_window_state.width != window->wl.width || decs.for_window_state.width != window->wl.width ||
decs.for_window_state.height != window->wl.height || decs.for_window_state.height != window->wl.height ||
decs.for_window_state.scale != window->wl.scale || decs.for_window_state.scale != window->wl.integer_scale ||
!decs.mapping.data !decs.mapping.data
); );
const bool needs_update = focus_changed || size_changed || !decs.left.surface || decs.buffer_destroyed; const bool needs_update = focus_changed || size_changed || !decs.left.surface || decs.buffer_destroyed;
@@ -384,7 +384,7 @@ ensure_csd_resources(_GLFWwindow *window) {
decs.buffer_destroyed = false; decs.buffer_destroyed = false;
} }
int32_t x, y, scale = window->wl.scale < 1 ? 1 : window->wl.scale; int32_t x, y, scale = window->wl.integer_scale < 1 ? 1 : window->wl.integer_scale;
x = 0; y = -decs.metrics.top; x = 0; y = -decs.metrics.top;
if (!decs.top.surface) create_csd_surfaces(window, &decs.top); if (!decs.top.surface) create_csd_surfaces(window, &decs.top);
position_csd_surface(&decs.top, x, y, scale); position_csd_surface(&decs.top, x, y, scale);
@@ -409,7 +409,7 @@ ensure_csd_resources(_GLFWwindow *window) {
decs.for_window_state.width = window->wl.width; decs.for_window_state.width = window->wl.width;
decs.for_window_state.height = window->wl.height; decs.for_window_state.height = window->wl.height;
decs.for_window_state.scale = window->wl.scale; decs.for_window_state.scale = window->wl.integer_scale;
decs.for_window_state.focused = is_focused; decs.for_window_state.focused = is_focused;
return true; return true;
} }

6
glfw/wl_init.c vendored
View File

@@ -132,7 +132,7 @@ static void setCursor(GLFWCursorShape shape, _GLFWwindow* window)
struct wl_cursor* cursor; struct wl_cursor* cursor;
struct wl_cursor_image* image; struct wl_cursor_image* image;
struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_surface* surface = _glfw.wl.cursorSurface;
const int scale = window->wl.scale; const int scale = window->wl.integer_scale;
struct wl_cursor_theme *theme = glfw_wlc_theme_for_scale(scale); struct wl_cursor_theme *theme = glfw_wlc_theme_for_scale(scale);
if (!theme) return; if (!theme) return;
@@ -346,14 +346,14 @@ static void pointerHandleAxis(void* data UNUSED,
window->wl.axis_discrete_count.x--; window->wl.axis_discrete_count.x--;
return; return;
} }
x = -wl_fixed_to_double(value) * (window->wl.scale); x = -wl_fixed_to_double(value) * (window->wl.integer_scale);
} }
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
if (window->wl.axis_discrete_count.y) { if (window->wl.axis_discrete_count.y) {
window->wl.axis_discrete_count.y--; window->wl.axis_discrete_count.y--;
return; return;
} }
y = -wl_fixed_to_double(value) * (window->wl.scale); y = -wl_fixed_to_double(value) * (window->wl.integer_scale);
} }
_glfwInputScroll(window, x, y, 1, _glfw.wl.xkb.states.modifiers); _glfwInputScroll(window, x, y, 1, _glfw.wl.xkb.states.modifiers);

2
glfw/wl_platform.h vendored
View File

@@ -171,7 +171,7 @@ typedef struct _GLFWwindowWayland
// We need to track the monitors the window spans on to calculate the // We need to track the monitors the window spans on to calculate the
// optimal scaling factor. // optimal scaling factor.
int scale; int integer_scale;
bool initial_scale_notified; bool initial_scale_notified;
_GLFWmonitor** monitors; _GLFWmonitor** monitors;
int monitorsCount; int monitorsCount;

View File

@@ -172,7 +172,7 @@ _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
commit(); commit();
break; break;
case GLFW_IME_UPDATE_CURSOR_POSITION: { case GLFW_IME_UPDATE_CURSOR_POSITION: {
const int scale = w->wl.scale; const int scale = w->wl.integer_scale;
const int left = ev->cursor.left / scale, top = ev->cursor.top / scale, width = ev->cursor.width / scale, height = ev->cursor.height / scale; const int left = ev->cursor.left / scale, top = ev->cursor.top / scale, width = ev->cursor.width / scale, height = ev->cursor.height / scale;
if (left != last_cursor_left || top != last_cursor_top || width != last_cursor_width || height != last_cursor_height) { if (left != last_cursor_left || top != last_cursor_top || width != last_cursor_width || height != last_cursor_height) {
last_cursor_left = left; last_cursor_left = left;

30
glfw/wl_window.c vendored
View File

@@ -206,7 +206,7 @@ setCursorImage(_GLFWwindow* window, bool on_theme_change) {
struct wl_cursor_image* image = NULL; struct wl_cursor_image* image = NULL;
struct wl_buffer* buffer = NULL; struct wl_buffer* buffer = NULL;
struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_surface* surface = _glfw.wl.cursorSurface;
const int scale = window->wl.scale; const int scale = window->wl.integer_scale;
if (!_glfw.wl.pointer) return; if (!_glfw.wl.pointer) return;
if (cursorWayland->scale < 0) { if (cursorWayland->scale < 0) {
@@ -285,9 +285,9 @@ static bool checkScaleChange(_GLFWwindow* window)
} }
// Only change the framebuffer size if the scale changed. // Only change the framebuffer size if the scale changed.
if (scale != window->wl.scale) if (scale != window->wl.integer_scale)
{ {
window->wl.scale = scale; window->wl.integer_scale = scale;
wl_surface_set_buffer_scale(window->wl.surface, scale); wl_surface_set_buffer_scale(window->wl.surface, scale);
setCursorImage(window, false); setCursorImage(window, false);
return true; return true;
@@ -326,7 +326,7 @@ static void setOpaqueRegion(_GLFWwindow* window, bool commit_surface)
static void static void
resizeFramebuffer(_GLFWwindow* window) { resizeFramebuffer(_GLFWwindow* window) {
int scale = window->wl.scale; int scale = window->wl.integer_scale;
int scaledWidth = window->wl.width * scale; int scaledWidth = window->wl.width * scale;
int scaledHeight = window->wl.height * scale; int scaledHeight = window->wl.height * scale;
debug("Resizing framebuffer to: %dx%d at scale: %d\n", window->wl.width, window->wl.height, scale); debug("Resizing framebuffer to: %dx%d at scale: %d\n", window->wl.width, window->wl.height, scale);
@@ -368,9 +368,9 @@ dispatchChangesAfterConfigure(_GLFWwindow *window, int32_t width, int32_t height
} }
if (scale_changed) { if (scale_changed) {
debug("Scale changed to %d in dispatchChangesAfterConfigure\n", window->wl.scale); debug("Scale changed to %d in dispatchChangesAfterConfigure\n", window->wl.integer_scale);
if (!size_changed) resizeFramebuffer(window); if (!size_changed) resizeFramebuffer(window);
_glfwInputWindowContentScale(window, window->wl.scale, window->wl.scale); _glfwInputWindowContentScale(window, window->wl.integer_scale, window->wl.integer_scale);
} }
_glfwInputWindowDamage(window); _glfwInputWindowDamage(window);
@@ -420,9 +420,9 @@ static void surfaceHandleEnter(void *data,
window->wl.monitors[window->wl.monitorsCount++] = monitor; window->wl.monitors[window->wl.monitorsCount++] = monitor;
if (checkScaleChange(window)) { if (checkScaleChange(window)) {
debug("Scale changed to %d in surface enter event\n", window->wl.scale); debug("Scale changed to %d in surface enter event\n", window->wl.integer_scale);
resizeFramebuffer(window); resizeFramebuffer(window);
_glfwInputWindowContentScale(window, window->wl.scale, window->wl.scale); _glfwInputWindowContentScale(window, window->wl.integer_scale, window->wl.integer_scale);
ensure_csd_resources(window); ensure_csd_resources(window);
} }
} }
@@ -446,9 +446,9 @@ static void surfaceHandleLeave(void *data,
window->wl.monitors[--window->wl.monitorsCount] = NULL; window->wl.monitors[--window->wl.monitorsCount] = NULL;
if (checkScaleChange(window)) { if (checkScaleChange(window)) {
debug("Scale changed to %d in surface leave event\n", window->wl.scale); debug("Scale changed to %d in surface leave event\n", window->wl.integer_scale);
resizeFramebuffer(window); resizeFramebuffer(window);
_glfwInputWindowContentScale(window, window->wl.scale, window->wl.scale); _glfwInputWindowContentScale(window, window->wl.integer_scale, window->wl.integer_scale);
ensure_csd_resources(window); ensure_csd_resources(window);
} }
} }
@@ -495,7 +495,7 @@ static bool createSurface(_GLFWwindow* window,
window->wl.user_requested_content_size.width = wndconfig->width; window->wl.user_requested_content_size.width = wndconfig->width;
window->wl.user_requested_content_size.height = wndconfig->height; window->wl.user_requested_content_size.height = wndconfig->height;
window->wl.scale = scale; window->wl.integer_scale = scale;
if (!window->wl.transparent) if (!window->wl.transparent)
setOpaqueRegion(window, false); setOpaqueRegion(window, false);
@@ -1126,9 +1126,9 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
{ {
_glfwPlatformGetWindowSize(window, width, height); _glfwPlatformGetWindowSize(window, width, height);
if (width) if (width)
*width *= window->wl.scale; *width *= window->wl.integer_scale;
if (height) if (height)
*height *= window->wl.scale; *height *= window->wl.integer_scale;
} }
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
@@ -1152,9 +1152,9 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
float* xscale, float* yscale) float* xscale, float* yscale)
{ {
if (xscale) if (xscale)
*xscale = (float) window->wl.scale; *xscale = (float) window->wl.integer_scale;
if (yscale) if (yscale)
*yscale = (float) window->wl.scale; *yscale = (float) window->wl.integer_scale;
} }
monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED) monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)