Skip to content

Commit c347748

Browse files
lenemtertintou
authored andcommitted
Improve dock hide animation
1 parent c0d7cd5 commit c347748

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

src/ShellClients/PanelWindow.vala

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public class Gala.PanelWindow : ShellWindow, RootTarget {
3131
private GestureController gesture_controller;
3232
private HideTracker hide_tracker;
3333

34-
private int width = -1;
35-
private int height = -1;
36-
3734
public PanelWindow (WindowManager wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) {
3835
Object (wm: wm, anchor: anchor, window: window, position: Position.from_anchor (anchor));
3936
}
@@ -53,6 +50,8 @@ public class Gala.PanelWindow : ShellWindow, RootTarget {
5350

5451
window.size_changed.connect (update_strut);
5552
window.position_changed.connect (update_strut);
53+
notify["width"].connect (update_strut);
54+
notify["height"].connect (update_strut);
5655

5756
gesture_controller = new GestureController (DOCK, wm);
5857
add_gesture_controller (gesture_controller);
@@ -62,32 +61,6 @@ public class Gala.PanelWindow : ShellWindow, RootTarget {
6261
hide_tracker.show.connect (show);
6362
}
6463

65-
public Mtk.Rectangle get_custom_window_rect () {
66-
var window_rect = window.get_frame_rect ();
67-
68-
if (width > 0) {
69-
window_rect.width = width;
70-
}
71-
72-
if (height > 0) {
73-
window_rect.height = height;
74-
75-
if (anchor == BOTTOM) {
76-
var geom = wm.get_display ().get_monitor_geometry (window.get_monitor ());
77-
window_rect.y = geom.y + geom.height - height;
78-
}
79-
}
80-
81-
return window_rect;
82-
}
83-
84-
public void set_size (int width, int height) {
85-
this.width = width;
86-
this.height = height;
87-
88-
update_strut ();
89-
}
90-
9164
private void hide () {
9265
gesture_controller.goto (1);
9366
}

src/ShellClients/PositionedWindow.vala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class Gala.PositionedWindow : Object {
2929
public Position position { get; construct set; }
3030
public Variant? position_data { get; construct set; }
3131

32+
private int width = -1;
33+
private int height = -1;
34+
3235
private ulong position_changed_id;
3336

3437
public PositionedWindow (Meta.Window window, Position position, Variant? position_data = null) {
@@ -50,6 +53,30 @@ public class Gala.PositionedWindow : Object {
5053
notify["position-data"].connect (position_window);
5154
}
5255

56+
public Mtk.Rectangle get_custom_window_rect () {
57+
var window_rect = window.get_frame_rect ();
58+
59+
if (width > 0) {
60+
window_rect.width = width;
61+
}
62+
63+
if (height > 0) {
64+
window_rect.height = height;
65+
66+
if (position == BOTTOM) {
67+
var geom = window.display.get_monitor_geometry (window.get_monitor ());
68+
window_rect.y = geom.y + geom.height - height;
69+
}
70+
}
71+
72+
return window_rect;
73+
}
74+
75+
public void set_size (int width, int height) {
76+
this.width = width;
77+
this.height = height;
78+
}
79+
5380
private void position_window () {
5481
int x = 0, y = 0;
5582
var window_rect = window.get_frame_rect ();

src/ShellClients/ShellWindow.vala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Gala.ShellWindow : PositionedWindow, GestureTarget {
2929
window_actor.notify["translation-y"].connect (update_clip);
3030
notify["position"].connect (update_clip);
3131

32-
window_actor.notify["height"].connect (update_target);
32+
window.size_changed.connect (update_target);
3333
notify["position"].connect (update_target);
3434
update_target ();
3535
}
@@ -136,11 +136,13 @@ public class Gala.ShellWindow : PositionedWindow, GestureTarget {
136136
}
137137

138138
private Value calculate_value (bool hidden) {
139+
var custom_rect = get_custom_window_rect ();
140+
139141
switch (position) {
140142
case TOP:
141-
return hidden ? -window_actor.height : 0f;
143+
return hidden ? -custom_rect.height : 0f;
142144
case BOTTOM:
143-
return hidden ? window_actor.height : 0f;
145+
return hidden ? custom_rect.height : 0f;
144146
default:
145147
return hidden ? 0u : 255u;
146148
}

0 commit comments

Comments
 (0)