mirror of
https://github.com/elementary/gala.git
synced 2024-12-18 14:51:51 +03:00
Fix occasional crashes in alt-tab-switch
This commit is contained in:
parent
edb669934a
commit
4d6bce848d
@ -27,6 +27,8 @@ namespace Gala
|
||||
|
||||
Window? moving; //place for the window that is being moved over
|
||||
|
||||
int modal_count; //count of modal modes overlaying each other
|
||||
|
||||
Gee.HashSet<Meta.WindowActor> minimizing = new Gee.HashSet<Meta.WindowActor> ();
|
||||
Gee.HashSet<Meta.WindowActor> maximizing = new Gee.HashSet<Meta.WindowActor> ();
|
||||
Gee.HashSet<Meta.WindowActor> unmaximizing = new Gee.HashSet<Meta.WindowActor> ();
|
||||
@ -162,6 +164,11 @@ namespace Gala
|
||||
|
||||
public new void begin_modal ()
|
||||
{
|
||||
if (modal_count != 0) {
|
||||
return;
|
||||
}
|
||||
modal_count ++;
|
||||
|
||||
var screen = get_screen ();
|
||||
var display = screen.get_display ();
|
||||
|
||||
@ -170,7 +177,10 @@ namespace Gala
|
||||
|
||||
public new void end_modal ()
|
||||
{
|
||||
base.end_modal (get_screen ().get_display ().get_current_time ());
|
||||
if (modal_count > 0)
|
||||
modal_count --;
|
||||
if (modal_count == 0)
|
||||
base.end_modal (get_screen ().get_display ().get_current_time ());
|
||||
}
|
||||
|
||||
public void get_current_cursor_position (out int x, out int y)
|
||||
|
@ -28,6 +28,8 @@ namespace Gala
|
||||
|
||||
Meta.Window? current_window;
|
||||
|
||||
bool active; //switcher is currently running
|
||||
|
||||
public WindowSwitcher (Gala.Plugin _plugin)
|
||||
{
|
||||
plugin = _plugin;
|
||||
@ -37,30 +39,38 @@ namespace Gala
|
||||
{
|
||||
if (((event.modifier_state & ModifierType.MOD1_MASK) == 0) ||
|
||||
event.keyval == Key.Alt_L) {
|
||||
|
||||
foreach (var clone in window_clones) {
|
||||
remove_child (clone);
|
||||
clone.destroy ();
|
||||
}
|
||||
|
||||
Meta.Compositor.get_window_actors (plugin.get_screen ()).foreach ((w) => {
|
||||
var meta_win = w.get_meta_window ();
|
||||
if (!meta_win.minimized &&
|
||||
(meta_win.get_workspace () == plugin.get_screen ().get_active_workspace ()) ||
|
||||
meta_win.is_on_all_workspaces ())
|
||||
w.show ();
|
||||
});
|
||||
|
||||
window_clones.clear ();
|
||||
|
||||
plugin.end_modal ();
|
||||
current_window.activate (event.time);
|
||||
current_window = null;
|
||||
close (event.time);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void close (uint time)
|
||||
{
|
||||
foreach (var clone in window_clones) {
|
||||
remove_child (clone);
|
||||
clone.destroy ();
|
||||
}
|
||||
|
||||
Meta.Compositor.get_window_actors (plugin.get_screen ()).foreach ((w) => {
|
||||
var meta_win = w.get_meta_window ();
|
||||
if (!meta_win.minimized &&
|
||||
(meta_win.get_workspace () == plugin.get_screen ().get_active_workspace ()) ||
|
||||
meta_win.is_on_all_workspaces ())
|
||||
w.show ();
|
||||
});
|
||||
|
||||
window_clones.clear ();
|
||||
|
||||
plugin.end_modal ();
|
||||
if (current_window != null) {
|
||||
current_window.activate (time);
|
||||
current_window = null;
|
||||
}
|
||||
|
||||
active = false;
|
||||
}
|
||||
|
||||
public override bool captured_event (Clutter.Event event)
|
||||
{
|
||||
if (!(event.get_type () == EventType.KEY_PRESS))
|
||||
@ -113,6 +123,14 @@ namespace Gala
|
||||
public void handle_switch_windows (Meta.Display display, Meta.Screen screen, Meta.Window? window,
|
||||
X.Event event, Meta.KeyBinding binding)
|
||||
{
|
||||
if (active) {
|
||||
if (window_clones.size != 0)
|
||||
close (screen.get_display ().get_current_time ());
|
||||
return;
|
||||
}
|
||||
|
||||
active = true;
|
||||
|
||||
var metawindows = display.get_tab_list (Meta.TabList.NORMAL, screen, screen.get_active_workspace ());
|
||||
if (metawindows.length () <= 1)
|
||||
return;
|
||||
|
@ -100,6 +100,8 @@ namespace Gala
|
||||
screen.remove_workspace (screen.get_workspaces ().nth_data (i), screen.get_display ().get_current_time ());
|
||||
}
|
||||
}
|
||||
|
||||
add_workspace ();
|
||||
}
|
||||
|
||||
bool draw_background (Cairo.Context cr)
|
||||
|
Loading…
Reference in New Issue
Block a user