Hyprland: fix background of ui not rendering, if waybar is running and it's running in dock mode

This commit is contained in:
dec05eba
2025-06-04 22:13:15 +02:00
parent d72ce588fb
commit 575592a12d
3 changed files with 36 additions and 3 deletions

View File

@@ -61,8 +61,8 @@ I'm looking for somebody that can create sound effects for the notifications.
![](https://dec05eba.com/images/settings_page.jpg) ![](https://dec05eba.com/images/settings_page.jpg)
# Known issues # Known issues
* When the UI is open the wallpaper is shown instead of the game on Hyprland. This is an issue with Hyprland. It cant be fixed until the UI is redesigned to not be a fullscreen overlay. * When the UI is open the wallpaper is shown instead of the game on Hyprland. This is an issue with Hyprland. It cant be fixed until the UI is redesigned to not be a fullscreen overlay. Change your waybar dock mode to "dock" in its config to fix this.
* Opening the UI when a game is fullscreen can mess up the game window a bit on Hyprland. This is an issue with Hyprland. * Opening the UI when a game is fullscreen can mess up the game window a bit on Hyprland. This is an issue with Hyprland. Change your waybar dock mode to "dock" in its config to fix this.
* The background of the UI is black when opening the UI while a Wayland application is focused on COSMIC. This is an issue with COSMIC. * The background of the UI is black when opening the UI while a Wayland application is focused on COSMIC. This is an issue with COSMIC.
* Unable to close the region selection with escape key while a Wayland application is focused on COSMIC. This is an issue with COSMIC. * Unable to close the region selection with escape key while a Wayland application is focused on COSMIC. This is an issue with COSMIC.

4
TODO
View File

@@ -183,3 +183,7 @@ Support freetype for text rendering. Maybe load freetype as runtime (with dlopen
Show .webm container option. It's currently chosen automatically if vp8/vp9 is chosen. The available containers should automatically switch depending on the video codec. Show .webm container option. It's currently chosen automatically if vp8/vp9 is chosen. The available containers should automatically switch depending on the video codec.
In settings show audio levels for each audio. Maybe show audio level image beside the audio name in the dropdown box and switch to a different image (have 3-4 different images for each level) depending on the volume. In settings show audio levels for each audio. Maybe show audio level image beside the audio name in the dropdown box and switch to a different image (have 3-4 different images for each level) depending on the volume.
Only use fake cursor on wayland if the focused x11 window is fullscreen.
Create window as a real overlay window, using layer shell protocol, when possible. This will however minimize windows on floating wms. Check if this can be fixed somehow, or only use layer shell in tiling wms.

View File

@@ -273,6 +273,33 @@ namespace gsr {
return true; return true;
} }
static bool is_hyprland_waybar_running_as_dock() {
const char *args[] = { "hyprctl", "layers", nullptr };
std::string stdout_str;
if(exec_program_on_host_get_stdout(args, stdout_str) != 0)
return false;
int waybar_layer_level = -1;
int current_layer_level = 0;
string_split_char(stdout_str, '\n', [&](const std::string_view line) {
if(line.find("Layer level 0") != std::string_view::npos)
current_layer_level = 0;
else if(line.find("Layer level 1") != std::string_view::npos)
current_layer_level = 1;
else if(line.find("Layer level 2") != std::string_view::npos)
current_layer_level = 2;
else if(line.find("Layer level 3") != std::string_view::npos)
current_layer_level = 3;
else if(line.find("namespace: waybar") != std::string_view::npos) {
waybar_layer_level = current_layer_level;
return false;
}
return true;
});
return waybar_layer_level >= 0 && waybar_layer_level <= 1;
}
static Hotkey config_hotkey_to_hotkey(ConfigHotkey config_hotkey) { static Hotkey config_hotkey_to_hotkey(ConfigHotkey config_hotkey) {
return { return {
(uint32_t)mgl::Keyboard::key_to_x11_keysym((mgl::Keyboard::Key)config_hotkey.key), (uint32_t)mgl::Keyboard::key_to_x11_keysym((mgl::Keyboard::Key)config_hotkey.key),
@@ -904,6 +931,8 @@ namespace gsr {
const std::string wm_name = get_window_manager_name(display); const std::string wm_name = get_window_manager_name(display);
const bool is_kwin = wm_name == "KWin"; const bool is_kwin = wm_name == "KWin";
const bool is_wlroots = wm_name.find("wlroots") != std::string::npos; const bool is_wlroots = wm_name.find("wlroots") != std::string::npos;
const bool is_hyprland = wm_name.find("Hyprland") != std::string::npos;
const bool hyprland_waybar_is_dock = is_hyprland && is_hyprland_waybar_running_as_dock();
std::optional<CursorInfo> cursor_info; std::optional<CursorInfo> cursor_info;
if(cursor_tracker) { if(cursor_tracker) {
@@ -1035,7 +1064,7 @@ namespace gsr {
// Owlboy seems to use xi events and XGrabPointer doesn't prevent owlboy from receiving events. // Owlboy seems to use xi events and XGrabPointer doesn't prevent owlboy from receiving events.
xi_grab_all_mouse_devices(xi_display); xi_grab_all_mouse_devices(xi_display);
if(!is_wlroots) if(!is_wlroots && !hyprland_waybar_is_dock)
window->set_fullscreen(true); window->set_fullscreen(true);
visible = true; visible = true;