diff options
author | Daniel Carl <danielcarl@gmx.de> | 2019-01-18 00:02:14 +0100 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2019-01-18 00:02:14 +0100 |
commit | 73fbd884bab5670e1593153df75697e82d174f8f (patch) | |
tree | 8dfef5b364a2ce3b533a221d496971241f2c8b5d /src/main.c | |
parent | d15d99b33171de0e373f4f2cd9fe16f41286a029 (diff) |
Allow to show video in fullscreen if requested.
If JavaScript calls element.webkitRequestFullScreen webkit switches vimb
into full screen mode. But the statusbar and the input box where still
shown. So now vimb hides the statusbar and the input box to allow videos
to be show on the whole screen.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -87,6 +87,8 @@ static void on_webview_ready_to_show(WebKitWebView *webview, Client *c); 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); @@ -1479,6 +1481,28 @@ static gboolean on_webview_authenticate(WebKitWebView *webview, } /** + * 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 destroys the window. Returns TRUE to stop other handlers from being @@ -1808,6 +1832,8 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview) "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 ); |