mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-07 15:19:56 +09:00
Keep keyboard led when turning on global hotkeys, move files
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "GlobalHotkeys.hpp"
|
#include "GlobalHotkeys.hpp"
|
||||||
#include "Hotplug.hpp"
|
#include "../Hotplug.hpp"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -6,10 +6,10 @@
|
|||||||
#include "Config.hpp"
|
#include "Config.hpp"
|
||||||
#include "window_texture.h"
|
#include "window_texture.h"
|
||||||
#include "WindowUtils.hpp"
|
#include "WindowUtils.hpp"
|
||||||
#include "GlobalHotkeysJoystick.hpp"
|
#include "GlobalHotkeys/GlobalHotkeysJoystick.hpp"
|
||||||
#include "AudioPlayer.hpp"
|
#include "AudioPlayer.hpp"
|
||||||
#include "RegionSelector.hpp"
|
#include "RegionSelector.hpp"
|
||||||
#include "CursorTracker.hpp"
|
#include "CursorTracker/CursorTracker.hpp"
|
||||||
|
|
||||||
#include <mglpp/window/Window.hpp>
|
#include <mglpp/window/Window.hpp>
|
||||||
#include <mglpp/window/Event.hpp>
|
#include <mglpp/window/Event.hpp>
|
||||||
|
|||||||
10
meson.build
10
meson.build
@@ -39,11 +39,11 @@ src = [
|
|||||||
'src/GsrInfo.cpp',
|
'src/GsrInfo.cpp',
|
||||||
'src/Process.cpp',
|
'src/Process.cpp',
|
||||||
'src/Overlay.cpp',
|
'src/Overlay.cpp',
|
||||||
'src/GlobalHotkeysX11.cpp',
|
'src/GlobalHotkeys/GlobalHotkeysX11.cpp',
|
||||||
'src/GlobalHotkeysLinux.cpp',
|
'src/GlobalHotkeys/GlobalHotkeysLinux.cpp',
|
||||||
'src/GlobalHotkeysJoystick.cpp',
|
'src/GlobalHotkeys/GlobalHotkeysJoystick.cpp',
|
||||||
'src/CursorTrackerX11.cpp',
|
'src/CursorTracker/CursorTrackerX11.cpp',
|
||||||
'src/CursorTrackerWayland.cpp',
|
'src/CursorTracker/CursorTrackerWayland.cpp',
|
||||||
'src/AudioPlayer.cpp',
|
'src/AudioPlayer.cpp',
|
||||||
'src/Hotplug.cpp',
|
'src/Hotplug.cpp',
|
||||||
'src/Rpc.cpp',
|
'src/Rpc.cpp',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "../include/Config.hpp"
|
#include "../include/Config.hpp"
|
||||||
#include "../include/Utils.hpp"
|
#include "../include/Utils.hpp"
|
||||||
#include "../include/GsrInfo.hpp"
|
#include "../include/GsrInfo.hpp"
|
||||||
#include "../include/GlobalHotkeys.hpp"
|
#include "../include/GlobalHotkeys/GlobalHotkeys.hpp"
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/CursorTrackerWayland.hpp"
|
#include "../../include/CursorTracker/CursorTrackerWayland.hpp"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "../include/CursorTrackerX11.hpp"
|
#include "../../include/CursorTracker/CursorTrackerX11.hpp"
|
||||||
#include "../include/WindowUtils.hpp"
|
#include "../../include/WindowUtils.hpp"
|
||||||
|
|
||||||
namespace gsr {
|
namespace gsr {
|
||||||
CursorTrackerX11::CursorTrackerX11(Display *dpy) : dpy(dpy) {
|
CursorTrackerX11::CursorTrackerX11(Display *dpy) : dpy(dpy) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/GlobalHotkeysJoystick.hpp"
|
#include "../../include/GlobalHotkeys/GlobalHotkeysJoystick.hpp"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/GlobalHotkeysLinux.hpp"
|
#include "../../include/GlobalHotkeys/GlobalHotkeysLinux.hpp"
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../include/GlobalHotkeysX11.hpp"
|
#include "../../include/GlobalHotkeys/GlobalHotkeysX11.hpp"
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <mglpp/window/Event.hpp>
|
#include <mglpp/window/Event.hpp>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
#include "../include/gui/Utils.hpp"
|
#include "../include/gui/Utils.hpp"
|
||||||
#include "../include/gui/PageStack.hpp"
|
#include "../include/gui/PageStack.hpp"
|
||||||
#include "../include/WindowUtils.hpp"
|
#include "../include/WindowUtils.hpp"
|
||||||
#include "../include/GlobalHotkeys.hpp"
|
#include "../include/GlobalHotkeys/GlobalHotkeys.hpp"
|
||||||
#include "../include/GlobalHotkeysLinux.hpp"
|
#include "../include/GlobalHotkeys/GlobalHotkeysLinux.hpp"
|
||||||
#include "../include/CursorTrackerX11.hpp"
|
#include "../include/CursorTracker/CursorTrackerX11.hpp"
|
||||||
#include "../include/CursorTrackerWayland.hpp"
|
#include "../include/CursorTracker/CursorTrackerWayland.hpp"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -207,24 +207,21 @@ namespace gsr {
|
|||||||
return false;
|
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) {
|
static const Monitor* find_monitor_at_position(const std::vector<Monitor> &monitors, mgl::vec2i pos) {
|
||||||
assert(!monitors.empty());
|
assert(!monitors.empty());
|
||||||
for(const Monitor &monitor : monitors) {
|
for(const Monitor &monitor : monitors) {
|
||||||
if(mgl::IntRect(monitor.position, monitor.size).contains(pos))
|
if(mgl::IntRect(monitor.position, monitor.size).contains(pos))
|
||||||
return &monitor;
|
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) {
|
static const Monitor* find_monitor_by_name(const std::vector<Monitor> &monitors, const std::string &name) {
|
||||||
assert(!monitors.empty());
|
|
||||||
for(const Monitor &monitor : monitors) {
|
for(const Monitor &monitor : monitors) {
|
||||||
if(monitor.name == name)
|
if(monitor.name == name)
|
||||||
return &monitor;
|
return &monitor;
|
||||||
}
|
}
|
||||||
return &monitors.front();
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string get_power_supply_online_filepath() {
|
static std::string get_power_supply_online_filepath() {
|
||||||
@@ -894,10 +891,14 @@ namespace gsr {
|
|||||||
const Monitor *focused_monitor = nullptr;
|
const Monitor *focused_monitor = nullptr;
|
||||||
if(cursor_info) {
|
if(cursor_info) {
|
||||||
focused_monitor = find_monitor_by_name(monitors, cursor_info->monitor_name);
|
focused_monitor = find_monitor_by_name(monitors, cursor_info->monitor_name);
|
||||||
|
if(!focused_monitor)
|
||||||
|
focused_monitor = &monitors.front();
|
||||||
cursor_position = cursor_info->position;
|
cursor_position = cursor_info->position;
|
||||||
} else {
|
} 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);
|
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);
|
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.
|
// Wayland doesn't allow XGrabPointer/XGrabKeyboard when a wayland application is focused.
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "../../include/gui/GlobalSettingsPage.hpp"
|
#include "../../include/gui/GlobalSettingsPage.hpp"
|
||||||
|
|
||||||
#include "../../include/Overlay.hpp"
|
#include "../../include/Overlay.hpp"
|
||||||
#include "../../include/GlobalHotkeys.hpp"
|
|
||||||
#include "../../include/Theme.hpp"
|
#include "../../include/Theme.hpp"
|
||||||
#include "../../include/Process.hpp"
|
#include "../../include/Process.hpp"
|
||||||
#include "../../include/gui/GsrPage.hpp"
|
#include "../../include/gui/GsrPage.hpp"
|
||||||
|
|||||||
@@ -404,8 +404,10 @@ static void keyboard_event_remove_event(keyboard_event *self, int index) {
|
|||||||
if(index < 0 || index >= self->num_event_polls)
|
if(index < 0 || index >= self->num_event_polls)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(self->event_polls[index].fd > 0) {
|
||||||
ioctl(self->event_polls[index].fd, EVIOCGRAB, 0);
|
ioctl(self->event_polls[index].fd, EVIOCGRAB, 0);
|
||||||
close(self->event_polls[index].fd);
|
close(self->event_polls[index].fd);
|
||||||
|
}
|
||||||
free(self->event_extra_data[index].key_states);
|
free(self->event_extra_data[index].key_states);
|
||||||
free(self->event_extra_data[index].key_presses_grabbed);
|
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_KEY) != -1);
|
||||||
success &= (ioctl(fd, UI_SET_EVBIT, EV_REP) != -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_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);
|
success &= (ioctl(fd, UI_SET_MSCBIT, MSC_SCAN) != -1);
|
||||||
for(int i = 1; i < KEY_MAX; ++i) {
|
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) {
|
for(int i = 0; i < REL_MAX; ++i) {
|
||||||
success &= (ioctl(fd, UI_SET_RELBIT, i) != -1);
|
success &= (ioctl(fd, UI_SET_RELBIT, i) != -1);
|
||||||
}
|
}
|
||||||
for(int i = 0; i < LED_MAX; ++i) {
|
// for(int i = 0; i < LED_MAX; ++i) {
|
||||||
success &= (ioctl(fd, UI_SET_LEDBIT, i) != -1);
|
// success &= (ioctl(fd, UI_SET_LEDBIT, i) != -1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// success &= (ioctl(fd, UI_SET_EVBIT, EV_ABS) != -1);
|
// success &= (ioctl(fd, UI_SET_EVBIT, EV_ABS) != -1);
|
||||||
// success &= (ioctl(fd, UI_SET_ABSBIT, ABS_X) != -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) {
|
for(int i = 0; i < self->num_event_polls; ++i) {
|
||||||
|
if(self->event_polls[i].fd > 0) {
|
||||||
ioctl(self->event_polls[i].fd, EVIOCGRAB, 0);
|
ioctl(self->event_polls[i].fd, EVIOCGRAB, 0);
|
||||||
close(self->event_polls[i].fd);
|
close(self->event_polls[i].fd);
|
||||||
|
}
|
||||||
free(self->event_extra_data[i].key_states);
|
free(self->event_extra_data[i].key_states);
|
||||||
free(self->event_extra_data[i].key_presses_grabbed);
|
free(self->event_extra_data[i].key_presses_grabbed);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user