Nvidia drivers: Refresh background and screen corners (#21) (#330)

* Nvidia drivers: Refresh background and screen corners (#21)

* Fix merge artifacts

* Remove unused GL_VENDOR constant

* Remove unused logind constants

* Cleanup: Turn refresh_backgrounds method into a closure
This commit is contained in:
Julian Raschke 2018-10-20 18:02:04 +02:00 committed by Cassidy James Blaede
parent fe9f48ae09
commit a1bad2672b
3 changed files with 24 additions and 43 deletions

View File

@ -71,10 +71,18 @@ namespace Gala.Plugins.MaskCorners
screen.in_fullscreen_changed.connect (fullscreen_changed); screen.in_fullscreen_changed.connect (fullscreen_changed);
screen.monitors_changed.connect (resetup_cornermasks); screen.monitors_changed.connect (resetup_cornermasks);
#if HAS_MUTTER322
screen.get_display ().gl_video_memory_purged.connect (resetup_cornermasks);
#endif
} }
void destroy_cornermasks () void destroy_cornermasks ()
{ {
#if HAS_MUTTER322
screen.get_display ().gl_video_memory_purged.disconnect (resetup_cornermasks);
#endif
screen.monitors_changed.disconnect (resetup_cornermasks); screen.monitors_changed.disconnect (resetup_cornermasks);
screen.in_fullscreen_changed.disconnect (fullscreen_changed); screen.in_fullscreen_changed.disconnect (fullscreen_changed);

View File

@ -60,6 +60,16 @@ namespace Gala
}); });
} }
} }
public static void refresh ()
{
// Meta.Background.refresh_all does not refresh backgrounds with the WALLPAPER style.
// (Last tested with mutter 3.28)
// As a workaround, re-apply the current color again to force the wallpaper texture
// to be rendered from scratch.
if (system_background != null)
system_background.set_color (DEFAULT_BACKGROUND_COLOR);
}
} }
} }

View File

@ -28,30 +28,8 @@ namespace Gala
public abstract async void show_window_menu (WindowFlags flags, int x, int y) throws Error; public abstract async void show_window_menu (WindowFlags flags, int x, int y) throws Error;
} }
[DBus (name = "org.freedesktop.login1.Manager")]
public interface LoginDRemote : GLib.Object
{
public signal void prepare_for_sleep (bool suspending);
}
public class WindowManagerGala : Meta.Plugin, WindowManager public class WindowManagerGala : Meta.Plugin, WindowManager
{ {
const uint GL_VENDOR = 0x1F00;
const string LOGIND_DBUS_NAME = "org.freedesktop.login1";
const string LOGIND_DBUS_OBJECT_PATH = "/org/freedesktop/login1";
delegate unowned string? GlQueryFunc (uint id);
static bool is_nvidia ()
{
var gl_get_string = (GlQueryFunc) Cogl.get_proc_address ("glGetString");
if (gl_get_string == null)
return false;
unowned string? vendor = gl_get_string (GL_VENDOR);
return (vendor != null && vendor.contains ("NVIDIA Corporation"));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -91,7 +69,6 @@ namespace Gala
Window? moving; //place for the window that is being moved over Window? moving; //place for the window that is being moved over
LoginDRemote? logind_proxy = null;
Daemon? daemon_proxy = null; Daemon? daemon_proxy = null;
Gee.LinkedList<ModalProxy> modal_stack = new Gee.LinkedList<ModalProxy> (); Gee.LinkedList<ModalProxy> modal_stack = new Gee.LinkedList<ModalProxy> ();
@ -121,18 +98,12 @@ namespace Gala
{ {
Util.later_add (LaterType.BEFORE_REDRAW, show_stage); Util.later_add (LaterType.BEFORE_REDRAW, show_stage);
// Handle FBO issue with nvidia blob #if HAS_MUTTER322
if (logind_proxy == null get_screen ().get_display ().gl_video_memory_purged.connect (() => {
&& is_nvidia ()) { Meta.Background.refresh_all ();
try { SystemBackground.refresh ();
logind_proxy = Bus.get_proxy_sync (BusType.SYSTEM, LOGIND_DBUS_NAME, LOGIND_DBUS_OBJECT_PATH); });
logind_proxy.prepare_for_sleep.connect (prepare_for_sleep); #endif
} catch (Error e) {
warning ("Failed to get LoginD proxy: %s", e.message);
}
}
Bus.watch_name (BusType.SESSION, DAEMON_DBUS_NAME, BusNameWatcherFlags.NONE, daemon_appeared, lost_daemon);
} }
void on_menu_get (GLib.Object? o, GLib.AsyncResult? res) void on_menu_get (GLib.Object? o, GLib.AsyncResult? res)
@ -156,14 +127,6 @@ namespace Gala
} }
} }
void prepare_for_sleep (bool suspending)
{
if (suspending)
return;
Meta.Background.refresh_all ();
}
bool show_stage () bool show_stage ()
{ {
var screen = get_screen (); var screen = get_screen ();