Skip to content

Commit 2bd83fb

Browse files
committed
Add docstrings
1 parent dd7f788 commit 2bd83fb

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

lib/BlurSurface.vala

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
*/
55

66
/**
7-
* This interface is used for manually asking window manager to provide background blur for the surface.
7+
* This interface is used for asking window manager to provide background blur for the surface.
88
*/
99
public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
10+
/**
11+
* Returns whether application is running with Wayland backend
12+
*/
1013
public bool is_wayland () {
1114
return Gdk.Display.get_default () is Gdk.Wayland.Display;
1215
}
1316

17+
/**
18+
* Initializes blur support. Uses default `blur_registry_handle_global` and `get_x11_blur_hints`.
19+
* Use if you are not using other Wayland/X11 protocols.
20+
*/
1421
public void simple_blur_init () {
1522
if (is_wayland ()) {
1623
init_wayland (blur_registry_handle_global);
@@ -20,6 +27,12 @@ public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
2027
}
2128

2229
private static Wl.RegistryListener registry_listener;
30+
31+
/**
32+
* Initializes blur support on Wayland.
33+
* Use this method only if you need to manually initialize support of multiple
34+
* Wayland protocols. Otherwise use `simple_blur_init`.
35+
*/
2336
public void init_wayland (Wl.RegistryListenerGlobal registry_handle_global) requires (is_wayland ()) {
2437
registry_listener.global = registry_handle_global;
2538
unowned var display = (Gdk.Wayland.Display) Gdk.Display.get_default ();
@@ -35,6 +48,9 @@ public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
3548
}
3649
}
3750

51+
/**
52+
* Registers the window as user of blur protocol. Use with `init_wayland` method.
53+
*/
3854
public void blur_registry_handle_global (Wl.Registry wl_registry, uint32 name, string @interface, uint32 version) {
3955
if (@interface == "io_elementary_pantheon_blur_manager_v1") {
4056
var blur_manager = wl_registry.bind<PantheonBlur.BlurManager> (name, ref PantheonBlur.BlurManager.iface, uint32.min (version, 1));
@@ -46,6 +62,10 @@ public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
4662
}
4763
}
4864

65+
/**
66+
* Request background blur. Use if you use blur Wayland/X11 protocol only.
67+
* Otherwise manually request blur using `request_blur_wayland` and `update_x11_hints` with `get_x11_blur_hints`.
68+
*/
4969
public void simple_request_blur (uint x, uint y, uint width, uint height, uint clip_radius) {
5070
if (is_wayland ()) {
5171
request_blur_wayland (x, y, width, height, clip_radius);
@@ -55,10 +75,11 @@ public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
5575
}
5676

5777
/**
58-
* Tells the window manager to add background blur behind this surface.
78+
* Request background blur on wayland.
79+
* Use this method only if you use multiple Wayland protocols. Otherwise use `simple_request_blur`.
5980
*/
6081
public void request_blur_wayland (uint x, uint y, uint width, uint height, uint clip_radius) {
61-
if (!is_wayland()) {
82+
if (!is_wayland ()) {
6283
warning ("BlurSurface.request_blur_wayland: Ignoring, not on Wayland");
6384
}
6485

@@ -70,6 +91,10 @@ public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
7091
}
7192
}
7293

94+
/**
95+
* Updates X11 hints that Gala (Pantheon window manager) uses for its protocols for X11 windows.
96+
* Use only if you support multiple X11 Gala protocols.
97+
*/
7398
public void update_x11_hints (string value) requires (!is_wayland ()) {
7499
unowned var display = (Gdk.X11.Display) Gdk.Display.get_default ();
75100
unowned var xdisplay = display.get_xdisplay ();
@@ -78,6 +103,10 @@ public interface Granite.BlurSurface : Gtk.Widget, Gtk.Native {
78103
xdisplay.change_property (xid, prop, X.XA_STRING, 8, 0, (uchar[]) value, value.length);
79104
}
80105

106+
/**
107+
* Returns string that can be used in `update_x11_hints` to request blur.
108+
* Use only if you support multiple X11 Gala protocols.
109+
*/
81110
public string get_x11_blur_hints (uint x, uint y, uint width, uint height, uint clip_radius) {
82111
return "blur=%u,%u,%u,%u,%u:".printf (x, y, width, height, clip_radius);
83112
}

0 commit comments

Comments
 (0)