update windowswitcher to use the latest functionality provided in mutter, improve its startup and code structure, add destroy-on-unmanaged properties to WindowIcon and SafeWindowClone

This commit is contained in:
Tom Beckmann 2014-07-19 00:42:06 +02:00
parent e02db107d9
commit 3e417dcfa8
4 changed files with 573 additions and 373 deletions

View File

@ -94,12 +94,42 @@ namespace Gala
public Meta.Window window { get; construct; }
public int icon_size { get; construct; }
/**
* If set to true, the SafeWindowClone will destroy itself when the connected
* window is unmanaged
*/
public bool destroy_on_unmanaged {
get {
return _destroy_on_unmanaged;
}
construct set {
if (_destroy_on_unmanaged == value)
return;
_destroy_on_unmanaged = value;
if (_destroy_on_unmanaged)
window.unmanaged.connect (unmanaged);
else
window.unmanaged.disconnect (unmanaged);
}
}
bool _destroy_on_unmanaged = false;
bool loaded = false;
uint32 xid;
public WindowIcon (Meta.Window window, int icon_size)
/**
* Creates a new WindowIcon
*
* @param window The window for which to create the icon
* @param icon_size The size of the icon in pixels
* @param destroy_on_unmanaged @see destroy_on_unmanaged
*/
public WindowIcon (Meta.Window window, int icon_size, bool destroy_on_unmanaged = false)
{
Object (window: window, icon_size: icon_size);
Object (window: window,
icon_size: icon_size,
destroy_on_unmanaged: destroy_on_unmanaged);
}
construct
@ -148,6 +178,11 @@ namespace Gala
set_from_pixbuf (pixbuf);
} catch (Error e) {}
}
void unmanaged (Meta.Window window)
{
destroy ();
}
}
/**

View File

@ -37,10 +37,25 @@ namespace Gala
{
public Window window { get; construct; }
public SafeWindowClone (Window window)
/**
* If set to true, the SafeWindowClone will destroy itself when the connected
* window is unmanaged
*/
public bool destroy_on_unmanaged { get; construct set; default = false; }
/**
* Creates a new SafeWindowClone
*
* @param window The window to clone from
* @param destroy_on_unmanaged @see destroy_on_unmanaged
*/
public SafeWindowClone (Window window, bool destroy_on_unmanaged = false)
{
var actor = (WindowActor) window.get_compositor_private ();
Object (window: window, source: actor);
Object (window: window,
source: actor,
destroy_on_unmanaged: destroy_on_unmanaged);
}
construct
@ -56,10 +71,13 @@ namespace Gala
void reset_source ()
{
// actually destroying the clone will be handled somewhere else, we just need
// to make sure the clone doesn't attempt to draw a clone of a window that
// has been destroyed
// actually destroying the clone will be handled somewhere else (unless we were
// requested to destroy it), we just need to make sure the clone doesn't attempt
// to draw a clone of a window that has been destroyed
source = null;
if (destroy_on_unmanaged)
destroy ();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -237,6 +237,8 @@ namespace Gala
KeyBinding.set_custom_handler ("switch-applications", winswitcher.handle_switch_windows);
KeyBinding.set_custom_handler ("switch-applications-backward", winswitcher.handle_switch_windows);
KeyBinding.set_custom_handler ("switch-windows", winswitcher.handle_switch_windows);
KeyBinding.set_custom_handler ("switch-windows-backward", winswitcher.handle_switch_windows);
}
if (plugin_manager.window_overview_provider == null