Skip to content

Commit

Permalink
Remove special casing for Hyprland
Browse files Browse the repository at this point in the history
Hyprland has now been fixed to send only a single fractional scale
event, so no need for special casing it.
  • Loading branch information
kovidgoyal committed Jan 22, 2025
1 parent 5e41de9 commit 0c47f81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
3 changes: 1 addition & 2 deletions glfw/wl_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ typedef struct _GLFWwindowWayland
struct org_kde_kwin_blur *org_kde_kwin_blur;
bool has_blur, expect_scale_from_compositor, window_fully_created;
struct {
bool surface_configured, preferred_scale_received;
unsigned fractional_scale_event_count;
bool surface_configured, preferred_scale_received, fractional_scale_received;
} once;
struct wl_buffer *temp_buffer_used_during_window_creation;
struct {
Expand Down
24 changes: 8 additions & 16 deletions glfw/wl_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ static GLFWLayerShellConfig layer_shell_config_for_next_window = {0};
static bool
is_layer_shell(_GLFWwindow *window) { return window->wl.layer_shell.config.type != GLFW_LAYER_SHELL_NONE; }

static bool
is_hyprland(void) {
return strcmp(_glfwWaylandCompositorName(), "Hyprland") == 0;
}

static void
activation_token_done(void *data, struct xdg_activation_token_v1 *xdg_token, const char *token) {
for (size_t i = 0; i < _glfw.wl.activation_requests.sz; i++) {
Expand Down Expand Up @@ -525,7 +520,7 @@ surface_preferred_buffer_scale(void *data, struct wl_surface *surface UNUSED, in
if ((int)window->wl.integer_scale.preferred == scale && window->wl.window_fully_created) return;
debug("Preferred integer buffer scale changed to: %d for window %llu\n", scale, window->id);
window->wl.integer_scale.preferred = scale;
window->wl.window_fully_created = true;
window->wl.window_fully_created = window->wl.once.surface_configured;
if (!window->wl.fractional_scale) apply_scale_changes(window, true, true);
}

Expand All @@ -548,18 +543,16 @@ static const struct wl_surface_listener surfaceListener = {
static void
fractional_scale_preferred_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1 UNUSED, uint32_t scale) {
_GLFWwindow *window = data;
window->wl.once.fractional_scale_event_count++;
window->wl.once.fractional_scale_received = true;
if (scale == window->wl.fractional_scale && window->wl.window_fully_created) return;
debug("Fractional scale requested: %u/120 = %.2f for window %llu\n", scale, scale / 120., window->id);
window->wl.fractional_scale = scale;
// Hyprland sends a fractional scale = 1 event before configuring the xdg surface and then another after with the correct scale
// https://github.com/hyprwm/Hyprland/issues/9126
//
// labwc doesnt support preferred buffer scale, so we assume it's done fucking around with scales on first fractional scale event
//
// niri and up-to-date mutter and up-to-date kwin all send the fractional
// scale before configure (as of Jan 2025). sway as of 1.10 sends it after configure.
window->wl.window_fully_created = window->wl.once.surface_configured || !_glfw.wl.has_preferred_buffer_scale;
// scale before configure (as of Jan 2025). sway as of 1.10 and Hyprland send it after configure.
// https://github.com/hyprwm/Hyprland/issues/9126
// labwc doesnt support preferred buffer scale and seems to send only a
// single fraction scale event before configure https://github.com/kovidgoyal/kitty/issues/7540
window->wl.window_fully_created = window->wl.once.surface_configured;
apply_scale_changes(window, true, true);
}

Expand Down Expand Up @@ -767,8 +760,7 @@ static void
update_fully_created_on_configure(_GLFWwindow *window) {
// See fractional_scale_preferred_scale() for logic
if (!window->wl.window_fully_created) {
window->wl.window_fully_created = window->wl.once.fractional_scale_event_count > 1 || (
window->wl.once.fractional_scale_event_count > 0 && (window->wl.fractional_scale != 120 || !is_hyprland()));
window->wl.window_fully_created = window->wl.once.fractional_scale_received;
if (window->wl.window_fully_created) debug("Marked window as fully created in configure event\n");
}
}
Expand Down

0 comments on commit 0c47f81

Please sign in to comment.