Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ freebsd_instance:
freebsd_task:
pkg_script:
- pkg update && pkg upgrade -y
- pkg install -y git ninja pkgconf cmake qt6-base qt6-svg qt6-tools boost-libs libsndfile protobuf avahi-libdns poco opus
- pkg install -y git ninja pkgconf cmake qt6-base qt6-svg qt6-tools boost-libs libsndfile protobuf avahi-libdns poco opus basu
fetch_submodules_script: git submodule --quiet update --init --recursive
build_script:
- mkdir build && cd build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ sudo apt -y install \
zsync \
appstream \
libpoco-dev \
libsqlite3-dev
libsqlite3-dev \
libsystemd-dev

# The package was initially called libqt6svg6-dev.
# Choose correct name based on the Ubuntu version along with some other version-specific setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ sudo apt -y install \
libsm-dev \
libspeechd-dev \
libavahi-compat-libdnssd-dev \
libasound2-dev
libasound2-dev \
libsystemd-dev

verify_required_env_variables_set

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
[submodule "3rdparty/CLI11"]
path = 3rdparty/CLI11
url = https://github.com/CLIUtils/CLI11.git
[submodule "3rdparty/os-events"]
path = 3rdparty/os-events
url = https://github.com/mumble-voip/os-events.git
1 change: 1 addition & 0 deletions 3rdparty/os-events
Submodule os-events added at 5d5025
2 changes: 1 addition & 1 deletion cmake/project-utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function(get_targets DEFINED_TARGETS DIR)
get_target_property(TARGET_TYPE "${CURRENT_TARGET}" TYPE)

# Only add the target if it is compilable
if("${TARGET_TYPE}" MATCHES "STATIC_LIBRARY|MODULE_LIBRARY|SHARED_LIBRARY|EXECUTABLE")
if("${TARGET_TYPE}" MATCHES "STATIC_LIBRARY|MODULE_LIBRARY|SHARED_LIBRARY|OBJECT_LIBRARY|EXECUTABLE")
list(APPEND DEFINED_TARGETS ${CURRENT_TARGET})
endif()
endforeach()
Expand Down
5 changes: 5 additions & 0 deletions src/mumble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,11 @@ elseif(TARGET Opus::opus)
target_link_libraries(mumble_client_object_lib PUBLIC Opus::opus)
endif()

set(OSEVENTS_EXPORT OFF)
add_subdirectory("${3RDPARTY_DIR}/os-events" "${CMAKE_BINARY_DIR}/os-events" EXCLUDE_FROM_ALL)
disable_warnings_for_all_targets_in("${3RDPARTY_DIR}/os-events")
target_link_libraries(mumble_client_object_lib PRIVATE osevents::osevents)

if(bundled-speex)
add_subdirectory("${3RDPARTY_DIR}/speexdsp-build" "${CMAKE_CURRENT_BINARY_DIR}/speexdsp" EXCLUDE_FROM_ALL)

Expand Down
25 changes: 25 additions & 0 deletions src/mumble/GlobalShortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@
# include <QtCore/QOperatingSystemVersion>
#endif

#include <osevents/session_lock.hpp>

#include <atomic>
#include <cassert>
#include <chrono>
#include <memory>

std::atomic< bool > GlobalShortcutEngine::allowShortcutProcessing = true;

const QString GlobalShortcutConfig::name = QLatin1String("GlobalShortcutConfig");

Expand Down Expand Up @@ -904,6 +910,21 @@ void GlobalShortcutConfig::accept() const {
GlobalShortcutEngine::GlobalShortcutEngine(QObject *p) : QThread(p) {
bNeedRemap = true;
needRemap();

try {
// This is to ensure that shortcuts won't work while the OS session is locked
static std::unique_ptr< osevents::SessionLock > sessionLockWatch;
if (!sessionLockWatch) {
sessionLockWatch = std::make_unique< osevents::SessionLock >();
sessionLockWatch->register_callback([](osevents::SessionLockState state) {
allowShortcutProcessing = state == osevents::SessionLockState::Unlocked;
});
}
} catch (std::runtime_error &e) {
qWarning() << "Failed to register session lock state observer -> disabling shortcuts to be on the safe side ("
<< e.what() << ")";
allowShortcutProcessing = false;
}
}

GlobalShortcutEngine::~GlobalShortcutEngine() {
Expand Down Expand Up @@ -987,6 +1008,10 @@ void GlobalShortcutEngine::needRemap() {
* @return True if button is suppressed, otherwise false
*/
bool GlobalShortcutEngine::handleButton(const QVariant &button, bool down) {
if (!allowShortcutProcessing) {
return false;
}

bool already = qlDownButtons.contains(button);
if (already == down)
return qlSuppressed.contains(button);
Expand Down
9 changes: 7 additions & 2 deletions src/mumble/GlobalShortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "MUComboBox.h"
#include "Timer.h"

#include <atomic>

#include "ui_GlobalShortcut.h"
#include "ui_GlobalShortcutTarget.h"

Expand Down Expand Up @@ -232,9 +234,7 @@ struct ShortcutKey {
* @see GlobalShortcutWin
*/
class GlobalShortcutEngine : public QThread {
private:
Q_OBJECT
Q_DISABLE_COPY(GlobalShortcutEngine)
public:
struct ButtonInfo {
QString device;
Expand All @@ -260,6 +260,8 @@ class GlobalShortcutEngine : public QThread {

GlobalShortcutEngine(QObject *p = nullptr);
~GlobalShortcutEngine() Q_DECL_OVERRIDE;
Q_DISABLE_COPY(GlobalShortcutEngine)

void resetMap();
void remap();
virtual void needRemap();
Expand All @@ -277,6 +279,9 @@ class GlobalShortcutEngine : public QThread {
virtual ButtonInfo buttonInfo(const QVariant &) = 0;
signals:
void buttonPressed(bool last);

private:
static std::atomic< bool > allowShortcutProcessing;
};

#endif
Loading