1.10: No cursor in M_Confined mode

In my current project, I’ve set the mouse-mode to “M_confined”. Unfortunately, this seems to have resulted in the mouse-cursor no longer being visible!

Specifically, it seems the issue occurs when one sets the window-properties with “setMouseMode(WindowProperties.M_confined)”, then (almost) immediately afterwards, in a second call to “base.win.requestProperties”, sets them again with the cursor hidden via “setCursorHidden(True)”. This seems to cause the cursor to disappear (as expected), and to not return after a later use of “setCursorHidden(False)”.

If there’s a gap between the first two requests for window-properties (such as if the second is run as a result of a button-press), then the issue doesn’t appear. Similarly, if they still occur one directly after another, but “setMouseMode(WindowProperties.M_confined)” is omitted, then again the issue doesn’t appear. Only if both the mouse-mode is set and the two requests for window-properties occur one directly after another does the issue show itself.

It’s not clear how “immediately” the two calls should be to cause the issue to appear.

I’m pretty confident that this worked in 1.9.

A simple program that demonstrates the issue on my end; when run, press “1”, then “2”.

from direct.showbase.ShowBase import ShowBase

from panda3d.core import WindowProperties

class GameFramework(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        base.disableMouse()

        self.accept("1", self.one)
        self.accept("2", self.two)

    def one(self):
        print "One!"

        wp = WindowProperties()
        # Comment out this next line to cause the
        #  subsequent call of the method "two" to
        #  work as expected
        wp.setMouseMode(WindowProperties.M_confined)
        wp.setCursorHidden(False)
        base.win.requestProperties(wp)

        wp = WindowProperties()
        wp.setCursorHidden(True)
        base.win.requestProperties(wp)

    def two(self):
        print "Two!"
        wp = WindowProperties()
        wp.setCursorHidden(False)
        base.win.requestProperties(wp)

# Let the game begin!
gameFramework = GameFramework()
gameFramework.run()

This was encountered in a custom build of 1.10, running under Ubuntu 16.04 (“Xenial”), I believe.

(As for why I’m requesting window-properties one directly after another like this, it’s a matter of program flow. As I recall: The first request is initialisation (including setting the “confined” mode). The second arises from a call to a method that is used both there and elsewhere in the program, and that happens to hide the cursor as part of its work.)

bump Any thoughts?

A minor update:

I’ve discovered that you don’t need to call “requestProperties” twice: the issue also occurs if you set the cursor to be hidden in the same set of properties in which you set the mouse-mode. (Were the requested properties perhaps being combined in the two-request code above, thus producing a set of properties that both hides the cursor and sets the mouse-mode?)

An updated version of the demonstration program above:

from direct.showbase.ShowBase import ShowBase

from panda3d.core import WindowProperties

class GameFramework(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        base.disableMouse()

        self.accept("1", self.one)
        self.accept("2", self.two)

    def one(self):
        print "One!"

        wp = WindowProperties()
        # Comment out this next line to cause the
        #  subsequent call of the method "two" to
        #  work as expected
        wp.setMouseMode(WindowProperties.M_confined)
        wp.setCursorHidden(True)
        base.win.requestProperties(wp)

    def two(self):
        print "Two!"

        wp = WindowProperties()
        wp.setCursorHidden(False)
        base.win.requestProperties(wp)

# Let the game begin!
gameFramework = GameFramework()
gameFramework.run()

I’ve tried looking at a diff of the 1.10 and 1.9 versions of a few of the obvious files associated with this process. I think that I looked at the following:

  • graphicsWindow.cxx/.h/.i
  • windowProperties.cxx/.h/.i
  • config_display.cxx/.h

I didn’t see anything that seemed likely to have caused the problem, I’m afraid. :confused:

Yeah, seems to be a bug; X11 ignores cursor changes while the cursor is in confined or relative mode. (although I find it strange to believe this would not have occurred in 1.9.)

Fixed in 2347587. Thanks for reporting, with such a clear test case!

For future reference, if you report issues on the issue tracker in the future, you may see faster response times.

Yes, this is what happens; the reason is that window property changes may need to be executed in another thread, so requestProperties simply queues the property changes until the window code has a chance to get around to it.

Ah, I can confirm that it does indeed seem to be working now! Thank you very much for fixing it! (The report and test-cast are my pleasure.) :slight_smile:

It’s possible that the issue began with some update to Ubuntu–I don’t recall whether I checked it under 1.9 after discovering the problem. I do seem to recall that it was working at some stage in the past.

As to the issue tracker, that perhaps would be better. Sorry! ^^;