Update to latest mglpp

This commit is contained in:
dec05eba
2025-04-20 01:14:03 +02:00
parent 4d8328a8d5
commit 28481db82c
7 changed files with 37 additions and 28 deletions

View File

@@ -22,8 +22,7 @@ GPU Screen Recorder UI uses meson build system so you need to install `meson` to
## Build dependencies ## Build dependencies
These are the dependencies needed to build GPU Screen Recorder UI: These are the dependencies needed to build GPU Screen Recorder UI:
* x11 (libx11, libxrandr, libxrender, libxcomposite, libxfixes, libxext, libxi) * x11 (libx11, libxrandr, libxrender, libxcomposite, libxfixes, libxext, libxi, libxcursor)
* libxcursor
* libglvnd (which provides libgl, libglx and libegl) * libglvnd (which provides libgl, libglx and libegl)
* linux-api-headers * linux-api-headers
* libpulse (libpulse-simple) * libpulse (libpulse-simple)
@@ -48,7 +47,7 @@ If you are stuck in such a lock where you cant press and keyboard keys you can p
This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`.\ This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`.\
`images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `CC BY-SA 3.0`.\ `images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `CC BY-SA 3.0`.\
The controller buttons under `images/` were created by [Julio Cacko](https://juliocacko.itch.io/free-input-prompts) and they are licensed under `CC0 1.0 Universal`.\ The controller buttons under `images/` were created by [Julio Cacko](https://juliocacko.itch.io/free-input-prompts) and they are licensed under `CC0 1.0 Universal`.\
The PlayStation logo under `images/` was created by [ArksDigital](https://arks.itch.io/ps4-buttons) and it's are licensed under `CC BY 4.0`. The PlayStation logo under `images/` was created by [ArksDigital](https://arks.itch.io/ps4-buttons) and it's licensed under `CC BY 4.0`.
# Reporting bugs, contributing patches, questions or donation # Reporting bugs, contributing patches, questions or donation
See [https://git.dec05eba.com/?p=about](https://git.dec05eba.com/?p=about).\ See [https://git.dec05eba.com/?p=about](https://git.dec05eba.com/?p=about).\

View File

@@ -75,6 +75,7 @@ executable(
dependency('xext'), dependency('xext'),
dependency('xi'), dependency('xi'),
dependency('xcursor'), dependency('xcursor'),
dependency('xrandr'),
dependency('libpulse-simple'), dependency('libpulse-simple'),
dependency('libdrm'), dependency('libdrm'),
dependency('wayland-client'), dependency('wayland-client'),

View File

@@ -16,6 +16,7 @@ xfixes = ">=0"
xext = ">=0" xext = ">=0"
xi = ">=0" xi = ">=0"
xcursor = ">=1" xcursor = ">=1"
xrandr = ">=0.5"
libpulse-simple = ">=0" libpulse-simple = ">=0"
libdrm = ">=2" libdrm = ">=2"
wayland-client = ">=1" wayland-client = ">=1"

View File

@@ -556,8 +556,8 @@ namespace gsr {
memset(xi_output_xev, 0, sizeof(*xi_output_xev)); memset(xi_output_xev, 0, sizeof(*xi_output_xev));
xi_output_xev->type = MotionNotify; xi_output_xev->type = MotionNotify;
xi_output_xev->xmotion.display = display; xi_output_xev->xmotion.display = display;
xi_output_xev->xmotion.window = window->get_system_handle(); xi_output_xev->xmotion.window = (Window)window->get_system_handle();
xi_output_xev->xmotion.subwindow = window->get_system_handle(); xi_output_xev->xmotion.subwindow = (Window)window->get_system_handle();
xi_output_xev->xmotion.x = de->root_x - window_pos.x; xi_output_xev->xmotion.x = de->root_x - window_pos.x;
xi_output_xev->xmotion.y = de->root_y - window_pos.y; xi_output_xev->xmotion.y = de->root_y - window_pos.y;
xi_output_xev->xmotion.x_root = de->root_x; xi_output_xev->xmotion.x_root = de->root_x;
@@ -569,8 +569,8 @@ namespace gsr {
memset(xi_output_xev, 0, sizeof(*xi_output_xev)); memset(xi_output_xev, 0, sizeof(*xi_output_xev));
xi_output_xev->type = cookie->evtype == XI_ButtonPress ? ButtonPress : ButtonRelease; xi_output_xev->type = cookie->evtype == XI_ButtonPress ? ButtonPress : ButtonRelease;
xi_output_xev->xbutton.display = display; xi_output_xev->xbutton.display = display;
xi_output_xev->xbutton.window = window->get_system_handle(); xi_output_xev->xbutton.window = (Window)window->get_system_handle();
xi_output_xev->xbutton.subwindow = window->get_system_handle(); xi_output_xev->xbutton.subwindow = (Window)window->get_system_handle();
xi_output_xev->xbutton.x = de->root_x - window_pos.x; xi_output_xev->xbutton.x = de->root_x - window_pos.x;
xi_output_xev->xbutton.y = de->root_y - window_pos.y; xi_output_xev->xbutton.y = de->root_y - window_pos.y;
xi_output_xev->xbutton.x_root = de->root_x; xi_output_xev->xbutton.x_root = de->root_x;
@@ -583,8 +583,8 @@ namespace gsr {
memset(xi_output_xev, 0, sizeof(*xi_output_xev)); memset(xi_output_xev, 0, sizeof(*xi_output_xev));
xi_output_xev->type = cookie->evtype == XI_KeyPress ? KeyPress : KeyRelease; xi_output_xev->type = cookie->evtype == XI_KeyPress ? KeyPress : KeyRelease;
xi_output_xev->xkey.display = display; xi_output_xev->xkey.display = display;
xi_output_xev->xkey.window = window->get_system_handle(); xi_output_xev->xkey.window = (Window)window->get_system_handle();
xi_output_xev->xkey.subwindow = window->get_system_handle(); xi_output_xev->xkey.subwindow = (Window)window->get_system_handle();
xi_output_xev->xkey.x = de->root_x - window_pos.x; xi_output_xev->xkey.x = de->root_x - window_pos.x;
xi_output_xev->xkey.y = de->root_y - window_pos.y; xi_output_xev->xkey.y = de->root_y - window_pos.y;
xi_output_xev->xkey.x_root = de->root_x; xi_output_xev->xkey.x_root = de->root_x;
@@ -767,13 +767,13 @@ namespace gsr {
// There should be a debug mode to not use these // There should be a debug mode to not use these
mgl_context *context = mgl_get_context(); mgl_context *context = mgl_get_context();
Display *display = (Display*)context->connection; Display *display = (Display*)context->connection;
XGrabPointer(display, window->get_system_handle(), True, XGrabPointer(display, (Window)window->get_system_handle(), True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask | Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask |
ButtonMotionMask, ButtonMotionMask,
GrabModeAsync, GrabModeAsync, None, default_cursor, CurrentTime); GrabModeAsync, GrabModeAsync, None, default_cursor, CurrentTime);
// TODO: This breaks global hotkeys (when using x11 global hotkeys) // TODO: This breaks global hotkeys (when using x11 global hotkeys)
XGrabKeyboard(display, window->get_system_handle(), True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabKeyboard(display, (Window)window->get_system_handle(), True, GrabModeAsync, GrabModeAsync, CurrentTime);
XFlush(display); XFlush(display);
} }
@@ -907,7 +907,7 @@ namespace gsr {
// Nvidia + Wayland + Egl doesn't work on some systems properly and it instead falls back to software rendering. // Nvidia + Wayland + Egl doesn't work on some systems properly and it instead falls back to software rendering.
// Use Glx on Wayland to workaround this issue. This is fine since Egl is only needed for x11 to reliably get the texture of the fullscreen window on Nvidia // Use Glx on Wayland to workaround this issue. This is fine since Egl is only needed for x11 to reliably get the texture of the fullscreen window on Nvidia
// when a compositor isn't running. // when a compositor isn't running.
window_create_params.render_api = gsr_info.system_info.display_server == DisplayServer::WAYLAND ? MGL_RENDER_API_GLX : MGL_RENDER_API_EGL; window_create_params.graphics_api = gsr_info.system_info.display_server == DisplayServer::WAYLAND ? MGL_GRAPHICS_API_GLX : MGL_GRAPHICS_API_EGL;
if(!window->create("gsr ui", window_create_params)) if(!window->create("gsr ui", window_create_params))
fprintf(stderr, "error: failed to create window\n"); fprintf(stderr, "error: failed to create window\n");
@@ -915,10 +915,10 @@ namespace gsr {
//window->set_low_latency(true); //window->set_low_latency(true);
unsigned char data = 2; // Prefer being composed to allow transparency unsigned char data = 2; // Prefer being composed to allow transparency
XChangeProperty(display, window->get_system_handle(), XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False), XA_CARDINAL, 32, PropModeReplace, &data, 1); XChangeProperty(display, (Window)window->get_system_handle(), XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False), XA_CARDINAL, 32, PropModeReplace, &data, 1);
data = 1; data = 1;
XChangeProperty(display, window->get_system_handle(), XInternAtom(display, "GAMESCOPE_EXTERNAL_OVERLAY", False), XA_CARDINAL, 32, PropModeReplace, &data, 1); XChangeProperty(display, (Window)window->get_system_handle(), XInternAtom(display, "GAMESCOPE_EXTERNAL_OVERLAY", False), XA_CARDINAL, 32, PropModeReplace, &data, 1);
const auto original_window_size = window_size; const auto original_window_size = window_size;
window_pos = focused_monitor->position; window_pos = focused_monitor->position;
@@ -952,12 +952,12 @@ namespace gsr {
//window->set_fullscreen(true); //window->set_fullscreen(true);
if(gsr_info.system_info.display_server == DisplayServer::X11) if(gsr_info.system_info.display_server == DisplayServer::X11)
make_window_click_through(display, window->get_system_handle()); make_window_click_through(display, (Window)window->get_system_handle());
window->set_visible(true); window->set_visible(true);
make_window_sticky(display, window->get_system_handle()); make_window_sticky(display, (Window)window->get_system_handle());
hide_window_from_taskbar(display, window->get_system_handle()); hide_window_from_taskbar(display, (Window)window->get_system_handle());
if(default_cursor) { if(default_cursor) {
XFreeCursor(display, default_cursor); XFreeCursor(display, default_cursor);
@@ -1557,7 +1557,7 @@ namespace gsr {
Display *display = (Display*)context->connection; Display *display = (Display*)context->connection;
const std::string video_filename = filepath_get_filename(video_filepath); const std::string video_filename = filepath_get_filename(video_filepath);
const Window gsr_ui_window = window ? window->get_system_handle() : None; const Window gsr_ui_window = window ? (Window)window->get_system_handle() : None;
std::string focused_window_name = get_window_name_at_cursor_position(display, gsr_ui_window); std::string focused_window_name = get_window_name_at_cursor_position(display, gsr_ui_window);
if(focused_window_name.empty()) if(focused_window_name.empty())
focused_window_name = get_focused_window_name(display, WindowCaptureType::FOCUSED); focused_window_name = get_focused_window_name(display, WindowCaptureType::FOCUSED);
@@ -1787,7 +1787,7 @@ namespace gsr {
Display *display = (Display*)context->connection; Display *display = (Display*)context->connection;
const Window focused_window = get_focused_window(display, WindowCaptureType::FOCUSED); const Window focused_window = get_focused_window(display, WindowCaptureType::FOCUSED);
if(window && focused_window == window->get_system_handle()) if(window && focused_window == (Window)window->get_system_handle())
return; return;
const bool prev_focused_window_is_fullscreen = focused_window_is_fullscreen; const bool prev_focused_window_is_fullscreen = focused_window_is_fullscreen;
@@ -2605,7 +2605,7 @@ namespace gsr {
mgl_context *context = mgl_get_context(); mgl_context *context = mgl_get_context();
Display *display = (Display*)context->connection; Display *display = (Display*)context->connection;
XRaiseWindow(display, window->get_system_handle()); XRaiseWindow(display, (Window)window->get_system_handle());
XFlush(display); XFlush(display);
} }
} }

View File

@@ -5,6 +5,7 @@
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
#include <X11/extensions/Xfixes.h> #include <X11/extensions/Xfixes.h>
#include <X11/extensions/shapeconst.h> #include <X11/extensions/shapeconst.h>
#include <X11/extensions/Xrandr.h>
#include <mglpp/system/Utf8.hpp> #include <mglpp/system/Utf8.hpp>
@@ -518,14 +519,21 @@ namespace gsr {
return XGetSelectionOwner(dpy, prop_atom) != None; return XGetSelectionOwner(dpy, prop_atom) != None;
} }
static void get_monitors_callback(const mgl_monitor *monitor, void *userdata) {
std::vector<Monitor> *monitors = (std::vector<Monitor>*)userdata;
monitors->push_back({mgl::vec2i(monitor->pos.x, monitor->pos.y), mgl::vec2i(monitor->size.x, monitor->size.y), std::string(monitor->name)});
}
std::vector<Monitor> get_monitors(Display *dpy) { std::vector<Monitor> get_monitors(Display *dpy) {
std::vector<Monitor> monitors; std::vector<Monitor> monitors;
mgl_for_each_active_monitor_output(dpy, get_monitors_callback, &monitors); int nmonitors = 0;
XRRMonitorInfo *monitor_info = XRRGetMonitors(dpy, DefaultRootWindow(dpy), True, &nmonitors);
if(monitor_info) {
for(int i = 0; i < nmonitors; ++i) {
char *monitor_name = XGetAtomName(dpy, monitor_info[i].name);
if(!monitor_name)
continue;
monitors.push_back({mgl::vec2i(monitor_info[i].x, monitor_info[i].y), mgl::vec2i(monitor_info[i].width, monitor_info[i].height), std::string(monitor_name)});
XFree(monitor_name);
}
XRRFreeMonitors(monitor_info);
}
return monitors; return monitors;
} }

View File

@@ -235,7 +235,7 @@ int main(int argc, char **argv) {
disable_prime_run(); disable_prime_run();
} }
if(mgl_init() != 0) { if(mgl_init(MGL_WINDOW_SYSTEM_X11) != 0) {
fprintf(stderr, "Error: failed to initialize mgl. Failed to either connect to the X11 server or setup opengl\n"); fprintf(stderr, "Error: failed to initialize mgl. Failed to either connect to the X11 server or setup opengl\n");
exit(1); exit(1);
} }