Wayland: Cleanup

Update naming and declarations to current standard.
This commit is contained in:
Camilla Löwy 2023-04-25 22:59:25 +02:00
parent 6b48f2be97
commit 3eaf1255b2

View File

@ -1315,47 +1315,47 @@ static void pointerHandleMotion(void* userData,
wl_fixed_t sy) wl_fixed_t sy)
{ {
_GLFWwindow* window = _glfw.wl.pointerFocus; _GLFWwindow* window = _glfw.wl.pointerFocus;
const char* cursorName = NULL;
double x, y;
if (!window) if (!window)
return; return;
if (window->cursorMode == GLFW_CURSOR_DISABLED) if (window->cursorMode == GLFW_CURSOR_DISABLED)
return; return;
x = wl_fixed_to_double(sx);
y = wl_fixed_to_double(sy); const double xpos = wl_fixed_to_double(sx);
window->wl.cursorPosX = x; const double ypos = wl_fixed_to_double(sy);
window->wl.cursorPosY = y; window->wl.cursorPosX = xpos;
window->wl.cursorPosY = ypos;
const char* cursorName = NULL;
switch (window->wl.decorations.focus) switch (window->wl.decorations.focus)
{ {
case GLFW_MAIN_WINDOW: case GLFW_MAIN_WINDOW:
_glfw.wl.cursorPreviousName = NULL; _glfw.wl.cursorPreviousName = NULL;
_glfwInputCursorPos(window, x, y); _glfwInputCursorPos(window, xpos, ypos);
return; return;
case GLFW_TOP_DECORATION: case GLFW_TOP_DECORATION:
if (y < GLFW_BORDER_SIZE) if (ypos < GLFW_BORDER_SIZE)
cursorName = "n-resize"; cursorName = "n-resize";
else else
cursorName = "left_ptr"; cursorName = "left_ptr";
break; break;
case GLFW_LEFT_DECORATION: case GLFW_LEFT_DECORATION:
if (y < GLFW_BORDER_SIZE) if (ypos < GLFW_BORDER_SIZE)
cursorName = "nw-resize"; cursorName = "nw-resize";
else else
cursorName = "w-resize"; cursorName = "w-resize";
break; break;
case GLFW_RIGHT_DECORATION: case GLFW_RIGHT_DECORATION:
if (y < GLFW_BORDER_SIZE) if (ypos < GLFW_BORDER_SIZE)
cursorName = "ne-resize"; cursorName = "ne-resize";
else else
cursorName = "e-resize"; cursorName = "e-resize";
break; break;
case GLFW_BOTTOM_DECORATION: case GLFW_BOTTOM_DECORATION:
if (x < GLFW_BORDER_SIZE) if (xpos < GLFW_BORDER_SIZE)
cursorName = "sw-resize"; cursorName = "sw-resize";
else if (x > window->wl.width + GLFW_BORDER_SIZE) else if (xpos > window->wl.width + GLFW_BORDER_SIZE)
cursorName = "se-resize"; cursorName = "se-resize";
else else
cursorName = "s-resize"; cursorName = "s-resize";
@ -1366,9 +1366,6 @@ static void pointerHandleMotion(void* userData,
if (_glfw.wl.cursorPreviousName != cursorName) if (_glfw.wl.cursorPreviousName != cursorName)
{ {
struct wl_buffer* buffer;
struct wl_cursor* cursor;
struct wl_cursor_image* image;
struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_surface* surface = _glfw.wl.cursorSurface;
struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
int scale = 1; int scale = 1;
@ -1381,17 +1378,16 @@ static void pointerHandleMotion(void* userData,
theme = _glfw.wl.cursorThemeHiDPI; theme = _glfw.wl.cursorThemeHiDPI;
} }
cursor = wl_cursor_theme_get_cursor(theme, name); struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName);
if (!cursor) if (!cursor)
return; return;
// TODO: handle animated cursors too. // TODO: handle animated cursors too.
image = cursor->images[0]; struct wl_cursor_image* image = cursor->images[0];
if (!image) if (!image)
return; return;
buffer = wl_cursor_image_get_buffer(image); struct wl_buffer* buffer = wl_cursor_image_get_buffer(image);
if (!buffer) if (!buffer)
return; return;
@ -1401,10 +1397,10 @@ static void pointerHandleMotion(void* userData,
image->hotspot_y / scale); image->hotspot_y / scale);
wl_surface_set_buffer_scale(surface, scale); wl_surface_set_buffer_scale(surface, scale);
wl_surface_attach(surface, buffer, 0, 0); wl_surface_attach(surface, buffer, 0, 0);
wl_surface_damage(surface, 0, 0, wl_surface_damage(surface, 0, 0, image->width, image->height);
image->width, image->height);
wl_surface_commit(surface); wl_surface_commit(surface);
_glfw.wl.cursorPreviousName = name;
_glfw.wl.cursorPreviousName = cursorName;
} }
} }