aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-02-26 19:46:38 +0100
committerdec05eba <dec05eba@protonmail.com>2024-02-26 19:46:38 +0100
commit8043453bd85eca50d4fcc3a653603535597e68bd (patch)
tree42345850bb8d860e267916a13ba65b9c8639e710 /src
parent6f498dd0200cab6dff2613518d5a6a8df96276c7 (diff)
Set cap sys nice again, to prevent gsr from being limited to game fps
Diffstat (limited to 'src')
-rw-r--r--src/egl.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/egl.c b/src/egl.c
index ec6f91c..7971dbd 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -9,6 +9,7 @@
#include <wayland-client.h>
#include <wayland-egl.h>
#include <unistd.h>
+#include <sys/capability.h>
// Move this shit to a separate wayland file, and have a separate file for x11.
@@ -118,6 +119,18 @@ static struct wl_registry_listener registry_listener = {
.global_remove = registry_remove_object,
};
+static void reset_cap_nice(void) {
+ cap_t caps = cap_get_proc();
+ if(!caps)
+ return;
+
+ const cap_value_t cap_to_remove = CAP_SYS_NICE;
+ cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap_to_remove, CAP_CLEAR);
+ cap_set_flag(caps, CAP_PERMITTED, 1, &cap_to_remove, CAP_CLEAR);
+ cap_set_proc(caps);
+ cap_free(caps);
+}
+
// TODO: Create egl context without surface (in other words, x11/wayland agnostic, doesn't require x11/wayland dependency)
static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
EGLConfig ecfg;
@@ -131,6 +144,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
const int32_t ctxattr[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, /* requires cap_sys_nice, ignored otherwise */
EGL_NONE
};
@@ -205,9 +219,11 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
goto fail;
}
+ reset_cap_nice();
return true;
fail:
+ reset_cap_nice();
gsr_egl_unload(self);
return false;
}