diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2020-07-08 19:38:51 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2020-07-08 19:38:51 -0300 |
commit | 7c17877ed3ad0683fda6c59e6cbe9b42b653178e (patch) | |
tree | 05d5a1537bc9f7cc0d075399b18198cf22caf070 /src | |
parent | 18d6b7c49b76051bc0e475b41390315bf71b40d9 (diff) | |
download | glade-7c17877ed3ad0683fda6c59e6cbe9b42b653178e.tar.gz |
GladeWindow: add CSS optimization for Quartz backend
Disable shadows and animations on OSX to improve performance.
Add glade_window_get_gdk_backend()
Diffstat (limited to 'src')
-rw-r--r-- | src/glade-window.c | 65 | ||||
-rw-r--r-- | src/glade-window.css | 18 | ||||
-rw-r--r-- | src/glade-window.h | 16 |
3 files changed, 92 insertions, 7 deletions
diff --git a/src/glade-window.c b/src/glade-window.c index 888dd40e..b12ad494 100644 --- a/src/glade-window.c +++ b/src/glade-window.c @@ -2101,6 +2101,7 @@ static void glade_window_init (GladeWindow *window) { GladeWindowPrivate *priv; + GtkStyleContext *ctx; window->priv = priv = glade_window_get_instance_private (window); @@ -2119,6 +2120,10 @@ glade_window_init (GladeWindow *window) gtk_box_set_homogeneous (GTK_BOX (priv->save_button_box), FALSE); priv->registration = glade_registration_new (); + + /* Add Gdk backend as a class */ + ctx = gtk_widget_get_style_context (GTK_WIDGET (window)); + gtk_style_context_add_class (ctx, glade_window_get_gdk_backend ()); } static void @@ -2555,3 +2560,63 @@ glade_window_registration_notify_user (GladeWindow *window) /* translators: Text to show in the statusbar if the user did not completed the survey and choose not to show the notification dialog again */ _("Go to Help -> Registration & User Survey and complete our survey!")); } + +#ifdef GDK_WINDOWING_X11 +#include "gdk/gdkx.h" +#endif + +#ifdef GDK_WINDOWING_QUARTZ +#include "gdk/gdkquartz.h" +#endif + +#ifdef GDK_WINDOWING_WIN32 +#include "gdk/gdkwin32.h" +#endif + +#ifdef GDK_WINDOWING_WAYLAND +#include "gdk/gdkwayland.h" +#endif + +#ifdef GDK_WINDOWING_BROADWAY +#include "gdk/gdkbroadway.h" +#endif + +const gchar * +glade_window_get_gdk_backend () +{ + GdkDisplay *display = gdk_display_get_default (); + +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY (display)) + return "X11"; + else +#endif + +#ifdef GDK_WINDOWING_QUARTZ + if (GDK_IS_QUARTZ_DISPLAY (display)) + return "Quartz"; + else +#endif + +#ifdef GDK_WINDOWING_WIN32 + if (GDK_IS_WIN32_DISPLAY (display)) + return "Win32"; + else +#endif + +#ifdef GDK_WINDOWING_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (display)) + return "Wayland"; + else +#endif + +#ifdef GDK_WINDOWING_BROADWAY + if (GDK_IS_BROADWAY_DISPLAY (display)) + return "Broadway"; + else +#endif + { + return "Unknown"; + } +} + diff --git a/src/glade-window.css b/src/glade-window.css index b1277d06..4c4f257b 100644 --- a/src/glade-window.css +++ b/src/glade-window.css @@ -110,3 +110,21 @@ stackswitcher.glade-intro-highlight > button, animation: widget-highlight 1s infinite alternate; } +/* Quartz workarounds to improve performance (issue #442) */ + +/* Disable window shadow */ +GladeWindow.Quartz > decoration { + box-shadow: none; +} + +/* Disable Glade logo shadow animation */ +GladeWindow.Quartz #glade-brand-image { + animation: none; +} + +/* Add window border since there is no shadow */ +GladeWindow.Quartz { + border: 1px solid lightgray; + border-top: unset; +} + diff --git a/src/glade-window.h b/src/glade-window.h index 757ecff4..03a8022b 100644 --- a/src/glade-window.h +++ b/src/glade-window.h @@ -47,18 +47,20 @@ struct _GladeWindowClass GtkWindowClass parent_class; }; -GType glade_window_get_type (void) G_GNUC_CONST; +GType glade_window_get_type (void) G_GNUC_CONST; -GtkWidget *glade_window_new (void); +GtkWidget *glade_window_new (void); -void glade_window_new_project (GladeWindow *window); +void glade_window_new_project (GladeWindow *window); -gboolean glade_window_open_project (GladeWindow *window, - const gchar *path); +gboolean glade_window_open_project (GladeWindow *window, + const gchar *path); -void glade_window_check_devhelp (GladeWindow *window); +void glade_window_check_devhelp (GladeWindow *window); -void glade_window_registration_notify_user (GladeWindow *window); +void glade_window_registration_notify_user (GladeWindow *window); + +const gchar *glade_window_get_gdk_backend (void); G_END_DECLS |