Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Feb 24, 2024
2 parents 74d4671 + 126f397 commit c383e24
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/Widgets/DisplaysOverlay.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
* Felix Andreas <fandreas@physik.hu-berlin.de>
*/

public class Display.DisplaysOverlay : Gtk.Overlay {
public class Display.DisplaysOverlay : Gtk.Box {
private const int SNAP_LIMIT = int.MAX - 1;
private const int MINIMUM_WIDGET_OFFSET = 50;

public signal void configuration_changed (bool changed);

private Gtk.Overlay overlay;
private bool scanning = false;
// The ratio between the real dimensions of the virtual monitor(s) and the
// allocated size of the overlay (min). Used for scaling movement of the
Expand Down Expand Up @@ -72,12 +73,10 @@ public class Display.DisplaysOverlay : Gtk.Overlay {
private Gtk.GestureDrag drag_gesture;

construct {
var grid = new Gtk.Grid () {
hexpand = true,
vexpand = true
};
grid.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
child = grid;
get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);

overlay = new Gtk.Overlay ();
add (overlay);

display_widgets = new List<DisplayWidget> ();

Expand All @@ -89,6 +88,8 @@ public class Display.DisplaysOverlay : Gtk.Overlay {
monitor_manager = Display.MonitorManager.get_default ();
monitor_manager.notify["virtual-monitor-number"].connect (() => rescan_displays ());
rescan_displays ();

overlay.get_child_position.connect (get_child_position);
}

static construct {
Expand Down Expand Up @@ -134,8 +135,6 @@ public class Display.DisplaysOverlay : Gtk.Overlay {
break;
}
}

reorder_overlay (dragging_display, -1);
}

// dx & dy are screen offsets from the start of dragging
Expand All @@ -157,7 +156,7 @@ public class Display.DisplaysOverlay : Gtk.Overlay {

// Determine the position in the overlay of a display widget based on its
// virtual monitor geometry and any offsets when dragging.
public override bool get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) {
private bool get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) {
allocation = Gdk.Rectangle ();
if (current_allocated_width != get_allocated_width () ||
current_allocated_height != get_allocated_height ()) {
Expand Down Expand Up @@ -319,11 +318,11 @@ public class Display.DisplaysOverlay : Gtk.Overlay {
current_allocated_width = 0;
current_allocated_height = 0;

var color_number = (get_children ().length () - 2) % 7;
var color_number = (display_widgets.length () - 1) % 7;
var display_widget = new DisplayWidget (virtual_monitor, colors[color_number], text_colors[color_number]);
display_widget.get_style_context ().add_class ("color-%u".printf (color_number));

add_overlay (display_widget);
overlay.add_overlay (display_widget);
display_widgets.append (display_widget);

display_widget.show_all ();
Expand Down

0 comments on commit c383e24

Please sign in to comment.