ui/environment: Add a setSourceColor helper
To simplify porting away from Clutter cairo helpers Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2808>
This commit is contained in:
parent
64c8d94d2b
commit
ef9113da43
@ -4,6 +4,7 @@ import '../misc/dependencies.js';
|
||||
import {setConsoleLogDomain} from 'console';
|
||||
import * as Gettext from 'gettext';
|
||||
|
||||
import Cairo from 'cairo';
|
||||
import Clutter from 'gi://Clutter';
|
||||
import Gdk from 'gi://Gdk';
|
||||
import Gio from 'gi://Gio';
|
||||
@ -275,6 +276,16 @@ GObject.Object.prototype.disconnect_object = function (...args) {
|
||||
|
||||
SignalTracker.registerDestroyableType(Clutter.Actor);
|
||||
|
||||
Cairo.Context.prototype.setSourceColor = function (color) {
|
||||
const {red, green, blue, alpha} = color;
|
||||
const rgb = [red, green, blue].map(v => v / 255.0);
|
||||
|
||||
if (alpha !== 0xff)
|
||||
this.setSourceRGBA(...rgb, alpha / 255.0);
|
||||
else
|
||||
this.setSourceRGB(...rgb);
|
||||
};
|
||||
|
||||
// Miscellaneous monkeypatching
|
||||
_patchContainerClass(St.BoxLayout);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user