Send out coordinates with pointer_focus event
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 6 Aug 2010 19:12:22 +0000 (15:12 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 6 Aug 2010 19:12:26 +0000 (15:12 -0400)
We can't rely on motion events happening right away, pointer_focus could
change because of windows coming or going etc.

TODO
clients/window.c
compositor.c
protocol.xml
wayland-client.c

diff --git a/TODO b/TODO
index 7c555cb..84fad7c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
 Core wayland protocol
 
- - enter notify needs coordinates for cases where pointer focus
-   changes without motion (surfaces coming or going)
+ - generate pointer_focus on raise/lower, move windows, all kinds of
+   changes in surface stacking.
 
  - generate marshal stubs as static inline functions.
 
index c01ca05..b2c4f03 100644 (file)
@@ -400,7 +400,8 @@ window_handle_key(void *data, struct wl_input_device *input_device,
 static void
 window_handle_pointer_focus(void *data,
                            struct wl_input_device *input_device,
-                           uint32_t time, struct wl_surface *surface)
+                           uint32_t time, struct wl_surface *surface,
+                           int32_t x, int32_t y, int32_t sx, int32_t sy)
 {
        struct input *input = data;
 
index 0ce2d09..6d7a627 100644 (file)
@@ -641,7 +641,9 @@ wlsc_input_device_set_keyboard_focus(struct wlsc_input_device *device,
 static void
 wlsc_input_device_set_pointer_focus(struct wlsc_input_device *device,
                                    struct wlsc_surface *surface,
-                                   uint32_t time)
+                                   uint32_t time,
+                                   int32_t x, int32_t y,
+                                   int32_t sx, int32_t sy)
 {
        if (device->pointer_focus == surface)
                return;
@@ -651,12 +653,13 @@ wlsc_input_device_set_pointer_focus(struct wlsc_input_device *device,
                wl_surface_post_event(&device->pointer_focus->base,
                                      &device->base,
                                      WL_INPUT_DEVICE_POINTER_FOCUS,
-                                     time, NULL);
+                                     time, NULL, 0, 0, 0, 0);
        if (surface)
                wl_surface_post_event(&surface->base,
                                      &device->base,
                                      WL_INPUT_DEVICE_POINTER_FOCUS,
-                                     time, &surface->base);
+                                     time, &surface->base,
+                                     x, y, sx, sy);
 
        device->pointer_focus = surface;
 }
@@ -711,7 +714,8 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
        case WLSC_DEVICE_GRAB_MOTION:
                es = pick_surface(device, &sx, &sy);
 
-               wlsc_input_device_set_pointer_focus(device, es, time);
+               wlsc_input_device_set_pointer_focus(device, es,
+                                                   time, x, y, sx, sy);
 
                if (es)
                        wl_surface_post_event(&es->base, &device->base,
@@ -806,6 +810,12 @@ notify_button(struct wlsc_input_device *device,
                    (device->modifier_state & MODIFIER_SUPER))
                        shell_move(NULL, &compositor->shell,
                                   &surface->base, device, time);
+               else if (state && button == BTN_MIDDLE &&
+                        device->grab == WLSC_DEVICE_GRAB_MOTION &&
+                        (device->modifier_state & MODIFIER_SUPER))
+                       shell_resize(NULL, &compositor->shell,
+                                    &surface->base, device, time,
+                                    WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT);
                else
                        wl_surface_post_event(&surface->base, &device->base,
                                              WL_INPUT_DEVICE_BUTTON,
@@ -896,7 +906,9 @@ handle_surface_destroy(struct wlsc_listener *listener,
        if (device->pointer_focus == surface) {
                device->grab = WLSC_DEVICE_GRAB_NONE;
                focus = pick_surface(device, &sx, &sy);
-               wlsc_input_device_set_pointer_focus(device, focus, time);
+               wlsc_input_device_set_pointer_focus(device, focus, time,
+                                                   device->x, device->y,
+                                                   sx, sy);
                fprintf(stderr, "lost pointer focus surface, reverting to %p\n", focus);
        }
 }
index a0c32a7..50a3480 100644 (file)
     <event name="pointer_focus">
       <arg name="time" type="uint"/>
       <arg name="surface" type="surface"/>
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+      <arg name="surface_x" type="int"/>
+      <arg name="surface_y" type="int"/>
     </event>
 
     <event name="keyboard_focus">
index 5ac6541..b55511e 100644 (file)
@@ -81,8 +81,6 @@ struct wl_visual {
 
 struct wl_output {
        struct wl_proxy proxy;
-       struct wl_listener listener;
-       int32_t width, height;
 };
 
 struct wl_shell {