mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
Add a gsetting key to disable keyboard grabbing
Add a gsetting key to disable keyboard grabbing that works the same way as spicy when unchecking "Options" > "Grab keyboard when active and focused".
This commit is contained in:
parent
f23c031af4
commit
66d146acee
@ -188,6 +188,13 @@
|
||||
<description>Grab keyboard sequence for the graphical console</description>
|
||||
</key>
|
||||
|
||||
<!--This key is not intended to be exposed in the UI yet-->
|
||||
<key name="grab-keyboard" type="b">
|
||||
<default>true</default>
|
||||
<summary>Enable grab keyboard when active and focused</summary>
|
||||
<description>Enable grab keyboard when active and focused</description>
|
||||
</key>
|
||||
|
||||
<key name="auto-redirect" type="b">
|
||||
<default>true</default>
|
||||
<summary>Enable SPICE Auto USB redirection in console window</summary>
|
||||
|
@ -286,6 +286,14 @@ class vmmConfig(object):
|
||||
def on_keys_combination_changed(self, cb):
|
||||
return self.conf.notify_add("/console/grab-keys", cb)
|
||||
|
||||
# This key is not intended to be exposed in the UI yet
|
||||
def get_grab_keyboard(self):
|
||||
return self.conf.get("/console/grab-keyboard")
|
||||
def set_grab_keyboard(self, val):
|
||||
self.conf.set("/console/grab-keyboard", val)
|
||||
def on_grab_keyboard_changed(self, cb):
|
||||
return self.conf.notify_add("/console/grab-keyboard", cb)
|
||||
|
||||
# Confirmation preferences
|
||||
def get_confirm_forcepoweroff(self):
|
||||
return self.conf.get("/confirm/forcepoweroff")
|
||||
|
@ -360,6 +360,9 @@ class Viewer(vmmGObject):
|
||||
def send_keys(self, keys):
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_grab_keyboard(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def open_host(self, ginfo):
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -394,6 +397,7 @@ class VNCViewer(Viewer):
|
||||
|
||||
def init_widget(self):
|
||||
self.set_grab_keys()
|
||||
self.set_grab_keyboard()
|
||||
|
||||
self.display.realize()
|
||||
|
||||
@ -403,7 +407,6 @@ class VNCViewer(Viewer):
|
||||
self.console.sync_scaling_with_display()
|
||||
self.console.refresh_resizeguest_from_settings()
|
||||
|
||||
self.display.set_keyboard_grab(True)
|
||||
self.display.set_pointer_grab(True)
|
||||
|
||||
self.display.connect("size-allocate",
|
||||
@ -461,6 +464,10 @@ class VNCViewer(Viewer):
|
||||
def send_keys(self, keys):
|
||||
return self.display.send_keys([Gdk.keyval_from_name(k) for k in keys])
|
||||
|
||||
def set_grab_keyboard(self):
|
||||
self.display.set_keyboard_grab(self.config.get_grab_keyboard())
|
||||
self.display.force_grab(self.config.get_grab_keyboard())
|
||||
|
||||
def _desktop_resize(self, src_ignore, w, h):
|
||||
self.desktop_resolution = (w, h)
|
||||
self.console.widget("console-gfx-scroll").queue_resize()
|
||||
@ -571,6 +578,7 @@ class SpiceViewer(Viewer):
|
||||
|
||||
def _init_widget(self):
|
||||
self.set_grab_keys()
|
||||
self.set_grab_keyboard()
|
||||
self.console.sync_scaling_with_display()
|
||||
self.console.refresh_resizeguest_from_settings()
|
||||
|
||||
@ -617,6 +625,9 @@ class SpiceViewer(Viewer):
|
||||
return self.display.send_keys([Gdk.keyval_from_name(k) for k in keys],
|
||||
SpiceClientGtk.DisplayKeyEvent.CLICK)
|
||||
|
||||
def set_grab_keyboard(self):
|
||||
self.display.set_property("grab-keyboard", self.config.get_grab_keyboard())
|
||||
|
||||
def close(self):
|
||||
if self.spice_session is not None:
|
||||
self.spice_session.disconnect()
|
||||
@ -875,6 +886,8 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
self.config.on_console_accels_changed(self.set_enable_accel))
|
||||
self.add_gconf_handle(
|
||||
self.config.on_keys_combination_changed(self.grab_keys_changed))
|
||||
self.add_gconf_handle(
|
||||
self.config.on_grab_keyboard_changed(self.grab_keyboard_changed))
|
||||
|
||||
self.page_changed()
|
||||
|
||||
@ -1027,6 +1040,9 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
def pointer_grabbed(self, src_ignore):
|
||||
self.pointer_is_grabbed = True
|
||||
self.change_title()
|
||||
if not self.config.get_grab_keyboard():
|
||||
self.viewer.display.force_grab(False)
|
||||
self.viewer.display.set_keyboard_grab(self.config.get_grab_keyboard())
|
||||
|
||||
def pointer_ungrabbed(self, src_ignore):
|
||||
self.pointer_is_grabbed = False
|
||||
@ -1067,6 +1083,10 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
if self.viewer:
|
||||
self.viewer.set_grab_keys()
|
||||
|
||||
def grab_keyboard_changed(self):
|
||||
if self.viewer:
|
||||
self.viewer.set_grab_keyboard()
|
||||
|
||||
def set_enable_accel(self):
|
||||
# Make sure modifiers are up to date
|
||||
self.viewer_focus_changed()
|
||||
|
Loading…
Reference in New Issue
Block a user