aboutsummaryrefslogtreecommitdiff
path: root/wayland.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-28 18:35:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-28 18:35:47 +0000
commit0dd37f0a364fc36284dad17e8fb1345714261a4a (patch)
tree36367aa234c01ba2a0010e9917d1c9e344a1972b /wayland.c
parentinput: pointer_button: apply same workaround as in pointer_motion (diff)
terminal: use the 'text' xcursor pointer whenever selection is possible
Diffstat (limited to 'wayland.c')
-rw-r--r--wayland.c71
1 files changed, 41 insertions, 30 deletions
diff --git a/wayland.c b/wayland.c
index c7720404..1a5cc5f9 100644
--- a/wayland.c
+++ b/wayland.c
@@ -28,6 +28,9 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
+static bool wayl_reload_cursor_theme(
+ struct wayland *wayl, const struct terminal *term);
+
static void
shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
{
@@ -792,44 +795,24 @@ wayl_win_destroy(struct wl_window *win)
}
bool
-wayl_reload_cursor_theme(struct wayland *wayl, struct terminal *term)
+wayl_cursor_set(struct wayland *wayl, const struct terminal *term)
{
- if (wayl->pointer.size == 0)
- return true;
+ if (wayl->pointer.theme == NULL)
+ return false;
- if (wayl->pointer.theme != NULL) {
- wl_cursor_theme_destroy(wayl->pointer.theme);
- wayl->pointer.theme = NULL;
- wayl->pointer.cursor = NULL;
+ if (wayl->moused != term) {
+ /* This terminal doesn't have mouse focus */
+ return true;
}
- LOG_DBG("reloading cursor theme: %s@%d",
- wayl->pointer.theme_name, wayl->pointer.size);
-
- wayl->pointer.theme = wl_cursor_theme_load(
- wayl->pointer.theme_name, wayl->pointer.size * term->scale, wayl->shm);
- if (wayl->pointer.theme == NULL) {
- LOG_ERR("failed to load cursor theme");
+ wayl->pointer.cursor = wl_cursor_theme_get_cursor(wayl->pointer.theme, term->xcursor);
+ if (wayl->pointer.cursor == NULL) {
+ LOG_ERR("%s: failed to load xcursor pointer '%s'",
+ wayl->pointer.theme_name, term->xcursor);
return false;
}
- wayl->pointer.cursor = wl_cursor_theme_get_cursor(
- wayl->pointer.theme, "left_ptr");
- assert(wayl->pointer.cursor != NULL);
- wayl_update_cursor_surface(wayl, term);
-
- return true;
-}
-
-void
-wayl_update_cursor_surface(struct wayland *wayl, struct terminal *term)
-{
- if (wayl->pointer.cursor == NULL)
- return;
-
const int scale = term->scale;
- wl_surface_set_buffer_scale(wayl->pointer.surface, scale);
-
struct wl_cursor_image *image = wayl->pointer.cursor->images[0];
wl_surface_attach(
@@ -843,9 +826,37 @@ wayl_update_cursor_surface(struct wayland *wayl, struct terminal *term)
wl_surface_damage_buffer(
wayl->pointer.surface, 0, 0, INT32_MAX, INT32_MAX);
+ wl_surface_set_buffer_scale(wayl->pointer.surface, scale);
wl_surface_commit(wayl->pointer.surface);
+ wl_display_roundtrip(wayl->display);
+ return true;
}
+static bool
+wayl_reload_cursor_theme(struct wayland *wayl, const struct terminal *term)
+{
+ if (wayl->pointer.size == 0)
+ return true;
+
+ if (wayl->pointer.theme != NULL) {
+ wl_cursor_theme_destroy(wayl->pointer.theme);
+ wayl->pointer.theme = NULL;
+ wayl->pointer.cursor = NULL;
+ }
+
+ LOG_DBG("reloading cursor theme: %s@%d",
+ wayl->pointer.theme_name, wayl->pointer.size);
+
+ wayl->pointer.theme = wl_cursor_theme_load(
+ wayl->pointer.theme_name, wayl->pointer.size * term->scale, wayl->shm);
+
+ if (wayl->pointer.theme == NULL) {
+ LOG_ERR("failed to load cursor theme");
+ return false;
+ }
+
+ return wayl_cursor_set(wayl, term);
+}
struct terminal *
wayl_terminal_from_surface(struct wayland *wayl, struct wl_surface *surface)