|
1 | 1 | namespace SwayNotificationCenter {
|
2 |
| - /* Only to be used by the Viewport in the Control Center */ |
3 |
| - private class FixedViewportLayout : Gtk.LayoutManager { |
4 |
| - private unowned Gtk.ScrolledWindow parent; |
5 |
| - |
6 |
| - public FixedViewportLayout (Gtk.ScrolledWindow parent) { |
7 |
| - this.parent = parent; |
8 |
| - } |
9 |
| - |
10 |
| - public override void measure (Gtk.Widget widget, |
11 |
| - Gtk.Orientation orientation, int for_size, |
12 |
| - out int minimum, out int natural, |
13 |
| - out int minimum_baseline, out int natural_baseline) { |
14 |
| - minimum = 0; |
15 |
| - natural = 0; |
16 |
| - minimum_baseline = 0; |
17 |
| - natural_baseline = 0; |
18 |
| - |
19 |
| - if (widget == null || !widget.should_layout ()) { |
20 |
| - return; |
21 |
| - } |
22 |
| - |
23 |
| - unowned Gtk.Widget child = ((Gtk.Viewport) widget).child; |
24 |
| - if (!child.should_layout ()) { |
25 |
| - return; |
26 |
| - } |
27 |
| - |
28 |
| - child.measure (orientation, for_size, |
29 |
| - out minimum, out natural, |
30 |
| - out minimum_baseline, out natural_baseline); |
31 |
| - } |
32 |
| - |
33 |
| - public override void allocate (Gtk.Widget widget, |
34 |
| - int width, int height, int baseline) { |
35 |
| - if (widget == null || !widget.should_layout ()) { |
36 |
| - return; |
37 |
| - } |
38 |
| - |
39 |
| - unowned Gtk.Widget child = ((Gtk.Viewport) widget).child; |
40 |
| - if (!child.should_layout ()) { |
41 |
| - return; |
42 |
| - } |
43 |
| - |
44 |
| - if (ConfigModel.instance.fit_to_screen) { |
45 |
| - child.allocate (width, height, baseline, null); |
46 |
| - return; |
47 |
| - } |
48 |
| - |
49 |
| - int m_height, n_height; |
50 |
| - child.measure (Gtk.Orientation.VERTICAL, -1, |
51 |
| - out m_height, out n_height, |
52 |
| - null, null); |
53 |
| - int m_width, n_width; |
54 |
| - child.measure (Gtk.Orientation.HORIZONTAL, -1, |
55 |
| - out m_width, out n_width, |
56 |
| - null, null); |
57 |
| - |
58 |
| - int parent_width = parent.get_width (); |
59 |
| - int parent_height = parent.get_height (); |
60 |
| - |
61 |
| - // Limit the size to the ScrolledWindows size |
62 |
| - child.allocate ( |
63 |
| - n_width.clamp ((int) Math.fmin (m_width, parent_width), parent_width), |
64 |
| - n_height.clamp ((int) Math.fmin (m_height, parent_height), parent_height), |
65 |
| - baseline, null); |
66 |
| - } |
67 |
| - } |
68 |
| - |
69 | 2 | [GtkTemplate (ui = "/org/erikreider/swaync/ui/control_center.ui")]
|
70 | 3 | public class ControlCenter : Gtk.ApplicationWindow {
|
71 | 4 | [GtkChild]
|
@@ -416,9 +349,6 @@ namespace SwayNotificationCenter {
|
416 | 349 | ConfigModel.instance.control_center_height);
|
417 | 350 | box.set_size_request (ConfigModel.instance.control_center_width,
|
418 | 351 | ConfigModel.instance.control_center_height);
|
419 |
| - // Use a custom layout to limit the minimum size above to the size |
420 |
| - // of the window so that it doesn't exceed the monitors edge |
421 |
| - window.child.set_layout_manager (new FixedViewportLayout (window)); |
422 | 352 |
|
423 | 353 | // Set the preferred monitor
|
424 | 354 | string ? monitor_name = ConfigModel.instance.control_center_preferred_output;
|
|
0 commit comments