Skip to content

Commit

Permalink
Support OS::requestion_permission("CAMERA") on linuxbsd using XDG D…
Browse files Browse the repository at this point in the history
…esktop Portal
  • Loading branch information
j20001970 committed Dec 17, 2024
1 parent 0e3fdc4 commit 627caff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions platform/linuxbsd/os_linuxbsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include "wayland/display_server_wayland.h"
#endif

#ifdef DBUS_ENABLED
#include "freedesktop_portal_desktop.h"
#endif

#include "modules/modules_enabled.gen.h" // For regex.
#ifdef MODULE_REGEX_ENABLED
#include "modules/regex/regex.h"
Expand Down Expand Up @@ -214,6 +218,19 @@ bool OS_LinuxBSD::is_sandboxed() const {
return false;
}

#ifdef DBUS_ENABLED
bool OS_LinuxBSD::request_permission(const String &p_name) {
if (p_name == "CAMERA") {
if (FreeDesktopPortalDesktop::get_singleton()->access_camera()) {
// Always return false here, because we cannot know if permission is granted in advance.
return false;
}
// Desktop portal is not available in this case, return true like every other permission does.
}
return true;
}
#endif

void OS_LinuxBSD::finalize() {
if (main_loop) {
memdelete(main_loop);
Expand Down
4 changes: 4 additions & 0 deletions platform/linuxbsd/os_linuxbsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class OS_LinuxBSD : public OS_Unix {

virtual bool is_sandboxed() const override;

#ifdef DBUS_ENABLED
virtual bool request_permission(const String &p_name) override;
#endif

virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override;

virtual bool _check_internal_feature_support(const String &p_feature) override;
Expand Down

0 comments on commit 627caff

Please sign in to comment.