We can use this to test more complex confine regions.

Signed-off-by: Jonas Ådahl <[email protected]>
---
 clients/window.c | 40 +++++++++++++++++++++++++++++++---------
 clients/window.h |  5 +++++
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 9f6816f..c1d2ece 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4671,14 +4671,16 @@ static const struct _wl_confined_pointer_listener 
confined_pointer_listener = {
 };
 
 int
-window_confine_pointer_to_widget(struct window *window,
-                                struct widget *widget,
-                                struct input *input)
+window_confine_pointer_to_rectangles(struct window *window,
+                                    struct input *input,
+                                    struct rectangle *rectangles,
+                                    int num_rectangles)
 {
        struct _wl_pointer_lock *pointer_lock = window->display->pointer_lock;
        struct _wl_confined_pointer *confined_pointer;
        struct wl_compositor *compositor = window->display->compositor;
        struct wl_region *region = NULL;
+       int i;
 
        if (!window->display->pointer_lock)
                return -1;
@@ -4692,13 +4694,15 @@ window_confine_pointer_to_widget(struct window *window,
        if (!input->pointer)
                return -1;
 
-       if (widget) {
+       if (num_rectangles >= 1) {
                region = wl_compositor_create_region(compositor);
-               wl_region_add(region,
-                             widget->allocation.x,
-                             widget->allocation.y,
-                             widget->allocation.width,
-                             widget->allocation.height);
+               for (i = 0; i < num_rectangles; i++) {
+                       wl_region_add(region,
+                                     rectangles[i].x,
+                                     rectangles[i].y,
+                                     rectangles[i].width,
+                                     rectangles[i].height);
+               }
        }
 
        confined_pointer =
@@ -4718,6 +4722,24 @@ window_confine_pointer_to_widget(struct window *window,
        return 0;
 }
 
+int
+window_confine_pointer_to_widget(struct window *window,
+                                struct widget *widget,
+                                struct input *input)
+{
+       if (widget) {
+               return window_confine_pointer_to_rectangles(window,
+                                                           input,
+                                                           &widget->allocation,
+                                                           1);
+       } else {
+               return window_confine_pointer_to_rectangles(window,
+                                                           input,
+                                                           NULL,
+                                                           0);
+       }
+}
+
 void
 window_unconfine_pointer(struct window *window)
 {
diff --git a/clients/window.h b/clients/window.h
index 7d2ac95..8042954 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -386,6 +386,11 @@ widget_set_locked_pointer_cursor_hint(struct widget 
*widget,
                                      float x, float y);
 
 int
+window_confine_pointer_to_rectangles(struct window *window,
+                                    struct input *input,
+                                    struct rectangle *rectangles,
+                                    int num_rectangles);
+
 int
 window_confine_pointer_to_widget(struct window *window,
                                 struct widget *widget,
-- 
2.1.4

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to