From 1ae944c07189b54d5d7458a2d0efaa39fbbac457 Mon Sep 17 00:00:00 2001 From: Greg V Date: Wed, 22 Nov 2017 15:57:05 +0300 Subject: Use SIGUSR2 for vt switching instead of SIGUSR1 Xwayland uses SIGUSR1 to signal readiness. With direct(-freebsd) session and Xwayland, wlroots was confusing the Xwayland readiness signal with a vt switch signal, freezing the desktop. Same problem was found in Weston in 2014: https://phabricator.freedesktop.org/T7080 --- backend/session/direct-freebsd.c | 6 +++--- backend/session/direct.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'backend') diff --git a/backend/session/direct-freebsd.c b/backend/session/direct-freebsd.c index fc4bab04..c0621416 100644 --- a/backend/session/direct-freebsd.c +++ b/backend/session/direct-freebsd.c @@ -148,8 +148,8 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display struct vt_mode mode = { .mode = VT_PROCESS, - .relsig = SIGUSR1, - .acqsig = SIGUSR1, + .relsig = SIGUSR2, + .acqsig = SIGUSR2, .frsig = SIGIO, // has to be set }; @@ -159,7 +159,7 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display } struct wl_event_loop *loop = wl_display_get_event_loop(display); - session->vt_source = wl_event_loop_add_signal(loop, SIGUSR1, + session->vt_source = wl_event_loop_add_signal(loop, SIGUSR2, vt_handler, session); if (!session->vt_source) { goto error; diff --git a/backend/session/direct.c b/backend/session/direct.c index 942dc552..9d6cd36d 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -184,8 +184,8 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display struct vt_mode mode = { .mode = VT_PROCESS, - .relsig = SIGUSR1, - .acqsig = SIGUSR1, + .relsig = SIGUSR2, + .acqsig = SIGUSR2, }; if (ioctl(fd, VT_SETMODE, &mode) < 0) { @@ -194,7 +194,7 @@ static bool setup_tty(struct direct_session *session, struct wl_display *display } struct wl_event_loop *loop = wl_display_get_event_loop(display); - session->vt_source = wl_event_loop_add_signal(loop, SIGUSR1, + session->vt_source = wl_event_loop_add_signal(loop, SIGUSR2, vt_handler, session); if (!session->vt_source) { goto error; -- cgit v1.2.3 From 87ea76e0374ddf23975ed5e57f01ad0ef69d0ab2 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 27 Nov 2017 12:15:38 +1300 Subject: Remove unneeded linux include --- backend/wayland/os-compatibility.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'backend') diff --git a/backend/wayland/os-compatibility.c b/backend/wayland/os-compatibility.c index 14125793..cbd7988d 100644 --- a/backend/wayland/os-compatibility.c +++ b/backend/wayland/os-compatibility.c @@ -29,9 +29,6 @@ #include #include #include -#ifdef __linux__ -#include -#endif #include #include -- cgit v1.2.3 From bc113c16aab5fed2a937ddb8b2b560eaef28620d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 30 Nov 2017 10:32:55 +1300 Subject: Use correct include path for glapi.h --- backend/drm/renderer.c | 2 +- render/egl.c | 2 +- render/gles2/renderer.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index d53acaa8..87064914 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -14,7 +14,7 @@ #include #include #include "backend/drm/drm.h" -#include "render/glapi.h" +#include "glapi.h" bool wlr_drm_renderer_init(struct wlr_drm_backend *drm, struct wlr_drm_renderer *renderer) { diff --git a/render/egl.c b/render/egl.c index 08612125..22d58df2 100644 --- a/render/egl.c +++ b/render/egl.c @@ -4,7 +4,7 @@ #include #include #include -#include "render/glapi.h" +#include "glapi.h" // Extension documentation // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_image_base.txt. diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 646d69ec..89cc4ffb 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -12,7 +12,7 @@ #include #include #include "render/gles2.h" -#include "render/glapi.h" +#include "glapi.h" struct shaders shaders; -- cgit v1.2.3 From cef6d7549131cfee7cd60ada0388a2766335c70a Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 30 Nov 2017 15:00:36 +0100 Subject: Moved os-compatibility and added header * Moved os-compatibility.c to util * Added header under util * Removed static since it isn't needed (i think so) * Adjusted meson.build to include lib_wlr Improved some codestyle * Added guard to os-compatibility.h * Fixed typo in include statment Adjusted Guard * Changed guard to _WLR_UTIL_OS_COMPATIBILITY --- backend/meson.build | 1 - backend/wayland/os-compatibility.c | 153 ------------------------------------- examples/meson.build | 3 +- examples/screenshot.c | 2 +- include/util/os-compatibility.h | 12 +++ util/meson.build | 1 + util/os-compatibility.c | 147 +++++++++++++++++++++++++++++++++++ 7 files changed, 163 insertions(+), 156 deletions(-) delete mode 100644 backend/wayland/os-compatibility.c create mode 100644 include/util/os-compatibility.h create mode 100644 util/os-compatibility.c (limited to 'backend') diff --git a/backend/meson.build b/backend/meson.build index 5ed7b227..c9d47317 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -21,7 +21,6 @@ backend_files = files( 'wayland/output.c', 'wayland/registry.c', 'wayland/wl_seat.c', - 'wayland/os-compatibility.c', 'x11/backend.c', ) diff --git a/backend/wayland/os-compatibility.c b/backend/wayland/os-compatibility.c deleted file mode 100644 index cbd7988d..00000000 --- a/backend/wayland/os-compatibility.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright © 2012 Collabora, Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define _XOPEN_SOURCE 700 -#include -#include -#include -#include -#include -#include -#include - -int -os_fd_set_cloexec(int fd) -{ - long flags; - - if (fd == -1) - return -1; - - flags = fcntl(fd, F_GETFD); - if (flags == -1) - return -1; - - if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) - return -1; - - return 0; -} - -static int -set_cloexec_or_close(int fd) -{ - if (os_fd_set_cloexec(fd) != 0) { - close(fd); - return -1; - } - return fd; -} - -static int -create_tmpfile_cloexec(char *tmpname) -{ - int fd; - -#ifdef HAVE_MKOSTEMP - fd = mkostemp(tmpname, O_CLOEXEC); - if (fd >= 0) - unlink(tmpname); -#else - fd = mkstemp(tmpname); - if (fd >= 0) { - fd = set_cloexec_or_close(fd); - unlink(tmpname); - } -#endif - - return fd; -} - -/* - * Create a new, unique, anonymous file of the given size, and - * return the file descriptor for it. The file descriptor is set - * CLOEXEC. The file is immediately suitable for mmap()'ing - * the given size at offset zero. - * - * The file should not have a permanent backing store like a disk, - * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. - * - * The file name is deleted from the file system. - * - * The file is suitable for buffer sharing between processes by - * transmitting the file descriptor over Unix sockets using the - * SCM_RIGHTS methods. - * - * If the C library implements posix_fallocate(), it is used to - * guarantee that disk space is available for the file at the - * given size. If disk space is insufficient, errno is set to ENOSPC. - * If posix_fallocate() is not supported, program may receive - * SIGBUS on accessing mmap()'ed file contents instead. - */ -int -os_create_anonymous_file(off_t size) -{ - static const char template[] = "/wlroots-shared-XXXXXX"; - const char *path; - char *name; - int fd; - int ret; - - path = getenv("XDG_RUNTIME_DIR"); - if (!path) { - errno = ENOENT; - return -1; - } - - name = malloc(strlen(path) + sizeof(template)); - if (!name) - return -1; - - strcpy(name, path); - strcat(name, template); - - fd = create_tmpfile_cloexec(name); - - free(name); - - if (fd < 0) - return -1; - -#ifdef HAVE_POSIX_FALLOCATE - do { - ret = posix_fallocate(fd, 0, size); - } while (ret == EINTR); - if (ret != 0) { - close(fd); - errno = ret; - return -1; - } -#else - do { - ret = ftruncate(fd, size); - } while (ret < 0 && errno == EINTR); - if (ret < 0) { - close(fd); - return -1; - } -#endif - - return fd; -} diff --git a/examples/meson.build b/examples/meson.build index 89fc6211..af0f5a18 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -29,5 +29,6 @@ executable( executable( 'screenshot', 'screenshot.c', - dependencies: [wayland_client, wlr_protos], + dependencies: [wayland_client, wlr_protos, wlroots], + link_with: lib_shared, ) diff --git a/examples/screenshot.c b/examples/screenshot.c index fc7f3cb3..a887d1d7 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -35,7 +35,7 @@ #include #include #include -#include "../backend/wayland/os-compatibility.c" +#include "util/os-compatibility.h" static struct wl_shm *shm = NULL; static struct orbital_screenshooter *screenshooter = NULL; diff --git a/include/util/os-compatibility.h b/include/util/os-compatibility.h new file mode 100644 index 00000000..b2ec2db9 --- /dev/null +++ b/include/util/os-compatibility.h @@ -0,0 +1,12 @@ +#ifndef _WLR_UTIL_OS_COMPATIBILITY_H +#define _WLR_UTIL_OS_COMPATIBILITY_H + +int os_fd_set_cloexec(int fd); + +int set_cloexec_or_close(int fd); + +int create_tmpfile_cloexec(char *tmpname); + +int os_create_anonymous_file(off_t size); + +#endif diff --git a/util/meson.build b/util/meson.build index dd620818..21930693 100644 --- a/util/meson.build +++ b/util/meson.build @@ -2,6 +2,7 @@ lib_wlr_util = static_library( 'wlr_util', files( 'log.c', + 'os-compatibility.c', ), include_directories: wlr_inc, ) diff --git a/util/os-compatibility.c b/util/os-compatibility.c new file mode 100644 index 00000000..98aeab3d --- /dev/null +++ b/util/os-compatibility.c @@ -0,0 +1,147 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define _XOPEN_SOURCE 700 +#include +#include +#include +#include +#include +#include +#include +#include "util/os-compatibility.h" + +int os_fd_set_cloexec(int fd) { + long flags; + + if (fd == -1) + return -1; + + flags = fcntl(fd, F_GETFD); + if (flags == -1) + return -1; + + if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) + return -1; + + return 0; +} + +int set_cloexec_or_close(int fd) { + if (os_fd_set_cloexec(fd) != 0) { + close(fd); + return -1; + } + return fd; +} + +int create_tmpfile_cloexec(char *tmpname) +{ + int fd; + +#ifdef HAVE_MKOSTEMP + fd = mkostemp(tmpname, O_CLOEXEC); + if (fd >= 0) + unlink(tmpname); +#else + fd = mkstemp(tmpname); + if (fd >= 0) { + fd = set_cloexec_or_close(fd); + unlink(tmpname); + } +#endif + + return fd; +} + +/* + * Create a new, unique, anonymous file of the given size, and + * return the file descriptor for it. The file descriptor is set + * CLOEXEC. The file is immediately suitable for mmap()'ing + * the given size at offset zero. + * + * The file should not have a permanent backing store like a disk, + * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. + * + * The file name is deleted from the file system. + * + * The file is suitable for buffer sharing between processes by + * transmitting the file descriptor over Unix sockets using the + * SCM_RIGHTS methods. + * + * If the C library implements posix_fallocate(), it is used to + * guarantee that disk space is available for the file at the + * given size. If disk space is insufficient, errno is set to ENOSPC. + * If posix_fallocate() is not supported, program may receive + * SIGBUS on accessing mmap()'ed file contents instead. + */ +int os_create_anonymous_file(off_t size) { + static const char template[] = "/wlroots-shared-XXXXXX"; + const char *path; + char *name; + int fd; + int ret; + + path = getenv("XDG_RUNTIME_DIR"); + if (!path) { + errno = ENOENT; + return -1; + } + + name = malloc(strlen(path) + sizeof(template)); + if (!name) + return -1; + + strcpy(name, path); + strcat(name, template); + + fd = create_tmpfile_cloexec(name); + + free(name); + + if (fd < 0) + return -1; + +#ifdef HAVE_POSIX_FALLOCATE + do { + ret = posix_fallocate(fd, 0, size); + } while (ret == EINTR); + if (ret != 0) { + close(fd); + errno = ret; + return -1; + } +#else + do { + ret = ftruncate(fd, size); + } while (ret < 0 && errno == EINTR); + if (ret < 0) { + close(fd); + return -1; + } +#endif + + return fd; +} -- cgit v1.2.3 From a8d8a63fe0b437a6a4d37fd03a0e8b4e178e22c7 Mon Sep 17 00:00:00 2001 From: n3rdopolis Date: Sat, 2 Dec 2017 10:50:00 -0500 Subject: Attempt to fix #454 With logind, only seat0 can use TTYs --- backend/session/logind.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'backend') diff --git a/backend/session/logind.c b/backend/session/logind.c index daff75b6..e42b85f8 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -347,19 +347,22 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) { goto error; } - ret = sd_session_get_vt(session->id, &session->base.vtnr); - if (ret < 0) { - wlr_log(L_ERROR, "Session not running in virtual terminal"); - goto error; - } - char *seat; ret = sd_session_get_seat(session->id, &seat); if (ret < 0) { wlr_log(L_ERROR, "Failed to get seat id: %s", strerror(-ret)); goto error; } + snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat); + if (seat == "seat0") + { + ret = sd_session_get_vt(session->id, &session->base.vtnr); + if (ret < 0) { + wlr_log(L_ERROR, "Session not running in virtual terminal"); + goto error; + } + } free(seat); ret = sd_bus_default_system(&session->bus); -- cgit v1.2.3 From 8a2d54c24ab157c8acc669f6aa5af365abc71a70 Mon Sep 17 00:00:00 2001 From: n3rdopolis Date: Sat, 2 Dec 2017 12:37:28 -0500 Subject: Fix style and string comparison --- backend/session/logind.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/session/logind.c b/backend/session/logind.c index e42b85f8..e9d4c8f3 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -353,10 +353,9 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) { wlr_log(L_ERROR, "Failed to get seat id: %s", strerror(-ret)); goto error; } - snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat); - if (seat == "seat0") - { + + if (strcmp(seat, "seat0") == 0) { ret = sd_session_get_vt(session->id, &session->base.vtnr); if (ret < 0) { wlr_log(L_ERROR, "Session not running in virtual terminal"); -- cgit v1.2.3 From 8af779fae610a86c6757eb4614cace39f687c292 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 5 Dec 2017 22:23:01 +0100 Subject: Fix segfault when moving hardware cursor --- backend/drm/drm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'backend') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index dd247998..9fcf2ad7 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -634,8 +634,10 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output, struct wlr_box transformed_box; wlr_output_transform_apply_to_box(transform, &box, &transformed_box); - transformed_box.x -= plane->cursor_hotspot_x; - transformed_box.y -= plane->cursor_hotspot_y; + if (plane != NULL) { + transformed_box.x -= plane->cursor_hotspot_x; + transformed_box.y -= plane->cursor_hotspot_y; + } return drm->iface->crtc_move_cursor(drm, conn->crtc, transformed_box.x, transformed_box.y); -- cgit v1.2.3 From 91d72040e588c500e8017c6ad824a96ed4180996 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 7 Dec 2017 13:59:19 +0100 Subject: Configure outputs with make, model, serial in rootston Added fallbacks in DRM backend in case EDID extension data for model and serial is missing. Updates #403 --- backend/drm/util.c | 6 ++++++ rootston/config.c | 15 ++++++++++----- rootston/output.c | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'backend') diff --git a/backend/drm/util.c b/backend/drm/util.c index c27d7b67..25256343 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -93,6 +93,12 @@ void parse_edid(struct wlr_output *restrict output, size_t len, const uint8_t *d uint16_t id = (data[8] << 8) | data[9]; snprintf(output->make, sizeof(output->make), "%s", get_manufacturer(id)); + uint16_t model = data[10] | (data[11] << 8); + snprintf(output->model, sizeof(output->model), "0x%04X", model); + + uint32_t serial = data[12] | (data[13] << 8) | (data[14] << 8) | (data[15] << 8); + snprintf(output->serial, sizeof(output->serial), "0x%08X", serial); + output->phys_width = ((data[68] & 0xf0) << 4) | data[66]; output->phys_height = ((data[68] & 0x0f) << 8) | data[67]; diff --git a/rootston/config.c b/rootston/config.c index 466ad16a..59adf13c 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -120,7 +120,7 @@ void add_binding_config(struct wl_list *bindings, const char* combination, xkb_keysym_t keysyms[ROOTS_KEYBOARD_PRESSED_KEYSYMS_CAP]; char *symnames = strdup(combination); - char* symname = strtok(symnames, "+"); + char *symname = strtok(symnames, "+"); while (symname) { uint32_t modifier = parse_modifier(symname); if (modifier != 0) { @@ -466,10 +466,15 @@ void roots_config_destroy(struct roots_config *config) { struct roots_output_config *roots_config_get_output(struct roots_config *config, struct wlr_output *output) { - struct roots_output_config *o_config; - wl_list_for_each(o_config, &config->outputs, link) { - if (strcmp(o_config->name, output->name) == 0) { - return o_config; + char name[83]; + snprintf(name, sizeof(name), "%s %s %s", output->make, output->model, + output->serial); + + struct roots_output_config *oc; + wl_list_for_each(oc, &config->outputs, link) { + if (strcmp(oc->name, output->name) == 0 || + strcmp(oc->name, name) == 0) { + return oc; } } diff --git a/rootston/output.c b/rootston/output.c index d0f4a378..aace1991 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -291,7 +291,7 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct roots_config *config = desktop->config; wlr_log(L_DEBUG, "Output '%s' added", wlr_output->name); - wlr_log(L_DEBUG, "%s %s %s %"PRId32"mm x %"PRId32"mm", wlr_output->make, + wlr_log(L_DEBUG, "'%s %s %s' %"PRId32"mm x %"PRId32"mm", wlr_output->make, wlr_output->model, wlr_output->serial, wlr_output->phys_width, wlr_output->phys_height); if (wl_list_length(&wlr_output->modes) > 0) { -- cgit v1.2.3