Skip to content

Commit

Permalink
Initial support for keeping shellclients in the multitasking view
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Feb 16, 2025
1 parent 434b79a commit e99cbb6
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 900 deletions.
6 changes: 6 additions & 0 deletions protocol/pantheon-desktop-shell-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@

<arg name="hide_mode" type="uint" enum="hide_mode" summary="hide mode"/>
</request>

<request name="request_visible_in_multitasking_view">
<description summary="request visible in multitasking view">
Tell the shell that the panel would like to be visible in the multitasking view.
</description>
</request>
</interface>

<interface name="io_elementary_pantheon_widget_v1" version="1">
Expand Down
3 changes: 3 additions & 0 deletions protocol/pantheon-desktop-shell.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace Pantheon.Desktop {
public Focus focus;
public SetSize set_size;
public SetHideMode set_hide_mode;
public RequestVisibleInMultitaskingView request_visible_in_multitasking_view;
}

[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "struct io_elementary_pantheon_widget_v1_interface")]
Expand Down Expand Up @@ -75,6 +76,8 @@ namespace Pantheon.Desktop {
[CCode (has_target = false, has_typedef = false)]
public delegate void SetHideMode (Wl.Client client, Wl.Resource resource, [CCode (type = "uint32_t")] HideMode hide_mode);
[CCode (has_target = false, has_typedef = false)]
public delegate void RequestVisibleInMultitaskingView (Wl.Client client, Wl.Resource resource);
[CCode (has_target = false, has_typedef = false)]
public delegate void SetKeepAbove (Wl.Client client, Wl.Resource resource);
[CCode (has_target = false, has_typedef = false)]
public delegate void MakeCentered (Wl.Client client, Wl.Resource resource);
Expand Down
18 changes: 18 additions & 0 deletions src/PantheonShell.vala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace Gala {
focus_panel,
set_size,
set_hide_mode,
request_visible_in_multitasking_view,
};

wayland_pantheon_widget_interface = {
Expand Down Expand Up @@ -311,6 +312,23 @@ namespace Gala {
ShellClientsManager.get_instance ().set_hide_mode (window, hide_mode);
}

internal static void request_visible_in_multitasking_view (Wl.Client client, Wl.Resource resource) {
unowned PanelSurface? panel_surface = resource.get_user_data<PanelSurface> ();
if (panel_surface.wayland_surface == null) {
warning ("Window tried to set visible in mutltiasking view but wayland surface is null.");
return;
}

Meta.Window? window;
panel_surface.wayland_surface.get ("window", out window, null);
if (window == null) {
warning ("Window tried to set hide mode but wayland surface had no associated window.");
return;
}

ShellClientsManager.get_instance ().request_visible_in_multitasking_view (window);
}

internal static void set_keep_above (Wl.Client client, Wl.Resource resource) {
unowned ExtendedBehaviorSurface? eb_surface = resource.get_user_data<ExtendedBehaviorSurface> ();
if (eb_surface.wayland_surface == null) {
Expand Down
9 changes: 9 additions & 0 deletions src/ShellClients/ShellClientsManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
panel_windows[window].hide_mode = hide_mode;
}

public void request_visible_in_multitasking_view (Meta.Window window) {
if (!(window in panel_windows)) {
warning ("Set anchor for window before visible in mutltiasking view.");
return;
}

panel_windows[window].visible_in_multitasking_view = true;
}

public void make_centered (Meta.Window window) requires (!is_itself_positioned (window)) {
positioned_windows[window] = new ShellWindow (window, CENTER);

Expand Down
15 changes: 12 additions & 3 deletions src/ShellClients/ShellWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class Gala.ShellWindow : PositionedWindow, GestureTarget {

public Clutter.Actor? actor { get { return window_actor; } }

public bool visible_in_multitasking_view { get; set; default = false; }

private Meta.WindowActor window_actor;
private double custom_progress = 0;
private double multitasking_view_progress = 0;
Expand Down Expand Up @@ -40,9 +42,16 @@ public class Gala.ShellWindow : PositionedWindow, GestureTarget {
);
}

private double get_hidden_progress () {
if (visible_in_multitasking_view) {
return double.min (custom_progress, 1 - multitasking_view_progress);
} else {
return double.max (custom_progress, multitasking_view_progress);
}
}

private void update_property () {
var hidden_progress = double.max (custom_progress, multitasking_view_progress);
property_target.propagate (UPDATE, GESTURE_ID, hidden_progress);
property_target.propagate (UPDATE, GESTURE_ID, get_hidden_progress ());
}

public override void propagate (UpdateType update_type, string id, double progress) {
Expand Down Expand Up @@ -84,7 +93,7 @@ public class Gala.ShellWindow : PositionedWindow, GestureTarget {
}

private void update_visibility () {
var visible = double.max (multitasking_view_progress, custom_progress) < 0.1;
var visible = get_hidden_progress () < 0.1;
var animating = animations_ongoing > 0;

if (!Meta.Util.is_wayland_compositor ()) {
Expand Down
Loading

0 comments on commit e99cbb6

Please sign in to comment.