Skip to content

Commit

Permalink
Fix: unbreak picom compilation on OpenBSD using libepoxy
Browse files Browse the repository at this point in the history
Fix: clang style

Fix: src/meson.build style
  • Loading branch information
yukiteruamano committed Feb 8, 2024
1 parent a39cd94 commit 4977fbd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) Yuxuan Shui <[email protected]>
#ifndef __OpenBSD__
#include <GL/gl.h>
#include <GL/glext.h>
#else
#include <epoxy/gl.h>
#include <epoxy/glx.h>
#endif
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
Expand Down
5 changes: 4 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ host_system = host_machine.system()
if host_system == 'linux'
cflags += ['-DHAS_INOTIFY']
elif (host_system == 'freebsd' or host_system == 'netbsd' or
host_system == 'dragonfly' or host_system == 'openbsd')
host_system == 'dragonfly')
cflags += ['-DHAS_KQUEUE']
elif host_system == 'openbsd'
cflags += ['-DHAS_KQUEUE']
deps += [dependency('epoxy', required: true)]
endif

subdir('backend')
Expand Down
26 changes: 23 additions & 3 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
/// This requires the user to set up permissions for the real-time scheduling. e.g. by
/// setting `ulimit -r`, or giving us the CAP_SYS_NICE capability.
void set_rr_scheduling(void) {
#ifndef __OpenBSD__
int priority = sched_get_priority_min(SCHED_RR);

int ret;
Expand All @@ -2597,12 +2598,31 @@ void set_rr_scheduling(void) {
param.sched_priority = priority;
ret = sched_setscheduler(0, SCHED_RR, &param);
if (ret != 0) {
log_info("Failed to set real-time scheduling priority to %d. Consider "
"giving picom the CAP_SYS_NICE capability",
priority);
log_info("Failed to set real-time scheduling priority to %d.", priority);
return;
}
log_info("Set real-time scheduling priority to %d", priority);
#else // OpenBSD real-time scheduling support
int priority = sched_get_priority_min(SCHED_RR);

int old_policy;
int ret;
struct sched_param param;

ret = pthread_getschedparam(pthread_self(), &old_policy, &param);
if (ret != 0) {
log_debug("Failed to get old scheduling priority");
return;
}

param.sched_priority = priority;
ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
if (ret != 0) {
log_info("Failed to set real-time scheduling priority to %d.", priority);
return;
}
log_info("Set real-time scheduling priority to %d", priority);
#endif
}

/**
Expand Down

0 comments on commit 4977fbd

Please sign in to comment.