aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-04-20 01:14:03 +0200
committerdec05eba <dec05eba@protonmail.com>2025-04-20 01:14:03 +0200
commit28481db82ce6ff9a4b674ae23c6150805ef5888d (patch)
tree4b74ec287538df0957e694bde5da8569abfacb6e
parent4d8328a8d5c3f92d938e92865193e3dd73d7a6ed (diff)
Update to latest mglpp
-rw-r--r--README.md5
m---------depends/mglpp0
-rw-r--r--meson.build1
-rw-r--r--project.conf1
-rw-r--r--src/Overlay.cpp34
-rw-r--r--src/WindowUtils.cpp20
-rw-r--r--src/main.cpp2
7 files changed, 36 insertions, 27 deletions
diff --git a/README.md b/README.md
index 8abb4a4..49ac69b 100644
--- a/README.md
+++ b/README.md
@@ -22,8 +22,7 @@ GPU Screen Recorder UI uses meson build system so you need to install `meson` to
## Build dependencies
These are the dependencies needed to build GPU Screen Recorder UI:
-* x11 (libx11, libxrandr, libxrender, libxcomposite, libxfixes, libxext, libxi)
-* libxcursor
+* x11 (libx11, libxrandr, libxrender, libxcomposite, libxfixes, libxext, libxi, libxcursor)
* libglvnd (which provides libgl, libglx and libegl)
* linux-api-headers
* 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`.\
`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 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
See [https://git.dec05eba.com/?p=about](https://git.dec05eba.com/?p=about).\
diff --git a/depends/mglpp b/depends/mglpp
-Subproject 0c90a62d08ef8846b2516342f7a3ded10415f3b
+Subproject 6c2249d0b0642dfc23727163234ce08407bf493
diff --git a/meson.build b/meson.build
index 13b215f..155b4ab 100644
--- a/meson.build
+++ b/meson.build
@@ -75,6 +75,7 @@ executable(
dependency('xext'),
dependency('xi'),
dependency('xcursor'),
+ dependency('xrandr'),
dependency('libpulse-simple'),
dependency('libdrm'),
dependency('wayland-client'),
diff --git a/project.conf b/project.conf
index 3dc44b1..9f320aa 100644
--- a/project.conf
+++ b/project.conf
@@ -16,6 +16,7 @@ xfixes = ">=0"
xext = ">=0"
xi = ">=0"
xcursor = ">=1"
+xrandr = ">=0.5"
libpulse-simple = ">=0"
libdrm = ">=2"
wayland-client = ">=1"
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index fe7c88e..53f9eae 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -556,8 +556,8 @@ namespace gsr {
memset(xi_output_xev, 0, sizeof(*xi_output_xev));
xi_output_xev->type = MotionNotify;
xi_output_xev->xmotion.display = display;
- xi_output_xev->xmotion.window = window->get_system_handle();
- xi_output_xev->xmotion.subwindow = window->get_system_handle();
+ xi_output_xev->xmotion.window = (Window)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.y = de->root_y - window_pos.y;
xi_output_xev->xmotion.x_root = de->root_x;
@@ -569,8 +569,8 @@ namespace gsr {
memset(xi_output_xev, 0, sizeof(*xi_output_xev));
xi_output_xev->type = cookie->evtype == XI_ButtonPress ? ButtonPress : ButtonRelease;
xi_output_xev->xbutton.display = display;
- xi_output_xev->xbutton.window = window->get_system_handle();
- xi_output_xev->xbutton.subwindow = window->get_system_handle();
+ xi_output_xev->xbutton.window = (Window)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.y = de->root_y - window_pos.y;
xi_output_xev->xbutton.x_root = de->root_x;
@@ -583,8 +583,8 @@ namespace gsr {
memset(xi_output_xev, 0, sizeof(*xi_output_xev));
xi_output_xev->type = cookie->evtype == XI_KeyPress ? KeyPress : KeyRelease;
xi_output_xev->xkey.display = display;
- xi_output_xev->xkey.window = window->get_system_handle();
- xi_output_xev->xkey.subwindow = window->get_system_handle();
+ xi_output_xev->xkey.window = (Window)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.y = de->root_y - window_pos.y;
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
mgl_context *context = mgl_get_context();
Display *display = (Display*)context->connection;
- XGrabPointer(display, window->get_system_handle(), True,
+ XGrabPointer(display, (Window)window->get_system_handle(), True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask |
ButtonMotionMask,
GrabModeAsync, GrabModeAsync, None, default_cursor, CurrentTime);
// 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);
}
@@ -907,7 +907,7 @@ namespace gsr {
// 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
// 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))
fprintf(stderr, "error: failed to create window\n");
@@ -915,10 +915,10 @@ namespace gsr {
//window->set_low_latency(true);
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;
- 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;
window_pos = focused_monitor->position;
@@ -952,12 +952,12 @@ namespace gsr {
//window->set_fullscreen(true);
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);
- make_window_sticky(display, window->get_system_handle());
- hide_window_from_taskbar(display, window->get_system_handle());
+ make_window_sticky(display, (Window)window->get_system_handle());
+ hide_window_from_taskbar(display, (Window)window->get_system_handle());
if(default_cursor) {
XFreeCursor(display, default_cursor);
@@ -1557,7 +1557,7 @@ namespace gsr {
Display *display = (Display*)context->connection;
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);
if(focused_window_name.empty())
focused_window_name = get_focused_window_name(display, WindowCaptureType::FOCUSED);
@@ -1787,7 +1787,7 @@ namespace gsr {
Display *display = (Display*)context->connection;
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;
const bool prev_focused_window_is_fullscreen = focused_window_is_fullscreen;
@@ -2605,7 +2605,7 @@ namespace gsr {
mgl_context *context = mgl_get_context();
Display *display = (Display*)context->connection;
- XRaiseWindow(display, window->get_system_handle());
+ XRaiseWindow(display, (Window)window->get_system_handle());
XFlush(display);
}
}
diff --git a/src/WindowUtils.cpp b/src/WindowUtils.cpp
index cf983db..eb6080f 100644
--- a/src/WindowUtils.cpp
+++ b/src/WindowUtils.cpp
@@ -5,6 +5,7 @@
#include <X11/extensions/XInput2.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/shapeconst.h>
+#include <X11/extensions/Xrandr.h>
#include <mglpp/system/Utf8.hpp>
@@ -518,14 +519,21 @@ namespace gsr {
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> 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;
}
diff --git a/src/main.cpp b/src/main.cpp
index 395b69a..9cb0ede 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -235,7 +235,7 @@ int main(int argc, char **argv) {
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");
exit(1);
}