Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the notification stack to be moved using DBus #1594

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ namespace Gala {
*/
public abstract void perform_action (ActionType type);

/**
* Tells the window manager to move the Notifications Stack down
* by the given number of points, to make room for menus.
*
* @param offset The number of points by which to move the notifications stack
*/
public abstract void offset_notifications (int32 offset);

/**
* Moves the window to the given workspace.
*
Expand Down
4 changes: 4 additions & 0 deletions src/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ namespace Gala {
wm.perform_action (type);
}

public void offset_notifications (int32 offset) throws DBusError, Error {
wm.offset_notifications (offset);
}

private const double SATURATION_WEIGHT = 1.5;
private const double WEIGHT_THRESHOLD = 1.0;

Expand Down
10 changes: 8 additions & 2 deletions src/NotificationStack.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class Gala.NotificationStack : Object {
private const int WIDTH = 300;

private int stack_y;
private int stack_y_offset;
private int stack_width;

public Meta.Display display { get; construct; }
Expand Down Expand Up @@ -99,7 +100,7 @@ public class Gala.NotificationStack : Object {
notification_x_pos = 0;
}

move_window (notification, notification_x_pos, stack_y + TOP_OFFSET + InternalUtils.scale_to_int (ADDITIONAL_MARGIN, scale));
move_window (notification, notification_x_pos, stack_y + TOP_OFFSET + InternalUtils.scale_to_int (stack_y_offset + ADDITIONAL_MARGIN, scale));
notifications.insert (0, notification);
}

Expand All @@ -114,7 +115,7 @@ public class Gala.NotificationStack : Object {
}

private void update_positions (bool animate, float scale, float add_y = 0.0f) {
var y = stack_y + TOP_OFFSET + add_y + InternalUtils.scale_to_int (ADDITIONAL_MARGIN, scale);
var y = stack_y + TOP_OFFSET + add_y + InternalUtils.scale_to_int (stack_y_offset + ADDITIONAL_MARGIN, scale);
var i = notifications.size;
var delay_step = i > 0 ? 150 / i : 0;
var iterator = 0;
Expand Down Expand Up @@ -156,6 +157,11 @@ public class Gala.NotificationStack : Object {
}
}

public void offset_notifications (int32 offset) {
stack_y_offset = offset;
update_positions (true);
}

public void destroy_notification (Meta.WindowActor notification, bool animate) {
if (animate) {
notification.save_easing_state ();
Expand Down
4 changes: 4 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,10 @@ namespace Gala {
}
}

public void offset_notifications (int32 offset) {
notification_stack.offset_notifications (offset);
}

public override void show_window_menu (Meta.Window window, Meta.WindowMenuType menu, int x, int y) {
switch (menu) {
case Meta.WindowMenuType.WM:
Expand Down
Loading