-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constrain mouse inside shadow window #3415
Comments
Gdk.pointer_grab used to do this in GTK2 (pygtk): import pygtk
pygtk.require("2.0")
import gobject, gtk
def release_me():
gtk.main_quit()
return True
def on_destroy(widget):
gtk.main_quit()
def on_enter(widget, event):
if event.type == gtk.gdk.ENTER_NOTIFY:
cursor = gtk.gdk.Cursor(gtk.gdk.PIRATE) # Pirates!!
gtk.gdk.pointer_grab(widget.window, False, gtk.gdk.POINTER_MOTION_MASK,
widget.window, cursor, long(event.time))
gobject.timeout_add(15000, release_me)
else:
# leaving: won't happen
gtk.gdk.pointer_ungrab(long(event.time))
return False
def on_move(widget, event):
print "move to:", event.x, event.y
def main():
w = gtk.Window()
w.set_title("Grabby")
w.connect('destroy', on_destroy)
w.connect('enter-notify-event', on_enter)
w.connect('motion-notify-event', on_move)
w.show_all()
gtk.main()
gdk.pointer_ungrab(long(event.time))
if __name__ == '__main__':
main() But this doesn't seem to work with GTK3 anymore? |
Actually, I just remembered that we already have this But I've just tried it and it doesn't seem to confine the pointer, only trap focus / input. |
Minimal reproducer #!/usr/bin/env python3
import gi
from xpra.util import AdHocStruct
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
from xpra.platform.win32.gui import pointer_grab
w = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
w._client = AdHocStruct()
w.show()
GLib.timeout_add(1000, pointer_grab, w)
Gtk.main() |
It works as expected. However ... at least, you should auto-disengage it on Alt+Tab. ... Which will also MAY be more complicated to judge if you need to auto- |
so we only reset the 'pointer_grabbed' value when we actually owned it
I just don't have any hardware available that runs MS Windows native so I can't try it!
The first commit above should fix that (totally untested), the second one is not strictly needed. We track and manage keyboard grabs and pointer grabs separately and I'm not sure that makes any sense but I don't have to courage to change it, especially if I can't test the only platform that actually honours it properly. |
Again, take the VM example (Virtualbox): "Simple keys" can just pass on as-is. If you'd like to grab the mouse (because I like the constraint), I can. If I need to capture the keyboard (#3388 eg for Alt+Tab), I can |
@stdedos is the double-grab issue fixed? Can we close this ticket? |
Yes, it's all good now! Thanks 😄 |
Is your feature request related to a problem? Please describe.
Somewhat related to #3388, I'd like to be able to constrain the mouse pointer within the Shadow window.
Again related to #3388, it could be released on a specific shortcut - VM software have already figured this out
The text was updated successfully, but these errors were encountered: