mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 15:15:39 +03:00
More API clean ups
Drop "window_stacking_order" and "windows_restacked" from window-manager and replace it by an implementation in TiledWindowContainer
This commit is contained in:
parent
195dfd06f9
commit
97b71fce4b
@ -38,22 +38,11 @@ namespace Gala
|
||||
|
||||
public interface WindowManager : Meta.Plugin
|
||||
{
|
||||
/**
|
||||
* Window stacking changed. You can read the plugin's stacking_order property
|
||||
* to restack window clones.
|
||||
*/
|
||||
public signal void windows_restacked ();
|
||||
|
||||
public abstract Clutter.Actor ui_group { get; protected set; }
|
||||
public abstract Clutter.Stage stage { get; protected set; }
|
||||
public abstract Clutter.Actor window_group { get; protected set; }
|
||||
public abstract Clutter.Actor top_window_group { get; protected set; }
|
||||
public abstract Meta.BackgroundGroup background_group { get; protected set; }
|
||||
/*
|
||||
* Provides a hashtable of windows' stable sequences and their stacking order
|
||||
* counted from 0 up.
|
||||
*/
|
||||
public abstract HashTable<int,int> window_stacking_order { get; protected set; }
|
||||
/**
|
||||
* If true all keybindings will be blocked while modal mode is active.
|
||||
*/
|
||||
|
@ -45,12 +45,9 @@ namespace Gala
|
||||
background = new Background (screen, monitor, BackgroundSettings.get_default ().schema);
|
||||
background.set_easing_duration (300);
|
||||
|
||||
window_container = new TiledWindowContainer (wm.window_stacking_order);
|
||||
window_container = new TiledWindowContainer ();
|
||||
window_container.window_selected.connect ((w) => { window_selected (w); });
|
||||
|
||||
wm.windows_restacked.connect (() => {
|
||||
window_container.stacking_order = wm.window_stacking_order;
|
||||
});
|
||||
screen.restacked.connect (window_container.restack_windows);
|
||||
|
||||
screen.window_entered_monitor.connect (window_entered);
|
||||
screen.window_left_monitor.connect (window_left);
|
||||
@ -71,6 +68,13 @@ namespace Gala
|
||||
update_allocation ();
|
||||
}
|
||||
|
||||
~MonitorClone ()
|
||||
{
|
||||
screen.window_entered_monitor.disconnect (window_entered);
|
||||
screen.window_left_monitor.disconnect (window_left);
|
||||
screen.restacked.disconnect (window_container.restack_windows);
|
||||
}
|
||||
|
||||
public void update_allocation ()
|
||||
{
|
||||
var monitor_geometry = screen.get_monitor_geometry (monitor);
|
||||
|
@ -29,17 +29,6 @@ namespace Gala
|
||||
public int padding_right { get; set; default = 12; }
|
||||
public int padding_bottom { get; set; default = 12; }
|
||||
|
||||
HashTable<int,int> _stacking_order;
|
||||
public HashTable<int,int> stacking_order {
|
||||
get {
|
||||
return _stacking_order;
|
||||
}
|
||||
set {
|
||||
_stacking_order = value;
|
||||
restack ();
|
||||
}
|
||||
}
|
||||
|
||||
bool _opened;
|
||||
public bool opened {
|
||||
get {
|
||||
@ -62,7 +51,6 @@ namespace Gala
|
||||
((TiledWindow) window).transition_to_original_state (false);
|
||||
}
|
||||
|
||||
restack ();
|
||||
reflow ();
|
||||
} else {
|
||||
transition_to_original_state ();
|
||||
@ -86,25 +74,45 @@ namespace Gala
|
||||
}
|
||||
}
|
||||
|
||||
public TiledWindowContainer (HashTable<int,int> stacking_order)
|
||||
public TiledWindowContainer ()
|
||||
{
|
||||
_stacking_order = stacking_order;
|
||||
}
|
||||
|
||||
public void add_window (Window window, bool reflow_windows = true)
|
||||
{
|
||||
unowned Meta.Display display = window.get_display ();
|
||||
var children = get_children ();
|
||||
|
||||
GLib.SList<unowned Meta.Window> windows = new GLib.SList<unowned Meta.Window> ();
|
||||
foreach (unowned Actor child in children) {
|
||||
unowned TiledWindow tw = (TiledWindow) child;
|
||||
windows.prepend (tw.window);
|
||||
}
|
||||
windows.prepend (window);
|
||||
windows.reverse ();
|
||||
|
||||
var windows_ordered = display.sort_windows_by_stacking (windows);
|
||||
|
||||
var new_window = new TiledWindow (window);
|
||||
var new_seq = stacking_order.get ((int)window.get_stable_sequence ());
|
||||
|
||||
new_window.selected.connect (window_selected_cb);
|
||||
new_window.destroy.connect (window_destroyed);
|
||||
new_window.request_reposition.connect (reflow);
|
||||
|
||||
var children = get_children ();
|
||||
var added = false;
|
||||
foreach (var child in children) {
|
||||
if (stacking_order.get ((int)((TiledWindow) child).window.get_stable_sequence ()) < new_seq) {
|
||||
insert_child_below (new_window, child);
|
||||
unowned Meta.Window? target = null;
|
||||
foreach (unowned Meta.Window w in windows_ordered) {
|
||||
if (w != window) {
|
||||
target = w;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (unowned Actor child in children) {
|
||||
unowned TiledWindow tw = (TiledWindow) child;
|
||||
if (target == tw.window) {
|
||||
insert_child_above (new_window, tw);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
@ -150,16 +158,26 @@ namespace Gala
|
||||
});
|
||||
}
|
||||
|
||||
public void restack ()
|
||||
public void restack_windows (Screen screen)
|
||||
{
|
||||
// FIXME there is certainly a way to do this in less than n^2 steps
|
||||
foreach (var child1 in get_children ()) {
|
||||
unowned Meta.Display display = screen.get_display ();
|
||||
var children = get_children ();
|
||||
|
||||
GLib.SList<unowned Meta.Window> windows = new GLib.SList<unowned Meta.Window> ();
|
||||
foreach (unowned Actor child in children) {
|
||||
unowned TiledWindow tw = (TiledWindow) child;
|
||||
windows.prepend (tw.window);
|
||||
}
|
||||
|
||||
var windows_ordered = display.sort_windows_by_stacking (windows);
|
||||
windows_ordered.reverse ();
|
||||
|
||||
foreach (unowned Meta.Window window in windows_ordered) {
|
||||
var i = 0;
|
||||
foreach (var child2 in get_children ()) {
|
||||
int index1 = stacking_order.get ((int)((TiledWindow) child1).window.get_stable_sequence ());
|
||||
int index2 = stacking_order.get ((int)((TiledWindow) child2).window.get_stable_sequence ());
|
||||
if (index1 < index2) {
|
||||
set_child_at_index (child1, i);
|
||||
foreach (unowned Actor child in children) {
|
||||
if (((TiledWindow) child).window == window) {
|
||||
set_child_at_index (child, i);
|
||||
children.remove (child);
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
|
@ -96,13 +96,11 @@ namespace Gala
|
||||
return false;
|
||||
});
|
||||
|
||||
window_container = new TiledWindowContainer (wm.window_stacking_order);
|
||||
window_container = new TiledWindowContainer ();
|
||||
window_container.window_selected.connect ((w) => { window_selected (w); });
|
||||
window_container.width = monitor_geometry.width;
|
||||
window_container.height = monitor_geometry.height;
|
||||
wm.windows_restacked.connect (() => {
|
||||
window_container.stacking_order = wm.window_stacking_order;
|
||||
});
|
||||
screen.restacked.connect (window_container.restack_windows);
|
||||
|
||||
icon_group = new IconGroup (workspace);
|
||||
icon_group.selected.connect (() => {
|
||||
@ -153,6 +151,8 @@ namespace Gala
|
||||
{
|
||||
unowned Screen screen = workspace.get_screen ();
|
||||
|
||||
screen.restacked.disconnect (window_container.restack_windows);
|
||||
|
||||
screen.window_entered_monitor.disconnect (window_entered_monitor);
|
||||
screen.window_left_monitor.disconnect (window_left_monitor);
|
||||
workspace.window_added.disconnect (add_window);
|
||||
|
@ -26,7 +26,6 @@ namespace Gala
|
||||
public Clutter.Actor window_group { get; protected set; }
|
||||
public Clutter.Actor top_window_group { get; protected set; }
|
||||
public Meta.BackgroundGroup background_group { get; protected set; }
|
||||
public HashTable<int,int> window_stacking_order { get; protected set; }
|
||||
|
||||
public WorkspaceManager workspace_manager { get; private set; }
|
||||
|
||||
@ -128,10 +127,6 @@ namespace Gala
|
||||
stage.remove_child (top_window_group);
|
||||
ui_group.add_child (top_window_group);
|
||||
|
||||
window_stacking_order = new HashTable<int,int> (null, null);
|
||||
update_stacking_order ();
|
||||
screen.restacked.connect (update_stacking_order);
|
||||
|
||||
/*keybindings*/
|
||||
|
||||
screen.get_display ().add_keybinding ("switch-to-workspace-first", KeybindingSettings.get_default ().schema, 0, () => {
|
||||
@ -254,19 +249,6 @@ namespace Gala
|
||||
return false;
|
||||
}
|
||||
|
||||
void update_stacking_order ()
|
||||
{
|
||||
window_stacking_order.remove_all ();
|
||||
|
||||
var i = 0;
|
||||
foreach (var window in Compositor.get_window_actors (get_screen ())) {
|
||||
var seq = (int)window.get_meta_window ().get_stable_sequence ();
|
||||
window_stacking_order.set (seq, i++);
|
||||
}
|
||||
|
||||
windows_restacked ();
|
||||
}
|
||||
|
||||
void configure_hotcorners ()
|
||||
{
|
||||
var geometry = get_screen ().get_monitor_geometry (get_screen ().get_primary_monitor ());
|
||||
|
Loading…
Reference in New Issue
Block a user