mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Fix incorrect region captured on wayland when using monitor scaling and without letting x11 scale monitors
This commit is contained in:
@@ -1,44 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "CursorTracker.hpp"
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
struct wl_display;
|
||||
struct wl_registry;
|
||||
struct wl_output;
|
||||
struct zxdg_output_manager_v1;
|
||||
struct zxdg_output_v1;
|
||||
|
||||
namespace gsr {
|
||||
struct WaylandOutput {
|
||||
uint32_t wl_name;
|
||||
struct wl_output *output;
|
||||
struct zxdg_output_v1 *xdg_output;
|
||||
mgl::vec2i pos;
|
||||
mgl::vec2i size;
|
||||
int32_t transform;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class CursorTrackerWayland : public CursorTracker {
|
||||
public:
|
||||
CursorTrackerWayland(const char *card_path);
|
||||
CursorTrackerWayland(const char *card_path, struct wl_display *wayland_dpy);
|
||||
CursorTrackerWayland(const CursorTrackerWayland&) = delete;
|
||||
CursorTrackerWayland& operator=(const CursorTrackerWayland&) = delete;
|
||||
~CursorTrackerWayland();
|
||||
|
||||
void update() override;
|
||||
std::optional<CursorInfo> get_latest_cursor_info() override;
|
||||
|
||||
std::vector<WaylandOutput> monitors;
|
||||
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
|
||||
private:
|
||||
void clear_monitors();
|
||||
void set_monitor_outputs_from_xdg_output(struct wl_display *dpy);
|
||||
private:
|
||||
int drm_fd = -1;
|
||||
mgl::vec2i latest_cursor_position; // Position of the cursor within the monitor
|
||||
int latest_crtc_id = -1;
|
||||
struct wl_display *wayland_dpy = nullptr;
|
||||
};
|
||||
}
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
struct wl_display;
|
||||
|
||||
namespace gsr {
|
||||
class DropdownButton;
|
||||
class GlobalHotkeys;
|
||||
@@ -162,6 +164,9 @@ namespace gsr {
|
||||
void on_press_take_screenshot(bool finished_selection, ScreenshotForceType force_type);
|
||||
bool update_compositor_texture(const Monitor &monitor);
|
||||
|
||||
void add_region_command(std::vector<const char*> &args, char *region_str, int region_str_size);
|
||||
void add_common_gpu_screen_recorder_args(std::vector<const char*> &args, const RecordOptions &record_options, const std::vector<std::string> &audio_tracks, const std::string &video_bitrate, const char *region, char *region_str, int region_str_size, const std::string ®ion_area_option);
|
||||
|
||||
std::string get_capture_target(const std::string &capture_target, const SupportedCaptureOptions &capture_options);
|
||||
|
||||
void force_window_on_top();
|
||||
@@ -250,6 +255,8 @@ namespace gsr {
|
||||
Display *x11_dpy = nullptr;
|
||||
XEvent x11_mapping_xev;
|
||||
|
||||
struct wl_display *wayland_dpy = nullptr;
|
||||
|
||||
mgl::Clock replay_save_clock;
|
||||
bool replay_save_show_notification = false;
|
||||
ReplayStartupMode replay_startup_mode = ReplayStartupMode::TURN_ON_AT_SYSTEM_STARTUP;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct wl_display;
|
||||
|
||||
namespace gsr {
|
||||
struct Region {
|
||||
mgl::vec2i pos;
|
||||
@@ -28,7 +30,7 @@ namespace gsr {
|
||||
bool poll_events();
|
||||
bool take_selection();
|
||||
bool take_canceled();
|
||||
Region get_selection() const;
|
||||
Region get_selection(Display *x11_dpy, struct wl_display *wayland_dpy) const;
|
||||
private:
|
||||
void on_button_press(const void *de);
|
||||
void on_button_release(const void *de);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <optional>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct wl_display;
|
||||
|
||||
namespace gsr {
|
||||
enum class WindowCaptureType {
|
||||
FOCUSED,
|
||||
@@ -13,8 +15,8 @@ namespace gsr {
|
||||
};
|
||||
|
||||
struct Monitor {
|
||||
mgl::vec2i position;
|
||||
mgl::vec2i size;
|
||||
mgl::vec2i position; // Logical position on Wayland
|
||||
mgl::vec2i size; // Logical size on Wayland
|
||||
std::string name;
|
||||
};
|
||||
|
||||
@@ -30,6 +32,7 @@ namespace gsr {
|
||||
std::string get_window_manager_name(Display *display);
|
||||
bool is_compositor_running(Display *dpy, int screen);
|
||||
std::vector<Monitor> get_monitors(Display *dpy);
|
||||
std::vector<Monitor> get_monitors_wayland(struct wl_display *dpy);
|
||||
void xi_grab_all_mouse_devices(Display *dpy);
|
||||
void xi_ungrab_all_mouse_devices(Display *dpy);
|
||||
void xi_warp_all_mouse_devices(Display *dpy, mgl::vec2i position);
|
||||
|
||||
Reference in New Issue
Block a user