mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-07 23:20:26 +09:00
Re-add kwin and hyprland helper to get window title, this time without a thread
This commit is contained in:
20
include/DesktopEnvironment/DesktopEnvironment.hpp
Normal file
20
include/DesktopEnvironment/DesktopEnvironment.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace gsr {
|
||||
class DesktopEnvironment {
|
||||
public:
|
||||
DesktopEnvironment() = default;
|
||||
DesktopEnvironment(const DesktopEnvironment&) = delete;
|
||||
DesktopEnvironment& operator=(const DesktopEnvironment&) = delete;
|
||||
virtual ~DesktopEnvironment() = default;
|
||||
|
||||
virtual bool start() = 0;
|
||||
virtual void update() = 0;
|
||||
// Return an empty string if none
|
||||
virtual std::string get_focused_window_title() = 0;
|
||||
// Return an empty string if unknown
|
||||
//virtual std::string get_focused_monitor_name() = 0;
|
||||
};
|
||||
}
|
||||
30
include/DesktopEnvironment/DesktopEnvironmentHyprland.hpp
Normal file
30
include/DesktopEnvironment/DesktopEnvironmentHyprland.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "DesktopEnvironment.hpp"
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace gsr {
|
||||
class DesktopEnvironmentHyprland : public DesktopEnvironment {
|
||||
public:
|
||||
DesktopEnvironmentHyprland() = default;
|
||||
DesktopEnvironmentHyprland(const DesktopEnvironmentHyprland&) = delete;
|
||||
DesktopEnvironmentHyprland& operator=(const DesktopEnvironmentHyprland&) = delete;
|
||||
~DesktopEnvironmentHyprland();
|
||||
|
||||
bool start() override;
|
||||
void update() override;
|
||||
std::string get_focused_window_title() override;
|
||||
//std::string get_focused_monitor_name() override;
|
||||
private:
|
||||
void shutdown();
|
||||
private:
|
||||
pid_t process_id = -1;
|
||||
FILE *stdout_file = nullptr;
|
||||
int read_fd = -1;
|
||||
char line_buffer[1024];
|
||||
std::string line;
|
||||
|
||||
std::string window_title;
|
||||
};
|
||||
}
|
||||
29
include/DesktopEnvironment/DesktopEnvironmentKde.hpp
Normal file
29
include/DesktopEnvironment/DesktopEnvironmentKde.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "DesktopEnvironment.hpp"
|
||||
|
||||
namespace gsr {
|
||||
class DesktopEnvironmentKde : public DesktopEnvironment {
|
||||
public:
|
||||
DesktopEnvironmentKde() = default;
|
||||
DesktopEnvironmentKde(const DesktopEnvironmentKde&) = delete;
|
||||
DesktopEnvironmentKde& operator=(const DesktopEnvironmentKde&) = delete;
|
||||
~DesktopEnvironmentKde();
|
||||
|
||||
bool start() override;
|
||||
void update() override;
|
||||
std::string get_focused_window_title() override;
|
||||
//std::string get_focused_monitor_name() override;
|
||||
private:
|
||||
void shutdown();
|
||||
private:
|
||||
pid_t process_id = -1;
|
||||
FILE *stdout_file = nullptr;
|
||||
int read_fd = -1;
|
||||
char line_buffer[1024];
|
||||
std::string line;
|
||||
|
||||
std::string window_title;
|
||||
std::string monitor_name;
|
||||
};
|
||||
}
|
||||
21
include/DesktopEnvironment/DesktopEnvironmentX11.hpp
Normal file
21
include/DesktopEnvironment/DesktopEnvironmentX11.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "DesktopEnvironment.hpp"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
namespace gsr {
|
||||
class DesktopEnvironmentX11 : public DesktopEnvironment {
|
||||
public:
|
||||
DesktopEnvironmentX11(Display *dpy) : dpy(dpy) {}
|
||||
DesktopEnvironmentX11(const DesktopEnvironmentX11&) = delete;
|
||||
DesktopEnvironmentX11& operator=(const DesktopEnvironmentX11&) = delete;
|
||||
~DesktopEnvironmentX11();
|
||||
|
||||
bool start() override;
|
||||
void update() override;
|
||||
std::string get_focused_window_title() override;
|
||||
//std::string get_focused_monitor_name() override;
|
||||
private:
|
||||
Display *dpy = NULL;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user