aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/bar.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-12-15 03:21:08 -0500
committerLibravatar emersion <contact@emersion.fr>2018-12-15 09:26:50 +0100
commit35a82a869328ecf387f1490ca6ecfca8bdc1ab39 (patch)
tree64984913256a543417b5932e0863ac02d9de1be8 /swaybar/bar.c
parentMerge pull request #3291 from RedSoxFan/fix-focus-nonvis (diff)
downloadsway-35a82a869328ecf387f1490ca6ecfca8bdc1ab39.tar.gz
sway-35a82a869328ecf387f1490ca6ecfca8bdc1ab39.tar.zst
sway-35a82a869328ecf387f1490ca6ecfca8bdc1ab39.zip
swaybar: fix cursor scale
This fixes a few issues with swaybar's cursor scaling: 1. The cursor scale is now changed when the output scale changes 2. The cursor scale is no longer bound by the max output scale when swaybar is launched 3. Related to the previous item, the cursor is no longer tiny on low scale outputs after the max output scale has changed This also bumps up `wl_compositor` to version 4 to allow usage of `wl_surface_damage_buffer`.
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 47c89a39..53e798bc 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -196,6 +196,10 @@ static void output_scale(void *data, struct wl_output *wl_output,
196 int32_t factor) { 196 int32_t factor) {
197 struct swaybar_output *output = data; 197 struct swaybar_output *output = data;
198 output->scale = factor; 198 output->scale = factor;
199 if (output == output->bar->pointer.current) {
200 update_cursor(output->bar);
201 render_frame(output);
202 }
199} 203}
200 204
201struct wl_output_listener output_listener = { 205struct wl_output_listener output_listener = {
@@ -273,7 +277,7 @@ static void handle_global(void *data, struct wl_registry *registry,
273 struct swaybar *bar = data; 277 struct swaybar *bar = data;
274 if (strcmp(interface, wl_compositor_interface.name) == 0) { 278 if (strcmp(interface, wl_compositor_interface.name) == 0) {
275 bar->compositor = wl_registry_bind(registry, name, 279 bar->compositor = wl_registry_bind(registry, name,
276 &wl_compositor_interface, 3); 280 &wl_compositor_interface, 4);
277 } else if (strcmp(interface, wl_seat_interface.name) == 0) { 281 } else if (strcmp(interface, wl_seat_interface.name) == 0) {
278 bar->seat = wl_registry_bind(registry, name, 282 bar->seat = wl_registry_bind(registry, name,
279 &wl_seat_interface, 3); 283 &wl_seat_interface, 3);
@@ -355,22 +359,6 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
355 wl_display_roundtrip(bar->display); 359 wl_display_roundtrip(bar->display);
356 360
357 struct swaybar_pointer *pointer = &bar->pointer; 361 struct swaybar_pointer *pointer = &bar->pointer;
358
359 int max_scale = 1;
360 struct swaybar_output *output;
361 wl_list_for_each(output, &bar->outputs, link) {
362 if (output->scale > max_scale) {
363 max_scale = output->scale;
364 }
365 }
366
367 pointer->cursor_theme =
368 wl_cursor_theme_load(NULL, 24 * max_scale, bar->shm);
369 assert(pointer->cursor_theme);
370 struct wl_cursor *cursor;
371 cursor = wl_cursor_theme_get_cursor(pointer->cursor_theme, "left_ptr");
372 assert(cursor);
373 pointer->cursor_image = cursor->images[0];
374 pointer->cursor_surface = wl_compositor_create_surface(bar->compositor); 362 pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
375 assert(pointer->cursor_surface); 363 assert(pointer->cursor_surface);
376 364