38 #include <sys/timerfd.h>
43 struct wl_shell_surface* shellSurface,
46 wl_shell_surface_pong(shellSurface, serial);
50 struct wl_shell_surface* shellSurface,
73 aspectRatio = (float)width / (
float)height;
74 targetRatio = (float)window->
numer / (
float)window->
denom;
75 if (aspectRatio < targetRatio)
76 height = width / targetRatio;
77 else if (aspectRatio > targetRatio)
78 width = height * targetRatio;
98 struct wl_shell_surface* shellSurface)
112 fd = mkostemp(tmpname, O_CLOEXEC);
141 static const char template[] =
"/glfw-shared-XXXXXX";
147 #ifdef HAVE_MEMFD_CREATE
148 fd = memfd_create(
"glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
156 fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
161 path = getenv(
"XDG_RUNTIME_DIR");
168 name = calloc(strlen(path) +
sizeof(
template), 1);
170 strcat(name,
template);
178 ret = posix_fallocate(fd, 0, size);
190 struct wl_shm_pool* pool;
191 struct wl_buffer* buffer;
192 int stride = image->
width * 4;
201 "Wayland: Creating a buffer file for %d B failed: %m",
206 data = mmap(
NULL,
length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
207 if (data == MAP_FAILED)
210 "Wayland: mmap failed: %m");
215 pool = wl_shm_create_pool(
_glfw.wl.shm, fd,
length);
218 unsigned char* source = (
unsigned char*) image->
pixels;
219 unsigned char* target = data;
220 for (i = 0; i < image->
width * image->
height; i++, source += 4)
222 unsigned int alpha = source[3];
224 *target++ = (
unsigned char) ((source[2] * alpha) / 255);
225 *target++ = (
unsigned char) ((source[1] * alpha) / 255);
226 *target++ = (
unsigned char) ((source[0] * alpha) / 255);
227 *target++ = (
unsigned char) alpha;
231 wl_shm_pool_create_buffer(pool, 0,
234 stride, WL_SHM_FORMAT_ARGB8888);
236 wl_shm_pool_destroy(pool);
242 struct wl_surface* parent,
243 struct wl_buffer* buffer,
GLFWbool opaque,
245 int width,
int height)
247 struct wl_region* region;
249 decoration->
surface = wl_compositor_create_surface(
_glfw.wl.compositor);
251 wl_subcompositor_get_subsurface(
_glfw.wl.subcompositor,
253 wl_subsurface_set_position(decoration->
subsurface, x, y);
254 decoration->
viewport = wp_viewporter_get_viewport(
_glfw.wl.viewporter,
256 wp_viewport_set_destination(decoration->
viewport, width, height);
257 wl_surface_attach(decoration->
surface, buffer, 0, 0);
261 region = wl_compositor_create_region(
_glfw.wl.compositor);
262 wl_region_add(region, 0, 0, width, height);
263 wl_surface_set_opaque_region(decoration->
surface, region);
264 wl_surface_commit(decoration->
surface);
265 wl_region_destroy(region);
268 wl_surface_commit(decoration->
surface);
273 unsigned char data[] = { 224, 224, 224, 255 };
277 if (!
_glfw.wl.viewporter || !window->
decorated || window->wl.decorations.serverSide)
280 if (!window->wl.decorations.buffer)
282 if (!window->wl.decorations.buffer)
286 window->wl.decorations.buffer, opaque,
290 window->wl.decorations.buffer, opaque,
294 window->wl.decorations.buffer, opaque,
298 window->wl.decorations.buffer, opaque,
306 wl_surface_destroy(decoration->
surface);
308 wl_subsurface_destroy(decoration->
subsurface);
310 wp_viewport_destroy(decoration->
viewport);
325 struct zxdg_toplevel_decoration_v1* decoration,
330 window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
332 if (!window->wl.decorations.serverSide)
343 struct wl_region* region;
345 region = wl_compositor_create_region(
_glfw.wl.compositor);
349 wl_region_add(region, 0, 0, window->wl.width, window->wl.height);
350 wl_surface_set_opaque_region(window->wl.surface, region);
351 wl_surface_commit(window->wl.surface);
352 wl_region_destroy(region);
358 int scale = window->wl.
scale;
359 int scaledWidth = window->wl.width * scale;
360 int scaledHeight = window->wl.height * scale;
362 if (!window->wl.transparent)
367 if (!window->wl.decorations.top.surface)
371 wp_viewport_set_destination(window->wl.decorations.top.viewport,
373 wl_surface_commit(window->wl.decorations.top.surface);
376 wp_viewport_set_destination(window->wl.decorations.left.viewport,
378 wl_surface_commit(window->wl.decorations.left.surface);
381 wl_subsurface_set_position(window->wl.decorations.right.subsurface,
383 wp_viewport_set_destination(window->wl.decorations.right.viewport,
385 wl_surface_commit(window->wl.decorations.right.surface);
388 wl_subsurface_set_position(window->wl.decorations.bottom.subsurface,
390 wp_viewport_set_destination(window->wl.decorations.bottom.viewport,
392 wl_surface_commit(window->wl.decorations.bottom.surface);
402 if (
_glfw.wl.compositorVersion < 3)
406 for (i = 0; i < window->wl.monitorsCount; ++i)
408 monitorScale = window->wl.monitors[i]->wl.
scale;
409 if (scale < monitorScale)
410 scale = monitorScale;
414 if (scale != window->wl.
scale)
416 window->wl.
scale = scale;
417 wl_surface_set_buffer_scale(window->wl.surface, scale);
423 struct wl_surface *surface,
424 struct wl_output *output)
427 _GLFWmonitor* monitor = wl_output_get_user_data(output);
429 if (window->wl.monitorsCount + 1 > window->wl.monitorsSize)
431 ++window->wl.monitorsSize;
432 window->wl.monitors =
433 realloc(window->wl.monitors,
437 window->wl.monitors[window->wl.monitorsCount++] = monitor;
443 struct wl_surface *surface,
444 struct wl_output *output)
447 _GLFWmonitor* monitor = wl_output_get_user_data(output);
451 for (i = 0, found =
GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i)
453 if (monitor == window->wl.monitors[i])
456 window->wl.monitors[i] = window->wl.monitors[i + 1];
458 window->wl.monitors[--window->wl.monitorsCount] =
NULL;
470 if (enable && !window->wl.idleInhibitor &&
_glfw.wl.idleInhibitManager)
472 window->wl.idleInhibitor =
473 zwp_idle_inhibit_manager_v1_create_inhibitor(
474 _glfw.wl.idleInhibitManager, window->wl.surface);
475 if (!window->wl.idleInhibitor)
477 "Wayland: Idle inhibitor creation failed");
479 else if (!enable && window->wl.idleInhibitor)
481 zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
482 window->wl.idleInhibitor =
NULL;
489 window->wl.surface = wl_compositor_create_surface(
_glfw.wl.compositor);
490 if (!window->wl.surface)
493 wl_surface_add_listener(window->wl.surface,
497 wl_surface_set_user_data(window->wl.surface, window);
502 if (!window->wl.native)
505 window->wl.width = wndconfig->
width;
506 window->wl.height = wndconfig->
height;
507 window->wl.
scale = 1;
509 if (!window->wl.transparent)
518 if (window->wl.xdg.toplevel)
520 xdg_toplevel_set_fullscreen(
521 window->wl.xdg.toplevel,
524 else if (window->wl.shellSurface)
526 wl_shell_surface_set_fullscreen(
527 window->wl.shellSurface,
528 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
533 if (!window->wl.decorations.serverSide)
542 "Wayland: wl_shell protocol not available");
546 window->wl.shellSurface = wl_shell_get_shell_surface(
_glfw.wl.shell,
548 if (!window->wl.shellSurface)
551 "Wayland: Shell surface creation failed");
555 wl_shell_surface_add_listener(window->wl.shellSurface,
559 if (window->wl.title)
560 wl_shell_surface_set_title(window->wl.shellSurface, window->wl.title);
566 else if (window->wl.maximized)
568 wl_shell_surface_set_maximized(window->wl.shellSurface,
NULL);
574 wl_shell_surface_set_toplevel(window->wl.shellSurface);
579 wl_surface_commit(window->wl.surface);
585 struct xdg_toplevel* toplevel,
588 struct wl_array* states)
598 wl_array_for_each(state, states)
602 case XDG_TOPLEVEL_STATE_MAXIMIZED:
605 case XDG_TOPLEVEL_STATE_FULLSCREEN:
608 case XDG_TOPLEVEL_STATE_RESIZING:
610 case XDG_TOPLEVEL_STATE_ACTIVATED:
616 if (width != 0 && height != 0)
618 if (!maximized && !fullscreen)
622 aspectRatio = (float)width / (
float)height;
623 targetRatio = (float)window->
numer / (
float)window->
denom;
624 if (aspectRatio < targetRatio)
625 height = width / targetRatio;
626 else if (aspectRatio > targetRatio)
627 width = height * targetRatio;
636 if (!window->wl.justCreated && !activated && window->
autoIconify)
643 struct xdg_toplevel* toplevel)
655 struct xdg_surface* surface,
658 xdg_surface_ack_configure(surface, serial);
667 if (
_glfw.wl.decorationManager)
669 window->wl.xdg.decoration =
670 zxdg_decoration_manager_v1_get_toplevel_decoration(
671 _glfw.wl.decorationManager, window->wl.xdg.toplevel);
672 zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration,
675 zxdg_toplevel_decoration_v1_set_mode(
676 window->wl.xdg.decoration,
677 ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
681 window->wl.decorations.serverSide =
GLFW_FALSE;
688 window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(
_glfw.wl.wmBase,
690 if (!window->wl.xdg.surface)
693 "Wayland: xdg-surface creation failed");
697 xdg_surface_add_listener(window->wl.xdg.surface,
701 window->wl.xdg.toplevel = xdg_surface_get_toplevel(window->wl.xdg.surface);
702 if (!window->wl.xdg.toplevel)
705 "Wayland: xdg-toplevel creation failed");
709 xdg_toplevel_add_listener(window->wl.xdg.toplevel,
713 if (window->wl.title)
714 xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
717 xdg_toplevel_set_min_size(window->wl.xdg.toplevel,
720 xdg_toplevel_set_max_size(window->wl.xdg.toplevel,
725 xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel,
729 else if (window->wl.maximized)
731 xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
741 wl_surface_commit(window->wl.surface);
742 wl_display_roundtrip(
_glfw.wl.display);
750 struct itimerspec timer = {};
753 struct wl_buffer* buffer;
754 struct wl_surface* surface =
_glfw.wl.cursorSurface;
758 buffer = cursorWayland->
buffer;
772 timer.it_value.tv_sec = image->
delay / 1000;
773 timer.it_value.tv_nsec = (image->
delay % 1000) * 1000000;
774 timerfd_settime(
_glfw.wl.cursorTimerfd, 0, &timer,
NULL);
782 wl_pointer_set_cursor(
_glfw.wl.pointer,
_glfw.wl.serial,
784 cursorWayland->
xhot / scale,
785 cursorWayland->
yhot / scale);
786 wl_surface_set_buffer_scale(surface, scale);
787 wl_surface_attach(surface, buffer, 0, 0);
788 wl_surface_damage(surface, 0, 0,
790 wl_surface_commit(surface);
800 cursor = window->wl.currentCursor;
801 if (cursor && cursor->wl.cursor)
803 cursor->wl.currentImage += 1;
804 cursor->wl.currentImage %= cursor->wl.cursor->image_count;
811 struct wl_display* display =
_glfw.wl.display;
812 struct pollfd fds[] = {
813 { wl_display_get_fd(display), POLLIN },
814 {
_glfw.wl.timerfd, POLLIN },
815 {
_glfw.wl.cursorTimerfd, POLLIN },
820 while (wl_display_prepare_read(display) != 0)
821 wl_display_dispatch_pending(display);
826 if (wl_display_flush(display) < 0 && errno != EAGAIN)
832 window = window->
next;
834 wl_display_cancel_read(display);
838 if (poll(fds, 3, timeout) > 0)
840 if (fds[0].revents & POLLIN)
842 wl_display_read_events(display);
843 wl_display_dispatch_pending(display);
847 wl_display_cancel_read(display);
850 if (fds[1].revents & POLLIN)
852 read_ret = read(
_glfw.wl.timerfd, &repeats,
sizeof(repeats));
856 for (i = 0; i < repeats; ++i)
859 _glfw.wl.xkb.modifiers);
862 if (fds[2].revents & POLLIN)
864 read_ret = read(
_glfw.wl.cursorTimerfd, &repeats,
sizeof(repeats));
873 wl_display_cancel_read(display);
892 return "sb_h_double_arrow";
894 return "sb_v_double_arrow";
933 if (wndconfig->
title)
953 window->wl.xdg.surface =
NULL;
954 window->wl.xdg.toplevel =
NULL;
955 window->wl.shellSurface =
NULL;
959 window->wl.currentCursor =
NULL;
962 window->wl.monitorsCount = 0;
963 window->wl.monitorsSize = 1;
970 if (window ==
_glfw.wl.pointerFocus)
975 if (window ==
_glfw.wl.keyboardFocus)
981 if (window->wl.idleInhibitor)
982 zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
988 if (window->wl.xdg.decoration)
989 zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
991 if (window->wl.decorations.buffer)
992 wl_buffer_destroy(window->wl.decorations.buffer);
994 if (window->wl.native)
997 if (window->wl.shellSurface)
998 wl_shell_surface_destroy(window->wl.shellSurface);
1000 if (window->wl.xdg.toplevel)
1001 xdg_toplevel_destroy(window->wl.xdg.toplevel);
1003 if (window->wl.xdg.surface)
1004 xdg_surface_destroy(window->wl.xdg.surface);
1006 if (window->wl.surface)
1007 wl_surface_destroy(window->wl.surface);
1009 free(window->wl.title);
1010 free(window->wl.monitors);
1015 if (window->wl.title)
1016 free(window->wl.title);
1018 if (window->wl.xdg.toplevel)
1019 xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
1020 else if (window->wl.shellSurface)
1021 wl_shell_surface_set_title(window->wl.shellSurface, title);
1028 "Wayland: Setting window icon not supported");
1037 "Wayland: Window position retrieval not supported");
1045 "Wayland: Window position setting not supported");
1051 *width = window->wl.width;
1053 *height = window->wl.height;
1058 window->wl.width = width;
1059 window->wl.height = height;
1064 int minwidth,
int minheight,
1065 int maxwidth,
int maxheight)
1067 if (
_glfw.wl.wmBase)
1069 if (window->wl.xdg.toplevel)
1072 minwidth = minheight = 0;
1074 maxwidth = maxheight = 0;
1075 xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight);
1076 xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight);
1077 wl_surface_commit(window->wl.surface);
1088 int numer,
int denom)
1095 int* width,
int* height)
1098 *width *= window->wl.
scale;
1099 *height *= window->wl.
scale;
1103 int* left,
int* top,
1104 int* right,
int* bottom)
1106 if (window->
decorated && !window->
monitor && !window->wl.decorations.serverSide)
1120 float* xscale,
float* yscale)
1123 *xscale = (float) window->wl.
scale;
1125 *yscale = (float) window->wl.
scale;
1130 if (
_glfw.wl.wmBase)
1132 if (window->wl.xdg.toplevel)
1133 xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
1138 "Wayland: Iconify window not supported on wl_shell");
1144 if (window->wl.xdg.toplevel)
1147 xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
1148 if (window->wl.maximized)
1149 xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
1153 else if (window->wl.shellSurface)
1155 if (window->
monitor || window->wl.maximized)
1156 wl_shell_surface_set_toplevel(window->wl.shellSurface);
1164 if (window->wl.xdg.toplevel)
1166 xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
1168 else if (window->wl.shellSurface)
1171 wl_shell_surface_set_maximized(window->wl.shellSurface,
NULL);
1178 if (!window->wl.visible)
1180 if (
_glfw.wl.wmBase)
1182 else if (!window->wl.shellSurface)
1190 if (window->wl.xdg.toplevel)
1192 xdg_toplevel_destroy(window->wl.xdg.toplevel);
1193 xdg_surface_destroy(window->wl.xdg.surface);
1194 window->wl.xdg.toplevel =
NULL;
1195 window->wl.xdg.surface =
NULL;
1197 else if (window->wl.shellSurface)
1199 wl_shell_surface_destroy(window->wl.shellSurface);
1200 window->wl.shellSurface =
NULL;
1209 "Wayland: Window attention request not implemented yet");
1215 "Wayland: Focusing a window requires user interaction");
1221 int width,
int height,
1230 if (window->wl.xdg.toplevel)
1231 xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
1232 else if (window->wl.shellSurface)
1233 wl_shell_surface_set_toplevel(window->wl.shellSurface);
1235 if (!
_glfw.wl.decorationManager)
1243 return _glfw.wl.keyboardFocus == window;
1255 return window->wl.visible;
1260 return window->wl.maximized;
1265 return window->wl.hovered;
1270 return window->wl.transparent;
1277 "Wayland: Window attribute setting not implemented yet");
1295 "Wayland: Window attribute setting not implemented yet");
1324 wl_display_sync(
_glfw.wl.display);
1330 *xpos = window->wl.cursorPosX;
1332 *ypos = window->wl.cursorPosY;
1341 zwp_locked_pointer_v1_set_cursor_position_hint(
1342 window->wl.pointerLock.lockedPointer,
1343 wl_fixed_from_double(x), wl_fixed_from_double(y));
1344 wl_surface_commit(window->wl.surface);
1361 return _glfw.wl.scancodes[key];
1369 if (!cursor->wl.buffer)
1372 cursor->wl.width = image->
width;
1373 cursor->wl.height = image->
height;
1374 cursor->wl.xhot = xhot;
1375 cursor->wl.yhot = yhot;
1385 if (!standardCursor)
1388 "Wayland: Standard cursor \"%s\" not found",
1393 cursor->wl.cursor = standardCursor;
1394 cursor->wl.currentImage = 0;
1396 if (
_glfw.wl.cursorThemeHiDPI)
1400 cursor->wl.cursorHiDPI = standardCursor;
1409 if (cursor->wl.cursor)
1412 if (cursor->wl.buffer)
1413 wl_buffer_destroy(cursor->wl.buffer);
1417 struct zwp_relative_pointer_v1* pointer,
1422 wl_fixed_t dxUnaccel,
1423 wl_fixed_t dyUnaccel)
1440 struct zwp_locked_pointer_v1* lockedPointer)
1446 struct zwp_relative_pointer_v1* relativePointer =
1447 window->wl.pointerLock.relativePointer;
1448 struct zwp_locked_pointer_v1* lockedPointer =
1449 window->wl.pointerLock.lockedPointer;
1451 zwp_relative_pointer_v1_destroy(relativePointer);
1452 zwp_locked_pointer_v1_destroy(lockedPointer);
1454 window->wl.pointerLock.relativePointer =
NULL;
1455 window->wl.pointerLock.lockedPointer =
NULL;
1461 struct zwp_locked_pointer_v1* lockedPointer)
1472 struct zwp_relative_pointer_v1* relativePointer;
1473 struct zwp_locked_pointer_v1* lockedPointer;
1475 if (!
_glfw.wl.relativePointerManager)
1478 "Wayland: no relative pointer manager");
1483 zwp_relative_pointer_manager_v1_get_relative_pointer(
1484 _glfw.wl.relativePointerManager,
1486 zwp_relative_pointer_v1_add_listener(relativePointer,
1491 zwp_pointer_constraints_v1_lock_pointer(
1492 _glfw.wl.pointerConstraints,
1496 ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
1497 zwp_locked_pointer_v1_add_listener(lockedPointer,
1501 window->wl.pointerLock.relativePointer = relativePointer;
1502 window->wl.pointerLock.lockedPointer = lockedPointer;
1504 wl_pointer_set_cursor(
_glfw.wl.pointer,
_glfw.wl.serial,
1510 return window->wl.pointerLock.lockedPointer !=
NULL;
1518 if (!
_glfw.wl.pointer)
1521 window->wl.currentCursor = cursor;
1543 "Wayland: Standard cursor not found");
1546 if (
_glfw.wl.cursorThemeHiDPI)
1547 defaultCursorHiDPI =
1568 wl_pointer_set_cursor(
_glfw.wl.pointer,
_glfw.wl.serial,
NULL, 0, 0);
1573 struct wl_data_source* dataSource,
1574 const char* mimeType)
1576 if (
_glfw.wl.dataSource != dataSource)
1579 "Wayland: Unknown clipboard data source");
1585 struct wl_data_source* dataSource,
1586 const char* mimeType,
1589 const char*
string =
_glfw.wl.clipboardSendString;
1590 size_t len =
_glfw.wl.clipboardSendSize;
1593 if (
_glfw.wl.dataSource != dataSource)
1596 "Wayland: Unknown clipboard data source");
1603 "Wayland: Copy requested from an invalid string");
1607 if (strcmp(mimeType,
"text/plain;charset=utf-8") != 0)
1610 "Wayland: Wrong MIME type asked from clipboard");
1617 ret = write(fd,
string, len);
1618 if (ret == -1 && errno == EINTR)
1624 "Wayland: Error while writing the clipboard");
1634 struct wl_data_source* dataSource)
1636 wl_data_source_destroy(dataSource);
1638 if (
_glfw.wl.dataSource != dataSource)
1641 "Wayland: Unknown clipboard data source");
1656 if (
_glfw.wl.dataSource)
1658 wl_data_source_destroy(
_glfw.wl.dataSource);
1662 if (
_glfw.wl.clipboardSendString)
1664 free(
_glfw.wl.clipboardSendString);
1668 _glfw.wl.clipboardSendString = strdup(
string);
1669 if (!
_glfw.wl.clipboardSendString)
1672 "Wayland: Impossible to allocate clipboard string");
1675 _glfw.wl.clipboardSendSize = strlen(
string);
1676 _glfw.wl.dataSource =
1677 wl_data_device_manager_create_data_source(
_glfw.wl.dataDeviceManager);
1678 if (!
_glfw.wl.dataSource)
1681 "Wayland: Impossible to create clipboard source");
1682 free(
_glfw.wl.clipboardSendString);
1685 wl_data_source_add_listener(
_glfw.wl.dataSource,
1688 wl_data_source_offer(
_glfw.wl.dataSource,
"text/plain;charset=utf-8");
1689 wl_data_device_set_selection(
_glfw.wl.dataDevice,
1690 _glfw.wl.dataSource,
1696 char* clipboard =
_glfw.wl.clipboardString;
1698 clipboard = realloc(clipboard,
_glfw.wl.clipboardSize * 2);
1702 "Wayland: Impossible to grow clipboard string");
1705 _glfw.wl.clipboardString = clipboard;
1706 _glfw.wl.clipboardSize =
_glfw.wl.clipboardSize * 2;
1716 if (!
_glfw.wl.dataOffer)
1719 "No clipboard data has been sent yet");
1723 ret = pipe2(fds, O_CLOEXEC);
1728 "Wayland: Impossible to create clipboard pipe fds");
1732 wl_data_offer_receive(
_glfw.wl.dataOffer,
"text/plain;charset=utf-8", fds[1]);
1742 if (len + 4096 >
_glfw.wl.clipboardSize)
1752 ret = read(fds[0],
_glfw.wl.clipboardString + len, 4096);
1755 if (ret == -1 && errno == EINTR)
1761 "Wayland: Impossible to read from clipboard fd");
1768 if (len + 1 >
_glfw.wl.clipboardSize)
1773 _glfw.wl.clipboardString[len] =
'\0';
1774 return _glfw.wl.clipboardString;
1788 uint32_t queuefamily)
1791 vkGetPhysicalDeviceWaylandPresentationSupportKHR =
1794 if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR)
1797 "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
1801 return vkGetPhysicalDeviceWaylandPresentationSupportKHR(device,
1817 if (!vkCreateWaylandSurfaceKHR)
1820 "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
1824 memset(&sci, 0,
sizeof(sci));
1827 sci.
surface = window->wl.surface;
1829 err = vkCreateWaylandSurfaceKHR(instance, &sci, allocator, surface);
1833 "Wayland: Failed to create Vulkan surface: %s",
1848 return _glfw.wl.display;
1855 return window->wl.surface;