Skip to content

Commit

Permalink
Wayland: Don’t reload the cursor on every pointer motion
Browse files Browse the repository at this point in the history
Previously, any pointer motion in the window decorations when using the
fallback implementation would obtain the wl_cursor again, and do the
attach danse for no benefit.

This will ultimately allow animated cursors to not reset to the first
frame on motion, once these will be implemented.
  • Loading branch information
linkmauve committed Nov 21, 2019
1 parent b5d4f24 commit a9f674e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ static void setCursor(_GLFWwindow* window, const char* name)
wl_surface_damage(surface, 0, 0,
image->width, image->height);
wl_surface_commit(surface);
_glfw.wl.cursorPreviousName = name;
}

static void pointerHandleMotion(void* data,
Expand All @@ -178,7 +179,7 @@ static void pointerHandleMotion(void* data,
wl_fixed_t sy)
{
_GLFWwindow* window = _glfw.wl.pointerFocus;
const char* cursorName;
const char* cursorName = NULL;

if (!window)
return;
Expand Down Expand Up @@ -227,7 +228,8 @@ static void pointerHandleMotion(void* data,
default:
assert(0);
}
setCursor(window, cursorName);
if (_glfw.wl.cursorPreviousName != cursorName)
setCursor(window, cursorName);
}

static void pointerHandleButton(void* data,
Expand Down
1 change: 1 addition & 0 deletions src/wl_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ typedef struct _GLFWlibraryWayland
struct wl_cursor_theme* cursorTheme;
struct wl_cursor_theme* cursorThemeHiDPI;
struct wl_surface* cursorSurface;
const char* cursorPreviousName;
int cursorTimerfd;
uint32_t serial;

Expand Down

0 comments on commit a9f674e

Please sign in to comment.