struct shell_pointer_grab_interface
{
void (*motion)(shell_pointer_grab_t *grab,
- int32_t x, int32_t y, uint32_t time, void *data);
+ uint32_t time, int32_t x, int32_t y, void *data);
void (*button)(shell_pointer_grab_t *grab,
- uint32_t button, uint32_t state, uint32_t time, void *data);
+ uint32_t time, uint32_t button, uint32_t state, void *data);
void (*axis)(shell_pointer_grab_t *grab,
uint32_t time, enum wl_pointer_axis axis, wl_fixed_t amount, void *data);
};
char *title, *class_;
+ struct
+ {
+ int32_t px, py; /* Initial pointer position */
+ int32_t vx, vy; /* Initial view position */
+ } move;
+
/* Data structures per surface type */
shell_surface_type_t type; /* Current surface type */
shell_surface_type_t next_type; /* Requested surface type */
void
shell_seat_pointer_end_grab(shell_seat_t *shseat);
+
+void
+shell_surface_move(shell_surface_t *shsurf, pepper_seat_t *seat, uint32_t serial);
#include "desktop-shell-internal.h"
#include "xdg-shell-server-protocol.h"
+
+extern shell_pointer_grab_interface_t shell_pointer_move_grab;
+
void
remove_ping_timer(shell_client_t *shell_client)
{
shsurf->next_type = type;
shsurf->mapped = PEPPER_FALSE;
}
+
+void
+shell_surface_move(shell_surface_t *shsurf, pepper_seat_t *seat, uint32_t serial)
+{
+ shell_seat_t *shseat = pepper_object_get_user_data((pepper_object_t *)seat, shsurf->shell);
+
+ double x, y;
+
+ pepper_view_get_position(shsurf->view, &x, &y);
+ shsurf->move.vx = (int)x;
+ shsurf->move.vy = (int)y;
+
+ pepper_pointer_get_position(shseat->pointer_grab.pointer, &shsurf->move.px, &shsurf->move.py);
+
+ shell_seat_pointer_start_grab(shseat, &shell_pointer_move_grab, shsurf);
+}
}
static void
-shell_pointer_default_grab_motion(shell_pointer_grab_t *grab,
- int32_t x, int32_t y, uint32_t time, void *userdata)
+shell_pointer_move_grab_motion(shell_pointer_grab_t *grab,
+ uint32_t time,
+ int32_t x,
+ int32_t y,
+ void *userdata)
+{
+ pepper_pointer_t *pointer = grab->pointer;
+ shell_surface_t *shsurf = userdata;
+
+ pepper_pointer_set_position(pointer, x, y);
+
+ pepper_view_set_position(shsurf->view,
+ shsurf->move.vx + (x - shsurf->move.px),
+ shsurf->move.vy + (y - shsurf->move.py));
+}
+
+static void
+shell_pointer_move_grab_button(shell_pointer_grab_t *grab,
+ uint32_t time,
+ uint32_t button,
+ uint32_t state,
+ void *userdata)
+{
+ /* FIXME */
+ if (state == WL_POINTER_BUTTON_STATE_RELEASED)
+ {
+ shell_seat_pointer_end_grab(grab->shseat);
+ }
+}
+
+static void
+shell_pointer_move_grab_axis(shell_pointer_grab_t *grab,
+ uint32_t time,
+ enum wl_pointer_axis axis,
+ wl_fixed_t amount,
+ void *userdata)
+{
+ /* TODO */
+}
+
+shell_pointer_grab_interface_t shell_pointer_move_grab =
+{
+ shell_pointer_move_grab_motion,
+ shell_pointer_move_grab_button,
+ shell_pointer_move_grab_axis,
+};
+
+static void
+shell_pointer_default_grab_motion(shell_pointer_grab_t *grab,
+ uint32_t time,
+ int32_t x,
+ int32_t y,
+ void *userdata)
{
/* TODO */
shell_seat_t *shseat = grab->shseat;
}
static void
-shell_pointer_default_grab_button(shell_pointer_grab_t *grab,
- uint32_t button, uint32_t state, uint32_t time, void *userdata)
+shell_pointer_default_grab_button(shell_pointer_grab_t *grab,
+ uint32_t time,
+ uint32_t button,
+ uint32_t state,
+ void *userdata)
{
shell_seat_t *shseat = grab->shseat;
pepper_pointer_t *pointer = pepper_seat_get_pointer(shseat->seat);
}
static void
-wl_shell_surface_move(struct wl_client *client, struct wl_resource *resource,
- struct wl_resource *seat, uint32_t serial)
+wl_shell_surface_move(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *seat_resource,
+ uint32_t serial)
{
- /* TODO */
+ shell_surface_t *shsurf = wl_resource_get_user_data(resource);
+ pepper_seat_t *seat = wl_resource_get_user_data(seat_resource);
+
+ shell_surface_move(shsurf, seat, serial);
}
static void
struct wl_resource *seat_resource,
uint32_t serial)
{
- /* TODO: */
+ shell_surface_t *shsurf = wl_resource_get_user_data(resource);
+ pepper_seat_t *seat = wl_resource_get_user_data(seat_resource);
+
+ if (!seat_resource)
+ {
+ wl_resource_post_error(resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "Invalid seat");
+ return ;
+ }
+ seat = wl_resource_get_user_data(seat_resource);
+
+ shell_surface_move(shsurf, seat, serial);
}
static void