static gboolean on_webview_web_process_crashed(WebKitWebView *webview, Client *c);
static gboolean on_webview_authenticate(WebKitWebView *webview,
WebKitAuthenticationRequest *request, Client *c);
+static gboolean on_webview_enter_fullscreen(WebKitWebView *webview, Client *c);
+static gboolean on_webview_leave_fullscreen(WebKitWebView *webview, Client *c);
static gboolean on_window_delete_event(GtkWidget *window, GdkEvent *event, Client *c);
static void on_window_destroy(GtkWidget *window, Client *c);
static gboolean quit(Client *c);
return FALSE;
}
+/**
+ * Callback in case JS calls element.webkitRequestFullScreen.
+ */
+static gboolean on_webview_enter_fullscreen(WebKitWebView *webview, Client *c)
+{
+ c->state.is_fullscreen = TRUE;
+ gtk_widget_hide(GTK_WIDGET(c->statusbar.box));
+ gtk_widget_set_visible(GTK_WIDGET(c->input), FALSE);
+ return FALSE;
+}
+
+/**
+ * Callback to restore the window state after entering fullscreen.
+ */
+static gboolean on_webview_leave_fullscreen(WebKitWebView *webview, Client *c)
+{
+ c->state.is_fullscreen = FALSE;
+ gtk_widget_show(GTK_WIDGET(c->statusbar.box));
+ gtk_widget_set_visible(GTK_WIDGET(c->input), TRUE);
+ return FALSE;
+}
+
/**
* Callback for window ::delete-event signal which is emitted if a user
* requests that a toplevel window is closed. The default handler for this
"signal::ready-to-show", G_CALLBACK(on_webview_ready_to_show), c,
"signal::web-process-crashed", G_CALLBACK(on_webview_web_process_crashed), c,
"signal::authenticate", G_CALLBACK(on_webview_authenticate), c,
+ "signal::enter-fullscreen", G_CALLBACK(on_webview_enter_fullscreen), c,
+ "signal::leave-fullscreen", G_CALLBACK(on_webview_leave_fullscreen), c,
NULL
);
static VbResult normal_clear_input(Client *c, const NormalCmdInfo *info)
{
+ /* If an element requested the fullscreen - the <esc> shoudl cause to
+ * leave this fullscreen mode. */
+ if (c->state.is_fullscreen) {
+ /* Unset the processed_key to indicate that the <esc> was not handled
+ * by us and letting the event bubble up. So that webkit handles the
+ * key for us to leave the fullscreen mode. */
+ c->state.processed_key = FALSE;
+ return RESULT_COMPLETE;
+ }
+
gtk_widget_grab_focus(GTK_WIDGET(c->webview));
/* Clear the inputbox and change the style to normal to reset also the