GTK-MiniBrowser-should-hide-the-toolbar-when-using-full-screen.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From e07345343415dd2496edc721daa61a3b42703131 Mon Sep 17 00:00:00 2001
  2. From: Christian Hesse <mail@eworm.de>
  3. Date: Tue, 19 Sep 2023 12:16:39 -0700
  4. Subject: [PATCH] [GTK] MiniBrowser should hide the toolbar when using
  5. --full-screen #17909 https://bugs.webkit.org/show_bug.cgi?id=261732
  6. Reviewed by Michael Catanzaro.
  7. Entering fullscreen mode with F11 works as expected.
  8. Starting with command line switch `--full-screen` does make the window
  9. fullscreen, but does not hide the toolbar. Let's change that.
  10. Instead of just making the window fullscreen with `gtk_window_fullscreen()`
  11. this introduces a new function `browser_window_fullscreen()` that hides
  12. the toolbar as well.
  13. Also introduce new function `browserWindowUnfullscreen()`, use both
  14. in `toggleFullScreen()`, and drop extra inversion.
  15. * Tools/MiniBrowser/gtk/BrowserWindow.c
  16. * Tools/MiniBrowser/gtk/BrowserWindow.h
  17. * Tools/MiniBrowser/gtk/main.c
  18. Canonical link: https://commits.webkit.org/268141@main
  19. ---
  20. Tools/MiniBrowser/gtk/BrowserWindow.c | 27 ++++++++++++++++++---------
  21. Tools/MiniBrowser/gtk/BrowserWindow.h | 1 +
  22. Tools/MiniBrowser/gtk/main.c | 2 +-
  23. 3 files changed, 20 insertions(+), 10 deletions(-)
  24. diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.c b/Tools/MiniBrowser/gtk/BrowserWindow.c
  25. index 626ce2207e845..58eb5ae39e2e0 100644
  26. --- a/Tools/MiniBrowser/gtk/BrowserWindow.c
  27. +++ b/Tools/MiniBrowser/gtk/BrowserWindow.c
  28. @@ -482,6 +482,20 @@ static GtkWidget *webViewCreate(WebKitWebView *webView, WebKitNavigationAction *
  29. return GTK_WIDGET(newWebView);
  30. }
  31. +void browser_window_fullscreen(BrowserWindow *window)
  32. +{
  33. + gtk_window_fullscreen(GTK_WINDOW(window));
  34. + gtk_widget_hide(window->toolbar);
  35. + window->fullScreenIsEnabled = TRUE;
  36. +}
  37. +
  38. +static void browserWindowUnfullscreen(BrowserWindow *window)
  39. +{
  40. + gtk_window_unfullscreen(GTK_WINDOW(window));
  41. + gtk_widget_show(window->toolbar);
  42. + window->fullScreenIsEnabled = FALSE;
  43. +}
  44. +
  45. static gboolean webViewEnterFullScreen(WebKitWebView *webView, BrowserWindow *window)
  46. {
  47. gtk_widget_hide(window->toolbar);
  48. @@ -867,15 +881,10 @@ static void loadHomePage(GSimpleAction *action, GVariant *parameter, gpointer us
  49. static void toggleFullScreen(GSimpleAction *action, GVariant *parameter, gpointer userData)
  50. {
  51. BrowserWindow *window = BROWSER_WINDOW(userData);
  52. - if (!window->fullScreenIsEnabled) {
  53. - gtk_window_fullscreen(GTK_WINDOW(window));
  54. - gtk_widget_hide(window->toolbar);
  55. - window->fullScreenIsEnabled = TRUE;
  56. - } else {
  57. - gtk_window_unfullscreen(GTK_WINDOW(window));
  58. - gtk_widget_show(window->toolbar);
  59. - window->fullScreenIsEnabled = FALSE;
  60. - }
  61. + if (window->fullScreenIsEnabled)
  62. + browserWindowUnfullscreen(window);
  63. + else
  64. + browser_window_fullscreen(window);
  65. }
  66. static void webKitPrintOperationFailedCallback(WebKitPrintOperation *printOperation, GError *error)
  67. diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.h b/Tools/MiniBrowser/gtk/BrowserWindow.h
  68. index c58ebc2beec7e..1fd07efb828b8 100644
  69. --- a/Tools/MiniBrowser/gtk/BrowserWindow.h
  70. +++ b/Tools/MiniBrowser/gtk/BrowserWindow.h
  71. @@ -58,6 +58,7 @@ GtkWidget* browser_window_new(GtkWindow*, WebKitWebContext*);
  72. #endif
  73. WebKitWebContext* browser_window_get_web_context(BrowserWindow*);
  74. void browser_window_append_view(BrowserWindow*, WebKitWebView*);
  75. +void browser_window_fullscreen(BrowserWindow*);
  76. void browser_window_load_uri(BrowserWindow*, const char *uri);
  77. void browser_window_load_session(BrowserWindow *, const char *sessionFile);
  78. void browser_window_set_background_color(BrowserWindow*, GdkRGBA*);
  79. diff --git a/Tools/MiniBrowser/gtk/main.c b/Tools/MiniBrowser/gtk/main.c
  80. index 8be643a541511..451e0333dd4e8 100644
  81. --- a/Tools/MiniBrowser/gtk/main.c
  82. +++ b/Tools/MiniBrowser/gtk/main.c
  83. @@ -925,7 +925,7 @@ static void activate(GApplication *application, WebKitSettings *webkitSettings)
  84. if (darkMode)
  85. g_object_set(gtk_widget_get_settings(GTK_WIDGET(mainWindow)), "gtk-application-prefer-dark-theme", TRUE, NULL);
  86. if (fullScreen)
  87. - gtk_window_fullscreen(GTK_WINDOW(mainWindow));
  88. + browser_window_fullscreen(mainWindow);
  89. if (backgroundColor)
  90. browser_window_set_background_color(mainWindow, backgroundColor);