Skip to content

Commit 4dc68a4

Browse files
committed
Move to extended behavior
1 parent ac219b1 commit 4dc68a4

6 files changed

+46
-70
lines changed

protocol/pantheon-desktop-shell-v1.xml

+16-9
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@
102102

103103
<interface name="io_elementary_pantheon_widget_v1" version="1">
104104
<request name="destroy" type="destructor"/>
105-
106-
<request name="focus">
107-
<description summary="request keyboard focus">
108-
Request keyboard focus, taking it away from any other window.
109-
Keyboard focus must always be manually be requested and is
110-
- in contrast to normal windows - never automatically granted
111-
by the compositor.
112-
</description>
113-
</request>
114105
</interface>
115106

116107
<interface name="io_elementary_pantheon_extended_behavior_v1" version="1">
@@ -120,5 +111,21 @@
120111
Tell the shell to keep the surface above on all workspaces
121112
</description>
122113
</request>
114+
115+
<request name="make_centered">
116+
<description summary="requests to keep the surface centered">
117+
Request to keep the surface centered. This will cause keyboard focus
118+
to not be granted automatically but having to be requested via focus.
119+
</description>
120+
</request>
121+
122+
<request name="focus">
123+
<description summary="request keyboard focus">
124+
Request keyboard focus, taking it away from any other window.
125+
Keyboard focus must always be manually be requested and is
126+
- in contrast to normal windows - never automatically granted
127+
by the compositor.
128+
</description>
129+
</request>
123130
</interface>
124131
</protocol>

protocol/pantheon-desktop-shell.vapi

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ namespace Pantheon.Desktop {
4848
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "io_elementary_pantheon_widget_v1_interface")]
4949
public static Wl.Interface iface;
5050
public Destroy destroy;
51-
public Focus focus;
5251
}
5352

5453
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "struct io_elementary_pantheon_extended_behavior_v1_interface")]
@@ -57,6 +56,8 @@ namespace Pantheon.Desktop {
5756
public static Wl.Interface iface;
5857
public Destroy destroy;
5958
public SetKeepAbove set_keep_above;
59+
public MakeCentered make_centered;
60+
public Focus focus;
6061
}
6162

6263
[CCode (has_target = false, has_typedef = false)]
@@ -76,5 +77,7 @@ namespace Pantheon.Desktop {
7677
[CCode (has_target = false, has_typedef = false)]
7778
public delegate void SetKeepAbove (Wl.Client client, Wl.Resource resource);
7879
[CCode (has_target = false, has_typedef = false)]
80+
public delegate void MakeCentered (Wl.Client client, Wl.Resource resource);
81+
[CCode (has_target = false, has_typedef = false)]
7982
public delegate void Destroy (Wl.Client client, Wl.Resource resource);
8083
}

src/PantheonShell.vala

+21-14
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ namespace Gala {
6262

6363
wayland_pantheon_widget_interface = {
6464
destroy_widget_surface,
65-
focus_widget,
6665
};
6766

6867
wayland_pantheon_extended_behavior_interface = {
6968
destroy_extended_behavior_surface,
7069
set_keep_above,
70+
make_centered,
71+
focus_extended_behavior,
7172
};
7273

7374
PanelSurface.quark = GLib.Quark.from_string ("-gala-wayland-panel-surface-data");
@@ -196,15 +197,6 @@ namespace Gala {
196197
widget_surface,
197198
(GLib.DestroyNotify) WidgetSurface.on_wayland_surface_disposed
198199
);
199-
200-
Meta.Window? window;
201-
wayland_surface.get ("window", out window, null);
202-
if (window == null) {
203-
warning ("Failed to make window a widget as requested because Meta.Window was null.");
204-
return;
205-
}
206-
207-
ShellClientsManager.get_instance ().make_widget (window);
208200
}
209201

210202
internal static void get_extended_behavior (Wl.Client client, Wl.Resource resource, uint32 output, Wl.Resource surface_resource) {
@@ -281,14 +273,14 @@ namespace Gala {
281273
focus (panel_surface.wayland_surface);
282274
}
283275

284-
internal static void focus_widget (Wl.Client client, Wl.Resource resource) {
285-
unowned WidgetSurface? widget_surface = resource.get_user_data<WidgetSurface> ();
286-
if (widget_surface.wayland_surface == null) {
276+
internal static void focus_extended_behavior (Wl.Client client, Wl.Resource resource) {
277+
unowned ExtendedBehaviorSurface? extended_behavior_surface = resource.get_user_data<ExtendedBehaviorSurface> ();
278+
if (extended_behavior_surface.wayland_surface == null) {
287279
warning ("Window tried to focus but wayland surface is null.");
288280
return;
289281
}
290282

291-
focus (widget_surface.wayland_surface);
283+
focus (extended_behavior_surface.wayland_surface);
292284
}
293285

294286
internal static void focus (Object wayland_surface) {
@@ -351,6 +343,21 @@ namespace Gala {
351343
window.make_above ();
352344
}
353345

346+
internal static void make_centered (Wl.Client client, Wl.Resource resource) {
347+
unowned ExtendedBehaviorSurface? eb_surface = resource.get_user_data<ExtendedBehaviorSurface> ();
348+
if (eb_surface.wayland_surface == null) {
349+
return;
350+
}
351+
352+
Meta.Window? window;
353+
eb_surface.wayland_surface.get ("window", out window, null);
354+
if (window == null) {
355+
return;
356+
}
357+
358+
ShellClientsManager.get_instance ().make_centered (window);
359+
}
360+
354361
internal static void destroy_panel_surface (Wl.Client client, Wl.Resource resource) {
355362
resource.destroy ();
356363
}

src/ShellClients/ShellClientsManager.vala

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Gala.ShellClientsManager : Object {
2626
private ManagedClient[] protocol_clients = {};
2727

2828
private GLib.HashTable<Meta.Window, PanelWindow> windows = new GLib.HashTable<Meta.Window, PanelWindow> (null, null);
29-
private GLib.HashTable<Meta.Window, WidgetWindow> widget_windows = new GLib.HashTable<Meta.Window, WidgetWindow> (null, null);
29+
private GLib.HashTable<Meta.Window, CenteredWindow> centered_windows = new GLib.HashTable<Meta.Window, CenteredWindow> (null, null);
3030

3131
private ShellClientsManager (WindowManager wm) {
3232
Object (wm: wm);
@@ -91,13 +91,13 @@ public class Gala.ShellClientsManager : Object {
9191
windows[window].set_hide_mode (hide_mode);
9292
}
9393

94-
public void make_widget (Meta.Window window) {
95-
if (window in widget_windows) {
94+
public void make_centered (Meta.Window window) {
95+
if (window in centered_windows) {
9696
return;
9797
}
9898

9999
make_dock (window);
100100

101-
widget_windows[window] = new WidgetWindow (wm, window);
101+
centered_windows[window] = new CenteredWindow (wm, window);
102102
}
103103
}

src/ShellClients/WidgetWindow.vala

-41
This file was deleted.

src/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ gala_bin_sources = files(
4040
'HotCorners/Barrier.vala',
4141
'HotCorners/HotCorner.vala',
4242
'HotCorners/HotCornerManager.vala',
43+
'ShellClients/CenteredWindow.vala',
4344
'ShellClients/HideTracker.vala',
4445
'ShellClients/ManagedClient.vala',
4546
'ShellClients/NotificationsClient.vala',
4647
'ShellClients/PanelClone.vala',
4748
'ShellClients/PanelWindow.vala',
4849
'ShellClients/ShellClientsManager.vala',
49-
'ShellClients/WidgetWindow.vala',
5050
'Widgets/DwellClickTimer.vala',
5151
'Widgets/IconGroup.vala',
5252
'Widgets/IconGroupContainer.vala',

0 commit comments

Comments
 (0)