Skip to content

Commit

Permalink
default_guivm: fire property-set on default_guivm
Browse files Browse the repository at this point in the history
  • Loading branch information
fepitre committed Nov 9, 2019
1 parent 78d0d2c commit e4d3e35
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions qubes/ext/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright (C) 2013-2016 Marek Marczykowski-Górecki
# <[email protected]>
# Copyright (C) 2014-2018 Wojtek Porczyk <[email protected]>
# Copyright (C) 2019 Frédéric Pierret <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -34,6 +35,12 @@ def send_gui_mode(vm):
if vm.features.get('gui-seamless', False)
else 'FULLSCREEN'))

# property-del <=> property-reset-to-default
@qubes.ext.handler('property-del:guivm')
def on_property_del(self, subject, event, name, oldvalue=None):
newvalue = getattr(subject, 'guivm', None)
self.on_property_set(subject, event, name, newvalue, oldvalue)

@qubes.ext.handler('property-set:guivm')
def on_property_set(self, subject, event, name, newvalue, oldvalue=None):
# pylint: disable=unused-argument,no-self-use
Expand All @@ -45,8 +52,9 @@ def on_property_set(self, subject, event, name, newvalue, oldvalue=None):
if 'guivm-' in tag:
subject.tags.remove(tag)

guivm = 'guivm-' + newvalue.name
subject.tags.add(guivm)
if newvalue:
guivm = 'guivm-' + newvalue.name
subject.tags.add(guivm)

@qubes.ext.handler('domain-qdb-create')
def on_domain_qdb_create(self, vm, event):
Expand Down Expand Up @@ -76,3 +84,12 @@ def on_domain_qdb_create(self, vm, event):
if vm.features.get('service.guivm-gui-agent', None):
vm.untrusted_qdb.write('/guivm-windows-prefix',
guivm_windows_prefix)

@qubes.ext.handler('property-set:default_guivm', system=True)
def on_property_set_default_guivm(self, app, event, name, newvalue,
oldvalue=None):
for vm in app.domains:
if getattr(vm, 'guivm', None) and vm.property_is_default('guivm'):
vm.fire_event('property-set:guivm',
name='guivm', newvalue=newvalue,
oldvalue=oldvalue)

0 comments on commit e4d3e35

Please sign in to comment.