How to use regions?

Asked by H. Guijt

Could someone please be kind enough to explain how to use regions?

I would like to receive gesture events on some of my (sub)windows, so I try to create a subscription somewhat like this:

      mywindowid = XCreateWindow (....);
       Subscription = geis_subscription_new (Geis, "subscription", GEIS_SUBSCRIPTION_CONT);
        Filter = geis_filter_new (Geis, "filter");
        Region = geis_region_new (Geis, "region", GEIS_REGION_X11_WINDOWID, mywindowid, nullptr);

        geis_filter_add_term (Filter, GEIS_FILTER_CLASS,
            GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_DRAG,
            GEIS_REGION_ATTRIBUTE_WINDOWID, GEIS_FILTER_OP_EQ, Region, // (*)
            GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_LE, 2,
            nullptr);

      geis_filter_add_term (Filter, GEIS_FILTER_CLASS,
            GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_PINCH,
            GEIS_REGION_ATTRIBUTE_WINDOWID, GEIS_FILTER_OP_EQ, Region, // (*)
            GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, 2,
            nullptr);

        geis_subscription_add_filter (Subscription, Filter);
        geis_subscription_activate (Subscription);

This works, as long as I leave out the lines marked (*). Of course in that case I have not restricted my gestures to one region, instead catching them system wide (and exclusively, apparently - other applications no longer seem to receive gestures once my application is running).

What is the appropriate way for doing this?

Once I delete the subscription, will the filter and region automatically be deleted as well, or do I need to clean them up manually?

Is there any significance to the names for the various items like "subscription", "filter", and "region"?

Thanks in advance!

Question information

Language:
English Edit question
Status:
Answered
For:
Geis Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
H. Guijt (hg-p) said :
#1

Anyone, please?

If the problem is that I'm somehow not following the proper procedure, please be kind enough to help me with that, at least...

Revision history for this message
Stephen M. Webb (bregma) said :
#2

(1) Try passing "(GeisInteger*)&mywindowid" instead of "Region" to the geis_filter_add_term() call and see what happens.

(2) The names are not significant but should be unique.

Revision history for this message
H. Guijt (hg-p) said :
#3

I've tried that. I get the exact same error messages as before (-100). After studying the library source itself for a bit I've come to believe that your solution is incorrect; the window ID should be passed directly, not as a pointer.

After some more experimentation and reading of library code, I've come to believe that Geis cannot set subscriptions on both gesture classes and individual windows simultaneously; it is either on specific classes (but always full screen), or on specific windows (but always all classes). Moreover, Geis cannot set subscriptions on anything that is not a top-level window. Only top-level windows can be subscribed as a region.

Is it possible I'm simply using the wrong library? I want to capture gesture events for specific controls - I have a set of graphs on screen that I want to zoom in and out, and move around, using gestures, but each graph is a control, not a top-level window. I originally thought Geis would be able to handle this for me, but maybe that was never its intended purpose?

Revision history for this message
H. Guijt (hg-p) said :
#4

As a follow-on question: is it correct that windows that have a gesture subscription (with the region limited to the window) no longer receive emulated mouse pointer events from non-gesture touches? Or is this a sign of me doing something wrong? If so, what?

Revision history for this message
Amit Nayar (amit-nyr) said :
#5

I am also struggling to use regions. I would like to restrict the gesture filters to a specific window and allow for multiple gesture regions within the window.

Revision history for this message
Amit Nayar (amit-nyr) said :
#6

Is this a case where we use GEIS_FILTER_REGION instead of GEIS_FILTER_CLASS on the filter?

Revision history for this message
H. Guijt (hg-p) said :
#7

I've managed to get a little bit further... The main problem I was running into is that GEIS does not allow filtering on non-toplevel windows. So setting a filter on a toplevel window is fine, and can be combined with further filters in the same subscription on specific gesture classes, but I have not found a way to specify a filter down to childwindow level. For me this is fine: once I receive the event for a toplevel window I can forward it to the relevant child window myself. I would suggest you do the same.

Actually, scratch that earlier remark: the main problem I ran into is that the documentation for this library is such a pile of shit - turned what should have been a few hours effort into more than a week of trial and error.

Revision history for this message
H. Guijt (hg-p) said :
#8

Anyway, try something like this:

Window SomeTopLevelWindow = ...;

geis_filter_add_term (MyFilter, GEIS_FILTER_REGION,
GEIS_REGION_ATTRIBUTE_WINDOWID, GEIS_FILTER_OP_EQ, SomeTopLevelWindow,
nullptr);

geis_filter_add_term (MyFilter, GEIS_FILTER_CLASS,
GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_TAP,
GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, 2,
nullptr);

Revision history for this message
Amit Nayar (amit-nyr) said :
#9

Thanks a lot. Yes I've been battling with the documentation for the past week and not getting very far. It's pretty shocking!

So that seems to work. I was getting confused with how to create a filter with both a region and a class - It didn't help that I was using the GEIS_REGION_X11_WINDOWID instead of GEIS_REGION_ATTRIBUTE_WINDOWID.
Anyway thanks for your help.

Can you help with this problem?

Provide an answer of your own, or ask H. Guijt for more information if necessary.

To post a message you must log in.