0

I am using the excellent PyGI AIO (3.14.0) binaries to develop with Gtk3 and Clutter on Windows. So far it has been working great. However, there seems to be a problem with pointer events not reaching the Clutter.Stage inside a GtkClutter.Embed widget. Here is the code:

import sys

from gi.repository import GtkClutter
GtkClutter.init(sys.argv)
from gi.repository import Clutter, Gdk, Gtk, GObject

def main():
    win = Gtk.Window(Gtk.WindowType.TOPLEVEL)

    # Works
    #win.connect('button-press-event', lambda *args: sys.stdout.write("BP\n"))
    #win.connect('button-release-event', lambda *args: sys.stdout.write("BR\n"))
    #win.connect('motion-notify-event', lambda *args: sys.stdout.write("ME\n"))

    embed = GtkClutter.Embed()
    embed.set_size_request(800, 600)

    # Works
    #embed.connect('button-press-event', lambda *args: sys.stdout.write("BP\n"))
    #embed.connect('button-release-event', lambda *args: sys.stdout.write("BR\n"))
    #embed.connect('motion-notify-event', lambda *args: sys.stdout.write("ME\n"))

    stage = embed.get_stage()
    stage.set_reactive(True)
    stage.set_size(800, 600)
    stage.set_color(Clutter.Color.new(0, 128, 0, 255))

    # Fails
    stage.connect('button-press-event', lambda *args: sys.stdout.write("BP\n"))
    stage.connect('button-release-event', lambda *args: sys.stdout.write("BR\n"))
    stage.connect('motion-event', lambda *args: sys.stdout.write("ME\n"))

    # Works (surprisingly...)
    stage.connect('key-press-event', lambda *args: sys.stdout.write("KP\n"))
    stage.connect('key-release-event', lambda *args: sys.stdout.write("KR\n"))

    stage.show_all()

    win.add(embed)

    win.connect("delete-event", Gtk.main_quit)
    win.show_all()

    Gtk.main()

    return 0

if __name__ == '__main__':
    sys.exit(main())

Is the above code correct? I am wondering whether this is a Windows specific issue. Can anybody reproduce the problem on another OS?

kloffy
  • 2,928
  • 2
  • 25
  • 34
  • 1
    are you getting warnings on the console? if Clutter is compiled with debug support enabled, can you export the `CLUTTER_DEBUG=all` environment variable and pastebin it somewhere? – ebassi Oct 22 '14 at 17:30
  • Unfortunately, it looks like these binaries (PyGI AIO) were not compiled with debug support enabled. I managed to print the framerate with CLUTTER_SHOW_FPS, but setting CLUTTER_DEBUG did not yield any additional output. – kloffy Nov 08 '14 at 06:56

1 Answers1

2

I got this kind of report long time ago by a map apps developer. I suggest him to switch to gdk backend a.k.a

from gi.repository import Clutter
Clutter.set_windowing_backend(Clutter.WINDOWING_GDK)

note: above should be done before other clutter stuff

it should catch events now but still all C examples are working fine without that workaround, so I'm clueless about why it doesn't work at binding level. I think your code also already comform gtk-clutter-test.c as well.

tumagonx
  • 36
  • 3
  • BTW, this is a workaround not an answer, the supposed backend is win32. Switching to gdk may lead to font rendering issue as I recall. – tumagonx Feb 16 '15 at 23:02
  • Yes, that does indeed fix the problem of the events not coming through, interesting. However, sometimes the stage does not show up and I get the following warning now: `Warning: value "0" of type 'gint' is invalid or out of range for property 'window-scaling-factor' of type 'gint'`. – kloffy Feb 17 '15 at 05:45
  • Correction, gtk-clutter-events.c example actually didn't work as expected. While embedded widget received events, the stage itself seems did not. Will try debug this and report upstream. – tumagonx Feb 18 '15 at 11:06
  • window-scaling-factor should set to 1 if not specified but somehow get meddled with argv? setting CLUTTER_SCALE enviroment should override that. BTW is this ok to discuss possible bug at SO? Sorry still noob in SO. – tumagonx Feb 18 '15 at 13:23
  • As long as the discussion contributes towards answering the question, I don't see a problem with it. Yes, having a proper fix would be great. But anyway, setting the environment variable did get rid of the error message too, so I am going to mark this as accepted. Thank you for your help! – kloffy Feb 18 '15 at 14:10