aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/CursorTracker/CursorTracker.hpp (renamed from include/CursorTracker.hpp)0
-rw-r--r--include/CursorTracker/CursorTrackerWayland.hpp (renamed from include/CursorTrackerWayland.hpp)0
-rw-r--r--include/CursorTracker/CursorTrackerX11.hpp (renamed from include/CursorTrackerX11.hpp)0
-rw-r--r--include/GlobalHotkeys/GlobalHotkeys.hpp (renamed from include/GlobalHotkeys.hpp)0
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysJoystick.hpp (renamed from include/GlobalHotkeysJoystick.hpp)2
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysLinux.hpp (renamed from include/GlobalHotkeysLinux.hpp)0
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysX11.hpp (renamed from include/GlobalHotkeysX11.hpp)0
-rw-r--r--include/Overlay.hpp4
-rw-r--r--meson.build10
-rw-r--r--src/Config.cpp2
-rw-r--r--src/CursorTracker/CursorTrackerWayland.cpp (renamed from src/CursorTrackerWayland.cpp)2
-rw-r--r--src/CursorTracker/CursorTrackerX11.cpp (renamed from src/CursorTrackerX11.cpp)4
-rw-r--r--src/GlobalHotkeys/GlobalHotkeysJoystick.cpp (renamed from src/GlobalHotkeysJoystick.cpp)2
-rw-r--r--src/GlobalHotkeys/GlobalHotkeysLinux.cpp (renamed from src/GlobalHotkeysLinux.cpp)2
-rw-r--r--src/GlobalHotkeys/GlobalHotkeysX11.cpp (renamed from src/GlobalHotkeysX11.cpp)2
-rw-r--r--src/Overlay.cpp19
-rw-r--r--src/gui/GlobalSettingsPage.cpp1
-rw-r--r--tools/gsr-global-hotkeys/keyboard_event.c20
18 files changed, 37 insertions, 33 deletions
diff --git a/include/CursorTracker.hpp b/include/CursorTracker/CursorTracker.hpp
index ff7374f..ff7374f 100644
--- a/include/CursorTracker.hpp
+++ b/include/CursorTracker/CursorTracker.hpp
diff --git a/include/CursorTrackerWayland.hpp b/include/CursorTracker/CursorTrackerWayland.hpp
index 1eeee83..1eeee83 100644
--- a/include/CursorTrackerWayland.hpp
+++ b/include/CursorTracker/CursorTrackerWayland.hpp
diff --git a/include/CursorTrackerX11.hpp b/include/CursorTracker/CursorTrackerX11.hpp
index 66618c4..66618c4 100644
--- a/include/CursorTrackerX11.hpp
+++ b/include/CursorTracker/CursorTrackerX11.hpp
diff --git a/include/GlobalHotkeys.hpp b/include/GlobalHotkeys/GlobalHotkeys.hpp
index 2927fa7..2927fa7 100644
--- a/include/GlobalHotkeys.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeys.hpp
diff --git a/include/GlobalHotkeysJoystick.hpp b/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp
index fde5be2..4b266cb 100644
--- a/include/GlobalHotkeysJoystick.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "GlobalHotkeys.hpp"
-#include "Hotplug.hpp"
+#include "../Hotplug.hpp"
#include <unordered_map>
#include <thread>
#include <poll.h>
diff --git a/include/GlobalHotkeysLinux.hpp b/include/GlobalHotkeys/GlobalHotkeysLinux.hpp
index 959d095..959d095 100644
--- a/include/GlobalHotkeysLinux.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysLinux.hpp
diff --git a/include/GlobalHotkeysX11.hpp b/include/GlobalHotkeys/GlobalHotkeysX11.hpp
index 610399a..610399a 100644
--- a/include/GlobalHotkeysX11.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysX11.hpp
diff --git a/include/Overlay.hpp b/include/Overlay.hpp
index 5af839e..4cfab1d 100644
--- a/include/Overlay.hpp
+++ b/include/Overlay.hpp
@@ -6,10 +6,10 @@
#include "Config.hpp"
#include "window_texture.h"
#include "WindowUtils.hpp"
-#include "GlobalHotkeysJoystick.hpp"
+#include "GlobalHotkeys/GlobalHotkeysJoystick.hpp"
#include "AudioPlayer.hpp"
#include "RegionSelector.hpp"
-#include "CursorTracker.hpp"
+#include "CursorTracker/CursorTracker.hpp"
#include <mglpp/window/Window.hpp>
#include <mglpp/window/Event.hpp>
diff --git a/meson.build b/meson.build
index 2b5cdb6..2f991ed 100644
--- a/meson.build
+++ b/meson.build
@@ -39,11 +39,11 @@ src = [
'src/GsrInfo.cpp',
'src/Process.cpp',
'src/Overlay.cpp',
- 'src/GlobalHotkeysX11.cpp',
- 'src/GlobalHotkeysLinux.cpp',
- 'src/GlobalHotkeysJoystick.cpp',
- 'src/CursorTrackerX11.cpp',
- 'src/CursorTrackerWayland.cpp',
+ 'src/GlobalHotkeys/GlobalHotkeysX11.cpp',
+ 'src/GlobalHotkeys/GlobalHotkeysLinux.cpp',
+ 'src/GlobalHotkeys/GlobalHotkeysJoystick.cpp',
+ 'src/CursorTracker/CursorTrackerX11.cpp',
+ 'src/CursorTracker/CursorTrackerWayland.cpp',
'src/AudioPlayer.cpp',
'src/Hotplug.cpp',
'src/Rpc.cpp',
diff --git a/src/Config.cpp b/src/Config.cpp
index e920bf0..2de6a96 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -1,7 +1,7 @@
#include "../include/Config.hpp"
#include "../include/Utils.hpp"
#include "../include/GsrInfo.hpp"
-#include "../include/GlobalHotkeys.hpp"
+#include "../include/GlobalHotkeys/GlobalHotkeys.hpp"
#include <variant>
#include <limits.h>
#include <inttypes.h>
diff --git a/src/CursorTrackerWayland.cpp b/src/CursorTracker/CursorTrackerWayland.cpp
index 9a0f442..b28b978 100644
--- a/src/CursorTrackerWayland.cpp
+++ b/src/CursorTracker/CursorTrackerWayland.cpp
@@ -1,4 +1,4 @@
-#include "../include/CursorTrackerWayland.hpp"
+#include "../../include/CursorTracker/CursorTrackerWayland.hpp"
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/src/CursorTrackerX11.cpp b/src/CursorTracker/CursorTrackerX11.cpp
index 7c40cea..7c98f4d 100644
--- a/src/CursorTrackerX11.cpp
+++ b/src/CursorTracker/CursorTrackerX11.cpp
@@ -1,5 +1,5 @@
-#include "../include/CursorTrackerX11.hpp"
-#include "../include/WindowUtils.hpp"
+#include "../../include/CursorTracker/CursorTrackerX11.hpp"
+#include "../../include/WindowUtils.hpp"
namespace gsr {
CursorTrackerX11::CursorTrackerX11(Display *dpy) : dpy(dpy) {
diff --git a/src/GlobalHotkeysJoystick.cpp b/src/GlobalHotkeys/GlobalHotkeysJoystick.cpp
index 822a73a..b3b21c8 100644
--- a/src/GlobalHotkeysJoystick.cpp
+++ b/src/GlobalHotkeys/GlobalHotkeysJoystick.cpp
@@ -1,4 +1,4 @@
-#include "../include/GlobalHotkeysJoystick.hpp"
+#include "../../include/GlobalHotkeys/GlobalHotkeysJoystick.hpp"
#include <string.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/src/GlobalHotkeysLinux.cpp b/src/GlobalHotkeys/GlobalHotkeysLinux.cpp
index d780916..a56bbc6 100644
--- a/src/GlobalHotkeysLinux.cpp
+++ b/src/GlobalHotkeys/GlobalHotkeysLinux.cpp
@@ -1,4 +1,4 @@
-#include "../include/GlobalHotkeysLinux.hpp"
+#include "../../include/GlobalHotkeys/GlobalHotkeysLinux.hpp"
#include <sys/wait.h>
#include <fcntl.h>
#include <limits.h>
diff --git a/src/GlobalHotkeysX11.cpp b/src/GlobalHotkeys/GlobalHotkeysX11.cpp
index 9af2607..bc79ce8 100644
--- a/src/GlobalHotkeysX11.cpp
+++ b/src/GlobalHotkeys/GlobalHotkeysX11.cpp
@@ -1,4 +1,4 @@
-#include "../include/GlobalHotkeysX11.hpp"
+#include "../../include/GlobalHotkeys/GlobalHotkeysX11.hpp"
#include <X11/keysym.h>
#include <mglpp/window/Event.hpp>
#include <assert.h>
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index 487b6bc..c423125 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -12,10 +12,10 @@
#include "../include/gui/Utils.hpp"
#include "../include/gui/PageStack.hpp"
#include "../include/WindowUtils.hpp"
-#include "../include/GlobalHotkeys.hpp"
-#include "../include/GlobalHotkeysLinux.hpp"
-#include "../include/CursorTrackerX11.hpp"
-#include "../include/CursorTrackerWayland.hpp"
+#include "../include/GlobalHotkeys/GlobalHotkeys.hpp"
+#include "../include/GlobalHotkeys/GlobalHotkeysLinux.hpp"
+#include "../include/CursorTracker/CursorTrackerX11.hpp"
+#include "../include/CursorTracker/CursorTrackerWayland.hpp"
#include <string.h>
#include <assert.h>
@@ -207,24 +207,21 @@ namespace gsr {
return false;
}*/
- // Returns the first monitor if not found. Assumes there is at least one monitor connected.
static const Monitor* find_monitor_at_position(const std::vector<Monitor> &monitors, mgl::vec2i pos) {
assert(!monitors.empty());
for(const Monitor &monitor : monitors) {
if(mgl::IntRect(monitor.position, monitor.size).contains(pos))
return &monitor;
}
- return &monitors.front();
+ return nullptr;
}
- // Returns the first monitor if not found. Assumes there is at least one monitor connected.
static const Monitor* find_monitor_by_name(const std::vector<Monitor> &monitors, const std::string &name) {
- assert(!monitors.empty());
for(const Monitor &monitor : monitors) {
if(monitor.name == name)
return &monitor;
}
- return &monitors.front();
+ return nullptr;
}
static std::string get_power_supply_online_filepath() {
@@ -894,10 +891,14 @@ namespace gsr {
const Monitor *focused_monitor = nullptr;
if(cursor_info) {
focused_monitor = find_monitor_by_name(monitors, cursor_info->monitor_name);
+ if(!focused_monitor)
+ focused_monitor = &monitors.front();
cursor_position = cursor_info->position;
} else {
const mgl::vec2i monitor_position_query_value = (x11_cursor_window || gsr_info.system_info.display_server != DisplayServer::WAYLAND) ? cursor_position : create_window_get_center_position(display);
focused_monitor = find_monitor_at_position(monitors, monitor_position_query_value);
+ if(!focused_monitor)
+ focused_monitor = &monitors.front();
}
// Wayland doesn't allow XGrabPointer/XGrabKeyboard when a wayland application is focused.
diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp
index ccebb92..5444ae5 100644
--- a/src/gui/GlobalSettingsPage.cpp
+++ b/src/gui/GlobalSettingsPage.cpp
@@ -1,7 +1,6 @@
#include "../../include/gui/GlobalSettingsPage.hpp"
#include "../../include/Overlay.hpp"
-#include "../../include/GlobalHotkeys.hpp"
#include "../../include/Theme.hpp"
#include "../../include/Process.hpp"
#include "../../include/gui/GsrPage.hpp"
diff --git a/tools/gsr-global-hotkeys/keyboard_event.c b/tools/gsr-global-hotkeys/keyboard_event.c
index bcfae6b..c7a54c3 100644
--- a/tools/gsr-global-hotkeys/keyboard_event.c
+++ b/tools/gsr-global-hotkeys/keyboard_event.c
@@ -404,8 +404,10 @@ static void keyboard_event_remove_event(keyboard_event *self, int index) {
if(index < 0 || index >= self->num_event_polls)
return;
- ioctl(self->event_polls[index].fd, EVIOCGRAB, 0);
- close(self->event_polls[index].fd);
+ if(self->event_polls[index].fd > 0) {
+ ioctl(self->event_polls[index].fd, EVIOCGRAB, 0);
+ close(self->event_polls[index].fd);
+ }
free(self->event_extra_data[index].key_states);
free(self->event_extra_data[index].key_presses_grabbed);
@@ -435,7 +437,7 @@ static int setup_virtual_keyboard_input(const char *name) {
success &= (ioctl(fd, UI_SET_EVBIT, EV_KEY) != -1);
success &= (ioctl(fd, UI_SET_EVBIT, EV_REP) != -1);
success &= (ioctl(fd, UI_SET_EVBIT, EV_REL) != -1);
- success &= (ioctl(fd, UI_SET_EVBIT, EV_LED) != -1);
+ //success &= (ioctl(fd, UI_SET_EVBIT, EV_LED) != -1);
success &= (ioctl(fd, UI_SET_MSCBIT, MSC_SCAN) != -1);
for(int i = 1; i < KEY_MAX; ++i) {
@@ -445,9 +447,9 @@ static int setup_virtual_keyboard_input(const char *name) {
for(int i = 0; i < REL_MAX; ++i) {
success &= (ioctl(fd, UI_SET_RELBIT, i) != -1);
}
- for(int i = 0; i < LED_MAX; ++i) {
- success &= (ioctl(fd, UI_SET_LEDBIT, i) != -1);
- }
+ // for(int i = 0; i < LED_MAX; ++i) {
+ // success &= (ioctl(fd, UI_SET_LEDBIT, i) != -1);
+ // }
// success &= (ioctl(fd, UI_SET_EVBIT, EV_ABS) != -1);
// success &= (ioctl(fd, UI_SET_ABSBIT, ABS_X) != -1);
@@ -566,8 +568,10 @@ void keyboard_event_deinit(keyboard_event *self) {
}
for(int i = 0; i < self->num_event_polls; ++i) {
- ioctl(self->event_polls[i].fd, EVIOCGRAB, 0);
- close(self->event_polls[i].fd);
+ if(self->event_polls[i].fd > 0) {
+ ioctl(self->event_polls[i].fd, EVIOCGRAB, 0);
+ close(self->event_polls[i].fd);
+ }
free(self->event_extra_data[i].key_states);
free(self->event_extra_data[i].key_presses_grabbed);
}