Skip to content

Commit bf85936

Browse files
authored
Add blur (#390)
1 parent 6a0a950 commit bf85936

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

protocol/pantheon-desktop-shell-v1.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@
104104
Tell the shell that the panel would like to be visible in the multitasking view.
105105
</description>
106106
</request>
107+
108+
<request name="add_blur">
109+
<description summary="add blur">
110+
Tell the window manager to add background blur.
111+
</description>
112+
113+
<arg name="left" type="uint"/>
114+
<arg name="right" type="uint"/>
115+
<arg name="top" type="uint"/>
116+
<arg name="bottom" type="uint"/>
117+
<arg name="clip_radius" type="uint"/>
118+
</request>
119+
120+
<request name="remove_blur">
121+
<description summary="remove blur">
122+
Tell the window manager to remove blur that was set in set_blur_region.
123+
</description>
124+
</request>
107125
</interface>
108126

109127
<interface name="io_elementary_pantheon_widget_v1" version="1">
@@ -117,5 +135,21 @@
117135
Tell the shell to keep the surface above on all workspaces
118136
</description>
119137
</request>
138+
139+
<request name="make_centered">
140+
<description summary="requests to keep the surface centered">
141+
Request to keep the surface centered. This will cause keyboard focus
142+
to not be granted automatically but having to be requested via focus.
143+
</description>
144+
</request>
145+
146+
<request name="focus">
147+
<description summary="request keyboard focus">
148+
Request keyboard focus, taking it away from any other window.
149+
Keyboard focus must always be manually be requested and is
150+
- in contrast to normal windows - never automatically granted
151+
by the compositor.
152+
</description>
153+
</request>
120154
</interface>
121155
</protocol>

protocol/pantheon-desktop-shell.vapi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ namespace Pantheon.Desktop {
4848
public void set_size (int width, int height);
4949
public void set_hide_mode (Pantheon.Desktop.HideMode hide_mode);
5050
public void request_visible_in_multitasking_view ();
51+
public void add_blur (uint left, uint right, uint top, uint bottom, uint clip_radius);
52+
public void remove_blur ();
5153
}
5254

5355
[CCode (cheader_filename = "pantheon-desktop-shell-client-protocol.h", cname = "struct io_elementary_pantheon_widget_v1", cprefix = "io_elementary_pantheon_widget_v1_")]

src/MainWindow.vala

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
1818

1919
// Matches top margin in Launcher.css
2020
private const int TOP_MARGIN = 64;
21+
private const int BORDER_RADIUS = 9;
2122

2223
private Settings transparency_settings;
2324
private static Settings settings = new Settings ("io.elementary.dock");
@@ -28,6 +29,8 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
2829
private Gtk.Box main_box;
2930

3031
private WindowDragManager window_drag_manager;
32+
private BottomMargin bottom_margin;
33+
private bool initialized_blur = false;
3134

3235
class construct {
3336
set_css_name ("dock-window");
@@ -50,9 +53,11 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
5053
size_group.add_widget (overlay.child);
5154
size_group.add_widget (launcher_manager);
5255

56+
bottom_margin = new BottomMargin ();
57+
5358
main_box = new Gtk.Box (VERTICAL, 0);
5459
main_box.append (overlay);
55-
main_box.append (new BottomMargin ());
60+
main_box.append (bottom_margin);
5661
child = main_box;
5762

5863
remove_css_class ("background");
@@ -131,6 +136,21 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
131136
item_manager_width,
132137
surface.height - top_margin
133138
}));
139+
140+
if (initialized_blur) {
141+
return;
142+
}
143+
144+
Graphene.Rect bounds;
145+
bottom_margin.compute_bounds (bottom_margin, out bounds);
146+
147+
initialized_blur = true;
148+
149+
if (panel != null) {
150+
panel.add_blur (0, 0, 0, (int) bounds.get_height (), BORDER_RADIUS);
151+
} else {
152+
update_panel_x11 ();
153+
}
134154
});
135155

136156
registry_listener.global = registry_handle_global;
@@ -162,6 +182,12 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
162182

163183
var value = "anchor=8:hide-mode=%d:restore-previous-region=1:visible-in-multitasking-view=1".printf (settings.get_enum ("autohide-mode"));
164184

185+
if (initialized_blur) {
186+
Graphene.Rect bounds;
187+
bottom_margin.compute_bounds (bottom_margin, out bounds);
188+
value += ":blur=0,0,0,%d,%d".printf ((int) bounds.get_height (), BORDER_RADIUS);
189+
}
190+
165191
xdisplay.change_property (window, prop, X.XA_STRING, 8, 0, (uchar[]) value, value.length);
166192
}
167193
}

0 commit comments

Comments
 (0)