frames: Load libadwaita on GNOME
Or, optionally, when the MUTTER_FRAMES_PLATFORM_LIBRARY env var is set to "adwaita". For debugging purposes, it is possible to disable loading any platform library with MUTTER_FRAMES_PLATFORM_LIBRARY set to "none". Add the CSS class "ssd-frame" to the MetaFrame (i.e. GtkWindow) instances as that lets libadwaita pick the right style, and won't do anything for non-Adwaita styles. This patch is specially careful not to link against libadwaita. Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/2830 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3981>
This commit is contained in:
parent
fb588bcb29
commit
690564277c
3 changed files with 47 additions and 0 deletions
|
@ -23,8 +23,49 @@
|
|||
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gmodule.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
|
||||
typedef void (* InitFunc) (void);
|
||||
|
||||
static gboolean
|
||||
should_load_libadwaita (void)
|
||||
{
|
||||
g_auto(GStrv) desktops = NULL;
|
||||
const char *current_desktop;
|
||||
const char *platform_library;
|
||||
|
||||
platform_library = g_getenv ("MUTTER_FRAMES_PLATFORM_LIBRARY");
|
||||
|
||||
if (g_strcmp0 (platform_library, "none") == 0)
|
||||
return FALSE;
|
||||
|
||||
if (g_strcmp0 (platform_library, "adwaita") == 0)
|
||||
return TRUE;
|
||||
|
||||
current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
|
||||
if (current_desktop != NULL)
|
||||
desktops = g_strsplit (current_desktop, ":", -1);
|
||||
|
||||
return desktops && g_strv_contains ((const char * const *) desktops, "GNOME");
|
||||
}
|
||||
|
||||
static void
|
||||
load_libadwaita (GdkDisplay *display)
|
||||
{
|
||||
GModule *libadwaita;
|
||||
InitFunc adw_init;
|
||||
|
||||
libadwaita = g_module_open ("libadwaita-1.so.0", G_MODULE_BIND_LAZY);
|
||||
if (!libadwaita)
|
||||
return;
|
||||
|
||||
if (!g_module_symbol (libadwaita, "adw_init", (gpointer *) &adw_init))
|
||||
return;
|
||||
|
||||
adw_init ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_sigterm (gpointer user_data)
|
||||
{
|
||||
|
@ -57,6 +98,9 @@ main (int argc,
|
|||
|
||||
display = gdk_display_get_default ();
|
||||
|
||||
if (should_load_libadwaita ())
|
||||
load_libadwaita (display);
|
||||
|
||||
xdisplay = gdk_x11_display_get_xdisplay (display);
|
||||
XFixesSetClientDisconnectMode (xdisplay,
|
||||
XFixesClientDisconnectFlagTerminate);
|
||||
|
|
|
@ -9,6 +9,7 @@ x11_frames_sources = [
|
|||
x11_frames = executable('mutter-x11-frames',
|
||||
sources: x11_frames_sources,
|
||||
dependencies: [
|
||||
gmodule_no_export_dep,
|
||||
gsettings_desktop_schemas_dep,
|
||||
gtk4_dep,
|
||||
x11_dep,
|
||||
|
|
|
@ -527,6 +527,8 @@ meta_frame_class_init (MetaFrameClass *klass)
|
|||
static void
|
||||
meta_frame_init (MetaFrame *frame)
|
||||
{
|
||||
gtk_widget_add_css_class (GTK_WIDGET (frame), "ssd-frame");
|
||||
|
||||
g_signal_connect (frame, "close-request",
|
||||
G_CALLBACK (on_frame_close_request), NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue