Skip to content

Commit

Permalink
gtk4: set focused activity state based on window::is-active
Browse files Browse the repository at this point in the history
Without the wpe_view_activity_state_focused flag, gamepad events
aren't forwarded to the view.

This change is aligned with what is done in GTK port [1].

[1] https://commits.webkit.org/273882@main.
  • Loading branch information
cadubentzen authored and philn committed Aug 3, 2024
1 parent 42b00d7 commit 9ac900a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions platform/gtk4/cog-platform-gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ on_fullscreen_change(GtkWidget* window, GParamSpec* pspec, gpointer user_data)
dispatch_wpe_fullscreen_event(win);
}

static void
on_is_active_change(GtkWidget *window, GParamSpec *pspec, gpointer user_data)
{
struct platform_window *win = user_data;
struct wpe_view_backend *backend = webkit_web_view_backend_get_wpe_backend(win->view_backend);
if (gtk_window_is_active(GTK_WINDOW(window)))
wpe_view_backend_add_activity_state(backend, wpe_view_activity_state_focused);
else
wpe_view_backend_remove_activity_state(backend, wpe_view_activity_state_focused);
}

static void
on_quit(GtkWidget* widget, gpointer data)
{
Expand Down Expand Up @@ -562,6 +573,7 @@ setup_window(struct platform_window* window)
g_signal_connect(window->gl_drawing_area, "notify::scale-factor", G_CALLBACK(scale_factor_change), window);

g_signal_connect(window->gtk_window, "notify::fullscreened", G_CALLBACK(on_fullscreen_change), window);
g_signal_connect(window->gtk_window, "notify::is-active", G_CALLBACK(on_is_active_change), window);

GtkGesture* press = gtk_gesture_click_new();
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(press), GDK_BUTTON_PRIMARY);
Expand Down

0 comments on commit 9ac900a

Please sign in to comment.